@botfabrik/engine-webclient 4.116.4-alpha.0 → 4.116.4
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.
|
@@ -72,4 +72,4 @@ ${w.current.stack}
|
|
|
72
72
|
|
|
73
73
|
- La cronologia delle chat è memorizzata nell'area UE e può essere visualizzata solo da persone autorizzate.
|
|
74
74
|
- Non inserire dati personali nella finestra di chat (password, data di nascita, ecc.).`,"general-conditions.accept-conditions-note":`Utilizzando la chat si accettano le condizioni d'uso.`,"block-user-input.title":`Attendere la risposta del chatbot.`,"conversation-rating.call-to-action.title":`Valuta questa chat`,"conversation-rating.overlay.title":`Quanto sei soddisfatto di questa chat?`,"conversation-rating.overlay.guest-feedback.input-placeholder":`Inserisci qui il tuo feedback (opzionale)`,"conversation-rating.overlay.star.very-bad":`Molto male`,"conversation-rating.overlay.star.very-good":`Molto buono`,"conversation-rating.overlay.bot-message.rate-feedback.value-1":`Oh, non suona bene. Vi prego di darmi un feedback in modo che possa imparare di più.`,"conversation-rating.overlay.bot-message.rate-feedback.value-2":`Oh, non suona bene. Vi prego di darmi un feedback in modo che possa imparare di più.`,"conversation-rating.overlay.bot-message.rate-feedback.value-3":`La media non è il mio obiettivo, cosa posso ancora migliorare?`,"conversation-rating.overlay.bot-message.rate-feedback.value-4":`Anche l'assenza è finita. Cosa posso migliorare per ottenere tutte le stelle la prossima volta?`,"conversation-rating.overlay.bot-message.rate-feedback.value-5":`Perfetto! Allora spero di potervi consigliare ancora una volta bene.`,"conversation-rating.overlay.bot-message.submit-feedback":`Grazie mille per il feedback. Mi impegno costantemente per migliorare.`,"conversation-rating.overlay.action.submit":`Invia`,"conversation-rating.overlay.action.back-to-chat":`Chiudere`,"conversation-rating.overlay.action.close-chat":`Minimizzare la chat`,"conversation-rating.overlay.action.restart-chat":`Riavviare la chat`,"conversation-rating.overlay.action.cancel":`Annulla`,"start-screen.intro":``,"start-screen.start-chat":`Avviare la chat`,"start-screen.waiting-for-login":`In attesa di login ...`,"header.close-chat":`Minimizzare la chat`,"header.menu.title":`Menu`,"header.menu.restart-chat":`Riavviare la chat`,"header.menu.expand-chat-window":`Espandere la finestra`,"header.menu.download-transcript":`Scaricare la trascrizione`,"header.menu.send-transcript":`Inviare la trascrizione`,"header.menu.export-transcript":`Esportare la trascrizione`,"header.menu.rate-conversation":`Valutare la conversazione`,"source-infos.close":`Chiudere`,"source-infos.open-source":`Fonte aperta`,"source-infos.error.title":`Errore`,"source-infos.error.info":`Ops! Qualcosa è andato storto. Riprovare o contattare l'assistenza se il problema persiste.`,"source-infos.highlight-loading.title":`Il contenuto rilevante è evidenziato...`,"source-infos.highlight-loading.description":`Un momento - la fonte è in fase di analisi`,"commands.show-more.action":`Di più`,"commands.show-more.tooltip":`Mostra più comandi`,"commands.show-less.action":`Meno`,"commands.show-less.tooltip":`Mostra meno comandi`},xf=[`de`,`en`,`fr`,`it`],Sf={locale:`de`,messages:gf},Cf=(e,t)=>{if(xf.includes(e)){let n=wf(e),r=vf(t);return{...n,...r}}return t},wf=e=>{switch(e.toString()){case`en`:return _f;case`fr`:return yf;case`it`:return bf;default:return gf}},Tf=(e=Ef,t)=>{switch(t.type){case Ii:return Object.assign({},e,{connectionState:ta.CONNECTING});case Li:return Object.assign({},e,{connectionState:ta.CONNECTED});case Ri:return Object.assign({},e,{connectionState:ta.DISCONNECTED});case zi:return Object.assign({},e,{connectionState:ta.RECONNECTED});case Bi:return Object.assign({},e,{sessionId:t.sessionId});case Vi:return Object.assign({},e,{sessionId:t.payload.sessionId,userId:t.payload.userId});case Hi:return Object.assign({},e,{sessionId:void 0});default:return e}},Ef={connectionState:ta.DISCONNECTED,sessionId:void 0,userId:void 0,queryString:window.location.search},Df=(e=Mf,t)=>{switch(t.type){case Ci:return Mf;case Vi:return kf({type:`webclient.chat.started`}),e;case Hi:return kf({type:`webclient.chat.ended`}),e;case at.TYPING_ON:return Object.assign({},e,{isBotTyping:!0});case at.TYPING_OFF:return Object.assign({},e,{isBotTyping:!1});case at.MESSAGE_FROM_GUEST:case at.MESSAGE_WITHOUT_ANALYSIS_FROM_GUEST:return Of(e,t.message,t.meta);case at.MESSAGE_TO_GUEST:{kf(t);let n=Object.assign({},t.message,{_id:t.meta.actionId}),r=e.messages.filter(e=>e._id===t.meta.actionId).length>0;return Object.assign({},e,{isBotTyping:!1,messages:r?e.messages:e.messages.concat([n]),quickReplies:n.quickReplies?n.quickReplies:[]})}case _t:{let n=t.messages,r=n.length?n[n.length-1]:void 0;return Object.assign({},e,{isBotTyping:!1,messages:n,quickReplies:r?.quickReplies||[]})}case gt:return kf(t.message),e;case at.EVENT_TO_GUEST:return kf(t.event),e;case at.DRAWER_OPEN:return Object.assign({},e,{drawerContentUrl:t.payload.parameters.contentUrl});case at.DRAWER_CLOSE:return Object.assign({},e,{drawerContentUrl:void 0});case at.GUEST_LOCALE_CHANGED:return Object.assign({},e,{locale:t.payload.locale});case Tt:return kf(t),e;case Et:return kf(t),{...e,conversationRating:{...e.conversationRating,opener:void 0}};case yt:{let n=new ft(t.transcription,new ut);return Of(e,Object.assign({},n,{_id:Zt()}))}case at.TRANSCRIPT_ITEM_GUEST_REACTION:{let n=e.messages.map(e=>e._id===t.payload.actionId?Object.assign({},e,t.payload.reaction?{reaction:{type:t.payload.reaction,category:t.payload.category,comment:t.payload.comment}}:{reaction:void 0}):e);return Object.assign({},e,{messages:n})}case bt:{let n={enabled:!0,rating:t.payload.rating};return Object.assign({},e,{conversationRating:n})}case at.CONVERSATION_RATING_FROM_GUEST:{let n={...e.conversationRating,rating:t.payload};return Object.assign({},e,{conversationRating:n})}case Ti:{let n={...e.conversationRating,opener:t.payload.opener,...t.payload.defaultRating?{rating:{value:t.payload.defaultRating,feedback:e.conversationRating.rating?.feedback||``}}:{}};return Object.assign({},e,{conversationRating:n})}case Ei:{let t={...e.conversationRating,opener:void 0};return Object.assign({},e,{conversationRating:t})}case Ct:return{...e,sourceInfos:{type:`loading`,chunkId:t.payload.chunkId}};case St:{let{highlighted:n}=t.payload;return e.sourceInfos?.type===`loaded`&&n?{...e,sourceInfos:{...e.sourceInfos,highlighted:!0}}:{...e,sourceInfos:{type:`loading-error`}}}case xt:{let n=e.sourceInfos?.type,{chunkId:r,knowledgeBaseType:i,title:a,content:o,highlighted:s,url:c}=t.payload,l=e.sourceInfos?.type===`loading`||e.sourceInfos?.type===`loaded`?e.sourceInfos?.chunkId:void 0;return l&&l!==r?e:n===`loading`||n===`loaded`&&s?{...e,sourceInfos:{type:`loaded`,chunkId:r,knowledgeBaseType:i,title:a,content:o,highlighted:s,url:c}}:e}case wt:return{...e,sourceInfos:void 0};case wi:return{...e,showTranscriptMailOverlay:!e.showTranscriptMailOverlay,conversationRating:{...e.conversationRating,opener:void 0}};default:return e}},Of=(e,t,n)=>{let r=e.messages[e.messages.length-1],i=r?.text===t.text,a=!!n?.actionId,o=r&&!r._id&&r.sender.type===t.sender.type;if(a&&o){let r=Object.assign({},t,{_id:n.actionId}),i=[...e.messages];return i[i.length-1]=r,Object.assign({},e,{messages:i,quickReplies:[]})}return r&&r.sender.type===t.sender.type&&i?e:Object.assign({},e,{messages:e.messages.concat([t]),quickReplies:[]})},kf=e=>{if(jf()){let t=Af();window.top?.postMessage(e,t)}else e.type===`webclient.change.url`&&window.open(e.url)},Af=()=>{try{return document.referrer?new URL(document.referrer).origin:`*`}catch{return`*`}},jf=()=>typeof window<`u`&&window.self!==window.top,Mf={messages:[],quickReplies:[],isBotTyping:!1,showTranscriptMailOverlay:!1,conversationRating:{enabled:!1}},Nf=ti({name:`intl`,initialState:Sf,reducers:{updateIntl:(e,t)=>{e.locale=t.payload.language,e.messages=t.payload.messages}}}),{updateIntl:Pf}=Nf.actions,Ff=Nf.reducer,If=ti({name:`settings`,initialState:{version:void 0,requiresUserAuthentication:!1,enableStartScreen:void 0,enableStandaloneView:!1,enableTranscriptExportEmail:!1,enableTranscriptExportPdf:!1,enableGeneralConditions:!1,enableSpeechSupport:!1,commands:[],menuItems:[],allowedEmbedOrigins:void 0},reducers:{setSettings(e,t){e.version&&e.version!==t.payload.version?(console.log(`version changed, reloading chat window`),window.location.reload()):(e.version=t.payload.version,e.requiresUserAuthentication=t.payload.requiresUserAuthentication,e.enableStartScreen=t.payload.enableStartScreen,e.enableStandaloneView=t.payload.enableStandaloneView,e.enableTranscriptExportEmail=t.payload.enableTranscriptExportEmail,e.enableTranscriptExportPdf=t.payload.enableTranscriptExportPdf,e.enableGeneralConditions=t.payload.enableGeneralConditions,e.enableSpeechSupport=t.payload.enableSpeechSupport,e.commands=t.payload.commands,e.menuItems=t.payload.menuItems||[],e.allowedEmbedOrigins=t.payload.allowedEmbedOrigins)}}}),{setSettings:Lf}=If.actions,Rf=If.reducer,zf=cn({settings:Rf,chat:Df,startScreen:Si,connection:Tf,intl:Ff}),Bf=`bubble-chat`,Vf=`state-last-saved-at`,Hf=`state`,Uf=e=>{try{if(!Kf()||Gf(qf(e,Vf)))return;{let t=qf(e,Hf);if(t===null)return;let n=JSON.parse(t),r=n.connection?.queryString;if(r!==void 0&&!Xf(r,window.location.search)){console.log(`Ignoring persisted state due to different query string`);return}else return n}}catch(e){console.error(e);return}},Wf=(e,t)=>{try{Jf(e,Hf,JSON.stringify(t)),Jf(e,Vf,new Date().toISOString())}catch(e){console.error(e)}},Gf=e=>{if(e===null)return!1;let t=new Date(e);return t.setHours(t.getHours()+12),new Date>t},Kf=()=>typeof localStorage<`u`,qf=(e,t)=>{let n=Yf(e,t);return localStorage.getItem(n)},Jf=(e,t,n)=>{let r=Yf(e,t);return localStorage.setItem(r,n)},Yf=(e,t)=>`${Bf}-${e}-${t}`,Xf=(e,t)=>{let n=new URLSearchParams(e),r=new URLSearchParams(t);n.delete(`referrer`),r.delete(`referrer`);let i=Array.from(n.entries()).sort(),a=Array.from(r.entries()).sort();return i.length===a.length?i.every(([e,t],n)=>{let[r,i]=a[n];return e===r&&t===i}):!1},Zf=Object.create(null);Zf.open=`0`,Zf.close=`1`,Zf.ping=`2`,Zf.pong=`3`,Zf.message=`4`,Zf.upgrade=`5`,Zf.noop=`6`;var Qf=Object.create(null);Object.keys(Zf).forEach(e=>{Qf[Zf[e]]=e});var $f={type:`error`,data:`parser error`},ep=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,tp=typeof ArrayBuffer==`function`,np=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,rp=({type:e,data:t},n,r)=>ep&&t instanceof Blob?n?r(t):ip(t,r):tp&&(t instanceof ArrayBuffer||np(t))?n?r(t):ip(new Blob([t]),r):r(Zf[e]+(t||``)),ip=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function ap(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var op;function sp(e,t){if(ep&&e.data instanceof Blob)return e.data.arrayBuffer().then(ap).then(t);if(tp&&(e.data instanceof ArrayBuffer||np(e.data)))return t(ap(e.data));rp(e,!1,e=>{op||=new TextEncoder,t(op.encode(e))})}var cp=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,lp=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)lp[cp.charCodeAt(e)]=e;var up=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=lp[e.charCodeAt(r)],o=lp[e.charCodeAt(r+1)],s=lp[e.charCodeAt(r+2)],c=lp[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},dp=typeof ArrayBuffer==`function`,fp=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:mp(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:pp(e.substring(1),t)}:Qf[n]?e.length>1?{type:Qf[n],data:e.substring(1)}:{type:Qf[n]}:$f},pp=(e,t)=>dp?mp(up(e),t):{base64:!0,data:e},mp=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},hp=``,gp=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{rp(e,!1,e=>{r[a]=e,++i===n&&t(r.join(hp))})})},_p=(e,t)=>{let n=e.split(hp),r=[];for(let e=0;e<n.length;e++){let i=fp(n[e],t);if(r.push(i),i.type===`error`)break}return r};function vp(){return new TransformStream({transform(e,t){sp(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var yp;function bp(e){return e.reduce((e,t)=>e+t.length,0)}function xp(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function Sp(e,t){yp||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(bp(n)<1)break;let e=xp(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(bp(n)<2)break;let e=xp(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(bp(n)<8)break;let e=xp(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue($f);break}i=a*2**32+t.getUint32(4),r=3}else{if(bp(n)<i)break;let e=xp(n,i);s.enqueue(fp(a?e:yp.decode(e),t)),r=0}if(i===0||i>e){s.enqueue($f);break}}}})}function Cp(e){if(e)return wp(e)}function wp(e){for(var t in Cp.prototype)e[t]=Cp.prototype[t];return e}Cp.prototype.on=Cp.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},Cp.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},Cp.prototype.off=Cp.prototype.removeListener=Cp.prototype.removeAllListeners=Cp.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},Cp.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},Cp.prototype.emitReserved=Cp.prototype.emit,Cp.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},Cp.prototype.hasListeners=function(e){return!!this.listeners(e).length};var Tp=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),Ep=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),Dp=`arraybuffer`;function Op(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var kp=Ep.setTimeout,Ap=Ep.clearTimeout;function jp(e,t){t.useNativeTimers?(e.setTimeoutFn=kp.bind(Ep),e.clearTimeoutFn=Ap.bind(Ep)):(e.setTimeoutFn=Ep.setTimeout.bind(Ep),e.clearTimeoutFn=Ep.clearTimeout.bind(Ep))}var Mp=1.33;function Np(e){return typeof e==`string`?Pp(e):Math.ceil((e.byteLength||e.size)*Mp)}function Pp(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function Fp(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Ip(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function Lp(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var Rp=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},zp=class extends Cp{constructor(e){super(),this.writable=!1,jp(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 Rp(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=fp(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=Ip(e);return t.length?`?`+t:``}},Bp=class extends zp{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 e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){_p(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),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,gp(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=Fp()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},Vp=!1;try{Vp=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var Hp=Vp;function Up(){}var Wp=class extends Bp{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;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`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},Gp=class e extends Cp{constructor(e,t,n){super(),this.createRequest=e,jp(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=Op(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(this._xhr===void 0||this._xhr===null)){if(this._xhr.onreadystatechange=Up,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.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()}};if(Gp.requestsCount=0,Gp.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,Kp);else if(typeof addEventListener==`function`){let e=`onpagehide`in Ep?`pagehide`:`unload`;addEventListener(e,Kp,!1)}}function Kp(){for(let e in Gp.requests)Gp.requests.hasOwnProperty(e)&&Gp.requests[e].abort()}var qp=(function(){let e=Yp({xdomain:!1});return e&&e.responseType!==null})(),Jp=class extends Wp{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=qp&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Gp(Yp,this.uri(),e)}};function Yp(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||Hp))return new XMLHttpRequest}catch{}if(!t)try{return new Ep[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var Xp=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,Zp=class extends zp{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=Xp?{}:Op(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(e){return this.emitReserved(`error`,e)}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],r=t===e.length-1;rp(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&Tp(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(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]=Fp()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},Qp=Ep.WebSocket||Ep.MozWebSocket,$p={websocket:class extends Zp{createSocket(e,t,n){return Xp?new Qp(e,t,n):t?new Qp(e,t):new Qp(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends zp{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=Sp(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=vp();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&Tp(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:Jp},em=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,tm=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function nm(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=em.exec(e||``),a={},o=14;for(;o--;)a[tm[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=rm(a,a.path),a.queryKey=im(a,a.query),a}function rm(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function im(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var am=typeof addEventListener==`function`&&typeof removeEventListener==`function`,om=[];am&&addEventListener(`offline`,()=>{om.forEach(e=>e())},!1);var sm=class e extends Cp{constructor(e,t){if(super(),this.binaryType=Dp,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=nm(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=nm(t.host).host);jp(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,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(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),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=Lp(this.opts.query)),am&&(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`})},om.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,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 t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}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`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.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=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 e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=Np(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,Tp(()=>{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,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),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(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(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(),am&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=om.indexOf(this._offlineEventListener);e!==-1&&om.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};sm.protocol=4;var cm=class extends sm{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;sm.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n)if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;sm.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),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}},lm=class extends cm{constructor(e,t={}){let n=typeof e==`object`?e:t;(!n.transports||n.transports&&typeof n.transports[0]==`string`)&&(n.transports=(n.transports||[`polling`,`websocket`,`webtransport`]).map(e=>$p[e]).filter(e=>!!e)),super(e,n)}};lm.protocol;function um(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=nm(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var dm=typeof ArrayBuffer==`function`,fm=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,pm=Object.prototype.toString,mm=typeof Blob==`function`||typeof Blob<`u`&&pm.call(Blob)===`[object BlobConstructor]`,hm=typeof File==`function`||typeof File<`u`&&pm.call(File)===`[object FileConstructor]`;function gm(e){return dm&&(e instanceof ArrayBuffer||fm(e))||mm&&e instanceof Blob||hm&&e instanceof File}function _m(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(_m(e[t]))return!0;return!1}if(gm(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return _m(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&_m(e[t]))return!0;return!1}function vm(e){let t=[],n=e.data,r=e;return r.data=ym(n,t),r.attachments=t.length,{packet:r,buffers:t}}function ym(e,t){if(!e)return e;if(gm(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=ym(e[r],t);return n}else if(typeof e==`object`&&!(e instanceof Date)){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=ym(e[r],t));return n}return e}function bm(e,t){return e.data=xm(e.data,t),delete e.attachments,e}function xm(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=xm(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=xm(e[n],t));return e}var Sm=s({Decoder:()=>Em,Encoder:()=>Tm,PacketType:()=>wm,isPacketValid:()=>Nm,protocol:()=>5}),Cm=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],wm;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(wm||={});var Tm=class{constructor(e){this.replacer=e}encode(e){return(e.type===wm.EVENT||e.type===wm.ACK)&&_m(e)?this.encodeAsBinary({type:e.type===wm.EVENT?wm.BINARY_EVENT:wm.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===wm.BINARY_EVENT||e.type===wm.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=vm(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},Em=class e extends Cp{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 Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===wm.BINARY_EVENT;n||t.type===wm.BINARY_ACK?(t.type=n?wm.EVENT:wm.ACK,this.reconstructor=new Dm(t),t.attachments===0&&super.emitReserved(`decoded`,t)):super.emitReserved(`decoded`,t)}else if(gm(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`);else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(wm[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===wm.BINARY_EVENT||r.type===wm.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!km(a)||a<0)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&!(t.charAt(n)===`,`||n===t.length););r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case wm.CONNECT:return jm(t);case wm.DISCONNECT:return t===void 0;case wm.CONNECT_ERROR:return typeof t==`string`||jm(t);case wm.EVENT:case wm.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&Cm.indexOf(t[0])===-1);case wm.ACK:case wm.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},Dm=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 e=bm(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function Om(e){return typeof e==`string`}var km=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function Am(e){return e===void 0||km(e)}function jm(e){return Object.prototype.toString.call(e)===`[object Object]`}function Mm(e,t){switch(e){case wm.CONNECT:return t===void 0||jm(t);case wm.DISCONNECT:return t===void 0;case wm.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&Cm.indexOf(t[0])===-1);case wm.ACK:return Array.isArray(t);case wm.CONNECT_ERROR:return typeof t==`string`||jm(t);default:return!1}}function Nm(e){return Om(e.nsp)&&Am(e.id)&&Mm(e.type,e.data)}function Pm(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var Fm=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Im=class extends Cp{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=[Pm(e,`open`,this.onopen.bind(this)),Pm(e,`packet`,this.onpacket.bind(this)),Pm(e,`error`,this.onerror.bind(this)),Pm(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(Fm.hasOwnProperty(e))throw 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 n={type:wm.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);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((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),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:wm.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(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case wm.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,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 wm.EVENT:case wm.BINARY_EVENT:this.onevent(e);break;case wm.ACK:case wm.BINARY_ACK:this.onack(e);break;case wm.DISCONNECT:this.ondisconnect();break;case wm.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t);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(...r){n||(n=!0,t.packet({type:wm.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:wm.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 Lm(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Lm.prototype.duration=function(){var e=this.ms*this.factor**+ this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},Lm.prototype.reset=function(){this.attempts=0},Lm.prototype.setMin=function(e){this.ms=e},Lm.prototype.setMax=function(e){this.max=e},Lm.prototype.setJitter=function(e){this.jitter=e};var Rm=class extends Cp{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,jp(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(t.randomizationFactor??.5),this.backoff=new Lm({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||Sm;this.encoder=new n.Encoder,this.decoder=new n.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.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||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 lm(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=Pm(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=Pm(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(Pm(e,`ping`,this.onping.bind(this)),Pm(e,`data`,this.ondata.bind(this)),Pm(e,`error`,this.onerror.bind(this)),Pm(e,`close`,this.onclose.bind(this)),Pm(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){Tp(()=>{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 Im(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].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.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(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):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)}},zm={};function Bm(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=um(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=zm[i]&&a in zm[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new Rm(r,t):(zm[i]||(zm[i]=new Rm(r,t)),c=zm[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(Bm,{Manager:Rm,Socket:Im,io:Bm,connect:Bm});var Vm=[at.MESSAGE_TO_GUEST,at.EVENT_TO_GUEST,at.TYPING_ON,at.TYPING_OFF,at.RESTART_CHAT_REQUEST,...Ui,...Ot,`@@localize/SET_ACTIVE_LANGUAGE`,`@@localize/ADD_TRANSLATION_FOR_LANGUAGE`],Hm=({dispatch:e,getState:t})=>n=>{let r=null;return i=>{let a=n(i);if(i.type===`CONNECT`)r?.disconnect(),e(Ki()),r=Bm({path:`/website-messenger/${i.clientName}/socket.io`,query:i.querystrings}),r.on(`action`,e),r.on(`connect`,()=>e(qi())),r.on(`disconnect`,()=>e(Ji())),r.on(`reconnect`,()=>e(Yi())),r.on(`set-translations`,(t,n)=>{e(Pf({language:t,messages:Cf(t,n)}))}),r.on(`set-settings`,t=>{e(Lf(t))}),r.on(`enable-conversation-rating`,t=>e(Nt(t))),r.on(`speech-transcription`,t=>e(At(t))),r.on(`restore-client-state`,t=>{e(Gi(t.sessionId)),e(It(t.messages))}),r.on(`expand-window`,({devices:t,initial:n=!1})=>{e({type:Tt,devices:t,initial:n})}),r.on(`restart-chat`,()=>{e(Zi())}),r.on(`login-success`,t=>{e(vi({loginToken:t.loginToken}))});else if(i.type===`start-screen/requestLogin`)r?.emit(`login-requested`,i.payload);else if(i.type===`START`)r?.emit(`start-chat`,i.payload);else if(i.type===`CLEAR_SESSION_ID`)r?.emit(`terminate-session`,i.payload);else if(i.type===`webclient.get.started`)r?.emit(`get-started`,JSON.stringify(i));else if(i.type===`AUDIO_MESSAGE_FROM_USER`)r?.emit(`audio-message`,i.buffer);else if(i.type===at.CONVERSATION_RATING_FROM_GUEST)r?.emit(`conversation-rating`,i.payload);else if(i.type===`webclient.transcript.pdf.download`){let{connection:{sessionId:e}}=t();if(e){let t=Qt(),n=new URL(`/${encodeURIComponent(t)}/transcript-pdf/${encodeURIComponent(e)}`,window.location.origin);window.location.href=n.toString()}}else Vm.indexOf(i.type)===-1&&i.meta===void 0&&r&&r.emit(`action`,JSON.stringify(i));return a}},Um=Qt(),Wm=qr({middleware:e=>e().concat(Hm),reducer:zf,preloadedState:{...Uf(Um),intl:Sf}});Wm.subscribe(Ic(()=>{let e=Wm.getState();Wf(Um,{connection:e.connection,startScreen:e.startScreen})},1e3)),(0,b.createRoot)(document.getElementById(`root`)).render((0,X.jsx)(qe,{store:Wm,children:(0,X.jsx)(hf,{})}));
|
|
75
|
-
//# sourceMappingURL=index-
|
|
75
|
+
//# sourceMappingURL=index-Dgye-P8u.js.map
|