@deepdesk/deepdesk-sdk 19.5.1-beta.2 → 19.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -80,7 +80,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
80
80
  c6.8-6.8,15.4-10.2,24.7-10.2h11.9v-70c0-44.4,16.2-82.8,47.8-115.2S212.1,0,256.4,0s82.8,16.2,115.2,47.8
81
81
  c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var ES=E(P()),r6={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},EA=({className:e,color:t})=>(0,ES.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ES.jsx)("path",{d:"M172.03 0.0199966H0V86.03C47.5 86.03 86 124.54 86 172.04C86 124.54 124.51 86.03 172.01 86.03C219.51 86.03 258.03 124.54 258.03 172.04C258.03 219.54 219.52 258.05 172.01 258.05C124.5 258.05 86 219.54 86 172.04C86 219.54 47.5 258.05 0 258.05V344.06H172.03C267.04 344.06 344.06 267.04 344.06 172.03C344.06 77.02 267.04 0 172.03 0V0.0199966Z",fill:r6[t||"pink"]})});var CA={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var CS={};ct(CS,{enUS:()=>o6,nlNL:()=>s6});var o6={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},s6={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Ei=E(P()),kA=({onLogIn:e})=>{let t=ie(CS),n=X("floatingMenu"),r=X("productName"),o=we(),s=G(Pt),i=F("FloatingMenu",CA);if(s===null||n===!1)return null;let a=()=>{s===!0?o(ir(!0)):e()};return(0,Ei.jsxs)("button",{type:"button",className:(0,TA.default)(i.root,{[i.isLoggedIn]:s,[i.isLoggedOut]:!s}),onClick:a,children:[(0,Ei.jsx)("div",{className:i.text,children:t(s?"search":"signin",{productName:r})}),(0,Ei.jsxs)("div",{className:i.icon,children:[(0,Ei.jsx)(EA,{className:i.logo,color:"pink"}),s===!1&&(0,Ei.jsx)(bA,{className:i.lock})]})]})};var Im=E(Y());function Gr(e){let{showMidSentenceSuggestions:t,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:r}=e.settings,{text:o,selection:s}=e.input;return s.end<e.input.suggestionTextStart||s.start!==s.end?!1:s.end>=o.length?!0:t?n&&new RegExp(n).test(o.substring(s.end))||r&&new RegExp(r).test(o.substring(0,s.end))?!0:n===!1&&r===!1:!1}var i6={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Em=({ui:e})=>e.overlayCollapsed,RA=Re({name:"ui",initialState:i6,reducers:{setShowTabHint(e,t){e.showTabHint=t.payload},setInputFocus(e,t){e.overlayCollapsedUserOverwrite!==!0&&(t.payload===!0&&(e.overlayCollapsed=!1),e.inputHasFocus=t.payload)},setOverlayCollapsed(e,t){t.payload.collapse===!1&&(e.openOverlayWhenTyping=!1),!(t.payload.skipWhenInputFocus&&e.inputHasFocus)&&(e.overlayCollapsed=t.payload.collapse)},setOpenOverlayWhenTyping(e,t){e.openOverlayWhenTyping=t.payload},setOverlayCollapsedUserOverwrite(e,t){e.overlayCollapsedUserOverwrite=t.payload,e.overlayCollapsed=t.payload}}}),{setShowTabHint:du,setInputFocus:Cm,setOverlayCollapsed:ws,setOpenOverlayWhenTyping:PA,setOverlayCollapsedUserOverwrite:AA}=RA.actions,IA=RA.reducer;var _A={styleRow:"dd-prYfH",styleSuggestion:"dd-JTmXy"};var fu=E(P()),a6=({match:e,selected:t,styles:n})=>(0,fu.jsx)(pe,{as:"button",selected:t,className:n.styleRow,"data-testid":"style-suggestion-item",title:e.suggestion,children:(0,fu.jsx)("span",{className:n.styleSuggestion,children:e.suggestion})}),l6=({matches:e,selectedIndex:t})=>{let n=F("StyleSuggestionList",_A);return(0,fu.jsx)(Tt,{children:e.map((r,o)=>(0,fu.jsx)(a6,{match:r,selected:t===o,styles:n},`${r.keyword}-${o}`))})},Tm=l6;var FA=E(Y());var bs=E(Y());var MA=E(Y());function OA(e,t,n){(0,MA.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var NA={root:"dd-1MBCO",actions:"dd--x4cy",closeIconContainer:"dd-1z5NR",closeIcon:"dd-8qMF-",badge:"dd-4Fpkz",formattedText:"dd-EzvTB",assistantContainer:"dd-j6o8F",formattedTextTruncated:"dd-fv169",assistantBadge:"dd-VD57E"};var pu=E(P()),LA=({title:e})=>(0,pu.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18px",height:"18px",viewBox:"0 0 24 24","aria-labelledby":"closeTitle",children:[(0,pu.jsx)("title",{id:"closeTitle",children:e}),(0,pu.jsx)("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})]});var TS={};ct(TS,{enUS:()=>c6,nlNL:()=>u6});var c6={assistant:[{type:0,value:"Assistant"}],close:[{type:0,value:"Close"}]},u6={assistant:[{type:0,value:"Assistent"}],close:[{type:0,value:"Sluiten"}]};var zn=E(P()),f6=["search","personal-collection-search","search-autocomplete"];function p6(e,t,n,r={}){var s;let o="";return f6.includes(t)?o=KP(gS(e,n,{stripAgentPart:!0}),(s=r.searchKeywords)!=null?s:[n]):o=gS(e,n,r),r.placeholders===!0&&(o=GP(o)),o}var m6=()=>{},g6=({selected:e,suggestion:t})=>{let n=ie(TS),r=X("inlineSuggestions"),o=G(Ls),[s,i]=(0,bs.useState)(!1),a=X("enableSuggestionFeedback"),l=G(S=>S.input.text),c=we(),u=F("TextSuggestion",NA),f=(0,bs.useRef)(null),d=t.source==="assistant",p=a&&!d;(0,bs.useEffect)(()=>{let S=setTimeout(()=>{c(Ab({text:t.text,suggestion:t}))},500);return()=>{clearTimeout(S)}},[t]),OA(f,"click",()=>{c(kn({suggestion:t,text:t.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let h=()=>{c(Fs({source:t.source,text:t.text,assistantCode:t.assistantCode}))},y=(0,bs.useMemo)(()=>p6(t.text,t.source,o,{stripAgentPart:r,placeholders:!0,searchKeywords:t.searchKeywords}),[r,t.text,t.source,o,t.searchKeywords]);return t.source==="gpt"&&!r?null:(0,zn.jsxs)("div",{className:u.root,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[(0,zn.jsx)(pe,{ref:f,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:m6,children:t.source==="assistant"?(0,zn.jsxs)("div",{className:u.assistantContainer,children:[(0,zn.jsx)(vs,{containerTagName:"div",tagName:"span",className:u.formattedTextTruncated,content:y}),(0,zn.jsx)("span",{className:u.assistantBadge,children:n("assistant")})]}):(0,zn.jsx)(vs,{containerTagName:"div",tagName:"span",className:u.formattedText,content:y})}),p&&s&&(0,zn.jsx)("div",{className:u.actions,children:(0,zn.jsx)(Sm,{source:"overlay",context:l,suggestion:t})}),d&&s&&(0,zn.jsx)("div",{className:u.closeIconContainer,children:(0,zn.jsx)("button",{type:"button",className:u.closeIcon,onClick:h,title:n("close"),children:(0,zn.jsx)(LA,{title:n("close")})})})]})},DA=g6;var zA=E(P()),h6=({suggestions:e,selectedIndex:t,reverse:n})=>(0,FA.useMemo)(()=>{let o=e.map((s,i)=>(0,zA.jsx)(DA,{index:i,selected:i===t,suggestion:s},`${s.text}-${s.source}`));return n?o.reverse():o},[e,t,n]),km=h6;var HA={root:"dd-PfvRI",paper:"dd-HYlyY"};var Rm={list:{keywordMatches:[]},fetchState:"idle"},Pm=e=>e.styleSuggestions.list,Ci=ge("styleSuggestions/getAll",(n,r)=>_(null,[n,r],function*({text:e},t){var l;let{deepdeskAPI:o}=t.extra,s=t.getState(),{showStyleSuggestions:i}=s.settings,a=(l=s.conversation.current)==null?void 0:l.profileCode;if(!i)return Rm.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),BA=Re({name:"styleSuggestions",initialState:Rm,reducers:{commitStyleSuggestion(e,t){let{keyword:n,suggestion:r}=t.payload;e.list.keywordMatches=e.list.keywordMatches.filter(o=>o.keyword.toLowerCase()!==n.toLowerCase()||o.suggestion!==r)}},extraReducers:e=>{e.addCase(Ci.pending,t=>{t.fetchState="loading"}).addCase(Ci.rejected,t=>{t.fetchState="error"}).addCase(Ci.fulfilled,(t,n)=>{t.fetchState="done",Bo(t.list,n.payload)||(t.list=n.payload)}).addCase(zs,t=>{t.list=Rm.list}).addCase(ut,()=>Rm)}}),{commitStyleSuggestion:UA}=BA.actions,VA=BA.reducer;var Am=e=>{let t=new Set;return e.filter(({keyword:n,suggestion:r})=>{let o=JSON.stringify([n.toLowerCase(),r]);return t.has(o)?!1:(t.add(o),!0)})};var Ti=E(P()),y6=()=>{var S;let e=(0,Im.useRef)(null),t=F("InlineSuggestionsOverlay",HA),n=G(Gr),r=we(),o=G(Pt),s=G($i),i=G(Em),a=X("showTextSuggestions"),l=G(Ds),c=G(wl),u=X("showStyleSuggestions"),f=X("showStyleSuggestionList"),d=G(Pm),p=u&&f?Am((S=d.keywordMatches)!=null?S:[]):[],h=p.length>0,y=a&&l.length>0;return ms(()=>{setTimeout(()=>{r(ws({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Im.useEffect)(()=>{let g=e.current;if(!g||!g.parentElement)return;g.parentElement.style.left="0px";let m=g.getBoundingClientRect();g.parentElement.style.left=`${Math.min(window.innerWidth-4-m.right,0)}px`}),i||o!==!0||s===!1||!n&&!h||!y&&!h?null:(0,Ti.jsx)("div",{className:t.root,"data-variant":"inline",children:(0,Ti.jsxs)("div",{ref:e,className:t.paper,children:[h&&(0,Ti.jsx)(Tm,{matches:p,selectedIndex:-1}),y&&(0,Ti.jsx)(Tt,{children:(0,Ti.jsx)(km,{suggestions:l,selectedIndex:c})})]})})},WA=y6;var Es=E(Y());var $A={root:"dd-7zvcP",dialogContent:"dd-4C0lK",continueButton:"dd-YUPQW",buttonContinueWrapper:"dd-IKpYs",nicknameInput:"dd-rxhGp",titleWrapper:"dd-nw3nD",title:"dd-5iof5",closeButtonWrapper:"dd-UUAzA",closeButton:"dd-7rjP5",buttonsWrapper:"dd-5e9Xb",errorMessage:"dd--5VgX",errorLink:"dd-u461n"};var kS={};ct(kS,{enUS:()=>v6,nlNL:()=>S6});var v6={title:[{type:0,value:"Enter your nickname"}],close:[{type:0,value:"Close"}],nicknameDialogTitle:[{type:0,value:"Please enter the name you'd like customers to see during chat conversations. This nickname will be used across your Deepdesk environment."}],nicknameDialogInputPlaceholder:[{type:0,value:"Enter your nickname"}],nicknameDialogContinueButton:[{type:0,value:"Continue"}],nicknameDialogError:[{type:0,value:"Nickname cannot be empty or spaces only"}],nicknameDialogEmojiError:[{type:0,value:"You cannot use emojis in this field."}],nicknameDialogSaveError:[{type:0,value:"We couldn't save your details just now. Please try again, or update it at "},{type:1,value:"account"},{type:0,value:".deepdesk.com/admin/user-settings"}],nicknameDialogSaveErrorWithoutLink:[{type:0,value:"We couldn\u2019t save your details just now. Please try again later, or update them in My Deepdesk \u2192 Settings."}]},S6={title:[{type:0,value:"Voer je bijnaam in"}],close:[{type:0,value:"Sluiten"}],nicknameDialogTitle:[{type:0,value:"Voer de naam in die je wilt dat klanten zien tijdens chatgesprekken. Deze bijnaam wordt gebruikt in je Deepdesk-omgeving."}],nicknameDialogInputPlaceholder:[{type:0,value:"Voer je bijnaam in"}],nicknameDialogContinueButton:[{type:0,value:"Doorgaan"}],nicknameDialogError:[{type:0,value:"Bijnaam mag niet leeg of alleen spaties zijn"}],nicknameDialogEmojiError:[{type:0,value:"Je kunt geen emoji's gebruiken in dit veld."}],nicknameDialogSaveError:[{type:0,value:"We konden je gegevens nu niet opslaan. Probeer het opnieuw of werk het bij op "},{type:1,value:"account"},{type:0,value:".deepdesk.com/admin/user-settings"}],nicknameDialogSaveErrorWithoutLink:[{type:0,value:"We konden je gegevens nu niet opslaan. Probeer het opnieuw later, of werk ze bij in My Deepdesk \u2192 Instellingen."}]};var mt=E(P()),jA=({onClose:e,onSave:t,id:n,error:r})=>{let[o,s]=(0,Es.useState)(""),[i,a]=(0,Es.useState)(!1),[l,c]=(0,Es.useState)(!1),u=F("Nickname",$A),f=Es.default.useRef(null),d=G(g=>g.info.showNicknameDialog),p=ie(kS),h=X("adminUrl");(0,Es.useEffect)(()=>{r&&a(!0)},[r]);let y=()=>{if(!f.current)return;o.trim()?f.current.setCustomValidity(""):f.current.setCustomValidity(p("nicknameDialogError")),f.current.reportValidity()},S=g=>{g.preventDefault();let m=o.trim(),v=g.currentTarget.querySelector("#nickname-input");if(!m){v.setCustomValidity(p("nicknameDialogError")),v.reportValidity();return}v.setCustomValidity(""),t(m)};return(0,mt.jsxs)(ja,{isOpen:d,"datatest-id":n,onClose:e||(()=>{}),onBack:e||(()=>{}),children:[(0,mt.jsx)("div",{className:u.titleWrapper,children:(0,mt.jsx)("h1",{className:u.title,children:p("title")})}),(0,mt.jsxs)("form",{className:u.dialogContent,onSubmit:S,children:[(0,mt.jsx)("p",{children:p("nicknameDialogTitle")}),i&&r&&(0,mt.jsx)("div",{className:u.errorMessage,children:h?(()=>{let g=p("nicknameDialogSaveError",{account:h}),m=`${h}.deepdesk.com/admin/user-settings`,v=g.indexOf(m);if(v!==-1){let x=g.substring(0,v),T=g.substring(v+m.length);return(0,mt.jsxs)(mt.Fragment,{children:[x,(0,mt.jsx)("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:u.errorLink,children:m}),T]})}return g})():p("nicknameDialogSaveErrorWithoutLink")}),(0,mt.jsx)("input",{required:!0,minLength:1,maxLength:20,"data-testid":"nickname-input",id:"nickname-input",className:u.nicknameInput,type:"text",placeholder:p("nicknameDialogInputPlaceholder"),value:o,onChange:g=>{c(new RegExp("\\p{Extended_Pictographic}","u").test(g.target.value)),s(g.target.value)},onBlur:y,ref:f}),l&&(0,mt.jsx)("div",{className:u.errorMessage,role:"alert",children:p("nicknameDialogEmojiError")}),(0,mt.jsxs)("div",{className:u.buttonsWrapper,children:[r?(0,mt.jsx)("div",{className:u.closeButtonWrapper,children:(0,mt.jsx)("button",{type:"button",className:u.closeButton,onClick:()=>e==null?void 0:e(),children:p("close")})}):null,(0,mt.jsx)("div",{className:u.buttonContinueWrapper,children:(0,mt.jsx)("button",{type:"submit",className:u.continueButton,disabled:!o.trim()||new RegExp("\\p{Extended_Pictographic}","u").test(o),children:p("nicknameDialogContinueButton")})})]})]})]})};var mu=E(P()),x6=({children:e})=>{let n=X("locale").replace("-","");return(0,mu.jsx)(Ph.Provider,{value:n,children:e})},w6=({store:e,customStyles:t={},children:n})=>(0,mu.jsx)(Cw,{store:e,children:(0,mu.jsx)(x6,{children:(0,mu.jsx)(ul.Provider,{value:t,children:n})})}),Po=w6;var Mm=E(De()),Xa=E(Y());var KA=E(Y());function GA(e,t){let[n,r]=(0,KA.useState)(()=>{if(typeof window=="undefined")return t;try{let s=window.localStorage.getItem(e);return s?JSON.parse(s):t}catch(s){return ee.error(s),t}});return[n,s=>{try{let i=s instanceof Function?s(n):s;r(i),typeof window!="undefined"&&window.localStorage.setItem(e,JSON.stringify(i))}catch(i){ee.error(i)}}]}var qA=()=>/Mac/i.test(navigator.platform);var XA=E(De()),Ao=E(Y());var RS={};ct(RS,{enUS:()=>b6,nlNL:()=>E6});var b6={loginPlease:[{type:8,value:"login",children:[{type:0,value:"Sign in"}]},{type:0,value:" to enable "},{type:1,value:"productName"},{type:0,value:"."}],snooze:[{type:0,value:"Snooze for "},{type:8,value:"min",children:[{type:0,value:"10 minutes"}]},{type:0,value:", "},{type:8,value:"hour",children:[{type:0,value:"1 hour"}]},{type:0,value:" or "},{type:8,value:"day",children:[{type:0,value:"1 day"}]}]},E6={loginPlease:[{type:8,value:"login",children:[{type:0,value:"Log in"}]},{type:0,value:" bij "},{type:1,value:"productName"},{type:0,value:"."}],snooze:[{type:0,value:"Snooze voor "},{type:8,value:"min",children:[{type:0,value:"10 minuten"}]},{type:0,value:", "},{type:8,value:"hour",children:[{type:0,value:"1 uur"}]},{type:0,value:" of "},{type:8,value:"day",children:[{type:0,value:"1 dag"}]}]};var YA={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var Cs=E(P()),PS=(e,t,n)=>r=>(0,Cs.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),C6=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let s=ie(RS),i=pn(),a=F("Login",YA),l=X("productName"),c=X("signInViaPopup"),u=n&&!c,f=(0,Ao.useCallback)(m=>{m.preventDefault(),r&&r(Number.parseInt(m.target.value,10))},[]),d=(0,Ao.useCallback)(m=>{m.preventDefault(),i.send(Yi,!0)},[t]),p=(0,Ao.useMemo)(()=>m=>(0,Cs.jsx)("a",{onClick:x=>{x.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:m},"login"),[t]),h=(0,Ao.useCallback)(m=>(0,Cs.jsx)("button",{type:"button",className:a.anchorButton,onClick:d,children:m},"prompt"),[d]),{min:y,hour:S,day:g}=(0,Ao.useMemo)(()=>({min:PS(a,600,f),hour:PS(a,3600,f),day:PS(a,3600*12,f)}),[]);return(0,Cs.jsxs)("div",{className:(0,XA.default)(e,a.root),children:[s("loginPlease",{login:u?h:p,productName:l}),r&&(0,Cs.jsxs)(Ao.Fragment,{children:[(0,Cs.jsx)("br",{}),s("snooze",{min:y,hour:S,day:g})]})]})},_m=C6;var QA={root:"dd-DoQhb",text:"dd-Jwnev"};var gu=E(P()),T6=({title:e})=>{let t=F("SearchTrigger",QA),n=we(),r=Je();return(0,gu.jsxs)("button",{type:"button",className:t.root,onClick:()=>{n(ir(!0)),r("open search",{via:"autocomplete-overlay"})},children:[(0,gu.jsx)(qa,{}),(0,gu.jsx)("span",{className:t.text,children:e})]})},ZA=T6;var AS={};ct(AS,{enUS:()=>k6,nlNL:()=>R6});var k6={arrowHint:[{type:0,value:"Tip: use arrow keys to navigate suggestions"}],searchHintWindows:[{type:0,value:"Press CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" to search"}],searchHintMac:[{type:0,value:"Press CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" to search"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Close"}],search:[{type:0,value:"Search"}],dismiss:[{type:0,value:"Dismiss"}],dismissError:[{type:0,value:"Dismiss error"}]},R6={arrowHint:[{type:0,value:"Tip: Selecteer suggesties met pijltoetsen"}],searchHintWindows:[{type:0,value:"Druk CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],searchHintMac:[{type:0,value:"Druk CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Sluiten"}],search:[{type:0,value:"Zoeken"}],dismiss:[{type:0,value:"Sluiten"}],dismissError:[{type:0,value:"Foutmelding sluiten"}]};var JA={root:"dd-oa7Vc",isInline:"dd-bwk31",toggleButton:"dd-MSB8Z",toggleButtonWrapper:"dd-ZkCzT",toggleButtonWrapperHidden:"dd-Sq66c",isCollapsed:"dd-vkrPk",collapsible:"dd-CWQJe",hints:"dd-IOoo3",hintsHidden:"dd-psVuT",triggers:"dd-toIoo",triggersRight:"dd-mc4l2",loginError:"dd-KCXeb",loginErrorMessage:"dd-Bv-BG",loginErrorDismiss:"dd-iSCjU"};var Me=E(P()),P6=({onLogIn:e})=>{var W;let t=F("SuggestionsOverlay",JA),n=ie(AS),r=G(Gr),o=G(Pb),s=we(),i=(0,Xa.useRef)(null),a=X("searchTriggerKey"),l=X("productName"),c=G(Em),u=G(Pt),f=G(hb),d=G($i),[p,h]=(0,Xa.useState)(null),y=X("showSearch"),S=X("showTextSuggestions"),g=X("adminUrl"),m=X("isEmbedded"),v=X("suggestionsPlacement"),[x,T]=GA("dd-snooze-until-ms",0),C=c||x>Date.now(),k=G(Ds),R=G(wl),N=X("showStyleSuggestions"),L=X("showStyleSuggestionList"),U=G(Pm),J=N&&L?Am((W=U.keywordMatches)!=null?W:[]):[],Q=J.length>0,M=k.filter(O=>O.source!=="gpt").length,V=()=>{C&&T(0),s(AA(!C))},B=O=>{let q=Date.now()+O*1e3;T(q),ee.info(`Snooze until: ${new Date(q)}`),s(ws({collapse:!0}))};return(0,Xa.useEffect)(()=>{M===0&&h(null)},[k,M]),ms(()=>{s(ws({collapse:!0,skipWhenInputFocus:!0}))}),u===null||d===!1?null:u===!1?(0,Me.jsxs)("div",{ref:i,className:(0,Mm.default)(t.root,{[t.isCollapsed]:C}),children:[!C&&(0,Me.jsxs)("div",{className:t.triggers,children:[(0,Me.jsx)("div",{style:{flex:1}}),(0,Me.jsx)("div",{className:t.triggersRight,children:(0,Me.jsx)(_s,{className:t.toggleButton,title:n("collapse"),onClick:V,isCollapsed:!1})})]}),(0,Me.jsx)("div",{className:t.toggleButtonWrapper,children:(0,Me.jsx)(_s,{className:t.toggleButton,title:n("open",{productName:l}),onClick:V,isCollapsed:!0})}),(0,Me.jsxs)("div",{className:t.collapsible,children:[f&&(0,Me.jsxs)("div",{className:t.loginError,children:[(0,Me.jsx)("span",{className:t.loginErrorMessage,children:f}),(0,Me.jsx)("button",{type:"button",className:t.loginErrorDismiss,onClick:()=>s(xd()),"aria-label":n("dismissError"),children:n("dismiss")})]}),(0,Me.jsx)(_m,{loginUrl:g,isEmbedded:m,onLogIn:e,onSnooze:B})]})]}):!o||!r&&!Q?null:(0,Me.jsxs)("div",{ref:i,className:(0,Mm.default)(t.root,{[t.isCollapsed]:C}),children:[!C&&(0,Me.jsxs)("div",{className:t.triggers,children:[(0,Me.jsx)("div",{style:{flex:1},children:y&&(0,Me.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>h(n(qA()?"searchHintMac":"searchHintWindows",{searchTriggerKey:a.toUpperCase()})),onMouseLeave:()=>h(null),children:(0,Me.jsx)(ZA,{title:n("search")})})}),(0,Me.jsxs)("div",{className:t.triggersRight,onFocus:()=>{},children:[(0,Me.jsx)("div",{className:(0,Mm.default)(!p&&t.hintsHidden,t.hints),children:p}),(0,Me.jsx)(_s,{className:t.toggleButton,title:n("collapse"),onClick:V,isCollapsed:!1})]})]}),(0,Me.jsx)("div",{className:t.toggleButtonWrapper,children:(0,Me.jsx)(_s,{className:t.toggleButton,title:n("open",{productName:l}),onClick:V,isCollapsed:!0})}),(Q||M>0&&S)&&(0,Me.jsxs)("div",{className:t.collapsible,onFocus:()=>{},children:[Q&&(0,Me.jsx)(Tm,{matches:J,selectedIndex:-1}),M>0&&S&&(0,Me.jsx)(Tt,{children:(0,Me.jsx)(km,{suggestions:k,selectedIndex:R,reverse:v==="above"})})]})]})},eI=P6;var jm=E(De());var Mo=E(Y());var Qa=E(Y());function Om(e){return e.contentEditable==="true"}function A6(e){let t=0,n=0,r=window.getSelection();if(r.rangeCount!==0){let o=r.getRangeAt(0),s=o.cloneRange();s.selectNodeContents(e),s.setEnd(o.endContainer,o.endOffset),n=s.toString().length,s.selectNodeContents(e),s.setEnd(o.startContainer,o.startOffset),t=s.toString().length}return{selectionStart:t,selectionEnd:n}}function tI(e){let{selectionStart:t,selectionEnd:n}=Om(e)?A6(e):e;return[t,n]}function nI(e){let[,t]=(0,Qa.useState)(),n=(0,Qa.useRef)(null);return n.current=tI(e),(0,Qa.useEffect)(()=>{let r=()=>{var a;let[o,s]=(a=n.current)!=null?a:[],i=tI(e);(!i||o!==i[0]||s!==i[1])&&(n.current=i,t({}))};return e.addEventListener("keyup",r),e.addEventListener("click",r),e.addEventListener("focus",r),document.addEventListener("selectionchange",r),()=>{e.removeEventListener("keyup",r),e.removeEventListener("click",r),e.removeEventListener("focus",r),document.removeEventListener("selectionchange",r)}},[e]),n.current}function rI(e,t){if(!t)return;let n=e,{value:r}=n,[o,s]=t,i=r.match(qu);if(!i||i.length===0)return;let a=0;i.find(l=>{let c=r.indexOf(l,a);return o>c&&s<c+l.length?(n.selectionStart=c,n.selectionEnd=c+l.length,!0):(a=c+l.length,!1)})}var oI=E(Y()),I6=["div","span","mark","strong","b","i","u","em"];function IS(e,t,n=0){var s;let r=e[e.length-1],o=typeof r=="object"&&r!==null?(s=r.props)==null?void 0:s.tagName:void 0;if(o==="br")return e.pop(),[...e,...t,r];if(I6.includes(o)){let i=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,oI.cloneElement)(r,{children:IS(i,t,n+1)})]}return[...e,...t]}function ki(e){return e.tagName.toLowerCase()==="textarea"}var sI={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var cI=E(De());var Bm=E(Y());var Za=E(Y());function iI(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function Nm(e){let t=(0,Za.useRef)(null),[n,r]=(0,Za.useState)(!1);return(0,Za.useEffect)(()=>{var u;let o=!1,s=Number.parseFloat((u=window.getComputedStyle(document.body).zoom)!=null?u:"1"),[i,a]=iI((f,d)=>{let p=t.current;if(!p)return;let h=f/s,y=d/s,S=p.getBoundingClientRect(),g=h>S.x&&h<S.x+S.width&&y>S.y&&y<S.y+S.height;g&&!o?(o=!0,r(!0)):!g&&o&&(o=!1,r(!1))},({clientX:f,clientY:d})=>[f,d]),[l,c]=iI(()=>{o=!1,r(!1)});return e.addEventListener("mousemove",i),e.addEventListener("mouseleave",l),()=>{a(),c(),e.removeEventListener("mousemove",i),e.removeEventListener("mouseleave",l)}},[t]),[t,n]}function Lm(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Dm(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function aI(e){return e!=null}var lI=E(De()),Fm=E(Y());var Io={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var _S=E(P()),zm=(0,Fm.forwardRef)((o,r)=>{var s=o,{className:e,children:t}=s,n=se(s,["className","children"]);let i=(0,Fm.useRef)(null),a=F("TabCompletion",Io);return(0,_S.jsx)("div",I(b({ref:Dm([i,r]),className:(0,lI.default)(e,a.popoverContentContainer)},n),{children:(0,_S.jsx)("div",{className:a.popoverContent,children:t})}))});var Ts=E(P()),_6=e=>t=>{let n=Q0(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},M6=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let s=F("TabCompletion",Io),i=Qp(),a=(0,Bm.useMemo)(()=>_6(e.getBoundingClientRect()),[e]),[l,c]=Nm(e);return(0,Bm.useEffect)(()=>{c?i.open():i.close()},[c]),(0,Ts.jsxs)("span",{children:[(0,Ts.jsx)("mark",{ref:Dm([l,i.triggerRef]),className:(0,cI.default)(s.matchKeyword,{[s.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:r}),i.opened&&(0,Ts.jsx)(Wa,{className:s.popover,triggerRef:i.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,Ts.jsx)(zm,{style:n,children:(0,Ts.jsx)("div",{className:s.hintText,children:o})})})]})},Hm=class extends To{constructor(){super(...arguments);this.keywordMatches=[];this.preparedKeywordMatches=[];this.usedKeywordMatches=new Set}onBeforeParse(n,r){return r.keywordMatches&&r.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=r.keywordMatches.map(o=>I(b({},o),{keywordRegex:new RegExp(`\\b${Lm(o.keyword)}\\b`,"i")})),this.keywordMatches=r.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let r=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let i=n.match(s.keywordRegex);if(!i)return null;let a=n.charAt(i.index-1),l=n.charAt(i.index+s.keyword.length);return a==="{"&&l==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(aI);if(r.length===0)return null;let o=r.reduce((s,i)=>i.index<s.index?i:s);return this.usedKeywordMatches.add(o.preparedKeywordMatch),o}replaceWith(n,r){return(0,Ts.jsx)(M6,{inputElement:r.inputElement,suggestion:r.suggestion,inputStyle:r.inputStyle,boundaryRef:r.boundaryRef,children:n},`keyword_${r.matchString}_${r.key}`)}asTag(){return"mark"}};var uI=E(De());var MS=E(P()),O6=({inputElement:e,children:t})=>{let n=F("TabCompletion",Io),[r,o]=Nm(e);return(0,MS.jsx)("mark",{ref:r,className:(0,uI.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},Um=class extends To{match(t){let n=t.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(t,n){return(0,MS.jsx)(O6,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var Wm=E(De());var ln=E(Y());var OS=E(P()),dI=()=>(0,OS.jsx)("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:(0,OS.jsx)("path",{fill:"currentColor",d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})});var qr=E(Y());var pI=E(sS());var fI={root:"dd-ky-Bv",content:"dd-kV5e1"};function Vm(e,t,n){var o;let r=((o=e.imageSizes)==null?void 0:o[t])||e.image||n;if(!r)return null;try{return new URL(r).toString()}catch(s){return null}}function NS(e){return e.replace("https://www.","").replace("https://","")}var Zn=E(P()),N6=3,L6=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),D6=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=N6})=>{let s=F("LinkSearch",fI),[i,a]=(0,qr.useState)(""),l=we(),c=G(fA("url")),u=G(Zb("URL")),f=(0,qr.useMemo)(()=>u.map(L6),[u]),[d,p]=(0,qr.useState)(f.length-1),h=X("fallbackImage"),y=v=>{let x=v.target;a(x.value)},S=(v,x)=>{v.stopPropagation(),v.preventDefault(),window.open(x,"_blank")},g=v=>{var C;let x=d-1<0?f.length-1:d-1,T=d+1===f.length?0:d+1;v.code==="Escape"&&(a(""),t()),v.code==="ArrowUp"&&p(x),v.code==="ArrowDown"&&p(T),v.code==="Enter"&&e(((C=f[d])==null?void 0:C.text)||i)},m=(0,qr.useCallback)((0,pI.default)(v=>{l(Hs({query:v,type:"URL",tags:["link-search"]}))},300),[]);return(0,qr.useEffect)(()=>{i&&m(i)},[i]),(0,qr.useEffect)(()=>()=>{l(Id())},[]),(0,Zn.jsxs)("div",{className:s.root,children:[(0,Zn.jsx)(Tt,{withDivider:!0,children:(i?f:c).slice(0,o).map((v,x)=>(0,Zn.jsx)(pe,{selected:d===x,onClick:()=>e(v.text),"data-testid":"linksearch-suggestion",children:(0,Zn.jsxs)(be,{children:[(0,Zn.jsx)(be.Image,{src:Vm(v,"small",h||void 0),title:v.title||v.text}),(0,Zn.jsxs)(be.Content,{className:s.content,cropText:!0,children:[(0,Zn.jsx)(be.Title,{children:v.title||NS(v.text)}),v.title&&NS(v.text)]}),(0,Zn.jsx)(pe.Actions,{children:(0,Zn.jsx)(pe.ActionButton,{label:r,onClick:T=>S(T,v.text)})})]})},v.text))}),(0,Zn.jsx)(Kc,{value:i,onChange:y,autoFocus:!0,placeholder:n,onKeyUp:g})]})},mI=D6;var LS={};ct(LS,{enUS:()=>F6,nlNL:()=>z6});var F6={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}],addToPersonalCollection:[{type:0,value:"Add to Personal Collection"}]},z6={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}],addToPersonalCollection:[{type:0,value:"Toevoegen aan Personal Collection"}]};var Nt=E(P()),H6=(0,ln.forwardRef)((e,t)=>{let n=F("TabCompletion",Io);return(0,Nt.jsx)("mark",{ref:t,className:(0,Wm.default)(n.matchSelection)},"selection-start")}),B6=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let s=ie(LS),i=F("TabCompletion",Io),a=X("addToPersonalCollection"),l=G(Qi("/admin/personal-collection/new")),c=(0,ln.useRef)(null),u=(0,ln.useRef)(null),[f,d]=(0,ln.useState)(null),p=we(),h=Qp(document.activeElement===r),[y]=(0,ln.useState)(()=>document.createRange());h.triggerRef.current=y,(0,ln.useEffect)(()=>()=>y.detach(),[]),(0,ln.useEffect)(()=>{let g=e.current,m=c.current;!g||!m||(y.setStart(g,0),y.setEnd(m,0))},[e.current,c.current]),ms(()=>{h.close()});let S=(0,ln.useCallback)(g=>{let m=y.toString(),v=/^http(s?):\/\//.test(g)?g:`https://${g}`,x=`[${m}](${v})`;p(kn({text:x,suggestion:{text:x,source:"search-url",type:"url"},eventMetrics:{inputType:"mouse"},replace:"selection"}))},[]);return(0,Nt.jsxs)("span",{children:[(0,Nt.jsx)("mark",{ref:c,className:(0,Wm.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":h.opened?"true":"false",children:o}),h.opened&&(0,Nt.jsx)(Wa,{className:i.popoverRoot,triggerRef:h.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,Nt.jsxs)(zm,{style:n,ref:u,children:[(0,Nt.jsxs)("div",{className:(0,Wm.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:f!==null}),children:[(0,Nt.jsxs)("button",{type:"button",tabIndex:f===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>d("insertLink"),children:[(0,Nt.jsx)(dI,{}),(0,Nt.jsx)("span",{children:"\xA0"}),(0,Nt.jsx)("span",{children:s("insertLink")})]}),a&&l&&(0,Nt.jsx)("button",{type:"button",tabIndex:f===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>{let g=y.toString(),m=`${l}?text=${encodeURIComponent(g)}`;window.open(m,"_blank")},children:(0,Nt.jsx)("span",{children:s("addToPersonalCollection")})})]}),f==="insertLink"&&(0,Nt.jsx)(mI,{placeholder:s("linkInputPlaceholder"),visitUrlText:s("visitUrl"),onSelectLink:S,onDismiss:()=>{d(null),h.close()}})]})})]},"selection-end")},$m=class extends To{constructor(){super(...arguments);this.charCount=0;this.foundIndex=0;this.startRef=null}onBeforeParse(n,r){return this.props=r,this.charCount=0,this.startRef=(0,ln.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[r,o]=this.props.selection;if(r===o)return null;let s=this.foundIndex===0?r:o,i=s>=this.charCount&&s<=this.charCount+n.length?{index:s-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let a=this.foundIndex===1;return i&&a?this.charCount+=s-this.charCount:this.charCount+=n.length,i?b({isStart:a},i):null}replaceWith(n,r){return r.isStart?(0,Nt.jsx)(H6,{ref:this.startRef}):(0,Nt.jsx)(B6,{inputElement:r.inputElement,startRef:this.startRef,boundaryRef:r.boundaryRef,inputStyle:r.inputStyle})}asTag(){return"mark"}};var _o=E(P()),U6=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:s,keywordMatches:i,inputElement:a,source:l})=>{let c=F("TabCompletion",sI),u=X("insertLink"),f=X("addToPersonalCollection"),d=X("showMidSentenceSuggestions"),p=X("inlineSuggestions"),h=nI(a),y=(0,Mo.useRef)(null),S=G(Pt);(0,Mo.useEffect)(()=>{ki(a)&&h&&rI(a,h)},[h]);let g=(0,Mo.useCallback)(x=>{if(!o||!n)return x;let T=[(0,_o.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,_o.jsx)("span",{"data-testid":"tab-completion",className:(0,jm.default)(c.tabText,c.resetIndent),"data-source":l,children:n},"tabText")];return r&&T.push((0,_o.jsx)("span",{className:(0,jm.default)(c.hint,c.resetIndent),children:(0,_o.jsx)(ju,{keyCode:"tab"},"tabHint")},"tabHint")),IS(x,T)},[o,n,r]),m=(0,Mo.useMemo)(()=>{let x=[];return(u||f)&&x.push(new $m("selection")),x.push(new Um("placeholders")),s&&x.push(new Hm("keywords")),x},[p,u,f,s]),v=(0,Mo.useMemo)(()=>{let x=window.getComputedStyle(a);return{"--dd-color":x.color,"--dd-font-size":x.fontSize,"--dd-font-family":x.fontFamily,"--dd-font-variant":x.fontVariant}},[]);return!e||!S?null:(0,_o.jsxs)("div",{ref:x=>{x!=null&&x.parentElement&&(y.current=x==null?void 0:x.parentElement)},className:c.root,style:v,children:[(0,_o.jsx)(vs,{tagName:"span",containerTagName:"div",className:(0,jm.default)(c.container,c.agentText),disableLineBreaks:ki(a),content:t||"\u200B",onAfterParse:g,matchers:m,selection:h,keywordMatches:i,inputElement:a,inputStyle:v,boundaryRef:y,inlineSuggestionsOnlyAtEnd:!d}),(0,_o.jsx)("br",{})]},"tab-completion")},V6=e=>{var g,m,v;let{input:t,ui:n,settings:r,styleSuggestions:o,conversation:s}=e,i=ji({input:t}),a=(i==null?void 0:i.text)||"",l=(i==null?void 0:i.source)||"",c=(g=t.html)!=null?g:Ka(t.text),u=t.text.slice(t.suggestionTextStart,t.selection.end),f=a.indexOf(u)===0?a.slice(u.length):"",{showTabHint:d}=n,{isSupported:p}=s,{showTabCompletion:h,visible:y,showStyleSuggestions:S}=r;return{showTabHint:d,showStyleSuggestions:S,showTabCompletion:h&&Gr(e),content:c,tabText:f,source:l,keywordMatches:(v=(m=o.list)==null?void 0:m.keywordMatches)!=null?v:[],enabled:y&&p!==!1}},gI=Ew(V6)(U6);var ks=E(Y());var W6={token:null,interval:null},DS=ge("passwordlessToken/getTemporaryPasswordlessToken",(e,t)=>_(null,null,function*(){let{deepdeskAPI:n}=t.extra;return{token:yield n.requestPasswordlessToken()}})),FS=ge("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(DS()),setInterval(()=>r(DS()),n)}),hI=Re({name:"passwordlessToken",initialState:W6,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(DS.fulfilled,(t,n)=>{t.token=n.payload.token}),e.addCase(FS.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:yI}=hI.actions,vI=hI.reducer;function $6(e){return"buttonText"in e&&"eventName"in e}function SI(e){if(e)return $6(e)?{label:e.buttonText,event:e.eventName,value:e.payload}:e}function j6(e){return e==null?void 0:e.map(t=>SI(t))}function K6(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}var xI=fn([PE,wd],(e,t)=>(t?e.filter(o=>!o.externalConversationId||o.externalConversationId===t):e).map(o=>{var a;let s=SI(o.callToAction),i=j6(o.callToActions);return I(b(b(b(b({text:o.response,title:o.name},s?{callToAction:s}:{}),i!=null&&i.length?{callToActions:i}:{}),o.message!==void 0?{message:o.message}:{}),(a=o.sources)!=null&&a.length?{sources:o.sources}:{}),{editable:o.editable,isLoading:o.isLoading,evaluationId:o.evaluationId,rule:{id:K6(o.code),label:o.code,name:o.name,description:o.name}})}));var Km=E(Y()),HS=E(De());var zS=E(P()),Ja=()=>(0,zS.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,zS.jsx)("path",{d:"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z"})});var wI={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var Yr=E(P()),G6=({entities:e})=>{let t=F("EntitiesWidgetList",wI),[n,r]=(0,Km.useState)(void 0),o=Je(),s=()=>{r(void 0)},i=a=>{e&&(r(e.indexOf(a)),Mr(a.text),o("entity copied",{entity:a,type:"copy"}))};return(0,Km.useEffect)(()=>{let a=setTimeout(s,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,Yr.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,Yr.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>i(a),children:[(0,Yr.jsx)("span",{className:t.entityText,children:a.text}),(0,Yr.jsxs)("span",{className:t.iconWrapper,children:[(0,Yr.jsx)("span",{className:(0,HS.default)(t.icon),children:(0,Yr.jsx)(Ja,{})}),(0,Yr.jsx)("span",{className:(0,HS.default)(t.icon,n===l&&t.iconClicked),children:(0,Yr.jsx)(Ja,{})})]})]},a.text))})},bI=G6;var BS=E(P()),EI=()=>(0,BS.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,BS.jsx)("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});var II=E(Y());var CI={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var TI={root:"dd-nazq3",rotation:"dd-3EHTv"};var RI=E(P()),q6=({size:e=12})=>{let t=F("LoadingSpinner",TI);return(0,RI.jsx)("span",{"data-testid":"loading-spinner",style:{width:`${e}px`,height:`${e}px`},className:t.root})},kI=q6;var US=E(P()),PI=()=>(0,US.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512",fill:"currentColor",children:(0,US.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var hu=E(P()),AI=e=>(0,hu.jsxs)("svg",I(b({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 448 512","aria-labelledby":"checkTitle"},e),{children:[(0,hu.jsx)("title",{id:"checkTitle",children:"Check"}),(0,hu.jsx)("path",{fill:"#666",d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"})]}));var VS={};ct(VS,{enUS:()=>Y6,nlNL:()=>X6});var Y6={error:[{type:0,value:"Something went wrong"}]},X6={error:[{type:0,value:"Er ging iets fout"}]};var Hn=E(P()),Q6=3e3,Z6=({assistantOptions:e})=>{let t=F("OnDemandAssistants",CI),n=ie(VS),r=(0,II.useRef)(),o=we(),s=Nd(mn),i=G(MP),a=Je(),l=i.filter(d=>d.isPinned),c=i.filter(d=>!d.isPinned),u=()=>_(null,null,function*(){return e.attachments&&e.attachments.length>0?e.attachments:o(((d,p,h)=>_(null,null,function*(){let y;if(e.transcript==="in-memory-transcript"){let S=h.dynamicThunkObject.conversationQuery;if(S){let g=yield S();y=Array.isArray(g)?g:void 0}}else Array.isArray(e.transcript)&&(y=e.transcript);return Wh({transcript:y})})))}),f=d=>_(null,null,function*(){clearTimeout(r.current);let p=yield u();a("trigger on demand assistant",{assistantCode:d}),yield s.call(b(I(b({},e),{assistantCode:d}),p.length>0?{attachments:p}:{})),r.current=setTimeout(()=>s.reset(),Q6)});return i.length===0?null:(0,Hn.jsxs)("div",{className:t.root,children:[l.map(({assistant:d,assistantName:p,displayName:h})=>(0,Hn.jsx)("button",{type:"button",className:t.button,disabled:s.state==="loading",onClick:()=>f(d),children:h||p},d)),c.length>0&&(0,Hn.jsxs)(Ye,{placement:"top-end",children:[(0,Hn.jsx)(Ye.Trigger,{className:t.trigger,disabled:s.state==="loading",children:(0,Hn.jsx)(vm,{"data-testid":"trigger"})}),(0,Hn.jsx)(Ye.Content,{className:t.nav,"data-testid":"popover",children:c.map(({assistant:d,assistantName:p,displayName:h})=>(0,Hn.jsx)(Ye.Button,{className:t.item,disabled:s.state==="loading",onClick:()=>f(d),children:h||p},d))})]}),s.state==="loading"&&(0,Hn.jsx)(kI,{}),s.state==="done"&&(0,Hn.jsx)(AI,{"data-testid":"trigger-done"}),s.state==="error"&&(0,Hn.jsx)(JR,{trigger:(0,Hn.jsx)(PI,{}),children:n("error")})]})},_I=Z6;var Ri=E(Y());var yu={};ct(yu,{enUS:()=>J6,nlNL:()=>ez});var J6={useCue:[{type:0,value:"Add to message"}],__summarizerAssistant__:[{type:0,value:"Summary"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},ez={useCue:[{type:0,value:"Voeg toe aan bericht"}],__summarizerAssistant__:[{type:0,value:"Samenvatting"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var WS={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",actions:"dd-9Iqn9",ctaMessage:"dd-ge8nB",thumbsUp:"dd-6QwVx",thumbsDown:"dd-d3E8l",form:"dd-sPNU2",formInput:"dd-F3E4I",formSubmit:"dd-vw5S0",actionButton:"dd-cCWyJ",editableCue:"dd-nWSD-",inputSpace:"dd-DGYB1"};var Lt=E(P()),tz=500,nz=100,rz=({content:e,onChange:t,onCopy:n})=>{let r=(0,Ri.useRef)(null),o=F("WidgetCue",WS);return(0,Ri.useEffect)(()=>{let s=r.current;if(!s)return;s.style.setProperty("height","0px");let i=Math.min(Math.max(s.scrollHeight,nz),tz);s.style.setProperty("height",`${i}px`)},[e]),(0,Lt.jsx)("textarea",{ref:r,className:o.editableCue,onCopy:n,onChange:t,value:e})},oz=({cue:e,onCallToAction:t,onRemove:n,onCopy:r,onUse:o,onSourceClick:s})=>{var S;let i=F("WidgetCue",WS),a=ie(yu),l=Je(),c=X("hasKeyboardInput"),[u,f]=(0,Ri.useState)(e.text),d=g=>{let m=g?I(b({},e),{callToAction:g}):e;t&&t(u,m),n(e)},p=(g,m)=>{r&&r(g,e),m&&Vo(m,i.fadeup)},h=g=>{o&&o(g,e)},y=g=>{g.preventDefault(),g.stopPropagation(),n(e)};return(0,Ri.useEffect)(()=>{l("Assistant response displayed",{evaluationId:e.evaluationId,assistantCode:e.rule.label,assistantOutput:e.text})},[]),(0,Lt.jsxs)(pe,{"data-testid":"cue",children:[(0,Lt.jsx)(be,{children:(0,Lt.jsxs)(be.Content,{children:[e.title&&(0,Lt.jsx)(be.Title,{className:i.title,"data-testid":"widget-cue-title",children:e.rule.label.startsWith("__")?a(e.rule.label):e.title}),e.message&&(0,Lt.jsx)("p",{className:i.ctaMessage,children:e.message}),e.editable?(0,Lt.jsx)(rz,{content:u,onCopy:()=>{let g=document.getSelection();g&&p(g.toString())},onChange:g=>{var m;return f((m=g.target.value)!=null?m:"")}}):(0,Lt.jsx)(gi,{content:e.text,sources:e.sources,onSourceClick:g=>s==null?void 0:s(g,e),useLabel:a("useCue"),copyLabel:a("copyCue"),onCopy:p,onUse:c?h:void 0})]})}),(0,Lt.jsxs)(pe.ButtonsContainer,{children:[(0,Lt.jsxs)("div",{className:i.actions,children:[(0,Lt.jsx)(pe.Button,{onClick:g=>{var m;return p((m=Xd(u,"reply")[0])!=null?m:u,g.target)},variant:"primary",children:a("copyCue")}),e.callToAction&&(0,Lt.jsx)(pe.Button,{onClick:()=>d(),variant:"primary",children:e.callToAction.label}),(S=e.callToActions)==null?void 0:S.map((g,m)=>(0,Lt.jsx)(pe.Button,{onClick:()=>d(g),variant:"primary",children:g.label},`${g.event}-${g.label}-${m}`)),(0,Lt.jsx)(pe.Button,{onClick:y,variant:"secondary",children:a("removeCue")})]}),(0,Lt.jsx)(of,{evaluationId:e.evaluationId,assistantCode:e.rule.label,assistantOutput:e.text,feedbackType:"assistant"})]})]})},MI=oz;var el=E(P()),sz=({cues:e})=>{let t=we(),n=pn(),r=ie(yu),o=Je(),s=u=>{t(Zd({code:u.rule.label})),o("Assistant response closed",{evaluationId:u.evaluationId,assistantCode:u.rule.label,assistantOutput:u.text})},i=(u,f)=>{Mr(u),o("Assistant response copied",{evaluationId:f.evaluationId,assistantCode:f.rule.label,assistantOutput:f.text,copiedText:u})},a=(u,f)=>{var d;f.callToAction&&(t(Qd(f)),o("Assistant call to action",{evaluationId:f.evaluationId,assistantCode:f.rule.label,assistantOutput:f.text,eventName:f.callToAction.event,value:(d=f.callToAction.value)!=null?d:u}))},l=(u,f)=>{var d;n.send(no,{text:u,suggestion:{source:"assistant",assistantCode:(d=f.rule)==null?void 0:d.label,sourceText:u}}),o("Assistant response used",{evaluationId:f.evaluationId,assistantCode:f.rule.label,assistantOutput:f.text,usedText:u})},c=(u,f)=>{o("Assistant source clicked",{evaluationId:f.evaluationId,assistantCode:f.rule.label,source:u})};return(0,el.jsx)(el.Fragment,{children:e.map(u=>u.isLoading?(0,el.jsx)(Jp,{title:u.rule.label.startsWith("__")?r(u.rule.label):u.title},u.rule.id):(0,el.jsx)(MI,{cue:u,onCallToAction:a,onRemove:s,onCopy:i,onUse:l,onSourceClick:c},u.evaluationId))})},OI=sz;var Gm=E(Y());var NI={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var En=E(P());function iz(e,t){return t.split(".").reduce((n,r)=>!n||typeof n!="object"||!(r in n)?null:n[r],e)}var LI=({data:e,schema:t})=>{let n=F("WidgetCustomData",NI),r=o=>{Mr(o)};return(0,Gm.useEffect)(()=>{ee.info("Custom data",e,t)},[e]),(0,En.jsx)("dl",{className:n.root,children:t.map(o=>{let s=iz(e,o.path);return(0,En.jsxs)(Gm.Fragment,{children:[(0,En.jsx)("dt",{className:n.label,children:o.label}),(0,En.jsx)("dd",{className:n.value,children:o.type==="boolean"&&s?(0,En.jsx)("span",{className:n.isTrue,children:o.trueValue}):o.type==="boolean"&&!s?(0,En.jsx)("span",{className:n.isFalse,children:o.falseValue}):o.type==="array"&&Array.isArray(s)&&s.length>0?(0,En.jsxs)("button",{type:"button",onClick:()=>r(s.join(", ")),className:n.copyButton,children:[(0,En.jsx)("span",{className:n.copyButtonText,children:s.join(", ")}),(0,En.jsx)(Ja,{})]}):typeof s=="string"||typeof s=="number"?(0,En.jsxs)("button",{type:"button",onClick:()=>r(`${s}`),className:n.copyButton,children:[(0,En.jsx)("span",{className:n.copyButtonText,children:s}),(0,En.jsx)(Ja,{})]}):"-"})]},o.label)})})};var FI=E(Y());var az=/(https?:\/\/[^\s]+)/,DI=e=>e.split(" ").find(t=>az.test(t));var Jn=E(P()),lz=({suggestion:e,lines:t,onUse:n})=>{var f;let r=e.text||e.url||e.message,o=DI(r),s=ie(iu),i=X("showImages"),a=X("fallbackImage"),l=X("hasKeyboardInput"),c=d=>{d.preventDefault(),d.stopPropagation(),l&&n(r)},u=(0,FI.useCallback)(d=>{window.open(o,"_blank"),d.stopPropagation(),d.preventDefault()},[o]);return(0,Jn.jsxs)(pe,{onClick:l?c:void 0,"data-testid":"edit-suggestion",children:[(0,Jn.jsxs)(be,{children:[i&&e.image&&(0,Jn.jsx)(be.Image,{src:Vm(e,"small",a||void 0),title:e.title}),(0,Jn.jsxs)(be.Content,{children:[e.title&&(0,Jn.jsx)(be.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((f=e.searchKeywords)==null?void 0:f.length)>0&&(0,Jn.jsx)(pe.Labels,{labels:e.searchKeywords}),(0,Jn.jsx)(be.Content,{cropText:t==="single",lineClamp:t==="multiple",children:r})]})]}),(0,Jn.jsxs)(pe.Actions,{children:[o&&(0,Jn.jsx)(pe.ActionButton,{onClick:u,label:s("visitUrl")}),l&&(0,Jn.jsx)(pe.ActionButton,{primary:!0,onClick:c,label:s("useSuggestion")})]})]})},zI=lz;var vu=E(P()),cz=({lines:e,suggestions:t})=>{let n=pn(),r=(o,s)=>{n.send(no,{text:o,suggestion:I(b({},s),{source:s.source,sourceText:s.text})})};return(0,vu.jsx)(vu.Fragment,{children:t.map(o=>(0,vu.jsx)(zI,{suggestion:o,lines:e,onUse:s=>r(s,o)},o.text||o.url||o.message))})},HI=cz;var Su={};ct(Su,{enUS:()=>uz,nlNL:()=>dz});var uz={waiting:[{type:0,value:"Loading\u2026"}],waitingForConversation:[{type:0,value:"Waiting for conversation\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}],close:[{type:0,value:"Close"}]},dz={waiting:[{type:0,value:"Laden\u2026"}],waitingForConversation:[{type:0,value:"Wachten op gesprek\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}],close:[{type:0,value:"Sluiten"}]};var tl={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",footer:"dd-tvofr",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",footerShortcut:"dd-dH7XJ",link:"dd-DRo0x"};var ae=E(P()),BI=(e,t)=>{let n=G(Pt);(0,ks.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},fz=({onLogIn:e})=>{let t=F("Widget",tl),n=X("isEmbedded"),r=X("adminUrl");return(0,ae.jsx)("div",{className:t.loginText,children:(0,ae.jsx)("div",{children:(0,ae.jsx)(_m,{isEmbedded:n,loginUrl:r,onLogIn:e})})},"login")},$S=({text:e})=>{let t=F("Widget",tl);return(0,ae.jsx)("div",{className:t.stateText,children:(0,ae.jsx)("div",{children:(0,ae.jsx)("p",{children:e})})},"notification")},pz=()=>{let e=ie(Su),t=we(),n=F("Widget",tl),r=X("showSearch"),o=X("isEmbedded"),s=G(Qi("/admin/")),i=pn(),a=X("productName"),l=Je();return BI(()=>{if(o)return t(FS()),()=>{t(yI())}},[t,o]),!r&&!s?null:(0,ae.jsxs)("div",{className:n.shortcutList,children:[r&&(0,ae.jsx)(pe.Button,{"data-testid":"shortcut-search","aria-label":e("linkSearch"),className:n.shortcut,icon:(0,ae.jsx)(qa,{}),onClick:()=>{i.send("ShowCommandPalette",{isOpen:!0}),l("open search",{via:"widget-shortcut"})},children:e("linkSearch")}),s&&(0,ae.jsx)(pe.Button,{as:"a",target:"_blank",icon:(0,ae.jsx)(EI,{}),href:s,"data-testid":"shortcut-studio-login","aria-label":e("linkStudioLogin",{productName:a}),className:n.shortcut,rel:"noreferrer",onClick:()=>{l("open my deepdesk",{via:"widget-shortcut"})},children:e("linkStudioLogin",{productName:a})})]})},mz=({title:e,content:t})=>{let n=ie(Su),[r,o]=(0,ks.useState)(!0);return r?(0,ae.jsx)(Rr,{"data-testid":"custom-data-banner",type:"custom-data-banner",title:e,children:(0,ae.jsx)(Tt,{withDivider:!0,children:(0,ae.jsxs)(pe,{children:[(0,ae.jsx)(be,{children:(0,ae.jsx)(be.Content,{children:(0,ae.jsx)(gi,{content:t})})}),(0,ae.jsx)(pe.ButtonsContainer,{children:(0,ae.jsx)(pe.Button,{onClick:()=>o(!1),children:n("close")})})]})})}):null},gz=()=>{let e=we(),t=G(Yc),n=G(NP),r=G(xI),o=G(Ub),s=G(ym),i=G(xm),a=G(gs),l=G(Ir);return(0,ks.useEffect)(()=>{o&&!n&&ee.warn("Custom data provided, but no schema.")},[o,n]),BI(()=>{t.forEach(({type:c})=>{c==="entities"?e(Sr()):Yu.includes(c)||e(xr(c))})},[e,l,a]),(0,ks.useEffect)(()=>{r.length>0&&!t.some(c=>c.type==="cues")&&ee.warn("Received cues, but cues are not configured in widget.")},[t,r]),(0,ae.jsx)(ks.Fragment,{children:t.map(({type:c,title:u,amount:f,lines:d,schema:p,property:h})=>{var y,S;switch(c){case"entities":return s&&s.length>0&&(0,ae.jsx)(Rr,{type:c,title:u,"data-testid":`type-${c}`,children:(0,ae.jsx)(bI,{entities:s})},c);case"cues":return r&&r.length>0&&(0,ae.jsx)(Rr,{type:c,title:u,"data-testid":`type-${c}`,children:(0,ae.jsx)(Tt,{withDivider:!0,children:(0,ae.jsx)(OI,{cues:r})})},c);case"custom-data-banner":return o&&h&&o[h]&&(0,ae.jsx)(mz,{title:u,content:String(o[h])},c);case"custom-data":return o&&p&&(0,ae.jsx)(Rr,{type:c,title:u,"data-testid":`type-${c}`,children:(0,ae.jsx)(Tt,{withDivider:!0,children:(0,ae.jsx)(LI,{data:o,schema:p})})},c);default:return((S=(y=i[c])==null?void 0:y.suggestions)==null?void 0:S.length)>0&&(0,ae.jsx)(Rr,{type:c,title:u,"data-testid":`type-${c}`,children:(0,ae.jsx)(Tt,{withDivider:!0,children:(0,ae.jsx)(HI,{lines:d,contentType:c,suggestions:i[c].suggestions.slice(0,f)||[]})})},c)}})})},jS=({children:e})=>{let t=F("Widget",tl);return(0,ae.jsx)("div",{className:t.footer,children:e})},KS=({children:e})=>{let t=F("Widget",tl);return(0,ae.jsx)("div",{className:t.root,"data-testid":"widget",children:e})},hz=({onLogIn:e,knowledgeAssistOptions:t={},assistantOptions:n={transcript:"in-memory-transcript"},openAdminFeedback:r})=>{let o=ie(Su),s=G($i),i=G(Pt),a=G(wd),l=G(gs),c=G(OP("knowledge-assist")),u=G(LP);return s===!1?(0,ae.jsx)($S,{text:o("notSupported")}):i===!1?(0,ae.jsx)(fz,{onLogIn:e}):i===null?(0,ae.jsx)($S,{text:o("waiting")}):!a||!l?(0,ae.jsx)($S,{text:o("waitingForConversation")}):(0,ae.jsx)(VE,{handler:r,children:(0,ae.jsx)(KS,{children:(0,ae.jsxs)(nm,{initialQuestion:t.initialQuestion,assistantCode:u!=null?u:void 0,evaluateKnowledgeAssistFn:Bl,children:[(0,ae.jsxs)(Hi,{children:[(0,ae.jsx)(pz,{}),(0,ae.jsx)(gz,{}),c&&(0,ae.jsx)(om,{title:c.title,emptyState:t.emptyState})]}),(0,ae.jsxs)(jS,{children:[c&&(0,ae.jsx)(rm,{}),(0,ae.jsx)(_I,{assistantOptions:n})]})]})})})},UI=hz;function nl(e){let t=new Range;return t.selectNodeContents(e),t}function VI(e,t,n){try{return Rs(e,t,n),!0}catch(r){return!1}}function qm(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function Ym(e){return"tagName"in e&&e.tagName==="BR"}var xu=/[\u200B-\u200D\uFEFF]/g;function Rs(e,t,n){let r=new Range;if(e.firstChild===null&&t===0&&n===0)return r.selectNodeContents(e),r;let o=0,s=!1;function i(l,c){let u=-1,f=/[\u200B-\u200D\uFEFF]/;if(!f.test(l))return c;for(let d=0;d<=l.length;d++)if(f.test(l[d])||u++,u===c)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,u=c.replace(xu,""),f=o+u.length,d=t>=o&&t<=f,p=n>=o&&n<=f;if(d){let h=i(c,t-o);h===0&&!p?r.setStartBefore(l):r.setStart(l,h)}p&&(r.setEnd(l,i(c,n-o)),s=!0),o=f;break}case Node.ELEMENT_NODE:{if(Ym(l)&&(o===t&&r.setStartBefore(l),o++,o===n)){r.setEndAfter(l),s=!0;return}for(let u=0;u<l.childNodes.length&&(a(l.childNodes[u]),!s);u++);let c=l.lastChild;qm(l)&&c&&!qm(c)&&!Ym(c)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function wu(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:s,collapsed:i}=t,a,l,c=0;function u(f){let d=f===e,p=f===n,h=f===o;switch(f.nodeType){case Node.TEXT_NODE:{let y=f.textContent;p&&(a=c+y.substring(0,r).replace(xu,"").length),h&&(l=c+y.substring(0,s).replace(xu,"").length),c+=y.replace(xu,"").length;break}case Node.ELEMENT_NODE:{if(Ym(f)&&f.nextSibling){c++;break}!d&&qm(f)&&f.previousSibling&&c++;for(let y=0;y<f.childNodes.length;y++){let S=p&&y===r,g=h&&y===s;if(S&&(a=c),g&&(l=c),l!==void 0||((!S||!i)&&u(f.childNodes[y]),h&&y===s-1&&(l=c),l!==void 0))break}h&&(l=c);break}default:break}}if(u(e),l===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:l,end:l}}function bu(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:s,collapsed:i}=t,a=0,l="";function c(u){let f=u===e,d=u===n,p=u===o;switch(d&&(a=1),u.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let h=d?r:0,y=p?s:void 0;l+=u.textContent.replace(xu,"").substring(h,y);break}case Node.ELEMENT_NODE:{if(!i&&a===1&&Ym(u)&&u.nextSibling){l+=`
82
82
  `;break}!f&&!i&&a===1&&qm(u)&&u.previousSibling&&(l+=`
83
- `);let h=d?r:0,y=p?Math.min(s,u.childNodes.length):u.childNodes.length;for(let S=h;S<y&&(c(u.childNodes[S]),a!==2);S++);break}default:break}p&&(a=2)}return c(e),l}var WI=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(WI||{}),Oo=class{constructor(t){this.element=t;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedSuggestionTextStart=0;this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedSuggestionTextStart=this.getSuggestionTextStart(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(t,n){let r=o=>{n(o)};this.element.addEventListener(t,r),this.disposeHandlers.push(()=>{this.element.removeEventListener(t,r)})}removeEventListener(t,n){this.element.removeEventListener(t,n)}handleInteraction(){let t=this.getText(),n=this.getHTML(),r=this.getSelection(),o=this.getSuggestionTextStart(),s=this.cachedCaretPosition===null;if(!this.isActive)return;t===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit");let i=t!==this.cachedText,a=n!==null&&n!==this.cachedHTML,l=o!==this.cachedSuggestionTextStart;if((i||a||l)&&(i?(this.cachedText=t,this.cachedHTML=n):a&&(this.cachedHTML=n),this.cachedSuggestionTextStart=o,s=!0,this.emit("change",{plainText:t,rawHTML:n,suggestionTextStart:o})),(r.start!==this.cachedSelection.start||r.end!==this.cachedSelection.end)&&(this.cachedSelection=r,s=!0,this.emit("selection",r)),!s)return;let c=this.getCaretPosition();Bo(c,this.cachedCaretPosition)||(this.cachedCaretPosition=c,this.emit("caretposition",c))}handleClick(){this.handleInteraction()}handleFocus(){let t=!this.isFocused;this.isFocused=!0,t&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let t=this.isFocused;this.isFocused=!1,t&&this.emit("blur")}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(WI).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleKeyUp(t){this.handleInteraction(),this.emit("keyup",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let t=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{t.disconnect()})}getSuggestionTextStart(){return 0}focus(){this.element.focus()}emit(t,...n){this.isDisposed||this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r(...n)})}on(t,n){this.isDisposed||(this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n))}off(t,n){if(!this.eventListeners[t])return;let r=this.eventListeners[t].indexOf(n);r!==-1&&this.eventListeners[t].splice(r,1)}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};function $I(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var Pi=class extends Oo{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),bu(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){let n=this.getRootNode();if(n.activeElement!==this.element)return null;let r="getSelection"in n?n.getSelection():window.getSelection();if(!r)return null;let o=r.rangeCount>0?r.getRangeAt(0):null;if(!o)return null;let s=this.element.ownerDocument.createRange();return s.setStart(o==null?void 0:o.startContainer,o==null?void 0:o.startOffset),s.setEnd(o==null?void 0:o.endContainer,o==null?void 0:o.endOffset),!s||!this.element.contains(s.startContainer)||!this.element.contains(s.endContainer)?null:s}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let r=n.getBoundingClientRect();return!$I(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!$I(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return wu(this.element,n);let r=this.lastKnownSelection;if(r&&VI(this.element,r.start,r.end))return r;let o=nl(this.element);return o.collapse(!1),wu(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return bu(this.element,Rs(this.element,n,r))}listen(){super.listen();let n=new MutationObserver(s=>{var i,a;s.length===2&&s[0].addedNodes.length===1&&((i=s[0].addedNodes[0])==null?void 0:i.textContent)==="\u2060"&&((a=s[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let r=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==r&&(r=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}};var yz=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize"];function jI(e,t){let n="mozInnerScreenX"in window,r=document.createElement("div");r.id="input-textarea-caret-position-mirror-div";let o=r.style,s=window.getComputedStyle(e),i=e.ownerDocument.body;o.whiteSpace="pre-wrap",o.wordWrap="break-word",o.position="absolute",o.visibility="hidden",yz.forEach(u=>{o[u]=s[u]}),n?e.scrollHeight>Number.parseInt(s.height)&&(o.overflowY="scroll"):o.overflow="hidden",r.textContent=e.value.substring(0,t);let a=document.createElement("span");a.textContent=e.value.substring(t)||".",r.appendChild(a),i.appendChild(r);let l=e.getBoundingClientRect(),c={top:l.top-e.scrollTop+a.offsetTop+Number.parseInt(s.borderTopWidth)+a.offsetHeight,left:l.left-e.scrollLeft+a.offsetLeft+Number.parseInt(s.borderLeftWidth)};return i.removeChild(r),c}var Ai=class extends Oo{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:r}=this.element;return{start:n,end:r}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return jI(this.element,this.element.selectionEnd)}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=n==null?void 0:n.get)==null?void 0:s.call(this.element)},set:s=>{var i;(i=n==null?void 0:n.set)==null||i.call(this.element,s),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let r=this.element.disabled,o=new MutationObserver(()=>{this.element.disabled!==r&&(r=this.element.disabled,this.emit(r?"disabled":"enabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>o.disconnect())}};function KI(e,t,n){let r=`deepdesk-iframe-${e}`,o=document.getElementById(r);if(o)return o;let s=document.createElement("iframe"),i=new URL(t);return Object.entries(n).forEach(([a,l])=>{i.searchParams.append(a,l)}),s.style.position="absolute",s.style.left="-999em",s.style.width="0px",s.style.height="0px",s.tabIndex=-1,s.id=r,s.title=`iframe-${e}`,s.src=i.toString(),window.document.body.appendChild(s),s}function vz(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var GS=class{constructor(t){this.name=t;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(t)}onMessage(t){this.broadcastChannel.addEventListener("message",t),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",t)})}postMessage(t){this.broadcastChannel.postMessage(JSON.stringify(t))}close(){this.disposeHandlers.forEach(t=>t()),this.broadcastChannel.close()}},qS=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=KI(t,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(t){window.addEventListener("message",t),this.disposeHandlers.push(()=>{window.removeEventListener("message",t)})}postMessage(t){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(t),this.targetOrigin)}close(){var t;this.disposeHandlers.forEach(n=>n()),(t=this.iframe)==null||t.remove()}},YS=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.externalId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setExternalId(t){this.externalId!==t&&(this.cleanup(),ee.info("Set externalId",t),this.externalId=t,this.channel=this.createChannel(t))}createChannel(t){let n=this.params.createCustomChannel?this.params.createCustomChannel(t):this.isCrossOrigin?new qS(t,this.deepdeskUrl,{debug:!0}):new GS(t),r=o=>{var i,a;if(o.origin!==this.deepdeskUrl)return;let s=vz(o.data);typeof s!="object"||s.type!=="event"||s.channel!==t||(ee.info("Received broadcast event",this.externalId,o),(a=(i=this.eventMap)[s.name])==null||a.call(i,s.payload))};return n.onMessage(r),n}send(t,n,r){var i,a;ee.info("Broadcast event",{externalId:this.externalId,name:t,payload:n});let o={type:"event",name:t,payload:n};r!==!1&&((a=(i=this.eventMap)[t])==null||a.call(i,n));let s=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage(I(b({},o),{channel:this.externalId}))}cleanup(t=!1){var n,r;(n=this.channel)==null||n.close(),this.channel=void 0,t&&((r=this.defaultChannel)==null||r.close(),this.defaultChannel=void 0)}},GI=YS;function Sz(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function Ve(e){return Array.isArray(e)?e.map(Ve):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>I(b({},t),{[Sz(n)]:Ve(e[n])}),{}):e}function xz(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Dt(e){return Array.isArray(e)?e.map(Dt):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>I(b({},t),{[xz(n)]:Dt(e[n])}),{}):e}var rl=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var Eu=e=>new Promise(t=>{setTimeout(t,e)});var wr=class extends rl{constructor(){super(...arguments);this.name="ClientError"}},Xm=class extends rl{constructor(){super(...arguments);this.name="ServerError"}},XS=new Map;function qI(e){return _(this,null,function*(){if(e.status===204)return e.text().catch(()=>{}),null;let t=e.headers.get("content-type");if(t!=null&&t.includes("application/json"))return e.json();let n=yield e.text();return n===""?null:(ee.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var Ii=class{constructor(t="",n={}){this.baseUrl=t;this.options=n;this.latestRequestByUrl={};this.refreshingToken=null;this.lastFailedRefreshAt=null;this.failedRefreshCooldown=1e4;var r;this.fetch=(r=n.fetch)!=null?r:window.fetch.bind(window)}patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let s={isAborted:!1,reject:o},i=`${this.baseUrl}${t}`,a=this.fetch,l=n.method===void 0||n.method.toLowerCase()==="get",C=n,{useCache:c=!1,abortLatest:u=!1,attempts:f=1,retryDelay:d=500,refreshTokenOn401:p=!0,retryOnError:h=k=>k instanceof TypeError,retryOnResponse:y=k=>k.status>=500,version:S=null}=C,g=se(C,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(c){if(!l)throw new Error(`Can't use 'useCache' for ${n.method}`);if(XS.has(i)){r(XS.get(i));return}}let m=I(b({credentials:"include"},g),{headers:b({Accept:"application/json","Content-Type":"application/json"},g.headers)});!l&&this.csrfToken&&(m.headers=I(b({},m.headers),{"X-CSRFToken":this.csrfToken})),typeof S=="string"&&(m.headers=I(b({},m.headers),{"X-Deepdesk-API-Version":S}));let v=f,x=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&u&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=s;let T=()=>_(this,null,function*(){return v--,a(i,m).then(k=>_(this,null,function*(){return y(k)&&!s.isAborted&&v>0?(yield Eu(d),T()):k.status===401&&p===!0&&x===!1?(x=!0,yield this.refreshToken(),T()):k})).catch(k=>_(this,null,function*(){if(h(k)&&!s.isAborted&&v>0)return yield Eu(d),T();throw k}))});T().then(k=>_(this,null,function*(){let R=yield qI(k);if(delete this.latestRequestByUrl[i],k.status>=500){o(new Xm("Server Error",R));return}if(k.status===401){o(new wr("Unauthorized",R));return}if(k.status===403){o(new wr("Forbidden",R));return}if(k.status===404){o(new wr("Not Found",R));return}if(k.status>=400){o(new wr("Bad Request",R));return}c&&XS.set(i,R),r(R)})).catch(k=>{o(k)})})}validateToken(){return _(this,null,function*(){let t,n,r;try{({has_valid_access_token:t,is_logged_in:n,has_valid_refresh_token:r}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1}))}catch(o){return!1}if(!t){if(!r)return!1;try{yield this.refreshToken();let{is_logged_in:o}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1});return o}catch(o){return!1}}return n})}refreshToken(){let t=Date.now();return this.lastFailedRefreshAt&&t-this.lastFailedRefreshAt<this.failedRefreshCooldown?Promise.reject(new wr("Unauthorized","Failed to refresh token")):this.refreshingToken?this.refreshingToken:(this.refreshingToken=this.get("/apis/admin/session/refresh/",{refreshTokenOn401:!1}).catch(n=>{throw(n==null?void 0:n.message)==="Unauthorized"&&(this.lastFailedRefreshAt=Date.now()),n}).finally(()=>{this.refreshingToken=null}),this.refreshingToken)}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,b({method:"POST",body:JSON.stringify(n)},r))}postWithStatus(t,n,r){return this.requestWithStatus(t,b({method:"POST",body:JSON.stringify(n)},r))}requestWithStatus(t,n={}){return new Promise((r,o)=>{let s={isAborted:!1,reject:o},i=`${this.baseUrl}${t}`,a=this.fetch,T=n,{useCache:l=!1,abortLatest:c=!1,attempts:u=1,retryDelay:f=500,refreshTokenOn401:d=!0,retryOnError:p=C=>C instanceof TypeError,retryOnResponse:h=C=>C.status>=500,version:y=null}=T,S=se(T,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]),g=I(b({credentials:"include"},S),{headers:b({Accept:"application/json","Content-Type":"application/json"},S.headers)});this.csrfToken&&(g.headers=I(b({},g.headers),{"X-CSRFToken":this.csrfToken})),typeof y=="string"&&(g.headers=I(b({},g.headers),{"X-Deepdesk-API-Version":y}));let m=u,v=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&c&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=s;let x=()=>_(this,null,function*(){return m--,a(i,g).then(C=>_(this,null,function*(){return h(C)&&!s.isAborted&&m>0?(yield Eu(f),x()):C.status===401&&d===!0&&v===!1?(v=!0,yield this.refreshToken(),x()):C})).catch(C=>_(this,null,function*(){if(p(C)&&!s.isAborted&&m>0)return yield Eu(f),x();throw C}))});x().then(C=>_(this,null,function*(){let k=yield qI(C);if(delete this.latestRequestByUrl[i],C.status>=500){o(new Xm("Server Error",k));return}if(C.status===401){o(new wr("Unauthorized",k));return}if(C.status===403){o(new wr("Forbidden",k));return}if(C.status===404){o(new wr("Not Found",k));return}if(C.status>=400){o(new wr("Bad Request",k));return}r({status:C.status,data:k})})).catch(C=>{delete this.latestRequestByUrl[i],o(C)})})}patch(t,n,r){return this.request(t,b({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,b({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,b({method:"DELETE"},n))}};var YI;(t=>{let e;(a=>(a.SUCCESS="success",a.FAILURE="failure",a.CONDITIONS_NOT_MET="conditions_not_met",a.MAX_RECURSION_LEVEL="max_recursion_level",a.NO_ACCESS_TO_ASSISTANT="no_access_to_assistant"))(e=t.EvaluationStatus||(t.EvaluationStatus={}))})(YI||(YI={}));function Qm(e){return I(b({},Ve(e)),{metadata:e.metadata})}var _i=class _i{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new Ii(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,s)=>_(this,null,function*(){let i=yield r(o,s);return this.handleDeepdeskVersionHeaders(i),i}))}preflight(){return _(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(_i.exchangeTokenPromise||(_i.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),_i.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return _(this,null,function*(){var r;yield this.preflight(),ee.info(`Creating conversation for session ${t.externalId} and agent ${t.agentId}`);let n=yield this.client.post("/api/v2/conversations",I(b({chat_start_time:new Date().toISOString()},Dt(t)),{metadata:(r=t.metadata)!=null?r:{}}));return Qm(n)})}upsertConversation(t){return _(this,null,function*(){var u;yield this.preflight(),ee.info(`Upserting conversation for session ${t.externalId} and agent ${t.agentId}`);let{status:n,data:r}=yield this.client.postWithStatus("/api/v2/conversations",I(b({chat_start_time:new Date().toISOString()},Dt(t)),{metadata:(u=t.metadata)!=null?u:{}}),{version:"v2"}),o=Qm(r);if(n===201)return o;let{agentId:s,agentName:i,agentEmail:a,agentNickname:l,metadata:c}=t;return this.updateConversation(o.id,{agentId:s,agentEmail:a,agentName:i,agentNickname:l,metadata:c})})}getMe(){return _(this,null,function*(){let t=yield this.client.get("/apis/admin/session/me/");return Ve(t)})}postIdentity(t){return _(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",Dt(t))})}patchMe(t){return _(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",Dt(t));return Ve(n)})}getProfile(t){return _(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{useCache:!0});return Ve(n)})}getKnowledgeAssistant(t){return _(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{useCache:!0});return Ve(n)})}getContentTypes(){return _(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return Ve(t)})}getAccount(){return _(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{useCache:!0});return Ve(t)})}getPlatformConfig(t){return _(this,null,function*(){let n=t!==void 0?`/platform/config/${t}/`:"/platform/config/",{config:r}=yield this.client.get(n,{useCache:!0});return Ve(r)})}checkUserExists(t){return _(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`,{version:"v1"});return n})}getConversationByExternalId(r){return _(this,arguments,function*(t,n={}){yield this.preflight(),ee.info(`Getting conversation for session ${t}`);let{attempts:o=1,retryDelay:s=1e3}=n,i=yield this.client.get(`/api/v2/conversations/by_external_id/${t}`,{attempts:o,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return ee.info(`Successfully retrieved conversation ${i.id} for session ${t}`),Qm(i)})}isConversationSupported(r){return _(this,arguments,function*(t,n={}){ee.info(`Check if conversation for session ${t} is supported`);let{attempts:o=1,retryDelay:s=1e3}=n;return(yield this.client.get(`/api/v2/conversations/by_external_id/${t}/has_active_profile`,{attempts:o,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500})).has_active_profile})}updateConversation(t,n){return _(this,null,function*(){var s;yield this.preflight();let r=Dt(n);n.metadata&&(r.metadata=(s=n.metadata)!=null?s:{});let o=yield this.client.put(`/api/v2/conversations/${t}`,r);return Qm(o)})}postMessages(t,n){return _(this,null,function*(){yield this.preflight(),yield this.client.post(`/api/v2/conversations/${t}/messages`,n.map(r=>I(b({},Dt(r)),{metadata:r.metadata})))})}sendEvent(t,n){return _(this,null,function*(){yield this.preflight();let a=n,{data:r}=a,o=se(a,["data"]),s=Object.entries(this.latestReceivedDeepdeskVersions).reduce((l,[c,u])=>I(b({},l),{[c]:u}),{}),i=["platform","agentId","agentName","agentEmail","conversationId"].reduce((l,c)=>(o[c]&&(l[c]=o[c]),l),{});return this.client.post("/api/v2/events",Dt(I(b(b({},s),i),{data:r,name:t})),{version:"v2"})})}getEntities(t){return _(this,null,function*(){return yield this.preflight(),yield this.client.post("/api/v2/entities",{messages:t.filter(r=>r.text)})})}getTemporaryExchangeToken(){return _(this,null,function*(){return(yield this.client.get("/apis/admin/session/exchange-token/")).jwt})}exchangeTokenForAccessCookie(t){return _(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t}).catch(n=>{throw ee.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return _(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Dt(n),{refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return _(this,arguments,function*(t,n={},r){if(yield this.preflight(),r==="sticky-messages")throw new Error("Use getPinnedMessages instead");return(yield this.client.post(`/api/v2/conversations/${t}/recommend/${r}`,Dt(n),{abortLatest:!0})).map(i=>I(b({},Ve(i)),{text:i.text||i.url||i.message,source:r,type:r})).filter((i,a,l)=>a===l.findIndex(c=>c.text===i.text))})}isLoggedIn(){return _(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return _(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${t}/autocomplete`,Dt(n),{abortLatest:!0})).map(o=>({score:1,source:o.source,sourceText:o.source_text,text:o.label,trainingJobs:o.training_jobs,searchKeywords:o.search_keywords,type:o.source})).filter((o,s,i)=>s===i.findIndex(a=>a.text===o.text))})}getPinnedMessages(t){return _(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${t}/pinned-messages`,{abortLatest:!0});return Ve(n).map(r=>I(b({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return _(this,null,function*(){let n=yield this.client.post("/api/v2/style-suggestions",Dt(t),{abortLatest:!0,version:"v2"});return Ve(n)})}search(t){return _(this,null,function*(){let n=yield this.client.post(`/api/v2/profiles/${t.profile}/search`,Dt(t));return Ve(n)})}loginWithPassword(t,n){return _(this,null,function*(){yield this.preflight();let r=yield this.client.post("/apis/admin/session/login/",{username:t,password:n},{refreshTokenOn401:!1});return Ve(r)})}logout(){return _(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/logout/",{},{refreshTokenOn401:!1})})}requestLoginByEmail(t){return _(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t});return Ve(n)})}requestPasswordlessToken(){return _(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/");return Ve(t.token)})}getCsrfToken(){return _(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/");return t})}verifyLoginToken(t){return _(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t});return Ve(n)})}evaluateAssistant(t,n){return _(this,null,function*(){var l,c,u;yield this.preflight();let r=new URLSearchParams;n!=null&&n.externalConversationId&&r.append("external_conversation_id",n.externalConversationId);let o=n!=null&&n.threadId?`/api/v2/assistants/${t}/threads/${n==null?void 0:n.threadId}/evaluate?${r.toString()}`:`/api/v2/assistants/${t}/evaluate?${r.toString()}`,s=f=>Dt(f),i=(l=n==null?void 0:n.transcript)==null?void 0:l.map(f=>{var d;return b({source:f.source,text:f.text},(d=f.attachments)!=null&&d.length?{attachments:f.attachments.map(s)}:{})}),a=yield this.client.post(o,b({input:(c=n==null?void 0:n.input)!=null?c:{},conversation:i},(u=n==null?void 0:n.attachments)!=null&&u.length?{attachments:n.attachments.map(s)}:{}));return Ve(a)})}createAssistantThread(t){return _(this,null,function*(){yield this.preflight();let{assistantCode:n}=t,r=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return Ve(r)})}postMessageToAssistantThread(t){return _(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:r,message:o}=t,s=yield this.client.post(`/apis/admin/assistants/${n}/threads/${r}/messages/`,{content:o,role:"user"});return Ve(s)})}translateMessages(t){return _(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/v2/translate",Dt(t));return Ve(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),s=o.match(aw);if(!n||!s)return;let i=s[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&ee.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};_i.exchangeTokenPromise=null;var No=_i;var Zm=class{constructor(t){this.options=t;this.socket=null;this.maxReconnectAttempts=5;this.reconnectInterval=25e3;this.cleanupCallbacks=[];var n,r;this.socket,this.eventListeners=new Map,this.url=t.url,this.maxReconnectAttempts=(n=t.maxReconnectAttempts)!=null?n:this.maxReconnectAttempts,this.reconnectInterval=(r=t.reconnectInterval)!=null?r:this.reconnectInterval,this.shouldReconnect=t.shouldReconnect}connect(){let t=()=>this.cleanup();window.addEventListener("beforeunload",t),this.cleanupCallbacks.push(()=>window.removeEventListener("beforeunload",t)),this.reconnect()}setupListeners(){this.socket&&(this.socket.onmessage=t=>{var n;try{let r=Ve(JSON.parse(t.data));r.event&&this.eventListeners.has(r.event)&&((n=this.eventListeners.get(r.event))==null||n.forEach(o=>o(r.data)))}catch(r){console.error("Error parsing WebSocket message:",r)}},this.socket.onclose=t=>{console.log("WebSocket connection closed:",t),setTimeout(()=>{this.reconnect()},this.reconnectInterval)},this.socket.onerror=t=>{console.error("WebSocket error:",t)})}reconnect(){var t,n;if(this.maxReconnectAttempts<=0){console.error("Max reconnect attempts reached, closing WebSocket connection."),(t=this.socket)==null||t.close();return}if(!this.shouldReconnect()){console.error("Should not reconnect, closing WebSocket connection."),(n=this.socket)==null||n.close();return}this.socket&&(this.socket.onmessage=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.close()),this.socket=new WebSocket(this.url),this.setupListeners(),this.maxReconnectAttempts--}send(t,n){if(!this.socket){console.error("WebSocket connection is not open.");return}this.socket.send(JSON.stringify({event:t,data:n}))}on(t,n){this.eventListeners.has(t)||this.eventListeners.set(t,[]);let r=this.eventListeners.get(t);r&&!r.includes(n)&&r.push(n)}close(){var t;(t=this.socket)==null||t.close()}cleanup(){this.close(),this.cleanupCallbacks.forEach(t=>t()),this.cleanupCallbacks=[]}};var XI={startTime:null,stopTime:null},QI=e=>e.handlingTime,ZI=Re({name:"handlingTime",initialState:XI,reducers:{handlingTimeStart(e){if(e.startTime&&!e.stopTime)throw new Error("Timing already started");e.startTime=new Date,e.stopTime=null},handlingTimeStop(e){if(!e.startTime)throw new Error("Timing not started");e.stopTime=new Date},handlingTimeReset(e){e.startTime=null,e.stopTime=null}},extraReducers:e=>{e.addCase(ut,()=>XI)}}),{handlingTimeStart:JI,handlingTimeStop:Jm,handlingTimeReset:e_}=ZI.actions,t_=ZI.reducer;var n_=(e={})=>{let t=b({onAuthError:Wi(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var r_=(e={})=>{let t,n=!0,r=b({getStyleSuggestions:Ci,debounce:500},e);return o=>s=>i=>{var p;let a=o.getState().input.text,l=s(i),c=o.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:u}=c.settings;if(!((p=c.conversation.current)==null?void 0:p.id)||!u)return l;let{text:d}=c.input;return d===a&&!n||(clearTimeout(t),d==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:d}))},e.debounce)),l}};function wz(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end&&e.suggestionTextStart===t.suggestionTextStart}var o_=(e={})=>{let t=b({getTextSuggestions:xr,getAutocompleteSuggestions:cu,debounce:200,check:Gr},e),n;return r=>o=>s=>{var y;let{input:i}=r.getState(),a=o(s),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:u}=l.settings,f=(y=l.conversation.current)==null?void 0:y.id,d=s.type===wm.toString();if(!f||!c&&!u)return a;let{input:p}=l;return wz(p,i)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let S=Ls(l);S===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(S))},d?0:t.debounce)),a}};var s_=Ci.fulfilled.toString();function bz(e,t){let n=new Set([...t.keywordMatches.map(o=>o.keyword)]),r=[];return n.forEach(o=>{let s=e.keywordMatches.filter(l=>l.keyword===o),i=t.keywordMatches.filter(l=>l.keyword===o),a=i.length-s.length;a<=0||r.push(...i.slice(0,a))}),r}var i_=e=>t=>n=>r=>{var c;if(r.type!==s_){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let s=t.getState(),i=s.styleSuggestions.list,a=(c=s.conversation)==null?void 0:c.current;if(o===i)return;let l=bz(o,i);r.type===s_&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var Ez=Ju({assistants:LE,auth:xb,conversation:kb,contentTypes:_P,passwordlessToken:vI,entities:sA,handlingTime:t_,info:qb,input:zb,settings:FE,profile:DP,search:eE,styleSuggestions:VA,ui:IA,textSuggestions:gA});function a_(e){return ab({reducer:Ez,middleware:t=>{var r;let n=t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI}},serializableCheck:!1}).concat(n_()).concat(o_({debounce:200})).concat(r_({debounce:500})).concat(i_(e.deepdeskAPI));return((r=e.middleware)!=null?r:[]).reduce((o,s)=>o.concat(s),n)},preloadedState:e.preloadedState})}function l_(e,t,n){if(t==="")return null;let r=new RegExp(`\\b${Lm(t)}\\b`,"gi"),o,s=null;for(;(o=r.exec(e))!==null&&!(o.index>n);)s={start:o.index,end:o.index+o[0].length};return s}var Cz=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},Tz=e=>t=>n=>r=>{var l,c,u,f,d,p;let o=t.getState(),s=Ws("inlineSuggestions")(o),i=Ws("autoSelectSuggestion")(o)||s;switch(r.type){case Wi.toString():{!r.payload&&e.emit("logout",void 0);break}case Sd.fulfilled.toString():{e.emit("logout",void 0);break}case Sr.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:(l=o.conversation.current)==null?void 0:l.id,data:{entities:r.payload}});break;case zs.toString():e.logSendMessage(r.payload);break;case Qd.toString():e.emit("call-to-action",{cue:r.payload});break;case mn.fulfilled.toString():if(!r.isBroadcasted){let{externalConversationId:h,currentExternalIdAtRequest:y}=(c=r.payload)!=null?c:{};(!h||!y||h===y)&&e.broadcast(vh,r,!1)}break;case mn.rejected.toString():break;default:break}let a=n(r);switch(r.type){case zs.toString():e.handleAfterSendMessage(r.payload);break;case du.toString():e.onUpdateShowTabHint(r.payload);break;case Jm.toString():e.logHandlingTime();break;case Ki.toString():e.broadcast(Md,r);break;case Fs.toString():e.broadcast(Md,r);break;case Zd.toString():t.dispatch(Fs({source:"assistant",assistantCode:r.payload.code}));break;case"analytics/logEvent/fulfilled":{let h=o.assistants.cues.find(y=>y.code===r.meta.arg.data.assistantCode);e.emit("event",I(b({},r.meta.arg),{cue:h}));break}case kn.toString():{let{start:h,end:y}=o.input.selection;e.emit("select-suggestion",I(b({type:Cz(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:h,end:y}:{start:0,end:y}})),s&&t.dispatch(Uo([]));break}case UA.toString():{let{keyword:h,suggestion:y,eventMetrics:S}=r.payload,{text:g,selection:m}=o.input,v=l_(g,h,(u=m==null?void 0:m.end)!=null?u:g.length);if(!v)break;e.emit("select-suggestion",{text:y,type:"style",replace:v,suggestion:{text:y,source:"style"},eventMetrics:S});break}case Td.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(f=o.conversation.current)==null?void 0:f.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case Uo.toString():{i&&r.payload.length>0&&t.dispatch(kd(0));break}case mn.fulfilled.toString():{let{evaluationId:h,output:y,externalConversationId:S}=r.payload,g=r.meta.arg.assistantCode;if(e.emit("event",{name:"Assistant evaluation completed",data:{evaluationId:h,assistantCode:g,assistantOutput:IE(y),externalConversationId:S,evaluationStatus:"success"}}),!r.meta.arg.skipState){let m=t.getState().assistants.cues;e.emit("cues",m)}break}case mn.rejected.toString():{let h=r.meta.arg.assistantCode,y=(p=r.meta.arg.externalConversationId)!=null?p:(d=t.getState().conversation.current)==null?void 0:d.externalId;e.emit("event",{name:"Assistant evaluation completed",data:{evaluationId:"",assistantCode:h,assistantOutput:"",externalConversationId:y,evaluationStatus:"failed"}});break}default:break}return a},c_=Tz;function QS(e){return e.toISOString().replace("T"," ").replace("Z","")}var kz=(e,t)=>t.version,u_=fn([Gi,Ir,QI,kz],(e,t,n,r)=>{if(!t)return ee.warn("No conversationId for handling time metrics"),null;let{startTime:o,stopTime:s}=n;return!o||!s?(ee.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:t,clientVersion:r,agentId:e==null?void 0:e.agentId,agentName:e==null?void 0:e.agentName,agentEmail:e==null?void 0:e.agentEmail,timeStart:QS(o),timeStop:QS(s)}});function d_(e,t){let{text:n,metrics:{numPaste:r,pastes:o,textSuggestions:s}}=e.input,i=n.length;return{source:"agent",clientVersion:t.version,pastes:o,lenTextTotal:i,numPastes:r,suggestions:s}}var Cu=class extends Error{};function Rz(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}var eg=class{constructor(){this.queues={}}push(t,n){let r=()=>{let s=this.queues[t][1];s?(this.queues[t]=[s.promise,null],s.resolve()):delete this.queues[t]};if(!this.queues[t]){let s=n().finally(r);return this.queues[t]=[s,null],s}this.queues[t][1]&&this.queues[t][1].reject(new Cu("Queued async function is outdated"));let o=Rz();return this.queues[t][1]=o,o.promise.then(()=>n().finally(r))}};function ZS(e,t){var s;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return ZS(r,t);let o=(s=e.ownerDocument.defaultView)==null?void 0:s.frameElement;return o?ZS(o,t):null}function JS(e,t){return ZS(e,t)}var Pz={accepted:"onConversationAcceptedAssistants","new-message":"onConversationNewMessageAssistants",ended:"onConversationEndedAssistants"},f_=(e,t)=>{var o,s,i;if(!((i=(s=(o=e.uiConfig)==null?void 0:o.widget)==null?void 0:s.types.find(a=>a.type==="cues"))==null?void 0:i.isActive))return ee.warn("Triggered a conversation assistant, but cues are not configured in widget."),[];let r=e[Pz[t]];return r&&r.length>0?r.map(a=>a.code):(ee.warn(`No assistant set in profile for conversation event "${t}"`),[])};function p_(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function Az(e){return typeof e=="object"&&e!==null&&"tagName"in e}function tg(e){return Az(e)&&(ki(e)||Om(e))}var g_,Xr=new Map,Iz=["bottom","height","left","right","top","width"],m_=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:Iz.some(n=>e[n]!==t[n]);function h_(e){var n,r,o;if(e.ownerDocument===document)return[];let t=(o=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)!=null?o:null;return t?[t,...h_(t)]:[]}function y_(e,t){return!e||!t?null:I(b({},e),{top:e.top+t.top,left:e.left+t.left})}var ng=!1,v_=()=>{ng=!0;let e=[];if(Xr.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Xr.delete(n);return}let r=n.getBoundingClientRect();m_(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(y_,t.rect):t.rect;m_(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Xr.size===0){ng=!1;return}g_=window.requestAnimationFrame(v_)};function ex(e,t){let n=h_(e),r=[],o=n.map((s,i)=>ex(s,a=>{r[i]=a;let l=Xr.get(e);if(!l)return;let c=r.reduce(y_,l.rect);l.callbacks.forEach(u=>u(c))}));return{observe(s=!0){if(o.forEach(i=>i.observe(!1)),Xr.has(e)){let i=Xr.get(e);i.callbacks.push(t),i.rect&&t(i.rect)}else Xr.set(e,{rect:void 0,callbacks:[t],parentRects:r});s&&!ng&&v_()},unobserve(){o.forEach(i=>i.unobserve());let s=Xr.get(e);if(s){let i=s.callbacks.indexOf(t);i>=0&&s.callbacks.splice(i,1),s.callbacks.length||Xr.delete(e),Xr.size||(cancelAnimationFrame(g_),ng=!1)}}}}var S_,Qr=new Map,x_=()=>{Qr.forEach((e,t)=>{if(!t.isConnected){Qr.delete(t);return}let{clientHeight:n,scrollHeight:r}=t,o=r>n;e.visible!==o&&(e.visible=o,e.callbacks.forEach(s=>s(e.visible)))}),Qr.size!==0&&(S_=window.requestAnimationFrame(x_))};function w_(e,t){return{observe(){let n=Qr.size===0;Qr.has(e)?Qr.get(e).callbacks.push(t):Qr.set(e,{visible:void 0,callbacks:[t]}),n&&x_()},unobserve(){let n=Qr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Qr.delete(e),Qr.size||cancelAnimationFrame(S_)}}}}var tx=["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth","borderStyle","boxSizing","color","overflowWrap","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontWeight","fontKerning","lineHeight","letterSpacing","paddingLeft","paddingTop","paddingRight","paddingBottom","width","height","textIndent","whiteSpace","wordBreak","wordSpacing","wordWrap"];function nx(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function ol(e){return Number.parseFloat(e)}function rg(e){return Math.round(e*1e6)}function b_(e){return e/1e6}function rx(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=ol(e.width),s=ol(e.borderLeftWidth),i=ol(e.borderRightWidth),a=ol(e.paddingRight),l=b_(rg(o)-rg(s)-rg(i)),c=b_(rg(r));if(l-c>2){let u=l-c;n.style.paddingRight=`${a+u}px`}}function Tu(e,t={}){var u,f;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(u=t.position)!=null?u:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",mi(n);let r=window.getComputedStyle(e),o=!0,s=()=>{n.scrollTop=e.scrollTop};nx(r,n,tx),rx(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",s));let i=w_(e,()=>{nx(r,n,tx),rx(r,e,n),s(),setTimeout(s,0)}),a,l=!0,c=ex(e,d=>{if(d===null){t.onRemove&&t.onRemove(),n.remove();return}if(!l&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(nx(r,n,tx),rx(r,e,n),s(),t.placement==="below"&&n.classList.add("below"),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let p=t.closestScrollElement.getBoundingClientRect(),h=window.getComputedStyle(t.closestScrollElement),y=ol(h.borderTopWidth),S=ol(h.borderBottomWidth),g=p.top+y-d.top,m=d.top+d.height+-(p.top+p.height-S);n.style.clipPath=`inset(${g}px 0px ${m}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(f=e.parentElement)==null||f.appendChild(n),c.observe(),i.observe(),[n,()=>{e.removeEventListener("scroll",s),c.unobserve(),i.unobserve(),n.remove()}]}function _z(e){return e.offsetParent!==null}function E_(e){if(!_z(e))return!1;let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}function og(e,t,n=100){let r=E_(e);t({isVisible:r});let o=setInterval(()=>{let s=E_(e);s!==r&&(r=s,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var C_=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch(r){return t}}catch(n){return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch(r){ee.warn("[Deepdesk] SessionStorage is blocked by browser")}}});var ke=E(P());var T_=C_("showTabHint",!0),sl=class sl{constructor({deepdeskUrl:t,version:n=sl.version||"unknown",locale:r="en-US",token:o,fetch:s,productName:i,createCustomChannel:a,websocketClient:l=Zm}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.disposeHandlers=[];this.inlineSuggestions=null;this.aboveSuggestions=null;this.belowSuggestions=null;this.floatingMenu=null;this.widgetElement=null;this.widgetRoot=null;this.nicknameDialogUnsubscribe=null;this.nicknameDialogFailed=!1;this.dynamicThunkObject={};this.queues=new eg;this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let c=t.replace(/\/api$/,"");this.deepdeskApi=new No(c,{token:o,fetch:s}),this.version=n,this.instanceId=sl.count++;let u={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[c_({broadcast:(h,y,S)=>{this.broadcastEvents.send(h,y,S)},emit:(h,y)=>this.emit(h,y),handleAfterSendMessage:h=>this.handleAfterSendMessage(h),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:h=>this.logSendMessage(h),onUpdateShowTabHint:h=>T_.update(h),sendEvent:(h,y)=>this.deepdeskApi.sendEvent(h,y)})]};this.store=a_(u),this.broadcastEvents=new GI({debug:!0,deepdeskUrl:c,eventMap:tE(this.store),createCustomChannel:a}),this.disposeHandlers.push(()=>{this.broadcastEvents.cleanup()}),this.ws=new l({url:`${c}/api/v2/me/realtime`.replace("https","wss"),reconnectInterval:25e3,shouldReconnect:()=>_(this,null,function*(){var h;return(h=Pt(this.state))!=null?h:!1})}),this.whenLoggedIn(()=>this.ws.connect()),this.store.dispatch(du(T_.value())),this.store.dispatch(Jd({locale:r,adminUrl:c,productName:i}));let f=[],d=h=>{if(!h.conversationId)return;let y=()=>{this.conversationId()===h.conversationId&&this.store.dispatch(NE(h))};this.hasConversation()?y():f.push(y)};this.ws.on("assistants::direct_response",d),this.ws.on("assistants::user_notification",d),this.ws.on("assistants::response_chunk",h=>{if(!h.conversationId)return;let y=()=>{this.conversationId()===h.conversationId&&this.store.dispatch(OE(h))};this.hasConversation()?y():f.push(y)}),this.ws.on("assistants::suggest_as_reply",h=>{if(!h.conversationId)return;let y=()=>{this.conversationId()===h.conversationId&&this.store.dispatch(Ki([{text:h.payload.message,type:"text",source:"assistant",assistantCode:h.code,sourceLabel:h.name}]))};this.hasConversation()?y():f.push(y)});let p=this.whenConversationLoaded(()=>{var h;this.broadcastEvents.setExternalId((h=this.state.conversation.current)==null?void 0:h.externalId),f.forEach(y=>y()),f.length=0});this.disposeHandlers.push(()=>{this.ws.cleanup(),f.length=0,p()})}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var t;return(t=Ds(this.state)[this.state.input.selectedSuggestionIndex])!=null?t:null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}externalId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.externalId}shouldAbort(){return this.state.conversation.isSupported===!1?(ee.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(ee.warn("Profile has not been loaded (yet)"),!0):(ee.warn("No conversation loaded (yet)"),!0)}whenLoggedIn(t){if(Pt(this.state))t();else{let n=this.subscribe(Pt,r=>{r&&t()});this.disposeHandlers.push(()=>{n()})}}login(){return this.store.dispatch(Wi(null)),this.store.dispatch(to()),new Promise(t=>{this.whenLoggedIn(()=>t())})}isLoggedIn(){return _(this,null,function*(){return(yield this.store.dispatch(to())).payload})}isConversationSupported(t,n){return _(this,null,function*(){return(yield this.store.dispatch(dh({externalId:t,options:n}))).payload})}createConversation(t){return _(this,null,function*(){var r;return this.hasConversation()&&this.externalId()!==t.externalId&&this.resetConversation(),(yield this.store.dispatch(bd(I(b({},t),{metadata:(r=t.metadata)!=null?r:{}})))).payload})}getConversationByExternalId(t,n){return _(this,null,function*(){return this.hasConversation()&&this.externalId()!==t&&this.resetConversation(),(yield this.store.dispatch(Ed({externalId:t,options:n}))).payload})}upsertConversation(t){return _(this,null,function*(){var r;return this.hasConversation()&&this.externalId()!==t.externalId&&this.resetConversation(),(yield this.store.dispatch(fh(I(b({},t),{metadata:(r=t.metadata)!=null?r:{}})))).payload})}postMessages(t){return _(this,null,function*(){yield this.store.dispatch(ph(t))})}updateConversation(t){return _(this,null,function*(){return(yield this.store.dispatch(Cd(t))).payload})}resetConversation(){this.store.dispatch(ut()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(t){this.store.dispatch(Jd(t))}setVisitorInfo(t){this.store.dispatch($b(t))}setCustomData(t){this.store.dispatch(jb(t))}setAgentInfo(t,n){return _(this,null,function*(){var o;yield this.store.dispatch(bl(b(b({},t),n))),(o=this.state.info.agentInfo)!=null&&o.agentNickname||this.broadcastEvents.send(_d,{showNicknameDialog:!0})})}setAgentSettings(t){return _(this,null,function*(){yield this.store.dispatch(gh(t))})}getAgentSettings(){return _(this,null,function*(){return(yield this.store.dispatch(hh())).payload})}refresh(){return _(this,null,function*(){if(this.shouldAbort())return Promise.resolve();let t=[];return t.push(this.refreshTextSuggestions()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}syncInputMediator(){this.inputMediator&&this.store.dispatch(Rd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),suggestionTextStart:this.inputMediator.getSuggestionTextStart()}))}notifyExternalSuggestion(t){this.store.dispatch(kn(t))}evaluateAssistant(t,n){return _(this,null,function*(){var u;let{input:r={},attachments:o=[],transcript:s,showCuesInWidget:i=!0,includeMetadata:a,externalConversationId:l}=n||{},c=yield this.store.dispatch(mn({assistantCode:t,attachments:o,transcript:s,includeMetadata:a,input:r,externalConversationId:l,skipState:!i}));if(c.error)throw new Error(`Assistant evaluation failed: ${(u=c.payload)!=null?u:c.error.message}`);return c.payload.output})}evaluateConversationAssistant(t,n){return _(this,null,function*(){var u,f,p;yield this.loadProfileConfig();let r=this.state.profile.data;if(!r&&((u=this.state.conversation.current)!=null&&u.profileCode)&&(yield this.loadProfileConfig(),r=this.state.profile.data),!r){ee.warn("Can't evaluate assistant when profile is not loaded yet.");return}let o=f_(r,t),s=(f=n==null?void 0:n.showCuesInWidget)!=null?f:!0,d=n!=null?n:{},{showCuesInWidget:i}=d,a=se(d,["showCuesInWidget"]),l=(p=n==null?void 0:n.externalConversationId)!=null?p:this.hasConversation()?this.externalId():"",c=yield Promise.all(o.map(h=>this.queues.push(h,()=>_(this,null,function*(){var S,g;let y=yield this.store.dispatch(mn(b(I(b({assistantCode:h,includeMetadata:!0},a),{skipState:!s}),n!=null&&n.attachments&&(n==null?void 0:n.attachments.length)>0?{attachments:n==null?void 0:n.attachments}:{})));if(y.error)throw new Error(`Assistant evaluation failed: ${(S=y.payload)!=null?S:y.error.message}`);return{assistantCode:h,evaluationId:y.payload.evaluationId,output:y.payload.output,externalConversationId:(g=y.payload.externalConversationId)!=null?g:l}})).catch(y=>{if(y instanceof Cu)return ee.warn(`Queued assistant "${h}" was outdated and dropped`),null;throw y})));if(!s)return c.filter(h=>h!==null)})}handleKeyDown(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:s,selection:i}=this.state.input,{inlineSuggestions:a,autoSelectSuggestion:l,showTextSuggestions:c,suggestionsPlacement:u}=this.settings,f=a||l,d=u==="inline"||u==="below"?"below":"above",p=o.length>0;if(this.store.dispatch(_b(mh(t))),!Gr(this.state)||t.key!=="Tab"&&!c)return;let h=()=>{n||!p||i&&(t.shiftKey||(this.store.dispatch(Nb()),t.preventDefault()))},y=()=>{n||!p||f&&s<=0||i&&(t.shiftKey||(this.store.dispatch(Lb()),t.preventDefault()))};switch(t.key){case"ArrowUp":d==="below"?y():h();break;case"ArrowDown":{d==="below"?h():y();break}case"Escape":{n||(this.store.dispatch(kd(-1)),this.store.dispatch(ws({collapse:!0})),this.store.dispatch(PA(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let S=ji(this.state);if(!S)return;this.store.dispatch(du(!1)),this.store.dispatch(kn({text:S.text,suggestion:S,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(f||this.state.input.selectedSuggestionIndex===-1)return;let S=ji(this.state);if(!S)return;this.store.dispatch(kn({text:S.text,suggestion:S,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(f||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let S=ji(this.state);if(!S)return;this.store.dispatch(kn({text:S.text,suggestion:S,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(ws({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(Uo([]))}handlingTimeStart(){this.state.handlingTime.startTime||(ee.info("Start handling time"),this.store.dispatch(JI()))}handlingTimeStop(){this.state.handlingTime.startTime&&(ee.info("Stop handling time"),this.store.dispatch(Jm()))}logSendMessage(t){let n=d_(this.state,{version:this.version});n&&(t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEvent("Send Message",{conversationId:this.conversationId(),data:n}),this.emit("send-message-event",n))}logHandlingTime(){let t=u_(this.state,{version:this.version});t&&(this.deepdeskApi.sendEvent("Handling Time",{conversationId:this.conversationId(),data:t}),this.store.dispatch(e_()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(zs((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(Fb()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(s){ee.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),ee.error(s)}})}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),()=>{this.off(t,n)}}off(t,n){if(!t&&!n){this.eventListeners={};return}let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}setConversationQuery(t){this.dynamicThunkObject.conversationQuery=t}setPlatformVariables(t){this.store.dispatch(Kb(t))}whenConversationLoaded(t){let n=s=>{var i;return(i=s.conversation.current)==null?void 0:i.id},r=()=>this.loadProfileConfig().then(()=>t());return n(this.state)&&r(),this.subscribe(n,s=>{s&&r()})}overlayContainerFactory(t,n,r,o){let[s,i]=Tu(n,r);return s.setAttribute("translate","no"),s.dataset.testid=t,o&&s.classList.add(o),[s,i]}createInlineContainer(t,n){var a;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let s=(a=t.ownerDocument.defaultView)==null?void 0:a.frameElement,i=s?s.ownerDocument.defaultView:null;if(s&&(i===window||(i==null?void 0:i.parent)===window)){let[l,c]=Tu(s,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{c()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return mi(o),o.dataset.testid=t,o.style.color=r.color,o.style.fontSize=r.fontSize,o.style.fontFamily=r.fontFamily,o.style.fontVariant=r.fontVariant,o.setAttribute("translate","no"),n.appendChild(o),o}storeMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(t,n),ee.info(`Stored analytics for ${this.conversationId()}`)}catch(t){}}restoreMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(t);if(!n)return;let r=JSON.parse(n);r.text.trim()===this.state.input.text.trim()?(ee.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(Db(r.metrics))):ee.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch(t){}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!tg(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let d=n,{customStyles:r,closestScrollSelector:o,floatingMenuParent:s,appendOverlayTo:i,inputMediator:a}=d,l=se(d,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),c={customStyles:r,closestScrollSelector:o,floatingMenuParent:s,appendOverlayTo:i};this.configure(l),this.settings.automaticHandlingTime&&this.setupHandlingTime(t),mi(t),this.inputMediator=a||(ki(t)?new Ai(t):new Pi(t)),this.inputMediator.on("change",({plainText:p,rawHTML:h,suggestionTextStart:y})=>{this.store.dispatch(Rd({text:p,html:h,suggestionTextStart:y}))}),this.inputMediator.on("keyup",p=>{this.store.dispatch(Mb(mh(p)))}),this.inputMediator.on("keydown",p=>{this.handleKeyDown(p)}),this.inputMediator.on("paste",({pastedText:p,selectionText:h})=>{this.store.dispatch(Ob({text:p,selectionText:h}))}),this.inputMediator.on("cut",({selectionText:p})=>{this.store.dispatch(Ib(p))});let u;this.inputMediator.on("selection",p=>{clearTimeout(u),p===null?u=setTimeout(()=>{p!==null&&this.store.dispatch(Pd(p))},500):this.store.dispatch(Pd(p))}),this.unmountHandlers.push(()=>{clearTimeout(u)}),this.inputMediator.on("disabled",()=>{var p;(p=this.inputMediator)==null||p.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{this.settings.detectSubmit&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(Cm(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(Cm(!0))}),this.renderSuggestions(t,c),this.subscribe(Ws("inlineSuggestions"),()=>{this.renderSuggestions(t,c)}),this.subscribe(Ws("suggestionsPlacement"),()=>{this.renderSuggestions(t,c)});let f=this.renderOverlays(n);this.unmountHandlers.push(()=>{f.unmount()}),this.store.dispatch(Rd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),suggestionTextStart:this.inputMediator.getSuggestionTextStart()})),this.store.dispatch(Pd(this.inputMediator.getSelection())),this.store.dispatch(Cm(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{this.restoreMetrics(),this.syncInputMediator(),this.refreshTextSuggestions(),this.promptForNickname()}),this.isMounted=!0}promptForNickname(t){if(this.nicknameDialogUnsubscribe||this.nicknameDialogFailed)return;let n=this.createContainer("nickname-dialog",document.body);document.body.appendChild(n);let r=(0,Lo.createRoot)(n),o=null,s=a=>{o=a,i()},i=()=>{r==null||r.render((0,ke.jsx)(Po,{store:this.store,children:(0,ke.jsx)(ro,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(jA,{id:"deepdesk-nickname-dialog",error:o,onSave:a=>_(this,null,function*(){try{yield this.store.dispatch(Vb({agentNickname:a})).unwrap(),console.log("setAgentNickname",a),this.broadcastEvents.send(_d,{showNicknameDialog:!1}),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe()}catch(l){ee.error("Error setting agent nickname",l),s("error"),this.nicknameDialogFailed=!0}})})})}))};i(),this.nicknameDialogUnsubscribe=()=>{r.unmount(),n.remove(),this.nicknameDialogUnsubscribe=null}}subscribe(t,n){let r=t(this.store.getState());return this.store.subscribe(()=>{let o=t(this.store.getState());o!==r&&(r=o,n(r))})}unmount(){var t,n,r,o,s;(t=this.inlineSuggestions)==null||t.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(r=this.belowSuggestions)==null||r.unmount(),(o=this.floatingMenu)==null||o.unmount(),this.unmountHandlers.forEach(i=>i()),this.unmountHandlers=[],(s=this.inputMediator)==null||s.dispose(),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe(),this.isMounted=!1}dispose(){this.unmount(),this.unmountWidget(),this.disposeHandlers.forEach(t=>t()),this.disposeHandlers=[],this.off()}renderSuggestions(t,n){var r,o,s,i;(r=this.floatingMenu)==null||r.unmount(),(o=this.inlineSuggestions)==null||o.unmount(),(s=this.aboveSuggestions)==null||s.unmount(),(i=this.belowSuggestions)==null||i.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(t,n)),this.settings.inlineSuggestions||this.settings.suggestionsPlacement==="inline"?this.inlineSuggestions=this.renderInlineSuggestions(t,n):this.settings.suggestionsPlacement==="below"?this.belowSuggestions=this.renderAboveOrBelowSuggestions(t,n,"below"):this.aboveSuggestions=this.renderAboveOrBelowSuggestions(t,n,"above")}renderInlineSuggestions(t,n){let{customStyles:r}=n,o=this.createInlineContainer(t,"deepdesk-caret"),s=(0,Lo.createRoot)(o);s.render((0,ke.jsx)(Po,{store:this.store,customStyles:r,children:(0,ke.jsx)(ro,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(WA,{})})}));let i=a=>{a?(o.style.display="block",o.style.top=`${a.top}px`,o.style.left=`${a.left}px`):o.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var a;(a=this.inputMediator)==null||a.off("caretposition",i),s.unmount(),o.remove()}}}renderAboveOrBelowSuggestions(t,n,r){let{customStyles:o,closestScrollSelector:s,appendOverlayTo:i}=n,a=s&&JS(t,s)||void 0,[l,c]=this.overlayContainerFactory("deepdesk-tab-completion",a||t,{appendTo:i,closestScrollElement:a,mirrorOverflow:!0,onRemove:()=>this.unmount()},o==null?void 0:o.rootNode),[u,f]=this.overlayContainerFactory("deepdesk-suggestions-overlay",a||t,{appendTo:i,placement:r},o==null?void 0:o.suggestionsRootNode),d=(0,Lo.createRoot)(l);d.render((0,ke.jsx)(Po,{store:this.store,customStyles:o,children:(0,ke.jsx)(ro,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(gI,{inputElement:t})})}));let p=(0,Lo.createRoot)(u);return p.render((0,ke.jsx)(Po,{store:this.store,customStyles:o,children:(0,ke.jsx)(ro,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(eI,{onLogIn:()=>this.loginViaPopup().catch(h=>ee.warn(h.message))})})})),{unmount(){d.unmount(),p.unmount(),c(),f()}}}renderFloatingMenu(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:s,floatingMenuParent:i}=n,a=o&&JS(t,o)||void 0,[l,c]=this.overlayContainerFactory("floating-menu",a||t,{appendTo:i!=null?i:s},r==null?void 0:r.floatingMenuParent),u=(0,Lo.createRoot)(l);return u.render((0,ke.jsx)(Po,{store:this.store,customStyles:r,children:(0,ke.jsx)(ro,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(kA,{onLogIn:()=>this.loginViaPopup().catch(f=>ee.warn(f.message))})})})),{unmount(){u.unmount(),c()}}}renderOverlays(t){let{customStyles:n}=t,r=this.createContainer("deepdesk-overlays"),o=(0,Lo.createRoot)(r);return o.render((0,ke.jsx)(Po,{store:this.store,customStyles:n,children:(0,ke.jsx)(ro,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(wA,{})})})),{unmount(){o.unmount(),r.remove()}}}renderWidget(t,n={}){if(this.widgetElement&&ee.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,isEmbedded:s,signInViaPopup:i,ssoUrl:a,openAdminFeedback:l}=n;this.widgetElement=t,this.configure({showImages:o,isEmbedded:s,signInViaPopup:i});let c;if(a)try{c={url:new URL(a,this.settings.adminUrl).toString()}}catch(u){ee.warn(`Invalid ssoUrl '${a}' passed to renderWidget`)}this.widgetRoot=(0,Lo.createRoot)(t),this.widgetRoot.render((0,ke.jsx)(Po,{store:this.store,customStyles:r,children:(0,ke.jsx)(ro,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(UI,{assistantOptions:n.assistantOptions,knowledgeAssistOptions:n.knowledgeAssist,openAdminFeedback:l,onLogIn:()=>this.loginViaPopup(c).catch(u=>ee.warn(u.message))})})}))}unmountWidget(){var t,n;(n=(t=this.widgetRoot)==null?void 0:t.unmount)==null||n.call(t),this.widgetRoot=null,this.widgetElement=null}renderKnowledgeAssistantWidget(t,n,r={}){let{customStyles:o,initialQuestion:s}=r,i=(0,Lo.createRoot)(n);return i.render((0,ke.jsx)(Po,{store:this.store,customStyles:o,children:(0,ke.jsx)(ro,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(KS,{children:(0,ke.jsxs)(nm,{assistantCode:t,initialQuestion:s,evaluateKnowledgeAssistFn:Bl,children:[(0,ke.jsx)(Hi,{children:(0,ke.jsx)(om,{title:r.title,emptyState:r.emptyState})}),(0,ke.jsx)(jS,{children:(0,ke.jsx)(rm,{})})]})})})})),{unmount(){i.unmount()}}}setupHandlingTime(t){let n=og(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){p_(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){var t;return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(t=this.state.conversation.current)!=null&&t.profileCode?(this.loadProfileConfigPromise=Promise.resolve().then(()=>_(this,null,function*(){yield this.store.dispatch(qc()).unwrap();let n=gs(this.state);n&&this.store.dispatch(Jd({showSearch:n.search,showImageSearch:n.imageSearch,showEntitiesCommand:n.entitiesCommand,showSummaryCommand:!!n.summarizerAssistantNew,showKnowledgeSearch:!!n.knowledgeAssistantNew||!!n.knowledgeAssistant,recommendTextSuggestions:n.recommendTextSuggestions}))})).finally(()=>{gs(this.state)||(this.loadProfileConfigPromise=null)}),this.loadProfileConfigPromise):Promise.resolve()}loginViaPopup(t){return _(this,null,function*(){return new Promise((n,r)=>{this.store.dispatch(xd());let o=new MessageChannel,s=o.port1,i=this.settings.adminUrl,a=new URL(t!=null&&t.url?t==null?void 0:t.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,c=()=>{u&&!u.closed&&u.close(),window.removeEventListener("message",f),clearInterval(d)};s.onmessage=p=>_(this,null,function*(){var h,y;if((h=p.data)!=null&&h.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((y=p.data)==null?void 0:y.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(Cl),l=!0,o.port1.close(),n()}catch(S){console.error(S),r(S)}finally{l=!0,c()}});let u=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");u===null&&r(new Error("Popup blocked by browser"));let f=p=>_(this,null,function*(){var h;if(p.origin===a.origin)switch((h=p.data)==null?void 0:h.type){case"deepdesk-popup-request-origin":{try{let y=JSON.stringify({type:"deepdesk-popup-parent-origin"});u==null||u.postMessage(y,a.origin)}catch(y){ee.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-loaded":{try{let y=JSON.stringify({type:"deepdesk-popup-create-channel"});u==null||u.postMessage(y,a.origin,[o.port2])}catch(y){ee.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-error":{if(c(),p.data.message==="Platform account url mismatch"){let y=`Please contact your administrator: The platform account url (${p.data.targetOrigin}) is misconfigured as it differs from the origin of the page that opened the popup (${p.data.openerOrigin}).`;ee.warn(y),this.store.dispatch(lh(y)),r(new Error(y))}if(p.data.message==="Timeout"){let y="Please contact your administrator: Popup timed out. Check if the account's platform url is configured correctly.";ee.warn(y),this.store.dispatch(lh(y)),r(new Error(y))}r(new Error(p.data.message));break}}});window.addEventListener("message",f);let d=setInterval(()=>{u&&!u.closed||(c(),l||r(new Error("Popup closed by user")))},200);this.disposeHandlers.push(c)})})}translateMessages(t){return this.deepdeskApi.translateMessages(t)}refreshTextSuggestions(){return _(this,null,function*(){this.isMounted&&(yield this.store.dispatch(wm()))})}refreshWidgetSuggestions(){return _(this,null,function*(){if(!this.widgetRoot)return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=Yc(this.state);try{n.forEach(({type:r})=>{switch(r){case"entities":this.store.dispatch(Sr());break;case"pinned-messages":case"sticky-messages":break;default:Yu.includes(r)||this.store.dispatch(xr(r))}})}catch(r){this.handleError(r)}})}};sl.version="19.5.1-beta.2",sl.count=0;var ku=sl;function Mz(e){return _(this,null,function*(){var o,s,i;let n=yield((o=e.fetch)!=null?o:window.fetch)(e.url),r=yield n.blob();return new File([r],e.name,{type:(i=(s=e.mimeType)!=null?s:n.headers.get("Content-Type"))!=null?i:"image/jpeg"})})}function k_(e,t){return _(this,null,function*(){let n=yield Mz(t),r=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(e,"files",{configurable:!0,get:()=>[n]}),e.dispatchEvent(r)}finally{Object.hasOwn(e,"files")&&delete e.files}})}function R_(e,t,n){return _(this,null,function*(){yield new No(e).authenticateWithKey(t,n)})}function P_(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function A_(r,o){return _(this,arguments,function*(e,t,n={}){var f,d;let{value:s}=e,{start:i,end:a}=(f=n.replace)!=null?f:{start:0,end:s.length},l=`${s.slice(0,i)}${t}${s.slice(a)}`,c=(d=n.selectionAfter)!=null?d:{start:i+t.length,end:i+t.length},u=()=>{if(n.setValue)return n.setValue(l);e.value=l};return Promise.resolve(u()).then(()=>{e.selectionStart=c.start,e.selectionEnd=c.end,e.blur(),e.focus()})})}function I_(r,o){return _(this,arguments,function*(e,t,n={}){let s=n.replace?Rs(e,n.replace.start,n.replace.end):nl(e),i,a=()=>{if(n.setRange)return n.setRange(s.cloneRange());s.deleteContents(),i=document.createElement("span"),s.insertNode(i),n.insertBRs!==!1?t.split(`
83
+ `);let h=d?r:0,y=p?Math.min(s,u.childNodes.length):u.childNodes.length;for(let S=h;S<y&&(c(u.childNodes[S]),a!==2);S++);break}default:break}p&&(a=2)}return c(e),l}var WI=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(WI||{}),Oo=class{constructor(t){this.element=t;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedSuggestionTextStart=0;this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedSuggestionTextStart=this.getSuggestionTextStart(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(t,n){let r=o=>{n(o)};this.element.addEventListener(t,r),this.disposeHandlers.push(()=>{this.element.removeEventListener(t,r)})}removeEventListener(t,n){this.element.removeEventListener(t,n)}handleInteraction(){let t=this.getText(),n=this.getHTML(),r=this.getSelection(),o=this.getSuggestionTextStart(),s=this.cachedCaretPosition===null;if(!this.isActive)return;t===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit");let i=t!==this.cachedText,a=n!==null&&n!==this.cachedHTML,l=o!==this.cachedSuggestionTextStart;if((i||a||l)&&(i?(this.cachedText=t,this.cachedHTML=n):a&&(this.cachedHTML=n),this.cachedSuggestionTextStart=o,s=!0,this.emit("change",{plainText:t,rawHTML:n,suggestionTextStart:o})),(r.start!==this.cachedSelection.start||r.end!==this.cachedSelection.end)&&(this.cachedSelection=r,s=!0,this.emit("selection",r)),!s)return;let c=this.getCaretPosition();Bo(c,this.cachedCaretPosition)||(this.cachedCaretPosition=c,this.emit("caretposition",c))}handleClick(){this.handleInteraction()}handleFocus(){let t=!this.isFocused;this.isFocused=!0,t&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let t=this.isFocused;this.isFocused=!1,t&&this.emit("blur")}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(WI).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleKeyUp(t){this.handleInteraction(),this.emit("keyup",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let t=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{t.disconnect()})}getSuggestionTextStart(){return 0}focus(){this.element.focus()}emit(t,...n){this.isDisposed||this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r(...n)})}on(t,n){this.isDisposed||(this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n))}off(t,n){if(!this.eventListeners[t])return;let r=this.eventListeners[t].indexOf(n);r!==-1&&this.eventListeners[t].splice(r,1)}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};function $I(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var Pi=class extends Oo{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),bu(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){let n=this.getRootNode();if(n.activeElement!==this.element)return null;let r="getSelection"in n?n.getSelection():window.getSelection();if(!r)return null;let o=r.rangeCount>0?r.getRangeAt(0):null;if(!o)return null;let s=this.element.ownerDocument.createRange();return s.setStart(o==null?void 0:o.startContainer,o==null?void 0:o.startOffset),s.setEnd(o==null?void 0:o.endContainer,o==null?void 0:o.endOffset),!s||!this.element.contains(s.startContainer)||!this.element.contains(s.endContainer)?null:s}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let r=n.getBoundingClientRect();return!$I(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!$I(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return wu(this.element,n);let r=this.lastKnownSelection;if(r&&VI(this.element,r.start,r.end))return r;let o=nl(this.element);return o.collapse(!1),wu(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return bu(this.element,Rs(this.element,n,r))}listen(){super.listen();let n=new MutationObserver(s=>{var i,a;s.length===2&&s[0].addedNodes.length===1&&((i=s[0].addedNodes[0])==null?void 0:i.textContent)==="\u2060"&&((a=s[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let r=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==r&&(r=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}};var yz=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize"];function jI(e,t){let n="mozInnerScreenX"in window,r=document.createElement("div");r.id="input-textarea-caret-position-mirror-div";let o=r.style,s=window.getComputedStyle(e),i=e.ownerDocument.body;o.whiteSpace="pre-wrap",o.wordWrap="break-word",o.position="absolute",o.visibility="hidden",yz.forEach(u=>{o[u]=s[u]}),n?e.scrollHeight>Number.parseInt(s.height)&&(o.overflowY="scroll"):o.overflow="hidden",r.textContent=e.value.substring(0,t);let a=document.createElement("span");a.textContent=e.value.substring(t)||".",r.appendChild(a),i.appendChild(r);let l=e.getBoundingClientRect(),c={top:l.top-e.scrollTop+a.offsetTop+Number.parseInt(s.borderTopWidth)+a.offsetHeight,left:l.left-e.scrollLeft+a.offsetLeft+Number.parseInt(s.borderLeftWidth)};return i.removeChild(r),c}var Ai=class extends Oo{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:r}=this.element;return{start:n,end:r}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return jI(this.element,this.element.selectionEnd)}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=n==null?void 0:n.get)==null?void 0:s.call(this.element)},set:s=>{var i;(i=n==null?void 0:n.set)==null||i.call(this.element,s),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let r=this.element.disabled,o=new MutationObserver(()=>{this.element.disabled!==r&&(r=this.element.disabled,this.emit(r?"disabled":"enabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>o.disconnect())}};function KI(e,t,n){let r=`deepdesk-iframe-${e}`,o=document.getElementById(r);if(o)return o;let s=document.createElement("iframe"),i=new URL(t);return Object.entries(n).forEach(([a,l])=>{i.searchParams.append(a,l)}),s.style.position="absolute",s.style.left="-999em",s.style.width="0px",s.style.height="0px",s.tabIndex=-1,s.id=r,s.title=`iframe-${e}`,s.src=i.toString(),window.document.body.appendChild(s),s}function vz(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var GS=class{constructor(t){this.name=t;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(t)}onMessage(t){this.broadcastChannel.addEventListener("message",t),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",t)})}postMessage(t){this.broadcastChannel.postMessage(JSON.stringify(t))}close(){this.disposeHandlers.forEach(t=>t()),this.broadcastChannel.close()}},qS=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=KI(t,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(t){window.addEventListener("message",t),this.disposeHandlers.push(()=>{window.removeEventListener("message",t)})}postMessage(t){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(t),this.targetOrigin)}close(){var t;this.disposeHandlers.forEach(n=>n()),(t=this.iframe)==null||t.remove()}},YS=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.externalId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setExternalId(t){this.externalId!==t&&(this.cleanup(),ee.info("Set externalId",t),this.externalId=t,this.channel=this.createChannel(t))}createChannel(t){let n=this.params.createCustomChannel?this.params.createCustomChannel(t):this.isCrossOrigin?new qS(t,this.deepdeskUrl,{debug:!0}):new GS(t),r=o=>{var i,a;if(o.origin!==this.deepdeskUrl)return;let s=vz(o.data);typeof s!="object"||s.type!=="event"||s.channel!==t||(ee.info("Received broadcast event",this.externalId,o),(a=(i=this.eventMap)[s.name])==null||a.call(i,s.payload))};return n.onMessage(r),n}send(t,n,r){var i,a;ee.info("Broadcast event",{externalId:this.externalId,name:t,payload:n});let o={type:"event",name:t,payload:n};r!==!1&&((a=(i=this.eventMap)[t])==null||a.call(i,n));let s=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage(I(b({},o),{channel:this.externalId}))}cleanup(t=!1){var n,r;(n=this.channel)==null||n.close(),this.channel=void 0,t&&((r=this.defaultChannel)==null||r.close(),this.defaultChannel=void 0)}},GI=YS;function Sz(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function Ve(e){return Array.isArray(e)?e.map(Ve):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>I(b({},t),{[Sz(n)]:Ve(e[n])}),{}):e}function xz(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Dt(e){return Array.isArray(e)?e.map(Dt):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>I(b({},t),{[xz(n)]:Dt(e[n])}),{}):e}var rl=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var Eu=e=>new Promise(t=>{setTimeout(t,e)});var wr=class extends rl{constructor(){super(...arguments);this.name="ClientError"}},Xm=class extends rl{constructor(){super(...arguments);this.name="ServerError"}},XS=new Map;function qI(e){return _(this,null,function*(){if(e.status===204)return e.text().catch(()=>{}),null;let t=e.headers.get("content-type");if(t!=null&&t.includes("application/json"))return e.json();let n=yield e.text();return n===""?null:(ee.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var Ii=class{constructor(t="",n={}){this.baseUrl=t;this.options=n;this.latestRequestByUrl={};this.refreshingToken=null;this.lastFailedRefreshAt=null;this.failedRefreshCooldown=1e4;var r;this.fetch=(r=n.fetch)!=null?r:window.fetch.bind(window)}patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let s={isAborted:!1,reject:o},i=`${this.baseUrl}${t}`,a=this.fetch,l=n.method===void 0||n.method.toLowerCase()==="get",C=n,{useCache:c=!1,abortLatest:u=!1,attempts:f=1,retryDelay:d=500,refreshTokenOn401:p=!0,retryOnError:h=k=>k instanceof TypeError,retryOnResponse:y=k=>k.status>=500,version:S=null}=C,g=se(C,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(c){if(!l)throw new Error(`Can't use 'useCache' for ${n.method}`);if(XS.has(i)){r(XS.get(i));return}}let m=I(b({credentials:"include"},g),{headers:b({Accept:"application/json","Content-Type":"application/json"},g.headers)});!l&&this.csrfToken&&(m.headers=I(b({},m.headers),{"X-CSRFToken":this.csrfToken})),typeof S=="string"&&(m.headers=I(b({},m.headers),{"X-Deepdesk-API-Version":S}));let v=f,x=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&u&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=s;let T=()=>_(this,null,function*(){return v--,a(i,m).then(k=>_(this,null,function*(){return y(k)&&!s.isAborted&&v>0?(yield Eu(d),T()):k.status===401&&p===!0&&x===!1?(x=!0,yield this.refreshToken(),T()):k})).catch(k=>_(this,null,function*(){if(h(k)&&!s.isAborted&&v>0)return yield Eu(d),T();throw k}))});T().then(k=>_(this,null,function*(){let R=yield qI(k);if(delete this.latestRequestByUrl[i],k.status>=500){o(new Xm("Server Error",R));return}if(k.status===401){o(new wr("Unauthorized",R));return}if(k.status===403){o(new wr("Forbidden",R));return}if(k.status===404){o(new wr("Not Found",R));return}if(k.status>=400){o(new wr("Bad Request",R));return}c&&XS.set(i,R),r(R)})).catch(k=>{o(k)})})}validateToken(){return _(this,null,function*(){let t,n,r;try{({has_valid_access_token:t,is_logged_in:n,has_valid_refresh_token:r}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1}))}catch(o){return!1}if(!t){if(!r)return!1;try{yield this.refreshToken();let{is_logged_in:o}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1});return o}catch(o){return!1}}return n})}refreshToken(){let t=Date.now();return this.lastFailedRefreshAt&&t-this.lastFailedRefreshAt<this.failedRefreshCooldown?Promise.reject(new wr("Unauthorized","Failed to refresh token")):this.refreshingToken?this.refreshingToken:(this.refreshingToken=this.get("/apis/admin/session/refresh/",{refreshTokenOn401:!1}).catch(n=>{throw(n==null?void 0:n.message)==="Unauthorized"&&(this.lastFailedRefreshAt=Date.now()),n}).finally(()=>{this.refreshingToken=null}),this.refreshingToken)}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,b({method:"POST",body:JSON.stringify(n)},r))}postWithStatus(t,n,r){return this.requestWithStatus(t,b({method:"POST",body:JSON.stringify(n)},r))}requestWithStatus(t,n={}){return new Promise((r,o)=>{let s={isAborted:!1,reject:o},i=`${this.baseUrl}${t}`,a=this.fetch,T=n,{useCache:l=!1,abortLatest:c=!1,attempts:u=1,retryDelay:f=500,refreshTokenOn401:d=!0,retryOnError:p=C=>C instanceof TypeError,retryOnResponse:h=C=>C.status>=500,version:y=null}=T,S=se(T,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]),g=I(b({credentials:"include"},S),{headers:b({Accept:"application/json","Content-Type":"application/json"},S.headers)});this.csrfToken&&(g.headers=I(b({},g.headers),{"X-CSRFToken":this.csrfToken})),typeof y=="string"&&(g.headers=I(b({},g.headers),{"X-Deepdesk-API-Version":y}));let m=u,v=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&c&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=s;let x=()=>_(this,null,function*(){return m--,a(i,g).then(C=>_(this,null,function*(){return h(C)&&!s.isAborted&&m>0?(yield Eu(f),x()):C.status===401&&d===!0&&v===!1?(v=!0,yield this.refreshToken(),x()):C})).catch(C=>_(this,null,function*(){if(p(C)&&!s.isAborted&&m>0)return yield Eu(f),x();throw C}))});x().then(C=>_(this,null,function*(){let k=yield qI(C);if(delete this.latestRequestByUrl[i],C.status>=500){o(new Xm("Server Error",k));return}if(C.status===401){o(new wr("Unauthorized",k));return}if(C.status===403){o(new wr("Forbidden",k));return}if(C.status===404){o(new wr("Not Found",k));return}if(C.status>=400){o(new wr("Bad Request",k));return}r({status:C.status,data:k})})).catch(C=>{delete this.latestRequestByUrl[i],o(C)})})}patch(t,n,r){return this.request(t,b({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,b({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,b({method:"DELETE"},n))}};var YI;(t=>{let e;(a=>(a.SUCCESS="success",a.FAILURE="failure",a.CONDITIONS_NOT_MET="conditions_not_met",a.MAX_RECURSION_LEVEL="max_recursion_level",a.NO_ACCESS_TO_ASSISTANT="no_access_to_assistant"))(e=t.EvaluationStatus||(t.EvaluationStatus={}))})(YI||(YI={}));function Qm(e){return I(b({},Ve(e)),{metadata:e.metadata})}var _i=class _i{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new Ii(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,s)=>_(this,null,function*(){let i=yield r(o,s);return this.handleDeepdeskVersionHeaders(i),i}))}preflight(){return _(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(_i.exchangeTokenPromise||(_i.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),_i.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return _(this,null,function*(){var r;yield this.preflight(),ee.info(`Creating conversation for session ${t.externalId} and agent ${t.agentId}`);let n=yield this.client.post("/api/v2/conversations",I(b({chat_start_time:new Date().toISOString()},Dt(t)),{metadata:(r=t.metadata)!=null?r:{}}));return Qm(n)})}upsertConversation(t){return _(this,null,function*(){var u;yield this.preflight(),ee.info(`Upserting conversation for session ${t.externalId} and agent ${t.agentId}`);let{status:n,data:r}=yield this.client.postWithStatus("/api/v2/conversations",I(b({chat_start_time:new Date().toISOString()},Dt(t)),{metadata:(u=t.metadata)!=null?u:{}}),{version:"v2"}),o=Qm(r);if(n===201)return o;let{agentId:s,agentName:i,agentEmail:a,agentNickname:l,metadata:c}=t;return this.updateConversation(o.id,{agentId:s,agentEmail:a,agentName:i,agentNickname:l,metadata:c})})}getMe(){return _(this,null,function*(){let t=yield this.client.get("/apis/admin/session/me/");return Ve(t)})}postIdentity(t){return _(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",Dt(t))})}patchMe(t){return _(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",Dt(t));return Ve(n)})}getProfile(t){return _(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{useCache:!0});return Ve(n)})}getKnowledgeAssistant(t){return _(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{useCache:!0});return Ve(n)})}getContentTypes(){return _(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return Ve(t)})}getAccount(){return _(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{useCache:!0});return Ve(t)})}getPlatformConfig(t){return _(this,null,function*(){let n=t!==void 0?`/platform/config/${t}/`:"/platform/config/",{config:r}=yield this.client.get(n,{useCache:!0});return Ve(r)})}checkUserExists(t){return _(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`,{version:"v1"});return n})}getConversationByExternalId(r){return _(this,arguments,function*(t,n={}){yield this.preflight(),ee.info(`Getting conversation for session ${t}`);let{attempts:o=1,retryDelay:s=1e3}=n,i=yield this.client.get(`/api/v2/conversations/by_external_id/${t}`,{attempts:o,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return ee.info(`Successfully retrieved conversation ${i.id} for session ${t}`),Qm(i)})}isConversationSupported(r){return _(this,arguments,function*(t,n={}){ee.info(`Check if conversation for session ${t} is supported`);let{attempts:o=1,retryDelay:s=1e3}=n;return(yield this.client.get(`/api/v2/conversations/by_external_id/${t}/has_active_profile`,{attempts:o,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500})).has_active_profile})}updateConversation(t,n){return _(this,null,function*(){var s;yield this.preflight();let r=Dt(n);n.metadata&&(r.metadata=(s=n.metadata)!=null?s:{});let o=yield this.client.put(`/api/v2/conversations/${t}`,r);return Qm(o)})}postMessages(t,n){return _(this,null,function*(){yield this.preflight(),yield this.client.post(`/api/v2/conversations/${t}/messages`,n.map(r=>I(b({},Dt(r)),{metadata:r.metadata})))})}sendEvent(t,n){return _(this,null,function*(){yield this.preflight();let a=n,{data:r}=a,o=se(a,["data"]),s=Object.entries(this.latestReceivedDeepdeskVersions).reduce((l,[c,u])=>I(b({},l),{[c]:u}),{}),i=["platform","agentId","agentName","agentEmail","conversationId"].reduce((l,c)=>(o[c]&&(l[c]=o[c]),l),{});return this.client.post("/api/v2/events",Dt(I(b(b({},s),i),{data:r,name:t})),{version:"v2"})})}getEntities(t){return _(this,null,function*(){return yield this.preflight(),yield this.client.post("/api/v2/entities",{messages:t.filter(r=>r.text)})})}getTemporaryExchangeToken(){return _(this,null,function*(){return(yield this.client.get("/apis/admin/session/exchange-token/")).jwt})}exchangeTokenForAccessCookie(t){return _(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t}).catch(n=>{throw ee.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return _(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Dt(n),{refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return _(this,arguments,function*(t,n={},r){if(yield this.preflight(),r==="sticky-messages")throw new Error("Use getPinnedMessages instead");return(yield this.client.post(`/api/v2/conversations/${t}/recommend/${r}`,Dt(n),{abortLatest:!0})).map(i=>I(b({},Ve(i)),{text:i.text||i.url||i.message,source:r,type:r})).filter((i,a,l)=>a===l.findIndex(c=>c.text===i.text))})}isLoggedIn(){return _(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return _(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${t}/autocomplete`,Dt(n),{abortLatest:!0})).map(o=>({score:1,source:o.source,sourceText:o.source_text,text:o.label,trainingJobs:o.training_jobs,searchKeywords:o.search_keywords,type:o.source})).filter((o,s,i)=>s===i.findIndex(a=>a.text===o.text))})}getPinnedMessages(t){return _(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${t}/pinned-messages`,{abortLatest:!0});return Ve(n).map(r=>I(b({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return _(this,null,function*(){let n=yield this.client.post("/api/v2/style-suggestions",Dt(t),{abortLatest:!0,version:"v2"});return Ve(n)})}search(t){return _(this,null,function*(){let n=yield this.client.post(`/api/v2/profiles/${t.profile}/search`,Dt(t));return Ve(n)})}loginWithPassword(t,n){return _(this,null,function*(){yield this.preflight();let r=yield this.client.post("/apis/admin/session/login/",{username:t,password:n},{refreshTokenOn401:!1});return Ve(r)})}logout(){return _(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/logout/",{},{refreshTokenOn401:!1})})}requestLoginByEmail(t){return _(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t});return Ve(n)})}requestPasswordlessToken(){return _(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/");return Ve(t.token)})}getCsrfToken(){return _(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/");return t})}verifyLoginToken(t){return _(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t});return Ve(n)})}evaluateAssistant(t,n){return _(this,null,function*(){var l,c,u;yield this.preflight();let r=new URLSearchParams;n!=null&&n.externalConversationId&&r.append("external_conversation_id",n.externalConversationId);let o=n!=null&&n.threadId?`/api/v2/assistants/${t}/threads/${n==null?void 0:n.threadId}/evaluate?${r.toString()}`:`/api/v2/assistants/${t}/evaluate?${r.toString()}`,s=f=>Dt(f),i=(l=n==null?void 0:n.transcript)==null?void 0:l.map(f=>{var d;return b({source:f.source,text:f.text},(d=f.attachments)!=null&&d.length?{attachments:f.attachments.map(s)}:{})}),a=yield this.client.post(o,b({input:(c=n==null?void 0:n.input)!=null?c:{},conversation:i},(u=n==null?void 0:n.attachments)!=null&&u.length?{attachments:n.attachments.map(s)}:{}));return Ve(a)})}createAssistantThread(t){return _(this,null,function*(){yield this.preflight();let{assistantCode:n}=t,r=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return Ve(r)})}postMessageToAssistantThread(t){return _(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:r,message:o}=t,s=yield this.client.post(`/apis/admin/assistants/${n}/threads/${r}/messages/`,{content:o,role:"user"});return Ve(s)})}translateMessages(t){return _(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/v2/translate",Dt(t));return Ve(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),s=o.match(aw);if(!n||!s)return;let i=s[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&ee.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};_i.exchangeTokenPromise=null;var No=_i;var Zm=class{constructor(t){this.options=t;this.socket=null;this.maxReconnectAttempts=5;this.reconnectInterval=25e3;this.cleanupCallbacks=[];var n,r;this.socket,this.eventListeners=new Map,this.url=t.url,this.maxReconnectAttempts=(n=t.maxReconnectAttempts)!=null?n:this.maxReconnectAttempts,this.reconnectInterval=(r=t.reconnectInterval)!=null?r:this.reconnectInterval,this.shouldReconnect=t.shouldReconnect}connect(){let t=()=>this.cleanup();window.addEventListener("beforeunload",t),this.cleanupCallbacks.push(()=>window.removeEventListener("beforeunload",t)),this.reconnect()}setupListeners(){this.socket&&(this.socket.onmessage=t=>{var n;try{let r=Ve(JSON.parse(t.data));r.event&&this.eventListeners.has(r.event)&&((n=this.eventListeners.get(r.event))==null||n.forEach(o=>o(r.data)))}catch(r){console.error("Error parsing WebSocket message:",r)}},this.socket.onclose=t=>{console.log("WebSocket connection closed:",t),setTimeout(()=>{this.reconnect()},this.reconnectInterval)},this.socket.onerror=t=>{console.error("WebSocket error:",t)})}reconnect(){var t,n;if(this.maxReconnectAttempts<=0){console.error("Max reconnect attempts reached, closing WebSocket connection."),(t=this.socket)==null||t.close();return}if(!this.shouldReconnect()){console.error("Should not reconnect, closing WebSocket connection."),(n=this.socket)==null||n.close();return}this.socket&&(this.socket.onmessage=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.close()),this.socket=new WebSocket(this.url),this.setupListeners(),this.maxReconnectAttempts--}send(t,n){if(!this.socket){console.error("WebSocket connection is not open.");return}this.socket.send(JSON.stringify({event:t,data:n}))}on(t,n){this.eventListeners.has(t)||this.eventListeners.set(t,[]);let r=this.eventListeners.get(t);r&&!r.includes(n)&&r.push(n)}close(){var t;(t=this.socket)==null||t.close()}cleanup(){this.close(),this.cleanupCallbacks.forEach(t=>t()),this.cleanupCallbacks=[]}};var XI={startTime:null,stopTime:null},QI=e=>e.handlingTime,ZI=Re({name:"handlingTime",initialState:XI,reducers:{handlingTimeStart(e){if(e.startTime&&!e.stopTime)throw new Error("Timing already started");e.startTime=new Date,e.stopTime=null},handlingTimeStop(e){if(!e.startTime)throw new Error("Timing not started");e.stopTime=new Date},handlingTimeReset(e){e.startTime=null,e.stopTime=null}},extraReducers:e=>{e.addCase(ut,()=>XI)}}),{handlingTimeStart:JI,handlingTimeStop:Jm,handlingTimeReset:e_}=ZI.actions,t_=ZI.reducer;var n_=(e={})=>{let t=b({onAuthError:Wi(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var r_=(e={})=>{let t,n=!0,r=b({getStyleSuggestions:Ci,debounce:500},e);return o=>s=>i=>{var p;let a=o.getState().input.text,l=s(i),c=o.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:u}=c.settings;if(!((p=c.conversation.current)==null?void 0:p.id)||!u)return l;let{text:d}=c.input;return d===a&&!n||(clearTimeout(t),d==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:d}))},e.debounce)),l}};function wz(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end&&e.suggestionTextStart===t.suggestionTextStart}var o_=(e={})=>{let t=b({getTextSuggestions:xr,getAutocompleteSuggestions:cu,debounce:200,check:Gr},e),n;return r=>o=>s=>{var y;let{input:i}=r.getState(),a=o(s),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:u}=l.settings,f=(y=l.conversation.current)==null?void 0:y.id,d=s.type===wm.toString();if(!f||!c&&!u)return a;let{input:p}=l;return wz(p,i)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let S=Ls(l);S===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(S))},d?0:t.debounce)),a}};var s_=Ci.fulfilled.toString();function bz(e,t){let n=new Set([...t.keywordMatches.map(o=>o.keyword)]),r=[];return n.forEach(o=>{let s=e.keywordMatches.filter(l=>l.keyword===o),i=t.keywordMatches.filter(l=>l.keyword===o),a=i.length-s.length;a<=0||r.push(...i.slice(0,a))}),r}var i_=e=>t=>n=>r=>{var c;if(r.type!==s_){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let s=t.getState(),i=s.styleSuggestions.list,a=(c=s.conversation)==null?void 0:c.current;if(o===i)return;let l=bz(o,i);r.type===s_&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var Ez=Ju({assistants:LE,auth:xb,conversation:kb,contentTypes:_P,passwordlessToken:vI,entities:sA,handlingTime:t_,info:qb,input:zb,settings:FE,profile:DP,search:eE,styleSuggestions:VA,ui:IA,textSuggestions:gA});function a_(e){return ab({reducer:Ez,middleware:t=>{var r;let n=t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI}},serializableCheck:!1}).concat(n_()).concat(o_({debounce:200})).concat(r_({debounce:500})).concat(i_(e.deepdeskAPI));return((r=e.middleware)!=null?r:[]).reduce((o,s)=>o.concat(s),n)},preloadedState:e.preloadedState})}function l_(e,t,n){if(t==="")return null;let r=new RegExp(`\\b${Lm(t)}\\b`,"gi"),o,s=null;for(;(o=r.exec(e))!==null&&!(o.index>n);)s={start:o.index,end:o.index+o[0].length};return s}var Cz=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},Tz=e=>t=>n=>r=>{var l,c,u,f,d,p;let o=t.getState(),s=Ws("inlineSuggestions")(o),i=Ws("autoSelectSuggestion")(o)||s;switch(r.type){case Wi.toString():{!r.payload&&e.emit("logout",void 0);break}case Sd.fulfilled.toString():{e.emit("logout",void 0);break}case Sr.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:(l=o.conversation.current)==null?void 0:l.id,data:{entities:r.payload}});break;case zs.toString():e.logSendMessage(r.payload);break;case Qd.toString():e.emit("call-to-action",{cue:r.payload});break;case mn.fulfilled.toString():if(!r.isBroadcasted){let{externalConversationId:h,currentExternalIdAtRequest:y}=(c=r.payload)!=null?c:{};(!h||!y||h===y)&&e.broadcast(vh,r,!1)}break;case mn.rejected.toString():break;default:break}let a=n(r);switch(r.type){case zs.toString():e.handleAfterSendMessage(r.payload);break;case du.toString():e.onUpdateShowTabHint(r.payload);break;case Jm.toString():e.logHandlingTime();break;case Ki.toString():e.broadcast(Md,r);break;case Fs.toString():e.broadcast(Md,r);break;case Zd.toString():t.dispatch(Fs({source:"assistant",assistantCode:r.payload.code}));break;case"analytics/logEvent/fulfilled":{let h=o.assistants.cues.find(y=>y.code===r.meta.arg.data.assistantCode);e.emit("event",I(b({},r.meta.arg),{cue:h}));break}case kn.toString():{let{start:h,end:y}=o.input.selection;e.emit("select-suggestion",I(b({type:Cz(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:h,end:y}:{start:0,end:y}})),s&&t.dispatch(Uo([]));break}case UA.toString():{let{keyword:h,suggestion:y,eventMetrics:S}=r.payload,{text:g,selection:m}=o.input,v=l_(g,h,(u=m==null?void 0:m.end)!=null?u:g.length);if(!v)break;e.emit("select-suggestion",{text:y,type:"style",replace:v,suggestion:{text:y,source:"style"},eventMetrics:S});break}case Td.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(f=o.conversation.current)==null?void 0:f.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case Uo.toString():{i&&r.payload.length>0&&t.dispatch(kd(0));break}case mn.fulfilled.toString():{let{evaluationId:h,output:y,externalConversationId:S}=r.payload,g=r.meta.arg.assistantCode;if(e.emit("event",{name:"Assistant evaluation completed",data:{evaluationId:h,assistantCode:g,assistantOutput:IE(y),externalConversationId:S,evaluationStatus:"success"}}),!r.meta.arg.skipState){let m=t.getState().assistants.cues;e.emit("cues",m)}break}case mn.rejected.toString():{let h=r.meta.arg.assistantCode,y=(p=r.meta.arg.externalConversationId)!=null?p:(d=t.getState().conversation.current)==null?void 0:d.externalId;e.emit("event",{name:"Assistant evaluation completed",data:{evaluationId:"",assistantCode:h,assistantOutput:"",externalConversationId:y,evaluationStatus:"failed"}});break}default:break}return a},c_=Tz;function QS(e){return e.toISOString().replace("T"," ").replace("Z","")}var kz=(e,t)=>t.version,u_=fn([Gi,Ir,QI,kz],(e,t,n,r)=>{if(!t)return ee.warn("No conversationId for handling time metrics"),null;let{startTime:o,stopTime:s}=n;return!o||!s?(ee.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:t,clientVersion:r,agentId:e==null?void 0:e.agentId,agentName:e==null?void 0:e.agentName,agentEmail:e==null?void 0:e.agentEmail,timeStart:QS(o),timeStop:QS(s)}});function d_(e,t){let{text:n,metrics:{numPaste:r,pastes:o,textSuggestions:s}}=e.input,i=n.length;return{source:"agent",clientVersion:t.version,pastes:o,lenTextTotal:i,numPastes:r,suggestions:s}}var Cu=class extends Error{};function Rz(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}var eg=class{constructor(){this.queues={}}push(t,n){let r=()=>{let s=this.queues[t][1];s?(this.queues[t]=[s.promise,null],s.resolve()):delete this.queues[t]};if(!this.queues[t]){let s=n().finally(r);return this.queues[t]=[s,null],s}this.queues[t][1]&&this.queues[t][1].reject(new Cu("Queued async function is outdated"));let o=Rz();return this.queues[t][1]=o,o.promise.then(()=>n().finally(r))}};function ZS(e,t){var s;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return ZS(r,t);let o=(s=e.ownerDocument.defaultView)==null?void 0:s.frameElement;return o?ZS(o,t):null}function JS(e,t){return ZS(e,t)}var Pz={accepted:"onConversationAcceptedAssistants","new-message":"onConversationNewMessageAssistants",ended:"onConversationEndedAssistants"},f_=(e,t)=>{var o,s,i;if(!((i=(s=(o=e.uiConfig)==null?void 0:o.widget)==null?void 0:s.types.find(a=>a.type==="cues"))==null?void 0:i.isActive))return ee.warn("Triggered a conversation assistant, but cues are not configured in widget."),[];let r=e[Pz[t]];return r&&r.length>0?r.map(a=>a.code):(ee.warn(`No assistant set in profile for conversation event "${t}"`),[])};function p_(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function Az(e){return typeof e=="object"&&e!==null&&"tagName"in e}function tg(e){return Az(e)&&(ki(e)||Om(e))}var g_,Xr=new Map,Iz=["bottom","height","left","right","top","width"],m_=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:Iz.some(n=>e[n]!==t[n]);function h_(e){var n,r,o;if(e.ownerDocument===document)return[];let t=(o=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)!=null?o:null;return t?[t,...h_(t)]:[]}function y_(e,t){return!e||!t?null:I(b({},e),{top:e.top+t.top,left:e.left+t.left})}var ng=!1,v_=()=>{ng=!0;let e=[];if(Xr.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Xr.delete(n);return}let r=n.getBoundingClientRect();m_(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(y_,t.rect):t.rect;m_(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Xr.size===0){ng=!1;return}g_=window.requestAnimationFrame(v_)};function ex(e,t){let n=h_(e),r=[],o=n.map((s,i)=>ex(s,a=>{r[i]=a;let l=Xr.get(e);if(!l)return;let c=r.reduce(y_,l.rect);l.callbacks.forEach(u=>u(c))}));return{observe(s=!0){if(o.forEach(i=>i.observe(!1)),Xr.has(e)){let i=Xr.get(e);i.callbacks.push(t),i.rect&&t(i.rect)}else Xr.set(e,{rect:void 0,callbacks:[t],parentRects:r});s&&!ng&&v_()},unobserve(){o.forEach(i=>i.unobserve());let s=Xr.get(e);if(s){let i=s.callbacks.indexOf(t);i>=0&&s.callbacks.splice(i,1),s.callbacks.length||Xr.delete(e),Xr.size||(cancelAnimationFrame(g_),ng=!1)}}}}var S_,Qr=new Map,x_=()=>{Qr.forEach((e,t)=>{if(!t.isConnected){Qr.delete(t);return}let{clientHeight:n,scrollHeight:r}=t,o=r>n;e.visible!==o&&(e.visible=o,e.callbacks.forEach(s=>s(e.visible)))}),Qr.size!==0&&(S_=window.requestAnimationFrame(x_))};function w_(e,t){return{observe(){let n=Qr.size===0;Qr.has(e)?Qr.get(e).callbacks.push(t):Qr.set(e,{visible:void 0,callbacks:[t]}),n&&x_()},unobserve(){let n=Qr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Qr.delete(e),Qr.size||cancelAnimationFrame(S_)}}}}var tx=["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth","borderStyle","boxSizing","color","overflowWrap","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontWeight","fontKerning","lineHeight","letterSpacing","paddingLeft","paddingTop","paddingRight","paddingBottom","width","height","textIndent","whiteSpace","wordBreak","wordSpacing","wordWrap"];function nx(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function ol(e){return Number.parseFloat(e)}function rg(e){return Math.round(e*1e6)}function b_(e){return e/1e6}function rx(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=ol(e.width),s=ol(e.borderLeftWidth),i=ol(e.borderRightWidth),a=ol(e.paddingRight),l=b_(rg(o)-rg(s)-rg(i)),c=b_(rg(r));if(l-c>2){let u=l-c;n.style.paddingRight=`${a+u}px`}}function Tu(e,t={}){var u,f;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(u=t.position)!=null?u:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",mi(n);let r=window.getComputedStyle(e),o=!0,s=()=>{n.scrollTop=e.scrollTop};nx(r,n,tx),rx(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",s));let i=w_(e,()=>{nx(r,n,tx),rx(r,e,n),s(),setTimeout(s,0)}),a,l=!0,c=ex(e,d=>{if(d===null){t.onRemove&&t.onRemove(),n.remove();return}if(!l&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(nx(r,n,tx),rx(r,e,n),s(),t.placement==="below"&&n.classList.add("below"),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let p=t.closestScrollElement.getBoundingClientRect(),h=window.getComputedStyle(t.closestScrollElement),y=ol(h.borderTopWidth),S=ol(h.borderBottomWidth),g=p.top+y-d.top,m=d.top+d.height+-(p.top+p.height-S);n.style.clipPath=`inset(${g}px 0px ${m}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(f=e.parentElement)==null||f.appendChild(n),c.observe(),i.observe(),[n,()=>{e.removeEventListener("scroll",s),c.unobserve(),i.unobserve(),n.remove()}]}function _z(e){return e.offsetParent!==null}function E_(e){if(!_z(e))return!1;let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}function og(e,t,n=100){let r=E_(e);t({isVisible:r});let o=setInterval(()=>{let s=E_(e);s!==r&&(r=s,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var C_=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch(r){return t}}catch(n){return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch(r){ee.warn("[Deepdesk] SessionStorage is blocked by browser")}}});var ke=E(P());var T_=C_("showTabHint",!0),sl=class sl{constructor({deepdeskUrl:t,version:n=sl.version||"unknown",locale:r="en-US",token:o,fetch:s,productName:i,createCustomChannel:a,websocketClient:l=Zm}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.disposeHandlers=[];this.inlineSuggestions=null;this.aboveSuggestions=null;this.belowSuggestions=null;this.floatingMenu=null;this.widgetElement=null;this.widgetRoot=null;this.nicknameDialogUnsubscribe=null;this.nicknameDialogFailed=!1;this.dynamicThunkObject={};this.queues=new eg;this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let c=t.replace(/\/api$/,"");this.deepdeskApi=new No(c,{token:o,fetch:s}),this.version=n,this.instanceId=sl.count++;let u={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[c_({broadcast:(h,y,S)=>{this.broadcastEvents.send(h,y,S)},emit:(h,y)=>this.emit(h,y),handleAfterSendMessage:h=>this.handleAfterSendMessage(h),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:h=>this.logSendMessage(h),onUpdateShowTabHint:h=>T_.update(h),sendEvent:(h,y)=>this.deepdeskApi.sendEvent(h,y)})]};this.store=a_(u),this.broadcastEvents=new GI({debug:!0,deepdeskUrl:c,eventMap:tE(this.store),createCustomChannel:a}),this.disposeHandlers.push(()=>{this.broadcastEvents.cleanup()}),this.ws=new l({url:`${c}/api/v2/me/realtime`.replace("https","wss"),reconnectInterval:25e3,shouldReconnect:()=>_(this,null,function*(){var h;return(h=Pt(this.state))!=null?h:!1})}),this.whenLoggedIn(()=>this.ws.connect()),this.store.dispatch(du(T_.value())),this.store.dispatch(Jd({locale:r,adminUrl:c,productName:i}));let f=[],d=h=>{if(!h.conversationId)return;let y=()=>{this.conversationId()===h.conversationId&&this.store.dispatch(NE(h))};this.hasConversation()?y():f.push(y)};this.ws.on("assistants::direct_response",d),this.ws.on("assistants::user_notification",d),this.ws.on("assistants::response_chunk",h=>{if(!h.conversationId)return;let y=()=>{this.conversationId()===h.conversationId&&this.store.dispatch(OE(h))};this.hasConversation()?y():f.push(y)}),this.ws.on("assistants::suggest_as_reply",h=>{if(!h.conversationId)return;let y=()=>{this.conversationId()===h.conversationId&&this.store.dispatch(Ki([{text:h.payload.message,type:"text",source:"assistant",assistantCode:h.code,sourceLabel:h.name}]))};this.hasConversation()?y():f.push(y)});let p=this.whenConversationLoaded(()=>{var h;this.broadcastEvents.setExternalId((h=this.state.conversation.current)==null?void 0:h.externalId),f.forEach(y=>y()),f.length=0});this.disposeHandlers.push(()=>{this.ws.cleanup(),f.length=0,p()})}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var t;return(t=Ds(this.state)[this.state.input.selectedSuggestionIndex])!=null?t:null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}externalId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.externalId}shouldAbort(){return this.state.conversation.isSupported===!1?(ee.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(ee.warn("Profile has not been loaded (yet)"),!0):(ee.warn("No conversation loaded (yet)"),!0)}whenLoggedIn(t){if(Pt(this.state))t();else{let n=this.subscribe(Pt,r=>{r&&t()});this.disposeHandlers.push(()=>{n()})}}login(){return this.store.dispatch(Wi(null)),this.store.dispatch(to()),new Promise(t=>{this.whenLoggedIn(()=>t())})}isLoggedIn(){return _(this,null,function*(){return(yield this.store.dispatch(to())).payload})}isConversationSupported(t,n){return _(this,null,function*(){return(yield this.store.dispatch(dh({externalId:t,options:n}))).payload})}createConversation(t){return _(this,null,function*(){var r;return this.hasConversation()&&this.externalId()!==t.externalId&&this.resetConversation(),(yield this.store.dispatch(bd(I(b({},t),{metadata:(r=t.metadata)!=null?r:{}})))).payload})}getConversationByExternalId(t,n){return _(this,null,function*(){return this.hasConversation()&&this.externalId()!==t&&this.resetConversation(),(yield this.store.dispatch(Ed({externalId:t,options:n}))).payload})}upsertConversation(t){return _(this,null,function*(){var r;return this.hasConversation()&&this.externalId()!==t.externalId&&this.resetConversation(),(yield this.store.dispatch(fh(I(b({},t),{metadata:(r=t.metadata)!=null?r:{}})))).payload})}postMessages(t){return _(this,null,function*(){yield this.store.dispatch(ph(t))})}updateConversation(t){return _(this,null,function*(){return(yield this.store.dispatch(Cd(t))).payload})}resetConversation(){this.store.dispatch(ut()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(t){this.store.dispatch(Jd(t))}setVisitorInfo(t){this.store.dispatch($b(t))}setCustomData(t){this.store.dispatch(jb(t))}setAgentInfo(t,n){return _(this,null,function*(){var o;yield this.store.dispatch(bl(b(b({},t),n))),(o=this.state.info.agentInfo)!=null&&o.agentNickname||this.broadcastEvents.send(_d,{showNicknameDialog:!0})})}setAgentSettings(t){return _(this,null,function*(){yield this.store.dispatch(gh(t))})}getAgentSettings(){return _(this,null,function*(){return(yield this.store.dispatch(hh())).payload})}refresh(){return _(this,null,function*(){if(this.shouldAbort())return Promise.resolve();let t=[];return t.push(this.refreshTextSuggestions()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}syncInputMediator(){this.inputMediator&&this.store.dispatch(Rd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),suggestionTextStart:this.inputMediator.getSuggestionTextStart()}))}notifyExternalSuggestion(t){this.store.dispatch(kn(t))}evaluateAssistant(t,n){return _(this,null,function*(){var u;let{input:r={},attachments:o=[],transcript:s,showCuesInWidget:i=!0,includeMetadata:a,externalConversationId:l}=n||{},c=yield this.store.dispatch(mn({assistantCode:t,attachments:o,transcript:s,includeMetadata:a,input:r,externalConversationId:l,skipState:!i}));if(c.error)throw new Error(`Assistant evaluation failed: ${(u=c.payload)!=null?u:c.error.message}`);return c.payload.output})}evaluateConversationAssistant(t,n){return _(this,null,function*(){var u,f,p;yield this.loadProfileConfig();let r=this.state.profile.data;if(!r&&((u=this.state.conversation.current)!=null&&u.profileCode)&&(yield this.loadProfileConfig(),r=this.state.profile.data),!r){ee.warn("Can't evaluate assistant when profile is not loaded yet.");return}let o=f_(r,t),s=(f=n==null?void 0:n.showCuesInWidget)!=null?f:!0,d=n!=null?n:{},{showCuesInWidget:i}=d,a=se(d,["showCuesInWidget"]),l=(p=n==null?void 0:n.externalConversationId)!=null?p:this.hasConversation()?this.externalId():"",c=yield Promise.all(o.map(h=>this.queues.push(h,()=>_(this,null,function*(){var S,g;let y=yield this.store.dispatch(mn(b(I(b({assistantCode:h,includeMetadata:!0},a),{skipState:!s}),n!=null&&n.attachments&&(n==null?void 0:n.attachments.length)>0?{attachments:n==null?void 0:n.attachments}:{})));if(y.error)throw new Error(`Assistant evaluation failed: ${(S=y.payload)!=null?S:y.error.message}`);return{assistantCode:h,evaluationId:y.payload.evaluationId,output:y.payload.output,externalConversationId:(g=y.payload.externalConversationId)!=null?g:l}})).catch(y=>{if(y instanceof Cu)return ee.warn(`Queued assistant "${h}" was outdated and dropped`),null;throw y})));if(!s)return c.filter(h=>h!==null)})}handleKeyDown(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:s,selection:i}=this.state.input,{inlineSuggestions:a,autoSelectSuggestion:l,showTextSuggestions:c,suggestionsPlacement:u}=this.settings,f=a||l,d=u==="inline"||u==="below"?"below":"above",p=o.length>0;if(this.store.dispatch(_b(mh(t))),!Gr(this.state)||t.key!=="Tab"&&!c)return;let h=()=>{n||!p||i&&(t.shiftKey||(this.store.dispatch(Nb()),t.preventDefault()))},y=()=>{n||!p||f&&s<=0||i&&(t.shiftKey||(this.store.dispatch(Lb()),t.preventDefault()))};switch(t.key){case"ArrowUp":d==="below"?y():h();break;case"ArrowDown":{d==="below"?h():y();break}case"Escape":{n||(this.store.dispatch(kd(-1)),this.store.dispatch(ws({collapse:!0})),this.store.dispatch(PA(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let S=ji(this.state);if(!S)return;this.store.dispatch(du(!1)),this.store.dispatch(kn({text:S.text,suggestion:S,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(f||this.state.input.selectedSuggestionIndex===-1)return;let S=ji(this.state);if(!S)return;this.store.dispatch(kn({text:S.text,suggestion:S,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(f||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let S=ji(this.state);if(!S)return;this.store.dispatch(kn({text:S.text,suggestion:S,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(ws({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(Uo([]))}handlingTimeStart(){this.state.handlingTime.startTime||(ee.info("Start handling time"),this.store.dispatch(JI()))}handlingTimeStop(){this.state.handlingTime.startTime&&(ee.info("Stop handling time"),this.store.dispatch(Jm()))}logSendMessage(t){let n=d_(this.state,{version:this.version});n&&(t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEvent("Send Message",{conversationId:this.conversationId(),data:n}),this.emit("send-message-event",n))}logHandlingTime(){let t=u_(this.state,{version:this.version});t&&(this.deepdeskApi.sendEvent("Handling Time",{conversationId:this.conversationId(),data:t}),this.store.dispatch(e_()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(zs((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(Fb()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(s){ee.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),ee.error(s)}})}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),()=>{this.off(t,n)}}off(t,n){if(!t&&!n){this.eventListeners={};return}let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}setConversationQuery(t){this.dynamicThunkObject.conversationQuery=t}setPlatformVariables(t){this.store.dispatch(Kb(t))}whenConversationLoaded(t){let n=s=>{var i;return(i=s.conversation.current)==null?void 0:i.id},r=()=>this.loadProfileConfig().then(()=>t());return n(this.state)&&r(),this.subscribe(n,s=>{s&&r()})}overlayContainerFactory(t,n,r,o){let[s,i]=Tu(n,r);return s.setAttribute("translate","no"),s.dataset.testid=t,o&&s.classList.add(o),[s,i]}createInlineContainer(t,n){var a;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let s=(a=t.ownerDocument.defaultView)==null?void 0:a.frameElement,i=s?s.ownerDocument.defaultView:null;if(s&&(i===window||(i==null?void 0:i.parent)===window)){let[l,c]=Tu(s,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{c()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return mi(o),o.dataset.testid=t,o.style.color=r.color,o.style.fontSize=r.fontSize,o.style.fontFamily=r.fontFamily,o.style.fontVariant=r.fontVariant,o.setAttribute("translate","no"),n.appendChild(o),o}storeMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(t,n),ee.info(`Stored analytics for ${this.conversationId()}`)}catch(t){}}restoreMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(t);if(!n)return;let r=JSON.parse(n);r.text.trim()===this.state.input.text.trim()?(ee.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(Db(r.metrics))):ee.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch(t){}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!tg(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let d=n,{customStyles:r,closestScrollSelector:o,floatingMenuParent:s,appendOverlayTo:i,inputMediator:a}=d,l=se(d,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),c={customStyles:r,closestScrollSelector:o,floatingMenuParent:s,appendOverlayTo:i};this.configure(l),this.settings.automaticHandlingTime&&this.setupHandlingTime(t),mi(t),this.inputMediator=a||(ki(t)?new Ai(t):new Pi(t)),this.inputMediator.on("change",({plainText:p,rawHTML:h,suggestionTextStart:y})=>{this.store.dispatch(Rd({text:p,html:h,suggestionTextStart:y}))}),this.inputMediator.on("keyup",p=>{this.store.dispatch(Mb(mh(p)))}),this.inputMediator.on("keydown",p=>{this.handleKeyDown(p)}),this.inputMediator.on("paste",({pastedText:p,selectionText:h})=>{this.store.dispatch(Ob({text:p,selectionText:h}))}),this.inputMediator.on("cut",({selectionText:p})=>{this.store.dispatch(Ib(p))});let u;this.inputMediator.on("selection",p=>{clearTimeout(u),p===null?u=setTimeout(()=>{p!==null&&this.store.dispatch(Pd(p))},500):this.store.dispatch(Pd(p))}),this.unmountHandlers.push(()=>{clearTimeout(u)}),this.inputMediator.on("disabled",()=>{var p;(p=this.inputMediator)==null||p.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{this.settings.detectSubmit&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(Cm(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(Cm(!0))}),this.renderSuggestions(t,c),this.subscribe(Ws("inlineSuggestions"),()=>{this.renderSuggestions(t,c)}),this.subscribe(Ws("suggestionsPlacement"),()=>{this.renderSuggestions(t,c)});let f=this.renderOverlays(n);this.unmountHandlers.push(()=>{f.unmount()}),this.store.dispatch(Rd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),suggestionTextStart:this.inputMediator.getSuggestionTextStart()})),this.store.dispatch(Pd(this.inputMediator.getSelection())),this.store.dispatch(Cm(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{this.restoreMetrics(),this.syncInputMediator(),this.refreshTextSuggestions(),this.promptForNickname()}),this.isMounted=!0}promptForNickname(t){if(this.nicknameDialogUnsubscribe||this.nicknameDialogFailed)return;let n=this.createContainer("nickname-dialog",document.body);document.body.appendChild(n);let r=(0,Lo.createRoot)(n),o=null,s=a=>{o=a,i()},i=()=>{r==null||r.render((0,ke.jsx)(Po,{store:this.store,children:(0,ke.jsx)(ro,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(jA,{id:"deepdesk-nickname-dialog",error:o,onSave:a=>_(this,null,function*(){try{yield this.store.dispatch(Vb({agentNickname:a})).unwrap(),console.log("setAgentNickname",a),this.broadcastEvents.send(_d,{showNicknameDialog:!1}),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe()}catch(l){ee.error("Error setting agent nickname",l),s("error"),this.nicknameDialogFailed=!0}})})})}))};i(),this.nicknameDialogUnsubscribe=()=>{r.unmount(),n.remove(),this.nicknameDialogUnsubscribe=null}}subscribe(t,n){let r=t(this.store.getState());return this.store.subscribe(()=>{let o=t(this.store.getState());o!==r&&(r=o,n(r))})}unmount(){var t,n,r,o,s;(t=this.inlineSuggestions)==null||t.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(r=this.belowSuggestions)==null||r.unmount(),(o=this.floatingMenu)==null||o.unmount(),this.unmountHandlers.forEach(i=>i()),this.unmountHandlers=[],(s=this.inputMediator)==null||s.dispose(),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe(),this.isMounted=!1}dispose(){this.unmount(),this.unmountWidget(),this.disposeHandlers.forEach(t=>t()),this.disposeHandlers=[],this.off()}renderSuggestions(t,n){var r,o,s,i;(r=this.floatingMenu)==null||r.unmount(),(o=this.inlineSuggestions)==null||o.unmount(),(s=this.aboveSuggestions)==null||s.unmount(),(i=this.belowSuggestions)==null||i.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(t,n)),this.settings.inlineSuggestions||this.settings.suggestionsPlacement==="inline"?this.inlineSuggestions=this.renderInlineSuggestions(t,n):this.settings.suggestionsPlacement==="below"?this.belowSuggestions=this.renderAboveOrBelowSuggestions(t,n,"below"):this.aboveSuggestions=this.renderAboveOrBelowSuggestions(t,n,"above")}renderInlineSuggestions(t,n){let{customStyles:r}=n,o=this.createInlineContainer(t,"deepdesk-caret"),s=(0,Lo.createRoot)(o);s.render((0,ke.jsx)(Po,{store:this.store,customStyles:r,children:(0,ke.jsx)(ro,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(WA,{})})}));let i=a=>{a?(o.style.display="block",o.style.top=`${a.top}px`,o.style.left=`${a.left}px`):o.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var a;(a=this.inputMediator)==null||a.off("caretposition",i),s.unmount(),o.remove()}}}renderAboveOrBelowSuggestions(t,n,r){let{customStyles:o,closestScrollSelector:s,appendOverlayTo:i}=n,a=s&&JS(t,s)||void 0,[l,c]=this.overlayContainerFactory("deepdesk-tab-completion",a||t,{appendTo:i,closestScrollElement:a,mirrorOverflow:!0,onRemove:()=>this.unmount()},o==null?void 0:o.rootNode),[u,f]=this.overlayContainerFactory("deepdesk-suggestions-overlay",a||t,{appendTo:i,placement:r},o==null?void 0:o.suggestionsRootNode),d=(0,Lo.createRoot)(l);d.render((0,ke.jsx)(Po,{store:this.store,customStyles:o,children:(0,ke.jsx)(ro,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(gI,{inputElement:t})})}));let p=(0,Lo.createRoot)(u);return p.render((0,ke.jsx)(Po,{store:this.store,customStyles:o,children:(0,ke.jsx)(ro,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(eI,{onLogIn:()=>this.loginViaPopup().catch(h=>ee.warn(h.message))})})})),{unmount(){d.unmount(),p.unmount(),c(),f()}}}renderFloatingMenu(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:s,floatingMenuParent:i}=n,a=o&&JS(t,o)||void 0,[l,c]=this.overlayContainerFactory("floating-menu",a||t,{appendTo:i!=null?i:s},r==null?void 0:r.floatingMenuParent),u=(0,Lo.createRoot)(l);return u.render((0,ke.jsx)(Po,{store:this.store,customStyles:r,children:(0,ke.jsx)(ro,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(kA,{onLogIn:()=>this.loginViaPopup().catch(f=>ee.warn(f.message))})})})),{unmount(){u.unmount(),c()}}}renderOverlays(t){let{customStyles:n}=t,r=this.createContainer("deepdesk-overlays"),o=(0,Lo.createRoot)(r);return o.render((0,ke.jsx)(Po,{store:this.store,customStyles:n,children:(0,ke.jsx)(ro,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(wA,{})})})),{unmount(){o.unmount(),r.remove()}}}renderWidget(t,n={}){if(this.widgetElement&&ee.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,isEmbedded:s,signInViaPopup:i,ssoUrl:a,openAdminFeedback:l}=n;this.widgetElement=t,this.configure({showImages:o,isEmbedded:s,signInViaPopup:i});let c;if(a)try{c={url:new URL(a,this.settings.adminUrl).toString()}}catch(u){ee.warn(`Invalid ssoUrl '${a}' passed to renderWidget`)}this.widgetRoot=(0,Lo.createRoot)(t),this.widgetRoot.render((0,ke.jsx)(Po,{store:this.store,customStyles:r,children:(0,ke.jsx)(ro,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(UI,{assistantOptions:n.assistantOptions,knowledgeAssistOptions:n.knowledgeAssist,openAdminFeedback:l,onLogIn:()=>this.loginViaPopup(c).catch(u=>ee.warn(u.message))})})}))}unmountWidget(){var t,n;(n=(t=this.widgetRoot)==null?void 0:t.unmount)==null||n.call(t),this.widgetRoot=null,this.widgetElement=null}renderKnowledgeAssistantWidget(t,n,r={}){let{customStyles:o,initialQuestion:s}=r,i=(0,Lo.createRoot)(n);return i.render((0,ke.jsx)(Po,{store:this.store,customStyles:o,children:(0,ke.jsx)(ro,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(KS,{children:(0,ke.jsxs)(nm,{assistantCode:t,initialQuestion:s,evaluateKnowledgeAssistFn:Bl,children:[(0,ke.jsx)(Hi,{children:(0,ke.jsx)(om,{title:r.title,emptyState:r.emptyState})}),(0,ke.jsx)(jS,{children:(0,ke.jsx)(rm,{})})]})})})})),{unmount(){i.unmount()}}}setupHandlingTime(t){let n=og(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){p_(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){var t;return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(t=this.state.conversation.current)!=null&&t.profileCode?(this.loadProfileConfigPromise=Promise.resolve().then(()=>_(this,null,function*(){yield this.store.dispatch(qc()).unwrap();let n=gs(this.state);n&&this.store.dispatch(Jd({showSearch:n.search,showImageSearch:n.imageSearch,showEntitiesCommand:n.entitiesCommand,showSummaryCommand:!!n.summarizerAssistantNew,showKnowledgeSearch:!!n.knowledgeAssistantNew||!!n.knowledgeAssistant,recommendTextSuggestions:n.recommendTextSuggestions}))})).finally(()=>{gs(this.state)||(this.loadProfileConfigPromise=null)}),this.loadProfileConfigPromise):Promise.resolve()}loginViaPopup(t){return _(this,null,function*(){return new Promise((n,r)=>{this.store.dispatch(xd());let o=new MessageChannel,s=o.port1,i=this.settings.adminUrl,a=new URL(t!=null&&t.url?t==null?void 0:t.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,c=()=>{u&&!u.closed&&u.close(),window.removeEventListener("message",f),clearInterval(d)};s.onmessage=p=>_(this,null,function*(){var h,y;if((h=p.data)!=null&&h.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((y=p.data)==null?void 0:y.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(Cl),l=!0,o.port1.close(),n()}catch(S){console.error(S),r(S)}finally{l=!0,c()}});let u=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");u===null&&r(new Error("Popup blocked by browser"));let f=p=>_(this,null,function*(){var h;if(p.origin===a.origin)switch((h=p.data)==null?void 0:h.type){case"deepdesk-popup-request-origin":{try{let y=JSON.stringify({type:"deepdesk-popup-parent-origin"});u==null||u.postMessage(y,a.origin)}catch(y){ee.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-loaded":{try{let y=JSON.stringify({type:"deepdesk-popup-create-channel"});u==null||u.postMessage(y,a.origin,[o.port2])}catch(y){ee.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-error":{if(c(),p.data.message==="Platform account url mismatch"){let y=`Please contact your administrator: The platform account url (${p.data.targetOrigin}) is misconfigured as it differs from the origin of the page that opened the popup (${p.data.openerOrigin}).`;ee.warn(y),this.store.dispatch(lh(y)),r(new Error(y))}if(p.data.message==="Timeout"){let y="Please contact your administrator: Popup timed out. Check if the account's platform url is configured correctly.";ee.warn(y),this.store.dispatch(lh(y)),r(new Error(y))}r(new Error(p.data.message));break}}});window.addEventListener("message",f);let d=setInterval(()=>{u&&!u.closed||(c(),l||r(new Error("Popup closed by user")))},200);this.disposeHandlers.push(c)})})}translateMessages(t){return this.deepdeskApi.translateMessages(t)}refreshTextSuggestions(){return _(this,null,function*(){this.isMounted&&(yield this.store.dispatch(wm()))})}refreshWidgetSuggestions(){return _(this,null,function*(){if(!this.widgetRoot)return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=Yc(this.state);try{n.forEach(({type:r})=>{switch(r){case"entities":this.store.dispatch(Sr());break;case"pinned-messages":case"sticky-messages":break;default:Yu.includes(r)||this.store.dispatch(xr(r))}})}catch(r){this.handleError(r)}})}};sl.version="19.6.0",sl.count=0;var ku=sl;function Mz(e){return _(this,null,function*(){var o,s,i;let n=yield((o=e.fetch)!=null?o:window.fetch)(e.url),r=yield n.blob();return new File([r],e.name,{type:(i=(s=e.mimeType)!=null?s:n.headers.get("Content-Type"))!=null?i:"image/jpeg"})})}function k_(e,t){return _(this,null,function*(){let n=yield Mz(t),r=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(e,"files",{configurable:!0,get:()=>[n]}),e.dispatchEvent(r)}finally{Object.hasOwn(e,"files")&&delete e.files}})}function R_(e,t,n){return _(this,null,function*(){yield new No(e).authenticateWithKey(t,n)})}function P_(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function A_(r,o){return _(this,arguments,function*(e,t,n={}){var f,d;let{value:s}=e,{start:i,end:a}=(f=n.replace)!=null?f:{start:0,end:s.length},l=`${s.slice(0,i)}${t}${s.slice(a)}`,c=(d=n.selectionAfter)!=null?d:{start:i+t.length,end:i+t.length},u=()=>{if(n.setValue)return n.setValue(l);e.value=l};return Promise.resolve(u()).then(()=>{e.selectionStart=c.start,e.selectionEnd=c.end,e.blur(),e.focus()})})}function I_(r,o){return _(this,arguments,function*(e,t,n={}){let s=n.replace?Rs(e,n.replace.start,n.replace.end):nl(e),i,a=()=>{if(n.setRange)return n.setRange(s.cloneRange());s.deleteContents(),i=document.createElement("span"),s.insertNode(i),n.insertBRs!==!1?t.split(`
84
84
  `).reverse().forEach((l,c)=>{c>0&&s.insertNode(document.createElement("br")),s.insertNode(document.createTextNode(l))}):s.insertNode(document.createTextNode(t))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){e.focus();let l=n.selectionAfter?Rs(e,n.selectionAfter.start,n.selectionAfter.end):(s.collapse(!1),s),c=window.getSelection();c==null||c.removeAllRanges(),c==null||c.addRange(l)}if(!i)return;i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}function Oz(e){let t=document.createElement("template");return t.innerHTML=e.replace(/(\[([^\]]+)])\(([^)]+)\)/g,'<a href="$3" target="_blank" rel="noopener noreferrer">$2</a>'),t.content}function Nz(e){let t=document.createDocumentFragment();return e.split(`
85
85
  `).forEach((n,r)=>{r>0&&t.appendChild(document.createElement("br"));let o={index:0},s=0;for(;o=n.slice(s).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=o[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(o[2])),t.appendChild(document.createTextNode(n.slice(s,s+o.index))),t.appendChild(i),s=s+o.index+o[0].length}t.appendChild(document.createTextNode(n.slice(s)))}),t}function __(e,t){let n=e.parentElement;if(!n){console.warn("No insert point found");return}let{display:r}=window.getComputedStyle(n);r.includes("block")||r==="table-cell"?n==null||n.insertBefore(t,e.nextSibling):__(n,t)}function M_(o,s){return _(this,arguments,function*(e,t,{isBlock:n,isHTML:r}={}){let i;e.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0}));let a=()=>{var d;let l=(d=e.ownerDocument.defaultView)!=null?d:window,c=l.getSelection();if((!c||c.rangeCount===0)&&(e.focus(),c=l.getSelection()),!c||c.rangeCount===0)return;let u=c.getRangeAt(0);if(!u)return;i=document.createElement("span"),u.insertNode(i);let f=r?Oz(t):Nz(t);n?__(u.startContainer,f):(u.insertNode(f),u.collapse(!1))};return Promise.resolve(a()).then(()=>{if(e.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0})),e.focus(),!!i)try{i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}return tM(Lz);})();
86
86
  /*! Bundled license information:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepdesk/deepdesk-sdk",
3
- "version": "19.5.1-beta.2",
3
+ "version": "19.6.0",
4
4
  "description": "Deepdesk SDK",
5
5
  "author": "Lukas Batteau",
6
6
  "license": "ISC",