@botfabrik/engine-webclient 4.104.28 → 4.104.29
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.
|
@@ -58,7 +58,7 @@ ${Ee.current.stack}
|
|
|
58
58
|
`},...z),{processed:!0,newPos:C(t,u),wasBlank:!1}}let A=M6(t,i,v,M,E,_);if(A!==null)return{processed:!0,newPos:A,wasBlank:!1};let D=e$(M,E,_,{inline:!1,list:!0});if(D.length>0){if(T&&D[0].type===W.paragraph){let z=D[0];v.push({type:W.text,text:`
|
|
59
59
|
`},...z.children),D.length>1&&v.push(...D.slice(1))}else if(!x&&D[0].type===W.paragraph&&v.length>0){let z=v[v.length-1],L=D[0];z.type===W.paragraph?z.children.push({type:W.text,text:`
|
|
60
60
|
`},...L.children):z.type===W.heading?v.push(...L.children):m9(v)?v.push(...D):v.push({type:W.text,text:" "},...L.children),D.length>1&&v.push(...D.slice(1))}else v.push(...D);return{processed:!0,newPos:C(t,u),wasBlank:!1}}if(x){let z=W$(E,!0,()=>k1(M,0,M.length,E,_));v.push({type:W.paragraph,children:z})}else K$(M,v,E,_);return{processed:!0,newPos:C(t,u),wasBlank:!1}}function o$(t,i,u,c){if(u.inline)return null;var p=u.inList;if(u.inList=!0,i>0){var g=b(t,i-1);if(g!==d&&g!==X0)return u.inList=p,null}var v=I(t,i),x=n(t,i,v);if(x.spaceEquivalent>3&&!u.inList)return u.inList=p,null;var E=t.slice(i,v),_=x.charCount,T=E.slice(_),w=C$(T);if(!w)return u.inList=p,null;var{match:R,ordered:M,listItemRegex:k}=w,A=x.spaceEquivalent,D=M?parseInt(R[1],10):void 0,z=M?R[2]:void 0,L=M?void 0:R[1],U=M?R[3]==="":R[2]==="";function V(ye,De){if(ye===0)return!0;var He=b(t,ye-1);if(He!==d)return!1;if(!De)return!0;for(var Ce=ye-2;Ce>=0;){var Ne=b(t,Ce);if(Ne!==f&&Ne!==l)break;Ce--}return Ce<0||b(t,Ce)===d}if(U&&!V(i,!0))return u.inList=p,null;if(M&&D!==1&&!V(i,!1)||!M&&IZ(R,L))return null;var Q=R.index||0,Z=M?Q+R[1].length+R[2].length+1:U?Q+R[1].length:Q+R[1].length+1,F=i+_+Z,Y=j$(t,F,v,A,Z),ne=Y.contentStartColumn,fe=A+Q+R[1].length,oe=M?fe+R[2].length+1:U?fe:fe+1,le=[],Se=[];function ve(ye,De,He){return He?ye>=De:ye>De}function _e(){return le[le.length-1]}function K(){return Se[Se.length-1]??ne}function pe(ye,De){let He=lZ(De),Ce=u.inList;u.inList=!0;let Ne=o$(t,ye,u,c);return u.inList=Ce,Ne?(He.push(Ne),Ne):null}for(var te=C(t,v),Re=te,Ae=!1;Re<t.length;){var H=I(t,Re),ie=t.slice(Re,H);if(ie.trim()===""){for(var ue=C(t,H);ue<t.length;){var be=b(t,ue);if(be!==d){if(!x6.has(t[ue]))break}ue++}var me=I(t,ue),Ee=t.slice(ue,me),Te=n(t,ue,me),ke=Ee.slice(Te.charCount);if(o1(ke,Te,M,L,z,A,k))Ae=!0;else{var Me=s$(t,ue,me,Te,ke,u,c);if(Me){for(var Ve=Me;Ve<t.length&&b(t,Ve)===d;)Ve++;if(Ve<t.length){var ft=I(t,Ve),je=t.slice(Ve,ft),vt=n(t,Ve,ft),At=je.slice(vt.charCount);o1(At,vt,M,L,z,A,k)&&(Ae=!0)}}}break}var Ue=n(t,Re,H),dt=ie.slice(Ue.charCount),un=C$(dt);if(!un)break;var _n=un.match;if(M){if(_n[2]!==z)break}else if(_n[1]!==L)break;Re=C(t,H)}var Ye=M?R[3]:R[2];Ye=Ye.trimStart();for(var Zt=i+_+(R.index||0),wt=M?Zt+R[1].length+R[2].length:Zt+R[1].length,cn=wt;cn<t.length;){var be=b(t,cn);if(be!==f&&be!==l)break;cn++}for(var Tt=0,ot=wt;ot<v;){var be=b(t,ot);if(be===l)Tt+=4-Tt%4;else if(be===f)Tt++;else break;ot++}var An=!1;if(wt<t.length&&b(t,wt)===l){for(var Xt=1,Dt=wt+1;Dt<t.length&&b(t,Dt)===l;)Xt++,Dt++;Xt>=2&&(Ye=" "+Ye,An=!0)}M||(U=U&&Tt===0),Tt>=4&&!An&&(Ye=" ".repeat(Tt-1)+Ye.trimStart()),Ye.trim();let Pt=Ae;if(!Ae&&te<t.length)for(var pn=te;pn<t.length;){var mn=I(t,pn),Yn=t.slice(pn,mn);if(W1(t,pn,mn)){for(var at=C(t,mn);at<t.length;){var gn=I(t,at);if(W1(t,at,gn))at=C(t,gn);else break}if(at<t.length){var bt=n(t,at,t.length),pt=bt.spaceEquivalent;if(pt>=A){for(var tt=t.slice(at,I(t,at)),nt=tt.slice(bt.charCount).match(k),fn=nt&&(M?nt[2]===z:nt[1]===L),yn=null,qt=te;qt<pn;qt=I(t,qt)+1){var rt=I(t,qt),Jt=n(t,qt,rt),Ct=t.slice(qt,rt).slice(Jt.charCount).match(k),Cn=Ct&&Jt.spaceEquivalent>A&&Jt.spaceEquivalent>=ne&&(M?Ct[2]===z:Ct[1]===L);if(Cn){var On=Jt.spaceEquivalent+1,mt=M?On+Ct[1].length+Ct[2].length+1:On+Ct[1].length+1,dn=qt+Jt.charCount+Ct[0].length,Kn=j$(t,dn,rt,On,mt-On);yn=Kn.contentStartColumn;break}}var wn=Tt>=5?oe:ne;!fn&&pt>=wn&&(yn===null||pt+1<yn)&&(Pt=!0)}}break}var Zn=n(t,pn,mn),Ut=Zn.spaceEquivalent,$t=Yn.slice(Zn.charCount),vn=$t.match(k),Nt=vn&&(M?vn[2]===z:vn[1]===L);if(Nt&&Ut<=A)break;pn=C(t,mn)}var Ie=Ye;if(s(Ye,"```")||s(Ye,"~~~")){var kt=M?R[1].length+R[2].length+1:R[1].length+1,tn=dZ(t,Ye,te,kt);Ie=tn.content,te=tn.endPos}var It=!U&&Ye.trim()===""&&Tt>0&&Tt<5;if(!Pt)for(var ht=Ie.length>0?Ie[0]:"",Ke=ht===">",i=te;i<t.length;){var v=I(t,i),E=t.slice(i,v);if(E.trim()==="")break;var x=n(t,i,v);if(x.spaceEquivalent<oe)break;var T=E.slice(x.charCount);if(x.spaceEquivalent<=A&&o1(T,x,M,L,z,A,k)||g$(T)&&x.spaceEquivalent>A)break;var nn=T.length>0?T[0]:"",Lt=nn===">"&&Ke;if(nn===">"&&!Lt||nn==="#"||s(T,"```")||s(T,"~~~"))break;Ie+=`
|
|
61
|
-
`+T,te=i=C(t,v)}if(le.push(iZ(Ie,Pt,u,c)),Se.push(ne),Pt&&(Tt>=5||It)){let ye=_e();te=xZ(t,ye,oe,te,A,M,L,z,k,u,c,!0)}else if(!Pt){let ye=oe-1;for(;te<t.length;){let De=I(t,te),He=t.slice(te,De),Ce=n(t,te,De),Ne=Ce.spaceEquivalent,We=He.slice(Ce.charCount);if(He.trim()===""||Ne<=A&&o1(We,Ce,M,L,z,A,k)||g$(We)&&Ne>A||Ne<ye)break;let Et=_e(),ze=V$(t,te,De,Ce,ye,ne,Et,!1,u,c,!0);if(ze.processed)te=ze.newPos;else break}}for(var Ze=!1;te<t.length;){let ye=I(t,te),De=t.slice(te,ye),He=n(t,te,ye),Ce=He.charCount,Ne=He.spaceEquivalent;if(De.trim()==="")Ae=!0,Ze=!0,te=C(t,ye);else if(Ne<A){let We=De.slice(Ce);if(We.startsWith("<")&&EZ(t,te,Ce,A,Ne,c))break;let Et=We.trim();if(Et.length>0&&le.length>0&&!u9(Et[0])&&!o1(We,He,M,L,z,A,k)){let ze=_e();if(ze.length>0){let ut=ze[ze.length-1];if(!Ze&&(ut.type===W.paragraph||ut.type===W.text)){K$(We,ze,u,c),Ze=!1,te=C(t,ye);continue}}}break}else{let We=De.slice(Ce);if(le.length>0){let Ge=Se[le.length-1]||ne;if(Ne+1>=Ge&&!o1(We,He,M,L,z,A,k)){let Ot=_e();if(Ot.length>0&&cZ(Ot,We,c)){te=C(t,ye);continue}}}if(D$(t,te))break;if(Ze){let Ge=s$(t,te,ye,He,We,u,c);if(Ge){te=Ge,Ze=!1;continue}}if(Ne<=A){if(We.startsWith("<")&&EZ(t,te,Ce,A,Ne,c))break;if(!o1(We,He,M,L,z,A,k)){if(Ne===A&&!Ze){let Ge=We.trim();if(Ge.length>0&&!u9(Ge[0])){let Ot=d9(t,te,u,c);if(Ot&&Ot.type!==W.paragraph)break;let Bt=_e();if(Bt.length>0&&!m9(Bt)){K$(We,Bt,u,c,!
|
|
61
|
+
`+T,te=i=C(t,v)}if(le.push(iZ(Ie,Pt,u,c)),Se.push(ne),Pt&&(Tt>=5||It)){let ye=_e();te=xZ(t,ye,oe,te,A,M,L,z,k,u,c,!0)}else if(!Pt){let ye=oe-1;for(;te<t.length;){let De=I(t,te),He=t.slice(te,De),Ce=n(t,te,De),Ne=Ce.spaceEquivalent,We=He.slice(Ce.charCount);if(He.trim()===""||Ne<=A&&o1(We,Ce,M,L,z,A,k)||g$(We)&&Ne>A||Ne<ye)break;let Et=_e(),ze=V$(t,te,De,Ce,ye,ne,Et,!1,u,c,!0);if(ze.processed)te=ze.newPos;else break}}for(var Ze=!1;te<t.length;){let ye=I(t,te),De=t.slice(te,ye),He=n(t,te,ye),Ce=He.charCount,Ne=He.spaceEquivalent;if(De.trim()==="")Ae=!0,Ze=!0,te=C(t,ye);else if(Ne<A){let We=De.slice(Ce);if(We.startsWith("<")&&EZ(t,te,Ce,A,Ne,c))break;let Et=We.trim();if(Et.length>0&&le.length>0&&!u9(Et[0])&&!o1(We,He,M,L,z,A,k)){let ze=_e();if(ze.length>0){let ut=ze[ze.length-1];if(!Ze&&(ut.type===W.paragraph||ut.type===W.text)){K$(We,ze,u,c),Ze=!1,te=C(t,ye);continue}}}break}else{let We=De.slice(Ce);if(le.length>0){let Ge=Se[le.length-1]||ne;if(Ne+1>=Ge&&!o1(We,He,M,L,z,A,k)){let Ot=_e();if(Ot.length>0&&cZ(Ot,We,c)){te=C(t,ye);continue}}}if(D$(t,te))break;if(Ze){let Ge=s$(t,te,ye,He,We,u,c);if(Ge){te=Ge,Ze=!1;continue}}if(Ne<=A){if(We.startsWith("<")&&EZ(t,te,Ce,A,Ne,c))break;if(!o1(We,He,M,L,z,A,k)){if(Ne===A&&!Ze){let Ge=We.trim();if(Ge.length>0&&!u9(Ge[0])){let Ot=d9(t,te,u,c);if(Ot&&Ot.type!==W.paragraph)break;let Bt=_e();if(Bt.length>0&&!m9(Bt)){K$(We,Bt,u,c,!0),Ze=!1,te=C(t,ye);continue}}}break}}if(TZ(le,U,Ze,Ye))break;let Et=C$(We),ze=Et?Et.match:null,ut=ze&&(M?ze[2]===z:ze[1]===L);if(ut&&Ne>3&&Ze)break;if(ut&&Ne<=A+3){if(Ne>=4&&Ze)break;if(Ne===A){let Ge=M?ze[3]:ze[2];if(Ge=Ge.trimStart(),te=Y$(t,le,Se,Ge,te,ye,Ne,Ce,ze,M,Ae,u,c).newCurrentPos,Ze=!1,Ge.trim()===""){let Ot=le[le.length-1],Bt=K();te=xZ(t,Ot,Bt,te,A,M,L,z,k,u,c)}continue}if(Ne>A){if(Ze){let Fe=M?ze[3]:ze[2];Fe=Fe.trimStart(),te=Y$(t,le,Se,Fe,te,ye,Ne,Ce,ze,M,Ae,u,c).newCurrentPos,Ze=!1;continue}let Ge=_e(),Ot=Ne+1,Bt=ve(Ot,K(),m9(Ge));if(Bt){let Fe=pe(te,Ge);if(Fe){te=Fe.endPos,Ze=!1;continue}}if(!Bt&&ut){let Fe=M?ze[3]:ze[2];if(Fe=Fe.trimStart(),!Ae){let bn=C(t,ye);for(;bn<t.length;){let Vt=I(t,bn),Ht=t.slice(bn,Vt),Qt=n(t,bn,Vt),Ba=Qt.spaceEquivalent;if(Ht.trim()===""){let kn=C(t,Vt);if(kn<t.length){let za=n(t,kn,t.length).spaceEquivalent,Nn=Ne+(M?ze[1].length+ze[2].length+1:ze[1].length+1);if(za+1>Nn)break}break}else if(Ba<=A){let kn=Ht.slice(Qt.charCount).match(k);if(kn&&(M?kn[2]===z:kn[1]===L)&&Ba<=A)break}bn=C(t,Vt)}}te=Y$(t,le,Se,Fe,te,ye,Ne,Ce,ze,M,Ae,u,c).newCurrentPos,Ze=!1;continue}else if(!Bt&&!ut)break;{let Fe=_e(),bn=Fe.length===0;if(bn&&TZ(le,U,Ze,Ye))break;let Vt=Fe.some(Qt=>Qt.type===W.codeBlock||Qt.type===W.paragraph||Qt.type===W.blockQuote||Qt.type===W.orderedList||Qt.type===W.unorderedList||Qt.type===W.heading),Ht=bn&&le.length===1?oe:ne;if(Vt?Ne>=Ht:Ne>Ht){let Qt=V$(t,te,ye,He,Ht,ne,_e(),Ze,u,c,void 0);if(Qt.processed){Ze=Qt.wasBlank,te=Qt.newPos;continue}}else break}}else if(Ne===A){if(!M&&ze&&IZ(ze,ze[1]))break;let Ge=M?ze[3]:ze[2];Ge=Ge.trimStart(),te=Y$(t,le,Se,Ge,te,ye,A,Ce,ze,M,Ae,u,c).newCurrentPos,Ze=!1}}else if(Ne>A){let Ge=_e();if(g$(We)){let Bt=Ne+1;if(ve(Bt,K(),m9(Ge))){let Fe=pe(te,Ge);if(Fe){te=Fe.endPos,Ze=!1;continue}}if(Ne-A>3){let Fe=Ge.length>0?Ge[Ge.length-1]:null;if(Fe&&(Fe.type===W.paragraph||Fe.type===W.text)){K$(We,Ge,u,c),Ze=!1,te=C(t,ye);continue}}else break}else{let Bt=pe(te,Ge);if(Bt){te=Bt.endPos,Ze=!1;continue}}let Ot=ne;if(m9(Ge)?Ne>=Ot-1:Ne>Ot-1){let Bt=V$(t,te,ye,He,Ot-1,ne,_e(),Ze,u,c,void 0);if(Bt.processed){Ze=Bt.wasBlank,te=Bt.newPos;continue}}else break}else break}}if(Ae&&le.length>1&&le[0].length>0&&le[0][0].type!==W.paragraph){for(var jn=1;jn<le.length;jn++)if(le[jn].length>0&&le[jn][0].type===W.paragraph){for(var Dn=!1,xe=0;xe<le[0].length;xe++){var q=le[0][xe].type;if(q===W.codeBlock||q===W.heading||q===W.blockQuote||q===W.orderedList||q===W.unorderedList||q===W.htmlBlock||q===W.breakThematic){Dn=!0;break}}Dn||(le[0]=[{type:W.paragraph,children:le[0]}]);break}}let ge=M?{type:W.orderedList,items:le,ordered:!0,start:D}:{type:W.unorderedList,items:le,ordered:!1};return u.inList=p,{...ge,endPos:te}}function aZ(t,i,u,c){if(u.inline)return null;let p=[],g=i;for(;g<t.length;){let k=I(t,g);if(W1(t,g,k))break;let A=t.slice(g,k).trim();if(!(A.indexOf("|")!==-1||p.length>=3&&A&&!u9(A[0])))break;p.push(A),g=C(t,k)}if(p.length<2)return null;let v=k=>k[0]==="|"&&k[k.length-1]==="|"?k.slice(1,-1):k,x=k=>{let A=[],D="",z=!1;for(let L=0;L<k.length;L++){let U=k[L];U==="\\"&&L+1<k.length&&k[L+1]==="|"?(D+="|",L++):U==="`"?(z=!z,D+=U):U==="|"&&!z?(A.push(D.trim()),D=""):D+=U}return A.push(D.trim()),A},E=x(v(p[0]));if(!E.length)return null;let _=x(v(p[1]));if(_.length!==E.length||_.some(k=>!/^:?-+:?$/.test(k)))return null;let T=_.map(k=>{let A=k[0]===":",D=k[k.length-1]===":";return A&&D?"center":A?"left":D?"right":null}),w=k=>W$(u,!0,()=>k.map(A=>k1(A,0,A.length,u,c))),R=w(E),M=p.slice(2).map(k=>{let A=k.indexOf("|")!==-1?x(v(k)):[k.trim()],D=E.length;for(;A.length<D;)A.push("");return A.length=D,w(A)});return{type:W.table,header:R,cells:M,align:T,endPos:g}}var l6=["div","p","section","article","aside","nav","header","footer","main","h1","h2","h3","h4","h5","h6","blockquote","ul","ol","li","dl","dt","dd","table","thead","tbody","tfoot","tr","td","th","form","fieldset","hr","pre","details","summary","figure","figcaption"],d6=new Set(["pre","script","style","textarea"]);function h9(t){return l6.indexOf(t.toLowerCase())!==-1}function A9(t){return d6.has(t)}function W1(t,i,u){for(var c=i;c<u;c++){let p=b(t,c);if(p!==f&&p!==l&&p!==X0)return!1}return!0}function W$(t,i,u){let c=t.inline;t.inline=i;try{return u()}finally{t.inline=c}}function k$(t,i,u){for(var c=i;c<u;){var p=I(t,c);if(W1(t,c,p))return c;c=C(t,p)}return u}function m$(t,i,u){return{type:W.htmlComment,text:g1(t),endPos:i,...u}}function M9(t,i,u,c,p,g,v,x,E){var _=g1(i),T=_;if(x&&x.forceBlock&&i&&!g){var w=new RegExp("^<"+t.toLowerCase()+"(\\s[^>]*)?>$","i");w.test(i.trim())&&(T="")}var R=T,M=t.toLowerCase(),k=new RegExp("^<"+M+"[\\s>]","i");if(k.test(R)){var A=R.indexOf(">");if(A!==-1){R=R.slice(A+1);var D="</"+M+">",z=R.indexOf(D);z!==-1&&(R=R.slice(0,z))}}else{var L="</"+M+">",U=R.indexOf(L);U!==-1&&(R=R.slice(0,U))}var V=[];if(R&&x){var Q=E||{inline:!1,inHTML:!0,inAnchor:!1},Z=R.trim(),F=F$.test(Z),Y=O$.test(Z),ne=H$.test(Z);if(F||Y||ne){var fe={...Q,inline:!1,inHTML:!0,inAnchor:Q.inAnchor||M==="a"};V=i9(Z,fe,x)}else if(Z){var oe={...Q,inline:!0,inAnchor:Q.inAnchor||M==="a"};V=k1(Z,0,Z.length,oe,x)}}return{type:W.htmlBlock,tag:t,attrs:c||{},rawAttrs:p,children:V,rawText:T,text:R,verbatim:!0,isClosingTag:g,canInterruptParagraph:v,endPos:u}}function p9(t){let i=O$.test(t),u=F$.test(t),c=N6.test(t);return i||u&&!c}function fZ(t,i,u,c,p,g,v,x,E,_){if(!x.inHTML&&!x.inline&&!n9(p,`
|
|
62
62
|
`)){let Te=g,ke=v.length;for(;Te<ke;){let Me=I(v,Te);if(W1(v,Te,Me))break;let Ve=v.slice(Te,Me).trim();if(Ve.length>0&&u9(Ve[0])){let ft=M$(v,Te,x,_);if(ft){Te=ft.endPos;continue}let je=n1(v,Te);if(je){Te=je.endPos;continue}return null}Te=C(v,Me)}}let T=i,w=A9(T);var R=!w&&!W9(i),M=void 0;if(p){var k=p.indexOf(">");if(k!==-1){var A=p.slice(0,k+1);A.indexOf(`
|
|
63
63
|
`)!==-1&&(M=A);for(var D=k,z=1;z<k;z++){var L=A[z];if(L===" "||L===" "||L===`
|
|
64
64
|
`||L===">"){D=z;break}}u=A.slice(D,k)}}var U=u.replace(/^[\s\n\r\t]+/,""),V=C1(U,i,t,_),Q={...V},Z=!1,F=!1;if(R&&c.length>0){var Y="</"+T,ne=c.indexOf(Y);if(ne>=0){for(var fe=ne+Y.length;fe<c.length&&(c[fe]===" "||c[fe]===" ");)fe++;if(fe<c.length&&c[fe]===">"){var oe=c.slice(0,ne);p9(oe)?(c=oe,F=!0):Z=!0}}if(!F){var le=c.length-1;if(c[le]===`
|
|
@@ -131,4 +131,4 @@ ${Ee.current.stack}
|
|
|
131
131
|
|
|
132
132
|
- La cronologia delle chat è memorizzata nell'area UE e può essere visualizzata solo da persone autorizzate.
|
|
133
133
|
- 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"},supportedLocales=["de","en","fr","it"],initialState$3={locale:"de",messages:de},mergeMessages=(t,i)=>{if(supportedLocales.includes(t)){const u=getMessagesByLanguage(t),c=flattenObject(i);return{...u,...c}}return i},getMessagesByLanguage=t=>{switch(t.toString()){case"en":return en;case"fr":return fr;case"it":return it;default:return de}},backendConnectionReducer=(t=initialState$2,i)=>{switch(i.type){case CONNECTING:return Object.assign({},t,{connectionState:ConnectionStateEnum.CONNECTING});case CONNECTED:return Object.assign({},t,{connectionState:ConnectionStateEnum.CONNECTED});case DISCONNECTED:return Object.assign({},t,{connectionState:ConnectionStateEnum.DISCONNECTED});case RECONNECTED:return Object.assign({},t,{connectionState:ConnectionStateEnum.RECONNECTED});case RESTORE_SESSION_ID:return Object.assign({},t,{sessionId:i.sessionId});case START:return Object.assign({},t,{sessionId:i.payload.sessionId,userId:i.payload.userId});case TERMINATE_SESSION:return Object.assign({},t,{sessionId:void 0});default:return t}},initialState$2={connectionState:ConnectionStateEnum.DISCONNECTED,sessionId:void 0,userId:void 0,queryString:window.location.search},chatReducer=(t=initialState$1,i)=>{switch(i.type){case RESET_CHAT_STATE:return initialState$1;case START:return sendToParentPage({type:"webclient.chat.started"}),t;case TERMINATE_SESSION:return sendToParentPage({type:"webclient.chat.ended"}),t;case TYPING_ON:return Object.assign({},t,{isBotTyping:!0});case TYPING_OFF:return Object.assign({},t,{isBotTyping:!1});case MESSAGE_FROM_GUEST:case MESSAGE_WITHOUT_ANALYSIS_FROM_GUEST:return appendMessageFromGuestToState(t,i.message);case MESSAGE_TO_GUEST:{sendToParentPage(i);const u=Object.assign({},i.message,{_id:i.meta.actionId}),c=t.messages.filter(p=>p._id===i.meta.actionId).length>0;return Object.assign({},t,{isBotTyping:!1,messages:c?t.messages:t.messages.concat([u]),quickReplies:u.quickReplies?u.quickReplies:[]})}case RESTORE_PREVIOUS_CHAT_MESSAGES:{const u=i.messages,c=u.length?u[u.length-1]:void 0;return Object.assign({},t,{isBotTyping:!1,messages:u,quickReplies:c?.quickReplies||[]})}case MESSAGE_TO_PARENT_PAGE:return sendToParentPage(i.message),t;case EVENT_TO_GUEST:return sendToParentPage(i.event),t;case DRAWER_OPEN:return Object.assign({},t,{drawerContentUrl:i.payload.parameters.contentUrl});case DRAWER_CLOSE:return Object.assign({},t,{drawerContentUrl:void 0});case GUEST_LOCALE_CHANGED:return Object.assign({},t,{locale:i.payload.locale});case EXPAND_WINDOW:return sendToParentPage(i),t;case CLOSE_WINDOW:return sendToParentPage(i),{...t,conversationRating:{...t.conversationRating,opener:void 0}};case RECEIVE_SPEECH_TRANSCRIPTION:{const u=new TextMessage$1(i.transcription,new GuestUser),c=Object.assign({},u,{_id:v4()});return appendMessageFromGuestToState(t,c)}case TRANSCRIPT_ITEM_GUEST_REACTION:{const u=t.messages.map(c=>c._id===i.payload.actionId?Object.assign({},c,i.payload.reaction?{reaction:{type:i.payload.reaction,category:i.payload.category,comment:i.payload.comment}}:{reaction:void 0}):c);return Object.assign({},t,{messages:u})}case ENABLE_CONVERSATION_RATING:{const u={enabled:!0,rating:i.payload.rating};return Object.assign({},t,{conversationRating:u})}case CONVERSATION_RATING_FROM_GUEST:{const u={...t.conversationRating,rating:i.payload};return Object.assign({},t,{conversationRating:u})}case SHOW_CONVERSATION_RATING_OVERLAY:{const u={...t.conversationRating,opener:i.payload.opener,...i.payload.defaultRating?{rating:{value:i.payload.defaultRating,feedback:t.conversationRating.rating?.feedback||""}}:{}};return Object.assign({},t,{conversationRating:u})}case HIDE_CONVERSATION_RATING_OVERLAY:{const u={...t.conversationRating,opener:void 0};return Object.assign({},t,{conversationRating:u})}case LOAD_SOURCE_INFOS_REQUEST:return{...t,sourceInfos:{type:"loading",chunkId:i.payload.chunkId}};case LOAD_SOURCE_INFOS_ERROR:{const{highlighted:u}=i.payload;return t.sourceInfos?.type==="loaded"&&u?{...t,sourceInfos:{...t.sourceInfos,highlighted:!0}}:{...t,sourceInfos:{type:"loading-error"}}}case LOAD_SOURCE_INFOS_RESPONSE:{const u=t.sourceInfos?.type,{chunkId:c,knowledgeBaseType:p,title:g,content:v,highlighted:x,url:E}=i.payload,_=t.sourceInfos?.type==="loading"||t.sourceInfos?.type==="loaded"?t.sourceInfos?.chunkId:void 0;return _&&_!==c?t:u==="loading"||u==="loaded"&&x?{...t,sourceInfos:{type:"loaded",chunkId:c,knowledgeBaseType:p,title:g,content:v,highlighted:x,url:E}}:t}case CLOSE_SOURCE_INFOS:return{...t,sourceInfos:void 0};case TOGGLE_TRANSCRIPT_MAIL_OVERLAY:return{...t,showTranscriptMailOverlay:!t.showTranscriptMailOverlay,conversationRating:{...t.conversationRating,opener:void 0}};default:return t}},appendMessageFromGuestToState=(t,i)=>{const u=t.messages[t.messages.length-1],c=u?.text===i.text;return u&&u.sender.type===i.sender.type&&c?t:Object.assign({},t,{messages:t.messages.concat([i]),quickReplies:[]})},sendToParentPage=t=>{isIframe()?window.top?.postMessage(t,"*"):t.type==="webclient.change.url"&&window.open(t.url)},isIframe=()=>typeof window<"u"&&window.self!==window.top,initialState$1={messages:[],quickReplies:[],isBotTyping:!1,showTranscriptMailOverlay:!1,conversationRating:{enabled:!1}},counterSlice=createSlice({name:"intl",initialState:initialState$3,reducers:{updateIntl:(t,i)=>{t.locale=i.payload.language,t.messages=i.payload.messages}}}),{updateIntl}=counterSlice.actions,intlReducer=counterSlice.reducer,initialState={version:void 0,requiresUserAuthentication:!1,enableStartScreen:void 0,enableStandaloneView:!1,enableTranscriptExportEmail:!1,enableTranscriptExportPdf:!1,enableGeneralConditions:!1,enableSpeechSupport:!1,commands:[],menuItems:[]},settingsSlice=createSlice({name:"settings",initialState,reducers:{setSettings(t,i){t.version&&t.version!==i.payload.version?(console.log("version changed, reloading chat window"),window.location.reload()):(t.version=i.payload.version,t.requiresUserAuthentication=i.payload.requiresUserAuthentication,t.enableStartScreen=i.payload.enableStartScreen,t.enableStandaloneView=i.payload.enableStandaloneView,t.enableTranscriptExportEmail=i.payload.enableTranscriptExportEmail,t.enableTranscriptExportPdf=i.payload.enableTranscriptExportPdf,t.enableGeneralConditions=i.payload.enableGeneralConditions,t.enableSpeechSupport=i.payload.enableSpeechSupport,t.commands=i.payload.commands,t.menuItems=i.payload.menuItems||[])}}}),{setSettings}=settingsSlice.actions,settingsSlice$1=settingsSlice.reducer,rootReducer=combineReducers({settings:settingsSlice$1,chat:chatReducer,startScreen:startScreenReducer,connection:backendConnectionReducer,intl:intlReducer}),LOCAL_STORAGE_ITEM_PREFIX="bubble-chat",LOCAL_STORAGE_LAST_SAVED_ITEM_NAME="state-last-saved-at",LOCAL_STORAGE_STATE_ITEM_NAME="state",loadState=t=>{try{if(!supportsLocalStorage())return;const i=getStoreItem(t,LOCAL_STORAGE_LAST_SAVED_ITEM_NAME);if(isExpired(i))return;{const u=getStoreItem(t,LOCAL_STORAGE_STATE_ITEM_NAME);if(u===null)return;const c=JSON.parse(u),p=c.connection?.queryString;if(p!==void 0&&!queryStringsMatchIgnoringReferrer(p,window.location.search)){console.log("Ignoring persisted state due to different query string");return}else return c}}catch(i){console.error(i);return}},saveState=(t,i)=>{try{const u=JSON.stringify(i);setStoreItem(t,LOCAL_STORAGE_STATE_ITEM_NAME,u);const c=new Date().toISOString();setStoreItem(t,LOCAL_STORAGE_LAST_SAVED_ITEM_NAME,c)}catch(u){console.error(u)}},isExpired=t=>{if(t===null)return!1;const i=new Date(t);return i.setHours(i.getHours()+12),new Date>i},supportsLocalStorage=()=>typeof localStorage<"u",getStoreItem=(t,i)=>{const u=getStoreItemName(t,i);return localStorage.getItem(u)},setStoreItem=(t,i,u)=>{const c=getStoreItemName(t,i);return localStorage.setItem(c,u)},getStoreItemName=(t,i)=>`${LOCAL_STORAGE_ITEM_PREFIX}-${t}-${i}`,queryStringsMatchIgnoringReferrer=(t,i)=>{const u=new URLSearchParams(t),c=new URLSearchParams(i);u.delete("referrer"),c.delete("referrer");const p=Array.from(u.entries()).sort(),g=Array.from(c.entries()).sort();return p.length!==g.length?!1:p.every(([v,x],E)=>{const[_,T]=g[E];return v===_&&x===T})},PACKET_TYPES=Object.create(null);PACKET_TYPES.open="0";PACKET_TYPES.close="1";PACKET_TYPES.ping="2";PACKET_TYPES.pong="3";PACKET_TYPES.message="4";PACKET_TYPES.upgrade="5";PACKET_TYPES.noop="6";const PACKET_TYPES_REVERSE=Object.create(null);Object.keys(PACKET_TYPES).forEach(t=>{PACKET_TYPES_REVERSE[PACKET_TYPES[t]]=t});const ERROR_PACKET={type:"error",data:"parser error"},withNativeBlob$1=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",withNativeArrayBuffer$2=typeof ArrayBuffer=="function",isView$1=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,encodePacket=({type:t,data:i},u,c)=>withNativeBlob$1&&i instanceof Blob?u?c(i):encodeBlobAsBase64(i,c):withNativeArrayBuffer$2&&(i instanceof ArrayBuffer||isView$1(i))?u?c(i):encodeBlobAsBase64(new Blob([i]),c):c(PACKET_TYPES[t]+(i||"")),encodeBlobAsBase64=(t,i)=>{const u=new FileReader;return u.onload=function(){const c=u.result.split(",")[1];i("b"+(c||""))},u.readAsDataURL(t)};function toArray(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let TEXT_ENCODER;function encodePacketToBinary(t,i){if(withNativeBlob$1&&t.data instanceof Blob)return t.data.arrayBuffer().then(toArray).then(i);if(withNativeArrayBuffer$2&&(t.data instanceof ArrayBuffer||isView$1(t.data)))return i(toArray(t.data));encodePacket(t,!1,u=>{TEXT_ENCODER||(TEXT_ENCODER=new TextEncoder),i(TEXT_ENCODER.encode(u))})}const chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lookup$1=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<chars.length;t++)lookup$1[chars.charCodeAt(t)]=t;const decode$1=t=>{let i=t.length*.75,u=t.length,c,p=0,g,v,x,E;t[t.length-1]==="="&&(i--,t[t.length-2]==="="&&i--);const _=new ArrayBuffer(i),T=new Uint8Array(_);for(c=0;c<u;c+=4)g=lookup$1[t.charCodeAt(c)],v=lookup$1[t.charCodeAt(c+1)],x=lookup$1[t.charCodeAt(c+2)],E=lookup$1[t.charCodeAt(c+3)],T[p++]=g<<2|v>>4,T[p++]=(v&15)<<4|x>>2,T[p++]=(x&3)<<6|E&63;return _},withNativeArrayBuffer$1=typeof ArrayBuffer=="function",decodePacket=(t,i)=>{if(typeof t!="string")return{type:"message",data:mapBinary(t,i)};const u=t.charAt(0);return u==="b"?{type:"message",data:decodeBase64Packet(t.substring(1),i)}:PACKET_TYPES_REVERSE[u]?t.length>1?{type:PACKET_TYPES_REVERSE[u],data:t.substring(1)}:{type:PACKET_TYPES_REVERSE[u]}:ERROR_PACKET},decodeBase64Packet=(t,i)=>{if(withNativeArrayBuffer$1){const u=decode$1(t);return mapBinary(u,i)}else return{base64:!0,data:t}},mapBinary=(t,i)=>i==="blob"?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer,SEPARATOR="",encodePayload=(t,i)=>{const u=t.length,c=new Array(u);let p=0;t.forEach((g,v)=>{encodePacket(g,!1,x=>{c[v]=x,++p===u&&i(c.join(SEPARATOR))})})},decodePayload=(t,i)=>{const u=t.split(SEPARATOR),c=[];for(let p=0;p<u.length;p++){const g=decodePacket(u[p],i);if(c.push(g),g.type==="error")break}return c};function createPacketEncoderStream(){return new TransformStream({transform(t,i){encodePacketToBinary(t,u=>{const c=u.length;let p;if(c<126)p=new Uint8Array(1),new DataView(p.buffer).setUint8(0,c);else if(c<65536){p=new Uint8Array(3);const g=new DataView(p.buffer);g.setUint8(0,126),g.setUint16(1,c)}else{p=new Uint8Array(9);const g=new DataView(p.buffer);g.setUint8(0,127),g.setBigUint64(1,BigInt(c))}t.data&&typeof t.data!="string"&&(p[0]|=128),i.enqueue(p),i.enqueue(u)})}})}let TEXT_DECODER;function totalLength(t){return t.reduce((i,u)=>i+u.length,0)}function concatChunks(t,i){if(t[0].length===i)return t.shift();const u=new Uint8Array(i);let c=0;for(let p=0;p<i;p++)u[p]=t[0][c++],c===t[0].length&&(t.shift(),c=0);return t.length&&c<t[0].length&&(t[0]=t[0].slice(c)),u}function createPacketDecoderStream(t,i){TEXT_DECODER||(TEXT_DECODER=new TextDecoder);const u=[];let c=0,p=-1,g=!1;return new TransformStream({transform(v,x){for(u.push(v);;){if(c===0){if(totalLength(u)<1)break;const E=concatChunks(u,1);g=(E[0]&128)===128,p=E[0]&127,p<126?c=3:p===126?c=1:c=2}else if(c===1){if(totalLength(u)<2)break;const E=concatChunks(u,2);p=new DataView(E.buffer,E.byteOffset,E.length).getUint16(0),c=3}else if(c===2){if(totalLength(u)<8)break;const E=concatChunks(u,8),_=new DataView(E.buffer,E.byteOffset,E.length),T=_.getUint32(0);if(T>Math.pow(2,21)-1){x.enqueue(ERROR_PACKET);break}p=T*Math.pow(2,32)+_.getUint32(4),c=3}else{if(totalLength(u)<p)break;const E=concatChunks(u,p);x.enqueue(decodePacket(g?E:TEXT_DECODER.decode(E),i)),c=0}if(p===0||p>t){x.enqueue(ERROR_PACKET);break}}}})}const protocol$1=4;function Emitter(t){if(t)return mixin(t)}function mixin(t){for(var i in Emitter.prototype)t[i]=Emitter.prototype[i];return t}Emitter.prototype.on=Emitter.prototype.addEventListener=function(t,i){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(i),this};Emitter.prototype.once=function(t,i){function u(){this.off(t,u),i.apply(this,arguments)}return u.fn=i,this.on(t,u),this};Emitter.prototype.off=Emitter.prototype.removeListener=Emitter.prototype.removeAllListeners=Emitter.prototype.removeEventListener=function(t,i){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var u=this._callbacks["$"+t];if(!u)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var c,p=0;p<u.length;p++)if(c=u[p],c===i||c.fn===i){u.splice(p,1);break}return u.length===0&&delete this._callbacks["$"+t],this};Emitter.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var i=new Array(arguments.length-1),u=this._callbacks["$"+t],c=1;c<arguments.length;c++)i[c-1]=arguments[c];if(u){u=u.slice(0);for(var c=0,p=u.length;c<p;++c)u[c].apply(this,i)}return this};Emitter.prototype.emitReserved=Emitter.prototype.emit;Emitter.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};Emitter.prototype.hasListeners=function(t){return!!this.listeners(t).length};const nextTick=typeof Promise=="function"&&typeof Promise.resolve=="function"?i=>Promise.resolve().then(i):(i,u)=>u(i,0),globalThisShim=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),defaultBinaryType="arraybuffer";function createCookieJar(){}function pick(t,...i){return i.reduce((u,c)=>(t.hasOwnProperty(c)&&(u[c]=t[c]),u),{})}const NATIVE_SET_TIMEOUT=globalThisShim.setTimeout,NATIVE_CLEAR_TIMEOUT=globalThisShim.clearTimeout;function installTimerFunctions(t,i){i.useNativeTimers?(t.setTimeoutFn=NATIVE_SET_TIMEOUT.bind(globalThisShim),t.clearTimeoutFn=NATIVE_CLEAR_TIMEOUT.bind(globalThisShim)):(t.setTimeoutFn=globalThisShim.setTimeout.bind(globalThisShim),t.clearTimeoutFn=globalThisShim.clearTimeout.bind(globalThisShim))}const BASE64_OVERHEAD=1.33;function byteLength(t){return typeof t=="string"?utf8Length(t):Math.ceil((t.byteLength||t.size)*BASE64_OVERHEAD)}function utf8Length(t){let i=0,u=0;for(let c=0,p=t.length;c<p;c++)i=t.charCodeAt(c),i<128?u+=1:i<2048?u+=2:i<55296||i>=57344?u+=3:(c++,u+=4);return u}function randomString(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function encode(t){let i="";for(let u in t)t.hasOwnProperty(u)&&(i.length&&(i+="&"),i+=encodeURIComponent(u)+"="+encodeURIComponent(t[u]));return i}function decode(t){let i={},u=t.split("&");for(let c=0,p=u.length;c<p;c++){let g=u[c].split("=");i[decodeURIComponent(g[0])]=decodeURIComponent(g[1])}return i}class TransportError extends Error{constructor(i,u,c){super(i),this.description=u,this.context=c,this.type="TransportError"}}class Transport extends Emitter{constructor(i){super(),this.writable=!1,installTimerFunctions(this,i),this.opts=i,this.query=i.query,this.socket=i.socket,this.supportsBinary=!i.forceBase64}onError(i,u,c){return super.emitReserved("error",new TransportError(i,u,c)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(i){this.readyState==="open"&&this.write(i)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(i){const u=decodePacket(i,this.socket.binaryType);this.onPacket(u)}onPacket(i){super.emitReserved("packet",i)}onClose(i){this.readyState="closed",super.emitReserved("close",i)}pause(i){}createUri(i,u={}){return i+"://"+this._hostname()+this._port()+this.opts.path+this._query(u)}_hostname(){const i=this.opts.hostname;return i.indexOf(":")===-1?i:"["+i+"]"}_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(i){const u=encode(i);return u.length?"?"+u:""}}class Polling extends Transport{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(i){this.readyState="pausing";const u=()=>{this.readyState="paused",i()};if(this._polling||!this.writable){let c=0;this._polling&&(c++,this.once("pollComplete",function(){--c||u()})),this.writable||(c++,this.once("drain",function(){--c||u()}))}else u()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(i){const u=c=>{if(this.readyState==="opening"&&c.type==="open"&&this.onOpen(),c.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(c)};decodePayload(i,this.socket.binaryType).forEach(u),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const i=()=>{this.write([{type:"close"}])};this.readyState==="open"?i():this.once("open",i)}write(i){this.writable=!1,encodePayload(i,u=>{this.doWrite(u,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const i=this.opts.secure?"https":"http",u=this.query||{};return this.opts.timestampRequests!==!1&&(u[this.opts.timestampParam]=randomString()),!this.supportsBinary&&!u.sid&&(u.b64=1),this.createUri(i,u)}}let value=!1;try{value=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch(t){}const hasCORS=value;function empty(){}class BaseXHR extends Polling{constructor(i){if(super(i),typeof location<"u"){const u=location.protocol==="https:";let c=location.port;c||(c=u?"443":"80"),this.xd=typeof location<"u"&&i.hostname!==location.hostname||c!==i.port}}doWrite(i,u){const c=this.request({method:"POST",data:i});c.on("success",u),c.on("error",(p,g)=>{this.onError("xhr post error",p,g)})}doPoll(){const i=this.request();i.on("data",this.onData.bind(this)),i.on("error",(u,c)=>{this.onError("xhr poll error",u,c)}),this.pollXhr=i}}class Request extends Emitter{constructor(i,u,c){super(),this.createRequest=i,installTimerFunctions(this,c),this._opts=c,this._method=c.method||"GET",this._uri=u,this._data=c.data!==void 0?c.data:null,this._create()}_create(){var i;const u=pick(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");u.xdomain=!!this._opts.xd;const c=this._xhr=this.createRequest(u);try{c.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){c.setDisableHeaderCheck&&c.setDisableHeaderCheck(!0);for(let p in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(p)&&c.setRequestHeader(p,this._opts.extraHeaders[p])}}catch{}if(this._method==="POST")try{c.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{c.setRequestHeader("Accept","*/*")}catch{}(i=this._opts.cookieJar)===null||i===void 0||i.addCookies(c),"withCredentials"in c&&(c.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(c.timeout=this._opts.requestTimeout),c.onreadystatechange=()=>{var p;c.readyState===3&&((p=this._opts.cookieJar)===null||p===void 0||p.parseCookies(c.getResponseHeader("set-cookie"))),c.readyState===4&&(c.status===200||c.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof c.status=="number"?c.status:0)},0))},c.send(this._data)}catch(p){this.setTimeoutFn(()=>{this._onError(p)},0);return}typeof document<"u"&&(this._index=Request.requestsCount++,Request.requests[this._index]=this)}_onError(i){this.emitReserved("error",i,this._xhr),this._cleanup(!0)}_cleanup(i){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=empty,i)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Request.requests[this._index],this._xhr=null}}_onLoad(){const i=this._xhr.responseText;i!==null&&(this.emitReserved("data",i),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Request.requestsCount=0;Request.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",unloadHandler);else if(typeof addEventListener=="function"){const t="onpagehide"in globalThisShim?"pagehide":"unload";addEventListener(t,unloadHandler,!1)}}function unloadHandler(){for(let t in Request.requests)Request.requests.hasOwnProperty(t)&&Request.requests[t].abort()}const hasXHR2=(function(){const t=newRequest({xdomain:!1});return t&&t.responseType!==null})();class XHR extends BaseXHR{constructor(i){super(i);const u=i&&i.forceBase64;this.supportsBinary=hasXHR2&&!u}request(i={}){return Object.assign(i,{xd:this.xd},this.opts),new Request(newRequest,this.uri(),i)}}function newRequest(t){const i=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!i||hasCORS))return new XMLHttpRequest}catch{}if(!i)try{return new globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const isReactNative=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class BaseWS extends Transport{get name(){return"websocket"}doOpen(){const i=this.uri(),u=this.opts.protocols,c=isReactNative?{}:pick(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(c.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(i,u,c)}catch(p){return this.emitReserved("error",p)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=i=>this.onClose({description:"websocket connection closed",context:i}),this.ws.onmessage=i=>this.onData(i.data),this.ws.onerror=i=>this.onError("websocket error",i)}write(i){this.writable=!1;for(let u=0;u<i.length;u++){const c=i[u],p=u===i.length-1;encodePacket(c,this.supportsBinary,g=>{try{this.doWrite(c,g)}catch{}p&&nextTick(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const i=this.opts.secure?"wss":"ws",u=this.query||{};return this.opts.timestampRequests&&(u[this.opts.timestampParam]=randomString()),this.supportsBinary||(u.b64=1),this.createUri(i,u)}}const WebSocketCtor=globalThisShim.WebSocket||globalThisShim.MozWebSocket;class WS extends BaseWS{createSocket(i,u,c){return isReactNative?new WebSocketCtor(i,u,c):u?new WebSocketCtor(i,u):new WebSocketCtor(i)}doWrite(i,u){this.ws.send(u)}}class WT extends Transport{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(i){return this.emitReserved("error",i)}this._transport.closed.then(()=>{this.onClose()}).catch(i=>{this.onError("webtransport error",i)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(i=>{const u=createPacketDecoderStream(Number.MAX_SAFE_INTEGER,this.socket.binaryType),c=i.readable.pipeThrough(u).getReader(),p=createPacketEncoderStream();p.readable.pipeTo(i.writable),this._writer=p.writable.getWriter();const g=()=>{c.read().then(({done:x,value:E})=>{x||(this.onPacket(E),g())}).catch(x=>{})};g();const v={type:"open"};this.query.sid&&(v.data=`{"sid":"${this.query.sid}"}`),this._writer.write(v).then(()=>this.onOpen())})})}write(i){this.writable=!1;for(let u=0;u<i.length;u++){const c=i[u],p=u===i.length-1;this._writer.write(c).then(()=>{p&&nextTick(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var i;(i=this._transport)===null||i===void 0||i.close()}}const transports={websocket:WS,webtransport:WT,polling:XHR},re=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,parts=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function parse(t){if(t.length>8e3)throw"URI too long";const i=t,u=t.indexOf("["),c=t.indexOf("]");u!=-1&&c!=-1&&(t=t.substring(0,u)+t.substring(u,c).replace(/:/g,";")+t.substring(c,t.length));let p=re.exec(t||""),g={},v=14;for(;v--;)g[parts[v]]=p[v]||"";return u!=-1&&c!=-1&&(g.source=i,g.host=g.host.substring(1,g.host.length-1).replace(/;/g,":"),g.authority=g.authority.replace("[","").replace("]","").replace(/;/g,":"),g.ipv6uri=!0),g.pathNames=pathNames(g,g.path),g.queryKey=queryKey(g,g.query),g}function pathNames(t,i){const u=/\/{2,9}/g,c=i.replace(u,"/").split("/");return(i.slice(0,1)=="/"||i.length===0)&&c.splice(0,1),i.slice(-1)=="/"&&c.splice(c.length-1,1),c}function queryKey(t,i){const u={};return i.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(c,p,g){p&&(u[p]=g)}),u}const withEventListeners=typeof addEventListener=="function"&&typeof removeEventListener=="function",OFFLINE_EVENT_LISTENERS=[];withEventListeners&&addEventListener("offline",()=>{OFFLINE_EVENT_LISTENERS.forEach(t=>t())},!1);class SocketWithoutUpgrade extends Emitter{constructor(i,u){if(super(),this.binaryType=defaultBinaryType,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,i&&typeof i=="object"&&(u=i,i=null),i){const c=parse(i);u.hostname=c.host,u.secure=c.protocol==="https"||c.protocol==="wss",u.port=c.port,c.query&&(u.query=c.query)}else u.host&&(u.hostname=parse(u.host).host);installTimerFunctions(this,u),this.secure=u.secure!=null?u.secure:typeof location<"u"&&location.protocol==="https:",u.hostname&&!u.port&&(u.port=this.secure?"443":"80"),this.hostname=u.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=u.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},u.transports.forEach(c=>{const p=c.prototype.name;this.transports.push(p),this._transportsByName[p]=c}),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},u),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=decode(this.opts.query)),withEventListeners&&(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"})},OFFLINE_EVENT_LISTENERS.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(i){const u=Object.assign({},this.opts.query);u.EIO=protocol$1,u.transport=i,this.id&&(u.sid=this.id);const c=Object.assign({},this.opts,{query:u,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[i]);return new this._transportsByName[i](c)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const i=this.opts.rememberUpgrade&&SocketWithoutUpgrade.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const u=this.createTransport(i);u.open(),this.setTransport(u)}setTransport(i){this.transport&&this.transport.removeAllListeners(),this.transport=i,i.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",u=>this._onClose("transport close",u))}onOpen(){this.readyState="open",SocketWithoutUpgrade.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(i){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",i),this.emitReserved("heartbeat"),i.type){case"open":this.onHandshake(JSON.parse(i.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const u=new Error("server error");u.code=i.data,this._onError(u);break;case"message":this.emitReserved("data",i.data),this.emitReserved("message",i.data);break}}onHandshake(i){this.emitReserved("handshake",i),this.id=i.sid,this.transport.query.sid=i.sid,this._pingInterval=i.pingInterval,this._pingTimeout=i.pingTimeout,this._maxPayload=i.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const i=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+i,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},i),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 i=this._getWritablePackets();this.transport.send(i),this._prevBufferLen=i.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let u=1;for(let c=0;c<this.writeBuffer.length;c++){const p=this.writeBuffer[c].data;if(p&&(u+=byteLength(p)),c>0&&u>this._maxPayload)return this.writeBuffer.slice(0,c);u+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const i=Date.now()>this._pingTimeoutTime;return i&&(this._pingTimeoutTime=0,nextTick(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),i}write(i,u,c){return this._sendPacket("message",i,u,c),this}send(i,u,c){return this._sendPacket("message",i,u,c),this}_sendPacket(i,u,c,p){if(typeof u=="function"&&(p=u,u=void 0),typeof c=="function"&&(p=c,c=null),this.readyState==="closing"||this.readyState==="closed")return;c=c||{},c.compress=c.compress!==!1;const g={type:i,data:u,options:c};this.emitReserved("packetCreate",g),this.writeBuffer.push(g),p&&this.once("flush",p),this.flush()}close(){const i=()=>{this._onClose("forced close"),this.transport.close()},u=()=>{this.off("upgrade",u),this.off("upgradeError",u),i()},c=()=>{this.once("upgrade",u),this.once("upgradeError",u)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?c():i()}):this.upgrading?c():i()),this}_onError(i){if(SocketWithoutUpgrade.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",i),this._onClose("transport error",i)}_onClose(i,u){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(),withEventListeners&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const c=OFFLINE_EVENT_LISTENERS.indexOf(this._offlineEventListener);c!==-1&&OFFLINE_EVENT_LISTENERS.splice(c,1)}this.readyState="closed",this.id=null,this.emitReserved("close",i,u),this.writeBuffer=[],this._prevBufferLen=0}}}SocketWithoutUpgrade.protocol=protocol$1;class SocketWithUpgrade extends SocketWithoutUpgrade{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let i=0;i<this._upgrades.length;i++)this._probe(this._upgrades[i])}_probe(i){let u=this.createTransport(i),c=!1;SocketWithoutUpgrade.priorWebsocketSuccess=!1;const p=()=>{c||(u.send([{type:"ping",data:"probe"}]),u.once("packet",w=>{if(!c)if(w.type==="pong"&&w.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",u),!u)return;SocketWithoutUpgrade.priorWebsocketSuccess=u.name==="websocket",this.transport.pause(()=>{c||this.readyState!=="closed"&&(T(),this.setTransport(u),u.send([{type:"upgrade"}]),this.emitReserved("upgrade",u),u=null,this.upgrading=!1,this.flush())})}else{const R=new Error("probe error");R.transport=u.name,this.emitReserved("upgradeError",R)}}))};function g(){c||(c=!0,T(),u.close(),u=null)}const v=w=>{const R=new Error("probe error: "+w);R.transport=u.name,g(),this.emitReserved("upgradeError",R)};function x(){v("transport closed")}function E(){v("socket closed")}function _(w){u&&w.name!==u.name&&g()}const T=()=>{u.removeListener("open",p),u.removeListener("error",v),u.removeListener("close",x),this.off("close",E),this.off("upgrading",_)};u.once("open",p),u.once("error",v),u.once("close",x),this.once("close",E),this.once("upgrading",_),this._upgrades.indexOf("webtransport")!==-1&&i!=="webtransport"?this.setTimeoutFn(()=>{c||u.open()},200):u.open()}onHandshake(i){this._upgrades=this._filterUpgrades(i.upgrades),super.onHandshake(i)}_filterUpgrades(i){const u=[];for(let c=0;c<i.length;c++)~this.transports.indexOf(i[c])&&u.push(i[c]);return u}}let Socket$1=class extends SocketWithUpgrade{constructor(i,u={}){const c=typeof i=="object"?i:u;(!c.transports||c.transports&&typeof c.transports[0]=="string")&&(c.transports=(c.transports||["polling","websocket","webtransport"]).map(p=>transports[p]).filter(p=>!!p)),super(i,c)}};function url(t,i="",u){let c=t;u=u||typeof location<"u"&&location,t==null&&(t=u.protocol+"//"+u.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=u.protocol+t:t=u.host+t),/^(https?|wss?):\/\//.test(t)||(typeof u<"u"?t=u.protocol+"//"+t:t="https://"+t),c=parse(t)),c.port||(/^(http|ws)$/.test(c.protocol)?c.port="80":/^(http|ws)s$/.test(c.protocol)&&(c.port="443")),c.path=c.path||"/";const g=c.host.indexOf(":")!==-1?"["+c.host+"]":c.host;return c.id=c.protocol+"://"+g+":"+c.port+i,c.href=c.protocol+"://"+g+(u&&u.port===c.port?"":":"+c.port),c}const withNativeArrayBuffer=typeof ArrayBuffer=="function",isView=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,toString=Object.prototype.toString,withNativeBlob=typeof Blob=="function"||typeof Blob<"u"&&toString.call(Blob)==="[object BlobConstructor]",withNativeFile=typeof File=="function"||typeof File<"u"&&toString.call(File)==="[object FileConstructor]";function isBinary(t){return withNativeArrayBuffer&&(t instanceof ArrayBuffer||isView(t))||withNativeBlob&&t instanceof Blob||withNativeFile&&t instanceof File}function hasBinary(t,i){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let u=0,c=t.length;u<c;u++)if(hasBinary(t[u]))return!0;return!1}if(isBinary(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return hasBinary(t.toJSON(),!0);for(const u in t)if(Object.prototype.hasOwnProperty.call(t,u)&&hasBinary(t[u]))return!0;return!1}function deconstructPacket(t){const i=[],u=t.data,c=t;return c.data=_deconstructPacket(u,i),c.attachments=i.length,{packet:c,buffers:i}}function _deconstructPacket(t,i){if(!t)return t;if(isBinary(t)){const u={_placeholder:!0,num:i.length};return i.push(t),u}else if(Array.isArray(t)){const u=new Array(t.length);for(let c=0;c<t.length;c++)u[c]=_deconstructPacket(t[c],i);return u}else if(typeof t=="object"&&!(t instanceof Date)){const u={};for(const c in t)Object.prototype.hasOwnProperty.call(t,c)&&(u[c]=_deconstructPacket(t[c],i));return u}return t}function reconstructPacket(t,i){return t.data=_reconstructPacket(t.data,i),delete t.attachments,t}function _reconstructPacket(t,i){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<i.length)return i[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let u=0;u<t.length;u++)t[u]=_reconstructPacket(t[u],i);else if(typeof t=="object")for(const u in t)Object.prototype.hasOwnProperty.call(t,u)&&(t[u]=_reconstructPacket(t[u],i));return t}const RESERVED_EVENTS$1=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],protocol=5;var PacketType;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(PacketType||(PacketType={}));class Encoder{constructor(i){this.replacer=i}encode(i){return(i.type===PacketType.EVENT||i.type===PacketType.ACK)&&hasBinary(i)?this.encodeAsBinary({type:i.type===PacketType.EVENT?PacketType.BINARY_EVENT:PacketType.BINARY_ACK,nsp:i.nsp,data:i.data,id:i.id}):[this.encodeAsString(i)]}encodeAsString(i){let u=""+i.type;return(i.type===PacketType.BINARY_EVENT||i.type===PacketType.BINARY_ACK)&&(u+=i.attachments+"-"),i.nsp&&i.nsp!=="/"&&(u+=i.nsp+","),i.id!=null&&(u+=i.id),i.data!=null&&(u+=JSON.stringify(i.data,this.replacer)),u}encodeAsBinary(i){const u=deconstructPacket(i),c=this.encodeAsString(u.packet),p=u.buffers;return p.unshift(c),p}}class Decoder extends Emitter{constructor(i){super(),this.reviver=i}add(i){let u;if(typeof i=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");u=this.decodeString(i);const c=u.type===PacketType.BINARY_EVENT;c||u.type===PacketType.BINARY_ACK?(u.type=c?PacketType.EVENT:PacketType.ACK,this.reconstructor=new BinaryReconstructor(u),u.attachments===0&&super.emitReserved("decoded",u)):super.emitReserved("decoded",u)}else if(isBinary(i)||i.base64)if(this.reconstructor)u=this.reconstructor.takeBinaryData(i),u&&(this.reconstructor=null,super.emitReserved("decoded",u));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+i)}decodeString(i){let u=0;const c={type:Number(i.charAt(0))};if(PacketType[c.type]===void 0)throw new Error("unknown packet type "+c.type);if(c.type===PacketType.BINARY_EVENT||c.type===PacketType.BINARY_ACK){const g=u+1;for(;i.charAt(++u)!=="-"&&u!=i.length;);const v=i.substring(g,u);if(v!=Number(v)||i.charAt(u)!=="-")throw new Error("Illegal attachments");c.attachments=Number(v)}if(i.charAt(u+1)==="/"){const g=u+1;for(;++u&&!(i.charAt(u)===","||u===i.length););c.nsp=i.substring(g,u)}else c.nsp="/";const p=i.charAt(u+1);if(p!==""&&Number(p)==p){const g=u+1;for(;++u;){const v=i.charAt(u);if(v==null||Number(v)!=v){--u;break}if(u===i.length)break}c.id=Number(i.substring(g,u+1))}if(i.charAt(++u)){const g=this.tryParse(i.substr(u));if(Decoder.isPayloadValid(c.type,g))c.data=g;else throw new Error("invalid payload")}return c}tryParse(i){try{return JSON.parse(i,this.reviver)}catch{return!1}}static isPayloadValid(i,u){switch(i){case PacketType.CONNECT:return isObject(u);case PacketType.DISCONNECT:return u===void 0;case PacketType.CONNECT_ERROR:return typeof u=="string"||isObject(u);case PacketType.EVENT:case PacketType.BINARY_EVENT:return Array.isArray(u)&&(typeof u[0]=="number"||typeof u[0]=="string"&&RESERVED_EVENTS$1.indexOf(u[0])===-1);case PacketType.ACK:case PacketType.BINARY_ACK:return Array.isArray(u)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class BinaryReconstructor{constructor(i){this.packet=i,this.buffers=[],this.reconPack=i}takeBinaryData(i){if(this.buffers.push(i),this.buffers.length===this.reconPack.attachments){const u=reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),u}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function isNamespaceValid(t){return typeof t=="string"}const isInteger=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};function isAckIdValid(t){return t===void 0||isInteger(t)}function isObject(t){return Object.prototype.toString.call(t)==="[object Object]"}function isDataValid(t,i){switch(t){case PacketType.CONNECT:return i===void 0||isObject(i);case PacketType.DISCONNECT:return i===void 0;case PacketType.EVENT:return Array.isArray(i)&&(typeof i[0]=="number"||typeof i[0]=="string"&&RESERVED_EVENTS$1.indexOf(i[0])===-1);case PacketType.ACK:return Array.isArray(i);case PacketType.CONNECT_ERROR:return typeof i=="string"||isObject(i);default:return!1}}function isPacketValid(t){return isNamespaceValid(t.nsp)&&isAckIdValid(t.id)&&isDataValid(t.type,t.data)}const parser=Object.freeze(Object.defineProperty({__proto__:null,Decoder,Encoder,get PacketType(){return PacketType},isPacketValid,protocol},Symbol.toStringTag,{value:"Module"}));function on(t,i,u){return t.on(i,u),function(){t.off(i,u)}}const RESERVED_EVENTS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Socket extends Emitter{constructor(i,u,c){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=i,this.nsp=u,c&&c.auth&&(this.auth=c.auth),this._opts=Object.assign({},c),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const i=this.io;this.subs=[on(i,"open",this.onopen.bind(this)),on(i,"packet",this.onpacket.bind(this)),on(i,"error",this.onerror.bind(this)),on(i,"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(...i){return i.unshift("message"),this.emit.apply(this,i),this}emit(i,...u){var c,p,g;if(RESERVED_EVENTS.hasOwnProperty(i))throw new Error('"'+i.toString()+'" is a reserved event name');if(u.unshift(i),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(u),this;const v={type:PacketType.EVENT,data:u};if(v.options={},v.options.compress=this.flags.compress!==!1,typeof u[u.length-1]=="function"){const T=this.ids++,w=u.pop();this._registerAckCallback(T,w),v.id=T}const x=(p=(c=this.io.engine)===null||c===void 0?void 0:c.transport)===null||p===void 0?void 0:p.writable,E=this.connected&&!(!((g=this.io.engine)===null||g===void 0)&&g._hasPingExpired());return this.flags.volatile&&!x||(E?(this.notifyOutgoingListeners(v),this.packet(v)):this.sendBuffer.push(v)),this.flags={},this}_registerAckCallback(i,u){var c;const p=(c=this.flags.timeout)!==null&&c!==void 0?c:this._opts.ackTimeout;if(p===void 0){this.acks[i]=u;return}const g=this.io.setTimeoutFn(()=>{delete this.acks[i];for(let x=0;x<this.sendBuffer.length;x++)this.sendBuffer[x].id===i&&this.sendBuffer.splice(x,1);u.call(this,new Error("operation has timed out"))},p),v=(...x)=>{this.io.clearTimeoutFn(g),u.apply(this,x)};v.withError=!0,this.acks[i]=v}emitWithAck(i,...u){return new Promise((c,p)=>{const g=(v,x)=>v?p(v):c(x);g.withError=!0,u.push(g),this.emit(i,...u)})}_addToQueue(i){let u;typeof i[i.length-1]=="function"&&(u=i.pop());const c={id:this._queueSeq++,tryCount:0,pending:!1,args:i,flags:Object.assign({fromQueue:!0},this.flags)};i.push((p,...g)=>(this._queue[0],p!==null?c.tryCount>this._opts.retries&&(this._queue.shift(),u&&u(p)):(this._queue.shift(),u&&u(null,...g)),c.pending=!1,this._drainQueue())),this._queue.push(c),this._drainQueue()}_drainQueue(i=!1){if(!this.connected||this._queue.length===0)return;const u=this._queue[0];u.pending&&!i||(u.pending=!0,u.tryCount++,this.flags=u.flags,this.emit.apply(this,u.args))}packet(i){i.nsp=this.nsp,this.io._packet(i)}onopen(){typeof this.auth=="function"?this.auth(i=>{this._sendConnectPacket(i)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(i){this.packet({type:PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},i):i})}onerror(i){this.connected||this.emitReserved("connect_error",i)}onclose(i,u){this.connected=!1,delete this.id,this.emitReserved("disconnect",i,u),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(i=>{if(!this.sendBuffer.some(c=>String(c.id)===i)){const c=this.acks[i];delete this.acks[i],c.withError&&c.call(this,new Error("socket has been disconnected"))}})}onpacket(i){if(i.nsp===this.nsp)switch(i.type){case PacketType.CONNECT:i.data&&i.data.sid?this.onconnect(i.data.sid,i.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 PacketType.EVENT:case PacketType.BINARY_EVENT:this.onevent(i);break;case PacketType.ACK:case PacketType.BINARY_ACK:this.onack(i);break;case PacketType.DISCONNECT:this.ondisconnect();break;case PacketType.CONNECT_ERROR:this.destroy();const c=new Error(i.data.message);c.data=i.data.data,this.emitReserved("connect_error",c);break}}onevent(i){const u=i.data||[];i.id!=null&&u.push(this.ack(i.id)),this.connected?this.emitEvent(u):this.receiveBuffer.push(Object.freeze(u))}emitEvent(i){if(this._anyListeners&&this._anyListeners.length){const u=this._anyListeners.slice();for(const c of u)c.apply(this,i)}super.emit.apply(this,i),this._pid&&i.length&&typeof i[i.length-1]=="string"&&(this._lastOffset=i[i.length-1])}ack(i){const u=this;let c=!1;return function(...p){c||(c=!0,u.packet({type:PacketType.ACK,id:i,data:p}))}}onack(i){const u=this.acks[i.id];typeof u=="function"&&(delete this.acks[i.id],u.withError&&i.data.unshift(null),u.apply(this,i.data))}onconnect(i,u){this.id=i,this.recovered=u&&this._pid===u,this._pid=u,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(i=>this.emitEvent(i)),this.receiveBuffer=[],this.sendBuffer.forEach(i=>{this.notifyOutgoingListeners(i),this.packet(i)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(i=>i()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:PacketType.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(i){return this.flags.compress=i,this}get volatile(){return this.flags.volatile=!0,this}timeout(i){return this.flags.timeout=i,this}onAny(i){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(i),this}prependAny(i){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(i),this}offAny(i){if(!this._anyListeners)return this;if(i){const u=this._anyListeners;for(let c=0;c<u.length;c++)if(i===u[c])return u.splice(c,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(i){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(i),this}prependAnyOutgoing(i){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(i),this}offAnyOutgoing(i){if(!this._anyOutgoingListeners)return this;if(i){const u=this._anyOutgoingListeners;for(let c=0;c<u.length;c++)if(i===u[c])return u.splice(c,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(i){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const u=this._anyOutgoingListeners.slice();for(const c of u)c.apply(this,i.data)}}}function Backoff(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}Backoff.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var i=Math.random(),u=Math.floor(i*this.jitter*t);t=(Math.floor(i*10)&1)==0?t-u:t+u}return Math.min(t,this.max)|0};Backoff.prototype.reset=function(){this.attempts=0};Backoff.prototype.setMin=function(t){this.ms=t};Backoff.prototype.setMax=function(t){this.max=t};Backoff.prototype.setJitter=function(t){this.jitter=t};class Manager extends Emitter{constructor(i,u){var c;super(),this.nsps={},this.subs=[],i&&typeof i=="object"&&(u=i,i=void 0),u=u||{},u.path=u.path||"/socket.io",this.opts=u,installTimerFunctions(this,u),this.reconnection(u.reconnection!==!1),this.reconnectionAttempts(u.reconnectionAttempts||1/0),this.reconnectionDelay(u.reconnectionDelay||1e3),this.reconnectionDelayMax(u.reconnectionDelayMax||5e3),this.randomizationFactor((c=u.randomizationFactor)!==null&&c!==void 0?c:.5),this.backoff=new Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(u.timeout==null?2e4:u.timeout),this._readyState="closed",this.uri=i;const p=u.parser||parser;this.encoder=new p.Encoder,this.decoder=new p.Decoder,this._autoConnect=u.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(i){return arguments.length?(this._reconnection=!!i,i||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(i){return i===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=i,this)}reconnectionDelay(i){var u;return i===void 0?this._reconnectionDelay:(this._reconnectionDelay=i,(u=this.backoff)===null||u===void 0||u.setMin(i),this)}randomizationFactor(i){var u;return i===void 0?this._randomizationFactor:(this._randomizationFactor=i,(u=this.backoff)===null||u===void 0||u.setJitter(i),this)}reconnectionDelayMax(i){var u;return i===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=i,(u=this.backoff)===null||u===void 0||u.setMax(i),this)}timeout(i){return arguments.length?(this._timeout=i,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(i){if(~this._readyState.indexOf("open"))return this;this.engine=new Socket$1(this.uri,this.opts);const u=this.engine,c=this;this._readyState="opening",this.skipReconnect=!1;const p=on(u,"open",function(){c.onopen(),i&&i()}),g=x=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",x),i?i(x):this.maybeReconnectOnOpen()},v=on(u,"error",g);if(this._timeout!==!1){const x=this._timeout,E=this.setTimeoutFn(()=>{p(),g(new Error("timeout")),u.close()},x);this.opts.autoUnref&&E.unref(),this.subs.push(()=>{this.clearTimeoutFn(E)})}return this.subs.push(p),this.subs.push(v),this}connect(i){return this.open(i)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const i=this.engine;this.subs.push(on(i,"ping",this.onping.bind(this)),on(i,"data",this.ondata.bind(this)),on(i,"error",this.onerror.bind(this)),on(i,"close",this.onclose.bind(this)),on(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(i){try{this.decoder.add(i)}catch(u){this.onclose("parse error",u)}}ondecoded(i){nextTick(()=>{this.emitReserved("packet",i)},this.setTimeoutFn)}onerror(i){this.emitReserved("error",i)}socket(i,u){let c=this.nsps[i];return c?this._autoConnect&&!c.active&&c.connect():(c=new Socket(this,i,u),this.nsps[i]=c),c}_destroy(i){const u=Object.keys(this.nsps);for(const c of u)if(this.nsps[c].active)return;this._close()}_packet(i){const u=this.encoder.encode(i);for(let c=0;c<u.length;c++)this.engine.write(u[c],i.options)}cleanup(){this.subs.forEach(i=>i()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(i,u){var c;this.cleanup(),(c=this.engine)===null||c===void 0||c.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",i,u),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const i=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const u=this.backoff.duration();this._reconnecting=!0;const c=this.setTimeoutFn(()=>{i.skipReconnect||(this.emitReserved("reconnect_attempt",i.backoff.attempts),!i.skipReconnect&&i.open(p=>{p?(i._reconnecting=!1,i.reconnect(),this.emitReserved("reconnect_error",p)):i.onreconnect()}))},u);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}}onreconnect(){const i=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",i)}}const cache={};function lookup(t,i){typeof t=="object"&&(i=t,t=void 0),i=i||{};const u=url(t,i.path||"/socket.io"),c=u.source,p=u.id,g=u.path,v=cache[p]&&g in cache[p].nsps,x=i.forceNew||i["force new connection"]||i.multiplex===!1||v;let E;return x?E=new Manager(c,i):(cache[p]||(cache[p]=new Manager(c,i)),E=cache[p]),u.query&&!i.query&&(i.query=u.queryKey),E.socket(u.path,i)}Object.assign(lookup,{Manager,Socket,io:lookup,connect:lookup});const blacklist=[MESSAGE_TO_GUEST,EVENT_TO_GUEST,TYPING_ON,TYPING_OFF,RESTART_CHAT_REQUEST,...INTERNAL_ACTIONS,...INTERNAL_ACTIONS$1,"@@localize/SET_ACTIVE_LANGUAGE","@@localize/ADD_TRANSLATION_FOR_LANGUAGE"],socketMiddleware=({dispatch:t,getState:i})=>u=>{let c=null;return p=>{const g=u(p);if(p.type===CONNECT){c?.disconnect(),t(connecting());const v=`/chat?${new URLSearchParams(p.querystrings).toString()}`;c=lookup(`/${p.clientName}${v}`),c.on("action",t),c.on("connect",()=>t(connected())),c.on("disconnect",()=>t(disconnected())),c.on("reconnect",()=>t(reconnected())),c.on("set-translations",(x,E)=>{t(updateIntl({language:x,messages:mergeMessages(x,E)}))}),c.on("set-settings",x=>{t(setSettings(x))}),c.on("enable-conversation-rating",x=>t(enableConversationRating(x))),c.on("speech-transcription",x=>t(receiveSpeechTranscription(x))),c.on("restore-client-state",x=>{t(restoreSessionId(x.sessionId)),t(restorePreviousChatMessages(x.messages))}),c.on("expand-window",({devices:x,initial:E=!1})=>{t({type:EXPAND_WINDOW,devices:x,initial:E})}),c.on("restart-chat",()=>{t(restartChat())}),c.on("login-success",x=>{t(startAuthenticatedChat({loginToken:x.loginToken}))})}else if(p.type==="start-screen/requestLogin")c?.emit("login-requested",p.payload);else if(p.type===START)c?.emit("start-chat",p.payload);else if(p.type===TERMINATE_SESSION)c?.emit("terminate-session",p.payload);else if(p.type===GET_STARTED)c?.emit("get-started",JSON.stringify(p));else if(p.type===AUDIO_MESSAGE_FROM_USER)c?.emit("audio-message",p.buffer);else if(p.type===CONVERSATION_RATING_FROM_GUEST)c?.emit("conversation-rating",p.payload);else if(p.type===DOWNLOAD_TRANSCRIPT_PDF){const{connection:{sessionId:v}}=i();window.location.href=`/transcript-pdf/${v}`}else blacklist.indexOf(p.type)===-1&&p.meta===void 0&&c&&c.emit("action",JSON.stringify(p));return g}},clientName=getClientName(),preloadedState={...loadState(clientName),intl:initialState$3},store=configureStore({middleware:t=>t().concat(socketMiddleware),reducer:rootReducer,preloadedState});store.subscribe(throttle(()=>{const t=store.getState();saveState(clientName,{connection:t.connection,startScreen:t.startScreen})},1e3));const container=document.getElementById("root"),root=clientExports.createRoot(container);root.render(jsxRuntimeExports.jsx(Provider_default,{store,children:jsxRuntimeExports.jsx(App,{})}));
|
|
134
|
-
//# sourceMappingURL=index-
|
|
134
|
+
//# sourceMappingURL=index-CyH54x-W.js.map
|