@swyger/client
Version:
Swyger Client JS library is used for Swyger Server as consumer Rest API(authentication,CRUD, Storage...)! Visit the master branch: https://github.com/coorise/swyger-js-client.git
1 lines • 981 kB
JavaScript
var A1=Object.defineProperty,S1=Object.defineProperties,T1=Object.getOwnPropertyDescriptors,Of=Object.getOwnPropertySymbols,P1=Object.prototype.hasOwnProperty,j1=Object.prototype.propertyIsEnumerable,nu=(n,e,t)=>e in n?A1(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,pe=(n,e)=>{for(var t in e||(e={}))P1.call(e,t)&&nu(n,t,e[t]);if(Of)for(var t of Of(e))j1.call(e,t)&&nu(n,t,e[t]);return n},It=(n,e)=>S1(n,T1(e)),C1=(n,e,t)=>(nu(n,typeof e!="symbol"?e+"":e,t),t),eg=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},zn=(n,e,t)=>(eg(n,e,"read from private field"),t?t.call(n):e.get(n)),uo=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},rl=(n,e,t,r)=>(eg(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),z=(n,e,t)=>new Promise((r,i)=>{var o=c=>{try{a(t.next(c))}catch(l){i(l)}},s=c=>{try{a(t.throw(c))}catch(l){i(l)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,s);a((t=t.apply(n,e)).next())});const er=Object.create(null);er.open="0";er.close="1";er.ping="2";er.pong="3";er.message="4";er.upgrade="5";er.noop="6";const Ys=Object.create(null);Object.keys(er).forEach(n=>{Ys[er[n]]=n});const R1={type:"error",data:"parser error"},I1=typeof Blob=="function"||typeof Blob!="undefined"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",N1=typeof ArrayBuffer=="function",B1=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,tg=({type:n,data:e},t,r)=>I1&&e instanceof Blob?t?r(e):Af(e,r):N1&&(e instanceof ArrayBuffer||B1(e))?t?r(e):Af(new Blob([e]),r):r(er[n]+(e||"")),Af=(n,e)=>{const t=new FileReader;return t.onload=function(){const r=t.result.split(",")[1];e("b"+(r||""))},t.readAsDataURL(n)},Sf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xo=typeof Uint8Array=="undefined"?[]:new Uint8Array(256);for(let n=0;n<Sf.length;n++)xo[Sf.charCodeAt(n)]=n;const L1=n=>{let e=n.length*.75,t=n.length,r,i=0,o,s,a,c;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);const l=new ArrayBuffer(e),u=new Uint8Array(l);for(r=0;r<t;r+=4)o=xo[n.charCodeAt(r)],s=xo[n.charCodeAt(r+1)],a=xo[n.charCodeAt(r+2)],c=xo[n.charCodeAt(r+3)],u[i++]=o<<2|s>>4,u[i++]=(s&15)<<4|a>>2,u[i++]=(a&3)<<6|c&63;return l},D1=typeof ArrayBuffer=="function",ng=(n,e)=>{if(typeof n!="string")return{type:"message",data:rg(n,e)};const t=n.charAt(0);return t==="b"?{type:"message",data:U1(n.substring(1),e)}:Ys[t]?n.length>1?{type:Ys[t],data:n.substring(1)}:{type:Ys[t]}:R1},U1=(n,e)=>{if(D1){const t=L1(n);return rg(t,e)}else return{base64:!0,data:n}},rg=(n,e)=>{switch(e){case"blob":return n instanceof ArrayBuffer?new Blob([n]):n;case"arraybuffer":default:return n}},ig=String.fromCharCode(30),q1=(n,e)=>{const t=n.length,r=new Array(t);let i=0;n.forEach((o,s)=>{tg(o,!1,a=>{r[s]=a,++i===t&&e(r.join(ig))})})},V1=(n,e)=>{const t=n.split(ig),r=[];for(let i=0;i<t.length;i++){const o=ng(t[i],e);if(r.push(o),o.type==="error")break}return r},og=4;function lt(n){if(n)return M1(n)}function M1(n){for(var e in lt.prototype)n[e]=lt.prototype[e];return n}lt.prototype.on=lt.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};lt.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this};lt.prototype.off=lt.prototype.removeListener=lt.prototype.removeAllListeners=lt.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var r,i=0;i<t.length;i++)if(r=t[i],r===e||r.fn===e){t.splice(i,1);break}return t.length===0&&delete this._callbacks["$"+n],this};lt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+n],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(t){t=t.slice(0);for(var r=0,i=t.length;r<i;++r)t[r].apply(this,e)}return this};lt.prototype.emitReserved=lt.prototype.emit;lt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};lt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const xn=(()=>typeof self!="undefined"?self:typeof window!="undefined"?window:Function("return this")())();function sg(n,...e){return e.reduce((t,r)=>(n.hasOwnProperty(r)&&(t[r]=n[r]),t),{})}const F1=xn.setTimeout,W1=xn.clearTimeout;function Qa(n,e){e.useNativeTimers?(n.setTimeoutFn=F1.bind(xn),n.clearTimeoutFn=W1.bind(xn)):(n.setTimeoutFn=xn.setTimeout.bind(xn),n.clearTimeoutFn=xn.clearTimeout.bind(xn))}const z1=1.33;function K1(n){return typeof n=="string"?H1(n):Math.ceil((n.byteLength||n.size)*z1)}function H1(n){let e=0,t=0;for(let r=0,i=n.length;r<i;r++)e=n.charCodeAt(r),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(r++,t+=4);return t}class J1 extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}}class ag extends lt{constructor(e){super(),this.writable=!1,Qa(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new J1(e,t,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=ng(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}}const cg="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),ru=64,Y1={};let Tf=0,Os=0,Pf;function jf(n){let e="";do e=cg[n%ru]+e,n=Math.floor(n/ru);while(n>0);return e}function lg(){const n=jf(+new Date);return n!==Pf?(Tf=0,Pf=n):n+"."+jf(Tf++)}for(;Os<ru;Os++)Y1[cg[Os]]=Os;function ug(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function G1(n){let e={},t=n.split("&");for(let r=0,i=t.length;r<i;r++){let o=t[r].split("=");e[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return e}let hg=!1;try{hg=typeof XMLHttpRequest!="undefined"&&"withCredentials"in new XMLHttpRequest}catch(n){}const X1=hg;function dg(n){const e=n.xdomain;try{if(typeof XMLHttpRequest!="undefined"&&(!e||X1))return new XMLHttpRequest}catch(t){}if(!e)try{return new xn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch(t){}}function Q1(){}const Z1=function(){return new dg({xdomain:!1}).responseType!=null}();class ek extends ag{constructor(e){if(super(e),this.polling=!1,typeof location!="undefined"){const r=location.protocol==="https:";let i=location.port;i||(i=r?"443":"80"),this.xd=typeof location!="undefined"&&e.hostname!==location.hostname||i!==e.port,this.xs=e.secure!==r}const t=e&&e.forceBase64;this.supportsBinary=Z1&&!t}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(r++,this.once("pollComplete",function(){--r||t()})),this.writable||(r++,this.once("drain",function(){--r||t()}))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const t=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};V1(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,q1(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.query||{};const t=this.opts.secure?"https":"http";let r="";this.opts.timestampRequests!==!1&&(e[this.opts.timestampParam]=lg()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.opts.port&&(t==="https"&&Number(this.opts.port)!==443||t==="http"&&Number(this.opts.port)!==80)&&(r=":"+this.opts.port);const i=ug(e),o=this.opts.hostname.indexOf(":")!==-1;return t+"://"+(o?"["+this.opts.hostname+"]":this.opts.hostname)+r+this.opts.path+(i.length?"?"+i:"")}request(e={}){return Object.assign(e,{xd:this.xd,xs:this.xs},this.opts),new Xn(this.uri(),e)}doWrite(e,t){const r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(i,o)=>{this.onError("xhr post error",i,o)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,r)=>{this.onError("xhr poll error",t,r)}),this.pollXhr=e}}class Xn extends lt{constructor(e,t){super(),Qa(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.async=t.async!==!1,this.data=t.data!==void 0?t.data:null,this.create()}create(){const e=sg(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;const t=this.xhr=new dg(e);try{t.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0);for(let r in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(r)&&t.setRequestHeader(r,this.opts.extraHeaders[r])}}catch(r){}if(this.method==="POST")try{t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(r){}try{t.setRequestHeader("Accept","*/*")}catch(r){}"withCredentials"in t&&(t.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(t.timeout=this.opts.requestTimeout),t.onreadystatechange=()=>{t.readyState===4&&(t.status===200||t.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof t.status=="number"?t.status:0)},0))},t.send(this.data)}catch(r){this.setTimeoutFn(()=>{this.onError(r)},0);return}typeof document!="undefined"&&(this.index=Xn.requestsCount++,Xn.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr=="undefined"||this.xhr===null)){if(this.xhr.onreadystatechange=Q1,e)try{this.xhr.abort()}catch(t){}typeof document!="undefined"&&delete Xn.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}Xn.requestsCount=0;Xn.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",Cf);else if(typeof addEventListener=="function"){const n="onpagehide"in xn?"pagehide":"unload";addEventListener(n,Cf,!1)}}function Cf(){for(let n in Xn.requests)Xn.requests.hasOwnProperty(n)&&Xn.requests[n].abort()}const fg=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?n=>Promise.resolve().then(n):(n,e)=>e(n,0))(),As=xn.WebSocket||xn.MozWebSocket,Rf=!0,tk="arraybuffer",If=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class nk extends ag{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,r=If?{}:sg(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=Rf&&!If?t?new As(e,t):new As(e):new As(e,t,r)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType||tk,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],i=t===e.length-1;tg(r,this.supportsBinary,o=>{try{Rf&&this.ws.send(o)}catch(s){}i&&fg(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws!="undefined"&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{};const t=this.opts.secure?"wss":"ws";let r="";this.opts.port&&(t==="wss"&&Number(this.opts.port)!==443||t==="ws"&&Number(this.opts.port)!==80)&&(r=":"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=lg()),this.supportsBinary||(e.b64=1);const i=ug(e),o=this.opts.hostname.indexOf(":")!==-1;return t+"://"+(o?"["+this.opts.hostname+"]":this.opts.hostname)+r+this.opts.path+(i.length?"?"+i:"")}check(){return!!As}}const rk={websocket:nk,polling:ek},ik=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ok=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function iu(n){const e=n,t=n.indexOf("["),r=n.indexOf("]");t!=-1&&r!=-1&&(n=n.substring(0,t)+n.substring(t,r).replace(/:/g,";")+n.substring(r,n.length));let i=ik.exec(n||""),o={},s=14;for(;s--;)o[ok[s]]=i[s]||"";return t!=-1&&r!=-1&&(o.source=e,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=sk(o,o.path),o.queryKey=ak(o,o.query),o}function sk(n,e){const t=/\/{2,9}/g,r=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function ak(n,e){const t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,i,o){i&&(t[i]=o)}),t}class Dr extends lt{constructor(e,t={}){super(),this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=iu(e),t.hostname=e.host,t.secure=e.protocol==="https"||e.protocol==="wss",t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=iu(t.host).host),Qa(this,t),this.secure=t.secure!=null?t.secure:typeof location!="undefined"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location!="undefined"?location.hostname:"localhost"),this.port=t.port||(typeof location!="undefined"&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket"],this.writeBuffer=[],this.prevBufferLen=0,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:!0},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=G1(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=og,t.transport=e,this.id&&(t.sid=this.id);const r=Object.assign({},this.opts.transportOptions[e],this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new rk[e](r)}open(){let e;if(this.opts.rememberUpgrade&&Dr.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch(t){this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.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))}probe(e){let t=this.createTransport(e),r=!1;Dr.priorWebsocketSuccess=!1;const i=()=>{r||(t.send([{type:"ping",data:"probe"}]),t.once("packet",h=>{if(!r)if(h.type==="pong"&&h.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Dr.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(u(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const y=new Error("probe error");y.transport=t.name,this.emitReserved("upgradeError",y)}}))};function o(){r||(r=!0,u(),t.close(),t=null)}const s=h=>{const y=new Error("probe error: "+h);y.transport=t.name,o(),this.emitReserved("upgradeError",y)};function a(){s("transport closed")}function c(){s("socket closed")}function l(h){t&&h.name!==t.name&&o()}const u=()=>{t.removeListener("open",i),t.removeListener("error",s),t.removeListener("close",a),this.off("close",c),this.off("upgrading",l)};t.once("open",i),t.once("error",s),t.once("close",a),this.once("close",c),this.once("upgrading",l),t.open()}onOpen(){if(this.readyState="open",Dr.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.resetPingTimeout(),this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){const r=this.writeBuffer[t].data;if(r&&(e+=K1(r)),t>0&&e>this.maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}write(e,t,r){return this.sendPacket("message",e,t,r),this}send(e,t,r){return this.sendPacket("message",e,t,r),this}sendPacket(e,t,r,i){if(typeof t=="function"&&(i=t,t=void 0),typeof r=="function"&&(i=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const o={type:e,data:t,options:r};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},r=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}onError(e){Dr.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let r=0;const i=e.length;for(;r<i;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}}Dr.protocol=og;function ck(n,e="",t){let r=n;t=t||typeof location!="undefined"&&location,n==null&&(n=t.protocol+"//"+t.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=t.protocol+n:n=t.host+n),/^(https?|wss?):\/\//.test(n)||(typeof t!="undefined"?n=t.protocol+"//"+n:n="https://"+n),r=iu(n)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+e,r.href=r.protocol+"://"+i+(t&&t.port===r.port?"":":"+r.port),r}const lk=typeof ArrayBuffer=="function",uk=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,pg=Object.prototype.toString,hk=typeof Blob=="function"||typeof Blob!="undefined"&&pg.call(Blob)==="[object BlobConstructor]",dk=typeof File=="function"||typeof File!="undefined"&&pg.call(File)==="[object FileConstructor]";function $h(n){return lk&&(n instanceof ArrayBuffer||uk(n))||hk&&n instanceof Blob||dk&&n instanceof File}function Gs(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0,r=n.length;t<r;t++)if(Gs(n[t]))return!0;return!1}if($h(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return Gs(n.toJSON(),!0);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&Gs(n[t]))return!0;return!1}function fk(n){const e=[],t=n.data,r=n;return r.data=ou(t,e),r.attachments=e.length,{packet:r,buffers:e}}function ou(n,e){if(!n)return n;if($h(n)){const t={_placeholder:!0,num:e.length};return e.push(n),t}else if(Array.isArray(n)){const t=new Array(n.length);for(let r=0;r<n.length;r++)t[r]=ou(n[r],e);return t}else if(typeof n=="object"&&!(n instanceof Date)){const t={};for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=ou(n[r],e));return t}return n}function pk(n,e){return n.data=su(n.data,e),delete n.attachments,n}function su(n,e){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<e.length)return e[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t]=su(n[t],e);else if(typeof n=="object")for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(n[t]=su(n[t],e));return n}const yk=5;var Re;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Re||(Re={}));class gk{constructor(e){this.replacer=e}encode(e){return(e.type===Re.EVENT||e.type===Re.ACK)&&Gs(e)?this.encodeAsBinary({type:e.type===Re.EVENT?Re.BINARY_EVENT:Re.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===Re.BINARY_EVENT||e.type===Re.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=fk(e),r=this.encodeAsString(t.packet),i=t.buffers;return i.unshift(r),i}}class Oh extends lt{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const r=t.type===Re.BINARY_EVENT;r||t.type===Re.BINARY_ACK?(t.type=r?Re.EVENT:Re.ACK,this.reconstructor=new mk(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if($h(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0;const r={type:Number(e.charAt(0))};if(Re[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===Re.BINARY_EVENT||r.type===Re.BINARY_ACK){const o=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);const s=e.substring(o,t);if(s!=Number(s)||e.charAt(t)!=="-")throw new Error("Illegal attachments");r.attachments=Number(s)}if(e.charAt(t+1)==="/"){const o=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););r.nsp=e.substring(o,t)}else r.nsp="/";const i=e.charAt(t+1);if(i!==""&&Number(i)==i){const o=t+1;for(;++t;){const s=e.charAt(t);if(s==null||Number(s)!=s){--t;break}if(t===e.length)break}r.id=Number(e.substring(o,t+1))}if(e.charAt(++t)){const o=this.tryParse(e.substr(t));if(Oh.isPayloadValid(r.type,o))r.data=o;else throw new Error("invalid payload")}return r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(t){return!1}}static isPayloadValid(e,t){switch(e){case Re.CONNECT:return typeof t=="object";case Re.DISCONNECT:return t===void 0;case Re.CONNECT_ERROR:return typeof t=="string"||typeof t=="object";case Re.EVENT:case Re.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="string"||typeof t[0]=="number");case Re.ACK:case Re.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class mk{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const t=pk(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const vk=Object.freeze(Object.defineProperty({__proto__:null,protocol:yk,get PacketType(){return Re},Encoder:gk,Decoder:Oh},Symbol.toStringTag,{value:"Module"}));function Rn(n,e,t){return n.on(e,t),function(){n.off(e,t)}}const bk=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class yg extends lt{constructor(e,t,r){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=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Rn(e,"open",this.onopen.bind(this)),Rn(e,"packet",this.onpacket.bind(this)),Rn(e,"error",this.onerror.bind(this)),Rn(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(bk.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const r={type:Re.EVENT,data:t};if(r.options={},r.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const o=this.ids++,s=t.pop();this._registerAckCallback(o,s),r.id=o}const i=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!i||!this.connected)||(this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(e,t){var r;const i=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(i===void 0){this.acks[e]=t;return}const o=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let s=0;s<this.sendBuffer.length;s++)this.sendBuffer[s].id===e&&this.sendBuffer.splice(s,1);t.call(this,new Error("operation has timed out"))},i);this.acks[e]=(...s)=>{this.io.clearTimeoutFn(o),t.apply(this,[null,...s])}}emitWithAck(e,...t){const r=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((i,o)=>{t.push((s,a)=>r?s?o(s):i(a):i(s)),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...o)=>r!==this._queue[0]?void 0:(i!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(i)):(this._queue.shift(),t&&t(null,...o)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Re.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Re.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.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 Re.EVENT:case Re.BINARY_EVENT:this.onevent(e);break;case Re.ACK:case Re.BINARY_ACK:this.onack(e);break;case Re.DISCONNECT:this.ondisconnect();break;case Re.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t);break}}onevent(e){const t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let r=!1;return function(...i){r||(r=!0,t.packet({type:Re.ACK,id:e,data:i}))}}onack(e){const t=this.acks[e.id];typeof t=="function"&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Re.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const r of t)r.apply(this,e.data)}}}function Gi(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}Gi.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*n);n=(Math.floor(e*10)&1)==0?n-t:n+t}return Math.min(n,this.max)|0};Gi.prototype.reset=function(){this.attempts=0};Gi.prototype.setMin=function(n){this.ms=n};Gi.prototype.setMax=function(n){this.max=n};Gi.prototype.setJitter=function(n){this.jitter=n};class au extends lt{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,Qa(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((r=t.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new Gi({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;const i=t.parser||vk;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new Dr(this.uri,this.opts);const t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=Rn(t,"open",function(){r.onopen(),e&&e()}),o=Rn(t,"error",s=>{r.cleanup(),r._readyState="closed",this.emitReserved("error",s),e?e(s):r.maybeReconnectOnOpen()});if(this._timeout!==!1){const s=this._timeout;s===0&&i();const a=this.setTimeoutFn(()=>{i(),t.close(),t.emit("error",new Error("timeout"))},s);this.opts.autoUnref&&a.unref(),this.subs.push(function(){clearTimeout(a)})}return this.subs.push(i),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Rn(e,"ping",this.onping.bind(this)),Rn(e,"data",this.ondata.bind(this)),Rn(e,"error",this.onerror.bind(this)),Rn(e,"close",this.onclose.bind(this)),Rn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){fg(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new yg(this,e,t),this.nsps[e]=r),r}_destroy(e){const t=Object.keys(this.nsps);for(const r of t)if(this.nsps[r].active)return;this._close()}_packet(e){const t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(t[r],e.options)}cleanup(){this.subs.forEach(e=>e()),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(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},t);this.opts.autoUnref&&r.unref(),this.subs.push(function(){clearTimeout(r)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const ho={};function Xs(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const t=ck(n,e.path||"/socket.io"),r=t.source,i=t.id,o=t.path,s=ho[i]&&o in ho[i].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||s;let c;return a?c=new au(r,e):(ho[i]||(ho[i]=new au(r,e)),c=ho[i]),t.query&&!e.query&&(e.query=t.queryKey),c.socket(t.path,e)}Object.assign(Xs,{Manager:au,Socket:yg,io:Xs,connect:Xs});const wk={init:({API_KEY:n,HOST_SERVER:e,CURRENT:t,ENV:r,API_VERSION:i})=>{var o,s;let a={};const c=localStorage.getItem("accessToken");try{const l={Accept:"application/json","Content-Type":"application/json","Access-Control-Allow-Origin":"*","Access-Key":n,"Access-Control-Allow-Methods":"POST, GET, OPTIONS, PUT, DELETE, HEAD,PATCH","Access-Control-Allow-Headers":"X-PINGOTHER, Origin, X-Requested-With, Content-Type, Accept","Access-Control-Max-Age":"1728000"};return c&&(l.Authorization="Bearer "+c),a.auth=Xs(e.AUTH,{extraHeaders:l}),(o=a==null?void 0:a.auth)==null||o.on("connect",()=>{var u,h,y,d,f;r==="dev"&&console.log("Swyger Auth Client JS is connected with Swyger Server!!!");let p=JSON.parse(localStorage.getItem("userInfo")?localStorage.getItem("userInfo"):"{}");p.uid&&(u=a.auth)!=null&&u.id&&(r==="dev"&&console.log("The socket device id is: ",(h=a.auth)==null?void 0:h.id),(d=a==null?void 0:a.auth)==null||d.emit((i==null?void 0:i.AUTH)+"/user/join",{socketId:(y=a.auth)==null?void 0:y.id,currentUserId:p.uid}),(f=a==null?void 0:a.auth)==null||f.on((i==null?void 0:i.AUTH)+"/user/status",v=>{if(p.status!=="online"){let w;v.from===p.uid&&(w=v==null?void 0:v.value),w!=null&&w.status&&(r==="dev"&&console.log("user is online: ",w),p.status=w.status,localStorage.setItem("userInfo",JSON.stringify(p)))}}))}),(s=a==null?void 0:a.auth)==null||s.on("disconnect",u=>{r==="dev"&&console.log("The device is disconnected from Auth server!");let h=JSON.parse(localStorage.getItem("userInfo")?localStorage.getItem("userInfo"):"{}");h.uid&&h.status!=="offline"&&(h.status="offline",localStorage.setItem("userInfo",JSON.stringify(h)))}),a}catch(l){}}};function cu(n){this.message=n}cu.prototype=new Error,cu.prototype.name="InvalidCharacterError";var Nf=typeof window!="undefined"&&window.atob&&window.atob.bind(window)||function(n){var e=String(n).replace(/=+$/,"");if(e.length%4==1)throw new cu("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,r,i=0,o=0,s="";r=e.charAt(o++);~r&&(t=i%4?64*t+r:r,i++%4)?s+=String.fromCharCode(255&t>>(-2*i&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return s};function kk(n){var e=n.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Nf(t).replace(/(.)/g,function(r,i){var o=i.charCodeAt(0).toString(16).toUpperCase();return o.length<2&&(o="0"+o),"%"+o}))}(e)}catch(t){return Nf(e)}}function Ia(n){this.message=n}function xk(n,e){if(typeof n!="string")throw new Ia("Invalid token specified");var t=(e=e||{}).header===!0?0:1;try{return JSON.parse(kk(n.split(".")[t]))}catch(r){throw new Ia("Invalid token specified: "+r.message)}}Ia.prototype=new Error,Ia.prototype.name="InvalidTokenError";function gg(n,e){return function(){return n.apply(e,arguments)}}const{toString:Ek}=Object.prototype,{getPrototypeOf:Ah}=Object,Za=(n=>e=>{const t=Ek.call(e);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),rr=n=>(n=n.toLowerCase(),e=>Za(e)===n),ec=n=>e=>typeof e===n,{isArray:Xi}=Array,No=ec("undefined");function _k(n){return n!==null&&!No(n)&&n.constructor!==null&&!No(n.constructor)&&$n(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const mg=rr("ArrayBuffer");function $k(n){let e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&mg(n.buffer),e}const Ok=ec("string"),$n=ec("function"),vg=ec("number"),tc=n=>n!==null&&typeof n=="object",Ak=n=>n===!0||n===!1,Qs=n=>{if(Za(n)!=="object")return!1;const e=Ah(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)},Sk=rr("Date"),Tk=rr("File"),Pk=rr("Blob"),jk=rr("FileList"),Ck=n=>tc(n)&&$n(n.pipe),Rk=n=>{let e;return n&&(typeof FormData=="function"&&n instanceof FormData||$n(n.append)&&((e=Za(n))==="formdata"||e==="object"&&$n(n.toString)&&n.toString()==="[object FormData]"))},Ik=rr("URLSearchParams"),Nk=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function os(n,e,{allOwnKeys:t=!1}={}){if(n===null||typeof n=="undefined")return;let r,i;if(typeof n!="object"&&(n=[n]),Xi(n))for(r=0,i=n.length;r<i;r++)e.call(null,n[r],r,n);else{const o=t?Object.getOwnPropertyNames(n):Object.keys(n),s=o.length;let a;for(r=0;r<s;r++)a=o[r],e.call(null,n[a],a,n)}}function bg(n,e){e=e.toLowerCase();const t=Object.keys(n);let r=t.length,i;for(;r-- >0;)if(i=t[r],e===i.toLowerCase())return i;return null}const wg=(()=>typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global)(),kg=n=>!No(n)&&n!==wg;function lu(){const{caseless:n}=kg(this)&&this||{},e={},t=(r,i)=>{const o=n&&bg(e,i)||i;Qs(e[o])&&Qs(r)?e[o]=lu(e[o],r):Qs(r)?e[o]=lu({},r):Xi(r)?e[o]=r.slice():e[o]=r};for(let r=0,i=arguments.length;r<i;r++)arguments[r]&&os(arguments[r],t);return e}const Bk=(n,e,t,{allOwnKeys:r}={})=>(os(e,(i,o)=>{t&&$n(i)?n[o]=gg(i,t):n[o]=i},{allOwnKeys:r}),n),Lk=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),Dk=(n,e,t,r)=>{n.prototype=Object.create(e.prototype,r),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:e.prototype}),t&&Object.assign(n.prototype,t)},Uk=(n,e,t,r)=>{let i,o,s;const a={};if(e=e||{},n==null)return e;do{for(i=Object.getOwnPropertyNames(n),o=i.length;o-- >0;)s=i[o],(!r||r(s,n,e))&&!a[s]&&(e[s]=n[s],a[s]=!0);n=t!==!1&&Ah(n)}while(n&&(!t||t(n,e))&&n!==Object.prototype);return e},qk=(n,e,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=e.length;const r=n.indexOf(e,t);return r!==-1&&r===t},Vk=n=>{if(!n)return null;if(Xi(n))return n;let e=n.length;if(!vg(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=n[e];return t},Mk=(n=>e=>n&&e instanceof n)(typeof Uint8Array!="undefined"&&Ah(Uint8Array)),Fk=(n,e)=>{const t=(n&&n[Symbol.iterator]).call(n);let r;for(;(r=t.next())&&!r.done;){const i=r.value;e.call(n,i[0],i[1])}},Wk=(n,e)=>{let t;const r=[];for(;(t=n.exec(e))!==null;)r.push(t);return r},zk=rr("HTMLFormElement"),Kk=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,r){return t.toUpperCase()+r}),Bf=(({hasOwnProperty:n})=>(e,t)=>n.call(e,t))(Object.prototype),Hk=rr("RegExp"),xg=(n,e)=>{const t=Object.getOwnPropertyDescriptors(n),r={};os(t,(i,o)=>{e(i,o,n)!==!1&&(r[o]=i)}),Object.defineProperties(n,r)},Jk=n=>{xg(n,(e,t)=>{if($n(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const r=n[t];if($n(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Yk=(n,e)=>{const t={},r=i=>{i.forEach(o=>{t[o]=!0})};return Xi(n)?r(n):r(String(n).split(e)),t},Gk=()=>{},Xk=(n,e)=>(n=+n,Number.isFinite(n)?n:e),il="abcdefghijklmnopqrstuvwxyz",Lf="0123456789",Eg={DIGIT:Lf,ALPHA:il,ALPHA_DIGIT:il+il.toUpperCase()+Lf},Qk=(n=16,e=Eg.ALPHA_DIGIT)=>{let t="";const{length:r}=e;for(;n--;)t+=e[Math.random()*r|0];return t};function Zk(n){return!!(n&&$n(n.append)&&n[Symbol.toStringTag]==="FormData"&&n[Symbol.iterator])}const ex=n=>{const e=new Array(10),t=(r,i)=>{if(tc(r)){if(e.indexOf(r)>=0)return;if(!("toJSON"in r)){e[i]=r;const o=Xi(r)?[]:{};return os(r,(s,a)=>{const c=t(s,i+1);!No(c)&&(o[a]=c)}),e[i]=void 0,o}}return r};return t(n,0)},tx=rr("AsyncFunction"),nx=n=>n&&(tc(n)||$n(n))&&$n(n.then)&&$n(n.catch),X={isArray:Xi,isArrayBuffer:mg,isBuffer:_k,isFormData:Rk,isArrayBufferView:$k,isString:Ok,isNumber:vg,isBoolean:Ak,isObject:tc,isPlainObject:Qs,isUndefined:No,isDate:Sk,isFile:Tk,isBlob:Pk,isRegExp:Hk,isFunction:$n,isStream:Ck,isURLSearchParams:Ik,isTypedArray:Mk,isFileList:jk,forEach:os,merge:lu,extend:Bk,trim:Nk,stripBOM:Lk,inherits:Dk,toFlatObject:Uk,kindOf:Za,kindOfTest:rr,endsWith:qk,toArray:Vk,forEachEntry:Fk,matchAll:Wk,isHTMLForm:zk,hasOwnProperty:Bf,hasOwnProp:Bf,reduceDescriptors:xg,freezeMethods:Jk,toObjectSet:Yk,toCamelCase:Kk,noop:Gk,toFiniteNumber:Xk,findKey:bg,global:wg,isContextDefined:kg,ALPHABET:Eg,generateString:Qk,isSpecCompliantForm:Zk,toJSONObject:ex,isAsyncFn:tx,isThenable:nx};function Ue(n,e,t,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),r&&(this.request=r),i&&(this.response=i)}X.inherits(Ue,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:X.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const _g=Ue.prototype,$g={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{$g[n]={value:n}});Object.defineProperties(Ue,$g);Object.defineProperty(_g,"isAxiosError",{value:!0});Ue.from=(n,e,t,r,i,o)=>{const s=Object.create(_g);return X.toFlatObject(n,s,function(a){return a!==Error.prototype},a=>a!=="isAxiosError"),Ue.call(s,n.message,e,t,r,i),s.cause=n,s.name=n.name,o&&Object.assign(s,o),s};const rx=null;function uu(n){return X.isPlainObject(n)||X.isArray(n)}function Og(n){return X.endsWith(n,"[]")?n.slice(0,-2):n}function Df(n,e,t){return n?n.concat(e).map(function(r,i){return r=Og(r),!t&&i?"["+r+"]":r}).join(t?".":""):e}function ix(n){return X.isArray(n)&&!n.some(uu)}const ox=X.toFlatObject(X,{},null,function(n){return/^is[A-Z]/.test(n)});function nc(n,e,t){if(!X.isObject(n))throw new TypeError("target must be an object");e=e||new FormData,t=X.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(d,f){return!X.isUndefined(f[d])});const r=t.metaTokens,i=t.visitor||l,o=t.dots,s=t.indexes,a=(t.Blob||typeof Blob!="undefined"&&Blob)&&X.isSpecCompliantForm(e);if(!X.isFunction(i))throw new TypeError("visitor must be a function");function c(d){if(d===null)return"";if(X.isDate(d))return d.toISOString();if(!a&&X.isBlob(d))throw new Ue("Blob is not supported. Use a Buffer instead.");return X.isArrayBuffer(d)||X.isTypedArray(d)?a&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function l(d,f,p){let v=d;if(d&&!p&&typeof d=="object"){if(X.endsWith(f,"{}"))f=r?f:f.slice(0,-2),d=JSON.stringify(d);else if(X.isArray(d)&&ix(d)||(X.isFileList(d)||X.endsWith(f,"[]"))&&(v=X.toArray(d)))return f=Og(f),v.forEach(function(w,S){!(X.isUndefined(w)||w===null)&&e.append(s===!0?Df([f],S,o):s===null?f:f+"[]",c(w))}),!1}return uu(d)?!0:(e.append(Df(p,f,o),c(d)),!1)}const u=[],h=Object.assign(ox,{defaultVisitor:l,convertValue:c,isVisitable:uu});function y(d,f){if(!X.isUndefined(d)){if(u.indexOf(d)!==-1)throw Error("Circular reference detected in "+f.join("."));u.push(d),X.forEach(d,function(p,v){(!(X.isUndefined(p)||p===null)&&i.call(e,p,X.isString(v)?v.trim():v,f,h))===!0&&y(p,f?f.concat(v):[v])}),u.pop()}}if(!X.isObject(n))throw new TypeError("data must be an object");return y(n),e}function Uf(n){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(t){return e[t]})}function Sh(n,e){this._pairs=[],n&&nc(n,this,e)}const Ag=Sh.prototype;Ag.append=function(n,e){this._pairs.push([n,e])};Ag.toString=function(n){const e=n?function(t){return n.call(this,t,Uf)}:Uf;return this._pairs.map(function(t){return e(t[0])+"="+e(t[1])},"").join("&")};function sx(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").re