@botfabrik/engine-webclient 4.110.1 → 4.110.2

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,5 +72,5 @@ ${ue.current.stack}
72
72
  - Ne saisissez aucune information personnelle dans la fenêtre de chat (mots de passe, date de naissance, etc.).`,"general-conditions.accept-conditions-note":"En utilisant le chat, vous acceptez les conditions d'utilisation.","block-user-input.title":"Veuillez attendre la réponse du chatbot.","conversation-rating.call-to-action.title":"Notez ce chat","conversation-rating.overlay.title":"Dans quelle mesure êtes-vous satisfait de ce chat ?","conversation-rating.overlay.guest-feedback.input-placeholder":"Veuillez saisir vos commentaires ici (facultatif)","conversation-rating.overlay.star.very-bad":"Très mauvais","conversation-rating.overlay.star.very-good":"Très bien","conversation-rating.overlay.bot-message.rate-feedback.value-1":"Oh, ça ne sonne pas bien. Merci de me donner un feedback pour que je puisse en apprendre davantage.","conversation-rating.overlay.bot-message.rate-feedback.value-2":"Oh, ça ne sonne pas bien. Merci de me donner un feedback pour que je puisse en apprendre davantage.","conversation-rating.overlay.bot-message.rate-feedback.value-3":"La moyenne n'est pas mon objectif, que puis-je encore améliorer ?","conversation-rating.overlay.bot-message.rate-feedback.value-4":"Le rater de peu, c'est le rater aussi. Que puis-je encore améliorer pour obtenir toutes les étoiles la prochaine fois ?","conversation-rating.overlay.bot-message.rate-feedback.value-5":"Parfait ! Alors j'espère pouvoir vous conseiller aussi bien une fois de plus.","conversation-rating.overlay.bot-message.submit-feedback":"Merci beaucoup pour votre feed-back. Je m'efforce de m'améliorer en permanence.","conversation-rating.overlay.action.submit":"Envoyer","conversation-rating.overlay.action.back-to-chat":"Fermer","conversation-rating.overlay.action.close-chat":"Minimiser le chat","conversation-rating.overlay.action.restart-chat":"Redémarrer le chat","conversation-rating.overlay.action.cancel":"Annuler","start-screen.intro":"","start-screen.start-chat":"Démarrer le chat","start-screen.waiting-for-login":"En attente de connexion ...","header.close-chat":"Minimiser le chat","header.menu.title":"Menu","header.menu.restart-chat":"Redémarrer le chat","header.menu.expand-chat-window":"Agrandir la fenêtre","header.menu.download-transcript":"Télécharger l'historique du chat","header.menu.send-transcript":"Envoyer l'historique du chat","header.menu.export-transcript":"Exporter l'historique du chat","header.menu.rate-conversation":"Évaluer le chat","source-infos.close":"Fermer","source-infos.open-source":"Ouvrir source","source-infos.error.title":"Erreur","source-infos.error.info":"Oups ! Quelque chose s'est mal passé. Merci de réessayer ou de contacter le support si le problème persiste.","source-infos.highlight-loading.title":"Contenus pertinents en surbrillance...","source-infos.highlight-loading.description":"Un instant - la source est analysée","commands.show-more.action":"Plus","commands.show-more.tooltip":"Afficher plus de commandes","commands.show-less.action":"Moins","commands.show-less.tooltip":"Afficher moins de commandes"},Bx={"page.title":"Bubble Chat Chatbot","message-input-label":"Input dell'utente","message-input-placeholder":"Inserire un messaggio","message-input.actions.submit.label":"Invia messaggio","message-input.actions.start-audio-recording.label":"Avviare l'input vocale","message-input.actions.stop-audio-recording.label":"Interrompere l'input vocale","message-input.actions.submit-audio-recording.label":"Trasmettere l'input vocale","message-input.actions.command.label":"Esegui azione","guest-bubble.label":"Il tuo messaggio","bot-bubble.label":"Messaggio del chatbot","bot-bubble.actions.label":"Azioni del messaggio","bot-bubble.reaction.good":"Mi piace","bot-bubble.reaction.bad":"Non mi piace","bot-bubble.reaction.remove":"Rimuovere il marcatore","bot-bubble.reaction.say-more":"Disci più, per favore","bot-bubble.reaction.category.WRONG_INFORMATION":"Errate","bot-bubble.reaction.category.MISSING_INFORMATION":"Incompleto","bot-bubble.reaction.category.OLD_INFORMATION":"Obsoleta","bot-bubble.reaction.category.UNCLEAR":"Poco chiaro","bot-bubble.reaction.category.OFF_TOPIC":"Non pertinente alla domanda","bot-bubble.reaction.comment":"Condividete con noi i vostri pensieri...","bot-bubble.reaction.close":"Chiudere","bot-bubble.copy":"Copia","bot-bubble.sources":"Elenco delle fonti","bot-bubble.source.open":"Fonte aperta","bot-bubble.footnote":"Nota a piè di pagina","agent-bubble.label":"Messaggio dell'agente dal vivo","conversation.label":"Cronologia chat","chatbot.typing":"Il chatbot sta scrivendo","export-transcript.email.title":"Ricevere la cronologia della chat","export-transcript.email.description":"Inserire l'indirizzo e-mail a cui inviare la cronologia della chat.","export-transcript.email.cancel":"Annulla","export-transcript.email.send":"Invia","export-transcript.email.placeholder":"E-mail","export-transcript.email.invalid":"Inserire un indirizzo e-mail valido.","export-transcript.email.success":"La cronologia della chat è stata inviata all'indirizzo e-mail fornito.","general-conditions.header":"**Condizioni di utilizzo**","general-conditions.body":`Si prega di considerare i seguenti punti:
73
73
 
74
74
  - La cronologia delle chat è memorizzata nell'area UE e può essere visualizzata solo da persone autorizzate.
75
- - 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"},jx=["de","en","fr","it"],eb={locale:"de",messages:Py},Ux=(n,l)=>{if(jx.includes(n)){const r=Hx(n),s=$y(l);return{...r,...s}}return l},Hx=n=>{switch(n.toString()){case"en":return zx;case"fr":return kx;case"it":return Bx;default:return Py}},qx=(n=Ix,l)=>{switch(l.type){case Wh:return Object.assign({},n,{connectionState:Kr.CONNECTING});case Qh:return Object.assign({},n,{connectionState:Kr.CONNECTED});case Ph:return Object.assign({},n,{connectionState:Kr.DISCONNECTED});case $h:return Object.assign({},n,{connectionState:Kr.RECONNECTED});case em:return Object.assign({},n,{sessionId:l.sessionId});case fu:return Object.assign({},n,{sessionId:l.payload.sessionId,userId:l.payload.userId});case du:return Object.assign({},n,{sessionId:void 0});default:return n}},Ix={connectionState:Kr.DISCONNECTED,sessionId:void 0,userId:void 0,queryString:window.location.search},Gx=(n=Cv,l)=>{switch(l.type){case gy:return Cv;case fu:return Yr({type:"webclient.chat.started"}),n;case du:return Yr({type:"webclient.chat.ended"}),n;case Uv:return Object.assign({},n,{isBotTyping:!0});case Hv:return Object.assign({},n,{isBotTyping:!1});case Lh:case qv:return Av(n,l.message);case Iv:{Yr(l);const r=Object.assign({},l.message,{_id:l.meta.actionId}),s=n.messages.filter(c=>c._id===l.meta.actionId).length>0;return Object.assign({},n,{isBotTyping:!1,messages:s?n.messages:n.messages.concat([r]),quickReplies:r.quickReplies?r.quickReplies:[]})}case jh:{const r=l.messages,s=r.length?r[r.length-1]:void 0;return Object.assign({},n,{isBotTyping:!1,messages:r,quickReplies:s?.quickReplies||[]})}case Bh:return Yr(l.message),n;case Gv:return Yr(l.event),n;case KA:return Object.assign({},n,{drawerContentUrl:l.payload.parameters.contentUrl});case FA:return Object.assign({},n,{drawerContentUrl:void 0});case JA:return Object.assign({},n,{locale:l.payload.locale});case Jv:return Yr(l),n;case Zv:return Yr(l),{...n,conversationRating:{...n.conversationRating,opener:void 0}};case Hh:{const r=new nu(l.transcription,new kh),s=Object.assign({},r,{_id:jc()});return Av(n,s)}case Vv:{const r=n.messages.map(s=>s._id===l.payload.actionId?Object.assign({},s,l.payload.reaction?{reaction:{type:l.payload.reaction,category:l.payload.category,comment:l.payload.comment}}:{reaction:void 0}):s);return Object.assign({},n,{messages:r})}case qh:{const r={enabled:!0,rating:l.payload.rating};return Object.assign({},n,{conversationRating:r})}case zh:{const r={...n.conversationRating,rating:l.payload};return Object.assign({},n,{conversationRating:r})}case yy:{const r={...n.conversationRating,opener:l.payload.opener,...l.payload.defaultRating?{rating:{value:l.payload.defaultRating,feedback:n.conversationRating.rating?.feedback||""}}:{}};return Object.assign({},n,{conversationRating:r})}case by:{const r={...n.conversationRating,opener:void 0};return Object.assign({},n,{conversationRating:r})}case Gh:return{...n,sourceInfos:{type:"loading",chunkId:l.payload.chunkId}};case Ih:{const{highlighted:r}=l.payload;return n.sourceInfos?.type==="loaded"&&r?{...n,sourceInfos:{...n.sourceInfos,highlighted:!0}}:{...n,sourceInfos:{type:"loading-error"}}}case Fv:{const r=n.sourceInfos?.type,{chunkId:s,knowledgeBaseType:c,title:f,content:d,highlighted:m,url:h}=l.payload,p=n.sourceInfos?.type==="loading"||n.sourceInfos?.type==="loaded"?n.sourceInfos?.chunkId:void 0;return p&&p!==s?n:r==="loading"||r==="loaded"&&m?{...n,sourceInfos:{type:"loaded",chunkId:s,knowledgeBaseType:c,title:f,content:d,highlighted:m,url:h}}:n}case Vh:return{...n,sourceInfos:void 0};case vy:return{...n,showTranscriptMailOverlay:!n.showTranscriptMailOverlay,conversationRating:{...n.conversationRating,opener:void 0}};default:return n}},Av=(n,l)=>{const r=n.messages[n.messages.length-1],s=r?.text===l.text;return r&&r.sender.type===l.sender.type&&s?n:Object.assign({},n,{messages:n.messages.concat([l]),quickReplies:[]})},Yr=n=>{if(Xx()){const l=Vx();window.top?.postMessage(n,l)}else n.type==="webclient.change.url"&&window.open(n.url)},Vx=()=>{try{return document.referrer?new URL(document.referrer).origin:"*"}catch{return"*"}},Xx=()=>typeof window<"u"&&window.self!==window.top,Cv={messages:[],quickReplies:[],isBotTyping:!1,showTranscriptMailOverlay:!1,conversationRating:{enabled:!1}},tb=Jh({name:"intl",initialState:eb,reducers:{updateIntl:(n,l)=>{n.locale=l.payload.language,n.messages=l.payload.messages}}}),{updateIntl:Yx}=tb.actions,Kx=tb.reducer,Fx={version:void 0,requiresUserAuthentication:!1,enableStartScreen:void 0,enableStandaloneView:!1,enableTranscriptExportEmail:!1,enableTranscriptExportPdf:!1,enableGeneralConditions:!1,enableSpeechSupport:!1,commands:[],menuItems:[],allowedOrigins:void 0},nb=Jh({name:"settings",initialState:Fx,reducers:{setSettings(n,l){n.version&&n.version!==l.payload.version?(console.log("version changed, reloading chat window"),window.location.reload()):(n.version=l.payload.version,n.requiresUserAuthentication=l.payload.requiresUserAuthentication,n.enableStartScreen=l.payload.enableStartScreen,n.enableStandaloneView=l.payload.enableStandaloneView,n.enableTranscriptExportEmail=l.payload.enableTranscriptExportEmail,n.enableTranscriptExportPdf=l.payload.enableTranscriptExportPdf,n.enableGeneralConditions=l.payload.enableGeneralConditions,n.enableSpeechSupport=l.payload.enableSpeechSupport,n.commands=l.payload.commands,n.menuItems=l.payload.menuItems||[],n.allowedOrigins=l.payload.allowedOrigins)}}}),{setSettings:Jx}=nb.actions,Zx=nb.reducer,Wx=ty({settings:Zx,chat:Gx,startScreen:uS,connection:qx,intl:Kx}),Qx="bubble-chat",ab="state-last-saved-at",lb="state",Px=n=>{try{if(!t4())return;const l=Sv(n,ab);if(e4(l))return;{const r=Sv(n,lb);if(r===null)return;const s=JSON.parse(r),c=s.connection?.queryString;if(c!==void 0&&!n4(c,window.location.search)){console.log("Ignoring persisted state due to different query string");return}else return s}}catch(l){console.error(l);return}},$x=(n,l)=>{try{const r=JSON.stringify(l);Ev(n,lb,r);const s=new Date().toISOString();Ev(n,ab,s)}catch(r){console.error(r)}},e4=n=>{if(n===null)return!1;const l=new Date(n);return l.setHours(l.getHours()+12),new Date>l},t4=()=>typeof localStorage<"u",Sv=(n,l)=>{const r=rb(n,l);return localStorage.getItem(r)},Ev=(n,l,r)=>{const s=rb(n,l);return localStorage.setItem(s,r)},rb=(n,l)=>`${Qx}-${n}-${l}`,n4=(n,l)=>{const r=new URLSearchParams(n),s=new URLSearchParams(l);r.delete("referrer"),s.delete("referrer");const c=Array.from(r.entries()).sort(),f=Array.from(s.entries()).sort();return c.length!==f.length?!1:c.every(([d,m],h)=>{const[p,y]=f[h];return d===p&&m===y})},Qa=Object.create(null);Qa.open="0";Qa.close="1";Qa.ping="2";Qa.pong="3";Qa.message="4";Qa.upgrade="5";Qa.noop="6";const Mc=Object.create(null);Object.keys(Qa).forEach(n=>{Mc[Qa[n]]=n});const Sh={type:"error",data:"parser error"},ib=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",sb=typeof ArrayBuffer=="function",ob=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,cm=({type:n,data:l},r,s)=>ib&&l instanceof Blob?r?s(l):Tv(l,s):sb&&(l instanceof ArrayBuffer||ob(l))?r?s(l):Tv(new Blob([l]),s):s(Qa[n]+(l||"")),Tv=(n,l)=>{const r=new FileReader;return r.onload=function(){const s=r.result.split(",")[1];l("b"+(s||""))},r.readAsDataURL(n)};function xv(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let $d;function a4(n,l){if(ib&&n.data instanceof Blob)return n.data.arrayBuffer().then(xv).then(l);if(sb&&(n.data instanceof ArrayBuffer||ob(n.data)))return l(xv(n.data));cm(n,!1,r=>{$d||($d=new TextEncoder),l($d.encode(r))})}const Ov="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Gs=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Ov.length;n++)Gs[Ov.charCodeAt(n)]=n;const l4=n=>{let l=n.length*.75,r=n.length,s,c=0,f,d,m,h;n[n.length-1]==="="&&(l--,n[n.length-2]==="="&&l--);const p=new ArrayBuffer(l),y=new Uint8Array(p);for(s=0;s<r;s+=4)f=Gs[n.charCodeAt(s)],d=Gs[n.charCodeAt(s+1)],m=Gs[n.charCodeAt(s+2)],h=Gs[n.charCodeAt(s+3)],y[c++]=f<<2|d>>4,y[c++]=(d&15)<<4|m>>2,y[c++]=(m&3)<<6|h&63;return p},r4=typeof ArrayBuffer=="function",um=(n,l)=>{if(typeof n!="string")return{type:"message",data:cb(n,l)};const r=n.charAt(0);return r==="b"?{type:"message",data:i4(n.substring(1),l)}:Mc[r]?n.length>1?{type:Mc[r],data:n.substring(1)}:{type:Mc[r]}:Sh},i4=(n,l)=>{if(r4){const r=l4(n);return cb(r,l)}else return{base64:!0,data:n}},cb=(n,l)=>l==="blob"?n instanceof Blob?n:new Blob([n]):n instanceof ArrayBuffer?n:n.buffer,ub="",s4=(n,l)=>{const r=n.length,s=new Array(r);let c=0;n.forEach((f,d)=>{cm(f,!1,m=>{s[d]=m,++c===r&&l(s.join(ub))})})},o4=(n,l)=>{const r=n.split(ub),s=[];for(let c=0;c<r.length;c++){const f=um(r[c],l);if(s.push(f),f.type==="error")break}return s};function c4(){return new TransformStream({transform(n,l){a4(n,r=>{const s=r.length;let c;if(s<126)c=new Uint8Array(1),new DataView(c.buffer).setUint8(0,s);else if(s<65536){c=new Uint8Array(3);const f=new DataView(c.buffer);f.setUint8(0,126),f.setUint16(1,s)}else{c=new Uint8Array(9);const f=new DataView(c.buffer);f.setUint8(0,127),f.setBigUint64(1,BigInt(s))}n.data&&typeof n.data!="string"&&(c[0]|=128),l.enqueue(c),l.enqueue(r)})}})}let eh;function Ec(n){return n.reduce((l,r)=>l+r.length,0)}function Tc(n,l){if(n[0].length===l)return n.shift();const r=new Uint8Array(l);let s=0;for(let c=0;c<l;c++)r[c]=n[0][s++],s===n[0].length&&(n.shift(),s=0);return n.length&&s<n[0].length&&(n[0]=n[0].slice(s)),r}function u4(n,l){eh||(eh=new TextDecoder);const r=[];let s=0,c=-1,f=!1;return new TransformStream({transform(d,m){for(r.push(d);;){if(s===0){if(Ec(r)<1)break;const h=Tc(r,1);f=(h[0]&128)===128,c=h[0]&127,c<126?s=3:c===126?s=1:s=2}else if(s===1){if(Ec(r)<2)break;const h=Tc(r,2);c=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),s=3}else if(s===2){if(Ec(r)<8)break;const h=Tc(r,8),p=new DataView(h.buffer,h.byteOffset,h.length),y=p.getUint32(0);if(y>Math.pow(2,21)-1){m.enqueue(Sh);break}c=y*Math.pow(2,32)+p.getUint32(4),s=3}else{if(Ec(r)<c)break;const h=Tc(r,c);m.enqueue(um(f?h:eh.decode(h),l)),s=0}if(c===0||c>n){m.enqueue(Sh);break}}}})}const fb=4;function sn(n){if(n)return f4(n)}function f4(n){for(var l in sn.prototype)n[l]=sn.prototype[l];return n}sn.prototype.on=sn.prototype.addEventListener=function(n,l){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(l),this};sn.prototype.once=function(n,l){function r(){this.off(n,r),l.apply(this,arguments)}return r.fn=l,this.on(n,r),this};sn.prototype.off=sn.prototype.removeListener=sn.prototype.removeAllListeners=sn.prototype.removeEventListener=function(n,l){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+n];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var s,c=0;c<r.length;c++)if(s=r[c],s===l||s.fn===l){r.splice(c,1);break}return r.length===0&&delete this._callbacks["$"+n],this};sn.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var l=new Array(arguments.length-1),r=this._callbacks["$"+n],s=1;s<arguments.length;s++)l[s-1]=arguments[s];if(r){r=r.slice(0);for(var s=0,c=r.length;s<c;++s)r[s].apply(this,l)}return this};sn.prototype.emitReserved=sn.prototype.emit;sn.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};sn.prototype.hasListeners=function(n){return!!this.listeners(n).length};const bu=typeof Promise=="function"&&typeof Promise.resolve=="function"?l=>Promise.resolve().then(l):(l,r)=>r(l,0),Ea=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),d4="arraybuffer";function db(n,...l){return l.reduce((r,s)=>(n.hasOwnProperty(s)&&(r[s]=n[s]),r),{})}const h4=Ea.setTimeout,m4=Ea.clearTimeout;function _u(n,l){l.useNativeTimers?(n.setTimeoutFn=h4.bind(Ea),n.clearTimeoutFn=m4.bind(Ea)):(n.setTimeoutFn=Ea.setTimeout.bind(Ea),n.clearTimeoutFn=Ea.clearTimeout.bind(Ea))}const p4=1.33;function g4(n){return typeof n=="string"?v4(n):Math.ceil((n.byteLength||n.size)*p4)}function v4(n){let l=0,r=0;for(let s=0,c=n.length;s<c;s++)l=n.charCodeAt(s),l<128?r+=1:l<2048?r+=2:l<55296||l>=57344?r+=3:(s++,r+=4);return r}function hb(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function y4(n){let l="";for(let r in n)n.hasOwnProperty(r)&&(l.length&&(l+="&"),l+=encodeURIComponent(r)+"="+encodeURIComponent(n[r]));return l}function b4(n){let l={},r=n.split("&");for(let s=0,c=r.length;s<c;s++){let f=r[s].split("=");l[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return l}class _4 extends Error{constructor(l,r,s){super(l),this.description=r,this.context=s,this.type="TransportError"}}class fm extends sn{constructor(l){super(),this.writable=!1,_u(this,l),this.opts=l,this.query=l.query,this.socket=l.socket,this.supportsBinary=!l.forceBase64}onError(l,r,s){return super.emitReserved("error",new _4(l,r,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(l){this.readyState==="open"&&this.write(l)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(l){const r=um(l,this.socket.binaryType);this.onPacket(r)}onPacket(l){super.emitReserved("packet",l)}onClose(l){this.readyState="closed",super.emitReserved("close",l)}pause(l){}createUri(l,r={}){return l+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const l=this.opts.hostname;return l.indexOf(":")===-1?l:"["+l+"]"}_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(l){const r=y4(l);return r.length?"?"+r:""}}class A4 extends fm{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(l){this.readyState="pausing";const r=()=>{this.readyState="paused",l()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||r()})),this.writable||(s++,this.once("drain",function(){--s||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(l){const r=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};o4(l,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const l=()=>{this.write([{type:"close"}])};this.readyState==="open"?l():this.once("open",l)}write(l){this.writable=!1,s4(l,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const l=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=hb()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(l,r)}}let mb=!1;try{mb=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const C4=mb;function S4(){}class E4 extends A4{constructor(l){if(super(l),typeof location<"u"){const r=location.protocol==="https:";let s=location.port;s||(s=r?"443":"80"),this.xd=typeof location<"u"&&l.hostname!==location.hostname||s!==l.port}}doWrite(l,r){const s=this.request({method:"POST",data:l});s.on("success",r),s.on("error",(c,f)=>{this.onError("xhr post error",c,f)})}doPoll(){const l=this.request();l.on("data",this.onData.bind(this)),l.on("error",(r,s)=>{this.onError("xhr poll error",r,s)}),this.pollXhr=l}}class Za extends sn{constructor(l,r,s){super(),this.createRequest=l,_u(this,s),this._opts=s,this._method=s.method||"GET",this._uri=r,this._data=s.data!==void 0?s.data:null,this._create()}_create(){var l;const r=db(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(r);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let c in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(c)&&s.setRequestHeader(c,this._opts.extraHeaders[c])}}catch{}if(this._method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(l=this._opts.cookieJar)===null||l===void 0||l.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var c;s.readyState===3&&((c=this._opts.cookieJar)===null||c===void 0||c.parseCookies(s.getResponseHeader("set-cookie"))),s.readyState===4&&(s.status===200||s.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof s.status=="number"?s.status:0)},0))},s.send(this._data)}catch(c){this.setTimeoutFn(()=>{this._onError(c)},0);return}typeof document<"u"&&(this._index=Za.requestsCount++,Za.requests[this._index]=this)}_onError(l){this.emitReserved("error",l,this._xhr),this._cleanup(!0)}_cleanup(l){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=S4,l)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Za.requests[this._index],this._xhr=null}}_onLoad(){const l=this._xhr.responseText;l!==null&&(this.emitReserved("data",l),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Za.requestsCount=0;Za.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Rv);else if(typeof addEventListener=="function"){const n="onpagehide"in Ea?"pagehide":"unload";addEventListener(n,Rv,!1)}}function Rv(){for(let n in Za.requests)Za.requests.hasOwnProperty(n)&&Za.requests[n].abort()}const T4=(function(){const n=pb({xdomain:!1});return n&&n.responseType!==null})();class x4 extends E4{constructor(l){super(l);const r=l&&l.forceBase64;this.supportsBinary=T4&&!r}request(l={}){return Object.assign(l,{xd:this.xd},this.opts),new Za(pb,this.uri(),l)}}function pb(n){const l=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!l||C4))return new XMLHttpRequest}catch{}if(!l)try{return new Ea[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const gb=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class O4 extends fm{get name(){return"websocket"}doOpen(){const l=this.uri(),r=this.opts.protocols,s=gb?{}:db(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(l,r,s)}catch(c){return this.emitReserved("error",c)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=l=>this.onClose({description:"websocket connection closed",context:l}),this.ws.onmessage=l=>this.onData(l.data),this.ws.onerror=l=>this.onError("websocket error",l)}write(l){this.writable=!1;for(let r=0;r<l.length;r++){const s=l[r],c=r===l.length-1;cm(s,this.supportsBinary,f=>{try{this.doWrite(s,f)}catch{}c&&bu(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const l=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=hb()),this.supportsBinary||(r.b64=1),this.createUri(l,r)}}const th=Ea.WebSocket||Ea.MozWebSocket;class R4 extends O4{createSocket(l,r,s){return gb?new th(l,r,s):r?new th(l,r):new th(l)}doWrite(l,r){this.ws.send(r)}}class w4 extends fm{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(l){return this.emitReserved("error",l)}this._transport.closed.then(()=>{this.onClose()}).catch(l=>{this.onError("webtransport error",l)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(l=>{const r=u4(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=l.readable.pipeThrough(r).getReader(),c=c4();c.readable.pipeTo(l.writable),this._writer=c.writable.getWriter();const f=()=>{s.read().then(({done:m,value:h})=>{m||(this.onPacket(h),f())}).catch(m=>{})};f();const d={type:"open"};this.query.sid&&(d.data=`{"sid":"${this.query.sid}"}`),this._writer.write(d).then(()=>this.onOpen())})})}write(l){this.writable=!1;for(let r=0;r<l.length;r++){const s=l[r],c=r===l.length-1;this._writer.write(s).then(()=>{c&&bu(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var l;(l=this._transport)===null||l===void 0||l.close()}}const N4={websocket:R4,webtransport:w4,polling:x4},M4=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,D4=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Eh(n){if(n.length>8e3)throw"URI too long";const l=n,r=n.indexOf("["),s=n.indexOf("]");r!=-1&&s!=-1&&(n=n.substring(0,r)+n.substring(r,s).replace(/:/g,";")+n.substring(s,n.length));let c=M4.exec(n||""),f={},d=14;for(;d--;)f[D4[d]]=c[d]||"";return r!=-1&&s!=-1&&(f.source=l,f.host=f.host.substring(1,f.host.length-1).replace(/;/g,":"),f.authority=f.authority.replace("[","").replace("]","").replace(/;/g,":"),f.ipv6uri=!0),f.pathNames=L4(f,f.path),f.queryKey=z4(f,f.query),f}function L4(n,l){const r=/\/{2,9}/g,s=l.replace(r,"/").split("/");return(l.slice(0,1)=="/"||l.length===0)&&s.splice(0,1),l.slice(-1)=="/"&&s.splice(s.length-1,1),s}function z4(n,l){const r={};return l.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,c,f){c&&(r[c]=f)}),r}const Th=typeof addEventListener=="function"&&typeof removeEventListener=="function",Dc=[];Th&&addEventListener("offline",()=>{Dc.forEach(n=>n())},!1);class ur extends sn{constructor(l,r){if(super(),this.binaryType=d4,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,l&&typeof l=="object"&&(r=l,l=null),l){const s=Eh(l);r.hostname=s.host,r.secure=s.protocol==="https"||s.protocol==="wss",r.port=s.port,s.query&&(r.query=s.query)}else r.host&&(r.hostname=Eh(r.host).host);_u(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(s=>{const c=s.prototype.name;this.transports.push(c),this._transportsByName[c]=s}),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},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=b4(this.opts.query)),Th&&(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"})},Dc.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(l){const r=Object.assign({},this.opts.query);r.EIO=fb,r.transport=l,this.id&&(r.sid=this.id);const s=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[l]);return new this._transportsByName[l](s)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const l=this.opts.rememberUpgrade&&ur.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(l);r.open(),this.setTransport(r)}setTransport(l){this.transport&&this.transport.removeAllListeners(),this.transport=l,l.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",ur.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(l){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",l),this.emitReserved("heartbeat"),l.type){case"open":this.onHandshake(JSON.parse(l.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const r=new Error("server error");r.code=l.data,this._onError(r);break;case"message":this.emitReserved("data",l.data),this.emitReserved("message",l.data);break}}onHandshake(l){this.emitReserved("handshake",l),this.id=l.sid,this.transport.query.sid=l.sid,this._pingInterval=l.pingInterval,this._pingTimeout=l.pingTimeout,this._maxPayload=l.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const l=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+l,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},l),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const l=this._getWritablePackets();this.transport.send(l),this._prevBufferLen=l.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let s=0;s<this.writeBuffer.length;s++){const c=this.writeBuffer[s].data;if(c&&(r+=g4(c)),s>0&&r>this._maxPayload)return this.writeBuffer.slice(0,s);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const l=Date.now()>this._pingTimeoutTime;return l&&(this._pingTimeoutTime=0,bu(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),l}write(l,r,s){return this._sendPacket("message",l,r,s),this}send(l,r,s){return this._sendPacket("message",l,r,s),this}_sendPacket(l,r,s,c){if(typeof r=="function"&&(c=r,r=void 0),typeof s=="function"&&(c=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const f={type:l,data:r,options:s};this.emitReserved("packetCreate",f),this.writeBuffer.push(f),c&&this.once("flush",c),this.flush()}close(){const l=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),l()},s=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():l()}):this.upgrading?s():l()),this}_onError(l){if(ur.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",l),this._onClose("transport error",l)}_onClose(l,r){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(),Th&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=Dc.indexOf(this._offlineEventListener);s!==-1&&Dc.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",l,r),this.writeBuffer=[],this._prevBufferLen=0}}}ur.protocol=fb;class k4 extends ur{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let l=0;l<this._upgrades.length;l++)this._probe(this._upgrades[l])}_probe(l){let r=this.createTransport(l),s=!1;ur.priorWebsocketSuccess=!1;const c=()=>{s||(r.send([{type:"ping",data:"probe"}]),r.once("packet",b=>{if(!s)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;ur.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(y(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const C=new Error("probe error");C.transport=r.name,this.emitReserved("upgradeError",C)}}))};function f(){s||(s=!0,y(),r.close(),r=null)}const d=b=>{const C=new Error("probe error: "+b);C.transport=r.name,f(),this.emitReserved("upgradeError",C)};function m(){d("transport closed")}function h(){d("socket closed")}function p(b){r&&b.name!==r.name&&f()}const y=()=>{r.removeListener("open",c),r.removeListener("error",d),r.removeListener("close",m),this.off("close",h),this.off("upgrading",p)};r.once("open",c),r.once("error",d),r.once("close",m),this.once("close",h),this.once("upgrading",p),this._upgrades.indexOf("webtransport")!==-1&&l!=="webtransport"?this.setTimeoutFn(()=>{s||r.open()},200):r.open()}onHandshake(l){this._upgrades=this._filterUpgrades(l.upgrades),super.onHandshake(l)}_filterUpgrades(l){const r=[];for(let s=0;s<l.length;s++)~this.transports.indexOf(l[s])&&r.push(l[s]);return r}}let B4=class extends k4{constructor(l,r={}){const s=typeof l=="object"?l:r;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(c=>N4[c]).filter(c=>!!c)),super(l,s)}};function j4(n,l="",r){let s=n;r=r||typeof location<"u"&&location,n==null&&(n=r.protocol+"//"+r.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=r.protocol+n:n=r.host+n),/^(https?|wss?):\/\//.test(n)||(typeof r<"u"?n=r.protocol+"//"+n:n="https://"+n),s=Eh(n)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const f=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+f+":"+s.port+l,s.href=s.protocol+"://"+f+(r&&r.port===s.port?"":":"+s.port),s}const U4=typeof ArrayBuffer=="function",H4=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,vb=Object.prototype.toString,q4=typeof Blob=="function"||typeof Blob<"u"&&vb.call(Blob)==="[object BlobConstructor]",I4=typeof File=="function"||typeof File<"u"&&vb.call(File)==="[object FileConstructor]";function dm(n){return U4&&(n instanceof ArrayBuffer||H4(n))||q4&&n instanceof Blob||I4&&n instanceof File}function Lc(n,l){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let r=0,s=n.length;r<s;r++)if(Lc(n[r]))return!0;return!1}if(dm(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return Lc(n.toJSON(),!0);for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)&&Lc(n[r]))return!0;return!1}function G4(n){const l=[],r=n.data,s=n;return s.data=xh(r,l),s.attachments=l.length,{packet:s,buffers:l}}function xh(n,l){if(!n)return n;if(dm(n)){const r={_placeholder:!0,num:l.length};return l.push(n),r}else if(Array.isArray(n)){const r=new Array(n.length);for(let s=0;s<n.length;s++)r[s]=xh(n[s],l);return r}else if(typeof n=="object"&&!(n instanceof Date)){const r={};for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=xh(n[s],l));return r}return n}function V4(n,l){return n.data=Oh(n.data,l),delete n.attachments,n}function Oh(n,l){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<l.length)return l[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let r=0;r<n.length;r++)n[r]=Oh(n[r],l);else if(typeof n=="object")for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=Oh(n[r],l));return n}const X4=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var We;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(We||(We={}));class Y4{constructor(l){this.replacer=l}encode(l){return(l.type===We.EVENT||l.type===We.ACK)&&Lc(l)?this.encodeAsBinary({type:l.type===We.EVENT?We.BINARY_EVENT:We.BINARY_ACK,nsp:l.nsp,data:l.data,id:l.id}):[this.encodeAsString(l)]}encodeAsString(l){let r=""+l.type;return(l.type===We.BINARY_EVENT||l.type===We.BINARY_ACK)&&(r+=l.attachments+"-"),l.nsp&&l.nsp!=="/"&&(r+=l.nsp+","),l.id!=null&&(r+=l.id),l.data!=null&&(r+=JSON.stringify(l.data,this.replacer)),r}encodeAsBinary(l){const r=G4(l),s=this.encodeAsString(r.packet),c=r.buffers;return c.unshift(s),c}}class hm extends sn{constructor(l){super(),this.reviver=l}add(l){let r;if(typeof l=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(l);const s=r.type===We.BINARY_EVENT;s||r.type===We.BINARY_ACK?(r.type=s?We.EVENT:We.ACK,this.reconstructor=new K4(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(dm(l)||l.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(l),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+l)}decodeString(l){let r=0;const s={type:Number(l.charAt(0))};if(We[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===We.BINARY_EVENT||s.type===We.BINARY_ACK){const f=r+1;for(;l.charAt(++r)!=="-"&&r!=l.length;);const d=l.substring(f,r);if(d!=Number(d)||l.charAt(r)!=="-")throw new Error("Illegal attachments");s.attachments=Number(d)}if(l.charAt(r+1)==="/"){const f=r+1;for(;++r&&!(l.charAt(r)===","||r===l.length););s.nsp=l.substring(f,r)}else s.nsp="/";const c=l.charAt(r+1);if(c!==""&&Number(c)==c){const f=r+1;for(;++r;){const d=l.charAt(r);if(d==null||Number(d)!=d){--r;break}if(r===l.length)break}s.id=Number(l.substring(f,r+1))}if(l.charAt(++r)){const f=this.tryParse(l.substr(r));if(hm.isPayloadValid(s.type,f))s.data=f;else throw new Error("invalid payload")}return s}tryParse(l){try{return JSON.parse(l,this.reviver)}catch{return!1}}static isPayloadValid(l,r){switch(l){case We.CONNECT:return wv(r);case We.DISCONNECT:return r===void 0;case We.CONNECT_ERROR:return typeof r=="string"||wv(r);case We.EVENT:case We.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&X4.indexOf(r[0])===-1);case We.ACK:case We.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class K4{constructor(l){this.packet=l,this.buffers=[],this.reconPack=l}takeBinaryData(l){if(this.buffers.push(l),this.buffers.length===this.reconPack.attachments){const r=V4(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function wv(n){return Object.prototype.toString.call(n)==="[object Object]"}const F4=Object.freeze(Object.defineProperty({__proto__:null,Decoder:hm,Encoder:Y4,get PacketType(){return We}},Symbol.toStringTag,{value:"Module"}));function Ba(n,l,r){return n.on(l,r),function(){n.off(l,r)}}const J4=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class yb extends sn{constructor(l,r,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=l,this.nsp=r,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const l=this.io;this.subs=[Ba(l,"open",this.onopen.bind(this)),Ba(l,"packet",this.onpacket.bind(this)),Ba(l,"error",this.onerror.bind(this)),Ba(l,"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(...l){return l.unshift("message"),this.emit.apply(this,l),this}emit(l,...r){var s,c,f;if(J4.hasOwnProperty(l))throw new Error('"'+l.toString()+'" is a reserved event name');if(r.unshift(l),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const d={type:We.EVENT,data:r};if(d.options={},d.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const y=this.ids++,b=r.pop();this._registerAckCallback(y,b),d.id=y}const m=(c=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||c===void 0?void 0:c.writable,h=this.connected&&!(!((f=this.io.engine)===null||f===void 0)&&f._hasPingExpired());return this.flags.volatile&&!m||(h?(this.notifyOutgoingListeners(d),this.packet(d)):this.sendBuffer.push(d)),this.flags={},this}_registerAckCallback(l,r){var s;const c=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(c===void 0){this.acks[l]=r;return}const f=this.io.setTimeoutFn(()=>{delete this.acks[l];for(let m=0;m<this.sendBuffer.length;m++)this.sendBuffer[m].id===l&&this.sendBuffer.splice(m,1);r.call(this,new Error("operation has timed out"))},c),d=(...m)=>{this.io.clearTimeoutFn(f),r.apply(this,m)};d.withError=!0,this.acks[l]=d}emitWithAck(l,...r){return new Promise((s,c)=>{const f=(d,m)=>d?c(d):s(m);f.withError=!0,r.push(f),this.emit(l,...r)})}_addToQueue(l){let r;typeof l[l.length-1]=="function"&&(r=l.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:l,flags:Object.assign({fromQueue:!0},this.flags)};l.push((c,...f)=>(this._queue[0],c!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(c)):(this._queue.shift(),r&&r(null,...f)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(l=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!l||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(l){l.nsp=this.nsp,this.io._packet(l)}onopen(){typeof this.auth=="function"?this.auth(l=>{this._sendConnectPacket(l)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(l){this.packet({type:We.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},l):l})}onerror(l){this.connected||this.emitReserved("connect_error",l)}onclose(l,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",l,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(l=>{if(!this.sendBuffer.some(s=>String(s.id)===l)){const s=this.acks[l];delete this.acks[l],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(l){if(l.nsp===this.nsp)switch(l.type){case We.CONNECT:l.data&&l.data.sid?this.onconnect(l.data.sid,l.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 We.EVENT:case We.BINARY_EVENT:this.onevent(l);break;case We.ACK:case We.BINARY_ACK:this.onack(l);break;case We.DISCONNECT:this.ondisconnect();break;case We.CONNECT_ERROR:this.destroy();const s=new Error(l.data.message);s.data=l.data.data,this.emitReserved("connect_error",s);break}}onevent(l){const r=l.data||[];l.id!=null&&r.push(this.ack(l.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(l){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const s of r)s.apply(this,l)}super.emit.apply(this,l),this._pid&&l.length&&typeof l[l.length-1]=="string"&&(this._lastOffset=l[l.length-1])}ack(l){const r=this;let s=!1;return function(...c){s||(s=!0,r.packet({type:We.ACK,id:l,data:c}))}}onack(l){const r=this.acks[l.id];typeof r=="function"&&(delete this.acks[l.id],r.withError&&l.data.unshift(null),r.apply(this,l.data))}onconnect(l,r){this.id=l,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(l=>this.emitEvent(l)),this.receiveBuffer=[],this.sendBuffer.forEach(l=>{this.notifyOutgoingListeners(l),this.packet(l)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(l=>l()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:We.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(l){return this.flags.compress=l,this}get volatile(){return this.flags.volatile=!0,this}timeout(l){return this.flags.timeout=l,this}onAny(l){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(l),this}prependAny(l){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(l),this}offAny(l){if(!this._anyListeners)return this;if(l){const r=this._anyListeners;for(let s=0;s<r.length;s++)if(l===r[s])return r.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(l){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(l),this}prependAnyOutgoing(l){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(l),this}offAnyOutgoing(l){if(!this._anyOutgoingListeners)return this;if(l){const r=this._anyOutgoingListeners;for(let s=0;s<r.length;s++)if(l===r[s])return r.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(l){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const s of r)s.apply(this,l.data)}}}function Ui(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}Ui.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var l=Math.random(),r=Math.floor(l*this.jitter*n);n=(Math.floor(l*10)&1)==0?n-r:n+r}return Math.min(n,this.max)|0};Ui.prototype.reset=function(){this.attempts=0};Ui.prototype.setMin=function(n){this.ms=n};Ui.prototype.setMax=function(n){this.max=n};Ui.prototype.setJitter=function(n){this.jitter=n};class Rh extends sn{constructor(l,r){var s;super(),this.nsps={},this.subs=[],l&&typeof l=="object"&&(r=l,l=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,_u(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((s=r.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new Ui({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=l;const c=r.parser||F4;this.encoder=new c.Encoder,this.decoder=new c.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(l){return arguments.length?(this._reconnection=!!l,l||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(l){return l===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=l,this)}reconnectionDelay(l){var r;return l===void 0?this._reconnectionDelay:(this._reconnectionDelay=l,(r=this.backoff)===null||r===void 0||r.setMin(l),this)}randomizationFactor(l){var r;return l===void 0?this._randomizationFactor:(this._randomizationFactor=l,(r=this.backoff)===null||r===void 0||r.setJitter(l),this)}reconnectionDelayMax(l){var r;return l===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=l,(r=this.backoff)===null||r===void 0||r.setMax(l),this)}timeout(l){return arguments.length?(this._timeout=l,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(l){if(~this._readyState.indexOf("open"))return this;this.engine=new B4(this.uri,this.opts);const r=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const c=Ba(r,"open",function(){s.onopen(),l&&l()}),f=m=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",m),l?l(m):this.maybeReconnectOnOpen()},d=Ba(r,"error",f);if(this._timeout!==!1){const m=this._timeout,h=this.setTimeoutFn(()=>{c(),f(new Error("timeout")),r.close()},m);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(c),this.subs.push(d),this}connect(l){return this.open(l)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const l=this.engine;this.subs.push(Ba(l,"ping",this.onping.bind(this)),Ba(l,"data",this.ondata.bind(this)),Ba(l,"error",this.onerror.bind(this)),Ba(l,"close",this.onclose.bind(this)),Ba(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(l){try{this.decoder.add(l)}catch(r){this.onclose("parse error",r)}}ondecoded(l){bu(()=>{this.emitReserved("packet",l)},this.setTimeoutFn)}onerror(l){this.emitReserved("error",l)}socket(l,r){let s=this.nsps[l];return s?this._autoConnect&&!s.active&&s.connect():(s=new yb(this,l,r),this.nsps[l]=s),s}_destroy(l){const r=Object.keys(this.nsps);for(const s of r)if(this.nsps[s].active)return;this._close()}_packet(l){const r=this.encoder.encode(l);for(let s=0;s<r.length;s++)this.engine.write(r[s],l.options)}cleanup(){this.subs.forEach(l=>l()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(l,r){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",l,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const l=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{l.skipReconnect||(this.emitReserved("reconnect_attempt",l.backoff.attempts),!l.skipReconnect&&l.open(c=>{c?(l._reconnecting=!1,l.reconnect(),this.emitReserved("reconnect_error",c)):l.onreconnect()}))},r);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const l=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",l)}}const Hs={};function zc(n,l){typeof n=="object"&&(l=n,n=void 0),l=l||{};const r=j4(n,l.path||"/socket.io"),s=r.source,c=r.id,f=r.path,d=Hs[c]&&f in Hs[c].nsps,m=l.forceNew||l["force new connection"]||l.multiplex===!1||d;let h;return m?h=new Rh(s,l):(Hs[c]||(Hs[c]=new Rh(s,l)),h=Hs[c]),r.query&&!l.query&&(l.query=r.queryKey),h.socket(r.path,l)}Object.assign(zc,{Manager:Rh,Socket:yb,io:zc,connect:zc});const Z4=[Iv,Gv,Uv,Hv,XA,...mS,...nC,"@@localize/SET_ACTIVE_LANGUAGE","@@localize/ADD_TRANSLATION_FOR_LANGUAGE"],W4=({dispatch:n,getState:l})=>r=>{let s=null;return c=>{const f=r(c);if(c.type===Zh){s?.disconnect(),n(vS());const m={path:`/website-messenger/${c.clientName}/socket.io`,query:c.querystrings};s=zc(m),s.on("action",n),s.on("connect",()=>n(yS())),s.on("disconnect",()=>n(bS())),s.on("reconnect",()=>n(_S())),s.on("set-translations",(h,p)=>{n(Yx({language:h,messages:Ux(h,p)}))}),s.on("set-settings",h=>{n(Jx(h))}),s.on("enable-conversation-rating",h=>n(sC(h))),s.on("speech-transcription",h=>n(lC(h))),s.on("restore-client-state",h=>{n(gS(h.sessionId)),n(cC(h.messages))}),s.on("expand-window",({devices:h,initial:p=!1})=>{n({type:Jv,devices:h,initial:p})}),s.on("restart-chat",()=>{n(Ws())}),s.on("login-success",h=>{n(iS({loginToken:h.loginToken}))})}else if(c.type==="start-screen/requestLogin")s?.emit("login-requested",c.payload);else if(c.type===fu)s?.emit("start-chat",c.payload);else if(c.type===du)s?.emit("terminate-session",c.payload);else if(c.type===tC)s?.emit("get-started",JSON.stringify(c));else if(c.type===Uh)s?.emit("audio-message",c.buffer);else if(c.type===zh)s?.emit("conversation-rating",c.payload);else if(c.type===Wv){const{connection:{sessionId:d}}=l(),m=au();window.location.href=`/${m}/transcript-pdf/${d}`}else Z4.indexOf(c.type)===-1&&c.meta===void 0&&s&&s.emit("action",JSON.stringify(c));return f}},bb=au(),Q4={...Px(bb),intl:eb},wh=KC({middleware:n=>n().concat(W4),reducer:Wx,preloadedState:Q4});wh.subscribe(s6(()=>{const n=wh.getState();$x(bb,{connection:n.connection,startScreen:n.startScreen})},1e3));const P4=document.getElementById("root"),$4=k2.createRoot(P4);$4.render(v.jsx(zA,{store:wh,children:v.jsx(Lx,{})}));
76
- //# sourceMappingURL=index-DBExFEgW.js.map
75
+ - 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"},jx=["de","en","fr","it"],eb={locale:"de",messages:Py},Ux=(n,l)=>{if(jx.includes(n)){const r=Hx(n),s=$y(l);return{...r,...s}}return l},Hx=n=>{switch(n.toString()){case"en":return zx;case"fr":return kx;case"it":return Bx;default:return Py}},qx=(n=Ix,l)=>{switch(l.type){case Wh:return Object.assign({},n,{connectionState:Kr.CONNECTING});case Qh:return Object.assign({},n,{connectionState:Kr.CONNECTED});case Ph:return Object.assign({},n,{connectionState:Kr.DISCONNECTED});case $h:return Object.assign({},n,{connectionState:Kr.RECONNECTED});case em:return Object.assign({},n,{sessionId:l.sessionId});case fu:return Object.assign({},n,{sessionId:l.payload.sessionId,userId:l.payload.userId});case du:return Object.assign({},n,{sessionId:void 0});default:return n}},Ix={connectionState:Kr.DISCONNECTED,sessionId:void 0,userId:void 0,queryString:window.location.search},Gx=(n=Cv,l)=>{switch(l.type){case gy:return Cv;case fu:return Yr({type:"webclient.chat.started"}),n;case du:return Yr({type:"webclient.chat.ended"}),n;case Uv:return Object.assign({},n,{isBotTyping:!0});case Hv:return Object.assign({},n,{isBotTyping:!1});case Lh:case qv:return Av(n,l.message);case Iv:{Yr(l);const r=Object.assign({},l.message,{_id:l.meta.actionId}),s=n.messages.filter(c=>c._id===l.meta.actionId).length>0;return Object.assign({},n,{isBotTyping:!1,messages:s?n.messages:n.messages.concat([r]),quickReplies:r.quickReplies?r.quickReplies:[]})}case jh:{const r=l.messages,s=r.length?r[r.length-1]:void 0;return Object.assign({},n,{isBotTyping:!1,messages:r,quickReplies:s?.quickReplies||[]})}case Bh:return Yr(l.message),n;case Gv:return Yr(l.event),n;case KA:return Object.assign({},n,{drawerContentUrl:l.payload.parameters.contentUrl});case FA:return Object.assign({},n,{drawerContentUrl:void 0});case JA:return Object.assign({},n,{locale:l.payload.locale});case Jv:return Yr(l),n;case Zv:return Yr(l),{...n,conversationRating:{...n.conversationRating,opener:void 0}};case Hh:{const r=new nu(l.transcription,new kh),s=Object.assign({},r,{_id:jc()});return Av(n,s)}case Vv:{const r=n.messages.map(s=>s._id===l.payload.actionId?Object.assign({},s,l.payload.reaction?{reaction:{type:l.payload.reaction,category:l.payload.category,comment:l.payload.comment}}:{reaction:void 0}):s);return Object.assign({},n,{messages:r})}case qh:{const r={enabled:!0,rating:l.payload.rating};return Object.assign({},n,{conversationRating:r})}case zh:{const r={...n.conversationRating,rating:l.payload};return Object.assign({},n,{conversationRating:r})}case yy:{const r={...n.conversationRating,opener:l.payload.opener,...l.payload.defaultRating?{rating:{value:l.payload.defaultRating,feedback:n.conversationRating.rating?.feedback||""}}:{}};return Object.assign({},n,{conversationRating:r})}case by:{const r={...n.conversationRating,opener:void 0};return Object.assign({},n,{conversationRating:r})}case Gh:return{...n,sourceInfos:{type:"loading",chunkId:l.payload.chunkId}};case Ih:{const{highlighted:r}=l.payload;return n.sourceInfos?.type==="loaded"&&r?{...n,sourceInfos:{...n.sourceInfos,highlighted:!0}}:{...n,sourceInfos:{type:"loading-error"}}}case Fv:{const r=n.sourceInfos?.type,{chunkId:s,knowledgeBaseType:c,title:f,content:d,highlighted:m,url:h}=l.payload,p=n.sourceInfos?.type==="loading"||n.sourceInfos?.type==="loaded"?n.sourceInfos?.chunkId:void 0;return p&&p!==s?n:r==="loading"||r==="loaded"&&m?{...n,sourceInfos:{type:"loaded",chunkId:s,knowledgeBaseType:c,title:f,content:d,highlighted:m,url:h}}:n}case Vh:return{...n,sourceInfos:void 0};case vy:return{...n,showTranscriptMailOverlay:!n.showTranscriptMailOverlay,conversationRating:{...n.conversationRating,opener:void 0}};default:return n}},Av=(n,l)=>{const r=n.messages[n.messages.length-1],s=r?.text===l.text;return r&&r.sender.type===l.sender.type&&s?n:Object.assign({},n,{messages:n.messages.concat([l]),quickReplies:[]})},Yr=n=>{if(Xx()){const l=Vx();window.top?.postMessage(n,l)}else n.type==="webclient.change.url"&&window.open(n.url)},Vx=()=>{try{return document.referrer?new URL(document.referrer).origin:"*"}catch{return"*"}},Xx=()=>typeof window<"u"&&window.self!==window.top,Cv={messages:[],quickReplies:[],isBotTyping:!1,showTranscriptMailOverlay:!1,conversationRating:{enabled:!1}},tb=Jh({name:"intl",initialState:eb,reducers:{updateIntl:(n,l)=>{n.locale=l.payload.language,n.messages=l.payload.messages}}}),{updateIntl:Yx}=tb.actions,Kx=tb.reducer,Fx={version:void 0,requiresUserAuthentication:!1,enableStartScreen:void 0,enableStandaloneView:!1,enableTranscriptExportEmail:!1,enableTranscriptExportPdf:!1,enableGeneralConditions:!1,enableSpeechSupport:!1,commands:[],menuItems:[],allowedOrigins:void 0},nb=Jh({name:"settings",initialState:Fx,reducers:{setSettings(n,l){n.version&&n.version!==l.payload.version?(console.log("version changed, reloading chat window"),window.location.reload()):(n.version=l.payload.version,n.requiresUserAuthentication=l.payload.requiresUserAuthentication,n.enableStartScreen=l.payload.enableStartScreen,n.enableStandaloneView=l.payload.enableStandaloneView,n.enableTranscriptExportEmail=l.payload.enableTranscriptExportEmail,n.enableTranscriptExportPdf=l.payload.enableTranscriptExportPdf,n.enableGeneralConditions=l.payload.enableGeneralConditions,n.enableSpeechSupport=l.payload.enableSpeechSupport,n.commands=l.payload.commands,n.menuItems=l.payload.menuItems||[],n.allowedOrigins=l.payload.allowedOrigins)}}}),{setSettings:Jx}=nb.actions,Zx=nb.reducer,Wx=ty({settings:Zx,chat:Gx,startScreen:uS,connection:qx,intl:Kx}),Qx="bubble-chat",ab="state-last-saved-at",lb="state",Px=n=>{try{if(!t4())return;const l=Sv(n,ab);if(e4(l))return;{const r=Sv(n,lb);if(r===null)return;const s=JSON.parse(r),c=s.connection?.queryString;if(c!==void 0&&!n4(c,window.location.search)){console.log("Ignoring persisted state due to different query string");return}else return s}}catch(l){console.error(l);return}},$x=(n,l)=>{try{const r=JSON.stringify(l);Ev(n,lb,r);const s=new Date().toISOString();Ev(n,ab,s)}catch(r){console.error(r)}},e4=n=>{if(n===null)return!1;const l=new Date(n);return l.setHours(l.getHours()+12),new Date>l},t4=()=>typeof localStorage<"u",Sv=(n,l)=>{const r=rb(n,l);return localStorage.getItem(r)},Ev=(n,l,r)=>{const s=rb(n,l);return localStorage.setItem(s,r)},rb=(n,l)=>`${Qx}-${n}-${l}`,n4=(n,l)=>{const r=new URLSearchParams(n),s=new URLSearchParams(l);r.delete("referrer"),s.delete("referrer");const c=Array.from(r.entries()).sort(),f=Array.from(s.entries()).sort();return c.length!==f.length?!1:c.every(([d,m],h)=>{const[p,y]=f[h];return d===p&&m===y})},Qa=Object.create(null);Qa.open="0";Qa.close="1";Qa.ping="2";Qa.pong="3";Qa.message="4";Qa.upgrade="5";Qa.noop="6";const Mc=Object.create(null);Object.keys(Qa).forEach(n=>{Mc[Qa[n]]=n});const Sh={type:"error",data:"parser error"},ib=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",sb=typeof ArrayBuffer=="function",ob=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,cm=({type:n,data:l},r,s)=>ib&&l instanceof Blob?r?s(l):Tv(l,s):sb&&(l instanceof ArrayBuffer||ob(l))?r?s(l):Tv(new Blob([l]),s):s(Qa[n]+(l||"")),Tv=(n,l)=>{const r=new FileReader;return r.onload=function(){const s=r.result.split(",")[1];l("b"+(s||""))},r.readAsDataURL(n)};function xv(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let $d;function a4(n,l){if(ib&&n.data instanceof Blob)return n.data.arrayBuffer().then(xv).then(l);if(sb&&(n.data instanceof ArrayBuffer||ob(n.data)))return l(xv(n.data));cm(n,!1,r=>{$d||($d=new TextEncoder),l($d.encode(r))})}const Ov="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Gs=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Ov.length;n++)Gs[Ov.charCodeAt(n)]=n;const l4=n=>{let l=n.length*.75,r=n.length,s,c=0,f,d,m,h;n[n.length-1]==="="&&(l--,n[n.length-2]==="="&&l--);const p=new ArrayBuffer(l),y=new Uint8Array(p);for(s=0;s<r;s+=4)f=Gs[n.charCodeAt(s)],d=Gs[n.charCodeAt(s+1)],m=Gs[n.charCodeAt(s+2)],h=Gs[n.charCodeAt(s+3)],y[c++]=f<<2|d>>4,y[c++]=(d&15)<<4|m>>2,y[c++]=(m&3)<<6|h&63;return p},r4=typeof ArrayBuffer=="function",um=(n,l)=>{if(typeof n!="string")return{type:"message",data:cb(n,l)};const r=n.charAt(0);return r==="b"?{type:"message",data:i4(n.substring(1),l)}:Mc[r]?n.length>1?{type:Mc[r],data:n.substring(1)}:{type:Mc[r]}:Sh},i4=(n,l)=>{if(r4){const r=l4(n);return cb(r,l)}else return{base64:!0,data:n}},cb=(n,l)=>l==="blob"?n instanceof Blob?n:new Blob([n]):n instanceof ArrayBuffer?n:n.buffer,ub="",s4=(n,l)=>{const r=n.length,s=new Array(r);let c=0;n.forEach((f,d)=>{cm(f,!1,m=>{s[d]=m,++c===r&&l(s.join(ub))})})},o4=(n,l)=>{const r=n.split(ub),s=[];for(let c=0;c<r.length;c++){const f=um(r[c],l);if(s.push(f),f.type==="error")break}return s};function c4(){return new TransformStream({transform(n,l){a4(n,r=>{const s=r.length;let c;if(s<126)c=new Uint8Array(1),new DataView(c.buffer).setUint8(0,s);else if(s<65536){c=new Uint8Array(3);const f=new DataView(c.buffer);f.setUint8(0,126),f.setUint16(1,s)}else{c=new Uint8Array(9);const f=new DataView(c.buffer);f.setUint8(0,127),f.setBigUint64(1,BigInt(s))}n.data&&typeof n.data!="string"&&(c[0]|=128),l.enqueue(c),l.enqueue(r)})}})}let eh;function Ec(n){return n.reduce((l,r)=>l+r.length,0)}function Tc(n,l){if(n[0].length===l)return n.shift();const r=new Uint8Array(l);let s=0;for(let c=0;c<l;c++)r[c]=n[0][s++],s===n[0].length&&(n.shift(),s=0);return n.length&&s<n[0].length&&(n[0]=n[0].slice(s)),r}function u4(n,l){eh||(eh=new TextDecoder);const r=[];let s=0,c=-1,f=!1;return new TransformStream({transform(d,m){for(r.push(d);;){if(s===0){if(Ec(r)<1)break;const h=Tc(r,1);f=(h[0]&128)===128,c=h[0]&127,c<126?s=3:c===126?s=1:s=2}else if(s===1){if(Ec(r)<2)break;const h=Tc(r,2);c=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),s=3}else if(s===2){if(Ec(r)<8)break;const h=Tc(r,8),p=new DataView(h.buffer,h.byteOffset,h.length),y=p.getUint32(0);if(y>Math.pow(2,21)-1){m.enqueue(Sh);break}c=y*Math.pow(2,32)+p.getUint32(4),s=3}else{if(Ec(r)<c)break;const h=Tc(r,c);m.enqueue(um(f?h:eh.decode(h),l)),s=0}if(c===0||c>n){m.enqueue(Sh);break}}}})}const fb=4;function sn(n){if(n)return f4(n)}function f4(n){for(var l in sn.prototype)n[l]=sn.prototype[l];return n}sn.prototype.on=sn.prototype.addEventListener=function(n,l){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(l),this};sn.prototype.once=function(n,l){function r(){this.off(n,r),l.apply(this,arguments)}return r.fn=l,this.on(n,r),this};sn.prototype.off=sn.prototype.removeListener=sn.prototype.removeAllListeners=sn.prototype.removeEventListener=function(n,l){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+n];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var s,c=0;c<r.length;c++)if(s=r[c],s===l||s.fn===l){r.splice(c,1);break}return r.length===0&&delete this._callbacks["$"+n],this};sn.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var l=new Array(arguments.length-1),r=this._callbacks["$"+n],s=1;s<arguments.length;s++)l[s-1]=arguments[s];if(r){r=r.slice(0);for(var s=0,c=r.length;s<c;++s)r[s].apply(this,l)}return this};sn.prototype.emitReserved=sn.prototype.emit;sn.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};sn.prototype.hasListeners=function(n){return!!this.listeners(n).length};const bu=typeof Promise=="function"&&typeof Promise.resolve=="function"?l=>Promise.resolve().then(l):(l,r)=>r(l,0),Ea=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),d4="arraybuffer";function db(n,...l){return l.reduce((r,s)=>(n.hasOwnProperty(s)&&(r[s]=n[s]),r),{})}const h4=Ea.setTimeout,m4=Ea.clearTimeout;function _u(n,l){l.useNativeTimers?(n.setTimeoutFn=h4.bind(Ea),n.clearTimeoutFn=m4.bind(Ea)):(n.setTimeoutFn=Ea.setTimeout.bind(Ea),n.clearTimeoutFn=Ea.clearTimeout.bind(Ea))}const p4=1.33;function g4(n){return typeof n=="string"?v4(n):Math.ceil((n.byteLength||n.size)*p4)}function v4(n){let l=0,r=0;for(let s=0,c=n.length;s<c;s++)l=n.charCodeAt(s),l<128?r+=1:l<2048?r+=2:l<55296||l>=57344?r+=3:(s++,r+=4);return r}function hb(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function y4(n){let l="";for(let r in n)n.hasOwnProperty(r)&&(l.length&&(l+="&"),l+=encodeURIComponent(r)+"="+encodeURIComponent(n[r]));return l}function b4(n){let l={},r=n.split("&");for(let s=0,c=r.length;s<c;s++){let f=r[s].split("=");l[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return l}class _4 extends Error{constructor(l,r,s){super(l),this.description=r,this.context=s,this.type="TransportError"}}class fm extends sn{constructor(l){super(),this.writable=!1,_u(this,l),this.opts=l,this.query=l.query,this.socket=l.socket,this.supportsBinary=!l.forceBase64}onError(l,r,s){return super.emitReserved("error",new _4(l,r,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(l){this.readyState==="open"&&this.write(l)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(l){const r=um(l,this.socket.binaryType);this.onPacket(r)}onPacket(l){super.emitReserved("packet",l)}onClose(l){this.readyState="closed",super.emitReserved("close",l)}pause(l){}createUri(l,r={}){return l+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const l=this.opts.hostname;return l.indexOf(":")===-1?l:"["+l+"]"}_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(l){const r=y4(l);return r.length?"?"+r:""}}class A4 extends fm{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(l){this.readyState="pausing";const r=()=>{this.readyState="paused",l()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||r()})),this.writable||(s++,this.once("drain",function(){--s||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(l){const r=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};o4(l,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const l=()=>{this.write([{type:"close"}])};this.readyState==="open"?l():this.once("open",l)}write(l){this.writable=!1,s4(l,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const l=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=hb()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(l,r)}}let mb=!1;try{mb=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const C4=mb;function S4(){}class E4 extends A4{constructor(l){if(super(l),typeof location<"u"){const r=location.protocol==="https:";let s=location.port;s||(s=r?"443":"80"),this.xd=typeof location<"u"&&l.hostname!==location.hostname||s!==l.port}}doWrite(l,r){const s=this.request({method:"POST",data:l});s.on("success",r),s.on("error",(c,f)=>{this.onError("xhr post error",c,f)})}doPoll(){const l=this.request();l.on("data",this.onData.bind(this)),l.on("error",(r,s)=>{this.onError("xhr poll error",r,s)}),this.pollXhr=l}}class Za extends sn{constructor(l,r,s){super(),this.createRequest=l,_u(this,s),this._opts=s,this._method=s.method||"GET",this._uri=r,this._data=s.data!==void 0?s.data:null,this._create()}_create(){var l;const r=db(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(r);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let c in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(c)&&s.setRequestHeader(c,this._opts.extraHeaders[c])}}catch{}if(this._method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(l=this._opts.cookieJar)===null||l===void 0||l.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var c;s.readyState===3&&((c=this._opts.cookieJar)===null||c===void 0||c.parseCookies(s.getResponseHeader("set-cookie"))),s.readyState===4&&(s.status===200||s.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof s.status=="number"?s.status:0)},0))},s.send(this._data)}catch(c){this.setTimeoutFn(()=>{this._onError(c)},0);return}typeof document<"u"&&(this._index=Za.requestsCount++,Za.requests[this._index]=this)}_onError(l){this.emitReserved("error",l,this._xhr),this._cleanup(!0)}_cleanup(l){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=S4,l)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Za.requests[this._index],this._xhr=null}}_onLoad(){const l=this._xhr.responseText;l!==null&&(this.emitReserved("data",l),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Za.requestsCount=0;Za.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Rv);else if(typeof addEventListener=="function"){const n="onpagehide"in Ea?"pagehide":"unload";addEventListener(n,Rv,!1)}}function Rv(){for(let n in Za.requests)Za.requests.hasOwnProperty(n)&&Za.requests[n].abort()}const T4=(function(){const n=pb({xdomain:!1});return n&&n.responseType!==null})();class x4 extends E4{constructor(l){super(l);const r=l&&l.forceBase64;this.supportsBinary=T4&&!r}request(l={}){return Object.assign(l,{xd:this.xd},this.opts),new Za(pb,this.uri(),l)}}function pb(n){const l=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!l||C4))return new XMLHttpRequest}catch{}if(!l)try{return new Ea[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const gb=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class O4 extends fm{get name(){return"websocket"}doOpen(){const l=this.uri(),r=this.opts.protocols,s=gb?{}:db(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(l,r,s)}catch(c){return this.emitReserved("error",c)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=l=>this.onClose({description:"websocket connection closed",context:l}),this.ws.onmessage=l=>this.onData(l.data),this.ws.onerror=l=>this.onError("websocket error",l)}write(l){this.writable=!1;for(let r=0;r<l.length;r++){const s=l[r],c=r===l.length-1;cm(s,this.supportsBinary,f=>{try{this.doWrite(s,f)}catch{}c&&bu(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const l=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=hb()),this.supportsBinary||(r.b64=1),this.createUri(l,r)}}const th=Ea.WebSocket||Ea.MozWebSocket;class R4 extends O4{createSocket(l,r,s){return gb?new th(l,r,s):r?new th(l,r):new th(l)}doWrite(l,r){this.ws.send(r)}}class w4 extends fm{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(l){return this.emitReserved("error",l)}this._transport.closed.then(()=>{this.onClose()}).catch(l=>{this.onError("webtransport error",l)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(l=>{const r=u4(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=l.readable.pipeThrough(r).getReader(),c=c4();c.readable.pipeTo(l.writable),this._writer=c.writable.getWriter();const f=()=>{s.read().then(({done:m,value:h})=>{m||(this.onPacket(h),f())}).catch(m=>{})};f();const d={type:"open"};this.query.sid&&(d.data=`{"sid":"${this.query.sid}"}`),this._writer.write(d).then(()=>this.onOpen())})})}write(l){this.writable=!1;for(let r=0;r<l.length;r++){const s=l[r],c=r===l.length-1;this._writer.write(s).then(()=>{c&&bu(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var l;(l=this._transport)===null||l===void 0||l.close()}}const N4={websocket:R4,webtransport:w4,polling:x4},M4=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,D4=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Eh(n){if(n.length>8e3)throw"URI too long";const l=n,r=n.indexOf("["),s=n.indexOf("]");r!=-1&&s!=-1&&(n=n.substring(0,r)+n.substring(r,s).replace(/:/g,";")+n.substring(s,n.length));let c=M4.exec(n||""),f={},d=14;for(;d--;)f[D4[d]]=c[d]||"";return r!=-1&&s!=-1&&(f.source=l,f.host=f.host.substring(1,f.host.length-1).replace(/;/g,":"),f.authority=f.authority.replace("[","").replace("]","").replace(/;/g,":"),f.ipv6uri=!0),f.pathNames=L4(f,f.path),f.queryKey=z4(f,f.query),f}function L4(n,l){const r=/\/{2,9}/g,s=l.replace(r,"/").split("/");return(l.slice(0,1)=="/"||l.length===0)&&s.splice(0,1),l.slice(-1)=="/"&&s.splice(s.length-1,1),s}function z4(n,l){const r={};return l.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,c,f){c&&(r[c]=f)}),r}const Th=typeof addEventListener=="function"&&typeof removeEventListener=="function",Dc=[];Th&&addEventListener("offline",()=>{Dc.forEach(n=>n())},!1);class ur extends sn{constructor(l,r){if(super(),this.binaryType=d4,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,l&&typeof l=="object"&&(r=l,l=null),l){const s=Eh(l);r.hostname=s.host,r.secure=s.protocol==="https"||s.protocol==="wss",r.port=s.port,s.query&&(r.query=s.query)}else r.host&&(r.hostname=Eh(r.host).host);_u(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(s=>{const c=s.prototype.name;this.transports.push(c),this._transportsByName[c]=s}),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},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=b4(this.opts.query)),Th&&(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"})},Dc.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(l){const r=Object.assign({},this.opts.query);r.EIO=fb,r.transport=l,this.id&&(r.sid=this.id);const s=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[l]);return new this._transportsByName[l](s)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const l=this.opts.rememberUpgrade&&ur.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(l);r.open(),this.setTransport(r)}setTransport(l){this.transport&&this.transport.removeAllListeners(),this.transport=l,l.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",ur.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(l){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",l),this.emitReserved("heartbeat"),l.type){case"open":this.onHandshake(JSON.parse(l.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const r=new Error("server error");r.code=l.data,this._onError(r);break;case"message":this.emitReserved("data",l.data),this.emitReserved("message",l.data);break}}onHandshake(l){this.emitReserved("handshake",l),this.id=l.sid,this.transport.query.sid=l.sid,this._pingInterval=l.pingInterval,this._pingTimeout=l.pingTimeout,this._maxPayload=l.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const l=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+l,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},l),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const l=this._getWritablePackets();this.transport.send(l),this._prevBufferLen=l.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let s=0;s<this.writeBuffer.length;s++){const c=this.writeBuffer[s].data;if(c&&(r+=g4(c)),s>0&&r>this._maxPayload)return this.writeBuffer.slice(0,s);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const l=Date.now()>this._pingTimeoutTime;return l&&(this._pingTimeoutTime=0,bu(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),l}write(l,r,s){return this._sendPacket("message",l,r,s),this}send(l,r,s){return this._sendPacket("message",l,r,s),this}_sendPacket(l,r,s,c){if(typeof r=="function"&&(c=r,r=void 0),typeof s=="function"&&(c=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const f={type:l,data:r,options:s};this.emitReserved("packetCreate",f),this.writeBuffer.push(f),c&&this.once("flush",c),this.flush()}close(){const l=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),l()},s=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():l()}):this.upgrading?s():l()),this}_onError(l){if(ur.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",l),this._onClose("transport error",l)}_onClose(l,r){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(),Th&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=Dc.indexOf(this._offlineEventListener);s!==-1&&Dc.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",l,r),this.writeBuffer=[],this._prevBufferLen=0}}}ur.protocol=fb;class k4 extends ur{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let l=0;l<this._upgrades.length;l++)this._probe(this._upgrades[l])}_probe(l){let r=this.createTransport(l),s=!1;ur.priorWebsocketSuccess=!1;const c=()=>{s||(r.send([{type:"ping",data:"probe"}]),r.once("packet",b=>{if(!s)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;ur.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(y(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const C=new Error("probe error");C.transport=r.name,this.emitReserved("upgradeError",C)}}))};function f(){s||(s=!0,y(),r.close(),r=null)}const d=b=>{const C=new Error("probe error: "+b);C.transport=r.name,f(),this.emitReserved("upgradeError",C)};function m(){d("transport closed")}function h(){d("socket closed")}function p(b){r&&b.name!==r.name&&f()}const y=()=>{r.removeListener("open",c),r.removeListener("error",d),r.removeListener("close",m),this.off("close",h),this.off("upgrading",p)};r.once("open",c),r.once("error",d),r.once("close",m),this.once("close",h),this.once("upgrading",p),this._upgrades.indexOf("webtransport")!==-1&&l!=="webtransport"?this.setTimeoutFn(()=>{s||r.open()},200):r.open()}onHandshake(l){this._upgrades=this._filterUpgrades(l.upgrades),super.onHandshake(l)}_filterUpgrades(l){const r=[];for(let s=0;s<l.length;s++)~this.transports.indexOf(l[s])&&r.push(l[s]);return r}}let B4=class extends k4{constructor(l,r={}){const s=typeof l=="object"?l:r;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(c=>N4[c]).filter(c=>!!c)),super(l,s)}};function j4(n,l="",r){let s=n;r=r||typeof location<"u"&&location,n==null&&(n=r.protocol+"//"+r.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=r.protocol+n:n=r.host+n),/^(https?|wss?):\/\//.test(n)||(typeof r<"u"?n=r.protocol+"//"+n:n="https://"+n),s=Eh(n)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const f=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+f+":"+s.port+l,s.href=s.protocol+"://"+f+(r&&r.port===s.port?"":":"+s.port),s}const U4=typeof ArrayBuffer=="function",H4=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,vb=Object.prototype.toString,q4=typeof Blob=="function"||typeof Blob<"u"&&vb.call(Blob)==="[object BlobConstructor]",I4=typeof File=="function"||typeof File<"u"&&vb.call(File)==="[object FileConstructor]";function dm(n){return U4&&(n instanceof ArrayBuffer||H4(n))||q4&&n instanceof Blob||I4&&n instanceof File}function Lc(n,l){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let r=0,s=n.length;r<s;r++)if(Lc(n[r]))return!0;return!1}if(dm(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return Lc(n.toJSON(),!0);for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)&&Lc(n[r]))return!0;return!1}function G4(n){const l=[],r=n.data,s=n;return s.data=xh(r,l),s.attachments=l.length,{packet:s,buffers:l}}function xh(n,l){if(!n)return n;if(dm(n)){const r={_placeholder:!0,num:l.length};return l.push(n),r}else if(Array.isArray(n)){const r=new Array(n.length);for(let s=0;s<n.length;s++)r[s]=xh(n[s],l);return r}else if(typeof n=="object"&&!(n instanceof Date)){const r={};for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=xh(n[s],l));return r}return n}function V4(n,l){return n.data=Oh(n.data,l),delete n.attachments,n}function Oh(n,l){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<l.length)return l[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let r=0;r<n.length;r++)n[r]=Oh(n[r],l);else if(typeof n=="object")for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=Oh(n[r],l));return n}const X4=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var We;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(We||(We={}));class Y4{constructor(l){this.replacer=l}encode(l){return(l.type===We.EVENT||l.type===We.ACK)&&Lc(l)?this.encodeAsBinary({type:l.type===We.EVENT?We.BINARY_EVENT:We.BINARY_ACK,nsp:l.nsp,data:l.data,id:l.id}):[this.encodeAsString(l)]}encodeAsString(l){let r=""+l.type;return(l.type===We.BINARY_EVENT||l.type===We.BINARY_ACK)&&(r+=l.attachments+"-"),l.nsp&&l.nsp!=="/"&&(r+=l.nsp+","),l.id!=null&&(r+=l.id),l.data!=null&&(r+=JSON.stringify(l.data,this.replacer)),r}encodeAsBinary(l){const r=G4(l),s=this.encodeAsString(r.packet),c=r.buffers;return c.unshift(s),c}}class hm extends sn{constructor(l){super(),this.reviver=l}add(l){let r;if(typeof l=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(l);const s=r.type===We.BINARY_EVENT;s||r.type===We.BINARY_ACK?(r.type=s?We.EVENT:We.ACK,this.reconstructor=new K4(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(dm(l)||l.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(l),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+l)}decodeString(l){let r=0;const s={type:Number(l.charAt(0))};if(We[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===We.BINARY_EVENT||s.type===We.BINARY_ACK){const f=r+1;for(;l.charAt(++r)!=="-"&&r!=l.length;);const d=l.substring(f,r);if(d!=Number(d)||l.charAt(r)!=="-")throw new Error("Illegal attachments");s.attachments=Number(d)}if(l.charAt(r+1)==="/"){const f=r+1;for(;++r&&!(l.charAt(r)===","||r===l.length););s.nsp=l.substring(f,r)}else s.nsp="/";const c=l.charAt(r+1);if(c!==""&&Number(c)==c){const f=r+1;for(;++r;){const d=l.charAt(r);if(d==null||Number(d)!=d){--r;break}if(r===l.length)break}s.id=Number(l.substring(f,r+1))}if(l.charAt(++r)){const f=this.tryParse(l.substr(r));if(hm.isPayloadValid(s.type,f))s.data=f;else throw new Error("invalid payload")}return s}tryParse(l){try{return JSON.parse(l,this.reviver)}catch{return!1}}static isPayloadValid(l,r){switch(l){case We.CONNECT:return wv(r);case We.DISCONNECT:return r===void 0;case We.CONNECT_ERROR:return typeof r=="string"||wv(r);case We.EVENT:case We.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&X4.indexOf(r[0])===-1);case We.ACK:case We.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class K4{constructor(l){this.packet=l,this.buffers=[],this.reconPack=l}takeBinaryData(l){if(this.buffers.push(l),this.buffers.length===this.reconPack.attachments){const r=V4(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function wv(n){return Object.prototype.toString.call(n)==="[object Object]"}const F4=Object.freeze(Object.defineProperty({__proto__:null,Decoder:hm,Encoder:Y4,get PacketType(){return We}},Symbol.toStringTag,{value:"Module"}));function Ba(n,l,r){return n.on(l,r),function(){n.off(l,r)}}const J4=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class yb extends sn{constructor(l,r,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=l,this.nsp=r,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const l=this.io;this.subs=[Ba(l,"open",this.onopen.bind(this)),Ba(l,"packet",this.onpacket.bind(this)),Ba(l,"error",this.onerror.bind(this)),Ba(l,"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(...l){return l.unshift("message"),this.emit.apply(this,l),this}emit(l,...r){var s,c,f;if(J4.hasOwnProperty(l))throw new Error('"'+l.toString()+'" is a reserved event name');if(r.unshift(l),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const d={type:We.EVENT,data:r};if(d.options={},d.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const y=this.ids++,b=r.pop();this._registerAckCallback(y,b),d.id=y}const m=(c=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||c===void 0?void 0:c.writable,h=this.connected&&!(!((f=this.io.engine)===null||f===void 0)&&f._hasPingExpired());return this.flags.volatile&&!m||(h?(this.notifyOutgoingListeners(d),this.packet(d)):this.sendBuffer.push(d)),this.flags={},this}_registerAckCallback(l,r){var s;const c=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(c===void 0){this.acks[l]=r;return}const f=this.io.setTimeoutFn(()=>{delete this.acks[l];for(let m=0;m<this.sendBuffer.length;m++)this.sendBuffer[m].id===l&&this.sendBuffer.splice(m,1);r.call(this,new Error("operation has timed out"))},c),d=(...m)=>{this.io.clearTimeoutFn(f),r.apply(this,m)};d.withError=!0,this.acks[l]=d}emitWithAck(l,...r){return new Promise((s,c)=>{const f=(d,m)=>d?c(d):s(m);f.withError=!0,r.push(f),this.emit(l,...r)})}_addToQueue(l){let r;typeof l[l.length-1]=="function"&&(r=l.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:l,flags:Object.assign({fromQueue:!0},this.flags)};l.push((c,...f)=>(this._queue[0],c!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(c)):(this._queue.shift(),r&&r(null,...f)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(l=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!l||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(l){l.nsp=this.nsp,this.io._packet(l)}onopen(){typeof this.auth=="function"?this.auth(l=>{this._sendConnectPacket(l)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(l){this.packet({type:We.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},l):l})}onerror(l){this.connected||this.emitReserved("connect_error",l)}onclose(l,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",l,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(l=>{if(!this.sendBuffer.some(s=>String(s.id)===l)){const s=this.acks[l];delete this.acks[l],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(l){if(l.nsp===this.nsp)switch(l.type){case We.CONNECT:l.data&&l.data.sid?this.onconnect(l.data.sid,l.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 We.EVENT:case We.BINARY_EVENT:this.onevent(l);break;case We.ACK:case We.BINARY_ACK:this.onack(l);break;case We.DISCONNECT:this.ondisconnect();break;case We.CONNECT_ERROR:this.destroy();const s=new Error(l.data.message);s.data=l.data.data,this.emitReserved("connect_error",s);break}}onevent(l){const r=l.data||[];l.id!=null&&r.push(this.ack(l.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(l){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const s of r)s.apply(this,l)}super.emit.apply(this,l),this._pid&&l.length&&typeof l[l.length-1]=="string"&&(this._lastOffset=l[l.length-1])}ack(l){const r=this;let s=!1;return function(...c){s||(s=!0,r.packet({type:We.ACK,id:l,data:c}))}}onack(l){const r=this.acks[l.id];typeof r=="function"&&(delete this.acks[l.id],r.withError&&l.data.unshift(null),r.apply(this,l.data))}onconnect(l,r){this.id=l,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(l=>this.emitEvent(l)),this.receiveBuffer=[],this.sendBuffer.forEach(l=>{this.notifyOutgoingListeners(l),this.packet(l)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(l=>l()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:We.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(l){return this.flags.compress=l,this}get volatile(){return this.flags.volatile=!0,this}timeout(l){return this.flags.timeout=l,this}onAny(l){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(l),this}prependAny(l){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(l),this}offAny(l){if(!this._anyListeners)return this;if(l){const r=this._anyListeners;for(let s=0;s<r.length;s++)if(l===r[s])return r.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(l){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(l),this}prependAnyOutgoing(l){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(l),this}offAnyOutgoing(l){if(!this._anyOutgoingListeners)return this;if(l){const r=this._anyOutgoingListeners;for(let s=0;s<r.length;s++)if(l===r[s])return r.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(l){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const s of r)s.apply(this,l.data)}}}function Ui(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}Ui.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var l=Math.random(),r=Math.floor(l*this.jitter*n);n=(Math.floor(l*10)&1)==0?n-r:n+r}return Math.min(n,this.max)|0};Ui.prototype.reset=function(){this.attempts=0};Ui.prototype.setMin=function(n){this.ms=n};Ui.prototype.setMax=function(n){this.max=n};Ui.prototype.setJitter=function(n){this.jitter=n};class Rh extends sn{constructor(l,r){var s;super(),this.nsps={},this.subs=[],l&&typeof l=="object"&&(r=l,l=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,_u(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((s=r.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new Ui({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=l;const c=r.parser||F4;this.encoder=new c.Encoder,this.decoder=new c.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(l){return arguments.length?(this._reconnection=!!l,l||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(l){return l===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=l,this)}reconnectionDelay(l){var r;return l===void 0?this._reconnectionDelay:(this._reconnectionDelay=l,(r=this.backoff)===null||r===void 0||r.setMin(l),this)}randomizationFactor(l){var r;return l===void 0?this._randomizationFactor:(this._randomizationFactor=l,(r=this.backoff)===null||r===void 0||r.setJitter(l),this)}reconnectionDelayMax(l){var r;return l===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=l,(r=this.backoff)===null||r===void 0||r.setMax(l),this)}timeout(l){return arguments.length?(this._timeout=l,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(l){if(~this._readyState.indexOf("open"))return this;this.engine=new B4(this.uri,this.opts);const r=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const c=Ba(r,"open",function(){s.onopen(),l&&l()}),f=m=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",m),l?l(m):this.maybeReconnectOnOpen()},d=Ba(r,"error",f);if(this._timeout!==!1){const m=this._timeout,h=this.setTimeoutFn(()=>{c(),f(new Error("timeout")),r.close()},m);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(c),this.subs.push(d),this}connect(l){return this.open(l)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const l=this.engine;this.subs.push(Ba(l,"ping",this.onping.bind(this)),Ba(l,"data",this.ondata.bind(this)),Ba(l,"error",this.onerror.bind(this)),Ba(l,"close",this.onclose.bind(this)),Ba(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(l){try{this.decoder.add(l)}catch(r){this.onclose("parse error",r)}}ondecoded(l){bu(()=>{this.emitReserved("packet",l)},this.setTimeoutFn)}onerror(l){this.emitReserved("error",l)}socket(l,r){let s=this.nsps[l];return s?this._autoConnect&&!s.active&&s.connect():(s=new yb(this,l,r),this.nsps[l]=s),s}_destroy(l){const r=Object.keys(this.nsps);for(const s of r)if(this.nsps[s].active)return;this._close()}_packet(l){const r=this.encoder.encode(l);for(let s=0;s<r.length;s++)this.engine.write(r[s],l.options)}cleanup(){this.subs.forEach(l=>l()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(l,r){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",l,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const l=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{l.skipReconnect||(this.emitReserved("reconnect_attempt",l.backoff.attempts),!l.skipReconnect&&l.open(c=>{c?(l._reconnecting=!1,l.reconnect(),this.emitReserved("reconnect_error",c)):l.onreconnect()}))},r);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const l=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",l)}}const Hs={};function zc(n,l){typeof n=="object"&&(l=n,n=void 0),l=l||{};const r=j4(n,l.path||"/socket.io"),s=r.source,c=r.id,f=r.path,d=Hs[c]&&f in Hs[c].nsps,m=l.forceNew||l["force new connection"]||l.multiplex===!1||d;let h;return m?h=new Rh(s,l):(Hs[c]||(Hs[c]=new Rh(s,l)),h=Hs[c]),r.query&&!l.query&&(l.query=r.queryKey),h.socket(r.path,l)}Object.assign(zc,{Manager:Rh,Socket:yb,io:zc,connect:zc});const Z4=[Iv,Gv,Uv,Hv,XA,...mS,...nC,"@@localize/SET_ACTIVE_LANGUAGE","@@localize/ADD_TRANSLATION_FOR_LANGUAGE"],W4=({dispatch:n,getState:l})=>r=>{let s=null;return c=>{const f=r(c);if(c.type===Zh){s?.disconnect(),n(vS());const m={path:`/website-messenger/${c.clientName}/socket.io`,query:c.querystrings};s=zc(m),s.on("action",n),s.on("connect",()=>n(yS())),s.on("disconnect",()=>n(bS())),s.on("reconnect",()=>n(_S())),s.on("set-translations",(h,p)=>{n(Yx({language:h,messages:Ux(h,p)}))}),s.on("set-settings",h=>{n(Jx(h))}),s.on("enable-conversation-rating",h=>n(sC(h))),s.on("speech-transcription",h=>n(lC(h))),s.on("restore-client-state",h=>{n(gS(h.sessionId)),n(cC(h.messages))}),s.on("expand-window",({devices:h,initial:p=!1})=>{n({type:Jv,devices:h,initial:p})}),s.on("restart-chat",()=>{n(Ws())}),s.on("login-success",h=>{n(iS({loginToken:h.loginToken}))})}else if(c.type==="start-screen/requestLogin")s?.emit("login-requested",c.payload);else if(c.type===fu)s?.emit("start-chat",c.payload);else if(c.type===du)s?.emit("terminate-session",c.payload);else if(c.type===tC)s?.emit("get-started",JSON.stringify(c));else if(c.type===Uh)s?.emit("audio-message",c.buffer);else if(c.type===zh)s?.emit("conversation-rating",c.payload);else if(c.type===Wv){const{connection:{sessionId:d}}=l();if(d){const m=au(),h=new URL(`/${encodeURIComponent(m)}/transcript-pdf/${encodeURIComponent(d)}`,window.location.origin);window.location.href=h.toString()}}else Z4.indexOf(c.type)===-1&&c.meta===void 0&&s&&s.emit("action",JSON.stringify(c));return f}},bb=au(),Q4={...Px(bb),intl:eb},wh=KC({middleware:n=>n().concat(W4),reducer:Wx,preloadedState:Q4});wh.subscribe(s6(()=>{const n=wh.getState();$x(bb,{connection:n.connection,startScreen:n.startScreen})},1e3));const P4=document.getElementById("root"),$4=k2.createRoot(P4);$4.render(v.jsx(zA,{store:wh,children:v.jsx(Lx,{})}));
76
+ //# sourceMappingURL=index-DR0rhLK_.js.map