@zabbu/chat-widget 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.html +1 -1
- package/dist/loader.js +1 -1
- package/package.json +1 -1
package/dist/index.html
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
(see specs/admin-conversation-tools/PLAN.md). -->
|
|
14
14
|
<meta
|
|
15
15
|
http-equiv="Content-Security-Policy"
|
|
16
|
-
content="default-src 'self'; script-src 'self'; style-src 'self'; connect-src 'self'
|
|
16
|
+
content="default-src 'self'; script-src 'self'; style-src 'self'; connect-src 'self' https://api-production-e565.up.railway.app; img-src 'self' https://api-production-e565.up.railway.app; object-src 'none'; base-uri 'none'"
|
|
17
17
|
/>
|
|
18
18
|
<title>Chat</title>
|
|
19
19
|
<link rel="stylesheet" href="chat-ui.css" />
|
package/dist/loader.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{var Lt=Object.defineProperty;var Pt=(r,e)=>{for(var t in e)Lt(r,t,{get:e[t],enumerable:!0})};var x=Object.create(null);x.open="0";x.close="1";x.ping="2";x.pong="3";x.message="4";x.upgrade="5";x.noop="6";var U=Object.create(null);Object.keys(x).forEach(r=>{U[x[r]]=r});var V={type:"error",data:"parser error"};var Ie=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",De=typeof ArrayBuffer=="function",qe=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer,F=({type:r,data:e},t,n)=>Ie&&e instanceof Blob?t?n(e):Be(e,n):De&&(e instanceof ArrayBuffer||qe(e))?t?n(e):Be(new Blob([e]),n):n(x[r]+(e||"")),Be=(r,e)=>{let t=new FileReader;return t.onload=function(){let n=t.result.split(",")[1];e("b"+(n||""))},t.readAsDataURL(r)};function He(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}var le;function Ue(r,e){if(Ie&&r.data instanceof Blob)return r.data.arrayBuffer().then(He).then(e);if(De&&(r.data instanceof ArrayBuffer||qe(r.data)))return e(He(r.data));F(r,!1,t=>{le||(le=new TextEncoder),e(le.encode(t))})}var Ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",G=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let r=0;r<Ve.length;r++)G[Ve.charCodeAt(r)]=r;var Fe=r=>{let e=r.length*.75,t=r.length,n,s=0,i,o,a,c;r[r.length-1]==="="&&(e--,r[r.length-2]==="="&&e--);let f=new ArrayBuffer(e),u=new Uint8Array(f);for(n=0;n<t;n+=4)i=G[r.charCodeAt(n)],o=G[r.charCodeAt(n+1)],a=G[r.charCodeAt(n+2)],c=G[r.charCodeAt(n+3)],u[s++]=i<<2|o>>4,u[s++]=(o&15)<<4|a>>2,u[s++]=(a&3)<<6|c&63;return f};var Mt=typeof ArrayBuffer=="function",z=(r,e)=>{if(typeof r!="string")return{type:"message",data:Ge(r,e)};let t=r.charAt(0);return t==="b"?{type:"message",data:Bt(r.substring(1),e)}:U[t]?r.length>1?{type:U[t],data:r.substring(1)}:{type:U[t]}:V},Bt=(r,e)=>{if(Mt){let t=Fe(r);return Ge(t,e)}else return{base64:!0,data:r}},Ge=(r,e)=>{switch(e){case"blob":return r instanceof Blob?r:new Blob([r]);case"arraybuffer":default:return r instanceof ArrayBuffer?r:r.buffer}};var ze="",Ye=(r,e)=>{let t=r.length,n=new Array(t),s=0;r.forEach((i,o)=>{F(i,!1,a=>{n[o]=a,++s===t&&e(n.join(ze))})})},$e=(r,e)=>{let t=r.split(ze),n=[];for(let s=0;s<t.length;s++){let i=z(t[s],e);if(n.push(i),i.type==="error")break}return n};function Ke(){return new TransformStream({transform(r,e){Ue(r,t=>{let n=t.length,s;if(n<126)s=new Uint8Array(1),new DataView(s.buffer).setUint8(0,n);else if(n<65536){s=new Uint8Array(3);let i=new DataView(s.buffer);i.setUint8(0,126),i.setUint16(1,n)}else{s=new Uint8Array(9);let i=new DataView(s.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(n))}r.data&&typeof r.data!="string"&&(s[0]|=128),e.enqueue(s),e.enqueue(t)})}})}var pe;function J(r){return r.reduce((e,t)=>e+t.length,0)}function Q(r,e){if(r[0].length===e)return r.shift();let t=new Uint8Array(e),n=0;for(let s=0;s<e;s++)t[s]=r[0][n++],n===r[0].length&&(r.shift(),n=0);return r.length&&n<r[0].length&&(r[0]=r[0].slice(n)),t}function Ze(r,e){pe||(pe=new TextDecoder);let t=[],n=0,s=-1,i=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(n===0){if(J(t)<1)break;let c=Q(t,1);i=(c[0]&128)===128,s=c[0]&127,s<126?n=3:s===126?n=1:n=2}else if(n===1){if(J(t)<2)break;let c=Q(t,2);s=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),n=3}else if(n===2){if(J(t)<8)break;let c=Q(t,8),f=new DataView(c.buffer,c.byteOffset,c.length),u=f.getUint32(0);if(u>Math.pow(2,21)-1){a.enqueue(V);break}s=u*Math.pow(2,32)+f.getUint32(4),n=3}else{if(J(t)<s)break;let c=Q(t,s);a.enqueue(z(i?c:pe.decode(c),e)),n=0}if(s===0||s>r){a.enqueue(V);break}}}})}var ue=4;function p(r){if(r)return Ht(r)}function Ht(r){for(var e in p.prototype)r[e]=p.prototype[e];return r}p.prototype.on=p.prototype.addEventListener=function(r,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(e),this};p.prototype.once=function(r,e){function t(){this.off(r,t),e.apply(this,arguments)}return t.fn=e,this.on(r,t),this};p.prototype.off=p.prototype.removeListener=p.prototype.removeAllListeners=p.prototype.removeEventListener=function(r,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+r];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var n,s=0;s<t.length;s++)if(n=t[s],n===e||n.fn===e){t.splice(s,1);break}return t.length===0&&delete this._callbacks["$"+r],this};p.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+r],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(t){t=t.slice(0);for(var n=0,s=t.length;n<s;++n)t[n].apply(this,e)}return this};p.prototype.emitReserved=p.prototype.emit;p.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]};p.prototype.hasListeners=function(r){return!!this.listeners(r).length};var T=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),g=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),We="arraybuffer";function j(r,...e){return e.reduce((t,n)=>(r.hasOwnProperty(n)&&(t[n]=r[n]),t),{})}var It=g.setTimeout,Dt=g.clearTimeout;function A(r,e){e.useNativeTimers?(r.setTimeoutFn=It.bind(g),r.clearTimeoutFn=Dt.bind(g)):(r.setTimeoutFn=g.setTimeout.bind(g),r.clearTimeoutFn=g.clearTimeout.bind(g))}var qt=1.33;function Xe(r){return typeof r=="string"?Ut(r):Math.ceil((r.byteLength||r.size)*qt)}function Ut(r){let e=0,t=0;for(let n=0,s=r.length;n<s;n++)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(n++,t+=4);return t}function ee(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Je(r){let e="";for(let t in r)r.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(r[t]));return e}function Qe(r){let e={},t=r.split("&");for(let n=0,s=t.length;n<s;n++){let i=t[n].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}var te=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}},w=class extends p{constructor(e){super(),this.writable=!1,A(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved("error",new te(e,t,n)),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=z(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&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=Je(e);return t.length?"?"+t:""}};var Y=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 n=0;this._polling&&(n++,this.once("pollComplete",function(){--n||t()})),this.writable||(n++,this.once("drain",function(){--n||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){let t=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};$e(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,Ye(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]=ee()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}};var je=!1;try{je=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var et=je;function Vt(){}var fe=class extends Y{constructor(e){if(super(e),typeof location<"u"){let t=location.protocol==="https:",n=location.port;n||(n=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(s,i)=>{this.onError("xhr post error",s,i)})}doPoll(){let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,n)=>{this.onError("xhr poll error",t,n)}),this.pollXhr=e}},v=class r extends p{constructor(e,t,n){super(),this.createRequest=e,A(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var e;let t=j(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;let n=this._xhr=this.createRequest(t);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let s in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(s)&&n.setRequestHeader(s,this._opts.extraHeaders[s])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var s;n.readyState===3&&((s=this._opts.cookieJar)===null||s===void 0||s.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},n.send(this._data)}catch(s){this.setTimeoutFn(()=>{this._onError(s)},0);return}typeof document<"u"&&(this._index=r.requestsCount++,r.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Vt,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete r.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};v.requestsCount=0;v.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",tt);else if(typeof addEventListener=="function"){let r="onpagehide"in g?"pagehide":"unload";addEventListener(r,tt,!1)}}function tt(){for(let r in v.requests)v.requests.hasOwnProperty(r)&&v.requests[r].abort()}var Ft=function(){let r=rt({xdomain:!1});return r&&r.responseType!==null}(),S=class extends fe{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=Ft&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new v(rt,this.uri(),e)}};function rt(r){let e=r.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||et))return new XMLHttpRequest}catch{}if(!e)try{return new g[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var nt=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",me=class extends w{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,n=nt?{}:j(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(s){return this.emitReserved("error",s)}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 n=e[t],s=t===e.length-1;F(n,this.supportsBinary,i=>{try{this.doWrite(n,i)}catch{}s&&T(()=>{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]=ee()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},de=g.WebSocket||g.MozWebSocket,k=class extends me{createSocket(e,t,n){return nt?new de(e,t,n):t?new de(e,t):new de(e)}doWrite(e,t){this.ws.send(t)}};var P=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=Ze(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),s=Ke();s.readable.pipeTo(e.writable),this._writer=s.writable.getWriter();let i=()=>{n.read().then(({done:a,value:c})=>{a||(this.onPacket(c),i())}).catch(a=>{})};i();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 n=e[t],s=t===e.length-1;this._writer.write(n).then(()=>{s&&T(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}};var ye={websocket:k,webtransport:P,polling:S};var Gt=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,zt=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function M(r){if(r.length>8e3)throw"URI too long";let e=r,t=r.indexOf("["),n=r.indexOf("]");t!=-1&&n!=-1&&(r=r.substring(0,t)+r.substring(t,n).replace(/:/g,";")+r.substring(n,r.length));let s=Gt.exec(r||""),i={},o=14;for(;o--;)i[zt[o]]=s[o]||"";return t!=-1&&n!=-1&&(i.source=e,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=Yt(i,i.path),i.queryKey=$t(i,i.query),i}function Yt(r,e){let t=/\/{2,9}/g,n=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&n.splice(0,1),e.slice(-1)=="/"&&n.splice(n.length-1,1),n}function $t(r,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,s,i){s&&(t[s]=i)}),t}var ge=typeof addEventListener=="function"&&typeof removeEventListener=="function",re=[];ge&&addEventListener("offline",()=>{re.forEach(r=>r())},!1);var N=class r extends p{constructor(e,t){if(super(),this.binaryType=We,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(t=e,e=null),e){let n=M(e);t.hostname=n.host,t.secure=n.protocol==="https"||n.protocol==="wss",t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=M(t.host).host);A(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(n=>{let s=n.prototype.name;this.transports.push(s),this._transportsByName[s]=n}),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},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Qe(this.opts.query)),ge&&(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"})},re.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=ue,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let e=this.opts.rememberUpgrade&&r.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";let t=this.createTransport(e);t.open(),this.setTransport(t)}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))}onOpen(){this.readyState="open",r.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_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._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let 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._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),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 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 t=1;for(let n=0;n<this.writeBuffer.length;n++){let s=this.writeBuffer[n].data;if(s&&(t+=Xe(s)),n>0&&t>this._maxPayload)return this.writeBuffer.slice(0,n);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,T(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket("message",e,t,n),this}send(e,t,n){return this._sendPacket("message",e,t,n),this}_sendPacket(e,t,n,s){if(typeof t=="function"&&(s=t,t=void 0),typeof n=="function"&&(s=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;let i={type:e,data:t,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),s&&this.once("flush",s),this.flush()}close(){let e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{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?n():e()}):this.upgrading?n():e()),this}_onError(e){if(r.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){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(),ge&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let n=re.indexOf(this._offlineEventListener);n!==-1&&re.splice(n,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}};N.protocol=ue;var ne=class extends N{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),n=!1;N.priorWebsocketSuccess=!1;let s=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",d=>{if(!n)if(d.type==="pong"&&d.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;N.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(u(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{let b=new Error("probe error");b.transport=t.name,this.emitReserved("upgradeError",b)}}))};function i(){n||(n=!0,u(),t.close(),t=null)}let o=d=>{let b=new Error("probe error: "+d);b.transport=t.name,i(),this.emitReserved("upgradeError",b)};function a(){o("transport closed")}function c(){o("socket closed")}function f(d){t&&d.name!==t.name&&i()}let u=()=>{t.removeListener("open",s),t.removeListener("error",o),t.removeListener("close",a),this.off("close",c),this.off("upgrading",f)};t.once("open",s),t.once("error",o),t.once("close",a),this.once("close",c),this.once("upgrading",f),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},B=class extends ne{constructor(e,t={}){let n=typeof e=="object",s=n?{...e}:{...t};(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(i=>ye[i]).filter(i=>!!i)),super(n?s:e,s)}};var xn=B.protocol;function st(r,e="",t){let n=r;t=t||typeof location<"u"&&location,r==null&&(r=t.protocol+"//"+t.host),typeof r=="string"&&(r.charAt(0)==="/"&&(r.charAt(1)==="/"?r=t.protocol+r:r=t.host+r),/^(https?|wss?):\/\//.test(r)||(typeof t<"u"?r=t.protocol+"//"+r:r="https://"+r),n=M(r)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";let i=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port+e,n.href=n.protocol+"://"+i+(t&&t.port===n.port?"":":"+n.port),n}var Te={};Pt(Te,{Decoder:()=>xe,Encoder:()=>be,PacketType:()=>h,isPacketValid:()=>tr,protocol:()=>ht});var Zt=typeof ArrayBuffer=="function",Wt=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,it=Object.prototype.toString,Xt=typeof Blob=="function"||typeof Blob<"u"&&it.call(Blob)==="[object BlobConstructor]",Jt=typeof File=="function"||typeof File<"u"&&it.call(File)==="[object FileConstructor]";function K(r){return Zt&&(r instanceof ArrayBuffer||Wt(r))||Xt&&r instanceof Blob||Jt&&r instanceof File}function $(r,e){if(!r||typeof r!="object")return!1;if(Array.isArray(r)){for(let t=0,n=r.length;t<n;t++)if($(r[t]))return!0;return!1}if(K(r))return!0;if(r.toJSON&&typeof r.toJSON=="function"&&arguments.length===1)return $(r.toJSON(),!0);for(let t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&$(r[t]))return!0;return!1}function ot(r){let e=[],t=r.data,n=r;return n.data=se(t,e),n.attachments=e.length,{packet:n,buffers:e}}function se(r,e,t){if(!r)return r;if(K(r)){let n={_placeholder:!0,num:e.length};return e.push(r),n}else if(Array.isArray(r)){let n=new Array(r.length);for(let s=0;s<r.length;s++)n[s]=se(r[s],e);return n}else if(typeof r=="object"&&!(r instanceof Date)){if(r.toJSON&&typeof r.toJSON=="function"&&!t)return se(r.toJSON(),e,!0);let n={};for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=se(r[s],e));return n}return r}function at(r,e){return r.data=_e(r.data,e),delete r.attachments,r}function _e(r,e){if(!r)return r;if(r&&r._placeholder===!0){if(typeof r.num=="number"&&r.num>=0&&r.num<e.length)return e[r.num];throw new Error("illegal attachments")}else if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]=_e(r[t],e);else if(typeof r=="object")for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&(r[t]=_e(r[t],e));return r}var ct=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],ht=5,h;(function(r){r[r.CONNECT=0]="CONNECT",r[r.DISCONNECT=1]="DISCONNECT",r[r.EVENT=2]="EVENT",r[r.ACK=3]="ACK",r[r.CONNECT_ERROR=4]="CONNECT_ERROR",r[r.BINARY_EVENT=5]="BINARY_EVENT",r[r.BINARY_ACK=6]="BINARY_ACK"})(h||(h={}));var be=class{constructor(e){this.replacer=e}encode(e){return(e.type===h.EVENT||e.type===h.ACK)&&$(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=ot(e),n=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(n),s}},xe=class r extends p{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}: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 n=t.type===h.BINARY_EVENT;n||t.type===h.BINARY_ACK?(t.type=n?h.EVENT:h.ACK,this.reconstructor=new Ee(t)):super.emitReserved("decoded",t)}else if(K(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,n={type:Number(e.charAt(0))};if(h[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===h.BINARY_EVENT||n.type===h.BINARY_ACK){let i=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let o=e.substring(i,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");let a=Number(o);if(!lt(a)||a<1)throw new Error("Illegal attachments");if(a>this.opts.maxAttachments)throw new Error("too many attachments");n.attachments=a}if(e.charAt(t+1)==="/"){let i=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););n.nsp=e.substring(i,t)}else n.nsp="/";let s=e.charAt(t+1);if(s!==""&&Number(s)==s){let i=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}n.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){let i=this.tryParse(e.substr(t));if(r.isPayloadValid(n.type,i))n.data=i;else throw new Error("invalid payload")}return n}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case h.CONNECT:return ie(t);case h.DISCONNECT:return t===void 0;case h.CONNECT_ERROR:return typeof t=="string"||ie(t);case h.EVENT:case h.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&ct.indexOf(t[0])===-1);case h.ACK:case h.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},Ee=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=at(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function Qt(r){return typeof r=="string"}var lt=Number.isInteger||function(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r};function jt(r){return r===void 0||lt(r)}function ie(r){return Object.prototype.toString.call(r)==="[object Object]"}function er(r,e){switch(r){case h.CONNECT:return e===void 0||ie(e);case h.DISCONNECT:return e===void 0;case h.EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&ct.indexOf(e[0])===-1);case h.ACK:return Array.isArray(e);case h.CONNECT_ERROR:return typeof e=="string"||ie(e);default:return!1}}function tr(r){return Qt(r.nsp)&&jt(r.id)&&er(r.type,r.data)}function _(r,e,t){return r.on(e,t),function(){r.off(e,t)}}var rr=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),H=class extends p{constructor(e,t,n){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,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[_(e,"open",this.onopen.bind(this)),_(e,"packet",this.onpacket.bind(this)),_(e,"error",this.onerror.bind(this)),_(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 n,s,i;if(rr.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++,d=t.pop();this._registerAckCallback(u,d),o.id=u}let a=(s=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||s===void 0?void 0:s.writable,c=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!a||(c?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,t){var n;let s=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(s===void 0){this.acks[e]=t;return}let i=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===e&&this.sendBuffer.splice(a,1);t.call(this,new Error("operation has timed out"))},s),o=(...a)=>{this.io.clearTimeoutFn(i),t.apply(this,a)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...t){return new Promise((n,s)=>{let i=(o,a)=>o?s(o):n(a);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((s,...i)=>(this._queue[0],s!==null?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(s)):(this._queue.shift(),t&&t(null,...i)),n.pending=!1,this._drainQueue())),this._queue.push(n),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(n=>String(n.id)===e)){let n=this.acks[e];delete this.acks[e],n.withError&&n.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 n=new Error(e.data.message);n.data=e.data.data,this.emitReserved("connect_error",n);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 n of t)n.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,n=!1;return function(...s){n||(n=!0,t.packet({type:h.ACK,id:e,data:s}))}}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 n=0;n<t.length;n++)if(e===t[n])return t.splice(n,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 n=0;n<t.length;n++)if(e===t[n])return t.splice(n,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 n of t)n.apply(this,e.data)}}};function L(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}L.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*r);r=Math.floor(e*10)&1?r+t:r-t}return Math.min(r,this.max)|0};L.prototype.reset=function(){this.attempts=0};L.prototype.setMin=function(r){this.ms=r};L.prototype.setMax=function(r){this.max=r};L.prototype.setJitter=function(r){this.jitter=r};var I=class extends p{constructor(e,t){var n;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,A(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((n=t.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new L({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let s=t.parser||Te;this.encoder=new s.Encoder,this.decoder=new s.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 B(this.uri,this.opts);let t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;let s=_(t,"open",function(){n.onopen(),e&&e()}),i=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=_(t,"error",i);if(this._timeout!==!1){let a=this._timeout,c=this.setTimeoutFn(()=>{s(),i(new Error("timeout")),t.close()},a);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(s),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(_(e,"ping",this.onping.bind(this)),_(e,"data",this.ondata.bind(this)),_(e,"error",this.onerror.bind(this)),_(e,"close",this.onclose.bind(this)),_(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){T(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new H(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let n of t)if(this.nsps[n].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],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 n;this.cleanup(),(n=this.engine)===null||n===void 0||n.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 n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(s=>{s?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",s)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};var Z={};function W(r,e){typeof r=="object"&&(e=r,r=void 0),e=e||{};let t=st(r,e.path||"/socket.io"),n=t.source,s=t.id,i=t.path,o=Z[s]&&i in Z[s].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o,c;return a?c=new I(n,e):(Z[s]||(Z[s]=new I(n,e)),c=Z[s]),t.query&&!e.query&&(e.query=t.queryKey),c.socket(t.path,e)}Object.assign(W,{Manager:I,Socket:H,io:W,connect:W});function pt(r,e,t){return W(`${r}/chat`,{auth:{apiKey:e,visitorId:t??void 0},transports:["websocket"]})}var nr="chat",ut={chat:'<path d="M4 5h16v11H9l-4 3.5V16H4V5Z"/><path d="M8 9h8M8 12h5"/>',"chat-round":'<path d="M12 4c4.97 0 9 3.36 9 7.5S16.97 19 12 19c-1 0-1.96-.14-2.85-.4L5 20l1.2-3.6C4.8 15 4 13.3 4 11.5 4 7.36 7.03 4 12 4Z"/>',"chat-dots":'<path d="M12 4c4.97 0 9 3.36 9 7.5S16.97 19 12 19c-1 0-1.96-.14-2.85-.4L5 20l1.2-3.6C4.8 15 4 13.3 4 11.5 4 7.36 7.03 4 12 4Z"/><circle cx="9" cy="11.5" r=".9" fill="currentColor" stroke="none"/><circle cx="12" cy="11.5" r=".9" fill="currentColor" stroke="none"/><circle cx="15" cy="11.5" r=".9" fill="currentColor" stroke="none"/>',"chat-two":'<path d="M4 5.5h10v7h-4l-2.5 2V12.5H4V5.5Z"/><path d="M10 10.5h10v7h-3.5L14 20v-2.5h-4v-7Z"/>',thought:'<path d="M8 5.5a5 5 0 0 1 9 3 4 4 0 0 1-1 7.9H8.5A4.5 4.5 0 0 1 8 5.5Z"/><circle cx="7" cy="18" r="1" fill="currentColor" stroke="none"/><circle cx="5" cy="20.5" r=".6" fill="currentColor" stroke="none"/>',mail:'<rect x="3.5" y="6" width="17" height="12" rx="1.5"/><path d="M4 7l8 6 8-6"/>',"mail-open":'<rect x="3.5" y="8" width="17" height="10" rx="1.5"/><path d="M3.5 8 12 3l8.5 5"/><path d="M3.5 8 10 13M20.5 8 14 13"/>',send:'<path d="M4 12 20 4l-4 16-5-6-6-2Z"/><path d="M20 4 9.5 14"/>',robot:'<rect x="5" y="8" width="14" height="10" rx="2.5"/><path d="M12 8V5"/><circle cx="12" cy="4" r="1.1" fill="currentColor" stroke="none"/><circle cx="9" cy="13" r="1.1" fill="currentColor" stroke="none"/><circle cx="15" cy="13" r="1.1" fill="currentColor" stroke="none"/><path d="M9 16.5h6"/>',brain:'<path d="M9 4.5a3 3 0 0 0-3 3 3 3 0 0 0-1 5.6 3 3 0 0 0 3.6 4A3 3 0 0 0 12 19V6a2.5 2.5 0 0 0-3-1.5Z"/><path d="M15 4.5a3 3 0 0 1 3 3 3 3 0 0 1 1 5.6 3 3 0 0 1-3.6 4A3 3 0 0 1 12 19V6a2.5 2.5 0 0 1 3-1.5Z"/>',bulb:'<path d="M9 16.5h6M10 19.5h4"/><path d="M12 3.5a6 6 0 0 0-3.2 11.1c.6.4 1 1.1 1 1.9h4.4c0-.8.4-1.5 1-1.9A6 6 0 0 0 12 3.5Z"/>',bolt:'<path d="M12.5 3 5 13.5h5.5L11 21l7.5-10.5H13l-.5-7.5Z"/>',sparkles:'<path d="M12 3.5c.5 3 1.7 4.2 4.7 4.7-3 .5-4.2 1.7-4.7 4.7-.5-3-1.7-4.2-4.7-4.7 3-.5 4.2-1.7 4.7-4.7Z"/><path d="M18.5 14c.3 1.7 1 2.4 2.7 2.7-1.7.3-2.4 1-2.7 2.7-.3-1.7-1-2.4-2.7-2.7 1.7-.3 2.4-1 2.7-2.7Z"/>',orbit:'<circle cx="12" cy="12" r="1.6" fill="currentColor" stroke="none"/><ellipse cx="12" cy="12" rx="9" ry="3.6"/><ellipse cx="12" cy="12" rx="9" ry="3.6" transform="rotate(60 12 12)"/><ellipse cx="12" cy="12" rx="9" ry="3.6" transform="rotate(120 12 12)"/>',rocket:'<path d="M12 3c2.5 1.5 4 4.5 4 8.5 0 2-1 4-1 4H9s-1-2-1-4c0-4 1.5-7 4-8.5Z"/><circle cx="12" cy="9" r="1.4"/><path d="M9 15l-2.5 2.5M15 15l2.5 2.5M10 19l2 2 2-2"/>',wand:'<path d="M4 20 15 9"/><path d="M17 4l.8 1.9L19.7 6.7 17.8 7.5 17 9.4 16.2 7.5 14.3 6.7 16.2 5.9 17 4Z"/><path d="M6 13.5l.5 1.2 1.2.5-1.2.5-.5 1.2-.5-1.2L4.3 15l1.2-.5.5-1.2Z"/>',wave:'<path d="M9 13V6a1.5 1.5 0 0 1 3 0v5"/><path d="M12 11V4.5a1.5 1.5 0 0 1 3 0V11"/><path d="M15 11V6a1.5 1.5 0 0 1 3 0v8c0 3-2 6-6 6s-6-2.5-6.5-5L4 12.5a1.4 1.4 0 0 1 2.3-1.6L9 14"/>',"raised-hand":'<path d="M7 20V10a1.2 1.2 0 0 1 2.4 0v3"/><path d="M9.4 12.5V6a1.2 1.2 0 0 1 2.4 0v6.5"/><path d="M11.8 12.5V5a1.2 1.2 0 0 1 2.4 0v7.5"/><path d="M14.2 12.5V7a1.2 1.2 0 0 1 2.4 0v7c0 3.3-2.3 6-6 6-2.5 0-4-1.2-5-3l-2-3.6a1.3 1.3 0 0 1 2.2-1.3l1.6 2.4"/>',smile:'<circle cx="12" cy="12" r="8.5"/><path d="M8.5 14c1 1.3 2.2 2 3.5 2s2.5-.7 3.5-2"/><circle cx="9" cy="10" r=".9" fill="currentColor" stroke="none"/><circle cx="15" cy="10" r=".9" fill="currentColor" stroke="none"/>',"smile-chat":'<path d="M12 4c4.97 0 9 3.36 9 7.5S16.97 19 12 19c-1 0-1.96-.14-2.85-.4L5 20l1.2-3.6C4.8 15 4 13.3 4 11.5 4 7.36 7.03 4 12 4Z"/><circle cx="9.5" cy="11" r=".8" fill="currentColor" stroke="none"/><circle cx="14.5" cy="11" r=".8" fill="currentColor" stroke="none"/><path d="M9.5 13.5c.7.8 1.5 1.2 2.5 1.2s1.8-.4 2.5-1.2"/>',handshake:'<path d="M3 12l4-3 3.5 2-1.5 2"/><path d="M21 12l-4-3-3.5 2 1.5 2"/><path d="M9 13l2.5 2.2a1.4 1.4 0 0 0 2-2l-3-2.7"/><path d="M15 13l-2.5 2.2"/>',"heart-chat":'<path d="M12 20s-7-4.4-9.3-8.8C1.3 8 3 5 6.2 5c2 0 3.4 1.2 4.3 2.4C11.4 6.2 12.8 5 14.8 5 18 5 19.7 8 17.3 11.2 15 15.6 12 20 12 20Z"/>',"thumbs-up":'<path d="M7 11v9H4v-9h3Z"/><path d="M7 11l3.5-6.5a1.6 1.6 0 0 1 3 1l-1 4.5H17a2 2 0 0 1 2 2.4l-1.3 6A2 2 0 0 1 15.7 20H10a3 3 0 0 1-3-3v-6Z"/>',wink:'<circle cx="12" cy="12" r="8.5"/><path d="M8.5 14c1 1.3 2.2 2 3.5 2s2.5-.7 3.5-2"/><path d="M7.5 10h3"/><circle cx="15" cy="10" r=".9" fill="currentColor" stroke="none"/>',headset:'<path d="M4 13a8 8 0 0 1 16 0"/><rect x="3" y="13" width="4" height="6" rx="1.5"/><rect x="17" y="13" width="4" height="6" rx="1.5"/><path d="M19 19v1a3 3 0 0 1-3 3h-3"/>',bell:'<path d="M6 17V11a6 6 0 0 1 12 0v6l1.5 2h-15L6 17Z"/><path d="M10 20.5a2 2 0 0 0 4 0"/>',megaphone:'<path d="M3 10v4h3l6 4V6L6 10H3Z"/><path d="M14 9a4 4 0 0 1 0 6"/><path d="M17 6.5a8 8 0 0 1 0 11"/>',broadcast:'<circle cx="12" cy="12" r="2"/><path d="M8.5 8.5a5 5 0 0 0 0 7M15.5 8.5a5 5 0 0 1 0 7"/><path d="M5.5 5.5a9.5 9.5 0 0 0 0 13M18.5 5.5a9.5 9.5 0 0 1 0 13"/>',"life-ring":'<circle cx="12" cy="12" r="8.5"/><circle cx="12" cy="12" r="3.5"/><path d="M6 6l3.5 3.5M18 6l-3.5 3.5M6 18l3.5-3.5M18 18l-3.5-3.5"/>',question:'<circle cx="12" cy="12" r="8.5"/><path d="M9.5 9.3a2.5 2.5 0 1 1 3.6 2.3c-.8.5-1.1.9-1.1 1.9"/><circle cx="12" cy="16.5" r=".9" fill="currentColor" stroke="none"/>',info:'<circle cx="12" cy="12" r="8.5"/><circle cx="12" cy="8" r=".9" fill="currentColor" stroke="none"/><path d="M12 11v6"/>',"phone-support":'<path d="M6.5 4.5h3L11 8l-2 1.5a11 11 0 0 0 5.5 5.5L16 13l3.5 1.5v3a2 2 0 0 1-2.2 2A15.5 15.5 0 0 1 4.5 6.7a2 2 0 0 1 2-2.2Z"/>',star:'<path d="M12 3.5l2.4 5.1 5.6.6-4.2 3.8 1.2 5.5L12 15.7l-5 2.8 1.2-5.5-4.2-3.8 5.6-.6L12 3.5Z"/>',"star-fill":'<path d="M12 3.5l2.4 5.1 5.6.6-4.2 3.8 1.2 5.5L12 15.7l-5 2.8 1.2-5.5-4.2-3.8 5.6-.6L12 3.5Z" fill="currentColor"/>',"check-circle":'<circle cx="12" cy="12" r="8.5"/><path d="M8.5 12.3 11 15l4.5-5.5"/>',target:'<circle cx="12" cy="12" r="8.5"/><circle cx="12" cy="12" r="5"/><circle cx="12" cy="12" r="1.4" fill="currentColor" stroke="none"/>',flame:'<path d="M12 3.5c1 2.5-.5 3.5-1.5 5C9 10 8 11.5 8 13.5A4 4 0 0 0 12 17.5a4 4 0 0 0 4-4c0-1.5-.7-2.3-1.3-3 .3 1.2-.2 2-1 2.3.3-2-1-2.7-1.7-4.3Z"/>',"shield-check":'<path d="M12 3.5 19 6.5V11c0 5-3 8.2-7 9.5-4-1.3-7-4.5-7-9.5V6.5L12 3.5Z"/><path d="M9 12l2 2 4-4.5"/>',crown:'<path d="M4 17l-1.5-8L7 12l5-6 5 6 4.5-3L20 17H4Z"/><path d="M4 19.5h16"/>',gift:'<rect x="4" y="9.5" width="16" height="10" rx="1"/><path d="M4 13h16"/><path d="M12 9.5v10"/><path d="M12 9.5c-1-2.5-2.8-4-4.3-4A2 2 0 0 0 6 7.5c0 1.3 1.2 2 2.5 2H12Z"/><path d="M12 9.5c1-2.5 2.8-4 4.3-4A2 2 0 0 1 18 7.5c0 1.3-1.2 2-2.5 2H12Z"/>'};function Ae(r){return`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">${r&&ut[r]||ut[nr]}</svg>`}var oe={SOFT:{waveform:"sine",gain:.12,tones:{CHAT_OPENED:[{freq:523,start:0,duration:.14}],BOT_REPLY:[{freq:659,start:0,duration:.16}],AGENT_MESSAGE:[{freq:494,start:0,duration:.14},{freq:587,start:.12,duration:.2}],RULE_TRIGGERED:[{freq:587,start:0,duration:.13}],COMMAND_EXECUTED:[{freq:440,start:0,duration:.18}]}},CLASSIC:{waveform:"sine",gain:.2,tones:{CHAT_OPENED:[{freq:660,start:0,duration:.09}],BOT_REPLY:[{freq:880,start:0,duration:.12}],AGENT_MESSAGE:[{freq:587,start:0,duration:.1},{freq:784,start:.1,duration:.14}],RULE_TRIGGERED:[{freq:740,start:0,duration:.08},{freq:740,start:.12,duration:.08}],COMMAND_EXECUTED:[{freq:784,start:0,duration:.1},{freq:660,start:.1,duration:.14}]}},BELL:{waveform:"triangle",gain:.15,tones:{CHAT_OPENED:[{freq:784,start:0,duration:.1},{freq:988,start:.05,duration:.12}],BOT_REPLY:[{freq:1046,start:0,duration:.18}],AGENT_MESSAGE:[{freq:659,start:0,duration:.12},{freq:784,start:.1,duration:.12},{freq:988,start:.2,duration:.22}],RULE_TRIGGERED:[{freq:1174,start:0,duration:.14}],COMMAND_EXECUTED:[{freq:880,start:0,duration:.1},{freq:1046,start:.1,duration:.16}]}}},sr={enabled:!0,soundStyle:"CLASSIC"},ae=class{constructor(){this.triggers={}}setTriggers(e){this.triggers=e}prime(){if(this.context){this.context.state==="suspended"&&this.context.resume();return}let e=window.AudioContext??window.webkitAudioContext;if(e)try{this.context=new e}catch{}}play(e){let t=this.context;if(!t)return;let n=this.triggers[e]??sr;if(!n.enabled)return;let{waveform:s,gain:i}=oe[n.soundStyle]??oe.CLASSIC,o=(oe[n.soundStyle]??oe.CLASSIC).tones[e],a=t.currentTime;for(let c of o){let f=t.createOscillator(),u=t.createGain();f.type=s,f.frequency.value=c.freq;let d=a+c.start,b=d+c.duration;u.gain.setValueAtTime(0,d),u.gain.linearRampToValueAtTime(i,d+.01),u.gain.linearRampToValueAtTime(0,b),f.connect(u),u.connect(t.destination),f.start(d),f.stop(b+.02)}}};var ft="chat:ready";var dt="chat:close",mt="chat:toggle",yt="chat:resize",gt="chat:send",_t="chat:bot-reply",bt="chat:connect-error",xt="chat:history",Et="chat:admin-message",Tt="chat:admin-typing",we="chat:agent-presence",At="chat:typing",wt="chat:upload-attachment",Ct="chat:attachment-uploaded",vt="chat:attachment-upload-error";var Ce="zabbu-chat-widget-launcher",ve="zabbu-chat-widget-panel",kt="zabbu-chat-widget-iframe",X="zabbu-chat-widget-teaser",Se="zabbu-chat-widget-badge",Rt="#2563eb";function ir(r,e){switch(r){case"NONE":return{launcher:"none",panel:"none",teaser:"none"};case"ELEVATED":return{launcher:"0 16px 40px -8px rgba(0, 0, 0, 0.45), 0 6px 16px rgba(0, 0, 0, 0.25)",panel:"0 30px 80px -16px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.3)",teaser:"0 20px 50px -12px rgba(0, 0, 0, 0.4), 0 8px 20px rgba(0, 0, 0, 0.2)"};case"BRAND_GLOW":{let t=ke(e,.5),n=ke(e,.3);return{launcher:`0 10px 26px -4px ${t}, 0 3px 10px ${n}`,panel:`0 26px 64px -12px ${t}, 0 10px 28px ${n}`,teaser:`0 18px 42px -8px ${t}, 0 6px 16px ${n}`}}case"SOFT":default:return{launcher:"0 4px 12px rgba(0, 0, 0, 0.2)",panel:"0 8px 30px rgba(0, 0, 0, 0.25)",teaser:"0 6px 20px rgba(0, 0, 0, 0.15)"}}}function ke(r,e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r);if(!t)return ke(Rt,e);let[n,s,i]=t.slice(1).map(o=>parseInt(o,16));return`rgba(${n}, ${s}, ${i}, ${e})`}function or(r,e,t){let n=r||Rt,s=ir(e,n),i=document.documentElement.style;i.setProperty("--zabbu-chat-primary",n),i.setProperty("--zabbu-chat-shadow-launcher",s.launcher),i.setProperty("--zabbu-chat-shadow-panel",s.panel),i.setProperty("--zabbu-chat-shadow-teaser",s.teaser),document.getElementById(X)?.classList.toggle("zabbu-chat-teaser-dark",t==="DARK")}async function ar(r,e){try{let t=await fetch(`${r}/public/sites/${e}`);if(!t.ok)return;let n=await t.json();or(n.primaryColor??null,n.shadowStyle??"SOFT",n.colorScheme??"LIGHT")}catch{}}function cr(){let r=document.currentScript;if(!r)throw new Error("zabbu-chat-widget: loader.js must run as a plain <script> tag");return r}function hr(r){let e=r.dataset.apiBase;return e?e.replace(/\/$/,""):"http://localhost:3002"}function lr(r){return new URL(r.src).origin}function St(r){return`zabbu-chat-visitor:${r}`}function pr(){let r=document.createElement("style");r.textContent=`
|
|
1
|
+
"use strict";(()=>{var Lt=Object.defineProperty;var Pt=(r,e)=>{for(var t in e)Lt(r,t,{get:e[t],enumerable:!0})};var x=Object.create(null);x.open="0";x.close="1";x.ping="2";x.pong="3";x.message="4";x.upgrade="5";x.noop="6";var U=Object.create(null);Object.keys(x).forEach(r=>{U[x[r]]=r});var V={type:"error",data:"parser error"};var Ie=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",De=typeof ArrayBuffer=="function",qe=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer,F=({type:r,data:e},t,n)=>Ie&&e instanceof Blob?t?n(e):Be(e,n):De&&(e instanceof ArrayBuffer||qe(e))?t?n(e):Be(new Blob([e]),n):n(x[r]+(e||"")),Be=(r,e)=>{let t=new FileReader;return t.onload=function(){let n=t.result.split(",")[1];e("b"+(n||""))},t.readAsDataURL(r)};function He(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}var le;function Ue(r,e){if(Ie&&r.data instanceof Blob)return r.data.arrayBuffer().then(He).then(e);if(De&&(r.data instanceof ArrayBuffer||qe(r.data)))return e(He(r.data));F(r,!1,t=>{le||(le=new TextEncoder),e(le.encode(t))})}var Ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",G=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let r=0;r<Ve.length;r++)G[Ve.charCodeAt(r)]=r;var Fe=r=>{let e=r.length*.75,t=r.length,n,s=0,i,o,a,c;r[r.length-1]==="="&&(e--,r[r.length-2]==="="&&e--);let f=new ArrayBuffer(e),u=new Uint8Array(f);for(n=0;n<t;n+=4)i=G[r.charCodeAt(n)],o=G[r.charCodeAt(n+1)],a=G[r.charCodeAt(n+2)],c=G[r.charCodeAt(n+3)],u[s++]=i<<2|o>>4,u[s++]=(o&15)<<4|a>>2,u[s++]=(a&3)<<6|c&63;return f};var Mt=typeof ArrayBuffer=="function",z=(r,e)=>{if(typeof r!="string")return{type:"message",data:Ge(r,e)};let t=r.charAt(0);return t==="b"?{type:"message",data:Bt(r.substring(1),e)}:U[t]?r.length>1?{type:U[t],data:r.substring(1)}:{type:U[t]}:V},Bt=(r,e)=>{if(Mt){let t=Fe(r);return Ge(t,e)}else return{base64:!0,data:r}},Ge=(r,e)=>{switch(e){case"blob":return r instanceof Blob?r:new Blob([r]);case"arraybuffer":default:return r instanceof ArrayBuffer?r:r.buffer}};var ze="",Ye=(r,e)=>{let t=r.length,n=new Array(t),s=0;r.forEach((i,o)=>{F(i,!1,a=>{n[o]=a,++s===t&&e(n.join(ze))})})},$e=(r,e)=>{let t=r.split(ze),n=[];for(let s=0;s<t.length;s++){let i=z(t[s],e);if(n.push(i),i.type==="error")break}return n};function Ke(){return new TransformStream({transform(r,e){Ue(r,t=>{let n=t.length,s;if(n<126)s=new Uint8Array(1),new DataView(s.buffer).setUint8(0,n);else if(n<65536){s=new Uint8Array(3);let i=new DataView(s.buffer);i.setUint8(0,126),i.setUint16(1,n)}else{s=new Uint8Array(9);let i=new DataView(s.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(n))}r.data&&typeof r.data!="string"&&(s[0]|=128),e.enqueue(s),e.enqueue(t)})}})}var pe;function J(r){return r.reduce((e,t)=>e+t.length,0)}function Q(r,e){if(r[0].length===e)return r.shift();let t=new Uint8Array(e),n=0;for(let s=0;s<e;s++)t[s]=r[0][n++],n===r[0].length&&(r.shift(),n=0);return r.length&&n<r[0].length&&(r[0]=r[0].slice(n)),t}function Ze(r,e){pe||(pe=new TextDecoder);let t=[],n=0,s=-1,i=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(n===0){if(J(t)<1)break;let c=Q(t,1);i=(c[0]&128)===128,s=c[0]&127,s<126?n=3:s===126?n=1:n=2}else if(n===1){if(J(t)<2)break;let c=Q(t,2);s=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),n=3}else if(n===2){if(J(t)<8)break;let c=Q(t,8),f=new DataView(c.buffer,c.byteOffset,c.length),u=f.getUint32(0);if(u>Math.pow(2,21)-1){a.enqueue(V);break}s=u*Math.pow(2,32)+f.getUint32(4),n=3}else{if(J(t)<s)break;let c=Q(t,s);a.enqueue(z(i?c:pe.decode(c),e)),n=0}if(s===0||s>r){a.enqueue(V);break}}}})}var ue=4;function p(r){if(r)return Ht(r)}function Ht(r){for(var e in p.prototype)r[e]=p.prototype[e];return r}p.prototype.on=p.prototype.addEventListener=function(r,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(e),this};p.prototype.once=function(r,e){function t(){this.off(r,t),e.apply(this,arguments)}return t.fn=e,this.on(r,t),this};p.prototype.off=p.prototype.removeListener=p.prototype.removeAllListeners=p.prototype.removeEventListener=function(r,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+r];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var n,s=0;s<t.length;s++)if(n=t[s],n===e||n.fn===e){t.splice(s,1);break}return t.length===0&&delete this._callbacks["$"+r],this};p.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+r],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(t){t=t.slice(0);for(var n=0,s=t.length;n<s;++n)t[n].apply(this,e)}return this};p.prototype.emitReserved=p.prototype.emit;p.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]};p.prototype.hasListeners=function(r){return!!this.listeners(r).length};var T=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),g=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),We="arraybuffer";function j(r,...e){return e.reduce((t,n)=>(r.hasOwnProperty(n)&&(t[n]=r[n]),t),{})}var It=g.setTimeout,Dt=g.clearTimeout;function A(r,e){e.useNativeTimers?(r.setTimeoutFn=It.bind(g),r.clearTimeoutFn=Dt.bind(g)):(r.setTimeoutFn=g.setTimeout.bind(g),r.clearTimeoutFn=g.clearTimeout.bind(g))}var qt=1.33;function Xe(r){return typeof r=="string"?Ut(r):Math.ceil((r.byteLength||r.size)*qt)}function Ut(r){let e=0,t=0;for(let n=0,s=r.length;n<s;n++)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(n++,t+=4);return t}function ee(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Je(r){let e="";for(let t in r)r.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(r[t]));return e}function Qe(r){let e={},t=r.split("&");for(let n=0,s=t.length;n<s;n++){let i=t[n].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}var te=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}},w=class extends p{constructor(e){super(),this.writable=!1,A(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved("error",new te(e,t,n)),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=z(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&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=Je(e);return t.length?"?"+t:""}};var Y=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 n=0;this._polling&&(n++,this.once("pollComplete",function(){--n||t()})),this.writable||(n++,this.once("drain",function(){--n||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){let t=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};$e(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,Ye(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]=ee()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}};var je=!1;try{je=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var et=je;function Vt(){}var fe=class extends Y{constructor(e){if(super(e),typeof location<"u"){let t=location.protocol==="https:",n=location.port;n||(n=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(s,i)=>{this.onError("xhr post error",s,i)})}doPoll(){let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,n)=>{this.onError("xhr poll error",t,n)}),this.pollXhr=e}},v=class r extends p{constructor(e,t,n){super(),this.createRequest=e,A(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var e;let t=j(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;let n=this._xhr=this.createRequest(t);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let s in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(s)&&n.setRequestHeader(s,this._opts.extraHeaders[s])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var s;n.readyState===3&&((s=this._opts.cookieJar)===null||s===void 0||s.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},n.send(this._data)}catch(s){this.setTimeoutFn(()=>{this._onError(s)},0);return}typeof document<"u"&&(this._index=r.requestsCount++,r.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Vt,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete r.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};v.requestsCount=0;v.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",tt);else if(typeof addEventListener=="function"){let r="onpagehide"in g?"pagehide":"unload";addEventListener(r,tt,!1)}}function tt(){for(let r in v.requests)v.requests.hasOwnProperty(r)&&v.requests[r].abort()}var Ft=function(){let r=rt({xdomain:!1});return r&&r.responseType!==null}(),S=class extends fe{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=Ft&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new v(rt,this.uri(),e)}};function rt(r){let e=r.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||et))return new XMLHttpRequest}catch{}if(!e)try{return new g[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var nt=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",me=class extends w{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,n=nt?{}:j(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(s){return this.emitReserved("error",s)}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 n=e[t],s=t===e.length-1;F(n,this.supportsBinary,i=>{try{this.doWrite(n,i)}catch{}s&&T(()=>{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]=ee()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},de=g.WebSocket||g.MozWebSocket,k=class extends me{createSocket(e,t,n){return nt?new de(e,t,n):t?new de(e,t):new de(e)}doWrite(e,t){this.ws.send(t)}};var P=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=Ze(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),s=Ke();s.readable.pipeTo(e.writable),this._writer=s.writable.getWriter();let i=()=>{n.read().then(({done:a,value:c})=>{a||(this.onPacket(c),i())}).catch(a=>{})};i();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 n=e[t],s=t===e.length-1;this._writer.write(n).then(()=>{s&&T(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}};var ye={websocket:k,webtransport:P,polling:S};var Gt=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,zt=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function M(r){if(r.length>8e3)throw"URI too long";let e=r,t=r.indexOf("["),n=r.indexOf("]");t!=-1&&n!=-1&&(r=r.substring(0,t)+r.substring(t,n).replace(/:/g,";")+r.substring(n,r.length));let s=Gt.exec(r||""),i={},o=14;for(;o--;)i[zt[o]]=s[o]||"";return t!=-1&&n!=-1&&(i.source=e,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=Yt(i,i.path),i.queryKey=$t(i,i.query),i}function Yt(r,e){let t=/\/{2,9}/g,n=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&n.splice(0,1),e.slice(-1)=="/"&&n.splice(n.length-1,1),n}function $t(r,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,s,i){s&&(t[s]=i)}),t}var ge=typeof addEventListener=="function"&&typeof removeEventListener=="function",re=[];ge&&addEventListener("offline",()=>{re.forEach(r=>r())},!1);var N=class r extends p{constructor(e,t){if(super(),this.binaryType=We,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(t=e,e=null),e){let n=M(e);t.hostname=n.host,t.secure=n.protocol==="https"||n.protocol==="wss",t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=M(t.host).host);A(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(n=>{let s=n.prototype.name;this.transports.push(s),this._transportsByName[s]=n}),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},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Qe(this.opts.query)),ge&&(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"})},re.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=ue,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let e=this.opts.rememberUpgrade&&r.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";let t=this.createTransport(e);t.open(),this.setTransport(t)}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))}onOpen(){this.readyState="open",r.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_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._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let 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._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),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 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 t=1;for(let n=0;n<this.writeBuffer.length;n++){let s=this.writeBuffer[n].data;if(s&&(t+=Xe(s)),n>0&&t>this._maxPayload)return this.writeBuffer.slice(0,n);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,T(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket("message",e,t,n),this}send(e,t,n){return this._sendPacket("message",e,t,n),this}_sendPacket(e,t,n,s){if(typeof t=="function"&&(s=t,t=void 0),typeof n=="function"&&(s=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;let i={type:e,data:t,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),s&&this.once("flush",s),this.flush()}close(){let e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{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?n():e()}):this.upgrading?n():e()),this}_onError(e){if(r.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){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(),ge&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let n=re.indexOf(this._offlineEventListener);n!==-1&&re.splice(n,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}};N.protocol=ue;var ne=class extends N{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),n=!1;N.priorWebsocketSuccess=!1;let s=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",d=>{if(!n)if(d.type==="pong"&&d.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;N.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(u(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{let b=new Error("probe error");b.transport=t.name,this.emitReserved("upgradeError",b)}}))};function i(){n||(n=!0,u(),t.close(),t=null)}let o=d=>{let b=new Error("probe error: "+d);b.transport=t.name,i(),this.emitReserved("upgradeError",b)};function a(){o("transport closed")}function c(){o("socket closed")}function f(d){t&&d.name!==t.name&&i()}let u=()=>{t.removeListener("open",s),t.removeListener("error",o),t.removeListener("close",a),this.off("close",c),this.off("upgrading",f)};t.once("open",s),t.once("error",o),t.once("close",a),this.once("close",c),this.once("upgrading",f),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},B=class extends ne{constructor(e,t={}){let n=typeof e=="object",s=n?{...e}:{...t};(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(i=>ye[i]).filter(i=>!!i)),super(n?s:e,s)}};var xn=B.protocol;function st(r,e="",t){let n=r;t=t||typeof location<"u"&&location,r==null&&(r=t.protocol+"//"+t.host),typeof r=="string"&&(r.charAt(0)==="/"&&(r.charAt(1)==="/"?r=t.protocol+r:r=t.host+r),/^(https?|wss?):\/\//.test(r)||(typeof t<"u"?r=t.protocol+"//"+r:r="https://"+r),n=M(r)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";let i=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port+e,n.href=n.protocol+"://"+i+(t&&t.port===n.port?"":":"+n.port),n}var Te={};Pt(Te,{Decoder:()=>xe,Encoder:()=>be,PacketType:()=>h,isPacketValid:()=>tr,protocol:()=>ht});var Zt=typeof ArrayBuffer=="function",Wt=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,it=Object.prototype.toString,Xt=typeof Blob=="function"||typeof Blob<"u"&&it.call(Blob)==="[object BlobConstructor]",Jt=typeof File=="function"||typeof File<"u"&&it.call(File)==="[object FileConstructor]";function K(r){return Zt&&(r instanceof ArrayBuffer||Wt(r))||Xt&&r instanceof Blob||Jt&&r instanceof File}function $(r,e){if(!r||typeof r!="object")return!1;if(Array.isArray(r)){for(let t=0,n=r.length;t<n;t++)if($(r[t]))return!0;return!1}if(K(r))return!0;if(r.toJSON&&typeof r.toJSON=="function"&&arguments.length===1)return $(r.toJSON(),!0);for(let t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&$(r[t]))return!0;return!1}function ot(r){let e=[],t=r.data,n=r;return n.data=se(t,e),n.attachments=e.length,{packet:n,buffers:e}}function se(r,e,t){if(!r)return r;if(K(r)){let n={_placeholder:!0,num:e.length};return e.push(r),n}else if(Array.isArray(r)){let n=new Array(r.length);for(let s=0;s<r.length;s++)n[s]=se(r[s],e);return n}else if(typeof r=="object"&&!(r instanceof Date)){if(r.toJSON&&typeof r.toJSON=="function"&&!t)return se(r.toJSON(),e,!0);let n={};for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=se(r[s],e));return n}return r}function at(r,e){return r.data=_e(r.data,e),delete r.attachments,r}function _e(r,e){if(!r)return r;if(r&&r._placeholder===!0){if(typeof r.num=="number"&&r.num>=0&&r.num<e.length)return e[r.num];throw new Error("illegal attachments")}else if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]=_e(r[t],e);else if(typeof r=="object")for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&(r[t]=_e(r[t],e));return r}var ct=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],ht=5,h;(function(r){r[r.CONNECT=0]="CONNECT",r[r.DISCONNECT=1]="DISCONNECT",r[r.EVENT=2]="EVENT",r[r.ACK=3]="ACK",r[r.CONNECT_ERROR=4]="CONNECT_ERROR",r[r.BINARY_EVENT=5]="BINARY_EVENT",r[r.BINARY_ACK=6]="BINARY_ACK"})(h||(h={}));var be=class{constructor(e){this.replacer=e}encode(e){return(e.type===h.EVENT||e.type===h.ACK)&&$(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=ot(e),n=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(n),s}},xe=class r extends p{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}: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 n=t.type===h.BINARY_EVENT;n||t.type===h.BINARY_ACK?(t.type=n?h.EVENT:h.ACK,this.reconstructor=new Ee(t)):super.emitReserved("decoded",t)}else if(K(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,n={type:Number(e.charAt(0))};if(h[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===h.BINARY_EVENT||n.type===h.BINARY_ACK){let i=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let o=e.substring(i,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");let a=Number(o);if(!lt(a)||a<1)throw new Error("Illegal attachments");if(a>this.opts.maxAttachments)throw new Error("too many attachments");n.attachments=a}if(e.charAt(t+1)==="/"){let i=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););n.nsp=e.substring(i,t)}else n.nsp="/";let s=e.charAt(t+1);if(s!==""&&Number(s)==s){let i=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}n.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){let i=this.tryParse(e.substr(t));if(r.isPayloadValid(n.type,i))n.data=i;else throw new Error("invalid payload")}return n}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case h.CONNECT:return ie(t);case h.DISCONNECT:return t===void 0;case h.CONNECT_ERROR:return typeof t=="string"||ie(t);case h.EVENT:case h.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&ct.indexOf(t[0])===-1);case h.ACK:case h.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},Ee=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=at(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function Qt(r){return typeof r=="string"}var lt=Number.isInteger||function(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r};function jt(r){return r===void 0||lt(r)}function ie(r){return Object.prototype.toString.call(r)==="[object Object]"}function er(r,e){switch(r){case h.CONNECT:return e===void 0||ie(e);case h.DISCONNECT:return e===void 0;case h.EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&ct.indexOf(e[0])===-1);case h.ACK:return Array.isArray(e);case h.CONNECT_ERROR:return typeof e=="string"||ie(e);default:return!1}}function tr(r){return Qt(r.nsp)&&jt(r.id)&&er(r.type,r.data)}function _(r,e,t){return r.on(e,t),function(){r.off(e,t)}}var rr=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),H=class extends p{constructor(e,t,n){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,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[_(e,"open",this.onopen.bind(this)),_(e,"packet",this.onpacket.bind(this)),_(e,"error",this.onerror.bind(this)),_(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 n,s,i;if(rr.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++,d=t.pop();this._registerAckCallback(u,d),o.id=u}let a=(s=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||s===void 0?void 0:s.writable,c=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!a||(c?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,t){var n;let s=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(s===void 0){this.acks[e]=t;return}let i=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===e&&this.sendBuffer.splice(a,1);t.call(this,new Error("operation has timed out"))},s),o=(...a)=>{this.io.clearTimeoutFn(i),t.apply(this,a)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...t){return new Promise((n,s)=>{let i=(o,a)=>o?s(o):n(a);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((s,...i)=>(this._queue[0],s!==null?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(s)):(this._queue.shift(),t&&t(null,...i)),n.pending=!1,this._drainQueue())),this._queue.push(n),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(n=>String(n.id)===e)){let n=this.acks[e];delete this.acks[e],n.withError&&n.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 n=new Error(e.data.message);n.data=e.data.data,this.emitReserved("connect_error",n);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 n of t)n.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,n=!1;return function(...s){n||(n=!0,t.packet({type:h.ACK,id:e,data:s}))}}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 n=0;n<t.length;n++)if(e===t[n])return t.splice(n,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 n=0;n<t.length;n++)if(e===t[n])return t.splice(n,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 n of t)n.apply(this,e.data)}}};function L(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}L.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*r);r=Math.floor(e*10)&1?r+t:r-t}return Math.min(r,this.max)|0};L.prototype.reset=function(){this.attempts=0};L.prototype.setMin=function(r){this.ms=r};L.prototype.setMax=function(r){this.max=r};L.prototype.setJitter=function(r){this.jitter=r};var I=class extends p{constructor(e,t){var n;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,A(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((n=t.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new L({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let s=t.parser||Te;this.encoder=new s.Encoder,this.decoder=new s.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 B(this.uri,this.opts);let t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;let s=_(t,"open",function(){n.onopen(),e&&e()}),i=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=_(t,"error",i);if(this._timeout!==!1){let a=this._timeout,c=this.setTimeoutFn(()=>{s(),i(new Error("timeout")),t.close()},a);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(s),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(_(e,"ping",this.onping.bind(this)),_(e,"data",this.ondata.bind(this)),_(e,"error",this.onerror.bind(this)),_(e,"close",this.onclose.bind(this)),_(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){T(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new H(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let n of t)if(this.nsps[n].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],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 n;this.cleanup(),(n=this.engine)===null||n===void 0||n.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 n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(s=>{s?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",s)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};var Z={};function W(r,e){typeof r=="object"&&(e=r,r=void 0),e=e||{};let t=st(r,e.path||"/socket.io"),n=t.source,s=t.id,i=t.path,o=Z[s]&&i in Z[s].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o,c;return a?c=new I(n,e):(Z[s]||(Z[s]=new I(n,e)),c=Z[s]),t.query&&!e.query&&(e.query=t.queryKey),c.socket(t.path,e)}Object.assign(W,{Manager:I,Socket:H,io:W,connect:W});function pt(r,e,t){return W(`${r}/chat`,{auth:{apiKey:e,visitorId:t??void 0},transports:["websocket"]})}var nr="chat",ut={chat:'<path d="M4 5h16v11H9l-4 3.5V16H4V5Z"/><path d="M8 9h8M8 12h5"/>',"chat-round":'<path d="M12 4c4.97 0 9 3.36 9 7.5S16.97 19 12 19c-1 0-1.96-.14-2.85-.4L5 20l1.2-3.6C4.8 15 4 13.3 4 11.5 4 7.36 7.03 4 12 4Z"/>',"chat-dots":'<path d="M12 4c4.97 0 9 3.36 9 7.5S16.97 19 12 19c-1 0-1.96-.14-2.85-.4L5 20l1.2-3.6C4.8 15 4 13.3 4 11.5 4 7.36 7.03 4 12 4Z"/><circle cx="9" cy="11.5" r=".9" fill="currentColor" stroke="none"/><circle cx="12" cy="11.5" r=".9" fill="currentColor" stroke="none"/><circle cx="15" cy="11.5" r=".9" fill="currentColor" stroke="none"/>',"chat-two":'<path d="M4 5.5h10v7h-4l-2.5 2V12.5H4V5.5Z"/><path d="M10 10.5h10v7h-3.5L14 20v-2.5h-4v-7Z"/>',thought:'<path d="M8 5.5a5 5 0 0 1 9 3 4 4 0 0 1-1 7.9H8.5A4.5 4.5 0 0 1 8 5.5Z"/><circle cx="7" cy="18" r="1" fill="currentColor" stroke="none"/><circle cx="5" cy="20.5" r=".6" fill="currentColor" stroke="none"/>',mail:'<rect x="3.5" y="6" width="17" height="12" rx="1.5"/><path d="M4 7l8 6 8-6"/>',"mail-open":'<rect x="3.5" y="8" width="17" height="10" rx="1.5"/><path d="M3.5 8 12 3l8.5 5"/><path d="M3.5 8 10 13M20.5 8 14 13"/>',send:'<path d="M4 12 20 4l-4 16-5-6-6-2Z"/><path d="M20 4 9.5 14"/>',robot:'<rect x="5" y="8" width="14" height="10" rx="2.5"/><path d="M12 8V5"/><circle cx="12" cy="4" r="1.1" fill="currentColor" stroke="none"/><circle cx="9" cy="13" r="1.1" fill="currentColor" stroke="none"/><circle cx="15" cy="13" r="1.1" fill="currentColor" stroke="none"/><path d="M9 16.5h6"/>',brain:'<path d="M9 4.5a3 3 0 0 0-3 3 3 3 0 0 0-1 5.6 3 3 0 0 0 3.6 4A3 3 0 0 0 12 19V6a2.5 2.5 0 0 0-3-1.5Z"/><path d="M15 4.5a3 3 0 0 1 3 3 3 3 0 0 1 1 5.6 3 3 0 0 1-3.6 4A3 3 0 0 1 12 19V6a2.5 2.5 0 0 1 3-1.5Z"/>',bulb:'<path d="M9 16.5h6M10 19.5h4"/><path d="M12 3.5a6 6 0 0 0-3.2 11.1c.6.4 1 1.1 1 1.9h4.4c0-.8.4-1.5 1-1.9A6 6 0 0 0 12 3.5Z"/>',bolt:'<path d="M12.5 3 5 13.5h5.5L11 21l7.5-10.5H13l-.5-7.5Z"/>',sparkles:'<path d="M12 3.5c.5 3 1.7 4.2 4.7 4.7-3 .5-4.2 1.7-4.7 4.7-.5-3-1.7-4.2-4.7-4.7 3-.5 4.2-1.7 4.7-4.7Z"/><path d="M18.5 14c.3 1.7 1 2.4 2.7 2.7-1.7.3-2.4 1-2.7 2.7-.3-1.7-1-2.4-2.7-2.7 1.7-.3 2.4-1 2.7-2.7Z"/>',orbit:'<circle cx="12" cy="12" r="1.6" fill="currentColor" stroke="none"/><ellipse cx="12" cy="12" rx="9" ry="3.6"/><ellipse cx="12" cy="12" rx="9" ry="3.6" transform="rotate(60 12 12)"/><ellipse cx="12" cy="12" rx="9" ry="3.6" transform="rotate(120 12 12)"/>',rocket:'<path d="M12 3c2.5 1.5 4 4.5 4 8.5 0 2-1 4-1 4H9s-1-2-1-4c0-4 1.5-7 4-8.5Z"/><circle cx="12" cy="9" r="1.4"/><path d="M9 15l-2.5 2.5M15 15l2.5 2.5M10 19l2 2 2-2"/>',wand:'<path d="M4 20 15 9"/><path d="M17 4l.8 1.9L19.7 6.7 17.8 7.5 17 9.4 16.2 7.5 14.3 6.7 16.2 5.9 17 4Z"/><path d="M6 13.5l.5 1.2 1.2.5-1.2.5-.5 1.2-.5-1.2L4.3 15l1.2-.5.5-1.2Z"/>',wave:'<path d="M9 13V6a1.5 1.5 0 0 1 3 0v5"/><path d="M12 11V4.5a1.5 1.5 0 0 1 3 0V11"/><path d="M15 11V6a1.5 1.5 0 0 1 3 0v8c0 3-2 6-6 6s-6-2.5-6.5-5L4 12.5a1.4 1.4 0 0 1 2.3-1.6L9 14"/>',"raised-hand":'<path d="M7 20V10a1.2 1.2 0 0 1 2.4 0v3"/><path d="M9.4 12.5V6a1.2 1.2 0 0 1 2.4 0v6.5"/><path d="M11.8 12.5V5a1.2 1.2 0 0 1 2.4 0v7.5"/><path d="M14.2 12.5V7a1.2 1.2 0 0 1 2.4 0v7c0 3.3-2.3 6-6 6-2.5 0-4-1.2-5-3l-2-3.6a1.3 1.3 0 0 1 2.2-1.3l1.6 2.4"/>',smile:'<circle cx="12" cy="12" r="8.5"/><path d="M8.5 14c1 1.3 2.2 2 3.5 2s2.5-.7 3.5-2"/><circle cx="9" cy="10" r=".9" fill="currentColor" stroke="none"/><circle cx="15" cy="10" r=".9" fill="currentColor" stroke="none"/>',"smile-chat":'<path d="M12 4c4.97 0 9 3.36 9 7.5S16.97 19 12 19c-1 0-1.96-.14-2.85-.4L5 20l1.2-3.6C4.8 15 4 13.3 4 11.5 4 7.36 7.03 4 12 4Z"/><circle cx="9.5" cy="11" r=".8" fill="currentColor" stroke="none"/><circle cx="14.5" cy="11" r=".8" fill="currentColor" stroke="none"/><path d="M9.5 13.5c.7.8 1.5 1.2 2.5 1.2s1.8-.4 2.5-1.2"/>',handshake:'<path d="M3 12l4-3 3.5 2-1.5 2"/><path d="M21 12l-4-3-3.5 2 1.5 2"/><path d="M9 13l2.5 2.2a1.4 1.4 0 0 0 2-2l-3-2.7"/><path d="M15 13l-2.5 2.2"/>',"heart-chat":'<path d="M12 20s-7-4.4-9.3-8.8C1.3 8 3 5 6.2 5c2 0 3.4 1.2 4.3 2.4C11.4 6.2 12.8 5 14.8 5 18 5 19.7 8 17.3 11.2 15 15.6 12 20 12 20Z"/>',"thumbs-up":'<path d="M7 11v9H4v-9h3Z"/><path d="M7 11l3.5-6.5a1.6 1.6 0 0 1 3 1l-1 4.5H17a2 2 0 0 1 2 2.4l-1.3 6A2 2 0 0 1 15.7 20H10a3 3 0 0 1-3-3v-6Z"/>',wink:'<circle cx="12" cy="12" r="8.5"/><path d="M8.5 14c1 1.3 2.2 2 3.5 2s2.5-.7 3.5-2"/><path d="M7.5 10h3"/><circle cx="15" cy="10" r=".9" fill="currentColor" stroke="none"/>',headset:'<path d="M4 13a8 8 0 0 1 16 0"/><rect x="3" y="13" width="4" height="6" rx="1.5"/><rect x="17" y="13" width="4" height="6" rx="1.5"/><path d="M19 19v1a3 3 0 0 1-3 3h-3"/>',bell:'<path d="M6 17V11a6 6 0 0 1 12 0v6l1.5 2h-15L6 17Z"/><path d="M10 20.5a2 2 0 0 0 4 0"/>',megaphone:'<path d="M3 10v4h3l6 4V6L6 10H3Z"/><path d="M14 9a4 4 0 0 1 0 6"/><path d="M17 6.5a8 8 0 0 1 0 11"/>',broadcast:'<circle cx="12" cy="12" r="2"/><path d="M8.5 8.5a5 5 0 0 0 0 7M15.5 8.5a5 5 0 0 1 0 7"/><path d="M5.5 5.5a9.5 9.5 0 0 0 0 13M18.5 5.5a9.5 9.5 0 0 1 0 13"/>',"life-ring":'<circle cx="12" cy="12" r="8.5"/><circle cx="12" cy="12" r="3.5"/><path d="M6 6l3.5 3.5M18 6l-3.5 3.5M6 18l3.5-3.5M18 18l-3.5-3.5"/>',question:'<circle cx="12" cy="12" r="8.5"/><path d="M9.5 9.3a2.5 2.5 0 1 1 3.6 2.3c-.8.5-1.1.9-1.1 1.9"/><circle cx="12" cy="16.5" r=".9" fill="currentColor" stroke="none"/>',info:'<circle cx="12" cy="12" r="8.5"/><circle cx="12" cy="8" r=".9" fill="currentColor" stroke="none"/><path d="M12 11v6"/>',"phone-support":'<path d="M6.5 4.5h3L11 8l-2 1.5a11 11 0 0 0 5.5 5.5L16 13l3.5 1.5v3a2 2 0 0 1-2.2 2A15.5 15.5 0 0 1 4.5 6.7a2 2 0 0 1 2-2.2Z"/>',star:'<path d="M12 3.5l2.4 5.1 5.6.6-4.2 3.8 1.2 5.5L12 15.7l-5 2.8 1.2-5.5-4.2-3.8 5.6-.6L12 3.5Z"/>',"star-fill":'<path d="M12 3.5l2.4 5.1 5.6.6-4.2 3.8 1.2 5.5L12 15.7l-5 2.8 1.2-5.5-4.2-3.8 5.6-.6L12 3.5Z" fill="currentColor"/>',"check-circle":'<circle cx="12" cy="12" r="8.5"/><path d="M8.5 12.3 11 15l4.5-5.5"/>',target:'<circle cx="12" cy="12" r="8.5"/><circle cx="12" cy="12" r="5"/><circle cx="12" cy="12" r="1.4" fill="currentColor" stroke="none"/>',flame:'<path d="M12 3.5c1 2.5-.5 3.5-1.5 5C9 10 8 11.5 8 13.5A4 4 0 0 0 12 17.5a4 4 0 0 0 4-4c0-1.5-.7-2.3-1.3-3 .3 1.2-.2 2-1 2.3.3-2-1-2.7-1.7-4.3Z"/>',"shield-check":'<path d="M12 3.5 19 6.5V11c0 5-3 8.2-7 9.5-4-1.3-7-4.5-7-9.5V6.5L12 3.5Z"/><path d="M9 12l2 2 4-4.5"/>',crown:'<path d="M4 17l-1.5-8L7 12l5-6 5 6 4.5-3L20 17H4Z"/><path d="M4 19.5h16"/>',gift:'<rect x="4" y="9.5" width="16" height="10" rx="1"/><path d="M4 13h16"/><path d="M12 9.5v10"/><path d="M12 9.5c-1-2.5-2.8-4-4.3-4A2 2 0 0 0 6 7.5c0 1.3 1.2 2 2.5 2H12Z"/><path d="M12 9.5c1-2.5 2.8-4 4.3-4A2 2 0 0 1 18 7.5c0 1.3-1.2 2-2.5 2H12Z"/>'};function Ae(r){return`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">${r&&ut[r]||ut[nr]}</svg>`}var oe={SOFT:{waveform:"sine",gain:.12,tones:{CHAT_OPENED:[{freq:523,start:0,duration:.14}],BOT_REPLY:[{freq:659,start:0,duration:.16}],AGENT_MESSAGE:[{freq:494,start:0,duration:.14},{freq:587,start:.12,duration:.2}],RULE_TRIGGERED:[{freq:587,start:0,duration:.13}],COMMAND_EXECUTED:[{freq:440,start:0,duration:.18}]}},CLASSIC:{waveform:"sine",gain:.2,tones:{CHAT_OPENED:[{freq:660,start:0,duration:.09}],BOT_REPLY:[{freq:880,start:0,duration:.12}],AGENT_MESSAGE:[{freq:587,start:0,duration:.1},{freq:784,start:.1,duration:.14}],RULE_TRIGGERED:[{freq:740,start:0,duration:.08},{freq:740,start:.12,duration:.08}],COMMAND_EXECUTED:[{freq:784,start:0,duration:.1},{freq:660,start:.1,duration:.14}]}},BELL:{waveform:"triangle",gain:.15,tones:{CHAT_OPENED:[{freq:784,start:0,duration:.1},{freq:988,start:.05,duration:.12}],BOT_REPLY:[{freq:1046,start:0,duration:.18}],AGENT_MESSAGE:[{freq:659,start:0,duration:.12},{freq:784,start:.1,duration:.12},{freq:988,start:.2,duration:.22}],RULE_TRIGGERED:[{freq:1174,start:0,duration:.14}],COMMAND_EXECUTED:[{freq:880,start:0,duration:.1},{freq:1046,start:.1,duration:.16}]}}},sr={enabled:!0,soundStyle:"CLASSIC"},ae=class{constructor(){this.triggers={}}setTriggers(e){this.triggers=e}prime(){if(this.context){this.context.state==="suspended"&&this.context.resume();return}let e=window.AudioContext??window.webkitAudioContext;if(e)try{this.context=new e}catch{}}play(e){let t=this.context;if(!t)return;let n=this.triggers[e]??sr;if(!n.enabled)return;let{waveform:s,gain:i}=oe[n.soundStyle]??oe.CLASSIC,o=(oe[n.soundStyle]??oe.CLASSIC).tones[e],a=t.currentTime;for(let c of o){let f=t.createOscillator(),u=t.createGain();f.type=s,f.frequency.value=c.freq;let d=a+c.start,b=d+c.duration;u.gain.setValueAtTime(0,d),u.gain.linearRampToValueAtTime(i,d+.01),u.gain.linearRampToValueAtTime(0,b),f.connect(u),u.connect(t.destination),f.start(d),f.stop(b+.02)}}};var ft="chat:ready";var dt="chat:close",mt="chat:toggle",yt="chat:resize",gt="chat:send",_t="chat:bot-reply",bt="chat:connect-error",xt="chat:history",Et="chat:admin-message",Tt="chat:admin-typing",we="chat:agent-presence",At="chat:typing",wt="chat:upload-attachment",Ct="chat:attachment-uploaded",vt="chat:attachment-upload-error";var Ce="zabbu-chat-widget-launcher",ve="zabbu-chat-widget-panel",kt="zabbu-chat-widget-iframe",X="zabbu-chat-widget-teaser",Se="zabbu-chat-widget-badge",Rt="#2563eb";function ir(r,e){switch(r){case"NONE":return{launcher:"none",panel:"none",teaser:"none"};case"ELEVATED":return{launcher:"0 16px 40px -8px rgba(0, 0, 0, 0.45), 0 6px 16px rgba(0, 0, 0, 0.25)",panel:"0 30px 80px -16px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.3)",teaser:"0 20px 50px -12px rgba(0, 0, 0, 0.4), 0 8px 20px rgba(0, 0, 0, 0.2)"};case"BRAND_GLOW":{let t=ke(e,.5),n=ke(e,.3);return{launcher:`0 10px 26px -4px ${t}, 0 3px 10px ${n}`,panel:`0 26px 64px -12px ${t}, 0 10px 28px ${n}`,teaser:`0 18px 42px -8px ${t}, 0 6px 16px ${n}`}}case"SOFT":default:return{launcher:"0 4px 12px rgba(0, 0, 0, 0.2)",panel:"0 8px 30px rgba(0, 0, 0, 0.25)",teaser:"0 6px 20px rgba(0, 0, 0, 0.15)"}}}function ke(r,e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r);if(!t)return ke(Rt,e);let[n,s,i]=t.slice(1).map(o=>parseInt(o,16));return`rgba(${n}, ${s}, ${i}, ${e})`}function or(r,e,t){let n=r||Rt,s=ir(e,n),i=document.documentElement.style;i.setProperty("--zabbu-chat-primary",n),i.setProperty("--zabbu-chat-shadow-launcher",s.launcher),i.setProperty("--zabbu-chat-shadow-panel",s.panel),i.setProperty("--zabbu-chat-shadow-teaser",s.teaser),document.getElementById(X)?.classList.toggle("zabbu-chat-teaser-dark",t==="DARK")}async function ar(r,e){try{let t=await fetch(`${r}/public/sites/${e}`);if(!t.ok)return;let n=await t.json();or(n.primaryColor??null,n.shadowStyle??"SOFT",n.colorScheme??"LIGHT")}catch{}}function cr(){let r=document.currentScript;if(!r)throw new Error("zabbu-chat-widget: loader.js must run as a plain <script> tag");return r}function hr(r){let e=r.dataset.apiBase;return e?e.replace(/\/$/,""):"https://api-production-e565.up.railway.app"}function lr(r){return new URL(r.src).origin}function St(r){return`zabbu-chat-visitor:${r}`}function pr(){let r=document.createElement("style");r.textContent=`
|
|
2
2
|
#${Ce} {
|
|
3
3
|
position: fixed;
|
|
4
4
|
bottom: 20px;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zabbu/chat-widget",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Embeddable chat widget (loader.js + chat UI) for the chat portal backend (zabbu-chat-portal). Served standalone — see server.mjs and Dockerfile.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|