UNPKG

p3x-redis-ui-material

Version:

💿 P3X Redis UI triple frontend — Angular + React/MUI + Vue/Vuetify with 54 languages, 7 themes, Socket.IO, desktop notifications, and full feature parity

8 lines (7 loc) • 47 kB
import{a as mt,b as yt}from"./chunk-AN7C4JCR.js";import{Rd as dt,U as S,Ua as pt,Y as x,d as E}from"./chunk-KQUCMSSK.js";import{f as Jt,h as lt}from"./chunk-O7S4L63H.js";var _t=(()=>{class i{isShown=!1;show(t={}){this.hide(),document.body.classList.add("p3xr-overlay-visible");let s=` <div id="p3xr-overlay"> <div id="p3xr-overlay-info"> <i class="fas fa-cog fa-spin" style="font-size: 500% !important;"></i> ${t.message?"<br/><br/>"+t.message:""} </div> </div>`;document.body.insertAdjacentHTML("beforeend",s),this.isShown=!0}hide(){this.isShown=!1,document.body.classList.remove("p3xr-overlay-visible");let t=document.getElementById("p3xr-overlay");t&&t.remove()}static \u0275fac=function(s){return new(s||i)};static \u0275prov=S({token:i,factory:i.\u0275fac,providedIn:"root"})}return i})();var bt="p3xr-desktop-notifications",Q=/electron/i.test(navigator.userAgent),wt=(()=>{class i{isEnabled(){try{let t=localStorage.getItem(bt);return t===null?Q:t==="true"}catch(t){return!1}}setEnabled(t){try{localStorage.setItem(bt,String(t))}catch(s){}t&&!Q&&this.requestWebPermission()}requestWebPermission(){typeof Notification>"u"||Notification.permission!=="granted"&&Notification.permission!=="denied"&&Notification.requestPermission()}notify(t,s){if(this.isEnabled()&&!(!document.hidden&&document.hasFocus())){if(Q){try{window.parent?.postMessage({type:"p3x-notify",title:t,body:s},"*")}catch(r){}return}if(typeof Notification<"u"&&Notification.permission==="granted")try{let r=new Notification(t,{body:s,icon:"/images/redis.svg"});r.onclick=()=>{window.focus(),r.close()}}catch(r){}}}static \u0275fac=function(s){return new(s||i)};static \u0275prov=S({token:i,factory:i.\u0275fac,providedIn:"root"})}return i})();var g=Object.create(null);g.open="0";g.close="1";g.ping="2";g.pong="3";g.message="4";g.upgrade="5";g.noop="6";var N=Object.create(null);Object.keys(g).forEach(i=>{N[g[i]]=i});var P={type:"error",data:"parser error"};var Et=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",xt=typeof ArrayBuffer=="function",Tt=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i&&i.buffer instanceof ArrayBuffer,L=({type:i,data:e},t,s)=>Et&&e instanceof Blob?t?s(e):vt(e,s):xt&&(e instanceof ArrayBuffer||Tt(e))?t?s(e):vt(new Blob([e]),s):s(g[i]+(e||"")),vt=(i,e)=>{let t=new FileReader;return t.onload=function(){let s=t.result.split(",")[1];e("b"+(s||""))},t.readAsDataURL(i)};function kt(i){return i instanceof Uint8Array?i:i instanceof ArrayBuffer?new Uint8Array(i):new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}var G;function St(i,e){if(Et&&i.data instanceof Blob)return i.data.arrayBuffer().then(kt).then(e);if(xt&&(i.data instanceof ArrayBuffer||Tt(i.data)))return e(kt(i.data));L(i,!1,t=>{G||(G=new TextEncoder),e(G.encode(t))})}var Rt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",q=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let i=0;i<Rt.length;i++)q[Rt.charCodeAt(i)]=i;var Ct=i=>{let e=i.length*.75,t=i.length,s,r=0,n,o,c,a;i[i.length-1]==="="&&(e--,i[i.length-2]==="="&&e--);let y=new ArrayBuffer(e),u=new Uint8Array(y);for(s=0;s<t;s+=4)n=q[i.charCodeAt(s)],o=q[i.charCodeAt(s+1)],c=q[i.charCodeAt(s+2)],a=q[i.charCodeAt(s+3)],u[r++]=n<<2|o>>4,u[r++]=(o&15)<<4|c>>2,u[r++]=(c&3)<<6|a&63;return y};var Qt=typeof ArrayBuffer=="function",I=(i,e)=>{if(typeof i!="string")return{type:"message",data:At(i,e)};let t=i.charAt(0);return t==="b"?{type:"message",data:Gt(i.substring(1),e)}:N[t]?i.length>1?{type:N[t],data:i.substring(1)}:{type:N[t]}:P},Gt=(i,e)=>{if(Qt){let t=Ct(i);return At(t,e)}else return{base64:!0,data:i}},At=(i,e)=>e==="blob"?i instanceof Blob?i:new Blob([i]):i instanceof ArrayBuffer?i:i.buffer;var Ot="",Bt=(i,e)=>{let t=i.length,s=new Array(t),r=0;i.forEach((n,o)=>{L(n,!1,c=>{s[o]=c,++r===t&&e(s.join(Ot))})})},Nt=(i,e)=>{let t=i.split(Ot),s=[];for(let r=0;r<t.length;r++){let n=I(t[r],e);if(s.push(n),n.type==="error")break}return s};function Pt(){return new TransformStream({transform(i,e){St(i,t=>{let s=t.length,r;if(s<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,s);else if(s<65536){r=new Uint8Array(3);let n=new DataView(r.buffer);n.setUint8(0,126),n.setUint16(1,s)}else{r=new Uint8Array(9);let n=new DataView(r.buffer);n.setUint8(0,127),n.setBigUint64(1,BigInt(s))}i.data&&typeof i.data!="string"&&(r[0]|=128),e.enqueue(r),e.enqueue(t)})}})}var Z;function W(i){return i.reduce((e,t)=>e+t.length,0)}function H(i,e){if(i[0].length===e)return i.shift();let t=new Uint8Array(e),s=0;for(let r=0;r<e;r++)t[r]=i[0][s++],s===i[0].length&&(i.shift(),s=0);return i.length&&s<i[0].length&&(i[0]=i[0].slice(s)),t}function Lt(i,e){Z||(Z=new TextDecoder);let t=[],s=0,r=-1,n=!1;return new TransformStream({transform(o,c){for(t.push(o);;){if(s===0){if(W(t)<1)break;let a=H(t,1);n=(a[0]&128)===128,r=a[0]&127,r<126?s=3:r===126?s=1:s=2}else if(s===1){if(W(t)<2)break;let a=H(t,2);r=new DataView(a.buffer,a.byteOffset,a.length).getUint16(0),s=3}else if(s===2){if(W(t)<8)break;let a=H(t,8),y=new DataView(a.buffer,a.byteOffset,a.length),u=y.getUint32(0);if(u>Math.pow(2,21)-1){c.enqueue(P);break}r=u*Math.pow(2,32)+y.getUint32(4),s=3}else{if(W(t)<r)break;let a=H(t,r);c.enqueue(I(n?a:Z.decode(a),e)),s=0}if(r===0||r>i){c.enqueue(P);break}}}})}var tt=4;function f(i){if(i)return Zt(i)}function Zt(i){for(var e in f.prototype)i[e]=f.prototype[e];return i}f.prototype.on=f.prototype.addEventListener=function(i,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(e),this};f.prototype.once=function(i,e){function t(){this.off(i,t),e.apply(this,arguments)}return t.fn=e,this.on(i,t),this};f.prototype.off=f.prototype.removeListener=f.prototype.removeAllListeners=f.prototype.removeEventListener=function(i,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+i];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+i],this;for(var s,r=0;r<t.length;r++)if(s=t[r],s===e||s.fn===e){t.splice(r,1);break}return t.length===0&&delete this._callbacks["$"+i],this};f.prototype.emit=function(i){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+i],s=1;s<arguments.length;s++)e[s-1]=arguments[s];if(t){t=t.slice(0);for(var s=0,r=t.length;s<r;++s)t[s].apply(this,e)}return this};f.prototype.emitReserved=f.prototype.emit;f.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};f.prototype.hasListeners=function(i){return!!this.listeners(i).length};var _=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),p=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),qt="arraybuffer";function K(i,...e){return e.reduce((t,s)=>(i.hasOwnProperty(s)&&(t[s]=i[s]),t),{})}var te=p.setTimeout,ee=p.clearTimeout;function b(i,e){e.useNativeTimers?(i.setTimeoutFn=te.bind(p),i.clearTimeoutFn=ee.bind(p)):(i.setTimeoutFn=p.setTimeout.bind(p),i.clearTimeoutFn=p.clearTimeout.bind(p))}var se=1.33;function It(i){return typeof i=="string"?ie(i):Math.ceil((i.byteLength||i.size)*se)}function ie(i){let e=0,t=0;for(let s=0,r=i.length;s<r;s++)e=i.charCodeAt(s),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(s++,t+=4);return t}function $(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Dt(i){let e="";for(let t in i)i.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(i[t]));return e}function Ft(i){let e={},t=i.split("&");for(let s=0,r=t.length;s<r;s++){let n=t[s].split("=");e[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return e}var Y=class extends Error{constructor(e,t,s){super(e),this.description=t,this.context=s,this.type="TransportError"}},w=class extends f{constructor(e){super(),this.writable=!1,b(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,s){return super.emitReserved("error",new Y(e,t,s)),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){let t=I(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=Dt(e);return t.length?"?"+t:""}};var D=class extends w{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";let t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||t()})),this.writable||(s++,this.once("drain",function(){--s||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){let t=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};Nt(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){let e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,Bt(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=$()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}};var Ut=!1;try{Ut=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch(i){}var Vt=Ut;function re(){}var et=class extends D{constructor(e){if(super(e),typeof location<"u"){let t=location.protocol==="https:",s=location.port;s||(s=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||s!==e.port}}doWrite(e,t){let s=this.request({method:"POST",data:e});s.on("success",t),s.on("error",(r,n)=>{this.onError("xhr post error",r,n)})}doPoll(){let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,s)=>{this.onError("xhr poll error",t,s)}),this.pollXhr=e}},z=(()=>{class i extends f{constructor(t,s,r){super(),this.createRequest=t,b(this,r),this._opts=r,this._method=r.method||"GET",this._uri=s,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;let s=K(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");s.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(s);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let n in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(n)&&r.setRequestHeader(n,this._opts.extraHeaders[n])}}catch(n){}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(n){}try{r.setRequestHeader("Accept","*/*")}catch(n){}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var n;r.readyState===3&&((n=this._opts.cookieJar)===null||n===void 0||n.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(n){this.setTimeoutFn(()=>{this._onError(n)},0);return}typeof document<"u"&&(this._index=i.requestsCount++,i.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=re,t)try{this._xhr.abort()}catch(s){}typeof document<"u"&&delete i.requests[this._index],this._xhr=null}}_onLoad(){let t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}return i.requestsCount=0,i.requests={},i})();if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Mt);else if(typeof addEventListener=="function"){let i="onpagehide"in p?"pagehide":"unload";addEventListener(i,Mt,!1)}}function Mt(){for(let i in z.requests)z.requests.hasOwnProperty(i)&&z.requests[i].abort()}var ne=(function(){let i=Wt({xdomain:!1});return i&&i.responseType!==null})(),v=class extends et{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=ne&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new z(Wt,this.uri(),e)}};function Wt(i){let e=i.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||Vt))return new XMLHttpRequest}catch(t){}if(!e)try{return new p[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch(t){}}var Ht=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",it=class extends w{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,s=Ht?{}:K(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(e,t,s)}catch(r){return this.emitReserved("error",r)}this.ws.binaryType=this.socket.binaryType,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++){let s=e[t],r=t===e.length-1;L(s,this.supportsBinary,n=>{try{this.doWrite(s,n)}catch(o){}r&&_(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=$()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},st=p.WebSocket||p.MozWebSocket,k=class extends it{createSocket(e,t,s){return Ht?new st(e,t,s):t?new st(e,t):new st(e)}doWrite(e,t){this.ws.send(t)}};var R=class extends w{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=Lt(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(t).getReader(),r=Pt();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let n=()=>{s.read().then(({done:c,value:a})=>{c||(this.onPacket(a),n())}).catch(c=>{})};n();let o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let s=e[t],r=t===e.length-1;this._writer.write(s).then(()=>{r&&_(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}};var rt={websocket:k,webtransport:R,polling:v};var oe=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ce=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function C(i){if(i.length>8e3)throw"URI too long";let e=i,t=i.indexOf("["),s=i.indexOf("]");t!=-1&&s!=-1&&(i=i.substring(0,t)+i.substring(t,s).replace(/:/g,";")+i.substring(s,i.length));let r=oe.exec(i||""),n={},o=14;for(;o--;)n[ce[o]]=r[o]||"";return t!=-1&&s!=-1&&(n.source=e,n.host=n.host.substring(1,n.host.length-1).replace(/;/g,":"),n.authority=n.authority.replace("[","").replace("]","").replace(/;/g,":"),n.ipv6uri=!0),n.pathNames=ae(n,n.path),n.queryKey=he(n,n.query),n}function ae(i,e){let t=/\/{2,9}/g,s=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&s.splice(0,1),e.slice(-1)=="/"&&s.splice(s.length-1,1),s}function he(i,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,r,n){r&&(t[r]=n)}),t}var nt=typeof addEventListener=="function"&&typeof removeEventListener=="function",X=[];nt&&addEventListener("offline",()=>{X.forEach(i=>i())},!1);var j=(()=>{class i extends f{constructor(t,s){if(super(),this.binaryType=qt,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(s=t,t=null),t){let r=C(t);s.hostname=r.host,s.secure=r.protocol==="https"||r.protocol==="wss",s.port=r.port,r.query&&(s.query=r.query)}else s.host&&(s.hostname=C(s.host).host);b(this,s),this.secure=s.secure!=null?s.secure:typeof location<"u"&&location.protocol==="https:",s.hostname&&!s.port&&(s.port=this.secure?"443":"80"),this.hostname=s.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=s.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},s.transports.forEach(r=>{let n=r.prototype.name;this.transports.push(n),this._transportsByName[n]=r}),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},s),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Ft(this.opts.query)),nt&&(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"})},X.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){let s=Object.assign({},this.opts.query);s.EIO=tt,s.transport=t,this.id&&(s.sid=this.id);let r=Object.assign({},this.opts,{query:s,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let t=this.opts.rememberUpgrade&&i.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";let s=this.createTransport(t);s.open(),this.setTransport(s)}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",s=>this._onClose("transport close",s))}onOpen(){this.readyState="open",i.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")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":let s=new Error("server error");s.code=t.data,this._onError(s);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}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(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let 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,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let s=1;for(let r=0;r<this.writeBuffer.length;r++){let n=this.writeBuffer[r].data;if(n&&(s+=It(n)),r>0&&s>this._maxPayload)return this.writeBuffer.slice(0,r);s+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,_(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,s,r){return this._sendPacket("message",t,s,r),this}send(t,s,r){return this._sendPacket("message",t,s,r),this}_sendPacket(t,s,r,n){if(typeof s=="function"&&(n=s,s=void 0),typeof r=="function"&&(n=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;let o={type:t,data:s,options:r};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),n&&this.once("flush",n),this.flush()}close(){let t=()=>{this._onClose("forced close"),this.transport.close()},s=()=>{this.off("upgrade",s),this.off("upgradeError",s),t()},r=()=>{this.once("upgrade",s),this.once("upgradeError",s)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(i.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),nt&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let r=X.indexOf(this._offlineEventListener);r!==-1&&X.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,s),this.writeBuffer=[],this._prevBufferLen=0}}}return i.protocol=tt,i})(),J=class extends j{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),s=!1;j.priorWebsocketSuccess=!1;let r=()=>{s||(t.send([{type:"ping",data:"probe"}]),t.once("packet",l=>{if(!s)if(l.type==="pong"&&l.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;j.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(u(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{let d=new Error("probe error");d.transport=t.name,this.emitReserved("upgradeError",d)}}))};function n(){s||(s=!0,u(),t.close(),t=null)}let o=l=>{let d=new Error("probe error: "+l);d.transport=t.name,n(),this.emitReserved("upgradeError",d)};function c(){o("transport closed")}function a(){o("socket closed")}function y(l){t&&l.name!==t.name&&n()}let u=()=>{t.removeListener("open",r),t.removeListener("error",o),t.removeListener("close",c),this.off("close",a),this.off("upgrading",y)};t.once("open",r),t.once("error",o),t.once("close",c),this.once("close",a),this.once("upgrading",y),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{s||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let s=0;s<e.length;s++)~this.transports.indexOf(e[s])&&t.push(e[s]);return t}},A=class extends J{constructor(e,t={}){let s=typeof e=="object"?e:t;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(r=>rt[r]).filter(r=>!!r)),super(e,s)}};var Es=A.protocol;function Kt(i,e="",t){let s=i;t=t||typeof location<"u"&&location,i==null&&(i=t.protocol+"//"+t.host),typeof i=="string"&&(i.charAt(0)==="/"&&(i.charAt(1)==="/"?i=t.protocol+i:i=t.host+i),/^(https?|wss?):\/\//.test(i)||(typeof t<"u"?i=t.protocol+"//"+i:i="https://"+i),s=C(i)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";let n=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+n+":"+s.port+e,s.href=s.protocol+"://"+n+(t&&t.port===s.port?"":":"+s.port),s}var ut={};Jt(ut,{Decoder:()=>ht,Encoder:()=>at,PacketType:()=>h,protocol:()=>jt});var ue=typeof ArrayBuffer=="function",le=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,$t=Object.prototype.toString,pe=typeof Blob=="function"||typeof Blob<"u"&&$t.call(Blob)==="[object BlobConstructor]",de=typeof File=="function"||typeof File<"u"&&$t.call(File)==="[object FileConstructor]";function U(i){return ue&&(i instanceof ArrayBuffer||le(i))||pe&&i instanceof Blob||de&&i instanceof File}function F(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,s=i.length;t<s;t++)if(F(i[t]))return!0;return!1}if(U(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return F(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&F(i[t]))return!0;return!1}function Yt(i){let e=[],t=i.data,s=i;return s.data=ot(t,e),s.attachments=e.length,{packet:s,buffers:e}}function ot(i,e){if(!i)return i;if(U(i)){let t={_placeholder:!0,num:e.length};return e.push(i),t}else if(Array.isArray(i)){let t=new Array(i.length);for(let s=0;s<i.length;s++)t[s]=ot(i[s],e);return t}else if(typeof i=="object"&&!(i instanceof Date)){let t={};for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=ot(i[s],e));return t}return i}function zt(i,e){return i.data=ct(i.data,e),delete i.attachments,i}function ct(i,e){if(!i)return i;if(i&&i._placeholder===!0){if(typeof i.num=="number"&&i.num>=0&&i.num<e.length)return e[i.num];throw new Error("illegal attachments")}else if(Array.isArray(i))for(let t=0;t<i.length;t++)i[t]=ct(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=ct(i[t],e));return i}var me=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],jt=5,h=(function(i){return i[i.CONNECT=0]="CONNECT",i[i.DISCONNECT=1]="DISCONNECT",i[i.EVENT=2]="EVENT",i[i.ACK=3]="ACK",i[i.CONNECT_ERROR=4]="CONNECT_ERROR",i[i.BINARY_EVENT=5]="BINARY_EVENT",i[i.BINARY_ACK=6]="BINARY_ACK",i})(h||{}),at=class{constructor(e){this.replacer=e}encode(e){return(e.type===h.EVENT||e.type===h.ACK)&&F(e)?this.encodeAsBinary({type:e.type===h.EVENT?h.BINARY_EVENT:h.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===h.BINARY_EVENT||e.type===h.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){let t=Yt(e),s=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(s),r}};function Xt(i){return Object.prototype.toString.call(i)==="[object Object]"}var ht=class i extends f{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);let s=t.type===h.BINARY_EVENT;s||t.type===h.BINARY_ACK?(t.type=s?h.EVENT:h.ACK,this.reconstructor=new ft(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(U(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,s={type:Number(e.charAt(0))};if(h[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===h.BINARY_EVENT||s.type===h.BINARY_ACK){let n=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let o=e.substring(n,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");s.attachments=Number(o)}if(e.charAt(t+1)==="/"){let n=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););s.nsp=e.substring(n,t)}else s.nsp="/";let r=e.charAt(t+1);if(r!==""&&Number(r)==r){let n=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}s.id=Number(e.substring(n,t+1))}if(e.charAt(++t)){let n=this.tryParse(e.substr(t));if(i.isPayloadValid(s.type,n))s.data=n;else throw new Error("invalid payload")}return s}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(t){return!1}}static isPayloadValid(e,t){switch(e){case h.CONNECT:return Xt(t);case h.DISCONNECT:return t===void 0;case h.CONNECT_ERROR:return typeof t=="string"||Xt(t);case h.EVENT:case h.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&me.indexOf(t[0])===-1);case h.ACK:case h.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},ft=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let t=zt(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function m(i,e,t){return i.on(e,t),function(){i.off(e,t)}}var ye=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),O=class extends f{constructor(e,t,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=e,this.nsp=t,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;let e=this.io;this.subs=[m(e,"open",this.onopen.bind(this)),m(e,"packet",this.onpacket.bind(this)),m(e,"error",this.onerror.bind(this)),m(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){var s,r,n;if(ye.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;let o={type:h.EVENT,data:t};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let u=this.ids++,l=t.pop();this._registerAckCallback(u,l),o.id=u}let c=(r=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||r===void 0?void 0:r.writable,a=this.connected&&!(!((n=this.io.engine)===null||n===void 0)&&n._hasPingExpired());return this.flags.volatile&&!c||(a?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,t){var s;let r=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(r===void 0){this.acks[e]=t;return}let n=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let c=0;c<this.sendBuffer.length;c++)this.sendBuffer[c].id===e&&this.sendBuffer.splice(c,1);t.call(this,new Error("operation has timed out"))},r),o=(...c)=>{this.io.clearTimeoutFn(n),t.apply(this,c)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...t){return new Promise((s,r)=>{let n=(o,c)=>o?r(o):s(c);n.withError=!0,t.push(n),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((r,...n)=>(this._queue[0],r!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(r)):(this._queue.shift(),t&&t(null,...n)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let 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:h.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),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(s=>String(s.id)===e)){let s=this.acks[e];delete this.acks[e],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case h.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 h.EVENT:case h.BINARY_EVENT:this.onevent(e);break;case h.ACK:case h.BINARY_ACK:this.onack(e);break;case h.DISCONNECT:this.ondisconnect();break;case h.CONNECT_ERROR:this.destroy();let s=new Error(e.data.message);s.data=e.data.data,this.emitReserved("connect_error",s);break}}onevent(e){let 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){let t=this._anyListeners.slice();for(let s of t)s.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){let t=this,s=!1;return function(...r){s||(s=!0,t.packet({type:h.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t=="function"&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}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:h.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){let t=this._anyListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,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){let t=this._anyOutgoingListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let s of t)s.apply(this,e.data)}}};function T(i){i=i||{},this.ms=i.min||100,this.max=i.max||1e4,this.factor=i.factor||2,this.jitter=i.jitter>0&&i.jitter<=1?i.jitter:0,this.attempts=0}T.prototype.duration=function(){var i=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*i);i=(Math.floor(e*10)&1)==0?i-t:i+t}return Math.min(i,this.max)|0};T.prototype.reset=function(){this.attempts=0};T.prototype.setMin=function(i){this.ms=i};T.prototype.setMax=function(i){this.max=i};T.prototype.setJitter=function(i){this.jitter=i};var B=class extends f{constructor(e,t){var s;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,b(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((s=t.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new T({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let r=t.parser||ut;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),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 A(this.uri,this.opts);let t=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;let r=m(t,"open",function(){s.onopen(),e&&e()}),n=c=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",c),e?e(c):this.maybeReconnectOnOpen()},o=m(t,"error",n);if(this._timeout!==!1){let c=this._timeout,a=this.setTimeoutFn(()=>{r(),n(new Error("timeout")),t.close()},c);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}return this.subs.push(r),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(m(e,"ping",this.onping.bind(this)),m(e,"data",this.ondata.bind(this)),m(e,"error",this.onerror.bind(this)),m(e,"close",this.onclose.bind(this)),m(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){_(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new O(this,e,t),this.nsps[e]=s),s}_destroy(e){let t=Object.keys(this.nsps);for(let s of t)if(this.nsps[s].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let s=0;s<t.length;s++)this.engine.write(t[s],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")}disconnect(){return this._close()}onclose(e,t){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),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;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let s=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(r=>{r?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",r)):e.onreconnect()}))},t);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};var V={};function M(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=Kt(i,e.path||"/socket.io"),s=t.source,r=t.id,n=t.path,o=V[r]&&n in V[r].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||o,a;return c?a=new B(s,e):(V[r]||(V[r]=new B(s,e)),a=V[r]),t.query&&!e.query&&(e.query=t.queryKey),a.socket(t.path,e)}Object.assign(M,{Manager:B,Socket:O,io:M,connect:M});var bi=(()=>{class i{appRef;state;settings;overlay;i18n;notificationService;ioClient;reconnect=!1;connectErrorWas=!1;disconnected=!1;authBlocked=!1;connections$=new E;redisDisconnected$=new E;redisStatus$=new E;configuration$=new E;socketError$=new E;stateChanged$=new E;constructor(t,s,r,n,o,c){this.appRef=t,this.state=s,this.settings=r,this.overlay=n,this.i18n=o,this.notificationService=c,this.initConnection()}tick(){setTimeout(()=>{this.appRef.tick()})}initConnection(){let t={rejectUnauthorized:!1,path:"/socket.io",secure:!0,reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:1e3,reconnectionDelayMax:5e3},s=localStorage.getItem("p3xr-auth-token");s&&(t.auth={token:s}),this.ioClient=M(this.state.apiHost,t),this.ioClient.on("connect",()=>lt(this,null,function*(){if(this.disconnected||this.connectErrorWas){console.log("p3xr-socket RE-connected",this.ioClient.id);let n=this.i18n.strings();this.notificationService.notify(n?.title?.name,n?.status?.connectionRestored),this.disconnected=!1,this.connectErrorWas=!1,location.reload();return}this.reconnect?console.log("p3xr-socket RE-connected",this.ioClient.id):console.log("p3xr-socket connected",this.ioClient.id),this.reconnect=!0})),this.ioClient.on("disconnect",()=>{if(!this.authBlocked){this.disconnected=!0;try{this.overlay.show()}catch(n){}}}),this.ioClient.on("error",n=>{this.handleSocketError(n)}),this.ioClient.on("connect_error",n=>{if(n?.message==="auth_required"){this.authBlocked=!0,this.ioClient.disconnect();return}this.handleSocketError(n)}),this.ioClient.on("connections",n=>{if(n.status==="error"){this.state.resetConnections(),this.tick();return}this.state.connections.set(n.connections),this.connections$.next(n),this.tick()}),this.ioClient.on("redis-disconnected",n=>{if(this.state.connection()!==void 0&&this.state.connection().id===n.connectionId){if(this.state.monitor.set(!1),this.state.connection.set(void 0),n.status==="error"){let o=this.i18n.strings(),c=o?.status?.redisDisconnected?.(n)??"Redis disconnected";this.showToast(c),this.notificationService.notify(o?.title?.name,c)}else if(n.status==="code"){let o=this.i18n.strings(),a=(o?.code??{})[n.code]??`unknown redis disconnect code: ${n.code}`;this.showToast(a),this.notificationService.notify(o?.title?.name,a)}this.redisDisconnected$.next(n),this.tick(),this.request({action:"connection/trigger-disconnect",enableResponse:!1}).catch(()=>{})}}),this.ioClient.on("redis-status",n=>{this.state.redisConnections.set(n.redisConnections),this.redisStatus$.next(n),this.tick()});let r=!1;this.ioClient.on("configuration",n=>{if(this.state.cfg.set(n),n.snapshot===!0)this.state.version.set("SNAPSHOT");else if(this.state.version.set("v"+n.version),!r){r=!0;try{window.gtag?.("config",this.settings.googleAnalytics,{page_path:"/version/"+this.state.version()})}catch(o){}}this.configuration$.next(n),this.tick()})}handleSocketError(t){try{this.overlay.show()}catch(s){}this.connectErrorWas||(this.connectErrorWas=!0,this.socketError$.next(t))}showToast(t){try{let s=globalThis.__p3xr_snackbar;if(s){let r=s.open(t,"x",{duration:5e3,horizontalPosition:"right",verticalPosition:"bottom"});r.onAction().subscribe(()=>r.dismiss())}}catch(s){}}request(t){return this.ioClient?(t.payload||(t.payload={}),t.payload.maxKeys=parseInt(String(this.settings.maxKeys()??"10000")),t.enableResponse!==!1?new Promise((r,n)=>{let o=this.settings.generateId();t.requestId=o;let c=`p3xr-response-${o}`,a,y=u=>{if(clearTimeout(a),this.ioClient.off(c),u?.status==="ok")r(u);else{let l="Unknown error";try{let d=u?.error;typeof d=="string"?l=d:d?.message?l=d.message:d!=null&&(l=String(d))}catch(d){}n(new Error(l))}this.tick()};a=setTimeout(()=>{this.ioClient.off(c,y);let l=this.i18n.strings()?.label?.socketIoTimeout?.({timeout:this.settings.socketTimeout})??`Socket.IO request timeout (${this.settings.socketTimeout}ms)`;n(new Error(l)),this.tick()},this.settings.socketTimeout),this.ioClient.on(c,y),this.ioClient.emit("p3xr-request",t)}):(this.ioClient.emit("p3xr-request",t),Promise.resolve())):Promise.reject(new Error("Socket.IO client unavailable"))}getClient(){return this.ioClient}static \u0275fac=function(s){return new(s||i)(x(pt),x(yt),x(mt),x(_t),x(dt),x(wt))};static \u0275prov=S({token:i,factory:i.\u0275fac,providedIn:"root"})}return i})();export{_t as a,wt as b,bi as c};