PageSourceSearch

https://app.stammer.ai/static/react/2787.38983e265d2059d6fce9.js

js stammer.ai collected 2026-09-28 10:05:22 UTC 96,222 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkStammer_ai=self.webpackChunkStammer_ai||[]).push([[2787],{22113:function(e,t,n){var o=n(38246),r=n.n(o),i=n(21879),a=n.n(i)()(r());a.push([e.id,"#message-input::-webkit-scrollbar {\n  display: none;\n}\n\np#character-count {\n  margin: 5px 10px 0px 0px;\n  text-align: right;\n  font-size: 12px;\n}\n",""]),t.A=a},33361:function(e,t,n){n.d(t,{q:function(){return ot},A:function(){return rt}});var o=n(78685),r=n(74294),i=n(31547),a=n(45043),l=n(10838),s=n(70559),c=n(34994),u=n(14428),d=n(26400),f=n(53630),g=n(2057),m=n(95614),h=n(49994),p=function(e){var t=e.widgetConfigurations,n=e.sourcePlatform,r=e.readOnly,a=void 0!==r&&r,l=e.previewOnly,s=void 0!==l&&l,c=e.allowClose,u=void 0!==c&&c;return(0,o.jsx)(i.A,{width:"100%",height:"100%",children:(0,o.jsx)(ot,{allowClose:u,sourcePlatform:n,readOnly:a,previewOnly:s,embedType:window.embedType||"inline",widgetConfigurations:t})})},v=function(e){var t,n,r=e.children,a=e.widgetPosition,l=e.previewOnly;return void 0!==l&&l?(0,o.jsx)(i.A,{position:"relative",height:"100%",children:(0,o.jsx)(i.A,{position:"absolute",sx:(t={},t[a]=0,t.bottom=0,t.top=0,t.display="flex",t.flexDirection="column",t.justifyContent="flex-end",t),children:r})}):(0,o.jsx)(i.A,{position:"fixed",sx:(n={bottom:0},n[a]=0,n),children:r})},b=g.memo((function(e){var t=e.previewOnly,n=void 0!==t&&t,a=e.widgetConfigurations,l=e.sourcePlatform,s=e.readOnly,c=void 0!==s&&s,u=(0,g.useState)(!1),d=u[0],f=u[1],b=(0,r.A)("(max-width: 500px)"),x=(0,g.useState)([]),S=x[0],w=x[1],y=(0,g.useMemo)((function(){var e;return(null===(e=h.I$.find((function(e){return e.value===a.fontFamily})))||void 0===e?void 0:e.label)||"System UI"}),[a.fontFamily]),C=(0,g.useMemo)((function(){return a.widgetPosition}),[a.widgetPosition]),A=(0,g.useCallback)((function(){f((function(e){return!e}))}),[]);return(0,g.useEffect)((function(){a&&(n||(b?a.mobilePopupType===h.WZ.CHATWIDGET_POPUP&&setTimeout((function(){f(!0)}),1e3*a.mobileChatwidgetPopupDelay):a.popupType===h.WZ.CHATWIDGET_POPUP&&setTimeout((function(){f(!0)}),1e3*a.chatwidgetPopupDelay))),b?setTimeout((function(){w(a.mobileInitialMessages||[])}),1e3*a.mobileInitialMessagePopupDelay):setTimeout((function(){w(a.initialMessages||[])}),1e3*a.initialMessagePopupDelay)}),[a,b,n]),(0,o.jsx)(o.Fragment,{children:n?(0,o.jsx)(v,{widgetPosition:a.widgetPosition,previewOnly:n,children:d?(0,o.jsx)(ot,{readOnly:c,sourcePlatform:l,widgetConfigurations:a,embedType:window.embedType||"bubble",allowClose:!0,setIsOpen:f,previewOnly:n}):(0,o.jsxs)(i.A,{margin:"20px",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"left"===C?"flex-start":"flex-end",gap:1,children:[S.map((function(e){return(0,o.jsx)("span",{role:"status","aria-live":"polite","aria-label":"Initial message: ".concat(e),style:{padding:"12px",display:"block",borderRadius:"10px",boxShadow:"0 0 6px 0 rgba(0, 0, 0, 0.1)",backgroundColor:a.aiMessageBgColor,fontSize:a.fontSize,color:a.aiMsgTextColor,fontFamily:y},dangerouslySetInnerHTML:{__html:e}},e)})),(0,o.jsx)(i.A,{id:"chatIcon",className:"chat-bubble","aria-label":d?"Close chat widget":"Open chat widget",sx:{width:"56px",height:"56px",borderRadius:"50%",display:"flex",justifyContent:"center",alignItems:"center",cursor:"pointer",boxShadow:"0 0 10px rgba(0, 0, 0, 0.2)",zIndex:999999,backgroundColor:a.chatBubbleColor,transition:"transform 0.1s ease-in","&:hover":{transform:"scale(1.1)",transition:"transform 0.1s ease-in"}},onClick:A,children:a.chatBubbleImg?(0,o.jsx)("img",{style:{width:"58px",height:"58px",borderRadius:"50%",backgroundSize:"cover",backgroundPosition:"center",verticalAlign:"middle"},src:a.chatBubbleImg,alt:""}):(0,o.jsx)(m.A,{sx:{fontSize:"25px"},htmlColor:"#fff","aria-hidden":"true"})})]})}):(0,o.jsx)(p,{readOnly:c,sourcePlatform:l,widgetConfigurations:a,previewOnly:n,allowClose:!0})})})),x=n(47838),S=n(25361),w=n(98777),y=n(91161),C=n(85355),A=n(38044),I=n(16657),T=n(78166),k=n(85072),E=n.n(k),j=n(97825),M=n.n(j),R=n(77659),_=n.n(R),D=n(55056),O=n.n(D),P=n(10540),N=n.n(P),F=n(41113),L=n.n(F),B=n(22113),U={};U.styleTagTransform=L(),U.setAttributes=O(),U.insert=_().bind(null,"head"),U.domAPI=M(),U.insertStyleElement=N();E()(B.A,U),B.A&&B.A.locals&&B.A.locals;var z=n(91251),W=n(47723),H=n(10792),q=n(19124),G=n(39675),Y=n(57559),K=n(90855),X=n(54935),V=n(32417),$=n(7098),Z=[".jpg",".jpeg",".png",".gif",".webp",".bmp",".svg"],Q=function(e){var t;if(null===(t=e.type)||void 0===t?void 0:t.startsWith("image/"))return!0;var n=e.name.toLowerCase();return Z.some((function(e){return n.endsWith(e)}))},J=function(e){return(null==e?void 0:e.length)?e.filter(Q):[]},ee=function(e){var t,n,r,a=e.queuedItems,s=e.widgetConfigurations,u=e.fontFamily,d=e.disabled,m=void 0!==d&&d,h=e.onRemove,p=(0,I.Bd)().t,v=(0,g.useState)(!1),b=v[0],x=v[1],S=(0,g.useRef)(new Map),w=(0,g.useRef)(null),y=(0,g.useState)({}),C=y[0],A=y[1],T=a.length,k=b&&T>0,E=s.widgetInputBgColor||s.widgetBgColor||"#FFFFFF",j=s.widgetBorderColor||s.chatInputTextColor||"#D1D5DB",M=(n=s.chatInputTextColor||"#111827",r=E||"#FFFFFF",(0,$.eM)(n,r)>=3.5?n:(0,$.eM)("#111827",r)>=4.5?"#111827":"#FFFFFF");(0,g.useEffect)((function(){var e=S.current,t=new Set;a.forEach((function(n){var o,r,i=(o=n.files,(r=J(o)).length?r[0]:null);
1i&&(t.add(n.id),e.has(n.id)||e.set(n.id,URL.createObjectURL(i)))})),e.forEach((function(n,o){t.has(o)||(URL.revokeObjectURL(n),e.delete(o))})),A(Object.fromEntries(e.entries()))}),[a]),(0,g.useEffect)((function(){return function(){S.current.forEach((function(e){return URL.revokeObjectURL(e)})),S.current.clear()}}),[]),(0,g.useEffect)((function(){0===T&&b&&x(!1)}),[T,b]);var R=(0,g.useCallback)((function(){x(!1)}),[]),_=(0,g.useCallback)((function(){m||0===T||x((function(e){return!e}))}),[m,T]);if((0,g.useEffect)((function(){if(b){var e=function(e){w.current&&(w.current.contains(e.target)||x(!1))};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}}),[b]),0===T)return null;var D=(null===(t=a[0])||void 0===t?void 0:t.message.trim())||"";return(0,o.jsx)(i.A,{ref:w,sx:{position:"absolute",left:0,right:0,bottom:"calc(100% + 8px)",zIndex:3},children:(0,o.jsxs)(i.A,{sx:{px:1.25,py:.75,borderRadius:"12px",border:"1px solid ".concat((0,$.X4)(j,.3)),backgroundColor:(0,$.X4)(E,.92),boxShadow:"0 8px 20px ".concat((0,$.X4)(j,.2)),cursor:m?"default":"pointer",pointerEvents:m?"none":"auto",transition:"all 0.2s ease","&:hover":m?void 0:{borderColor:(0,$.X4)(j,.45),backgroundColor:(0,$.X4)(E,1)},"&:focus-visible":{outline:"2px solid ".concat((0,$.X4)(M,.45)),outlineOffset:2}},children:[(0,o.jsxs)(i.A,{role:"button",tabIndex:m?-1:0,"aria-label":p("DISPLAY_STRINGS.QUEUED_MESSAGES","Queued messages"),"aria-expanded":k,"aria-haspopup":"dialog",onClick:function(){return _()},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),_()),"Escape"===e.key&&R()},display:"flex",alignItems:"center",justifyContent:"space-between",gap:1,sx:{cursor:m?"default":"pointer"},children:[(0,o.jsx)(l.A,{variant:"body2",sx:{fontFamily:u,color:M,fontWeight:700,maxWidth:"min(64vw, 260px)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:!k&&1===T&&D?D:"".concat(T," ").concat(p("DISPLAY_STRINGS.QUEUED","Queued"))}),k?(0,o.jsx)(K.A,{fontSize:"small",htmlColor:M}):(0,o.jsx)(X.A,{fontSize:"small",htmlColor:M})]}),k&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(f.A,{sx:{my:.75,borderColor:(0,$.X4)(j,.24)}}),(0,o.jsx)(V.A,{spacing:.5,sx:{maxHeight:190,overflowY:"auto",pr:.5},children:a.map((function(e){var t=e.message.trim(),n=J(e.files).length,r=C[e.id];return(0,o.jsxs)(i.A,{sx:{position:"relative",px:.25,py:.45,pr:3.5},children:[(0,o.jsx)(c.A,{size:"small","aria-label":p("DISPLAY_STRINGS.REMOVE_QUEUED_MESSAGE","Remove queued message"),disabled:!h,onClick:function(t){t.stopPropagation(),null==h||h(e.id)},sx:{position:"absolute",top:2,right:2,color:(0,$.X4)(M,.8),"&:hover":{backgroundColor:(0,$.X4)(j,.16)}},children:(0,o.jsx)(Y.A,{sx:{fontSize:14}})}),(0,o.jsxs)(V.A,{direction:"row",spacing:.7,alignItems:"center",children:[(0,o.jsx)(i.A,{sx:{width:7,height:7,borderRadius:"50%",bgcolor:(0,$.X4)(M,.68),flexShrink:0}}),r&&(0,o.jsx)(i.A,{component:"img",src:r,alt:p("DISPLAY_STRINGS.IMAGE","Image"),sx:{width:20,height:20,borderRadius:"5px",objectFit:"cover",border:"1px solid ".concat((0,$.X4)(j,.3))}}),(0,o.jsxs)(i.A,{sx:{minWidth:0,flex:1},children:[(0,o.jsx)(V.A,{direction:"row",spacing:.4,alignItems:"center",children:n>1&&(0,o.jsxs)(l.A,{variant:"caption",sx:{fontFamily:u,color:(0,$.X4)(M,.85)},children:["+",n-1]})}),t&&(0,o.jsx)(l.A,{variant:"caption",sx:{mt:.15,fontFamily:u,fontWeight:500,lineHeight:1.25,color:M,display:"-webkit-box",overflow:"hidden",textOverflow:"ellipsis",WebkitLineClamp:1,WebkitBoxOrient:"vertical",maxWidth:"min(62vw, 240px)"},children:t})]})]})]},e.id)}))})]})]})})},te=function(){return te=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},te.apply(this,arguments)},ne=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n},oe=function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}
1,re=g.forwardRef((function(e,t){var n=e.onChange,r=e.onSend,a=e.value,l=e.sendMsgButtonImage,s=e.disabled,c=e.clear,u=void 0!==c&&c,d=e.filesAllowed,f=void 0!==d&&d,m=e.voiceInputAllowed,p=void 0!==m&&m,v=e.queuedItems,b=void 0===v?[]:v,x=e.onRemoveQueuedMessage,S=e.widgetConfigurations,w=ne(e,["onChange","onSend","value","sendMsgButtonImage","disabled","clear","filesAllowed","voiceInputAllowed","queuedItems","onRemoveQueuedMessage","widgetConfigurations"]),y=(0,I.Bd)().t,C=["pdf","txt","doc","docx","csv","jpg","png","jpeg"],A=5242880,k=y("DISPLAY_STRINGS.FILE_SIZE_EXCEEDS_LIMIT",{limit:(0,q.Ar)(A)}),E=g.useRef(null),j=(0,g.useState)(""),M=j[0],R=j[1],_=(0,g.useState)(!1),D=_[0],O=_[1],P=(0,g.useState)(null),N=P[0],F=P[1],L=g.useRef(null),B=g.useRef(null),U=g.useRef(null);B.current=N,(0,g.useImperativeHandle)(t,(function(){return{focus:function(){U.current&&U.current.focus()}}}));var Y=(0,g.useMemo)((function(){var e;return(null===(e=h.I$.find((function(e){return e.value===S.fontFamily})))||void 0===e?void 0:e.label)||"System UI"}),[S.fontFamily]);g.useEffect((function(){null!=a&&R(a)}),[a]);var K=(0,g.useCallback)((function(e){var t,n=e.clipboardData.items,o=[];if(f){for(var r=0;r<n.length;r++){var i=n[r];if("file"===i.kind){var a=i.getAsFile(),l=(null===(t=null==a?void 0:a.name.split(".").at(-1))||void 0===t?void 0:t.toLowerCase())||"",s=(null==a?void 0:a.size)||0;s>A&&(0,q.Sx)("",k,"warning"),a&&C.includes(l)&&s<=A&&o.push(a)}}o.length>5&&((0,q.Sx)("",y("DISPLAY_STRINGS.MAX_FILES_EXCEEDED",{max:5,uploaded:o.length}),"warning"),o=o.slice(0,5)),o.length>0&&F((function(e){return e?oe(oe([],e,!0),o,!0):o}))}}),[f,k,y]),X=(0,g.useCallback)((function(){E.current=new(window.SpeechRecognition||window.webkitSpeechRecognition),E.current.interimResults=!1,E.current.lang="en-US",E.current.onstart=function(){O(!0)},E.current.onresult=function(e){var t=e.results[0][0].transcript;R(t)},E.current.onend=function(){O(!1)},E.current.onerror=function(e){console.error("Web Speech API error:",e.error)},E.current.start()}),[]),V=(0,g.useCallback)((function(){E.current&&E.current.stop()}),[]),$=(0,g.useCallback)((function(){D?V():X()}),[D,V,X]),Z=(0,g.useCallback)((function(e,t){return e.trim().length>0||((null==t?void 0:t.length)||0)>0}),[]),Q=Z(M,N),J=(0,g.useCallback)((function(){var e,t=M.trim(),n=null!==(e=B.current)&&void 0!==e?e:null;Z(t,n)&&(r&&r(t,n),u&&(R(""),F([])))}),[u,Z,M,r]),re=(0,g.useCallback)((function(e){for(var t=e.target.files?Array.from(e.target.files):[],n=[],o=0;o<t.length;o++){t[o].size<=A?n.push(t[o]):(0,q.Sx)("",k,"warning")}n.length>5&&((0,q.Sx)("",y("DISPLAY_STRINGS.MAX_FILES_EXCEEDED",{max:5,uploaded:n.length}),"warning"),n=n.slice(0,5)),F((function(e){return oe(oe([],e||[],!0),n,!0)}))}),[k,y]),ie=(0,g.useCallback)((function(e){R(e.target.value),n&&n(e.target.value)}),[n]),ae=(0,g.useCallback)((function(){var e;null===(e=null==L?void 0:L.current)||void 0===e||e.click()}),[]),le=(0,g.useCallback)((function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),J()),"Enter"===e.key&&e.shiftKey&&(e.preventDefault(),R((function(e){return e+"\n"})))}),[J]);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("input",{ref:L,"aria-label":"Upload files",onChange:re,hidden:!0,type:"file",multiple:!0,accept:".pdf, .csv, .txt, .doc, .docx, image/jpg, image/png, image/jpeg"}),(0,o.jsx)(T.hcB,{files:N,setFiles:F,bgColor:S.widgetBgColor,themeContext:G.fL}),(0,o.jsxs)(i.A,{sx:{position:"relative",flexShrink:0},children:[(0,o.jsx)(ee,{queuedItems:b,widgetConfigurations:S,fontFamily:Y,disabled:s,onRemove:x}),(0,o.jsx)(T.A_L,te({inputRef:U,sx:{borderRadius:"1.5rem",boxShadow:"0px 0px 6px 0px ".concat(S.widgetBorderColor,"88"),width:"100%",backgroundColor:S.widgetInputBgColor,"& textarea":{fontSize:S.fontSize,color:S.chatInputTextColor,fontFamily:Y,overflowY:"auto",maxHeight:"120px",resize:"none"},"& textarea::-webkit-scrollbar":{width:"14px"},"& textarea::-webkit-scrollbar-track":{backgroundColor:"".concat(S.widgetBorderColor,"22")},"& textarea::-webkit-scrollbar-thumb":{backgroundColor:"".concat(S.widgetBorderColor,"88"),borderRadius:"3px"},"& textarea::placeholder":{color:S.chatInputTextColor,fontSize:S.fontSize,fontFamily:Y},"& .MuiInputBase-root":{padding:"5px",paddingLeft:"20px",overflow:"visible"},"& .MuiOutlinedInput-notchedOutline":{border:"none"}},id:"message-input","aria-label":"Message input",placeholder:S.chatInputPlaceholder||y("DISPLAY_STRINGS.SEND_MESSAGE_PLACEHOLDER"),multiline:!0,minRows:1,maxRows:5,value:M,disabled:s,onChange:ie,onPaste:K,InputProps:{endAdornment:(0,o.jsxs)(o.Fragment,{children:[f&&(0,o.jsx)(T.jC1,{position:"start",children:(0,o.jsx)(T.K0,{size:"small","aria-label":"Attach file",onClick:ae,disabled:D||s,children:(0,o.jsx)(z.A,{sx:{opacity:D||s?.5:1,transform:"rotate(230deg)"},fontSize:"small",htmlColor:S.chatInputTextColor,"aria-hidden":"true"})})}),p&&(0,o.jsx)(T.jC1,{position:"start",children:(0,o.jsx)(T.K0,{size:"small","aria-label":D?"Stop voice recording":"Start voice recording","aria-pressed":D,onClick:$,disabled:s,children:D?(0,o.jsx)(T.PaH,{size:20,"aria-hidden":"true"}):(0,o.jsx)(W.A,{sx:{opacity:D||s?.5:1},htmlColor:S.chatInputTextColor,fontSize:"small","aria-hidden":"true"})})}),(0,o.jsx)(T.jC1,{position:"start",children:(0,o.jsx)(T.K0,{className:"send-message-button",disabled:!Q||D||s,size:"small","aria-label":"Send message",onClick:J,children:l?(0,o.jsx)("img",{style:{opacity:!Q||D||s?.5:1},src:l,alt:"Send message",width:20,height:20}):(0,o.jsx)(H.A,{sx:{opacity:!Q||D||s?.5:1},fontSize:"small",htmlColor:S.chatInputTextColor,"aria-hidden":"true"})})})]})},onKeyDown:le},w))]})]})}));re.displayName="WidgetMessageInput";var ie=g.memo(re),ae=n(81971),le=n(81687),se=n(10208),ce=n(96497),ue=n(83589),de=n(8081),fe=n(63402),ge=n(80114),me=n(2091),he=n(87514),pe=n(24983),ve=n(60551),be=n(21762),xe=n(38451),Se=function(e,t,n,o){return new(n||(n=Prom
1ise))((function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function l(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}s((o=o.apply(e,t||[])).next())}))},we=function(e,t){var n,o,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(n=1,o&&(r=2&l[0]?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,o=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==l[0]&&2!==l[0])){i=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){i.label=l[1];break}if(6===l[0]&&i.label<r[1]){i.label=r[1],r=l;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(l);break}r[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],o=0}finally{n=r=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},ye=function(e,t,n,o){return Se(void 0,void 0,void 0,(function(){return we(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,ve.A.post(be.n.MASTER_CHAT.TEXT_TO_SPEECH,(0,q.uc)({text:e,service:t,chatbotId:n,chatbotUuid:o}))];case 1:return[2,r.sent().data];case 2:throw r.sent(),new Error(xe.Ay.t("DISPLAY_STRINGS.TEXT_TO_SPEECH_ERROR"));case 3:return[2]}}
1))}))},Ce=n(12081),Ae=(0,g.createContext)(void 0),Ie=function(e){var t=e.children,n=(0,g.useState)(null),r=n[0],i=n[1],a=(0,g.useState)(!1),l=a[0],s=a[1];return(0,o.jsx)(Ae.Provider,{value:{currentlyPlayingIndex:r,isFetching:l,setCurrentlyPlayingIndex:i,setIsFetching:s},children:t})},Te=n(40139),ke=n(73433),Ee=n(67325),je=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function l(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}s((o=o.apply(e,t||[])).next())}))},Me=function(e,t){var n,o,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(n=1,o&&(r=2&l[0]?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,o=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==l[0]&&2!==l[0])){i=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){i.label=l[1];break}if(6===l[0]&&i.label<r[1]){i.label=r[1],r=l;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(l);break}r[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],o=0}finally{n=r=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}};function Re(e){var t,n,r=this,s=e.timestampFormat,u=e.setTimestampFormat,f=e.id,m=e.message,p=e.metadata,v=e.sender,b=e.widgetConfigurations,x=e.widgetDetails,S=e.sourcePlatform,w=e.voiceAllowed,k=e.isStreaming,E=void 0!==k&&k,j=e.isInitialMessage,M=void 0!==j&&j,R=e.isStreamingEnabled,_=void 0===R||R,D=e.isLatestLocalMessage,O=void 0!==D&&D,P=(0,I.Bd)().t,N=(0,g.useState)(h.vZ.NONE),F=N[0],L=N[1],B=(0,g.useState)(null),U=B[0],z=B[1],W=(0,g.useState)(""),H=W[0],Y=W[1],K=(0,g.useState)(!1),X=K[0],V=K[1],$=(0,g.useState)(null),Z=$[0],Q=$[1],J=(0,g.useState)(""),ee=J[0],te=J[1],ne=(0,g.useState)(null),oe=ne[0],re=ne[1],ie=(0,g.useRef)(null),ae=function(){var e=(0,g.useContext)(Ae);if(void 0===e)throw new Error(xe.Ay.t("DISPLAY_STRINGS.AUDIO_CONTEXT_ERROR"));return e}(),le=ae.currentlyPlayingIndex,ce=ae.setCurrentlyPlayingIndex,de=ae.setIsFetching,ve=(0,g.useRef)(null),be=(0,g.useRef)(0),Se=Te.A.getInstance(),we=le===f,Ce=(0,g.useState)(!1),Ie=Ce[0],Re=Ce[1];(0,g.useEffect)((function(){var e=b.enableResponseTypingSimulation,t=b.responseTypingSpeed||10;if(ve.current&&(clearTimeout(ve.current),ve.current=null),"agent"===v&&!_&&e&&!E&&m&&O){be.current=0,Y("");var n=5*(10-t+1),o=function(){if(be.current<m.length){be.current+=1,Y(m.substring(0,be.current)),ve.current=setTimeout(o,n);var e=document.getElementById("messagesContainer");e&&!E&&(e.scrollTop=e.scrollHeight)}else Y(m),ve.current=null};return o(),function(){ve.current&&(clearTimeout(ve.current),ve.current=null)}}Y(m)}),[m,v,_,E,O,b.enableResponseTypingSimulation,b.responseTypingSpeed]),(0,g.useEffect)((function(){p.reaction&&L(p.reaction)}),[p.reaction]),(0,g.useEffect)((function(){var e=ie.current;if(e){var t=e.querySelectorAll("img"),n=[];return t.forEach((function(e){var t=function(t){var n;t.preventDefault();var o=e.getAttribute("src");o&&(Q(o),te(null!==(n=e.getAttribute("alt"))&&void 0!==n?n:""),V(!0))};e.addEventListener("click",t),n.push({el:e,fn:t})})),function(){n.forEach((function(e){var t=e.el,n=e.fn;return t.removeEventListener("click",n)}))}}}),[m,H]);var _e=(0,g.useCallback)((function(e,t){(0,A._l)(e,t).then((function(e){L(t)})).catch((function(e){console.error("Error setting chat reaction:",e)}))}),[]),De=(0,g.useMemo)((function(){var e;return(null===(e=h.I$.find((function(e){return e.value===b.fontFamily})))||void 0===e?void 0:e.label)||"System UI"}),[b.fontFamily]),Oe=(0,g.useCallback)((function(e){if(we)window.speechSynthesis.cancel(),ce(null);else{ce(f);var t=(0,q.im)(e),n=t.match(/[^.!?]+[.!?]+/g)||[t],o=0,r=function(){if(o<n.length){var e=new SpeechSynthesisUtterance(n[o]);e.lang="en-US",e.rate=.9,e.volume=2,e.onend=function(){o++,r(),n.length},window.speechSynthesis.speak(e)}};r()}}),[we]),Pe=(0,g.useCallback)((function(){return je(r,void 0,void 0,(function(){var e,t,n,o;return Me(this,(function(r){switch(r.label){case 0:if(we)return[3,6];de(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,ye((0,q.im)(m),"elevenlabs",void 0,window.chatbotUUID)];case 2:return e=r.sent(),(null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.audio_base64)?(t=e.data.audio_base64,Se.playAudio(t),ce(f)):(console.error("No audio data received"),ce(null)),[3,5];
1case 3:return n=r.sent(),console.error("Error fetching audio:",n),[3,5];case 4:return de(!1),[7];case 5:return[3,7];case 6:Se.stopAudio(),ce(null),r.label=7;case 7:return[2]}}))}))}),[we,m,f,de,ce]),Ne=(0,g.useCallback)((function(){(null==x?void 0:x.isUsingElevenlabs)?Pe():Oe(m)}),[m,null==x?void 0:x.isUsingElevenlabs,Pe,Oe]),Fe=(0,g.useMemo)((function(){return b.userMsgAvatarImage||""}),[b.userMsgAvatarImage]),Le=(0,g.useMemo)((function(){return(null==b?void 0:b.useIconImageAsAvatar)?b.icon||"":b.chatAvatarImage||""}),[null==b?void 0:b.useIconImageAsAvatar,b.icon,b.chatAvatarImage]),Be=(0,g.useMemo)((function(){return"user"===v?b.userMsgTextColor:b.aiMsgTextColor}),[v,b.userMsgTextColor,b.aiMsgTextColor]),Ue=(0,g.useMemo)((function(){return"user"===v?b.userMessageBgColor:b.aiMessageBgColor}),[v,b.userMessageBgColor,b.aiMessageBgColor]),ze=(0,g.useMemo)((function(){var e;if(!(p.files&&p.files.length>0))return[];var t=[];return null===(e=p.files)||void 0===e||e.forEach((function(e){e.url?t.push({name:e.fileName,url:e.url}):e.base64&&t.push((0,q.Xz)(e.base64,e.fileName))})),t}),[p.files]),We=(0,g.useCallback)((function(){(0,q.eM)((0,q.im)(m),"Copied to clipboard")}),[m]),He=(0,g.useCallback)((function(){_e(f,h.vZ.POSITIVE)}),[f,_e]),qe=(0,g.useCallback)((function(){_e(f,h.vZ.NEGATIVE)}),[f,_e]),Ge=(0,g.useCallback)((function(e){e.currentTarget&&z(e.currentTarget)}),[]),Ye=(0,g.useCallback)((function(){z(null)}),[]),Ke=(0,g.useCallback)((function(e){e.startsWith("http")&&window.open(e,"_blank")}),[]),Xe="agent"===v&&H?H:m,Ve="agent"===v&&!E&&(!b.enableResponseTypingSimulation||H===m)&&Xe.length>600,$e=Ve&&!Ie?"".concat(Xe.slice(0,600),"..."):Xe,Ze=$e.trim().length>0;return(0,g.useEffect)((function(){Re(!1)}),[m]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(i.A,{id:"".concat(v,"-message-").concat(f),className:"message-container",role:"article","aria-label":"Message from ".concat("user"===v?"you":"agent"),sx:{display:"flex",flexDirection:"agent"===v?"row":"row-reverse",alignItems:"flex-start",marginBottom:"agent"===v?"0px":"10px",width:"100%"},children:[(null==b?void 0:b.showAvatar)&&(0,o.jsx)(i.A,{className:"message-avatar",display:"flex",alignItems:"center",gap:1,marginRight:"agent"===v?"10px":"0px",marginLeft:"agent"!==v?"10px":"0px",children:(0,o.jsx)(a.A,{className:"message-avatar-image",alt:"user"===v?"User avatar":"Agent avatar",src:"user"===v?Fe:Le,sx:{height:30,width:30,backgroundColor:"".concat(Be,"22"),"& img":{backgroundColor:"".concat(Ue,"22"),borderRadius:"50%",objectFit:"contain"}},children:(0,o.jsx)(i.A,{sx:{"& svg":{height:"16px",width:"16px"}},children:"user"===v?(0,o.jsx)(me.A,{fontSize:"small",htmlColor:Be}):(0,o.jsx)(se.A,{fontSize:"small",htmlColor:Be})})})}),(0,o.jsxs)("div",{style:{minWidth:"160px",maxWidth:"85%",borderRadius:"10px",padding:"10px",fontSize:b.fontSize,fontFamily:De,backgroundColor:Ue,color:Be},className:"message-".concat(v),children:[Ze&&(0,o.jsxs)(i.A,{dir:"auto",sx:(0,h.ph)(b),className:"message-".concat(v),children:[(0,o.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,q.hw)($e).__html}}),Ve&&(0,o.jsx)(l.A,{className:"read-more-button",component:"span",onClick:function(){return Re((function(e){return!e}))},sx:{cursor:"pointer",color:Be,fontSize:"0.8rem",fontWeight:700,"&:hover":{textDecoration:"underline",opacity:.8}},children:Ie?P("DISPLAY_STRINGS.SHOW_LESS","Show less"):P("DISPLAY_STRINGS.READ_MORE","Read more")})]}),!!ze.length&&(0,o.jsx)(i.A,{sx:{marginTop:1.5,marginBottom:.5},children:(0,o.jsx)(T.hcB,{files:ze,readOnly:!0,themeContext:G.fL,bgColor:Ue,align:"left",ignoreSpacing:!0,onImageClick:function(e,t){Q(e),te(null!=t?t:""),V(!0)},onFilePreview:function(e,t){return re({file:e,mimeType:t})}})}),b.showTimestamp&&(0,o.jsxs)(l.A,{variant:"caption",fontFamily:De,textAlign:"right",color:Be,onClick:function(){return u("relative"===s?"absolute":"relative")},sx:{cursor:"pointer"},"aria-label":"relative"===s?"Show absolute timestamp":"Show relative timestamp",children:[!(!b.enableTrace||S!==Ee.NR.DASHBOARD||!(null==p?void 0:p.promptTokens)||"agent"!==v)&&(0,o.jsxs)(o.Fragment,{children:[p.promptTokens.toLocaleStr
1ing()," tokens • "]}),"relative"===s?(0,q.g5)(p.createdAt):(0,q.r6)(p.createdAt,"MMM D, YYYY, h:mm:ss a")]})]})]}),"agent"===v&&!!p.dataSourceInfo&&b.showDataSources&&(0,o.jsxs)(i.A,{marginLeft:(null==b?void 0:b.showAvatar)?"45px":"0px",children:[(0,o.jsx)(i.A,{display:"flex",gap:1,children:(0,o.jsx)(d.A,{className:"answer-sources-button","aria-label":U?"Hide answer sources":"Show answer sources","aria-expanded":!!U,sx:{padding:"0px",fontSize:"0.75rem",color:Be},variant:"text",size:"small",endIcon:U?(0,o.jsx)(ke.Oe,{fontSize:"small",htmlColor:Be}):(0,o.jsx)(ge.A,{fontSize:"small",htmlColor:Be}),onClick:Ge,children:"Answer Sources"})}),(0,o.jsx)(ue.Ay,{open:!!U,anchorEl:U,onClose:Ye,role:"dialog","aria-label":"Answer sources",anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{className:"answer-sources-popover",sx:{"& a":{color:b.hyperlinkColor},padding:"auto 10px",width:"250px",backgroundColor:Ue,color:Be,border:"1px solid ".concat(Be,"20"),overflowX:"auto",borderRadius:"8px"}},children:(0,o.jsx)(i.A,{padding:"5px 10px",children:null===(t=p.dataSourceInfo)||void 0===t?void 0:t.split("\n").map((function(e,t){return(0,o.jsx)("a",{style:{width:"100%",fontSize:"0.75rem",display:"block",marginBottom:"3px"},href:e,onClick:function(t){t.preventDefault(),Ke(e)},children:e},t)}))})})]}),"agent"===v&&!E&&(_||!b.enableResponseTypingSimulation||H===m)&&(0,o.jsx)(i.A,{sx:{marginBottom:"6px",marginLeft:(null==b?void 0:b.showAvatar)?"45px":"0px"},children:(0,o.jsxs)(i.A,{display:"flex",className:"message-action-buttons",children:[b.enableActions&&!M&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(c.A,{className:"action-button",size:"x-small","aria-label":"Copy message to clipboard",onClick:We,children:(0,o.jsx)(fe.A,{htmlColor:Be,sx:{fontSize:"0.9rem !important"},"aria-hidden":"true"})}),(0,o.jsx)(c.A,{className:"action-button",size:"x-small","aria-label":F===h.vZ.POSITIVE?"Remove positive reaction":"Add positive reaction","aria-pressed":F===h.vZ.POSITIVE,onClick:He,children:(0,o.jsx)(pe.A,{sx:{fontSize:"0.9rem !important"},htmlColor:F===h.vZ.POSITIVE?"#00ac69":Be,"aria-hidden":"true"})}),(0,o.jsx)(c.A,{className:"action-button",size:"x-small","aria-label":F===h.vZ.NEGATIVE?"Remove negative reaction":"Add negative reaction","aria-pressed":F===h.vZ.NEGATIVE,onClick:qe,children:(0,o.jsx)(he.A,{sx:{fontSize:"0.9rem !important"},htmlColor:F===h.vZ.NEGATIVE?"#e81500":Be,"aria-hidden":"true"})})]}),w&&(0,o.jsx)(o.Fragment,{children:(0,o.jsx)(c.A,{className:"action-button",size:"x-small","aria-label":we?"Stop audio playback":"Play message audio","aria-pressed":we,onClick:function(){return je(r,void 0,void 0,(function(){return Me(this,(function(e){switch(e.label){case 0:return[4,Ne()];case 1:return e.sent(),[2]}}))}))},children:we?(0,o.jsx)(y.A,{htmlColor:Be,sx:{fontSize:"0.9rem !important"},"aria-hidden":"true"}):(0,o.jsx)(C.A,{htmlColor:Be,sx:{fontSize:"0.9rem !important"},"aria-hidden":"true"})})})]})}),(0,o.jsx)(T.BbZ,{open:X,onClose:function(){V(!1),Q(null),te("")},src:Z,alt:ee}),(0,o.jsx)(T.deU,{open:!!oe,onClose:function(){return re(null)},file:null!==(n=null==oe?void 0:oe.file)&&void 0!==n?n:null,mimeType:null==oe?void 0:oe.mimeType})]})}var _e=g.memo((function(e){var t=e.timestampFormat,n=e.setTimestampFormat,r=e.voiceAllowed,a=e.message,l=e.widgetConfigurations,s=e.widgetDetails,c=e.sourcePlatform,u=e.isStreaming,d=void 0!==u&&u,f=e.isInitialMessage,g=void 0!==f&&f,m=e.isStreamingEnabled,h=void 0===m||m,p=e.isLatestLocalMessage,v=void 0!==p&&p,b=a.id,x=a.query,S=a.answer,w=a.promptTokens,y=a.completionTokens,C=a.dataSourceInfo,A=a.createdAt,I=a.updatedAt,T=a.reaction,k=a.files,E=a.fromSource===Ce.i$.SUPPORT_PERSON,j=((null==k?void 0:k.length)||0)>0&&!E,M=((null==k?void 0:k.length)||0)>0&&E,R=(0,de.Zd)(x,j).trim(),_=R.length>0||j;return(0,o.jsxs)(i.A,{children:[_&&(0,o.jsx)(Re,{id:b,message:R,metadata:{promptTokens:w,completionTokens:y,dataSourceInfo:C,createdAt:A,updatedAt:I,files:j?k:void 0,reaction:T},sender:"user",timestampFormat:t,setTimestampFormat:n,isInitialMessage:g,widgetConfigurations:l,widgetDetails:s,sourcePlatform:c,voiceAllowed:r}),(S||M)&&(0,o.jsx)(Re,{id:b,message:S||"",metadata:{promptTokens:w,completionTokens:y,dataSourceInfo:C,createdAt:A,updatedAt:I,files:M?k:void 0,reaction:T},sender:"agent",isInitialMessage:g,widgetConfigurations:l,widgetDetails:s,sourcePlatform:c,voiceAllowed:r,isStreaming:d,timestampFormat:t,setTimestampFormat:n,isStreamingEnabled:h,isLatestLocalMessage:v})]})})),De=(n(39481),n(96300)),Oe=function(){return Oe=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Oe.apply(this,arguments)},Pe=function(e){var t=e.textColor,n=e.backgroundColor,r=e.name,i=e.required,a=e.type,l=e.placeholder,s=e.id,c=e.ariaLabel,u=e.options,d="checkbox"!==a?{width:"100%"}:{width:"auto"},f=Oe(Oe({},d),{marginBottom:"5px",borderRadius:"8px",padding:"5px 10px",border:"1px solid ".concat(t),color:t,backgroundColor:n}),g=Oe(Oe({},d),{marginBottom:"5px",borderRadius:"8px",padding:"5px 10px",outline:"none",border:"1px solid ".concat(t),color:t,backgroundColor:n,appearance:"none",paddingRight:"30px"});return"dropdown"===a&&u&&u.length>0?(0,o.jsxs)("div",{style:{position:"relative",width:"100%"},children:[(0,o.jsxs)("select",{style:g,className:"lead-collection-form-input-field",name:r,id:s,required:i,"aria-label":c,"aria-required":i,children:[(0,o.jsx)("option",{value:"",disabled:!0,selected:!0,children:l||"Select an option..."}),u.map((function(e){return(0,o.jsx)("option",{value:e.value,children:e.label},e.value)}))]}),(0,o.jsx)(De.A,{style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",pointerEvents:"none",color:t,fontSize:20}})]}):(0,o.jsx)("input",{style:f,className:"lead-collection-form-input-field",type:a,name:r,id:s,step:"number"===a?.01:void 0,required:i,placeholder:l,"aria-label":c,"aria-required":i})};var Ne=function(e){var t=e.widgetConfigurations,n=e.widgetDetails,r=e.refetchWidgetDetails,s=e.closeLeadsForm,u=e.chatbotUUID,f=e.userKey,m=e.parentDomain,p=e.previewOnly,v=void 0!==p&&p,b=(0,g.useState)(!1),S=b[0],w=b[1],y=n.leadForm.fields||[],C=y.filter((function(e){return e.isRequired&&"checkbox"!==e.fieldType})).concat(y.filter((function(e){return!e.isRequired&&"checkbox"!==e.fieldType})),y.filter((function(e){return"checkbox"===e.fieldType}))),I=(0,g.useMemo)((function(){var e;return(null===(e=h.I$.find((function(e){return e.value===t.fontFamily})))||void 0===e?void 0:e.label)||"System UI"}),[t.fontFamily]),k=n.leadForm.areAllFieldsOptional||v,E=t.aiMessageBgColor,j=t.aiMsgTextColor;(0,g.useEffect)((function(){if(n.leadForm.fields.length>0){var e=document.getElementById("messagesContainer");e&&(e.scrollTop=e.scrollHeight)}}),[n.leadForm.fields.length]);var M=(0,g.useMemo)((function(){return(null==t?void 0:t.useIconImageAsAvatar)?t.icon||"":t.chatAvatarImage||""}),[null==t?void 0:t.useIconImageAsAvatar,t.icon,t.chatAvatarImage]);return(0,o.jsxs)(i.A,{id:"lead-collection-form-container",className:"lead-collection-form-container",role:"article","aria-label":"Lead collection form",sx:{mt:1,display:"flex",justifyContent:"flex-start",alignItems:"flex-start",marginBottom:"10px",width:"100%"},children:[(null==t?void 0:t.showAvatar)&&(0,o.jsx)(i.A,{className:"message-avatar",display:"flex",alignItems:"center",gap:1,marginRight:"10px",marginLeft:"0px",children:(0,o.jsx)(a.A,{className:"message-avatar-image",alt:"Agent avatar",src:M,sx:{height:30,width:30,backgroundColor:"".concat(t.aiMsgTextColor,"22"),"& img":{backgroundColor:"".concat(t.aiMessageBgColor,"22"),borderRadius:"50%",objectFit:"contain"}},children:(0,o.jsx)(i.A,{sx:{"& svg":{height:"16px",width:"16px"}},children:(0,o.jsx)(se.A,{fontSize:"small",htmlColor:t.aiMsgTextColor})})})}),(0,o.jsxs)("div",{style:{minWidth:"250px",maxWidth:"85%",borderRadius:"10px",padding:"10px",fontSize:t.fontSize,fontFamily:I,backgroundColor:E,color:j},children:[k&&(0,o.jsx)(i.A,{position:"relative",children:(0,o.jsx)(c.A,{className:"lead-collection-form-close-btn",size:"small","aria-label":"Close lead collection form",onClick:function(){s()},sx:{position:"absolute",top:"-10px",right:"-10px"},children:(0,o.jsx)(x.A,{fontSize:"small","aria-hidden":"true"})})}),t.leadsCollectionFormPromptText&&(0,o.jsx)(l.A,{variant:"body1",fontFamily:I,fontWeight:700,fontSize:t.fontSize,color:j,style:{marginTop:k?"15px":"0px",marginBottom:"10px"},dir:"auto",children:t.leadsCollectionFormPromptText}),(0,o.jsxs)("form",{onSubmit:function(e){e.preventDefault(),e.stopPropagation(),w(!0);var t={};e.target.querySelectorAll("input, select").forEach((function(e){e instanceof HTMLInputElement&&"checkbox"===e.type?t[e.name]=e.checked:e instanceof HTMLInputElement&&"number"===e.type?t[e.name]=parseInt(e.value):(e instanceof HTMLSelectElement||e instanceof HTMLInputElement)&&(t[e.name]=e.value)})),(0,A.HY)(u,f,t,m).then((function(){r(),s()})).catch((function(e){console.error("Error submitting form:",e)})).finally((function(){w(!1)}))},"aria-label":"Lead collection form",children:[C.map((function(e){var n="checkbox"===e.fieldType,r="lead-form-".concat(e.fieldName),a=e.fieldLabel||(0,q.wy)(e.fieldName),l="dropdown"===e.fieldType;return(0,o.jsxs)(i.A,{sx:{display:n?"flex":"block",alignItems:n?"center":"flex-start",ga
1p:n?"10px":"0px"},children:[(0,o.jsx)(T.JU7,{className:"lead-collection-form-input-label",name:a,required:e.isRequired,htmlFor:r,style:{fontWeight:400,fontSize:t.fontSize}}),(0,o.jsx)(Pe,{textColor:j,backgroundColor:t.widgetBgColor,name:e.fieldName,id:r,required:e.isRequired,type:e.fieldType,placeholder:e.fieldPlaceholder||(l?"Select ".concat(a,"..."):"Please enter ".concat(a,"...")),ariaLabel:a+(e.isRequired?" (required)":" (optional)"),options:e.options})]},e.fieldName)})),(0,o.jsx)(d.A,{className:"lead-collection-form-submit-btn",style:{marginTop:"10px"},type:"submit",variant:"contained",color:"primary",disabled:S||v,"aria-label":S?"Submitting form":"Submit lead collection form",sx:{fontFamily:I},children:S?"Submitting...":"Submit"}),v&&(0,o.jsx)(l.A,{mt:1,variant:"caption",color:"error",children:"Disabled in preview mode."})]})]})]})},Fe=n(67340),Le=n.n(Fe),Be=function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))},Ue=function(e){var t=e.widgetConfigurations;return(0,o.jsxs)(i.A,{sx:{marginBottom:1.2},children:[(0,o.jsx)(i.A,{display:"flex",justifyContent:"flex-end",children:(0,o.jsx)(ae.A,{variant:"rectangular",height:75,width:"75%",sx:{borderRadius:"12px",mb:1.2,backgroundColor:t.userMessageBgColor}})}),(0,o.jsx)(ae.A,{variant:"rectangular",height:75,width:"75%",sx:{borderRadius:"12px",backgroundColor:t.aiMessageBgColor}})]})};var ze=function(e){var t=e.widgetConfigurations,n=e.fontFamily,r=e.messages,i=(0,g.useState)(0),a=i[0],s=i[1];return(0,g.useEffect)((function(){var e=setInterval((function(){s((function(e){return(e+1)%r.length}))}),1500);return function(){return clearInterval(e)}}),[r]),(0,o.jsx)(l.A,{dir:"auto",my:1,variant:"caption",fontFamily:n,color:"".concat(t.aiMsgTextColor,"DD"),children:r[a]})},We=g.memo((function(e){e.isBubble;var t,n=e.voiceAllowed,r=e.widgetConfigurations,s=e.sourcePlatform,c=e.userKey,u=e.streamingMessage,f=e.isStreaming,m=e.isWaitingForResponse,p=e.pendingUserMessage,v=e.setRefetchFunction,b=e.isHumanHandoffOn,x=e.temporaryMessage,S=e.setAddLocalMessageFunction,w=e.showLeadsForm,y=e.widgetDetails,C=e.previewOnly,I=e.chatbotUUID,k=e.parentDomain,E=e.setHasClosedLeadsForm,j=e.refetchWidgetDetails,M=e.isStreamingEnabled,R=e.onHasMessagesChange,_=(0,g.useRef)(null),D=(0,g.useState)([]),O=D[0],P=D[1],N=(0,g.useState)(null),F=N[0],L=N[1],B=(0,g.useState)("relative"),U=B[0],z=B[1],W=(0,A.hg)(window.chatbotUUID,c),H=W.data,Y=W.fetchNextPage,K=W.hasNextPage,X=W.isFetchingNextPage,V=W.isLoading,$=W.refetch,Z=(0,g.useCallback)((function(){$()}),[$]),Q=(0,g.useCallback)((function(e){e.answer&&(_.current=e.id),P((function(t){return t.some((function(t){return t.id===e.id}))?t:Be(Be([],t,!0),[e],!1)}))}),[]);(0,g.useEffect)((function(){v&&v(Z)}),[v,Z]),(0,g.useEffect)((function(){S&&S(Q)}),[S,Q]),(0,g.useEffect)((function(){if(!V&&(null==H?void 0:H.pages)){var e=H.pages.reduce((function(e,t){var n;return e+((null===(n=t.results)||void 0===n?void 0:n.length)||0)}),0);0===e&&O.length>0&&(P([]),_.current=null)}}),[null==H?void 0:H.pages,V]),(0,g.useEffect)((function(){if((null==H?void 0:H.pages)&&O.length>0){var e=new Set(H.pages.flatMap((function(e){return e.results.map((function(e){return e.id}))})));P((function(t){return t.filter((function(t){return!e.has(t.id)}))}))}}),[null==H?void 0:H.pages,O.length]);var J=(0,g.useMemo)((function(){var e=((null==H?void 0:H.pages.flatMap((function(e){var t;return null!==(t=e.results)&&void 0!==t?t:[]})))||[]).reverse(),t=(null==u?void 0:u.chatId)?[u.chatId]:[],n=t.length>0?e.filter((function(e){return!t.includes(e.id)}
1)):e;return Be(Be([],n,!0),O,!0).filter(Boolean).sort((function(e,t){return new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()}))}),[null==H?void 0:H.pages,O,null==u?void 0:u.chatId]);(0,g.useEffect)((function(){null==R||R(J.length>0)}),[J.length,R]);var ee=(0,g.useMemo)((function(){var e=r.initialMessage||"";return e?e.split("\n"):[]}),[r.initialMessage]);(0,g.useEffect)((function(){if(!X){var e=document.getElementById("messagesContainer");e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})}}),[J.length,p,m,X]),(0,g.useEffect)((function(){if(f&&(null==u?void 0:u.answer)){var e=document.getElementById("messagesContainer");e&&setTimeout((function(){e.scrollTop=e.scrollHeight}),100)}}),[f,null==u?void 0:u.answer]);var te=(0,g.useMemo)((function(){var e;return(null===(e=h.I$.find((function(e){return e.value===r.fontFamily})))||void 0===e?void 0:e.label)||"System UI"}),[r.fontFamily]);return V?(0,o.jsx)(Ue,{widgetConfigurations:r}):(0,o.jsxs)(i.A,{role:"log","aria-label":"Conversation messages","aria-live":"polite","aria-atomic":"false",children:[X&&(0,o.jsx)(Ue,{widgetConfigurations:r}),!K&&!X&&ee.map((function(e){return(0,o.jsx)(_e,{isInitialMessage:!0,timestampFormat:U,setTimestampFormat:z,voiceAllowed:n,widgetDetails:y,sourcePlatform:s,message:{id:1e6*Math.random(),query:"",answer:e,promptTokens:0,completionTokens:0,dataSourceInfo:null,createdAt:(new Date).toISOString(),updatedAt:(new Date).toISOString(),files:[]},widgetConfigurations:r},e)})),K&&!X&&(0,o.jsx)(d.A,{sx:{mb:1,backgroundColor:r.aiMessageBgColor,color:r.aiMsgTextColor,"&:hover":{backgroundColor:"".concat(r.aiMessageBgColor,"80")}},className:"load-previous-chats-button",size:"small",variant:"text",fullWidth:!0,color:"inherit","aria-label":"Load previous chat messages",onClick:function(){return Y()},endIcon:(0,o.jsx)(ce.A,{fontSize:"small",htmlColor:r.aiMsgTextColor}),children:"Load previous chats"}),null==J?void 0:J.map((function(e){return(0,o.jsx)(_e,{timestampFormat:U,setTimestampFormat:z,widgetDetails:y,voiceAllowed:n,sourcePlatform:s,message:e,widgetConfigurations:r,isStreamingEnabled:M,isLatestLocalMessage:null!==_.current&&e.id===_.current},e.id)})),p&&(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)(i.A,{id:"pending-user-message",className:"message-container",role:"status","aria-live":"polite","aria-label":"Your message",sx:{display:"flex",flexDirection:"row-reverse",alignItems:"flex-start",marginBottom:"10px",width:"100%"},children:[(null==r?void 0:r.showAvatar)&&(0,o.jsx)(i.A,{className:"message-avatar",display:"flex",alignItems:"center",marginBottom:1,marginLeft:"10px",gap:1,children:(0,o.jsx)(a.A,{className:"message-avatar-image",alt:"user",src:r.userMsgAvatarImage||"",sx:{height:30,width:30,backgroundColor:"".concat(r.userMsgTextColor,"22"),"& img":{backgroundColor:"".concat(r.userMessageBgColor,"22"),borderRadius:"50%",objectFit:"contain"}},children:(0,o.jsx)(i.A,{sx:{"& svg":{height:"16px",width:"16px"}},children:(0,o.jsx)(le.A,{fontSize:"small",htmlColor:r.userMsgTextColor})})})}),(0,o.jsxs)("div",{style:{minWidth:"160px",maxWidth:"85%",borderRadius:"10px",padding:"10px",fontSize:r.fontSize,fontFamily:te,backgroundColor:r.userMessageBgColor,color:r.userMsgTextColor},className:"message-user",children:[p.message.trim().length>0&&(0,o.jsx)(i.A,{dir:"auto",sx:(0,h.ph)(r),className:"message-user",dangerouslySetInnerHTML:{__html:(0,q.hw)(p.message).__html}}),p.files&&p.files.length>0&&(0,o.jsx)(i.A,{sx:{marginTop:1.5,marginBottom:.5},children:(0,o.jsx)(T.hcB,{files:p.files,readOnly:!0,themeContext:G.fL,bgColor:r.userMessageBgColor,align:"left",ignoreSpacing:!0,onFilePreview:function(e,t){return L({file:e,mimeType:t})}})}),r.showTimestamp&&(0,o.jsx)(l.A,{variant:"caption",fontFamily:te,color:r.userMsgTextColor,textAlign:"right",onClick:function(){return z("relative"===U?"absolute":"relative")},sx:{cursor:"pointer"},children:"relative"===U?Le()((new Date).toISOString()).fromNow():(0,q.r6)((new Date).toISOString(),"MMM D, YYYY, h:mm:ss a")})]})]})}),x&&(0,o.jsx)(l.A,{className:"information-message",m:1,align:"center",variant:"body2",fontSize:r.fontSize-2,fontFamily:te,color:x.includes("Error")?"error":"".concat(r.aiMsgTextColor,"DD"),children:x}),m&&!u&&!b&&(0,o.jsxs)(i.A,{children:[(0,o.jsxs)(i.A,{id:"typing-indicator",className:"message-container",role:"status","aria-live":"polite","aria-label":"Agent is typing",sx:{dis
1play:"flex",alignItems:"flex-start",marginBottom:"0px",width:"100%"},children:[(null==r?void 0:r.showAvatar)&&(0,o.jsx)(i.A,{className:"message-avatar",display:"flex",alignItems:"center",marginBottom:1,marginRight:"10px",gap:1,children:(0,o.jsx)(a.A,{className:"message-avatar-image",alt:"agent",src:(null==r?void 0:r.useIconImageAsAvatar)?r.icon||"":r.chatAvatarImage||"",sx:{height:30,width:30,backgroundColor:"".concat(r.aiMsgTextColor,"22"),"& img":{backgroundColor:"".concat(r.aiMessageBgColor,"22"),borderRadius:"50%",objectFit:"contain"}},children:(0,o.jsx)(i.A,{sx:{"& svg":{height:"16px",width:"16px"}},children:(0,o.jsx)(se.A,{fontSize:"small",htmlColor:r.aiMsgTextColor})})})}),(0,o.jsx)("div",{style:{minWidth:"160px",maxWidth:"85%",borderRadius:"10px",padding:"10px",fontSize:r.fontSize,fontFamily:te,backgroundColor:r.aiMessageBgColor,color:r.aiMsgTextColor},className:"message-agent",children:(0,o.jsx)(i.A,{dir:"auto",sx:(0,h.ph)(r),className:"message-agent",display:"flex",alignItems:"center",gap:1,children:(0,o.jsx)("img",{style:{width:"40px",height:"auto"},src:"".concat(location.origin,"/static/common/img/icons/typing.gif"),alt:"","aria-hidden":"true"})})})]}),r.enableAiAgentStatusMessages&&(0,o.jsx)(i.A,{className:"message-agent-status-message",role:"status","aria-live":"polite","aria-label":"Agent status",marginLeft:(null==r?void 0:r.showAvatar)?"45px":"0px",sx:{paddingBottom:"30px"},children:(0,o.jsx)(ze,{fontFamily:te,widgetConfigurations:r,messages:r.aiAgentStatusMessages?r.aiAgentStatusMessages.split("\n"):[]})})]}),u&&u.answer&&(0,o.jsx)(_e,{widgetDetails:y,timestampFormat:U,setTimestampFormat:z,voiceAllowed:n,sourcePlatform:s,message:{id:u.chatId||-1,query:"",answer:u.answer,promptTokens:0,completionTokens:0,dataSourceInfo:u.dataSourceInfo,createdAt:(new Date).toISOString(),updatedAt:(new Date).toISOString(),files:[]},widgetConfigurations:r,isStreaming:f,isStreamingEnabled:M},"streaming-message"),w&&y&&(0,o.jsx)(Ne,{widgetConfigurations:r,previewOnly:C,chatbotUUID:I,userKey:c,parentDomain:k,closeLeadsForm:function(){return E(!0)},widgetDetails:y,refetchWidgetDetails:j}),(0,o.jsx)(T.deU,{open:!!F,onClose:function(){return L(null)},file:null!==(t=null==F?void 0:F.file)&&void 0!==t?t:null,mimeType:null==F?void 0:F.mimeType})]})})),He=n(74305),qe="hasClickedQuickMessages",Ge="quickMessagesFirstVisitDone",Ye=g.memo((function(e){var t=e.messageText,n=e.disabled,r=e.persistent,a=e.hasClicked,s=e.isUsed,c=e.onMarkUsed,u=e.setInputMessage,d=e.setShowMessages,f=e.widgetConfigurations,m=e.fontFamily,h=(e.isLastMessage,(0,g.useCallback)((function(){if(!n){c(t);var e=!!r;d(e),u(t,e),a||r||(0,He.g$)(qe,"true")}}),[n,r,t,c,u,d,a])),p=(0,g.useCallback)((function(e){if(("Enter"===e.key||" "===e.key)&&!n){e.preventDefault(),c(t);var o=!!r;d(o),u(t,o),a||r||(0,He.g$)(qe,"true")}}),[n,r,t,c,u,d,a]),v=s?f.aiMessageBgColor:f.userMessageBgColor,b=s?f.aiMsgTextColor:f.userMsgTextColor;return(0,o.jsx)(i.A,{className:"starter-message-item",role:"button",tabIndex:n?-1:0,"aria-label":"Quick message: ".concat(t),"aria-disabled":n,sx:{opacity:n?.85:1,pointerEvents:n?"none":"auto",padding:"6px 14px",border:"1.5px solid ".concat(f.userMessageBgColor),borderRadius:"14px",cursor:n?"not-allowed":"pointer",transition:"all 0.2s ease-in-out",display:"inline-flex",alignItems:"center",justifyContent:"center",textAlign:"center",boxSizing:"border-box",background:v,"&:hover":{opacity:.85,background:"".concat(s?f.aiMessageBgColor:f.userMessageBgColor,"EE"),transition:"all 0.2s ease-in-out"}},onClick:h,onKeyDown:p,children:(0,o.jsx)(l.A,{color:b,fontFamily:m,fontSize:f.fontSize,fontWeight:500,variant:"body1",sx:{textAlign:"center",lineHeight:1.2},dangerouslySetInnerHTML:{__html:t}})})}));Ye.displayName="QuickMessageItem";var Ke=g.memo((function(e){var t=e.disabled,n=e.setInputMessage,r=e.widgetConfigurations,a="true"===(0,He.kl)(qe),l=r.persistentConversationStarterMessage,s=(0,g.useState)(!0),c=s[0],u=s[1],d=(0,g.useState)((function(){return new Set})),f=d[0],m=d[1],p=(0,g.useCallback)((function(e){m((function(t){return new Set(t).add(e)}))}),[]),v=(0,g.useMemo)((function(){var e;return(null===(e=h.I$.find((function(e){return e.value===r.fontFamily})))||void 0===e?void 0:e.label)||"System UI"}),[r.fontFamily]),b=(0,g.useMemo)((function(){var e;return(null===(e=r.conversationStarterMessage)||void 0===e?void 0:e.split("\n"))||[]}),[r.conversationStarterMessage]),x=b.some((function(e){return""!==e.trim()}));return(0,g.useEffect)((function(){if(x&&c&&!a)try{sessionStorage.setItem(Ge,"true")}catch(e){console.error("Error setting to sessionStorage (using default)",e)}}),[x,c,a]),x&&c&&!a?(0,o.jsx)(i.A,{id:"quick-messages-list",className:"starter-messages",role:"group","aria-label":"Quick message options",sx:{dis
1play:"flex",flexDirection:"row",flexWrap:"wrap",gap:"8px",justifyContent:"flex-end",px:"12px",pb:"4px",pt:"5px",flexFlow:"wrap-reverse"},children:b.map((function(e,i){var s=e.trim();return""===s?null:(0,o.jsx)(Ye,{messageText:s,disabled:t,persistent:l,hasClicked:a,isUsed:f.has(s),onMarkUsed:p,setInputMessage:n,setShowMessages:u,widgetConfigurations:r,fontFamily:v,isLastMessage:i===b.length-1},"".concat(s,"-").concat(i))}))}):null})),Xe="userConversationKey",Ve=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},$e=function(e){if(!e)return null;try{for(var t=localStorage.getItem(Xe),n="_".concat(e),o=(null==t?void 0:t.split(","))||[],r=0,i=o;r<i.length;r++){var a=i[r];if(a.match("".concat(n,"$")))return o.splice(o.indexOf(a),1),localStorage.setItem(Xe,o.toString()),a}return null}catch(e){return console.error("Error in findOrDeleteKey (localStorage not available):",e),null}},Ze=n(38544);function Qe(){var e=function(){try{var e=new URLSearchParams(window.location.search).get("parent_url");return e?{parentDomain:new URL(e).hostname,parentUrl:e}:null}catch(e){return console.warn("Could not parse parent_url from embed query string:",e),null}}();if(e)return e;var t=function(){var e="",t="";try{if(window.parent!==window.self)try{e=window.parent.location.hostname,t=window.parent.location.href}catch(n){if(document.referrer)try{e=new URL(document.referrer).hostname,t=document.referrer}catch(e){console.warn("Could not parse referrer URL:",e)}}}catch(e){console.warn("Error accessing iframe parent:",e)}return{parentDomain:e,parentUrl:t}}();if(t.parentDomain)return t;var n=function(){var e="",t="";if(window.location.ancestorOrigins&&window.location.ancestorOrigins.length>0)try{e=new URL(window.location.ancestorOrigins[0]).hostname,t=window.location.ancestorOrigins[0]}catch(e){console.warn("Could not parse ancestor origin:",e)}return{parentDomain:e,parentUrl:t}}();return n.parentDomain?n:{parentDomain:window.location.hostname,parentUrl:window.location.href}}var Je=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function l(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}s((o=o.apply(e,t||[])).next())}))},et=function(e,t){var n,o,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(n=1,o&&(r=2&l[0]?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,o=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==l[0]&&2!==l[0])){i=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){i.label=l[1];break}if(6===l[0]&&i.label<r[1]){i.label=r[1],r=l;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(l);break}r[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],o=0}finally{n=r=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},tt=function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))},nt="readAloudEnabled",ot=function(e){var t,n,m,p,v,b,k,E,j,M,R,_=e.embedType,D=e.setIsOpen,O=e.widgetConfigurations,P=e.sourcePlatform,N=e.allowClose,F=void 0!==N&&N,L=e.readOnly,B=void 0!==L&&L,U=e.previewOnly,z=void 0!==U&&U,W=(0,g.useState)({width:1920,height:1080}),H=W[0],G=W[1],Y=null!==(t=O.widgetWidth)&&void 0!==t?t:450,K=(0,g.useState)(null),X=K[0],V=K[1],$=(0,g.useState)(null),Z=$[0],Q=($[1],(0,g.useState)("true"===(0,He.kl)(nt))),J=Q[0],ee=Q[1],te=(0,g.useState)(!1),ne=te[0],oe=te[1],re=(0,g.useState)(!1),ae=re[0],le=re[1],se=(0,g.useState)(!1),ce=se[0],ue=se[1],de=(0,g.useState)(!1),fe=de[0],ge=de[1],me=(0,g.useState)(!1),he
1=me[0],pe=me[1],ve=(0,g.useRef)(null),be=function(e){try{var t=[],n=Xe,o=localStorage.getItem(n);if(o){t=o.split(",");for(var r=0,i=t;r<i.length;r++){var a=i[r];if(a.match("_".concat(e,"$")))return a}}var l=Ve(),s="".concat(l,"_").concat(e);return t.push(s),localStorage.setItem(n,t.join(",")),s}catch(t){return console.error("Error in getOrCreateUserKey (localStorage not available):",t),"".concat(Ve(),"_").concat(e)}}(window.chatbotId),xe=window.chatbotUUID,Se="bubble"===_,we=window.navigator.userAgent.includes("Mobile"),Ae=Se?we||(null!==(n=null==H?void 0:H.width)&&void 0!==n?n:0)<Y+40:(0,r.A)("(max-width: ".concat(Y,"px)")),Ie="shared"===P&&(0,r.A)("(max-width: 768px)"),Te=(0,g.useState)(!1),ke=Te[0],Ee=Te[1],je=(0,g.useState)(!1),Me=je[0],Re=je[1],_e=(0,g.useState)(!1),De=_e[0],Oe=_e[1],Pe=(0,g.useRef)(!1);(0,g.useEffect)((function(){Pe.current=De}),[De]);var Ne=(0,g.useState)(null),Fe=Ne[0],Le=Ne[1],Be=(0,g.useState)(null),Ue=Be[0],ze=Be[1],Ye=(0,g.useState)(!1),ot=Ye[0],rt=Ye[1],it=(0,g.useState)(null),at=it[0],lt=it[1],st=(0,g.useState)(!1),ct=st[0],ut=st[1],dt=(0,g.useRef)(""),ft=(0,g.useRef)(null),gt=(0,g.useRef)(null),mt=(0,g.useRef)(null),ht=(0,g.useRef)(null),pt=(0,g.useRef)(null),vt=(0,g.useRef)([]),bt=(0,g.useRef)([]),xt=(0,g.useRef)(null),St=(0,g.useRef)(null),wt=(0,g.useState)([]),yt=wt[0],Ct=wt[1],At=(0,I.Bd)().t,It=(0,g.useMemo)((function(){return Qe()}),[]),Tt=(0,A.Ar)(xe,be,It.parentDomain),kt=Tt.data,Et=Tt.isLoading,jt=Tt.refetch;(0,g.useEffect)((function(){var e=function(e){if(Se){var t=function(e){if("chatwidget-parent-size"===e.data.type)return{width:e.data.width,height:e.data.height}}(e);t&&G(t)}};return window.addEventListener("message",e),function(){window.removeEventListener("message",e)}}),[Se]);var Mt=(0,g.useMemo)((function(){var e,t,n,o,r;return!(null!==(t=null===(e=null==kt?void 0:kt.leadForm)||void 0===e?void 0:e.hasSubmitted)&&void 0!==t&&t)&&(null!==(r=null===(o=null===(n=null==kt?void 0:kt.leadForm)||void 0===n?void 0:n.fields)||void 0===o?void 0:o.length)&&void 0!==r?r:0)>0&&!ce}),[null===(m=null==kt?void 0:kt.leadForm)||void 0===m?void 0:m.hasSubmitted,null===(v=null===(p=null==kt?void 0:kt.leadForm)||void 0===p?void 0:p.fields)||void 0===v?void 0:v.length,ce]),Rt=(0,g.useMemo)((function(){return Se?Ae?"100dvh":O.widgetHeight:Ie?"100dvh":"100%"}),[O.widgetHeight,Ae,Se,P,Ie]),_t=(0,g.useMemo)((function(){var e;return null!==(e=O.audioIoEnabled)&&void 0!==e&&e}),[O.audioIoEnabled]),Dt="embeded"===P&&!B&&!z&&null!==(b=O.autoRefreshEnabled)&&void 0!==b&&b;(0,g.useEffect)((function(){if(Dt){var e=!1,t=function(t){t.persisted||e||Pe.current&&(e=!0,$e(window.chatbotId),(0,A.NR)(be)||(0,A.dR)(be).catch((function(e){console.error("[auto-refresh] failed to reset conversation on page exit:",e)})))};return window.addEventListener("pagehide",t),function(){window.removeEventListener("pagehide",t)}}}),[Dt,be]),(0,g.useEffect)((function(){var e;oe(null!==(e=null==kt?void 0:kt.isHumanHandoffOn)&&void 0!==e&&e)}),[null==kt?void 0:kt.isHumanHandoffOn]),(0,g.useEffect)((function(){ne&&(bt.current=[],xt.current=null,Ct([]))}),[ne]);var Ot=(0,g.useCallback)((function(){if(O.enableSoundEffects&&O.notificationSound)try{new Audio(O.notificationSound).play().catch((function(e){console.error("Error playing notification sound:",e)}))}catch(e){console.error("Error creating notification sound:",e)}}),[O.enableSoundEffects,O.notificationSound]),Pt=(0,g.useCallback)((function(e,t,n,o){var r=document.getElementById("sourcesSection");if(r){var i="";o&&(i='\n        <div class="mt-10">\n            <strong>Trace</strong>\n            <div class="debug-mode-info-section">\n            '.concat((0,q.jT)([o]).outerHTML,"\n            </div>\n        </div>"));var a="";e&&e.length>0&&(a='\n        <div class="mt-10">\n            <strong>Knowledge Base Search Results</strong>\n            <div class="debug-mode-info-section">\n            <pre>\n              '.concat((0,q.hw)(JSON.stringify(e)),"\n            </pre>\n            </div>\n        </div>"));var l="";n&&n.length>0&&(l='\n        <div class="mt-10">\n            <strong>Tool &amp; KB Calls ('.concat(n.length,')</strong>\n            <div class="debug-mode-info-section">\n            ').concat((0,q.jT)(n).outerHTML,"\n            </div>\n        </div>"));var s="";t&&(s='\n        <div class="mt-10">\n            <strong>Messages sent to LLM</strong>\n            <div class="debug-mode-info-section">\n            '.concat((0,q.jT)(t).outerHTML,"\n            </div>\n        </div>"));var c='\n      <div class="debug-mode-section mt-2">\n          '.concat(i,"\n          ").concat(l,"\n          ").concat(a,"\n          ").concat(s,"\n      </div>"),u=document.querySelector(".debug-mode-section");u&&u.remove(),r&&r.insertAdjacentHTML("afterend",c)}}),[]),Nt=(0,g.useCallback)((function(e){if(J&&_t&&e.trim()){var t=(0,q.im)(e),n=t.match(/[^.!?]+[.!?]+/g)||[t],o=0,r=function(){if(le(!0),o<n.length){var e=new SpeechSynthesisUtterance(n[o]);e.lang="en-US",e.rate=.9,e.volume=2,e.onend=function(){o++,r(),o===n.length&&le(!1)},window.speechSynthesis.speak(e)}else le(!1)};r()}}),[J,_t]),Ft=(0,g.useCallback)((function(e){return Je(void 0,void 0,void 0,(function(){var t,n,o,r;return et(this,(function(i){switch(i.label){case 0:if(!J||!_t||!e.trim())return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),ve.current&&(ve.current.pause(),ve.current.currentTime=0),le(!0),[4,ye((0,q.im)(e),"elevenlabs",void 0,window.chatbotUUID)];case 2:return t=i.sent(),(null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.audio_base64)?(n=new Audio("data:audio/mp3;base64,".concat(t.data.audio_base64)),ve.current=n,n.addEventListener("ended",(function(){le(!1),ve.current=null})),n.addEventListener("error",(function(){le(!1),ve.current=null})),n.play().catch((function(e){console.error("Error playing read aloud audio:",e),le(!1),ve.current=null}))):(console.error("No audio data received"),le(!1)),[3,4];case 3:return o=i.sent(),console.error("Error fetching audio for read aloud:",o),le(!1),[3,4];case 4:return[2]}}
1))}))}),[J,_t]),Lt=(0,g.useCallback)((function(e){_t&&(null==kt?void 0:kt.isUsingElevenlabs)?Ft(e):Nt(e)}),[_t,null==kt?void 0:kt.isUsingElevenlabs,Ft,Nt]),Bt=function(e){void 0===e&&(e="auto");var t=document.getElementById("messagesContainer");t&&(t.scrollTo({top:t.scrollHeight,behavior:e}),Re(!1))},Ut=(0,g.useCallback)((function(){ve.current&&(ve.current.pause(),ve.current.currentTime=0,ve.current=null),le(!1)}),[]),zt=(0,g.useCallback)((function(){ae?(Ut(),window.speechSynthesis.cancel()):((0,He.g$)(nt,J?"false":"true"),ee(!J))}),[ae,J,Ut]),Wt=(0,g.useCallback)((function(){window.parent.postMessage("close-chatbubble","*"),null==D||D(!1)}),[D]),Ht=(0,g.useCallback)((function(){ge(!0)}),[]),qt=(0,g.useCallback)((function(){ge(!1)}),[]),Gt=(0,g.useCallback)((function(e,t){return e.trim().length>0||((null==t?void 0:t.length)||0)>0}),[]),Yt=(0,g.useCallback)((function(){return Je(void 0,void 0,void 0,(function(){var e,t,n,o;return et(this,(function(r){switch(r.label){case 0:return Fe?xt.current?[2]:(e=bt.current.shift())?(Ct((function(t){return t.filter((function(t){return t.id!==e.id}))})),xt.current=e,V(null),t={message:e.message,files:e.files},[4,(0,q.f7)(e.files)]):[2]:[2];case 1:return n=r.sent(),vt.current=n,ne&&mt.current?(o=-Date.now(),mt.current({id:o,query:e.message,answer:void 0,promptTokens:0,completionTokens:0,dataSourceInfo:null,createdAt:(new Date).toISOString(),updatedAt:(new Date).toISOString(),files:(null==n?void 0:n.map((function(e){return{fileName:e.filename,base64:e.content}})))||[]}),lt(null),pt.current=null,vt.current=[]):(lt(t),pt.current=t,ut(!0)),dt.current="",ft.current=null,rt(!1),ze(null),Fe.query(e.message,e.files||void 0,ne),ne&&(xt.current=null),[2]}}))}))}),[Fe,ne]),Kt=(0,g.useCallback)((function(){lt(null),pt.current=null,vt.current=[],xt.current=null,Yt().catch((function(e){console.error("Error processing queued message:",e),(0,q.ag)("Error sending message.")}))}),[Yt]),Xt=(0,g.useCallback)((function(e){var t,n,o,r,i=e.answer,a=e.from,l=e.stream_ended,s=e.should_display,c=e.api_messages,u=e.completion_tokens,d=e.prompt_tokens,f=e.search_results,g=e.tool_calls,m=e.trace,h=e.data_source_info,p=e.is_human_handed_off,v=e.chat_id,b=e.error,x=(e.messages_remaining,e.end_user_connected),S=e.is_initializing,w=e.files,y=void 0===w?[]:w;if("boolean"!=typeof x){var C=void 0===l||l,A=void 0===a?Ce.i$.CHATBOT:a,I=!1!==s,T=A===Ce.i$.CHATBOT,k=A===Ce.i$.USER,E=y.map((function(e){return{fileName:e.file_name||e.fileName||"",url:e.url}}));if(I&&(i&&V(null),void 0!==p&&"boolean"==typeof p&&(oe(p),p&&!S&&Ot()),!S)){if(h&&(ft.current=h),b&&C)return V("Error: ".concat(b)),ut(!1),rt(!1),ze(null),Kt(),Ot(),dt.current="",void console.error("Chat error:",b);if(p&&i){var j=(null===(t=pt.current)||void 0===t?void 0:t.message)||(null==at?void 0:at.message)||"",M=vt.current;return mt.current&&mt.current({id:v||-Date.now(),query:j,answer:i,promptTokens:d,completionTokens:u,dataSourceInfo:null,createdAt:(new Date).toISOString(),updatedAt:(new Date).toISOString(),files:(null==M?void 0:M.map((function(e){return{fileName:e.filename,base64:e.content}})))||[]}),ut(!1),rt(!1),ze(null),Kt(),void(dt.current="")}if(i||C){if(k)return v&&mt.current&&mt.current({id:v,query:i||"",answer:void 0,fromSource:Ce.i$.USER,promptTokens:0,completionTokens:0,dataSourceInfo:null,createdAt:(new Date).toISOString(),updatedAt:(new Date).toISOString(),files:E}),void Bt();var R=(null===(n=pt.current)||void 0===n?void 0:n.message)||(null==at?void 0:at.message)||"",_=vt.current;if(C){if(C&&T){ut(!1),rt(!1);var D=dt.current||i||"",O=ft.current||h;mt.current&&D&&v&&mt.current({id:v,query:R,answer:D,fromSource:Ce.i$.CHATBOT,promptTokens:d,completionTokens:u,dataSourceInfo:O,createdAt:(new Date).toISOString(),updatedAt:(new Date).toISOString(),files:(null==_?void 0:_.map((function(e){return{fileName:e.filename,base64:e.content}})))||[]}),Kt(),ze(null),dt.current="",ft.current=null,Ot(),null===(o=St.current)||void 0===o||o.call(St),D&&(Lt(D),Bt()),(f||c||(null==g?void 0:g.length)||m)&&setTimeout((function(){Pt(f,c,g,m)}),0)}else if(C){ut(!1),rt(!1);var P=i||"";O=h||ft.current;
1mt.current&&(P||E.length)&&v&&mt.current({id:v,query:k?P:"",answer:k?void 0:P,fromSource:A,promptTokens:d,completionTokens:u,dataSourceInfo:O,createdAt:(new Date).toISOString(),updatedAt:(new Date).toISOString(),files:E.length?E:(null==_?void 0:_.map((function(e){return{fileName:e.filename,base64:e.content}})))||[]}),Kt(),ze(null),dt.current="",ft.current=null,Ot(),k||null===(r=St.current)||void 0===r||r.call(St),P&&!k&&(Lt(P),Bt()),(f||c||(null==g?void 0:g.length)||m)&&setTimeout((function(){Pt(f,c,g,m)}),0)}}else ut(!1),dt.current+=i||"",rt(!0),ze({answer:dt.current,dataSourceInfo:ft.current,chatId:v})}else rt(!1)}}else x&&(V(At("DISPLAY_STRINGS.MCP_END_USER_SIGNED_IN")),Ot())}),[Kt,Ot,Lt,Pt,At]),Vt=(0,g.useRef)(Xt);(0,g.useEffect)((function(){Vt.current=Xt}),[Xt]);var $t=(0,g.useCallback)((function(e){Vt.current(e)}),[]),Zt=(0,g.useCallback)((function(e,t){return Je(void 0,void 0,void 0,(function(){var n,o,r;return et(this,(function(i){return Fe?(V(null),n=(e||"").trim(),Gt(n,t)?(o=(null==t?void 0:t.length)?Array.from(t):null,r={id:"".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2)),message:n,files:o},bt.current.push(r),ne||Ct((function(e){return tt(tt([],e,!0),[r],!1)})),Yt().catch((function(e){console.error("Error processing queued message:",e),(0,q.ag)("Error sending message.")})),[2]):[2]):[2]}))}))}),[Fe,Gt,ne,Yt]),Qt=(0,g.useCallback)((function(e){bt.current=bt.current.filter((function(t){return t.id!==e})),Ct((function(t){return t.filter((function(t){return t.id!==e}))}))}),[]),Jt=(0,g.useCallback)((function(e,t){Ee(t),e&&Fe&&Zt(e,null).catch((function(e){console.error("Error sending message:",e),(0,q.ag)("Error sending message.")}))}),[Fe,Zt]),en=(0,g.useCallback)((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Je(void 0,tt([],e,!0),void 0,(function(e){var t;return void 0===e&&(e="manual"),et(this,(function(n){switch(n.label){case 0:console.log("[auto-refresh] resetting conversation: ".concat(e)),bt.current=[],xt.current=null,Ct([]),lt(null),pt.current=null,vt.current=[],ut(!1),rt(!1),ze(null),ue(!1),dt.current="",ft.current=null,Fe&&(Fe.disconnect(),Le(null)),(0,He.qu)(qe);try{sessionStorage.removeItem(Ge)}catch(e){console.error("Error removing from sessionStorage",e)}$e(window.chatbotId),gt.current&&gt.current(),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,(0,A.dR)(be)];case 2:return n.sent(),[3,4];case 3:throw t=n.sent(),console.error("Error resetting conversation:",t),t;case 4:return[2]}}
1))}))}),[be,Fe]),tn=(0,g.useCallback)((function(){he||(pe(!0),ge(!1),en("user-clicked-reset").then((function(){(0,q.vd)("Conversation reset successfully.")})).catch((function(e){var t,n;(0,q.ag)((null===(n=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.data)||void 0===n?void 0:n.message)||"Error Resetting Conversation.")})).finally((function(){pe(!1)})))}),[en,he]),nn=function(e){var t=e.enabled,n=e.pageInactivityTimeout,o=e.botInactivityTimeout,r=e.tabVisibilityTimeout,i=e.activityCheckInterval,a=e.onTrigger,l=(0,g.useRef)(Date.now()),s=(0,g.useRef)(Date.now()),c=(0,g.useRef)(null),u=(0,g.useRef)(!0),d=(0,g.useRef)(null),f=(0,g.useRef)(null),m=(0,g.useRef)(null),h=(0,g.useRef)(a);(0,g.useEffect)((function(){h.current=a}),[a]);var p=(0,g.useCallback)((function(){d.current&&(clearTimeout(d.current),d.current=null),f.current&&(clearTimeout(f.current),f.current=null),m.current&&(clearTimeout(m.current),m.current=null)}),[]),v=(0,g.useCallback)((function(e){u.current&&(console.log("[auto-refresh] trigger: ".concat(e)),p(),u.current=!1,Promise.resolve().then((function(){return h.current(e)})).catch((function(e){console.error("[auto-refresh] failed to reset conversation:",e),u.current=!0})))}),[p]),b=(0,g.useCallback)((function(){t&&(u.current=!0,s.current=Date.now(),l.current=Date.now(),f.current&&clearTimeout(f.current),f.current=setTimeout((function(){v("bot-inactivity")}),o))}),[t,o,v]);return(0,g.useEffect)((function(){if(t){u.current=!0,l.current=Date.now();var e=function(){l.current=Date.now(),d.current&&clearTimeout(d.current),d.current=setTimeout((function(){v("user-inactivity")}),n)},a=function(){var e=Date.now();"hidden"===document.visibilityState?(c.current=e,m.current&&clearTimeout(m.current),m.current=setTimeout((function(){v("tab-hidden-timeout")}),r)):"visible"===document.visibilityState&&(null!==c.current&&(e-c.current>=r&&v("tab-hidden-return"),c.current=null),m.current&&(clearTimeout(m.current),m.current=null))},f=["mousemove","keydown","click","scroll","touchstart"];f.forEach((function(t){return document.addEventListener(t,e)})),document.addEventListener("visibilitychange",a);var g=setInterval((function(){var e=Date.now();u.current&&e-s.current>=o&&v("bot-inactivity-check"),u.current&&e-l.current>=n&&v("user-inactivity-check")}),i);return e(),function(){f.forEach((function(t){return document.removeEventListener(t,e)})),document.removeEventListener("visibilitychange",a),clearInterval(g),p()}}p()}),[t,n,o,r,i,v,p]),{bumpBotInteraction:b}}({enabled:Dt,pageInactivityTimeout:null!==(k=O.chatwidgetPageInactivityTimeout)&&void 0!==k?k:9e5,botInactivityTimeout:null!==(E=O.chatwidgetInactivityTimeout)&&void 0!==E?E:18e5,tabVisibilityTimeout:null!==(j=O.chatwidgetTabVisibilityTimeout)&&void 0!==j?j:6e4,activityCheckInterval:null!==(M=O.chatwidgetActivityCheckInterval)&&void 0!==M?M:6e4,onTrigger:function(e){return en(e)}}).bumpBotInteraction;(0,g.useEffect)((function(){St.current=nn}),[nn]),(0,g.useEffect)((function(){return!J&&ae&&Ut(),function(){Ut()}}),[J,ae,Ut]),(0,g.useEffect)((function(){if(xe&&be&&P&&!B){var e=new Ze.c(xe,be,P,$t,"true"===window.isInternal,!1,It);return e.setIsStreamingEnabled(O.isStreamingEnabled),e.connect(),Le(e),function(){e.disconnect()}}}),[xe,be,P,O.isStreamingEnabled,B,$t,It]),(0,g.useEffect)((function(){Yt().catch((function(e){console.error("Error processing queued message:",e),(0,q.ag)("Error sending message.")}))}),[Fe,Yt]),(0,g.useEffect)((function(){O.conversationStarterMessage&&Ee(!0)}),[O.conversationStarterMessage]);(0,g.useMemo)((function(){return B?"calc(100% - 65px)":O.showTagline?"calc(100% - 160px)":"calc(100% - 125px)"}),[B,O.showTagline]);var on=(0,g.useMemo)((function(){var e;return(null===(e=h.I$.find((function(e){return e.value===O.fontFamily})))||void 0===e?void 0:e.label)||"System UI"}),[O.fontFamily]),rn=(0,g.useCallback)((function(e){gt.current=e}),[]),an=(0,g.useCallback)((function(e){mt.current=e}),[]),ln=(0,g.useRef)(!1);(0,g.useEffect)((function(){if(Se&&!Et&&!B&&!ln.current){var e=setTimeout((function(){var e;null===(e=ht.current)||void 0===e||e.focus(),ln.current=!0}),300);return function(){return clearTimeout(e)}}}),[Se,Et,B]);var sn=(0,g.useRef)(!1);if((0,g.useEffect)((function(){var e=ot||ct;
1if(sn.current&&!e){var t=setTimeout((function(){var e;null===(e=ht.current)||void 0===e||e.focus()}),100);return function(){return clearTimeout(t)}}sn.current=e}),[ot,ct]),Et)return null;var cn=O.displayName||O.name||"CB";return(0,o.jsxs)(i.A,{className:"chat-widget-container",role:"region","aria-label":"Chat widget - ".concat(cn),width:Se&&!Ae?Y:"100%",height:Se&&Ae?"100dvh":z&&Se?"min(".concat(null!==(R=O.widgetHeight)&&void 0!==R?R:600,"px, 100%)"):Rt,boxShadow:"0 0 10px 0px ".concat(O.widgetBorderColor,"88"),border:"".concat(O.widgetBorderWidth,"px solid ").concat(O.widgetBorderColor),borderRadius:z||!Ae&&!Ie?"15px":"0",sx:{overflow:"hidden",display:"flex",flexDirection:"column",background:"image"===O.widgetBgPreference?"url(".concat(O.widgetBgImage,") no-repeat center center"):O.widgetBgColor,backgroundSize:"cover",backgroundColor:O.widgetBgColor},children:[(0,o.jsxs)(i.A,{className:"chat-widget-header",role:"banner","aria-label":"Chat widget header",sx:{background:O.widgetHeaderBannerImage?"url(".concat(O.widgetHeaderBannerImage,") no-repeat center center"):"linear-gradient(135deg, ".concat(O.headerGradientColor_1," 0%, ").concat(O.headerGradientColor_2," 100%)"),backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat"},height:"65px",padding:"12px",display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,o.jsxs)(i.A,{display:"flex",alignItems:"center",gap:2,children:[(0,o.jsxs)(i.A,{children:[(0,o.jsx)(a.A,{alt:cn,src:O.icon||"",sx:{height:40,width:40,backgroundColor:"".concat(O.chatwidgetTitleTextColor,"22"),"& img":{backgroundColor:"".concat(O.chatwidgetTitleTextColor,"22"),borderRadius:"50%",objectFit:"contain"}},children:(0,o.jsx)(l.A,{color:O.chatwidgetTitleTextColor,fontFamily:on,variant:"h3",children:cn.charAt(0)})}),ne&&(0,o.jsx)(s.A,{placement:"bottom",arrow:!0,title:"Human is online.",children:(0,o.jsx)(i.A,{position:"relative",children:(0,o.jsx)(i.A,{position:"absolute",top:"-10px",right:0,width:12,height:12,bgcolor:"#fff",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",children:(0,o.jsx)(i.A,{width:8,height:8,bgcolor:"#00d500",borderRadius:"50%"})})})})]}),(0,o.jsxs)(i.A,{children:[(0,o.jsx)(l.A,{color:O.chatwidgetTitleTextColor,variant:"h5",fontWeight:"600",fontFamily:on,children:cn}),O.subheading&&(0,o.jsx)(l.A,{color:"".concat(O.chatwidgetTitleTextColor,"AA"),variant:"body1",fontFamily:on,children:O.subheading})]})]}),(0,o.jsxs)(i.A,{display:"flex",alignItems:"center",children:[_t&&(0,o.jsx)(s.A,{placement:"bottom",arrow:!0,title:ae?"Stop Read Aloud":"Turn Read Aloud ".concat(J?"Off":"On"),children:(0,o.jsx)(c.A,{size:"small","aria-label":ae?"Stop read aloud":"Turn read aloud ".concat(J?"off":"on"),onClick:zt,children:ae?(0,o.jsx)(y.A,{fontSize:"small",htmlColor:O.chatwidgetTitleTextColor}):J?(0,o.jsx)(C.A,{fontSize:"small",htmlColor:O.chatwidgetTitleTextColor}):(0,o.jsx)(y.A,{fontSize:"small",htmlColor:O.chatwidgetTitleTextColor})})}),!B&&(0,o.jsx)(s.A,{placement:"bottom",arrow:!0,title:At("DISPLAY_STRINGS.RESET_CONVERSATION","Reset Conversation"),children:(0,o.jsx)("span",{style:{cursor:De?"pointer":"not-allowed"},children:(0,o.jsxs)(c.A,{size:"small",className:"start-chat","data-testid":"start-chat",disabled:!De,"aria-label":At("DISPLAY_STRINGS.RESET_CONVERSATION","Reset conversation"),onClick:Ht,sx:{opacity:De?1:.5},children:[(0,o.jsx)(S.A,{fontSize:"small",htmlColor:O.chatwidgetTitleTextColor}),(0,o.jsx)("span",{className:"visually-hidden",children:"Start a new chat"})]})})}),F&&(0,o.jsx)(s.A,{placement:"bottom",arrow:!0,title:At("DISPLAY_STRINGS.CLOSE","Close"),children:(0,o.jsx)(c.A,{size:"small","aria-label":At("DISPLAY_STRINGS.CLOSE","Close"),onClick:Wt,children:(0,o.jsx)(x.A,{fontSize:"small",htmlColor:O.chatwidgetTitleTextColor})})})]})]}),fe&&(0,o.jsx)(i.A,{position:"relative",sx:{width:"100%"},children:(0,o.jsxs)(i.A,{className:"reset-chat-dialog",position:"absolute",sx:{padding:"16px",zIndex:100,width:"100%",backgroundColor:O.widgetBgColor,borderBottom:"1px solid ".concat(O.widgetBorderColor)},children:[(0,o.jsx)(T.JU7,{style:{color:O.aiMsgTextColor},name:At("DISPLAY_STRINGS.RESET_CONVERSATION","Reset Conversation?")}),(0,o.jsx)(l.A,{id:"reset-dialog-description",variant:"body2",sx:{color:O.aiMsgTextColor,fontFamily:on},children:At("DISPLAY_STRINGS.RESET_CONVERSATION_DESCRIPTION","This will clear all messages and start a fresh conversation. This action cannot be undone.")}),(0,o.jsxs)(u.A,{container:!0,spacing:2,mt:1,children:[(0,o.jsx)(u.A,{size:6,children:(0,o.jsx)(d.A,{variant:"outlined",color:"primary","aria-label":"Cancel reset chat",fullWidth:!0,size:"small",onClick:qt,disabled:he,children:At("DISPLAY_STRINGS.CANCEL","Cancel")})}),(0,o.jsx)(u.A,{size:6,children:(0,o.jsx)(d.A,{disabled:he,onClick:tn,variant:"contained",color:"error",fullWidth:!0,size:"small","aria-label":"Confirm reset chat",children:At("DISPLAY_STRINGS.RESET","Reset")})})]})]})}),(0,o.jsxs)(i.A,{sx:{position:"relative",display:"flex",flex:1,minHeight:0},children:[(0,o.jsx)(i.A,{id:"messagesContainer",className:"chat-widget-body",role:"log","aria-label":"Chat messages","aria-live":"polite","aria-atomic":"false",onScroll:function(e){var t=e.currentTarget,n=t.scrollTop,o=t.scrollHeight,r=t.clientHeight;Re(o-n-r>160)}
1,sx:{"::-webkit-scrollbar":{display:"none"},padding:"10px",paddingBottom:ke?"10px":"0px",overflowY:"auto",flex:1,minHeight:0},children:(0,o.jsx)(We,{isBubble:Se,voiceAllowed:_t,widgetConfigurations:O,sourcePlatform:P,userKey:be,streamingMessage:Ue,isStreaming:ot,isWaitingForResponse:ct,pendingUserMessage:at,setRefetchFunction:rn,setAddLocalMessageFunction:an,isHumanHandoffOn:ne,temporaryMessage:X,showLeadsForm:Mt,widgetDetails:kt,previewOnly:z,chatbotUUID:window.chatbotUUID,parentDomain:It.parentDomain,setHasClosedLeadsForm:ue,refetchWidgetDetails:function(){return jt()},isStreamingEnabled:O.isStreamingEnabled,onHasMessagesChange:Oe},be)}),Me&&(0,o.jsx)(s.A,{title:At("DISPLAY_STRINGS.SCROLL_TO_BOTTOM"),arrow:!0,children:(0,o.jsx)(c.A,{className:"scroll-to-bottom-button","aria-label":At("DISPLAY_STRINGS.SCROLL_TO_BOTTOM"),onClick:function(){return Bt("smooth")},size:"small",sx:{position:"absolute",bottom:1.5,left:"50%",transform:"translateX(-50%)",color:O.aiMsgTextColor,bgcolor:O.aiMessageBgColor,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.14)","&:hover":{bgcolor:O.aiMessageBgColor,filter:"brightness(0.97)"}},children:(0,o.jsx)(w.A,{})})})]}),Z&&(0,o.jsx)(i.A,{role:"alert",sx:{px:2,py:.75,backgroundColor:"#fff3cd",borderTop:"1px solid #ffc107",textAlign:"center"},children:(0,o.jsx)(l.A,{variant:"caption",sx:{color:"#856404",fontSize:11},children:Z})}),(0,o.jsxs)(i.A,{className:"chat-widget-foindexoter",role:"contentinfo","aria-label":"Chat input area",sx:{flexShrink:0},children:[!(ot||ct||ne)&&(!De||O.persistentConversationStarterMessage)&&(0,o.jsx)(Ke,{disabled:Mt||ot||ct,widgetConfigurations:O,setInputMessage:Jt}),!B&&(0,o.jsx)("div",{style:{padding:"10px"},className:"w-100",children:(0,o.jsx)(ie,{ref:ht,className:"chat-widget-input",clear:!0,disabled:Mt||he||ot||ct,onSend:Zt,onChange:function(){},queuedItems:yt,onRemoveQueuedMessage:Qt,filesAllowed:O.imageUploadEnabled,voiceInputAllowed:_t,widgetConfigurations:O,sendMsgButtonImage:(null==O?void 0:O.sendMsgButtonImage)||null})}),!B&&O.showTagline&&(0,o.jsxs)("div",{className:"w-100 widget-tagline",children:[(0,o.jsx)(f.A,{sx:{borderColor:O.widgetBorderColor}}),(0,o.jsx)(l.A,{color:O.taglineColor,variant:"body2",textAlign:"center",sx:{width:"100%",padding:"8px","& a":{color:O.hyperlinkColor}},children:(0,o.jsx)("span",{style:{fontFamily:on},dangerouslySetInnerHTML:{__html:O.tagline||""}})})]})]})]})};var rt=function(e){var t=e.chatbotUUID,n=e.sourcePlatform,r=e.embedType,i=e.previewOnly,a=void 0!==i&&i,l=e.readOnly,s=void 0!==l&&l,c=e.settingConfigurations,u=(0,g.useMemo)((function(){return Qe()}),[]),d=(0,A.vk)(t,!c,u.parentUrl),f=d.data,m=d.isLoading,v=c||f||(0,h.u5)(f||c||null);return(0,g.useEffect)((function(){var e="chat-widget-custom-css",t=document.getElementById(e);if(t&&t.remove(),v.rawCss){var n=document.createElement("style");n.id=e,n.textContent=v.rawCss,document.head.appendChild(n)}}),[v.rawCss]),m?null:(0,o.jsx)(Ie,{children:"bubble"===r?(0,o.jsx)(b,{readOnly:s,sourcePlatform:n,widgetConfigurations:v,previewOnly:a}):(0,o.jsx)(p,{readOnly:s,sourcePlatform:n,widgetConfigurations:v,previewOnly:a})})}},49994:function(e,t,n){n.d(t,{I$:function(){return a},WZ:function(){return r},ph:function(){return l},u5:function(){return o},vZ:function(){return i}});var o=function(e){var t;return{name:(null==e?void 0:e.name)||"Chatbot",chatwidgetTitleTextColor:"#FFFFFF",sendMsgButtonImage:(null==e?void 0:e.sendMsgButtonImage)||null,widgetHeaderBannerImage:null,userMsgTextColor:"#69707A",aiMsgTextColor:"#69707A",userMessageBgColor:"#DAE7FB",aiMessageBgColor:"#E0E5EC",fontSize:16,fontFamily:"system_ui",enableResponseTypingSimulation:(null==e?void 0:e.enableResponseTypingSimulation)||!0,responseTypingSpeed:(null==e?void 0:e.responseTypingSpeed)||10,icon:null,headerGradientColor_1:"#0061F2",headerGradientColor_2:"#5F1A9C",showTagline:(null==e?void 0:e.showTagline)||!1,tagline:(null==e?void 0:e.tagline)||null,taglineColor:"#D9DBDF",chatInputPlaceholder:(null==e?void 0:e.chatInputPlaceholder)||"Ask me anything...",chatInputTextColor:"#69707A",widgetBorderColor:"#E0E5EC",widgetBorderWidth:0,widgetBgPreference:"color",widgetBgColor:"#fff",widgetBgImage:null,widgetInputBgColor:"#fff",hyperlinkColor:"#0964F1",subheading:(null==e?void 0:e.subheading)||"",notificationSound:(null==e?void 0:e.notificationSound)||null,leadsCollectionFormPromptText:(null==e?void 0:e.leadsCollectionFormPromptText)||"",rawCss:'/* Styling for the card containing the lead collection form */\r\n.lead-collection-form-card {\r\n background-color: lightgrey;\r\n border: 1px solid #e0e5ec;\r\n border-radius: 10px;\r\n padding: 10px 20px;\r\n position: absolute;\r\n bottom: 25px;\r\n left: 20px;\r\n right: 20px;\r\n}\r\n\r\n/* Styling for the body section of the lead collection form card */\r\n.lead-collection-form-card-body {\r\n margin: 10px 0;\r\n}\r\n\r\n/* Styling for the input section of the lead collection form */\r\n.lead-collection-form-input-section {\r\n margin-top: 5px;\r\n font-size: 14px;\r\n}\r\n\r\n/* Styling for the labels of the lead collection form inputs */\r\n.lead-collection-form-input-label {\r\n display: block;\r\n margin: 10px 0 1px;\r\n}\r\n\r\n/* Styling for the input fields of the lead collection form */\r\n.lead-collection-form-input-field {\r\n border: 1px solid #ced4da;\r\n border-radius: 4px;\r\n padding: 5px;\r\n width: 100%;\r\n}\r\n\r\n/* Specific styling for checkbox type input fields */\r\n.lead-collection-form-input-field[type="checkbox"] {\r\n width: auto;\r\n}\r\n\r\n/* Styling for the submit button of the lead collection form */\r\n.lead-collection-form-submit-btn {\r\n color: white;\r\n border: none;\r\n border-radius: 4px;\r\n padding: 5px 10px;\r\n cursor: pointer;\r\n text-align: center;\r\n text-decoration: none;\r\n display: inline-block;\r\n background-color: #0061f2;\r\n transition: background-color 0.3s, border-color 0.3s; /* Smooth transition */\r\n}\r\n\r\n/* Hover and focus states for the submit button */\r\n.lead-collection-form-submit-btn:hover,\r\n.lead-collection-form-submit-btn:focus {\r\n background-color: #0052ce;\r\n}',chatBubbleImg:(null==e?void 0:e.chatBubbleImg)||"http://127.0.0.1:8000/static/common/img/icons/chat.svg",chatBubbleColor:"#0000FF",chatAvatarImage:(null==e?void 0:e.chatAvatarImage)||null,userMsgAvatarImage:(null==e?void 0:e.userMsgAvatarImage)||null,useIconImageAsAvatar:(null==e?void 0:e.useIconImageAsAvatar)||!1,enableAiAgentStatusMessages:(null==e?void 0:e.enableAiAgentStatusMessages)||!0,aiAgentStatusMessages:"Agent is reading and analyzing your message...\r\nAgent is checking the knowledge base...\r\nAgent is generating a response...",widgetHeight:(null==e?void 0:e.widgetHeight)||560,widgetWidth:(null==e?void 0:e.widgetWidth)||355,showAvatar:(null==e?void 0:e.showAvatar)||!1,showTimestamp:(null==e?void 0:e.showTimestamp)||!0,displayName:(null==e?void 0:e.displayName)||"Chatbot",initialMessage:(null==e?void 0:e.initialMessage)||"Hi! What can I help you with?",initialMessagePopupDelay:(null==e?void 0:e.initialMessagePopupDelay)||-1,initialMessages:(null==e?void 0:e.initialMessages)||[],mobileInitialMessage:(null==e?void 0:e.mobileInitialMessage)||"Hi! What can I help you with?",mobileInitialMessages:(null==e?void 0:e.mobileInitialMessages)||[],showPopupMessagesOnlyOnce:(null==e?void 0:e.showPopupMessagesOnlyOnce)||!0,chatwidgetPopupDelay:(null==e?void 0:e.chatwidgetPopupDelay)||-1,popupType:(null==e?void 0:e.popupType)||"initial_messages_popup",mobilePopupType:(null==e?void 0:e.mobilePopupType)||"none",mobileInitialMessagePopupDelay:(null==e?void 0:e.mobileInitialMessagePopupDelay)||-1,mobileChatwidgetPopupDelay:(null==e?void 0:e.mobileChatwidgetPopupDelay)||-1,widgetPosition:(null==e?void 0:e.widgetPosition)||"right",close:"http://127.0.0.1:8000/static/common/img/icons/close.svg",defaultIcon:!0,debugMode:(null==e?void 0:e.debugMode)||!1,enableTrace:(null==e?void 0:e.enableTrace)||!1,enableActions:(null==e?void 0:e.enableActions)||!0,enableSoundEffects:(null==e?void 0:e.enableSoundEffects)||!0,conversationStarterMessage:(null==e?void 0:e.conversationStarterMessage)||"",persistentConversationStarterMessage:(null==e?void 0:e.persistentConversationStarterMessage)||!1,imageUploadEnabled:(null==e?void 0:e.imageUploadEnabled)||!1,audioIoEnabled:(null==e?void 0:e.audioIoEnabled)||!1,isStreamingEnabled:null===(t=null==e?void 0:e.isStreamingEnabled)||void 0===t||t,showDataSources:(null==e?void 0:e.showDataSources)||!1}},r={NONE:"none",INITIAL_MESSAGES_POPUP:"initial_messages_popup",CHATWIDGET_POPUP:"chatwidget_popup"},i={NONE:null,POSITIVE:1,NEGATIVE:2},a=[{value:"arial",label:"Arial"},{value:"helvetica",label:"Helvetica"},{value:"times_new_roman",label:"Times New Roman"},{value:"courier_new",label:"Courier New"},{value:"verdana",label:"Verdana"},{value:"georgia",label:"Georgia"},{value:"comic_sans_ms",label:"Comic Sans MS"},{value:"trebuchet_ms",label:"Trebuchet MS"},{value:"arial_black",label:"Arial Black"},{value:"impact",label:"Impact"},{value:"lucida_sans_unicode",label:"Lucida Sans Unicode"},{value:"tahoma",label:"Tahoma"},{value:"courier",label:"Courier"},{value:"cursive",label:"Cursive"},{value:"system_ui",label:"system-ui"},{value:"montserrat",label:"Montserrat"}],l=function(e){return{wordBreak:"break-word",fontSize:e.fontSize,"& pre":{backgroundColor:"transparent !important"},"& code":{borderRadius:"5px !important"},"& a":{color:e.hyperlinkColor},"& h1":{fontSize:e.fontSize+6},"& h2":{fontSize:e.fontSize+5},"& h3":{fontSize:e.fontSize+4},"& h4":{fontSize:e.fontSize+3},"& h5":{fontSize:e.fontSize+2},"& h6":{fontSize:e.fontSize+1},"& p, li, blockquote, pre, code":{fontSize:e.fontSize,fontWeight:"normal",marginBottom:"0px !important"},"& img":{width:"auto",maxWidth:"min(100%, 380px)",height:"auto",margin:"8px 0",borderRadius:"8px",objectFit:"contain",cursor:"pointer",display:"block"}}}},30227:function(e,t,n){n.d(t,{BP:function(){return o},ph:function(){return r},qX:function(){return i}});var o=function(e){try{var t=sessionStorage.getItem(e);if(!t)return null;var n=JSON.parse(t);return!n||Date.now()>=n.expiresAt?(sessionStorage.removeItem(e),null):n.value}catch(e){return console.error("Error in readSessionCache (sessionStorage not available):",e),null}},r=function(e){try{sessionStorage.removeItem(e)}catch(e){console.error("Error in removeSessionCache (sessionStorage not available):",e)}},i=function(e,t,n){try{var o={value:t,expiresAt:Date.now()+n};sessionStorage.setItem(e,JSON.stringify(o))}catch(e){console.error("Error in writeSessionCache (sessionStorage not available):",e)}}},38544:function(e,t,n){n.d(t,{c:function(){return s}});var o=n(49295),r=n(19124),i=n(6765),a=n(21762),l=function(){return l=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},l.apply(this,arguments)},s=function(){function e(e,t,n,o,r,i,l){void 0===r&&(r=!0),void 0===i&&(i=!1),this.websocketClient=null,this.isAPICallInProcess=!1,this.isStreamingInProcess=!1,this.isStreamingEnabled=!0,this.isHumanHandedOff=!1,this.isHuman=!1,this.isInternal=!1,this.chatbotUUID="",this.sourcePlatform="",this.userConversationKey="",this.chatAPIURL=a.n.CHATBOT.INTERNAL_MESSAGE,this.chatbotUUID=e,this.isInternal=r,this.sourcePlatform=n,this.userConversationKey=t,this.isHuman=i,this.responseHandler=o,this.parentInfo=l,this.websocketClient=null}return e.prototype.query=function(e,t,n){var o=this;void 0===n&&(n=!1);var i=e.trim(),a=((null==t?void 0:t.length)||0)>0;return!i&&!a||this.isAPICallInProcess||this.isStreamingInProcess?(console.log("Returning!"),this.isStreamingEnabled):((0,r.f7)(t).then((function(e){var t=n||o.isHumanHandedOff;o.isStreamingEnabled||t?(console.log("Streaming!"),o.queryChatbotViaStreaming(i,e,n)):(console.log("Using API!"),o.queryChatbotViaAPI(i,e,n))}
1)).catch((function(e){console.error("Error converting files:",e)})),this.isStreamingEnabled)},e.prototype.updateUserKey=function(e){this.userConversationKey=e,this.websocketClient&&(this.websocketClient.close(),this.websocketClient=null)},e.prototype.setIsStreamingEnabled=function(e){this.isStreamingEnabled=e},e.prototype.connect=function(){var e,t,n,r,i,a=this,l=null===(t=null===(e=this.websocketClient)||void 0===e?void 0:e.chatbotWebSocket)||void 0===t?void 0:t.readyState;l===WebSocket.OPEN||l===WebSocket.CONNECTING||(null===(n=this.websocketClient)||void 0===n||n.close(),this.websocketClient=new o.a({chatbotUUID:this.chatbotUUID,userConversationKey:this.userConversationKey,sourcePlatform:this.sourcePlatform,parentDomain:null===(r=this.parentInfo)||void 0===r?void 0:r.parentDomain,parentUrl:null===(i=this.parentInfo)||void 0===i?void 0:i.parentUrl},(function(e){"boolean"==typeof(null==e?void 0:e.is_human_handed_off)&&(a.isHumanHandedOff=e.is_human_handed_off),a.responseHandler(e)})))},e.prototype.queryChatbotViaStreaming=function(e,t,n){var o=this;this.isStreamingInProcess=!0;var r=0,i=function(){o.connect();var a=o.websocketClient;if(null==a?void 0:a.isWebSocketOpen()){var l={query:e,chatbot_uuid:o.chatbotUUID,is_internal:o.isInternal,is_human:o.isHuman,user_key:o.userConversationKey,source_platform:o.sourcePlatform,is_human_response:n||o.isHumanHandedOff,chat_files:t,user_timezone:Intl.DateTimeFormat().resolvedOptions().timeZone};return a.sendWebSocketData(l),o.isStreamingInProcess=!1,!0}if(r<3)return r++,console.log("WebSocket not ready, connection attempt (".concat(r,"/").concat(3,")...")),void setTimeout(i,1e3);console.error("WebSocket connection failed after ".concat(3," retries. Falling back to API.")),o.isStreamingInProcess=!1,o.queryChatbotViaAPI(e,t,n)};i()},e.prototype.queryChatbotViaAPI=function(e,t,n){var o=this;this.isAPICallInProcess=!0;var r=l({query:e,chatbot_uuid:this.chatbotUUID,is_internal:this.isInternal,user_key:this.userConversationKey,source_platform:this.sourcePlatform,is_human:this.isHuman,chat_files:t,user_timezone:Intl.DateTimeFormat().resolvedOptions().timeZone},this.parentInfo&&{parent_domain:this.parentInfo.parentDomain,parent_url:this.parentInfo.parentUrl});i.Ay.post(this.chatAPIURL,r).then((function(e){var t;o.isAPICallInProcess=!1;var n=(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.data)||(null==e?void 0:e.data)||{};o.responseHandler(n)})).catch((function(e){var t,n,r,i,a,l;o.isAPICallInProcess=!1;var s=(null===(r=null===(n=null===(t=e.response)||void 0===t?void 0:t.data)||void 0===n?void 0:n.data)||void 0===r?void 0:r.error)||(null===(a=null===(i=e.response)||void 0===i?void 0:i.data)||void 0===a?void 0:a.error)||"An error occurred";o.responseHandler({error:s,stream_ended:!0}),console.error(null===(l=e.response)||void 0===l?void 0:l.data)}))},e.prototype.disconnect=function(){this.websocketClient&&(this.websocketClient.close(),this.websocketClient=null)},e}()},49295:function(e,t,n){n.d(t,{a:function(){return r}});var o=function(){return o=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},o.apply(this,arguments)},r=function(){function e(e,t){var n=e.chatbotUUID,o=e.userConversationKey,r=e.sourcePlatform,i=e.parentDomain,a=e.parentUrl;this.isStreamingEnabled=!0,this.isIntentionalClose=!1,this.shouldReconnect=!0,this.reconnectAttempts=0,this.reconnectTimeoutId=null,this.heartbeatIntervalId=null,this.lastDataSentTimestamp=0,this.dispatchChain=Promise.resolve(),this.HEARTBEAT_INTERVAL_MS=6e4,this.RECONNECT_BASE_DELAY_MS=2e3,this.RECONNECT_MAX_DELAY_MS=15e3,this.RECONNECT_MAX_ATTEMPTS=5,this.chatbotUUID=n,this.userConversationKey=o,this.handleResponse=t,this.chatbotWebSocket=null,this.isHumanHandedOff=!1,this.sourcePlatform=r,this.parentDomain=i,this.parentUrl=a,this.initializeWebSocket()}return e.prototype.dispatchResponse=function(e){var t=this;this.dispatchChain=this.dispatchChain.then((function(){return t.handleResponse(e)})).catch((function(e){console.error("Failed to handle WebSocket message",e)}))},e.prototype.updateUserKey=function(e){this.close(),this.userConversationKey=e,this.isStreamingEnabled=!0,this.isIntentionalClose=!1,this.shouldReconnect=!0,this.reconnectAttempts=0,this.initializeWebSocket()},e.prototype.initializeWebSocket=function(){var e=this;if(this.isStreamingEnabled&&this.shouldReconnect&&(!this.chatbotWebSocket||this.chatbotWebSocket.readyState!==WebSocket.OPEN&&this.chatbotWebSocket.readyState!==WebSocket.CONNECTING)){var t="https:"===window.location.protocol?"wss":"ws",n=encodeURIComponent(this.userConversationKey),o="".concat(t,"://").concat(window.location.host,"/ws/chatbot/stream/").concat(n);this.isIntentionalClose=!1;try{this.chatbotWebSocket=new WebSocket(o)}catch(e){return console.error("WebSocket blocked or unavailable",e),this.chatbotWebSocket=null,void(this.isStreamingEnabled&&this.shouldReconnect&&this.scheduleReconnect())}this.chatbotWebSocket.onopen=function(t){console.log("WebSocket connection established"),e.reconnectAttempts=0,e.clearReconnectTimer(),e.startHeartbeat(),e.initializeChatbotWebSocketData()},this.chatbotWebSocket.onmessage=function(t){try{var n=JSON.parse(t.data);if(n.pong)return;n.is_initializing?(e.isHumanHandedOff=n.is_human_handed_off||!1,e.dispatchResponse(n)):("boolean"==typeof n.is_human_handed_off&&(e.isHumanHandedOff=n.is_human_handed_off),e.dispatchResponse(n))}catch(e){console.error("Failed to parse WebSocket message",e)}},this.chatbotWebSocket.onclose=function(t){e.isIntentionalClose||console.error("Connection closed",t),e.stopHeartbeat(),e.chatbotWebSocket=null,e.isStreamingEnabled&&!e.isIntentionalClose&&e.shouldReconnect&&e.shouldReconnectOnClose(t)&&e.scheduleReconnect()},this.chatbotWebSocket.onerror=function(t){e.isIntentionalClose||console.error("WebSocket error",t)}}},e.prototype.scheduleReconnect=function(){var e=this;if(!this.reconnectTimeoutId&&this.shouldReconnect)if(this.reconnectAttempts>=this.RECONNECT_MAX_ATTEMPTS)console.warn("WebSocket reconnect limit reached (".concat(this.RECONNECT_MAX_ATTEMPTS,"). Stopping retries."));else{var t=Math.min(this.RECONNECT_BASE_DELAY_MS*Math.pow(2,this.reconnectAttempts),this.RECONNECT_MAX_DELAY_MS)+Math.floor(500*Math.random());this.reconnectAttempts+=1,this.reconnectTimeoutId=setTimeout((function(){e.reconnectTimeoutId=null,e.initializeWebSocket()}),t)}},e.prototype.shouldReconnectOnClose=function(e){return!new Set([1002,1003,1007,1008,1009,1010,4401,4403]).has(e.code)||(console.warn("WebSocket closed with 
1non-retryable code ".concat(e.code,". Stopping reconnect.")),!1)},e.prototype.clearReconnectTimer=function(){this.reconnectTimeoutId&&(clearTimeout(this.reconnectTimeoutId),this.reconnectTimeoutId=null)},e.prototype.startHeartbeat=function(){var e=this;this.stopHeartbeat(),this.heartbeatIntervalId=setInterval((function(){e.isWebSocketOpen()&&(Date.now()-e.lastDataSentTimestamp<e.HEARTBEAT_INTERVAL_MS||e.sendWebSocketData({ping:!0}))}),this.HEARTBEAT_INTERVAL_MS)},e.prototype.stopHeartbeat=function(){this.heartbeatIntervalId&&(clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=null)},e.prototype.initializeChatbotWebSocketData=function(){if(this.isWebSocketOpen()){var e=o(o({data_initialisation:!0,chatbot_uuid:this.chatbotUUID,user_key:this.userConversationKey,source_platform:this.sourcePlatform},this.parentDomain&&{parent_domain:this.parentDomain}),this.parentUrl&&{parent_url:this.parentUrl});this.sendWebSocketData(e)}else console.error("Trying to reinitialize WebSocket, but connection is not open.")},e.prototype.isWebSocketOpen=function(){return null!==this.chatbotWebSocket&&this.chatbotWebSocket.readyState===WebSocket.OPEN},e.prototype.sendWebSocketData=function(e){this.isWebSocketOpen()?(this.chatbotWebSocket.send(JSON.stringify(e)),e.ping||(this.lastDataSentTimestamp=Date.now())):console.error("WebSocket connection is not open. Cannot send data.")},e.prototype.close=function(){this.isIntentionalClose=!0,this.shouldReconnect=!1,this.clearReconnectTimer(),this.stopHeartbeat(),this.chatbotWebSocket&&(this.chatbotWebSocket.close(1e3,"Socket closed by client"),this.chatbotWebSocket=null)},e}()},40139:function(e,t,n){var o=function(){function e(){this.audio=null}return e.prototype._binaryStringToUint8Array=function(e){for(var t=e.length,n=new Uint8Array(t),o=0;o<t;o++)n[o]=e.charCodeAt(o);return n},e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e.prototype.playAudio=function(e,t,n,o){var r=this;if(void 0===t&&(t="base64"),void 0===n&&(n=!1),void 0===o&&(o=!1),n&&this.stopAudio(),this.audio&&(this.audio.pause(),this.audio.currentTime=0),"blob"===t){var i=URL.createObjectURL(e);this.audio=new Audio(i)}else if("base64"===t)this.audio=new Audio("data:audio/mp3;base64,".concat(e));else{if("url"!==t)throw new Error("Invalid audio type");this.audio=new Audio(e)}this.audio.play().catch((function(e){console.error("Error playing audio:",e)})),o&&this.audio.addEventListener("ended",(function(){var e;null===(e=r.audio)||void 0===e||e.play().catch((function(e){console.error("Error playing audio:",e)}))}))},e.prototype.stopAudio=function(){this.audio&&(this.audio.pause(),this.audio.currentTime=0)},e}();t.A=o}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.