@deepdesk/deepdesk-sdk 19.1.2-beta.1 → 19.2.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.
package/dist/index.esm.js CHANGED
@@ -1,12 +1,12 @@
1
- var vi=Object.defineProperty,Ou=Object.defineProperties;var Du=Object.getOwnPropertyDescriptors;var zn=Object.getOwnPropertySymbols;var xi=Object.prototype.hasOwnProperty,Si=Object.prototype.propertyIsEnumerable;var yi=(t,e,n)=>e in t?vi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,y=(t,e)=>{for(var n in e||(e={}))xi.call(e,n)&&yi(t,n,e[n]);if(zn)for(var n of zn(e))Si.call(e,n)&&yi(t,n,e[n]);return t},x=(t,e)=>Ou(t,Du(e));var M=(t,e)=>{var n={};for(var o in t)xi.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&zn)for(var o of zn(t))e.indexOf(o)<0&&Si.call(t,o)&&(n[o]=t[o]);return n};var X=(t,e)=>{for(var n in e)vi(t,n,{get:e[n],enumerable:!0})};var v=(t,e,n)=>new Promise((o,r)=>{var s=d=>{try{a(n.next(d))}catch(l){r(l)}},i=d=>{try{a(n.throw(d))}catch(l){r(l)}},a=d=>d.done?o(d.value):Promise.resolve(d.value).then(s,i);a((n=n.apply(t,e)).next())});import Ci from"classnames";import Uu,{createContext as Ku,useContext as Er,useEffect as zu,useState as Wu}from"react";import _u,{useContext as Fu}from"react";import Hu from"classnames";var rn=_u.createContext({});function S(t,e){let s=Fu(rn),{debug:n}=s,r=M(s,["debug"])[t];return Object.entries(e).reduce((i,[a,d])=>{let l=r==null?void 0:r[a];return x(y({},i),{[a]:Hu(d,l,n?`${t}__${a}`:!1)})},{})}var bi={root:"dd-4s9wq"};import{jsx as Wn,jsxs as Bu}from"react/jsx-runtime";var Vn=()=>Bu("svg",{className:bi.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[Wn("defs",{children:Wn("style",{children:".cls-1 { fill: #b3b3b3; }"})}),Wn("title",{children:"Failed loading image"}),Wn("path",{className:"cls-1",d:"M15 130.896V16.994c0-1.097.898-1.994 2.007-1.994h150.986A2 2 0 0 1 170 16.994v69.147L133.015 51 87.26 120.377l-35.863-17.758L15 130.896zM2 0C.895 0 0 .887 0 2v166c0 1.105.887 2 2 2h181c1.105 0 2-.887 2-2V2c0-1.105-.887-2-2-2H2zm49 72c11.046 0 20-9.178 20-20.5S62.046 31 51 31s-20 9.178-20 20.5S39.954 72 51 72z",fillRule:"evenodd"})]});var wr={root:"dd-c9KvZ",imageWrapper:"dd-sE7D9",image:"dd-bEGMz",content:"dd-oFIQa",title:"dd-mSgoo",contentIsCropped:"dd-Uvjv4",lineClamp:"dd-ApQo-"};import{jsx as wt}from"react/jsx-runtime";var jn=Ku(wr),Vu=({title:t,src:e})=>{let n=Er(jn),[o,r]=Wu(!1);return zu(()=>{r(!1)},[e]),wt("div",{className:n.imageWrapper,children:e&&!o?wt("img",{className:n.image,alt:t,src:e,onError:()=>r(!0)}):wt(Vn,{})})},ju=({className:t,lineClamp:e=!1,cropText:n=!1,children:o})=>{let r=Er(jn);return wt("div",{className:Ci(r.content,t,{[r.contentIsCropped]:n,[r.lineClamp]:e}),children:o})},$u=s=>{var i=s,{as:t="h1",cropText:e=!1,className:n,children:o}=i,r=M(i,["as","cropText","className","children"]);let a=Er(jn);return Uu.createElement(t,y({className:Ci(a.title,n,{[a.contentIsCropped]:e})},r),o)},$n=({children:t})=>{let e=S("Card",wr);return wt("div",{className:e.root,children:wt(jn.Provider,{value:e,children:t})})};$n.Image=Vu;$n.Content=ju;$n.Title=$u;var D=$n;import Gu from"classnames";var Ti={root:"dd-llBx9"};import{jsx as Ju}from"react/jsx-runtime";var qu={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Xu=o=>{var r=o,{className:t,keyCode:e}=r,n=M(r,["className","keyCode"]);let s=S("KeyboardHint",Ti);return Ju("span",y({"data-key":qu[e],className:Gu(t,s.root)},n))},kr=Xu;import Qu from"classnames";var wi={root:"dd-e6HXZ"};import{jsx as ep}from"react/jsx-runtime";var Zu=o=>{var r=o,{className:t,children:e}=r,n=M(r,["className","children"]);let s=S("Label",wi);return ep("span",x(y({},n),{className:Qu(t,s.root),children:e}))},Yu=Zu;var Ei={root:"dd-FiMI7",subTitleContainer:"dd-98jc7",subtitle:"dd-3MnW8",suggestions:"dd-0SGL8"};import{jsx as Rr,jsxs as np}from"react/jsx-runtime";var tp=r=>{var s=r,{title:t,children:e,type:n}=s,o=M(s,["title","children","type"]);let i=S("Section",Ei);return np("section",x(y({},o),{className:i.root,"data-section-type":n,children:[t&&Rr("div",{className:i.subTitleContainer,children:Rr("span",{className:i.subtitle,children:t})}),Rr("div",{className:i.suggestions,children:e})]}))},Le=tp;import lp from"classnames";import{useRef as dp}from"react";import{createContext as op,useCallback as rp,useContext as sp,useEffect as ip}from"react";import{jsx as ap}from"react/jsx-runtime";var ki=op(null),Ri=({scrollContainerRef:t,children:e})=>{let n=rp(o=>{let r=t.current;if(!r||r.scrollHeight<=r.clientHeight)return;let{top:s}=r.getBoundingClientRect(),{top:i}=o.getBoundingClientRect(),a=r.scrollTop+(i-s);typeof r.scrollTo=="function"?r.scrollTo({top:a}):r.scrollTop=a},[]);return ap(ki.Provider,{value:n,children:e})},Gn=t=>{let e=sp(ki);ip(()=>{let n=t.current;n&&e(n)},[])};var Pi={root:"dd-uoTXh"};import{jsx as Ii}from"react/jsx-runtime";var cp=({className:t,children:e})=>{let n=S("SectionList",Pi),o=dp(null);return Ii(Ri,{scrollContainerRef:o,children:Ii("div",{ref:o,className:lp(n.root,t),children:e})})},sn=cp;import an from"classnames";import up,{createContext as pp,useCallback as gp,useContext as nt}from"react";var Pr={root:"dd-1g-A9",fadein:"dd-McXxq",isClickable:"dd-CTG8E",isSelected:"dd-yhg27",actions:"dd-Nlm6p",actionsIsFixed:"dd-OK-kw",actionButton:"dd-zbXsQ",dropdownList:"dd-AvwWP",dropdownButton:"dd-piaJi",dropdownItem:"dd-qgkTO",dropdownItemButton:"dd-sTE2D",actionButtonIsPrimary:"dd-mhkWS",actionButtonIsDisabled:"dd-0eKLQ",labels:"dd-QKJu6",label:"dd-aMplE",buttonsContainer:"dd-uRYN4",button:"dd-9UE-x",buttonPrimary:"dd-aYDCB",buttonSecondary:"dd--cpPL",buttonWithIcon:"dd-MQVt5",icon:"dd-Jr-ww",buttonDisabled:"dd-agTuH"};import{jsx as ue,jsxs as Li}from"react/jsx-runtime";var We=pp(Pr),mp=o=>{var r=o,{fixed:t,children:e}=r,n=M(r,["fixed","children"]);let s=nt(We);return ue("div",x(y({},n),{className:an(s.actions,{[s.actionsIsFixed]:t}),children:e}))};function fp(d){var l=d,{as:t,className:e,icon:n,title:o,children:r,disabled:s,variant:i}=l,a=M(l,["as","className","icon","title","children","disabled","variant"]);let c=nt(We);return Li(t||"button",x(y({type:"button",className:an(c.button,{[c.buttonWithIcon]:n,[c.buttonDisabled]:s,[c.buttonPrimary]:i==="primary",[c.buttonSecondary]:i==="secondary"},e),title:o,"aria-label":o},a),{children:[n&&ue("span",{className:c.icon,children:n}),r]}))}var hp=({children:t})=>{let e=nt(We);return ue("div",{className:e.buttonsContainer,children:t})},yp=({className:t,primary:e,disabled:n,label:o,children:r})=>{let s=nt(We);return Li("div",{className:an(t,s.actionButton,s.dropdownButton,{[s.actionButtonIsPrimary]:e,[s.actionButtonIsDisabled]:n}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[o,ue("ul",{className:s.dropdownList,children:r})]})},vp=({index:t,label:e,onClick:n})=>{let o=nt(We);return ue("li",{className:o.dropdownItem,children:ue("button",{className:o.dropdownItemButton,type:"button","data-index":t,onClick:n,children:e})})},xp=({className:t,primary:e,disabled:n,onClick:o,label:r})=>{let s=nt(We);return ue("button",{type:"button",className:an(t,s.actionButton,{[s.actionButtonIsPrimary]:e,[s.actionButtonIsDisabled]:n}),onClick:o!=null?o:(i=>i.stopPropagation()),disabled:n,"aria-hidden":n,children:r})},Sp=({labels:t})=>{let e=nt(We);return ue("div",{className:e.labels,children:t.map(n=>ue("span",{className:e.label,children:n},n))})},Ve=up.forwardRef((a,i)=>{var d=a,{className:t,selected:e,onClick:n,children:o,as:r="div"}=d,s=M(d,["className","selected","onClick","children","as"]);let l=S("Suggestion",Pr),c=gp(p=>{p.preventDefault(),n&&n(p)},[n]);return ue(r,x(y({},s),{ref:i,className:an(t,l.root,{[l.isSelected]:e,[l.isClickable]:!!n}),onClick:c,children:ue(We.Provider,{value:l,children:o})}))});Ve.Labels=Sp;Ve.Actions=mp;Ve.ActionButton=xp;Ve.DropdownButton=yp;Ve.DropdownItem=vp;Ve.ButtonsContainer=hp;Ve.Button=fp;var I=Ve;import bp from"classnames";var Ai={root:"dd-W35K-",isWithDivider:"dd-sscOy"};import{jsx as Tp}from"react/jsx-runtime";var Cp=({withDivider:t,children:e})=>{let n=S("SuggestionList",Ai);return Tp("div",{"data-testid":"suggestions-overlay-list",className:bp(n.root,{[n.isWithDivider]:t}),children:e})},te=Cp;import wp from"classnames";var Mi={root:"dd-oWarc",isCollapsed:"dd-tfZI0"};import{jsx as Ir}from"react/jsx-runtime";var Ep=({className:t,isCollapsed:e,title:n,onClick:o})=>{let r=S("ToggleButton",Mi);return Ir("button",{type:"button",className:wp(r.root,t,{[r.isCollapsed]:e}),onClick:o,title:n,children:Ir("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:Ir("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Et=Ep;var Ni=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,qn=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Oi=/x-deepdesk-(([a-z0-9\-_])+-version)/,Xn=["cues","custom-data","custom-data-banner","knowledge-assist"],Di=Intl.DateTimeFormat().resolvedOptions().timeZone,je=(g=>(g.SEARCH="search",g.TEMPLATE="template",g.ELASTIC_SEARCH="search-autocomplete",g.GPT="gpt",g.TRIE="trie",g.TRIE_WITH_TYPOS="trie-with-typos",g.SEMANTIC="semantic",g.TEXT_RECOMMENDATION="text_recommendation",g.URL_RECOMMENDATION="url_recommendation",g.LINK_RECOMMENDATION="link_recommendation",g.PERSONAL_COLLECTION="personal-collection",g.PERSONAL_COLLECTION_SEARCH="personal-collection-search",g.SEARCH_OVERLAY="search-overlay",g.SEARCH_PREVIEW="search-preview",g.SEARCH_URL="search-url",g))(je||{}),kt=(i=>(i.ENTER="enter",i.TAB="tab",i.ARROW="arrow",i.HOTKEY="hotkey",i.MOUSE="mouse",i.SPACE="space",i))(kt||{});import{createRoot as tt}from"react-dom/client";import{Fragment as If}from"react";import{createSlice as kp}from"@reduxjs/toolkit";import{useSelector as Rp}from"react-redux";var Jn=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(Jn||{});var Pp={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showImages:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,addToPersonalCollection:!1,inlineSuggestions:!1,suggestionsPlacement:"above",floatingMenu:!1,detectSubmit:!1,automaticHandlingTime:!1,enableSuggestionFeedback:!1,enableFeedbackForm:!0,adminUrl:void 0,productName:"Deepdesk",hasKeyboardInput:!0},_i=kp({name:"settings",initialState:Pp,reducers:{set(t,e){Object.entries(e.payload).forEach(n=>{let[o,r]=n;typeof r!="undefined"&&(t[o]=r)})}}}),{set:Qn}=_i.actions,Rt=t=>e=>e.settings[t],E=t=>Rp(Rt(t)),Fi=_i.reducer;import{useSelector as za}from"react-redux";import{createAsyncThunk as Lr,createSlice as Ip}from"@reduxjs/toolkit";var Lp={isLoggedIn:null,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1,loginError:null},J=t=>t.auth.isLoggedIn;var Hi=t=>t.auth.verifyFetchState,Bi=t=>t.auth.showLoginOverlay,Ui=t=>t.auth.loginError,Ae=Lr("auth/validate",(t,e)=>v(null,null,function*(){return e.extra.deepdeskAPI.isLoggedIn()})),Ki=Lr("auth/requestLogin",(n,o)=>v(null,[n,o],function*({email:t},e){let{deepdeskAPI:r}=e.extra;return r.requestLoginByEmail(t)})),ln=Lr("auth/verifyLoginToken",(n,o)=>v(null,[n,o],function*({token:t},e){let{deepdeskAPI:r}=e.extra;return r.verifyLoginToken(t)})),zi=Ip({name:"auth",initialState:Lp,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload},setLoginError(t,e){t.loginError=e.payload},clearLoginError(t){t.loginError=null}},extraReducers:t=>{t.addCase(Ae.pending,e=>{e.loginFetchState="loading"}),t.addCase(Ae.fulfilled,(e,{payload:n})=>{e.isLoggedIn=n,e.loginFetchState="done"}),t.addCase(Ae.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(ln.pending,e=>{e.verifyFetchState="loading"}),t.addCase(ln.rejected,e=>{e.verifyFetchState="error"}),t.addCase(ln.fulfilled,(e,n)=>{n.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Pt,setShowLoginOverlay:Wi,setLoginError:Ar,clearLoginError:Zn}=zi.actions,Vi=zi.reducer;import{createAction as Up,createSelector as Qi,createSlice as Kp}from"@reduxjs/toolkit";import{diffChars as zp}from"diff";function ji(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function $e(t,e,n=10){let o=typeof t,r=typeof e;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return o!==r?!1:t==null||o==="string"||o==="number"||o==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((s,i)=>$e(s,e[i],n-1)):ji(t)&&ji(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>$e(t[i],e[i],n-1)):!1}function Ap(t){return Math.max(...t.map(e=>e.length))}function Mp(t,e){let n=t.reduce((o,r)=>{if(r){let s=o[r]?o[r]+1:1;return x(y({},o),{[r]:s})}return o},{});return Object.keys(n).reduce((o,r)=>(n[r]<e&&o.push(r),o),[])}function $i(t,e){let o=[...t.map(({text:r})=>r.split(/\b(\w+)\b/))];for(let r=0;r<Ap(o);r++){let s=Mp(o.map(a=>a[r]),e),i=o.filter(a=>!s.includes(a[r]));if(i.length>=e)o=i;else return{text:o[0].slice(0,r).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var Np=2;function Gi(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let n=$i(t,Np);return n&&n.text!==e?n:t[0]}import{createAction as Dp,createAsyncThunk as It,createSlice as _p}from"@reduxjs/toolkit";var Op={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},k=Op;var qi={current:null,isSupported:null},V=Dp("resetConversation"),Xi=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.externalId)||null},Se=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Lt=t=>t.conversation.isSupported,Mr=It("conversation/isSupported",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.isConversationSupported(t.externalId,t.options)}),Yn=It("conversation/create",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.createConversation(t)}),eo=It("conversation/byExternalId",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationByExternalId(t.externalId,t.options)}),to=It("conversation/update",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=Se(e.getState());if(!o)throw new Error("No current conversation to update");return n.updateConversation(o,t)}),Nr=It("conversation/upsert",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationByExternalId(t.externalId).catch(()=>null).then(o=>{if(!o)return n.createConversation(t);let{agentId:r,agentName:s,agentEmail:i,agentNickname:a,metadata:d}=t;return n.updateConversation(o.id,{agentId:r,agentEmail:i,agentName:s,agentNickname:a,metadata:d})})}),Or=It("conversation/postMessages",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=Se(e.getState());if(!o)throw new Error("No current conversation to update messages");return n.postMessages(o,t.map(r=>y({},r)))}),Fp=[Yn.rejected,eo.rejected,to.rejected,Or.rejected].map(t=>t==null?void 0:t.toString());function Hp(t){return Fp.includes(t.type)}var Bp=_p({name:"conversation",initialState:qi,reducers:{},extraReducers:t=>{t.addCase(Mr.fulfilled,(e,n)=>{e.isSupported=n.payload}).addCase(Yn.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(eo.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(Nr.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(to.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(V,()=>qi).addMatcher(Hp,(e,n)=>{var o;throw k.info("Conversation action rejected",n.type,((o=n.error)==null?void 0:o.message)||"No message"),new Error(n.error.message)})}}),Ji=Bp.reducer;var ot={text:"",html:null,selection:{start:0,end:0},beforeInputChange:null,mixedSuggestion:null,textSuggestions:[],pinnedSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Dr(t){let{key:e,shiftKey:n,ctrlKey:o,metaKey:r,altKey:s}=t;return{key:e,shiftKey:n,ctrlKey:o,metaKey:r,altKey:s}}var no=Up("input/applyImageSuggestion"),Zi=Kp({name:"input",initialState:ot,reducers:{setInput(t,e){var s,i;let{beforeInputChange:n}=t,{text:o,html:r}=e.payload;if(t.text=o,t.html=r!=null?r:null,o==="")t.metrics=ot.metrics,t.textSuggestions=[],t.mixedSuggestion=null;else if(n!==null&&t.text!==n.text){let{key:a,shiftKey:d,ctrlKey:l,metaKey:c,altKey:p}=n.keyDown;switch(a){case"Enter":d&&(t.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:u}=t,f=zp(n.text,u);n.text.length-u.length>1&&t.metrics.deletions.push(...f.filter(m=>m.removed).map(m=>m.value)),t.metrics.numCharsDeleted+=n.text.length-u.length;break}case"Shift":case"Meta":case"Tab":break;case"C":case"V":case"X":case"c":case"v":case"x":if(l||c)break;default:if(!l&&!c&&!p){t.metrics.numCharsTyped+=1;let u=((s=n.selection)==null?void 0:s.start)!==void 0&&((i=n.selection)==null?void 0:i.end)!==void 0?n.text.substring(n.selection.start,n.selection.end):null;u&&u.length>0&&(t.metrics.numCharsDeleted+=u.length,t.metrics.deletions.push(u))}}t.metrics.agentStartedTypingTimestamp||(t.metrics.agentStartedTypingTimestamp=Date.now())}t.beforeInputChange=null},sendMessage(t,e){t.pinnedSuggestions=t.pinnedSuggestions.filter(n=>!t.metrics.textSuggestions.some(o=>o.text===n.text&&o.source===n.source))},setSelection(t,e){e.payload!==null&&($e(t.selection,e.payload)||(t.selection=e.payload))},commitSuggestion(t,e){let n=e.payload,{text:o,suggestion:{source:r,abVariant:s,abTestName:i,trainingJobs:a,sourceText:d,searchTerm:l,assistantCode:c,text:p},eventMetrics:{inputType:u},replace:f}=n,m=r==="search"||r==="personal-collection-search",g=o.slice(t.text.substring(0,t.selection.start).length);(m||f==="selection")&&(g=o),n.suggestion.source==="search-overlay"&&(g=p),t.metrics.textSuggestions.push({text:g,source:r,assistantCode:c,abVariant:s,abTestName:i,inputType:u,sourceText:d,trainingJobs:a||[],searchTerm:m?t.text:l}),t.textSuggestions=[],t.selectedSuggestionIndex=-1},offeredTextSuggestion(t,e){let{text:n,suggestion:{source:o}}=e.payload;t.metrics.offeredTextSuggestions.find(s=>s.text===n)||t.metrics.offeredTextSuggestions.push({text:n,source:o})},registerKeyDown(t,e){let{key:n}=e.payload;["Control","Meta","Shift","Alt"].includes(n)||(t.beforeInputChange={text:t.text,selection:t.selection,keyDown:e.payload})},registerKeyUp(t,e){},registerCut(t,e){let{metrics:n}=t,o=e.payload;t.metrics=x(y({},t.metrics),{numCharsCut:n.numCharsCut+o.length,cuts:[...n.cuts,o]})},registerPaste(t,e){let{metrics:n}=t,{text:o,selectionText:r}=e.payload,s=n.numCharsDeleted+(r!=null&&r.length?r.length:0),i=r!=null&&r.length?[...n.deletions,r]:n.deletions;t.metrics=x(y({},t.metrics),{numCharsDeleted:s,deletions:i,numCharsPasted:n.numCharsPasted+o.length,numPaste:n.numPaste+1,pastes:[...n.pastes,o]})},selectNextTextSuggestion(t){let e=t.textSuggestions.length+t.pinnedSuggestions.length;t.selectedSuggestionIndex=t.selectedSuggestionIndex<e-1?t.selectedSuggestionIndex+1:t.selectedSuggestionIndex},selectPreviousTextSuggestion(t){t.selectedSuggestionIndex=t.selectedSuggestionIndex>=0?t.selectedSuggestionIndex-1:t.selectedSuggestionIndex},selectTextSuggestionByIndex(t,e){t.selectedSuggestionIndex=e.payload},setTextSuggestions(t,e){if(t.selectedSuggestionIndex=-1,t.textSuggestions=e.payload,e.payload.length===0){t.mixedSuggestion=null;return}let n=t.text.substring(0,t.selection.end),o=Gi(e.payload,n);t.mixedSuggestion=o!=null&&o.text.includes(n)?o:null},setPinnedSuggestions(t,e){t.pinnedSuggestions=e.payload},removePinnedSuggestions(t,e){t.pinnedSuggestions=t.pinnedSuggestions.filter(o=>o.source!==e.payload.source||e.payload.assistantCode&&o.assistantCode!==e.payload.assistantCode?!0:e.payload.text?o.text!==e.payload.text:!1);let n=t.textSuggestions.length+t.pinnedSuggestions.length;t.selectedSuggestionIndex>n-1&&(t.selectedSuggestionIndex=-1)},setMetrics(t,{payload:e}){t.metrics=e},resetMetrics(t){t.metrics=ot.metrics}},extraReducers:t=>{t.addCase(V,e=>{e.mixedSuggestion=ot.mixedSuggestion,e.textSuggestions=ot.textSuggestions,e.selectedSuggestionIndex=ot.selectedSuggestionIndex,e.metrics=ot.metrics})}}),At=t=>t.input.text.substring(0,t.input.selection.end),Wp=t=>t.input.mixedSuggestion,Vp=t=>t.input.pinnedSuggestions,jp=t=>t.input.textSuggestions,dn=t=>t.input.selectedSuggestionIndex,rt=Qi([jp,Vp],(t,e)=>[...t,...e]),Mt=Qi([rt,Wp,dn],(t,e,n)=>n>-1?t[n]:e),Yi=t=>t.input.selection,{commitSuggestion:re,offeredTextSuggestion:ea,registerCut:ta,registerKeyDown:na,registerKeyUp:oa,registerPaste:ra,selectNextTextSuggestion:sa,selectPreviousTextSuggestion:ia,selectTextSuggestionByIndex:oo,setInput:ro,setMetrics:aa,setPinnedSuggestions:Nt,removePinnedSuggestions:st,setSelection:so,setTextSuggestions:Ge,resetMetrics:la,sendMessage:it}=Zi.actions,da=Zi.reducer;import{createAsyncThunk as Xp,createSelector as Jp,createSlice as Qp}from"@reduxjs/toolkit";import{createAsyncThunk as io,createSlice as $p}from"@reduxjs/toolkit";function ca(t){try{return Intl.DateTimeFormat(void 0,{timeZone:t}),!0}catch(e){return!1}}var Gp={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,platformVariables:void 0,fetchState:"idle",showNicknameDialog:!1},Ot=t=>{var e;return(e=t.info.agentInfo)!=null?e:null},ua=t=>{var e;return(e=t.info.visitorInfo)!=null?e:null},pa=t=>{var e;return(e=t.info.customData)!=null?e:null},un=({info:{visitorInfo:t,agentInfo:e}})=>{var n,o;return{timezone:t!=null&&t.visitorTimeZone&&ca(t.visitorTimeZone)?t.visitorTimeZone:Di,agentName:(n=e==null?void 0:e.agentNickname)!=null?n:"",visitorName:(o=t==null?void 0:t.visitorName)!=null?o:""}},qp=[["agentNickname","nickname"],["agentDefaultLocale","defaultLocale"],["agentEmail","email"]],ga=io("info/setAgentNickname",(n,o)=>v(null,[n,o],function*({agentNickname:t},e){var i;let{deepdeskAPI:r}=e.extra,s=yield r.patchMe({nickname:t});return{agentNickname:(i=s==null?void 0:s.nickname)!=null?i:t}})),cn=io("info/setAgentInfo",(t,e)=>v(null,null,function*(){var s,i,a;let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),r=[];if(t.agentId&&t.skipSync!==!0&&r.push(n.postIdentity({externalId:t.agentId})),t.skipSync!==!0){let d=qp.reduce((l,[c,p])=>!o[p]&&c in t?x(y({},l),{[p]:t[c]}):l,{});Object.keys(d).length>0&&r.push(n.patchMe(d).then(l=>o=l))}return r.length>0&&(yield Promise.all(r)),{agentId:t.agentId,agentName:t.agentName,agentNickname:(s=o.nickname)!=null?s:t.agentNickname,agentEmail:(i=o.email)!=null?i:t.agentEmail,agentDefaultLocale:(a=o.defaultLocale)!=null?a:t.agentDefaultLocale,agentTimeZone:t.agentTimeZone}})),_r=io("info/setAgentSettings",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),r=y(y({},typeof o.uiConfig=="object"?o.uiConfig:{}),t);return yield n.patchMe({uiConfig:r}),r})),Fr=io("info/getAgentSettings",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra;return(yield n.getMe()).uiConfig})),ma=$p({name:"info",initialState:Gp,reducers:{setVisitorInfo(t,e){t.visitorInfo=y(y({},t.visitorInfo),e.payload)},setCustomData(t,e){t.customData=e.payload},setPlatformVariables(t,e){t.platformVariables=e.payload},setShowNicknameDialog(t,e){t.showNicknameDialog=e.payload}},extraReducers:t=>{t.addCase(cn.pending,(e,n)=>{e.fetchState="loading",e.agentInfo=y(y({},e.agentInfo),n.meta.arg)}).addCase(cn.rejected,e=>{e.fetchState="error"}).addCase(cn.fulfilled,(e,n)=>{e.fetchState="done",e.agentInfo=n.payload}).addCase(_r.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(Fr.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(V,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:fa,setCustomData:ha,setPlatformVariables:ya,setShowNicknameDialog:va}=ma.actions,xa=ma.reducer;function ge(t,e){return e?t==null?(k.warn("replaceVars called with non-string text; upstream contract violation",{keys:Object.keys(e)}),t):Object.entries(e).reduce((n,[o,r])=>n.replaceAll(o,r),t):t}var ao={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},Sa=t=>t.search.isOpen,ba=t=>t.search.page,Hr=t=>t.search.list,Ca=t=>t.search.aggregates,Zp=Jp([Hr,(t,e)=>e],(t,e)=>t.filter(n=>n.type===e)),Ta=t=>e=>Zp(e,t),at=Xp("search/getAll",(t,e)=>v(null,null,function*(){var d;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=(d=o.conversation.current)==null?void 0:d.profileCode,{platformVariables:s}=o.info;if(!r)throw new Error("Profile should be provided in order to be able to search");let{results:i,aggregates:a}=yield n.search({profile:r,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:un(o)});return{results:i.map(l=>x(y(y({},l),l.title&&s?{title:ge(l.title,s)}:{}),{text:ge(l.text,s!=null?s:{}),source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:a}})),wa=Qp({name:"search",initialState:ao,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=ao.fetchState,t.list=ao.list}},extraReducers:t=>{t.addCase(at.pending,e=>{e.fetchState="loading"}).addCase(at.rejected,(e,n)=>{e.fetchState="error",k.error(n.error)}).addCase(at.fulfilled,(e,n)=>{e.fetchState="done",e.list=n.payload.results,e.aggregates=n.payload.aggregates||{}}).addCase(V,()=>ao)}}),{resetSearch:lo,setIsOpen:me,setPage:Dt}=wa.actions,Ea=wa.reducer;var Br="SetOutputs",_t="ShowLoginOverlay",pn="UserLoggedIn",Yp="UserLoggedOut",Me="ApplySuggestion",Ur="ApplyImageSuggestion",eg="ShowCommandPalette",co="ShowNicknameDialog",uo="ReduxAction",tg="RemovePinnedSuggestion",ng=t=>({[Br]:e=>{t.dispatch(x(y({},e),{isBroadcasted:!0}))},[uo]:e=>{e.isBroadcasted||t.dispatch(x(y({},e),{isBroadcasted:!0}))},[tg]:e=>{t.dispatch(st(e))},[eg]:e=>{t.dispatch(me(e.isOpen)),e.page&&t.dispatch(Dt(e.page))},[co]:e=>{t.dispatch(va(e.showNicknameDialog))},[_t]:e=>{t.dispatch(Wi(e))},[pn]:()=>{t.dispatch(Ae())},[Yp]:()=>{t.dispatch(Ae())},[Ur]:e=>{t.dispatch(no({suggestion:e.suggestion}))},[Me]:e=>{t.dispatch(re(x(y({},e),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),ka=ng;import Ra,{useContext as og}from"react";import{jsx as rg}from"react/jsx-runtime";var Pa=Ra.createContext(null),Ne=({broadcastEvents:t,children:e})=>{let n=Ra.useMemo(()=>t,[]);return rg(Pa.Provider,{value:n,children:e})},ne=()=>{let t=og(Pa);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import Qr from"classnames";import{useCallback as Ua,useEffect as Ig,useMemo as Lg,useState as Zr}from"react";import{useDispatch as Ag,useSelector as Mg}from"react-redux";import{createContext as yg,useContext as vg}from"react";var Kr=function(t,e){return Kr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(n[r]=o[r])},Kr(t,e)};function gn(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Kr(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var se=function(){return se=Object.assign||function(e){for(var n,o=1,r=arguments.length;o<r;o++){n=arguments[o];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},se.apply(this,arguments)};function Ia(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]]);return n}function po(t,e,n){if(n||arguments.length===2)for(var o=0,r=e.length,s;o<r;o++)(s||!(o in e))&&(s||(s=Array.prototype.slice.call(e,0,o)),s[o]=e[o]);return t.concat(s||Array.prototype.slice.call(e))}function go(t,e){var n=e&&e.cache?e.cache:ug,o=e&&e.serializer?e.serializer:dg,r=e&&e.strategy?e.strategy:ig;return r(t,{cache:n,serializer:o})}function sg(t){return t==null||typeof t=="number"||typeof t=="boolean"}function La(t,e,n,o){var r=sg(o)?o:n(o),s=e.get(r);return typeof s=="undefined"&&(s=t.call(this,o),e.set(r,s)),s}function Aa(t,e,n){var o=Array.prototype.slice.call(arguments,3),r=n(o),s=e.get(r);return typeof s=="undefined"&&(s=t.apply(this,o),e.set(r,s)),s}function zr(t,e,n,o,r){return n.bind(e,t,o,r)}function ig(t,e){var n=t.length===1?La:Aa;return zr(t,this,n,e.cache.create(),e.serializer)}function ag(t,e){return zr(t,this,Aa,e.cache.create(),e.serializer)}function lg(t,e){return zr(t,this,La,e.cache.create(),e.serializer)}var dg=function(){return JSON.stringify(arguments)},cg=(function(){function t(){this.cache=Object.create(null)}return t.prototype.get=function(e){return this.cache[e]},t.prototype.set=function(e,n){this.cache[e]=n},t})(),ug={create:function(){return new cg}},mo={variadic:ag,monadic:lg};var fo;(function(t){t[t.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",t[t.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",t[t.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",t[t.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",t[t.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",t[t.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",t[t.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",t[t.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",t[t.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",t[t.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",t[t.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",t[t.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",t[t.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",t[t.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",t[t.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",t[t.INVALID_TAG=23]="INVALID_TAG",t[t.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",t[t.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",t[t.UNCLOSED_TAG=27]="UNCLOSED_TAG"})(fo||(fo={}));var ho=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var de;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(de||(de={}));var yo;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(yo||(yo={}));function Wr(t){return t.type===de.literal}function Vr(t){return t.type===de.argument}function mn(t){return t.type===de.number}function fn(t){return t.type===de.date}function hn(t){return t.type===de.time}function yn(t){return t.type===de.select}function vn(t){return t.type===de.plural}function Ma(t){return t.type===de.pound}function xn(t){return t.type===de.tag}function vo(t){return!!(t&&typeof t=="object"&&t.type===yo.number)}function Sn(t){return!!(t&&typeof t=="object"&&t.type===yo.dateTime)}function jr(t){t.forEach(function(e){if(delete e.location,yn(e)||vn(e))for(var n in e.options)delete e.options[n].location,jr(e.options[n].value);else mn(e)&&vo(e.style)||(fn(e)||hn(e))&&Sn(e.style)?delete e.style.location:xn(e)&&jr(e.children)})}function Na(t,e){e===void 0&&(e={}),e=se({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var n=new ho(t,e).parse();if(n.err){var o=SyntaxError(fo[n.err.kind]);throw o.location=n.err.location,o.originalMessage=n.err.message,o}return e!=null&&e.captureLocation||jr(n.val),n.val}var lt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(lt||(lt={}));var bn=(function(t){gn(e,t);function e(n,o,r){var s=t.call(this,n)||this;return s.code=o,s.originalMessage=r,s}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e})(Error);var $r=(function(t){gn(e,t);function e(n,o,r,s){return t.call(this,'Invalid values for "'.concat(n,'": "').concat(o,'". Options are "').concat(Object.keys(r).join('", "'),'"'),lt.INVALID_VALUE,s)||this}return e})(bn);var Oa=(function(t){gn(e,t);function e(n,o,r){return t.call(this,'Value for "'.concat(n,'" must be of type ').concat(o),lt.INVALID_VALUE,r)||this}return e})(bn);var Da=(function(t){gn(e,t);function e(n,o){return t.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(o,'"'),lt.MISSING_VALUE,o)||this}return e})(bn);var Q;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(Q||(Q={}));function pg(t){return t.length<2?t:t.reduce(function(e,n){var o=e[e.length-1];return!o||o.type!==Q.literal||n.type!==Q.literal?e.push(n):o.value+=n.value,e},[])}function gg(t){return typeof t=="function"}function Cn(t,e,n,o,r,s,i){if(t.length===1&&Wr(t[0]))return[{type:Q.literal,value:t[0].value}];for(var a=[],d=0,l=t;d<l.length;d++){var c=l[d];if(Wr(c)){a.push({type:Q.literal,value:c.value});continue}if(Ma(c)){typeof s=="number"&&a.push({type:Q.literal,value:n.getNumberFormat(e).format(s)});continue}var p=c.value;if(!(r&&p in r))throw new Da(p,i);var u=r[p];if(Vr(c)){(!u||typeof u=="string"||typeof u=="number")&&(u=typeof u=="string"||typeof u=="number"?String(u):""),a.push({type:typeof u=="string"?Q.literal:Q.object,value:u});continue}if(fn(c)){var f=typeof c.style=="string"?o.date[c.style]:Sn(c.style)?c.style.parsedOptions:void 0;a.push({type:Q.literal,value:n.getDateTimeFormat(e,f).format(u)});continue}if(hn(c)){var f=typeof c.style=="string"?o.time[c.style]:Sn(c.style)?c.style.parsedOptions:o.time.medium;a.push({type:Q.literal,value:n.getDateTimeFormat(e,f).format(u)});continue}if(mn(c)){var f=typeof c.style=="string"?o.number[c.style]:vo(c.style)?c.style.parsedOptions:void 0;f&&f.scale&&(u=u*(f.scale||1)),a.push({type:Q.literal,value:n.getNumberFormat(e,f).format(u)});continue}if(xn(c)){var m=c.children,g=c.value,h=r[g];if(!gg(h))throw new Oa(g,"function",i);var b=Cn(m,e,n,o,r,s),T=h(b.map(function(L){return L.value}));Array.isArray(T)||(T=[T]),a.push.apply(a,T.map(function(L){return{type:typeof L=="string"?Q.literal:Q.object,value:L}}))}if(yn(c)){var C=c.options[u]||c.options.other;if(!C)throw new $r(c.value,u,Object.keys(c.options),i);a.push.apply(a,Cn(C.value,e,n,o,r));continue}if(vn(c)){var C=c.options["=".concat(u)];if(!C){if(!Intl.PluralRules)throw new bn(`Intl.PluralRules is not available in this environment.
1
+ var vi=Object.defineProperty,Ou=Object.defineProperties;var Du=Object.getOwnPropertyDescriptors;var zn=Object.getOwnPropertySymbols;var xi=Object.prototype.hasOwnProperty,Si=Object.prototype.propertyIsEnumerable;var yi=(t,e,n)=>e in t?vi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,y=(t,e)=>{for(var n in e||(e={}))xi.call(e,n)&&yi(t,n,e[n]);if(zn)for(var n of zn(e))Si.call(e,n)&&yi(t,n,e[n]);return t},x=(t,e)=>Ou(t,Du(e));var M=(t,e)=>{var n={};for(var o in t)xi.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&zn)for(var o of zn(t))e.indexOf(o)<0&&Si.call(t,o)&&(n[o]=t[o]);return n};var X=(t,e)=>{for(var n in e)vi(t,n,{get:e[n],enumerable:!0})};var v=(t,e,n)=>new Promise((o,r)=>{var s=d=>{try{a(n.next(d))}catch(l){r(l)}},i=d=>{try{a(n.throw(d))}catch(l){r(l)}},a=d=>d.done?o(d.value):Promise.resolve(d.value).then(s,i);a((n=n.apply(t,e)).next())});import Ci from"classnames";import Uu,{createContext as Ku,useContext as Er,useEffect as zu,useState as Wu}from"react";import _u,{useContext as Fu}from"react";import Hu from"classnames";var rn=_u.createContext({});function S(t,e){let s=Fu(rn),{debug:n}=s,r=M(s,["debug"])[t];return Object.entries(e).reduce((i,[a,d])=>{let l=r==null?void 0:r[a];return x(y({},i),{[a]:Hu(d,l,n?`${t}__${a}`:!1)})},{})}var bi={root:"dd-4s9wq"};import{jsx as Wn,jsxs as Bu}from"react/jsx-runtime";var Vn=()=>Bu("svg",{className:bi.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[Wn("defs",{children:Wn("style",{children:".cls-1 { fill: #b3b3b3; }"})}),Wn("title",{children:"Failed loading image"}),Wn("path",{className:"cls-1",d:"M15 130.896V16.994c0-1.097.898-1.994 2.007-1.994h150.986A2 2 0 0 1 170 16.994v69.147L133.015 51 87.26 120.377l-35.863-17.758L15 130.896zM2 0C.895 0 0 .887 0 2v166c0 1.105.887 2 2 2h181c1.105 0 2-.887 2-2V2c0-1.105-.887-2-2-2H2zm49 72c11.046 0 20-9.178 20-20.5S62.046 31 51 31s-20 9.178-20 20.5S39.954 72 51 72z",fillRule:"evenodd"})]});var wr={root:"dd-c9KvZ",imageWrapper:"dd-sE7D9",image:"dd-bEGMz",content:"dd-oFIQa",title:"dd-mSgoo",contentIsCropped:"dd-Uvjv4",lineClamp:"dd-ApQo-"};import{jsx as Et}from"react/jsx-runtime";var jn=Ku(wr),Vu=({title:t,src:e})=>{let n=Er(jn),[o,r]=Wu(!1);return zu(()=>{r(!1)},[e]),Et("div",{className:n.imageWrapper,children:e&&!o?Et("img",{className:n.image,alt:t,src:e,onError:()=>r(!0)}):Et(Vn,{})})},ju=({className:t,lineClamp:e=!1,cropText:n=!1,children:o})=>{let r=Er(jn);return Et("div",{className:Ci(r.content,t,{[r.contentIsCropped]:n,[r.lineClamp]:e}),children:o})},$u=s=>{var i=s,{as:t="h1",cropText:e=!1,className:n,children:o}=i,r=M(i,["as","cropText","className","children"]);let a=Er(jn);return Uu.createElement(t,y({className:Ci(a.title,n,{[a.contentIsCropped]:e})},r),o)},$n=({children:t})=>{let e=S("Card",wr);return Et("div",{className:e.root,children:Et(jn.Provider,{value:e,children:t})})};$n.Image=Vu;$n.Content=ju;$n.Title=$u;var D=$n;import Gu from"classnames";var Ti={root:"dd-llBx9"};import{jsx as Ju}from"react/jsx-runtime";var qu={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Xu=o=>{var r=o,{className:t,keyCode:e}=r,n=M(r,["className","keyCode"]);let s=S("KeyboardHint",Ti);return Ju("span",y({"data-key":qu[e],className:Gu(t,s.root)},n))},kr=Xu;import Qu from"classnames";var wi={root:"dd-e6HXZ"};import{jsx as ep}from"react/jsx-runtime";var Zu=o=>{var r=o,{className:t,children:e}=r,n=M(r,["className","children"]);let s=S("Label",wi);return ep("span",x(y({},n),{className:Qu(t,s.root),children:e}))},Yu=Zu;var Ei={root:"dd-FiMI7",subTitleContainer:"dd-98jc7",subtitle:"dd-3MnW8",suggestions:"dd-0SGL8"};import{jsx as Rr,jsxs as np}from"react/jsx-runtime";var tp=r=>{var s=r,{title:t,children:e,type:n}=s,o=M(s,["title","children","type"]);let i=S("Section",Ei);return np("section",x(y({},o),{className:i.root,"data-section-type":n,children:[t&&Rr("div",{className:i.subTitleContainer,children:Rr("span",{className:i.subtitle,children:t})}),Rr("div",{className:i.suggestions,children:e})]}))},Le=tp;import lp from"classnames";import{useRef as dp}from"react";import{createContext as op,useCallback as rp,useContext as sp,useEffect as ip}from"react";import{jsx as ap}from"react/jsx-runtime";var ki=op(null),Ri=({scrollContainerRef:t,children:e})=>{let n=rp(o=>{let r=t.current;if(!r||r.scrollHeight<=r.clientHeight)return;let{top:s}=r.getBoundingClientRect(),{top:i}=o.getBoundingClientRect(),a=r.scrollTop+(i-s);typeof r.scrollTo=="function"?r.scrollTo({top:a}):r.scrollTop=a},[]);return ap(ki.Provider,{value:n,children:e})},Gn=t=>{let e=sp(ki);ip(()=>{let n=t.current;n&&e(n)},[])};var Pi={root:"dd-uoTXh"};import{jsx as Ii}from"react/jsx-runtime";var cp=({className:t,children:e})=>{let n=S("SectionList",Pi),o=dp(null);return Ii(Ri,{scrollContainerRef:o,children:Ii("div",{ref:o,className:lp(n.root,t),children:e})})},sn=cp;import an from"classnames";import up,{createContext as pp,useCallback as gp,useContext as nt}from"react";var Pr={root:"dd-1g-A9",fadein:"dd-McXxq",isClickable:"dd-CTG8E",isSelected:"dd-yhg27",actions:"dd-Nlm6p",actionsIsFixed:"dd-OK-kw",actionButton:"dd-zbXsQ",dropdownList:"dd-AvwWP",dropdownButton:"dd-piaJi",dropdownItem:"dd-qgkTO",dropdownItemButton:"dd-sTE2D",actionButtonIsPrimary:"dd-mhkWS",actionButtonIsDisabled:"dd-0eKLQ",labels:"dd-QKJu6",label:"dd-aMplE",buttonsContainer:"dd-uRYN4",button:"dd-9UE-x",buttonPrimary:"dd-aYDCB",buttonSecondary:"dd--cpPL",buttonWithIcon:"dd-MQVt5",icon:"dd-Jr-ww",buttonDisabled:"dd-agTuH"};import{jsx as ue,jsxs as Li}from"react/jsx-runtime";var We=pp(Pr),mp=o=>{var r=o,{fixed:t,children:e}=r,n=M(r,["fixed","children"]);let s=nt(We);return ue("div",x(y({},n),{className:an(s.actions,{[s.actionsIsFixed]:t}),children:e}))};function fp(d){var l=d,{as:t,className:e,icon:n,title:o,children:r,disabled:s,variant:i}=l,a=M(l,["as","className","icon","title","children","disabled","variant"]);let c=nt(We);return Li(t||"button",x(y({type:"button",className:an(c.button,{[c.buttonWithIcon]:n,[c.buttonDisabled]:s,[c.buttonPrimary]:i==="primary",[c.buttonSecondary]:i==="secondary"},e),title:o,"aria-label":o},a),{children:[n&&ue("span",{className:c.icon,children:n}),r]}))}var hp=({children:t})=>{let e=nt(We);return ue("div",{className:e.buttonsContainer,children:t})},yp=({className:t,primary:e,disabled:n,label:o,children:r})=>{let s=nt(We);return Li("div",{className:an(t,s.actionButton,s.dropdownButton,{[s.actionButtonIsPrimary]:e,[s.actionButtonIsDisabled]:n}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[o,ue("ul",{className:s.dropdownList,children:r})]})},vp=({index:t,label:e,onClick:n})=>{let o=nt(We);return ue("li",{className:o.dropdownItem,children:ue("button",{className:o.dropdownItemButton,type:"button","data-index":t,onClick:n,children:e})})},xp=({className:t,primary:e,disabled:n,onClick:o,label:r})=>{let s=nt(We);return ue("button",{type:"button",className:an(t,s.actionButton,{[s.actionButtonIsPrimary]:e,[s.actionButtonIsDisabled]:n}),onClick:o!=null?o:(i=>i.stopPropagation()),disabled:n,"aria-hidden":n,children:r})},Sp=({labels:t})=>{let e=nt(We);return ue("div",{className:e.labels,children:t.map(n=>ue("span",{className:e.label,children:n},n))})},Ve=up.forwardRef((a,i)=>{var d=a,{className:t,selected:e,onClick:n,children:o,as:r="div"}=d,s=M(d,["className","selected","onClick","children","as"]);let l=S("Suggestion",Pr),c=gp(p=>{p.preventDefault(),n&&n(p)},[n]);return ue(r,x(y({},s),{ref:i,className:an(t,l.root,{[l.isSelected]:e,[l.isClickable]:!!n}),onClick:c,children:ue(We.Provider,{value:l,children:o})}))});Ve.Labels=Sp;Ve.Actions=mp;Ve.ActionButton=xp;Ve.DropdownButton=yp;Ve.DropdownItem=vp;Ve.ButtonsContainer=hp;Ve.Button=fp;var I=Ve;import bp from"classnames";var Ai={root:"dd-W35K-",isWithDivider:"dd-sscOy"};import{jsx as Tp}from"react/jsx-runtime";var Cp=({withDivider:t,children:e})=>{let n=S("SuggestionList",Ai);return Tp("div",{"data-testid":"suggestions-overlay-list",className:bp(n.root,{[n.isWithDivider]:t}),children:e})},te=Cp;import wp from"classnames";var Mi={root:"dd-oWarc",isCollapsed:"dd-tfZI0"};import{jsx as Ir}from"react/jsx-runtime";var Ep=({className:t,isCollapsed:e,title:n,onClick:o})=>{let r=S("ToggleButton",Mi);return Ir("button",{type:"button",className:wp(r.root,t,{[r.isCollapsed]:e}),onClick:o,title:n,children:Ir("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:Ir("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},kt=Ep;var Ni=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,qn=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Oi=/x-deepdesk-(([a-z0-9\-_])+-version)/,Xn=["cues","custom-data","custom-data-banner","knowledge-assist"],Di=Intl.DateTimeFormat().resolvedOptions().timeZone,je=(m=>(m.SEARCH="search",m.TEMPLATE="template",m.ELASTIC_SEARCH="search-autocomplete",m.GPT="gpt",m.TRIE="trie",m.TRIE_WITH_TYPOS="trie-with-typos",m.SEMANTIC="semantic",m.TEXT_RECOMMENDATION="text_recommendation",m.URL_RECOMMENDATION="url_recommendation",m.LINK_RECOMMENDATION="link_recommendation",m.PERSONAL_COLLECTION="personal-collection",m.PERSONAL_COLLECTION_SEARCH="personal-collection-search",m.SEARCH_OVERLAY="search-overlay",m.SEARCH_PREVIEW="search-preview",m.SEARCH_URL="search-url",m))(je||{}),Rt=(i=>(i.ENTER="enter",i.TAB="tab",i.ARROW="arrow",i.HOTKEY="hotkey",i.MOUSE="mouse",i.SPACE="space",i))(Rt||{});import{createContext as Pm,Fragment as Im,useContext as ls,useEffect as Lm,useRef as pl,useState as mt}from"react";import{useDispatch as Am,useSelector as Mm}from"react-redux";import{createAsyncThunk as Lr,createSlice as kp}from"@reduxjs/toolkit";var Jn=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(Jn||{});var Rp={isLoggedIn:null,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1,loginError:null},J=t=>t.auth.isLoggedIn;var _i=t=>t.auth.verifyFetchState,Fi=t=>t.auth.showLoginOverlay,Hi=t=>t.auth.loginError,Ae=Lr("auth/validate",(t,e)=>v(null,null,function*(){return e.extra.deepdeskAPI.isLoggedIn()})),Bi=Lr("auth/requestLogin",(n,o)=>v(null,[n,o],function*({email:t},e){let{deepdeskAPI:r}=e.extra;return r.requestLoginByEmail(t)})),ln=Lr("auth/verifyLoginToken",(n,o)=>v(null,[n,o],function*({token:t},e){let{deepdeskAPI:r}=e.extra;return r.verifyLoginToken(t)})),Ui=kp({name:"auth",initialState:Rp,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload},setLoginError(t,e){t.loginError=e.payload},clearLoginError(t){t.loginError=null}},extraReducers:t=>{t.addCase(Ae.pending,e=>{e.loginFetchState="loading"}),t.addCase(Ae.fulfilled,(e,{payload:n})=>{e.isLoggedIn=n,e.loginFetchState="done"}),t.addCase(Ae.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(ln.pending,e=>{e.verifyFetchState="loading"}),t.addCase(ln.rejected,e=>{e.verifyFetchState="error"}),t.addCase(ln.fulfilled,(e,n)=>{n.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Pt,setShowLoginOverlay:Ki,setLoginError:Ar,clearLoginError:Qn}=Ui.actions,zi=Ui.reducer;import{createAction as Fp,createSelector as Xi,createSlice as Hp}from"@reduxjs/toolkit";import{diffChars as Bp}from"diff";function Wi(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function $e(t,e,n=10){let o=typeof t,r=typeof e;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return o!==r?!1:t==null||o==="string"||o==="number"||o==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((s,i)=>$e(s,e[i],n-1)):Wi(t)&&Wi(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>$e(t[i],e[i],n-1)):!1}function Pp(t){return Math.max(...t.map(e=>e.length))}function Ip(t,e){let n=t.reduce((o,r)=>{if(r){let s=o[r]?o[r]+1:1;return x(y({},o),{[r]:s})}return o},{});return Object.keys(n).reduce((o,r)=>(n[r]<e&&o.push(r),o),[])}function Vi(t,e){let o=[...t.map(({text:r})=>r.split(/\b(\w+)\b/))];for(let r=0;r<Pp(o);r++){let s=Ip(o.map(a=>a[r]),e),i=o.filter(a=>!s.includes(a[r]));if(i.length>=e)o=i;else return{text:o[0].slice(0,r).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var Lp=2;function ji(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let n=Vi(t,Lp);return n&&n.text!==e?n:t[0]}import{createAction as Mp,createAsyncThunk as It,createSlice as Np}from"@reduxjs/toolkit";var Ap={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},E=Ap;var $i={current:null,isSupported:null},V=Mp("resetConversation"),Gi=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.externalId)||null},Se=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Lt=t=>t.conversation.isSupported,Mr=It("conversation/isSupported",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.isConversationSupported(t.externalId,t.options)}),Zn=It("conversation/create",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.createConversation(t)}),Yn=It("conversation/byExternalId",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationByExternalId(t.externalId,t.options)}),eo=It("conversation/update",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=Se(e.getState());if(!o)throw new Error("No current conversation to update");return n.updateConversation(o,t)}),Nr=It("conversation/upsert",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationByExternalId(t.externalId).catch(()=>null).then(o=>{if(!o)return n.createConversation(t);let{agentId:r,agentName:s,agentEmail:i,agentNickname:a,metadata:d}=t;return n.updateConversation(o.id,{agentId:r,agentEmail:i,agentName:s,agentNickname:a,metadata:d})})}),Or=It("conversation/postMessages",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=Se(e.getState());if(!o)throw new Error("No current conversation to update messages");return n.postMessages(o,t.map(r=>y({},r)))}),Op=[Zn.rejected,Yn.rejected,eo.rejected,Or.rejected].map(t=>t==null?void 0:t.toString());function Dp(t){return Op.includes(t.type)}var _p=Np({name:"conversation",initialState:$i,reducers:{},extraReducers:t=>{t.addCase(Mr.fulfilled,(e,n)=>{e.isSupported=n.payload}).addCase(Zn.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(Yn.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(Nr.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(eo.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=!!((o=n.payload)!=null&&o.profileCode)}).addCase(V,()=>$i).addMatcher(Dp,(e,n)=>{var o;throw E.info("Conversation action rejected",n.type,((o=n.error)==null?void 0:o.message)||"No message"),new Error(n.error.message)})}}),qi=_p.reducer;var ot={text:"",html:null,selection:{start:0,end:0},beforeInputChange:null,mixedSuggestion:null,textSuggestions:[],pinnedSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Dr(t){let{key:e,shiftKey:n,ctrlKey:o,metaKey:r,altKey:s}=t;return{key:e,shiftKey:n,ctrlKey:o,metaKey:r,altKey:s}}var to=Fp("input/applyImageSuggestion"),Ji=Hp({name:"input",initialState:ot,reducers:{setInput(t,e){var s,i;let{beforeInputChange:n}=t,{text:o,html:r}=e.payload;if(t.text=o,t.html=r!=null?r:null,o==="")t.metrics=ot.metrics,t.textSuggestions=[],t.mixedSuggestion=null;else if(n!==null&&t.text!==n.text){let{key:a,shiftKey:d,ctrlKey:l,metaKey:c,altKey:p}=n.keyDown;switch(a){case"Enter":d&&(t.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:u}=t,f=Bp(n.text,u);n.text.length-u.length>1&&t.metrics.deletions.push(...f.filter(h=>h.removed).map(h=>h.value)),t.metrics.numCharsDeleted+=n.text.length-u.length;break}case"Shift":case"Meta":case"Tab":break;case"C":case"V":case"X":case"c":case"v":case"x":if(l||c)break;default:if(!l&&!c&&!p){t.metrics.numCharsTyped+=1;let u=((s=n.selection)==null?void 0:s.start)!==void 0&&((i=n.selection)==null?void 0:i.end)!==void 0?n.text.substring(n.selection.start,n.selection.end):null;u&&u.length>0&&(t.metrics.numCharsDeleted+=u.length,t.metrics.deletions.push(u))}}t.metrics.agentStartedTypingTimestamp||(t.metrics.agentStartedTypingTimestamp=Date.now())}t.beforeInputChange=null},sendMessage(t,e){t.pinnedSuggestions=t.pinnedSuggestions.filter(n=>!t.metrics.textSuggestions.some(o=>o.text===n.text&&o.source===n.source))},setSelection(t,e){e.payload!==null&&($e(t.selection,e.payload)||(t.selection=e.payload))},commitSuggestion(t,e){let n=e.payload,{text:o,suggestion:{source:r,abVariant:s,abTestName:i,trainingJobs:a,sourceText:d,searchTerm:l,assistantCode:c,text:p},eventMetrics:{inputType:u},replace:f}=n,h=r==="search"||r==="personal-collection-search",m=o.slice(t.text.substring(0,t.selection.start).length);(h||f==="selection")&&(m=o),n.suggestion.source==="search-overlay"&&(m=p),t.metrics.textSuggestions.push({text:m,source:r,assistantCode:c,abVariant:s,abTestName:i,inputType:u,sourceText:d,trainingJobs:a||[],searchTerm:h?t.text:l}),t.textSuggestions=[],t.selectedSuggestionIndex=-1},offeredTextSuggestion(t,e){let{text:n,suggestion:{source:o}}=e.payload;t.metrics.offeredTextSuggestions.find(s=>s.text===n)||t.metrics.offeredTextSuggestions.push({text:n,source:o})},registerKeyDown(t,e){let{key:n}=e.payload;["Control","Meta","Shift","Alt"].includes(n)||(t.beforeInputChange={text:t.text,selection:t.selection,keyDown:e.payload})},registerKeyUp(t,e){},registerCut(t,e){let{metrics:n}=t,o=e.payload;t.metrics=x(y({},t.metrics),{numCharsCut:n.numCharsCut+o.length,cuts:[...n.cuts,o]})},registerPaste(t,e){let{metrics:n}=t,{text:o,selectionText:r}=e.payload,s=n.numCharsDeleted+(r!=null&&r.length?r.length:0),i=r!=null&&r.length?[...n.deletions,r]:n.deletions;t.metrics=x(y({},t.metrics),{numCharsDeleted:s,deletions:i,numCharsPasted:n.numCharsPasted+o.length,numPaste:n.numPaste+1,pastes:[...n.pastes,o]})},selectNextTextSuggestion(t){let e=t.textSuggestions.length+t.pinnedSuggestions.length;t.selectedSuggestionIndex=t.selectedSuggestionIndex<e-1?t.selectedSuggestionIndex+1:t.selectedSuggestionIndex},selectPreviousTextSuggestion(t){t.selectedSuggestionIndex=t.selectedSuggestionIndex>=0?t.selectedSuggestionIndex-1:t.selectedSuggestionIndex},selectTextSuggestionByIndex(t,e){t.selectedSuggestionIndex=e.payload},setTextSuggestions(t,e){if(t.selectedSuggestionIndex=-1,t.textSuggestions=e.payload,e.payload.length===0){t.mixedSuggestion=null;return}let n=t.text.substring(0,t.selection.end),o=ji(e.payload,n);t.mixedSuggestion=o!=null&&o.text.includes(n)?o:null},setPinnedSuggestions(t,e){t.pinnedSuggestions=e.payload},removePinnedSuggestions(t,e){t.pinnedSuggestions=t.pinnedSuggestions.filter(o=>o.source!==e.payload.source||e.payload.assistantCode&&o.assistantCode!==e.payload.assistantCode?!0:e.payload.text?o.text!==e.payload.text:!1);let n=t.textSuggestions.length+t.pinnedSuggestions.length;t.selectedSuggestionIndex>n-1&&(t.selectedSuggestionIndex=-1)},setMetrics(t,{payload:e}){t.metrics=e},resetMetrics(t){t.metrics=ot.metrics}},extraReducers:t=>{t.addCase(V,e=>{e.mixedSuggestion=ot.mixedSuggestion,e.textSuggestions=ot.textSuggestions,e.selectedSuggestionIndex=ot.selectedSuggestionIndex,e.metrics=ot.metrics})}}),At=t=>t.input.text.substring(0,t.input.selection.end),Up=t=>t.input.mixedSuggestion,Kp=t=>t.input.pinnedSuggestions,zp=t=>t.input.textSuggestions,dn=t=>t.input.selectedSuggestionIndex,rt=Xi([zp,Kp],(t,e)=>[...t,...e]),Mt=Xi([rt,Up,dn],(t,e,n)=>n>-1?t[n]:e),Qi=t=>t.input.selection,{commitSuggestion:re,offeredTextSuggestion:Zi,registerCut:Yi,registerKeyDown:ea,registerKeyUp:ta,registerPaste:na,selectNextTextSuggestion:oa,selectPreviousTextSuggestion:ra,selectTextSuggestionByIndex:no,setInput:oo,setMetrics:sa,setPinnedSuggestions:Nt,removePinnedSuggestions:st,setSelection:ro,setTextSuggestions:Ge,resetMetrics:ia,sendMessage:it}=Ji.actions,aa=Ji.reducer;import{createAsyncThunk as $p,createSelector as Gp,createSlice as qp}from"@reduxjs/toolkit";import{createAsyncThunk as so,createSlice as Wp}from"@reduxjs/toolkit";function la(t){try{return Intl.DateTimeFormat(void 0,{timeZone:t}),!0}catch(e){return!1}}var Vp={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,platformVariables:void 0,fetchState:"idle",showNicknameDialog:!1},Ot=t=>{var e;return(e=t.info.agentInfo)!=null?e:null},da=t=>{var e;return(e=t.info.visitorInfo)!=null?e:null},ca=t=>{var e;return(e=t.info.customData)!=null?e:null},un=({info:{visitorInfo:t,agentInfo:e}})=>{var n,o;return{timezone:t!=null&&t.visitorTimeZone&&la(t.visitorTimeZone)?t.visitorTimeZone:Di,agentName:(n=e==null?void 0:e.agentNickname)!=null?n:"",visitorName:(o=t==null?void 0:t.visitorName)!=null?o:""}},jp=[["agentNickname","nickname"],["agentDefaultLocale","defaultLocale"],["agentEmail","email"]],ua=so("info/setAgentNickname",(n,o)=>v(null,[n,o],function*({agentNickname:t},e){var i;let{deepdeskAPI:r}=e.extra,s=yield r.patchMe({nickname:t});return{agentNickname:(i=s==null?void 0:s.nickname)!=null?i:t}})),cn=so("info/setAgentInfo",(t,e)=>v(null,null,function*(){var s,i,a;let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),r=[];if(t.agentId&&t.skipSync!==!0&&r.push(n.postIdentity({externalId:t.agentId})),t.skipSync!==!0){let d=jp.reduce((l,[c,p])=>!o[p]&&c in t?x(y({},l),{[p]:t[c]}):l,{});Object.keys(d).length>0&&r.push(n.patchMe(d).then(l=>o=l))}return r.length>0&&(yield Promise.all(r)),{agentId:t.agentId,agentName:t.agentName,agentNickname:(s=o.nickname)!=null?s:t.agentNickname,agentEmail:(i=o.email)!=null?i:t.agentEmail,agentDefaultLocale:(a=o.defaultLocale)!=null?a:t.agentDefaultLocale,agentTimeZone:t.agentTimeZone}})),_r=so("info/setAgentSettings",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra,o=yield n.getMe(),r=y(y({},typeof o.uiConfig=="object"?o.uiConfig:{}),t);return yield n.patchMe({uiConfig:r}),r})),Fr=so("info/getAgentSettings",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra;return(yield n.getMe()).uiConfig})),pa=Wp({name:"info",initialState:Vp,reducers:{setVisitorInfo(t,e){t.visitorInfo=y(y({},t.visitorInfo),e.payload)},setCustomData(t,e){t.customData=e.payload},setPlatformVariables(t,e){t.platformVariables=e.payload},setShowNicknameDialog(t,e){t.showNicknameDialog=e.payload}},extraReducers:t=>{t.addCase(cn.pending,(e,n)=>{e.fetchState="loading",e.agentInfo=y(y({},e.agentInfo),n.meta.arg)}).addCase(cn.rejected,e=>{e.fetchState="error"}).addCase(cn.fulfilled,(e,n)=>{e.fetchState="done",e.agentInfo=n.payload}).addCase(_r.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(Fr.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(V,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:ga,setCustomData:ma,setPlatformVariables:fa,setShowNicknameDialog:ha}=pa.actions,ya=pa.reducer;function ge(t,e){return e?t==null?(E.warn("replaceVars called with non-string text; upstream contract violation",{keys:Object.keys(e)}),t):Object.entries(e).reduce((n,[o,r])=>n.replaceAll(o,r),t):t}var io={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},va=t=>t.search.isOpen,xa=t=>t.search.page,Hr=t=>t.search.list,Sa=t=>t.search.aggregates,Xp=Gp([Hr,(t,e)=>e],(t,e)=>t.filter(n=>n.type===e)),ba=t=>e=>Xp(e,t),at=$p("search/getAll",(t,e)=>v(null,null,function*(){var d;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=(d=o.conversation.current)==null?void 0:d.profileCode,{platformVariables:s}=o.info;if(!r)throw new Error("Profile should be provided in order to be able to search");let{results:i,aggregates:a}=yield n.search({profile:r,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:un(o)});return{results:i.map(l=>x(y(y({},l),l.title&&s?{title:ge(l.title,s)}:{}),{text:ge(l.text,s!=null?s:{}),source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:a}})),Ca=qp({name:"search",initialState:io,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=io.fetchState,t.list=io.list}},extraReducers:t=>{t.addCase(at.pending,e=>{e.fetchState="loading"}).addCase(at.rejected,(e,n)=>{e.fetchState="error",E.error(n.error)}).addCase(at.fulfilled,(e,n)=>{e.fetchState="done",e.list=n.payload.results,e.aggregates=n.payload.aggregates||{}}).addCase(V,()=>io)}}),{resetSearch:ao,setIsOpen:me,setPage:Dt}=Ca.actions,Ta=Ca.reducer;var Br="SetOutputs",_t="ShowLoginOverlay",pn="UserLoggedIn",Jp="UserLoggedOut",Me="ApplySuggestion",Ur="ApplyImageSuggestion",Qp="ShowCommandPalette",lo="ShowNicknameDialog",co="ReduxAction",Zp="RemovePinnedSuggestion",Yp=t=>({[Br]:e=>{t.dispatch(x(y({},e),{isBroadcasted:!0}))},[co]:e=>{e.isBroadcasted||t.dispatch(x(y({},e),{isBroadcasted:!0}))},[Zp]:e=>{t.dispatch(st(e))},[Qp]:e=>{t.dispatch(me(e.isOpen)),e.page&&t.dispatch(Dt(e.page))},[lo]:e=>{t.dispatch(ha(e.showNicknameDialog))},[_t]:e=>{t.dispatch(Ki(e))},[pn]:()=>{t.dispatch(Ae())},[Jp]:()=>{t.dispatch(Ae())},[Ur]:e=>{t.dispatch(to({suggestion:e.suggestion}))},[Me]:e=>{t.dispatch(re(x(y({},e),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),wa=Yp;import{useDispatch as tg}from"react-redux";import{createAsyncThunk as eg}from"@reduxjs/toolkit";function Kr(t){return eg("analytics/logEvent",(e,n)=>{var s,i,a;let o=(i=(s=n.getState())==null?void 0:s.conversation.current)==null?void 0:i.id,r=(a=n.getState())==null?void 0:a.info.agentInfo;return n.extra.deepdeskAPI.sendEvent(e.name,x(y({conversationId:o},r),{data:e.data}))})(t)}function K(){let t=tg();return(e,n)=>v(null,null,function*(){yield t(Kr({name:e,data:n}))})}import{useRef as ng,useState as zr}from"react";import{useDispatch as og}from"react-redux";function uo(t,e){let n=ng(t);n.current=t;let[o,r]=zr(void 0),[s,i]=zr(void 0),[a,d]=zr("idle"),l=og();return{error:s,state:a,data:o,call:u=>v(null,null,function*(){d("loading"),yield l(n.current(u)).unwrap().then(f=>{r(f),d("done"),e!=null&&e.onSuccess&&(e==null||e.onSuccess(f))}).catch(f=>{i(f),d("error"),e!=null&&e.onError&&(e==null||e.onError(f))})}),reset:()=>{d("idle"),r(void 0),i(void 0)}}}import Ea,{useContext as rg}from"react";import{jsx as sg}from"react/jsx-runtime";var ka=Ea.createContext(null),Ne=({broadcastEvents:t,children:e})=>{let n=Ea.useMemo(()=>t,[]);return sg(ka.Provider,{value:n,children:e})},ne=()=>{let t=rg(ka);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import{createContext as vg,useContext as xg}from"react";var Wr=function(t,e){return Wr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(n[r]=o[r])},Wr(t,e)};function gn(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Wr(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var se=function(){return se=Object.assign||function(e){for(var n,o=1,r=arguments.length;o<r;o++){n=arguments[o];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},se.apply(this,arguments)};function Ra(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]]);return n}function po(t,e,n){if(n||arguments.length===2)for(var o=0,r=e.length,s;o<r;o++)(s||!(o in e))&&(s||(s=Array.prototype.slice.call(e,0,o)),s[o]=e[o]);return t.concat(s||Array.prototype.slice.call(e))}function go(t,e){var n=e&&e.cache?e.cache:pg,o=e&&e.serializer?e.serializer:cg,r=e&&e.strategy?e.strategy:ag;return r(t,{cache:n,serializer:o})}function ig(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Pa(t,e,n,o){var r=ig(o)?o:n(o),s=e.get(r);return typeof s=="undefined"&&(s=t.call(this,o),e.set(r,s)),s}function Ia(t,e,n){var o=Array.prototype.slice.call(arguments,3),r=n(o),s=e.get(r);return typeof s=="undefined"&&(s=t.apply(this,o),e.set(r,s)),s}function Vr(t,e,n,o,r){return n.bind(e,t,o,r)}function ag(t,e){var n=t.length===1?Pa:Ia;return Vr(t,this,n,e.cache.create(),e.serializer)}function lg(t,e){return Vr(t,this,Ia,e.cache.create(),e.serializer)}function dg(t,e){return Vr(t,this,Pa,e.cache.create(),e.serializer)}var cg=function(){return JSON.stringify(arguments)},ug=(function(){function t(){this.cache=Object.create(null)}return t.prototype.get=function(e){return this.cache[e]},t.prototype.set=function(e,n){this.cache[e]=n},t})(),pg={create:function(){return new ug}},mo={variadic:lg,monadic:dg};var fo;(function(t){t[t.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",t[t.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",t[t.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",t[t.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",t[t.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",t[t.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",t[t.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",t[t.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",t[t.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",t[t.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",t[t.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",t[t.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",t[t.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",t[t.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",t[t.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",t[t.INVALID_TAG=23]="INVALID_TAG",t[t.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",t[t.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",t[t.UNCLOSED_TAG=27]="UNCLOSED_TAG"})(fo||(fo={}));var ho=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var de;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(de||(de={}));var yo;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(yo||(yo={}));function jr(t){return t.type===de.literal}function $r(t){return t.type===de.argument}function mn(t){return t.type===de.number}function fn(t){return t.type===de.date}function hn(t){return t.type===de.time}function yn(t){return t.type===de.select}function vn(t){return t.type===de.plural}function La(t){return t.type===de.pound}function xn(t){return t.type===de.tag}function vo(t){return!!(t&&typeof t=="object"&&t.type===yo.number)}function Sn(t){return!!(t&&typeof t=="object"&&t.type===yo.dateTime)}function Gr(t){t.forEach(function(e){if(delete e.location,yn(e)||vn(e))for(var n in e.options)delete e.options[n].location,Gr(e.options[n].value);else mn(e)&&vo(e.style)||(fn(e)||hn(e))&&Sn(e.style)?delete e.style.location:xn(e)&&Gr(e.children)})}function Aa(t,e){e===void 0&&(e={}),e=se({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var n=new ho(t,e).parse();if(n.err){var o=SyntaxError(fo[n.err.kind]);throw o.location=n.err.location,o.originalMessage=n.err.message,o}return e!=null&&e.captureLocation||Gr(n.val),n.val}var lt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(lt||(lt={}));var bn=(function(t){gn(e,t);function e(n,o,r){var s=t.call(this,n)||this;return s.code=o,s.originalMessage=r,s}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e})(Error);var qr=(function(t){gn(e,t);function e(n,o,r,s){return t.call(this,'Invalid values for "'.concat(n,'": "').concat(o,'". Options are "').concat(Object.keys(r).join('", "'),'"'),lt.INVALID_VALUE,s)||this}return e})(bn);var Ma=(function(t){gn(e,t);function e(n,o,r){return t.call(this,'Value for "'.concat(n,'" must be of type ').concat(o),lt.INVALID_VALUE,r)||this}return e})(bn);var Na=(function(t){gn(e,t);function e(n,o){return t.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(o,'"'),lt.MISSING_VALUE,o)||this}return e})(bn);var Q;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(Q||(Q={}));function gg(t){return t.length<2?t:t.reduce(function(e,n){var o=e[e.length-1];return!o||o.type!==Q.literal||n.type!==Q.literal?e.push(n):o.value+=n.value,e},[])}function mg(t){return typeof t=="function"}function Cn(t,e,n,o,r,s,i){if(t.length===1&&jr(t[0]))return[{type:Q.literal,value:t[0].value}];for(var a=[],d=0,l=t;d<l.length;d++){var c=l[d];if(jr(c)){a.push({type:Q.literal,value:c.value});continue}if(La(c)){typeof s=="number"&&a.push({type:Q.literal,value:n.getNumberFormat(e).format(s)});continue}var p=c.value;if(!(r&&p in r))throw new Na(p,i);var u=r[p];if($r(c)){(!u||typeof u=="string"||typeof u=="number")&&(u=typeof u=="string"||typeof u=="number"?String(u):""),a.push({type:typeof u=="string"?Q.literal:Q.object,value:u});continue}if(fn(c)){var f=typeof c.style=="string"?o.date[c.style]:Sn(c.style)?c.style.parsedOptions:void 0;a.push({type:Q.literal,value:n.getDateTimeFormat(e,f).format(u)});continue}if(hn(c)){var f=typeof c.style=="string"?o.time[c.style]:Sn(c.style)?c.style.parsedOptions:o.time.medium;a.push({type:Q.literal,value:n.getDateTimeFormat(e,f).format(u)});continue}if(mn(c)){var f=typeof c.style=="string"?o.number[c.style]:vo(c.style)?c.style.parsedOptions:void 0;f&&f.scale&&(u=u*(f.scale||1)),a.push({type:Q.literal,value:n.getNumberFormat(e,f).format(u)});continue}if(xn(c)){var h=c.children,m=c.value,g=r[m];if(!mg(g))throw new Ma(m,"function",i);var b=Cn(h,e,n,o,r,s),T=g(b.map(function(L){return L.value}));Array.isArray(T)||(T=[T]),a.push.apply(a,T.map(function(L){return{type:typeof L=="string"?Q.literal:Q.object,value:L}}))}if(yn(c)){var C=c.options[u]||c.options.other;if(!C)throw new qr(c.value,u,Object.keys(c.options),i);a.push.apply(a,Cn(C.value,e,n,o,r));continue}if(vn(c)){var C=c.options["=".concat(u)];if(!C){if(!Intl.PluralRules)throw new bn(`Intl.PluralRules is not available in this environment.
2
2
  Try polyfilling it using "@formatjs/intl-pluralrules"
3
- `,lt.MISSING_INTL_API,i);var w=n.getPluralRules(e,{type:c.pluralType}).select(u-(c.offset||0));C=c.options[w]||c.options.other}if(!C)throw new $r(c.value,u,Object.keys(c.options),i);a.push.apply(a,Cn(C.value,e,n,o,r,u-(c.offset||0)));continue}}return pg(a)}function mg(t,e){return e?se(se(se({},t||{}),e||{}),Object.keys(t).reduce(function(n,o){return n[o]=se(se({},t[o]),e[o]||{}),n},{})):t}function fg(t,e){return e?Object.keys(t).reduce(function(n,o){return n[o]=mg(t[o],e[o]),n},se({},t)):t}function Gr(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,n){t[e]=n}}}}}function hg(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:go(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.NumberFormat).bind.apply(e,po([void 0],n,!1)))},{cache:Gr(t.number),strategy:mo.variadic}),getDateTimeFormat:go(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.DateTimeFormat).bind.apply(e,po([void 0],n,!1)))},{cache:Gr(t.dateTime),strategy:mo.variadic}),getPluralRules:go(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.PluralRules).bind.apply(e,po([void 0],n,!1)))},{cache:Gr(t.pluralRules),strategy:mo.variadic})}}var qr=(function(){function t(e,n,o,r){n===void 0&&(n=t.defaultLocale);var s=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(l){var c=s.formatToParts(l);if(c.length===1)return c[0].value;var p=c.reduce(function(u,f){return!u.length||f.type!==Q.literal||typeof u[u.length-1]!="string"?u.push(f.value):u[u.length-1]+=f.value,u},[]);return p.length<=1?p[0]||"":p},this.formatToParts=function(l){return Cn(s.ast,s.locales,s.formatters,s.formats,l,void 0,s.message)},this.resolvedOptions=function(){var l;return{locale:((l=s.resolvedLocale)===null||l===void 0?void 0:l.toString())||Intl.NumberFormat.supportedLocalesOf(s.locales)[0]}},this.getAst=function(){return s.ast},this.locales=n,this.resolvedLocale=t.resolveLocale(n),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=r||{},a=i.formatters,d=Ia(i,["formatters"]);this.ast=t.__parse(e,se(se({},d),{locale:this.resolvedLocale}))}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=fg(t.formats,o),this.formatters=r&&r.formatters||hg(this.formatterCache)}return Object.defineProperty(t,"defaultLocale",{get:function(){return t.memoizedDefaultLocale||(t.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),t.memoizedDefaultLocale},enumerable:!1,configurable:!0}),t.memoizedDefaultLocale=null,t.resolveLocale=function(e){if(typeof Intl.Locale!="undefined"){var n=Intl.NumberFormat.supportedLocalesOf(e);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof e=="string"?e:e[0])}},t.__parse=Na,t.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},t})();function xg(t,e){return e.split(".").reduce((n,o)=>n?n[o]:void 0,t)}var Sg="dummy",Xr=yg(null);function R(t){var o;let e=vg(Xr);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let n=(o=t[e])!=null?o:{};return(r,s)=>{let i=xg(n,r);return i?new qr(i).format(s):(e!==Sg&&console.warn(`${r} does not exist in messages of ${e}`),`[${r}]`)}}import{useEffect as bg,useRef as Cg}from"react";var _a={root:"dd-tvkOF",content:"dd-eXA1D"};import{jsx as Fa}from"react/jsx-runtime";var Tg=({isOpen:t,autoFocus:e,children:n,onClose:o,onBack:r,onKeyDown:s,overlayAriaLabel:i,contentAriaLabel:a})=>{let d=Cg(null),l=S("Dialog",_a),c=u=>{if(u.key==="Escape"){u.preventDefault(),u.stopPropagation(),r();return}s&&s(u)},p=u=>{u.target===d.current&&t&&o()};return bg(()=>{var u,f;!d.current||!t||!e||(f=(u=d.current)==null?void 0:u.querySelector("input, textarea"))==null||f.focus()},[t,e,d]),t?Fa("div",{role:"dialog","data-testid":"dialog",className:l.root,"aria-label":i,ref:d,onKeyDown:c,onMouseDown:p,children:Fa("div",{"data-testid":"dialog-content",className:l.content,"aria-label":a,children:n})}):null},Ft=Tg;import wg from"classnames";var Ha={root:"dd-ranhW"};import{jsx as kg}from"react/jsx-runtime";var Eg=o=>{var r=o,{className:t,value:e}=r,n=M(r,["className","value"]);let s=S("TextInput",Ha);return kg("input",y({className:wg(t,s.root),type:"text",value:e},n))},Tn=Eg;var Jr={};X(Jr,{enUS:()=>Rg,nlNL:()=>Pg});var Rg={back:[{type:0,value:"Back"}],promptTitle:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Paste the code from your email"}],verifyCodeBody:[{type:0,value:"Copy the code from the email you just received and paste it here."}],verifyCodeInputPlaceholder:[{type:0,value:"Paste link or code here"}],verifyCodeSubmitLabel:[{type:0,value:"Sign in"}],verifyCodeError:[{type:0,value:"Sign in failed. The code is probably no longer valid. Please "},{type:8,value:"login",children:[{type:0,value:"request new code"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Have a code sent to your email"}],requestCodeBody:[{type:0,value:"Enter your email and request a code. If you are an existing "},{type:1,value:"productName"},{type:0,value:" user you will receive an email with a code. If you are a new user you will receive an email asking to request access to "},{type:1,value:"productName"},{type:0,value:" first."}],requestCodeInputPlaceholder:[{type:0,value:"Enter your email"}],requestCodeSubmitLabel:[{type:0,value:"Request code"}]},Pg={back:[{type:0,value:"Terug"}],promptTitle:[{type:0,value:"Login bij "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Plak de code uit je email"}],verifyCodeBody:[{type:0,value:"Kopieer de code uit de email en plak deze hier."}],verifyCodeInputPlaceholder:[{type:0,value:"Plak hier de code"}],verifyCodeSubmitLabel:[{type:0,value:"Inloggen"}],verifyCodeError:[{type:0,value:"Inloggen is niet gelukt. De code is waarschijnlijk niet meer geldig. "},{type:8,value:"login",children:[{type:0,value:"Vraag een nieuwe code aan"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Verstuur een login code naar je email"}],requestCodeBody:[{type:0,value:"Voer je e-mailadres in en krijg een login code. Als je een bestaande "},{type:1,value:"productName"},{type:0,value:" gebruiker bent krijg je een email met een code. Als je een nieuwe gebruiker bent wordt er een email verstuurd met een toegangsverzoek voor "},{type:1,value:"productName"},{type:0,value:"."}],requestCodeInputPlaceholder:[{type:0,value:"Typ hier je e-mailadres"}],requestCodeSubmitLabel:[{type:0,value:"Code aanvragen"}]};var Ba={root:"dd-lWxnE",anchorButton:"dd-TZ4in",errorMessage:"dd-fIsPg",title:"dd-pGhJx",subtitle:"dd-f5l29",text:"dd-iamoD",input:"dd-uhQZ3",actions:"dd-lubvx",button:"dd-CJsNI",primaryButton:"dd-MWBfl"};import{jsx as oe,jsxs as xo}from"react/jsx-runtime";var Ng=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch(e){return t}},Og=({agentEmail:t,isOpen:e,origin:n="",onSuccess:o,onDismiss:r})=>{let s=R(Jr),i=S("LoginTokenDialog",Ba),a=Mg(Hi),d=Ag(),l=E("productName"),[c,p]=Zr(t||""),[u,f]=Zr(0),[m,g]=Zr(""),h=Ua(w=>v(null,null,function*(){w.preventDefault(),d(Ki({email:c})),f(1)}),[n,c]),b=()=>{g(""),f(0)},T=Ua(w=>v(null,null,function*(){w.preventDefault();let L=Ng(w.target.elements.token.value);if(!L){g(s("verifyCodeError",{login:C}));return}d(ln({token:L}))}),[n]),C=Lg(()=>w=>oe("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:b,children:w},"back-button"),[]);return Ig(()=>{a==="error"&&g(s("verifyCodeError",{login:C})),a==="done"&&o()},[a]),oe(Ft,{autoFocus:!0,isOpen:e,contentAriaLabel:s("promptTitle",{productName:l}),overlayAriaLabel:s("promptTitle",{productName:l}),onClose:r,onBack:r,children:xo("div",{className:i.root,children:[oe("h1",{className:i.title,children:s("promptTitle",{productName:l})}),u===0&&xo("form",{onSubmit:h,children:[oe("h2",{className:i.subtitle,children:s("requestCodeTitle")}),oe("p",{className:i.text,children:s("requestCodeBody",{productName:l})}),oe(Tn,{className:i.input,name:"email",placeholder:s("requestCodeInputPlaceholder"),value:c,onChange:w=>p(w.target.value)}),oe("div",{className:i.actions,children:oe("button",{type:"submit",className:Qr(i.button,i.primaryButton),children:s("requestCodeSubmitLabel")})})]}),u===1&&xo("form",{onSubmit:T,children:[oe("h2",{className:i.subtitle,children:s("verifyCodeTitle")}),oe("p",{className:i.text,children:s("verifyCodeBody")}),oe(Tn,{className:i.input,name:"token",placeholder:s("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),m&&oe("div",{className:i.errorMessage,children:m}),xo("div",{className:i.actions,children:[oe("button",{type:"button",className:Qr(i.button),onClick:b,children:s("back")}),oe("button",{type:"submit",className:Qr(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:s("verifyCodeSubmitLabel")})]})]})]})})},Ka=Og;import{jsx as _g}from"react/jsx-runtime";var Dg=()=>{let t=za(Bi),e=za(Ot),n=E("adminUrl"),o=ne(),r=()=>o.send(_t,!1),s=()=>{o.send(_t,!1),o.send(pn)};return _g(Ka,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:n,onDismiss:r,onSuccess:s})},Wa=Dg;import Sf from"lodash.debounce";import{Fragment as bf,useCallback as Hl,useEffect as Bl,useMemo as Cf,useState as gs}from"react";import{useDispatch as Tf,useSelector as pt}from"react-redux";import{createAsyncThunk as Fg,createSlice as Hg}from"@reduxjs/toolkit";var Bg={data:null,fetchState:"idle"},Va=t=>t.contentTypes.data,wn=Fg("contentTypes/getContentTypes",(t,e)=>v(null,null,function*(){return e.extra.deepdeskAPI.getContentTypes()})),Ug=Hg({name:"contentTypes",initialState:Bg,reducers:{},extraReducers:t=>{t.addCase(wn.pending,e=>{e.fetchState="loading"}).addCase(wn.rejected,e=>{e.fetchState="error"}).addCase(wn.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),ja=Ug.reducer;import{createAsyncThunk as Kg,createSelector as zg,createSlice as Wg}from"@reduxjs/toolkit";var Vg={data:null,fetchState:"idle"},jg=[],dt=t=>t.profile.data,$g=t=>t.profile.data?t.profile.data.uiConfig.widget.types:jg,kn=zg([$g],t=>t.filter(e=>e.isActive)),$a=t=>{var e;return((e=t.profile.data)==null?void 0:e.onDemandAssistants)||[]},Ga=t=>e=>kn(e).find(n=>n.type===t),qa=t=>t.profile.data?!!t.profile.data.uiConfig.widget.types.find(e=>e.type==="custom-data"):!1,Xa=t=>{var e,n;return(n=(e=t.profile.data)==null?void 0:e.knowledgeAssistantNew)!=null?n:null},En=Kg("profile/getProfile",(t,e)=>v(null,null,function*(){var s;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=o.conversation.current;if(!r||!r.profileCode)throw new Error("No conversation of conversation profileCode found");return((s=o.profile.data)==null?void 0:s.code)===r.profileCode?o.profile.data:n.getProfile(r.profileCode)})),Gg=Wg({name:"profile",initialState:Vg,reducers:{},extraReducers:t=>{t.addCase(En.pending,e=>{e.fetchState="loading"}).addCase(En.rejected,e=>{e.fetchState="error"}).addCase(En.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),Ja=Gg.reducer;function be(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}import{useEffect as vl,useState as _m,useRef as Fm,useCallback as Hm}from"react";import{useState as Jg}from"react";import Yr from"classnames";var ie={root:"dd-U2SX4",list:"dd-cYTlj",listWrapper:"dd-GLQFR",listHorizontal:"dd-x-knl",page:"dd-1F4vk",search:"dd-nvbxc",pageNav:"dd-sRUuT",pageTitle:"dd-t-MKS",pageBackButton:"dd-cjptm",listHeader:"dd-Fg666",listHeading:"dd-w-xhJ",listMoreButton:"dd--mKep",listItem:"dd-wpvuA",listItemContent:"dd-V-mKo",listItemText:"dd-ukCHL",listItemDescription:"dd-sSyu4",listItemActions:"dd-xelho",listItemTooltip:"dd-SWFsE",listItemTooltipContent:"dd-I7J9N",truncate:"dd-IlopJ",lineClamp:"dd-Twaca",listItemTitle:"dd-lMGHq",listItemAction:"dd-xPLAs",listItemSelected:"dd-jFX0Y",sources:"dd-pZx4v",sourcesTitle:"dd-phYVd",source:"dd-DaR6h",sourceShowMore:"dd-M1-8j",icon:"dd-m6yxD",searchIcon:"dd-0AU-O",searchInputWrapper:"dd-DUFcE",searchInput:"dd-ukrlD",select:"dd--Tifv",selectType:"dd-IkZb2",selectWrapper:"dd-J14mx",image:"dd-RQgsB",imageSrc:"dd-jxh8F",imageSrcHidden:"dd-e20Jk",imageSrcStatus:"dd-j50Tt",imageTitle:"dd-qCjfW",actions:"dd-3mfWc",actionsWrapper:"dd-TjDyI",actionsBar:"dd-LiA35",actionButton:"dd-4wk0u",hasShortKeys:"dd-XilV-",actionShortcut:"dd-s4Mla",actionShortcutFixKerning:"dd-lyh5e"};var Oe={};X(Oe,{enUS:()=>qg,nlNL:()=>Xg});var qg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}],showAll:[{type:0,value:"Show more"}],sources:[{type:0,value:"Sources"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},Xg={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}],showAll:[{type:0,value:"Toon meer"}],sources:[{type:0,value:"Bronnen"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};import{jsx as Rn,jsxs as Zg}from"react/jsx-runtime";var Qg=({src:t,title:e})=>{let n=S("CommandPalette",ie),[o,r]=Jg("loading"),s=R(Oe);return Zg("div",{className:n.image,children:[Rn("img",{src:t,alt:e,onLoad:()=>r("done"),onError:()=>r("error"),className:Yr(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(o)})}),o==="loading"&&Rn("span",{className:Yr(n.imageSrc,n.imageSrcStatus),children:s("loading")}),o==="error"&&Rn("span",{className:Yr(n.imageSrc,n.imageSrcStatus),children:Rn(Vn,{})}),e&&Rn("span",{className:n.imageTitle,children:e})]})},Qa=Qg;import Yg from"react";import em from"classnames";import{jsx as es,jsxs as Za}from"react/jsx-runtime";function ts({children:t,heading:e,orientation:n,hasMore:o,onShowAll:r}){let s=R(Oe),i=S("CommandPalette",ie);return Yg.Children.count(t)===0?null:Za("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||o)&&Za("div",{className:i.listHeader,children:[e&&es("h4",{className:i.listHeading,children:e}),o&&r&&es("button",{onClick:r,className:i.listMoreButton,type:"button",children:s("showAll")})]}),es("div",{className:em(i.listWrapper,n==="horizontal"&&i.listHorizontal),children:t})]})}import Co from"classnames";import{Interweave as al}from"interweave";import{useEffect as km,useMemo as ll,useState as dl}from"react";var tm=/[.*+?^${}()|[\]\\]/g,nm=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function om(t){return t.replace(tm,"\\$&")}function rm(t,e){let n=t.split("").findIndex((o,r)=>o!==e[r]);return n>-1?n:Math.min(t.length,e.length)}function sm(t){return t.search(nm)}function Ya(t,e=[]){let n=t;return e.forEach(o=>{if(!o)return;let r=new RegExp(`\\b(${om(o)})\\b`,"gi");n=n.replace(r,"<strong>$1</strong>")}),n}function el(t){return t.replace(qn,'<mark data-type="placeholder">$1</mark>')}function Pn(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function im(t,e){return t.split("").map((i,a)=>({char:i,index:a})).filter(({char:i,index:a})=>/\s/.test(i)&&a<=e).map(({index:i})=>i).reverse()[0]}function ns(t,e,n={}){if(e){let o=rm(e.toLowerCase(),t.toLowerCase()),r=Pn(t.substring(o,t.length));if(n.stripAgentPart){let d=t.substring(0,o),l=sm(d);return`<span style="opacity: 0.5">${d.substring(l+1)}</span>${r}`}let i=e.split(Ni).length>3||e.length>30?im(e.trim(),o):0;return`${`${i>0?"\u2026":""}${Pn(t.substring(i,o))}`}<strong>${r}</strong>`}return t}var am=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function So(t){return am.test(t)}function os(t){var n;let e=document.createElement("template");return e.innerHTML=t,(n=e.content.textContent)!=null?n:""}import rs from"react";import{jsx as lm}from"react/jsx-runtime";var tl=rs.createContext(void 0);function Ht(){let t=rs.useContext(tl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var nl=({children:t,page:e,isOpen:n,onChangeOpen:o,selected:r,setSelected:s})=>{let i=rs.useMemo(()=>({page:e,isOpen:n,onChangeOpen:o,selected:r,setSelected:s}),[n,e,r]);return lm(tl.Provider,{value:i,children:t})};import*as Ce from"react";import{useFloating as dm,autoUpdate as cm,useClick as um,useDismiss as pm,useRole as gm,useInteractions as mm,useMergeRefs as rl,FloatingPortal as fm,FloatingFocusManager as hm,useHover as ym,offset as vm,flip as xm,shift as Sm,safePolygon as bm}from"@floating-ui/react";var bo={tooltip:"dd-XpCXd",tooltipTrigger:"dd-8TKeF",arrow:"dd-ZEu2Y"};import{jsx as qe,jsxs as ol}from"react/jsx-runtime";function Cm({initialOpen:t=!1,placement:e="bottom",modal:n,tooltip:o,open:r,onOpenChange:s}={}){let[i,a]=Ce.useState(t),d=r!=null?r:i,l=s!=null?s:a,c=dm({placement:e,open:d,onOpenChange:l,whileElementsMounted:cm,middleware:[vm(5),xm({crossAxis:e.includes("-"),fallbackAxisSideDirection:"end",padding:5}),Sm({padding:10})]}),p=c.context,u=um(p,{enabled:r==null}),f=pm(p),m=gm(p),g=ym(p,{enabled:o!=null?o:!1,handleClose:bm()}),h=mm([u,f,m,g]);return Ce.useMemo(()=>x(y(y({open:d,setOpen:l},h),c),{modal:n}),[d,l,h,c,n])}var sl=Ce.createContext(null),ss=()=>{let t=Ce.useContext(sl);if(t==null)throw new Error("Popover components must be wrapped in <Popover />");return t},ct=o=>{var r=o,{children:t,modal:e=!1}=r,n=M(r,["children","modal"]);let s=Cm(y({modal:e},n));return qe(sl.Provider,{value:s,children:t})};function Tm(o){var r=o,{as:t,children:e}=r,n=M(r,["as","children"]);let s=ss(),i=t||"button",a=e.ref,d=rl([s.refs.setReference,a]);return qe(i,x(y({ref:d,type:"button"},s.getReferenceProps(n)),{children:e}))}var wm=Ce.forwardRef(function(r,o){var s=r,{style:e}=s,n=M(s,["style"]);let l=ss(),{context:i}=l,a=M(l,["context"]),d=rl([a.refs.setFloating,o]);return i.open?qe(fm,{children:qe(hm,{context:i,modal:a.modal,disabled:n.disableFocusManager,children:qe("div",x(y({ref:d,style:y(x(y({},a.floatingStyles),{zIndex:1e7}),e)},a.getFloatingProps(n)),{children:n.children}))})}):null});function Em(r){var s=r,{as:t,children:e,onClick:n}=s,o=M(s,["as","children","onClick"]);let{setOpen:i}=ss();return qe(t||"button",x(y({type:"button",onClick:l=>{n(l),i(!1),l.stopPropagation()}},o),{children:e}))}function il({trigger:t,children:e,placement:n="top"}){return ol(ct,{tooltip:!0,placement:n,children:[ol(ct.Content,{className:bo.tooltip,children:[e,qe("div",{className:bo.arrow})]}),qe(ct.Trigger,{className:bo.tooltipTrigger,children:t})]})}ct.Trigger=Tm;ct.Content=wm;ct.Button=Em;var $=ct;import{jsx as De,jsxs as To}from"react/jsx-runtime";var Rm=3,Pm=90,cl=({children:t})=>{let e=S("CommandPalette",ie);return De("div",{className:e.listItemActions,children:t})};function is(f){var m=f,{closeOnSelect:t=!0,lineClamp:e,tooltip:n,children:o,onClick:r,extra:s,onSourceClick:i,description:a,sources:d,id:l,styles:c,defaultSourcesAmount:p=Rm}=m,u=M(m,["closeOnSelect","lineClamp","tooltip","children","onClick","extra","onSourceClick","description","sources","id","styles","defaultSourcesAmount"]);var ae;let g=R(Oe),[h,b]=dl(!1),{selected:T,onChangeOpen:C}=Ht(),[w,L]=dl(!1),N=S("CommandPalette",ie);function _(O){r(O),t&&C(!1)}let W=ll(()=>typeof a!="string"?a:So(a)?os(a).trim():a,[a]),ce=ll(()=>typeof n!="string"?n:So(n)?os(n).trim():n,[n]);return km(()=>{L(T===l)},[T]),To("div",{className:Co(N.listItem,l===T&&N.listItemSelected),children:[To($,{placement:"right-start",tooltip:!0,onOpenChange:L,open:w,children:[De($.Trigger,x(y({className:N.listItemAction,"aria-disabled":(ae=u.disabled)!=null?ae:!1,onClick:_,"data-command-palette-item":!0,"data-item-id":l},u),{children:To("div",{className:N.listItemContent,children:[typeof o=="string"?De("p",{className:Co(N.listItemText,N.truncate,c==null?void 0:c.title),children:o}):o,W&&typeof W=="string"?De(al,{tagName:"p",allowList:[],content:W,className:Co(N.listItemDescription,c==null?void 0:c.description,e?N.lineClamp:N.truncate)}):a]})})),ce&&ce.length>Pm&&De($.Content,{className:N.listItemTooltip,disableFocusManager:!0,children:De(al,{className:N.listItemTooltipContent,allowList:["h1","h2","h3","h4","h5","h6","a","p","br"],tagName:"div",content:ce.replace(/\n/g,"<br />")})})]}),l===T&&s,d&&d.length>0&&To("div",{className:N.sources,children:[De("span",{className:N.sourcesTitle,children:g("sources")}),d.slice(0,h?d.length:p).map(O=>De("a",{className:N.source,href:O.url,target:"_blank",title:O.url,rel:"noopener noreferrer","data-testid":"source",onClick:()=>i==null?void 0:i(O),children:O.name},O.url)),!h&&d.length>p&&De("button",{className:Co(N.source,N.sourceShowMore),type:"button",onClick:()=>b(!0),children:g("showMore",{amount:d.length-p})})]})]})}import{jsx as ul,jsxs as Im}from"react/jsx-runtime";var pl=()=>Im("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[ul("title",{id:"angleLeftTitle",children:"AngleLeft"}),ul("path",{d:"M192 448c-8.188 0-16.38-3.125-22.62-9.375l-160-160c-12.5-12.5-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L77.25 256l137.4 137.4c12.5 12.5 12.5 32.75 0 45.25C208.4 444.9 200.2 448 192 448z"})]});import{jsx as gl,jsxs as as}from"react/jsx-runtime";function ls({children:t,title:e,id:n,onDismiss:o}){let r=R(Oe),s=S("CommandPalette",ie),{page:i}=Ht();return i!==n?null:as("div",{className:s.page,id:`page_${n}`,tabIndex:-1,children:[o&&as("div",{className:s.pageNav,children:[as("button",{className:s.pageBackButton,type:"button",onClick:o,children:[gl(pl,{}),r("back")]}),e&&gl("h3",{className:s.pageTitle,children:e})]}),t]})}import{forwardRef as Am}from"react";import{jsx as ml,jsxs as Lm}from"react/jsx-runtime";var Bt=()=>Lm("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[ml("path",{d:"M0 0h24v24H0z",fill:"none"}),ml("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});import{jsx as Ut,jsxs as ds}from"react/jsx-runtime";function Mm({onChange:t,onChangeType:e,placeholder:n,typePlaceholder:o,types:r,value:s,selectedType:i},a){let d=S("CommandPalette",ie);return ds("div",{className:d.search,children:[Ut("div",{className:d.searchIcon,children:Ut(Bt,{})}),ds("div",{className:d.searchInputWrapper,children:[Ut("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:l=>{t(l.currentTarget.value)},onFocus:l=>{l.currentTarget.select()},className:d.searchInput,placeholder:n,value:s,type:"text",id:"command-palette-search-input",autoFocus:!0}),r&&r.length>0&&Ut("div",{className:d.selectWrapper,children:ds("select",{"data-testid":"command-palette-type-select",className:d.select,onChange:l=>e(l.target.value===o?void 0:l.target.value),value:i||o,children:[o&&Ut("option",{children:o}),r.map(l=>Ut("option",{value:l.value,children:l.label},l.value))]})})]})]})}var fl=Am(Mm);import hl from"classnames";import{jsx as Om,jsxs as Dm}from"react/jsx-runtime";var Nm=r=>{var s=r,{onClick:t,shortKeys:e,children:n}=s,o=M(s,["onClick","shortKeys","children"]);let i=S("CommandPalette",ie);return Dm("button",x(y({type:"button"},o),{onClick:t,className:hl(i.actionButton,o.className,{[i.hasShortKeys]:e&&e.length>0}),children:[n,e==null?void 0:e.map(a=>Om("span",{className:hl(i.actionShortcut,a===8629&&i.actionShortcutFixKerning),children:typeof a=="number"?String.fromCharCode(a):a},a))]}))},yl=Nm;import{jsx as xl,jsxs as Um}from"react/jsx-runtime";var Bm="[data-command-palette-item]";function ut({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:n="search",page:o,onChangePage:r,onChangeSearch:s,onChangeType:i,onChangeOpen:a,selectedType:d,types:l,children:c,isOpen:p,search:u,updateDeps:f=[]}){let[m,g]=_m(),h=Fm(null),b=()=>{r&&r(n),i(void 0),s(""),a(!1)},T=()=>{var O;if(o!==n&&r){r(n);return}if(d&&i){i(void 0),(O=h.current)==null||O.focus();return}if(u.length>0){s("");return}a(!1)},C=()=>{let O=w();O.length!==0&&g(O[0].dataset.itemId)},w=()=>Array.from(document.querySelectorAll(Bm)||[]),L=O=>document.querySelector(`[data-item-id=${O}]`),N=O=>{let U=L(O);U&&g(U.dataset.itemId)},_=O=>{let U=L(O);U&&U.scrollIntoView({behavior:"smooth"})},W=()=>{if(!m)return;let O=w(),U=L(m);if(!U)return;let Ie=O.indexOf(U),le=O[Ie+1];le!=null&&le.dataset.itemId?N(le.dataset.itemId):C()},ce=()=>{if(!m)return;let O=w(),U=L(m);if(!U)return;let Ie=O.indexOf(U),le=O[Ie-1];le!=null&&le.dataset.itemId?N(le.dataset.itemId):N(O[O.length-1].dataset.itemId)},ae=Hm(O=>{switch(O.key){case"ArrowDown":{O.preventDefault(),W();break}case"ArrowUp":{O.preventDefault(),ce();break}case"Enter":{if(m){let U=L(m);U==null||U.click()}break}}},[m]);return vl(()=>{C()},[u,o,d,p,...f]),vl(()=>{m&&_(m)},[m]),xl(Ft,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:p,onBack:T,onClose:b,onKeyDown:ae,children:Um(nl,{selected:m,setSelected:g,isOpen:p,onChangeOpen:a,page:o,children:[o===n&&xl(fl,{ref:h,onChange:s,onChangeType:i,placeholder:t,value:u,selectedType:d,types:l,typePlaceholder:e}),c]})})}ut.Page=ls;ut.List=ts;ut.Image=Qa;ut.ListItem=is;ut.ListItemActions=cl;ut.Button=yl;var G=ut;import{useEffect as Km}from"react";function Sl(t,e){Km(()=>{let n=o=>{var r;((r=navigator==null?void 0:navigator.platform)!=null&&r.toLowerCase().includes("mac")?o.metaKey:o.ctrlKey)&&o.key===t&&(o.preventDefault(),o.stopPropagation(),e())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}import{useEffect as wl,useRef as Jm}from"react";import{useSelector as Qm,useDispatch as Zm}from"react-redux";import{createAsyncThunk as zm,createSelector as Wm,createSlice as Vm}from"@reduxjs/toolkit";var bl={data:null,fetchState:"idle"},jm=t=>{var e;return(e=t.entities.data)!=null?e:null},wo=Wm([jm,Ot,ua],(t,e,n)=>{var a;let o=[],{visitorName:r}=n!=null?n:{},{agentName:s,agentNickname:i}=e!=null?e:{};return s&&s!==r&&o.push(s),i&&i!==r&&o.push(i),(a=t==null?void 0:t.filter(d=>!o.includes(d.text)))!=null?a:null}),fe=zm("entities/getEntities",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra;if(!o.conversationQuery)return Promise.resolve([]);let r=o.conversationQuery,s=yield r();return s.length===0?Promise.resolve([]):n.getEntities(s)})),$m=t=>t.filter((e,n)=>n===t.findIndex(o=>o.text===e.text)),Gm=Vm({name:"entities",initialState:bl,reducers:{},extraReducers:t=>{t.addCase(fe.pending,e=>{e.fetchState="loading"}).addCase(fe.rejected,e=>{e.fetchState="error"}).addCase(fe.fulfilled,(e,n)=>{e.fetchState="done",e.data=$m(e.data?[...e.data,...n.payload]:n.payload)}).addCase(V,()=>bl)}}),Cl=Gm.reducer;var cs={};X(cs,{enUS:()=>qm,nlNL:()=>Xm});var qm={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Xm={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Tl={root:"dd-TYTKs",empty:"dd-AU7uT"};import{jsx as us,jsxs as ef}from"react/jsx-runtime";var Ym=({onCopy:t})=>{let e=Jm(null),n=S("EntitiesList",Tl),o=Qm(wo),{setSelected:r}=Ht(),s=R(cs),i=Zm();return wl(()=>{i(fe())},[]),wl(()=>{e.current&&(e.current.focus(),r("entity-0"))},[e]),ef("div",{className:n.root,ref:e,tabIndex:-1,children:[o&&o.length>0&&us(G.List,{children:o.map((a,d)=>us(G.ListItem,{id:`entity-${d}`,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities"),o&&o.length===0&&us("p",{className:n.empty,children:s("noResults")})]})},El=Ym;import{jsx as kl}from"react/jsx-runtime";var Eo=t=>kl("svg",x(y({xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512"},t),{children:kl("path",{fill:"currentColor",d:"M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"})}));var In={};X(In,{enUS:()=>tf,nlNL:()=>nf});var tf={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],giveFeedback:[{type:0,value:"Give feedback"}],answer:[{type:0,value:"Answer"}]},nf={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],giveFeedback:[{type:0,value:"Geef feedback"}],answer:[{type:0,value:"Antwoord"}]};var Xe=t=>e=>{let{passwordlessToken:{token:n},settings:{isEmbedded:o,adminUrl:r}}=e,s=r||window.location.origin;return o&&!n?null:o&&n?`${s}/apis/admin/session/passwordless/login/?token=${n}&redirect=${encodeURIComponent(t)}`:`${s}${t}`};import{useSelector as Rl}from"react-redux";var ko={trigger:"dd-dQ-OH",content:"dd-9k0N3",item:"dd-va6pa"};import{useDispatch as rf}from"react-redux";import{createAsyncThunk as of}from"@reduxjs/toolkit";function ps(t){return of("analytics/logEvent",(e,n)=>{var s,i,a;let o=(i=(s=n.getState())==null?void 0:s.conversation.current)==null?void 0:i.id,r=(a=n.getState())==null?void 0:a.info.agentInfo;return n.extra.deepdeskAPI.sendEvent(e.name,x(y({conversationId:o},r),{data:e.data}))})(t)}function K(){let t=rf();return(e,n)=>v(null,null,function*(){yield t(ps({name:e,data:n}))})}import{jsx as Ro,jsxs as af}from"react/jsx-runtime";var sf=({suggestion:t,source:e,context:n})=>{let o=R(In),r=Rl(Se),s=K(),i=E("enableSuggestionFeedback"),a=`${t.text}`,d=Rl(Xe(`/admin/feedback?conversationId=${r}&type=${e}&text=${a}&data=${JSON.stringify({context:n})}`)),l=()=>{s("suggestion feedback",{text:t.text,source:e,context:n})};return!i||!d?null:af($,{placement:"top-end",children:[Ro($.Trigger,{className:ko.trigger,children:Ro(Eo,{"data-testid":"feedback-dropdown-trigger"})}),Ro($.Content,{className:ko.content,children:Ro($.Button,{className:ko.item,as:"a",onClick:l,target:"_blank",href:d,children:o("giveFeedback")})})]})},Po=sf;var Ln={};X(Ln,{enUS:()=>lf,nlNL:()=>df});var lf={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"URL suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},df={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"URL suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};import{useEffect as mf}from"react";import{useDispatch as ff,useSelector as hf}from"react-redux";import{createAction as pf,createAsyncThunk as Al,createSlice as gf}from"@reduxjs/toolkit";var cf=["{amount}"," {amount}","{date}","{email}","{iban}","{name}","{postal_code}","{street}","{tarif}","{usage}","{3_digits}","{4_digits}","{5_digits}","{6_digits}","{7_digits}","{8_digits}","{9_digits}","{10_digits}"],uf=new RegExp(cf.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Pl(t,e){let n=t.split(uf),o=0,r=[];for(let s=0;s<n.length;s++){let i=n[s];if(r.push(i),s===n.length-1)break;if(e.indexOf(i)===-1)return t;let a=n[s+1],d=s===n.length-2;o+=i.length;let l=o;if(d){let p=a.charAt(0),u=0;do l=p?e.indexOf(p,l+1):-1,u+=1;while(l!==-1&&a.indexOf(e.slice(l))!==0);if(l===-1&&u>2)return t}else l=a&&a!==""?e.indexOf(a,o):-1;let c=l===-1?e.slice(o):e.slice(o,l);r.push(c),o=l}return r.join("")}function Il(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Ml={suggestions:[],fetchState:"idle"},Ll={default:Ml},Nl=t=>e=>{var n,o;return(o=(n=e.textSuggestions[t])==null?void 0:n.suggestions)!=null?o:[]},Io=t=>t.textSuggestions,Ol=t=>{let e=t.toLowerCase();return n=>{let o=n.text.toLowerCase();return o.startsWith(e)&&o.length>e.length}},Lo=pf("textSuggestions/refresh"),he=Al("textSuggestions/recommendations",(t,e)=>v(null,null,function*(){var c,p,u;let{deepdeskAPI:n}=e.extra,o=e.getState(),{platformVariables:r}=o.info,{textSuggestionsCount:s,inlineSuggestions:i}=o.settings,a=At(o),d=(c=o.conversation.current)==null?void 0:c.id;if(!d)throw new Error("No current conversation to fetch text suggestions");if(!((p=o.profile.data)!=null&&p.recommendationEngine))return[];let l=[];if(t==="sticky-messages"){let f=(u=o.profile.data)==null?void 0:u.code;if(!f)throw new Error("No current profile to fetch pinned messages");l=yield n.getPinnedMessages(f)}else l=yield n.getTextSuggestions(d,un(o),t);if(r&&(l=l.map(f=>y(x(y({},f),{text:ge(f.text,r)}),f.title?{title:ge(f.title,r)}:{}))),t==="default"){let f=i?l.filter(Ol(a)):l;e.dispatch(Ge(f.slice(0,s)))}return l})),An=Al("textSuggestions/autocompletions",(t,e)=>v(null,null,function*(){var c,p;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=(c=o.conversation.current)==null?void 0:c.id,{platformVariables:s}=o.info,{textSuggestionsCount:i,deanonymize:a,inlineSuggestions:d}=o.settings;if(!((p=o.profile.data)!=null&&p.recommendationEngine))return[];if(!r)throw new Error("No current conversation to fetch text suggestions");let l=yield n.getAutocompleteSuggestions(r,x(y({},un(o)),{input:t}));if(!e.getState().input.text)throw new Error("Abort");return d&&(l=l.filter(Ol(t))),s&&(l=l.map(u=>x(y({},u),{text:ge(u.text,s)}))),a&&(l=l.map(u=>x(y({},u),{text:u.source!=="trie-with-typos"?Pl(u.text,t):u.text}))),l=Il(l,i),e.dispatch(Ge(l)),l})),Dl=gf({name:"textSuggestions",initialState:Ll,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:n}=e.payload;t[n].fetchState="done",t[n].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}}},extraReducers:t=>{t.addCase(he.pending,(e,n)=>{let o=n.meta.arg,r=e[o]||Ml;return x(y({},e),{[o]:x(y({},r),{fetchState:"loading"})})}).addCase(he.rejected,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="error")}).addCase(he.fulfilled,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="done",e[o].suggestions=n.payload)}).addCase(An.pending,e=>{e.default.fetchState="loading"}).addCase(An.rejected,e=>{e.default.fetchState="error"}).addCase(An.fulfilled,(e,n)=>{e.default.fetchState="done",e.default.suggestions=n.payload}).addCase(V,()=>Ll)}}),{setTextSuggestions:_E}=Dl.actions,_l=Dl.reducer;import{jsx as Ao,jsxs as vf}from"react/jsx-runtime";var yf=({types:t,commands:e,onClick:n})=>{let o=ff(),r=R(Ln),s=hf(Io);return mf(()=>{t.forEach(({type:i})=>{(!s[i]||s[i].suggestions.length===0)&&o(he(i))})},[]),vf("div",{children:[e.length>0&&Ao(G.List,{heading:r("commands"),children:e.map((i,a)=>Ao(G.ListItem,{id:`command-${a}`,closeOnSelect:!1,onClick:i.onClick,children:i.label},i.label))}),t.map(({type:i,title:a})=>{var d;return Ao(G.List,{heading:a,orientation:"vertical",children:(d=s[i])==null?void 0:d.suggestions.map((l,c)=>Ao(G.ListItem,{id:`${i}-${c}`,closeOnSelect:!1,description:l.title&&l.text,onClick:()=>n(l.text,l),"data-testid":"search-overlay-suggestion",children:l.title||l.text},`${l.id}-${l.text}`))},i)})]})},Fl=yf;import{jsx as Te,jsxs as fs}from"react/jsx-runtime";var wf=200,Ef=5,kf=4,ms=(t,e,n)=>t.slice(0,n?10:e.toLowerCase()==="image"?kf:Ef),Rf=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Pf=()=>{var Ie,le,hi;let t=Tf(),e=ne(),n=R(Ln),[o,r]=gs(!1),[s,i]=gs(""),a=pt(ba),d=pt(dt),[l,c]=gs(),p=pt(J),u=E("showSearch"),f=E("enableSuggestionFeedback"),m=E("showEntitiesCommand"),g=E("showImageSearch"),h=E("searchTriggerKey"),b=pt(Va),T=pt(Hr),C=pt(Ca),w=pt(Sa),L=((hi=(le=(Ie=d==null?void 0:d.uiConfig)==null?void 0:Ie.search)==null?void 0:le.initialTypes)==null?void 0:hi.filter(({isActive:A})=>A))||[],N=K(),_=Cf(()=>{let A=ee=>ms(T.filter(z=>z.type===ee.toUpperCase()),ee,l),j=(b==null?void 0:b.map(ee=>({value:ee.code.toUpperCase(),label:`${ee.name}s`,list:A(ee.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[];if(j.push({value:"PERSONAL",label:n("personalSuggestions"),list:A("PERSONAL"),lineClamp:!1,listOrientation:"vertical"},{value:"URL",label:n("urlSuggestions"),list:A("URL"),lineClamp:!1,listOrientation:"vertical"},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:A("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical"}),g&&j.push({value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:A("IMAGE"),listOrientation:"horizontal"}),L.length===0)return j;let on=L.map(ee=>j.find(z=>z.value.toLowerCase()===ee.type)).filter(ee=>!!ee),Tr=j.filter(ee=>!on.find(z=>z.value===ee.value));return[...on,...Tr]},[b,L,g,l]),W=[{label:n("entitiesClipboard"),onClick:()=>t(Dt("entities")),shouldShow:m&&Rf(n("entitiesClipboard"),s)}].filter(A=>A.shouldShow).filter(()=>!l),ce=Hl(Sf((A,j)=>{t(at({query:A,type:j,tags:["search-overlay"],size:l?50:20}))},wf),[l]),ae=Hl((A,j)=>{j.type==="IMAGE"?e.send(Ur,{suggestion:j}):e.send(Me,{text:A,suggestion:j}),t(me(!1))},[t]),O=A=>{be(A.text),N("entity copied",{entity:A,type:"copy"}),t(me(!1))};function U(A){return j=>{o?window.confirm(n("warning"))&&(A(j),r(!1)):A(j)}}return Bl(()=>{s?ce(s,l):t(lo())},[s,l]),Bl(()=>{p&&t(wn())},[p]),Sl(h,()=>{t(me(!0)),N("open search",{via:"ctrl+k"})}),!u||!d?null:fs(G,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:i,onChangeOpen:U(A=>t(me(A))),onChangeType:A=>c(A),onChangePage:U(A=>t(Dt(A))),selectedType:l,search:s,page:a,isOpen:w,types:_,updateDeps:[T],children:[fs(G.Page,{id:"search",children:[s.length===0&&Te(Fl,{types:L,commands:W,onClick:ae}),s.length>0&&fs(bf,{children:[W.length>0&&Te(G.List,{heading:n("commands"),children:W.map((A,j)=>Te(G.ListItem,{closeOnSelect:!1,onClick:A.onClick,id:`commands-${j}`,children:A.label},A.label))}),_.map(({value:A,label:j,list:on,lineClamp:Tr,listOrientation:ee})=>Te(G.List,{heading:j,orientation:ee==="horizontal"?"horizontal":"vertical",onShowAll:()=>c(A),hasMore:!l&&C[A.toLowerCase()]>ms(on,A,l).length,children:ms(on,A,l).map(z=>Te(G.ListItem,{id:`${A}-${z.id}`,closeOnSelect:!1,lineClamp:Tr,onClick:()=>ae(z.text,z),description:A!=="IMAGE"?z.title&&z.text:void 0,tooltip:z.text,extra:f&&Te(G.ListItemActions,{children:Te(Po,{context:s,source:"search",suggestion:z})}),children:A==="IMAGE"?Te(G.Image,{title:z.title||z.text,src:z.image}):z.title||z.text},`${z.id}-${z.text}`))},A))]})]}),Te(G.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:U(()=>{t(Dt("search"))}),children:Te(El,{onCopy:O})})]})},Ul=Pf;import{jsx as Kl,jsxs as Af}from"react/jsx-runtime";var Lf=()=>{let t=E("showSearch"),e=E("isEmbedded");return Af(If,{children:[t&&Kl(Ul,{}),e&&Kl(Wa,{})]})},zl=Lf;import Df from"classnames";import{useSelector as _f}from"react-redux";import{jsx as hs}from"react/jsx-runtime";var Wl=({className:t})=>hs("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 512 512",xmlSpace:"preserve",className:t,children:hs("g",{children:hs("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
3
+ `,lt.MISSING_INTL_API,i);var w=n.getPluralRules(e,{type:c.pluralType}).select(u-(c.offset||0));C=c.options[w]||c.options.other}if(!C)throw new qr(c.value,u,Object.keys(c.options),i);a.push.apply(a,Cn(C.value,e,n,o,r,u-(c.offset||0)));continue}}return gg(a)}function fg(t,e){return e?se(se(se({},t||{}),e||{}),Object.keys(t).reduce(function(n,o){return n[o]=se(se({},t[o]),e[o]||{}),n},{})):t}function hg(t,e){return e?Object.keys(t).reduce(function(n,o){return n[o]=fg(t[o],e[o]),n},se({},t)):t}function Xr(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,n){t[e]=n}}}}}function yg(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:go(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.NumberFormat).bind.apply(e,po([void 0],n,!1)))},{cache:Xr(t.number),strategy:mo.variadic}),getDateTimeFormat:go(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.DateTimeFormat).bind.apply(e,po([void 0],n,!1)))},{cache:Xr(t.dateTime),strategy:mo.variadic}),getPluralRules:go(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.PluralRules).bind.apply(e,po([void 0],n,!1)))},{cache:Xr(t.pluralRules),strategy:mo.variadic})}}var Jr=(function(){function t(e,n,o,r){n===void 0&&(n=t.defaultLocale);var s=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(l){var c=s.formatToParts(l);if(c.length===1)return c[0].value;var p=c.reduce(function(u,f){return!u.length||f.type!==Q.literal||typeof u[u.length-1]!="string"?u.push(f.value):u[u.length-1]+=f.value,u},[]);return p.length<=1?p[0]||"":p},this.formatToParts=function(l){return Cn(s.ast,s.locales,s.formatters,s.formats,l,void 0,s.message)},this.resolvedOptions=function(){var l;return{locale:((l=s.resolvedLocale)===null||l===void 0?void 0:l.toString())||Intl.NumberFormat.supportedLocalesOf(s.locales)[0]}},this.getAst=function(){return s.ast},this.locales=n,this.resolvedLocale=t.resolveLocale(n),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=r||{},a=i.formatters,d=Ra(i,["formatters"]);this.ast=t.__parse(e,se(se({},d),{locale:this.resolvedLocale}))}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=hg(t.formats,o),this.formatters=r&&r.formatters||yg(this.formatterCache)}return Object.defineProperty(t,"defaultLocale",{get:function(){return t.memoizedDefaultLocale||(t.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),t.memoizedDefaultLocale},enumerable:!1,configurable:!0}),t.memoizedDefaultLocale=null,t.resolveLocale=function(e){if(typeof Intl.Locale!="undefined"){var n=Intl.NumberFormat.supportedLocalesOf(e);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof e=="string"?e:e[0])}},t.__parse=Aa,t.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},t})();function Sg(t,e){return e.split(".").reduce((n,o)=>n?n[o]:void 0,t)}var bg="dummy",Qr=vg(null);function R(t){var o;let e=xg(Qr);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let n=(o=t[e])!=null?o:{};return(r,s)=>{let i=Sg(n,r);return i?new Jr(i).format(s):(e!==bg&&console.warn(`${r} does not exist in messages of ${e}`),`[${r}]`)}}import{createAction as Da,createAsyncThunk as _a,createSlice as Tg}from"@reduxjs/toolkit";import{Marked as Cg}from"marked";var xo=(t,e)=>{let n=[],o=new Cg,r=s=>{s.type==="code"&&s.lang===e&&n.push(s.text)};return o.use({walkTokens:r}),o.parse(t),n};var Oa={cues:[],threads:{},pending:[]},Fa=t=>{var e;return(e=t.assistants)==null?void 0:e.cues};var Ha=t=>e=>{var n,o;return(o=(n=e.assistants)==null?void 0:n.threads[t])!=null?o:null},So=Da("assistants/callToAction"),Tn=_a("assistants/evaluateKnowledgeAssistant",(t,e)=>v(null,null,function*(){var l,c,p;let{threadId:n}=t,{onNewThreadId:o}=t,{deepdeskAPI:r}=e.extra,s=e.getState(),{platformVariables:i}=s.info;n||(n=(yield r.createAssistantThread({assistantCode:t.assistantCode})).id,o&&o(n)),yield r.postMessageToAssistantThread({assistantCode:t.assistantCode,threadId:n,message:t.input});let a=yield e.dispatch(be(x(y({skipState:!0},t),{input:{},threadId:n})));if(a.error)throw new Error(a.error.message);let d=(l=a.payload.output[0])!=null?l:{response:"",sources:[]};return{threadId:n,question:t.input,evaluationId:a.payload.evaluationId,answer:{answer:(c=ge(d.response,i!=null?i:{}))!=null?c:"",sources:(p=d.sources)!=null?p:[]}}})),rT=Da("assistants/extractedTextSuggestions");function wg(t,e){var n,o;return Array.isArray(t.output)?t.output:typeof t.output=="string"?[{code:e,name:e,response:t.output}]:[x(y({code:e,name:e},t.output&&typeof t.output=="object"?t.output:{}),{response:(o=(n=t.output)==null?void 0:n.response)!=null?o:""})]}var be=_a("assistants/evaluate",(t,e)=>v(null,null,function*(){var m;let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra,{transcript:r,input:s={},threadId:i}=t,a=e.getState(),{platformVariables:d}=a.info,l=(m=a.conversation.current)==null?void 0:m.externalId,c;if(r==="in-memory-transcript"){if(!o.conversationQuery)throw new Error("Can't include in-memory-transcript, setConversationQuery is not defined");c=yield o.conversationQuery()}else Array.isArray(r)&&(c=r);if(t.includeMetadata){if(!a.conversation.current)throw new Error("Can't include metadata, no current conversation");let{metadata:g}=a.conversation.current;Object.assign(s,{metadata:g})}let p=yield n.evaluateAssistant(t.assistantCode,{input:s,transcript:c,externalConversationId:l,threadId:i});if(p.evaluationStatus!=="success")return e.rejectWithValue(`Assistant ${t.assistantCode} evaluation failed: ${p.evaluationStatus}`);let f=wg(p,t.assistantCode).map(g=>x(y({},g),{name:ge(g.name,d),response:ge(g.response,d)||""})),h=[];return f.forEach(g=>{if(!g.response)return;let b=xo(g.response,"reply");b.length!==0&&h.push(...b.map(T=>({text:T,type:"text",source:"assistant",assistantCode:g.code,sourceLabel:g.name})))}),h.length>0&&e.dispatch(Nt(h)),x(y({},p),{output:f})})),Ba=Tg({name:"assistants",initialState:Oa,reducers:{resetCues(t){t.cues=[]},removeCueByCode(t,e){t.cues=t.cues.filter(n=>n.code!==e.payload.code)},removeThreadById(t,e){delete t.threads[e.payload]},receiveChunk(t,e){let{code:n,name:o,payload:r,evaluationId:s}=e.payload,i=t.cues.findIndex(a=>a.code===n);i!==-1?t.cues[i].response+=r.text:t.cues.push({code:n,name:o,evaluationId:s,response:r.text})},userNotification(t,e){let n=t.cues.filter(d=>d.code!==e.payload.code),{code:o,name:r,evaluationId:s,payload:i}=e.payload,{callToAction:a}=i;t.cues=[...n,{code:o,name:r,evaluationId:s,response:i.message,editable:i.editableMessage,callToAction:a&&{label:a.displayName,event:a.onClickEvent,value:a.eventPayload}}]}},extraReducers:t=>{t.addCase(be.pending,(e,n)=>{e.pending.includes(n.meta.arg.assistantCode)&&E.warn(`Assistant ${n.meta.arg.assistantCode} already evaluating`),e.pending.push(n.meta.arg.assistantCode)}).addCase(be.rejected,(e,n)=>{var r;E.warn((r=n.error)==null?void 0:r.message);let o=e.pending.indexOf(n.meta.arg.assistantCode);o!==-1&&e.pending.splice(o,1)}).addCase(be.fulfilled,(e,n)=>{let o=e.pending.indexOf(n.meta.arg.assistantCode);if(o!==-1&&e.pending.splice(o,1),n.meta.arg.skipState)return;let{evaluationId:r,output:s}=n.payload,i=s.map(l=>l.code),a=e.cues.filter(l=>!i.includes(l.code)),d=s.map(l=>x(y({},l),{evaluationId:r}));e.cues=[...a,...d]}).addCase(Tn.fulfilled,(e,n)=>{let s=n.payload,{threadId:o}=s,r=M(s,["threadId"]);e.threads[o]=[...e.threads[o]||[],r]}).addCase(V,()=>Oa)}}),{removeCueByCode:bo,resetCues:sT,removeThreadById:Ua,receiveChunk:Ka,userNotification:za}=Ba.actions,Wa=Ba.reducer;import{createSlice as Eg}from"@reduxjs/toolkit";import{useSelector as kg}from"react-redux";var Rg={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showImages:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,addToPersonalCollection:!1,inlineSuggestions:!1,autoSelectSuggestion:!1,suggestionsPlacement:"above",floatingMenu:!1,detectSubmit:!1,automaticHandlingTime:!1,enableSuggestionFeedback:!1,enableFeedbackForm:!0,adminUrl:void 0,productName:"Deepdesk",hasKeyboardInput:!0},Va=Eg({name:"settings",initialState:Rg,reducers:{set(t,e){Object.entries(e.payload).forEach(n=>{let[o,r]=n;typeof r!="undefined"&&(t[o]=r)})}}}),{set:Co}=Va.actions,dt=t=>e=>e.settings[t],k=t=>kg(dt(t)),ja=Va.reducer;function Ce(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}import es from"classnames";import{useState as Lg}from"react";import{jsx as $a}from"react/jsx-runtime";var Zr=t=>$a("svg",x(y({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:$a("path",{fillRule:"evenodd",d:"M6.57086468,14.9173453 C6.38997052,14.9711236 6.19835748,15 6,15 L4,15 C2.8954305,15 2,14.1045695 2,13 L2,4 C2,2.8954305 2.8954305,2 4,2 L6,2 C6.68685475,2 7.29284112,2.34623869 7.65294381,2.87370078 C7.95642355,2.67736738 8.29504785,2.51351337 8.66312366,2.3818197 C9.50544052,2.08044754 10.3408482,1.9879107 10.9989281,1.99971266 C11.0150698,2.00005426 13.3487605,2.00015005 18,2 C20.7551411,2 22,6.05643086 22,12 C22,13.6824804 20.8695981,15 19,15 L15.9269768,15 C15.9359266,15.0245465 15.9451954,15.0497804 15.9547911,15.0757271 C16.007193,15.2174219 16.2391583,15.8256341 16.2970775,15.9810953 C16.4872151,16.4914441 16.6259612,16.9026411 16.7382242,17.3098712 C16.9079007,17.9253665 17,18.4798886 17,19 C17,20.4720069 16.091867,21.3862822 14.748281,21.777514 C14.1422801,21.9539723 13.6147967,22.0000922 13.0076976,22.0000008 L12.5204954,22 L12.2202699,21.6261158 C11.2556275,20.4248034 7.64562469,16.4822788 6.57086468,14.9173453 Z M8,13 C8,13.2401953 8.04443154,13.4528921 8.14171093,13.6800176 C8.40663864,14.2985643 11.914268,18.1371493 13.4599624,19.9848695 C13.7113931,19.9660111 13.9483736,19.9273712 14.1891338,19.8572655 C14.7621788,19.6904035 15,19.4509737 15,19 C15,18.6834183 14.9359344,18.2976852 14.8101464,17.8413935 C14.7161494,17.500423 14.5944107,17.1396301 14.4229225,16.6793379 C14.3689242,16.5344009 14.1358033,15.923159 14.0789589,15.7694517 C13.9489218,15.4178313 13.8632547,15.1589343 13.8046536,14.9236885 C13.5555377,13.9236468 13.8054549,13 15,13 L19,13 C19.6912225,13 20,12.6401099 20,12 C20,7.20925475 19.015127,4 18,4 C15.9322103,4 15.9322103,4 10.9655994,3.99940813 C10.5253746,3.99154158 9.91062406,4.05963657 9.33687634,4.2649175 C8.45196659,4.58152894 8,5.09776992 8,6 L8,13 Z M4,4 L4,13 L6,13 L6,4 L4,4 Z"})}));import{jsx as Ga}from"react/jsx-runtime";var qa=t=>Ga("svg",x(y({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Ga("path",{fillRule:"evenodd",d:"M7.65336736,21.1256786 C7.2933164,21.6534897 6.68712411,22 6,22 L4,22 C2.8954305,22 2,21.1045695 2,20 L2,11 C2,9.8954305 2.8954305,9 4,9 L6,9 C6.198171,9 6.38961023,9.02882212 6.57035446,9.08250314 C7.6444817,7.51807482 11.2554748,3.57449216 12.2202699,2.37298955 L12.5204954,1.99910538 L13,1.99910538 C13.6147967,1.99901314 14.1422801,2.04513312 14.748281,2.22159137 C16.091867,2.61282321 17,3.52709845 17,4.99910538 C17,5.51921677 16.9079007,6.07373891 16.7382242,6.68923415 C16.6259612,7.09646424 16.4872151,7.50766133 16.2970775,8.01801005 C16.2391583,8.17347129 16.007193,8.78168345 15.9547911,8.92337824 C15.9451954,8.94932503 15.9359266,8.9745589 15.9269768,8.99910538 L19,8.99910538 C20.8695981,8.99910538 22,10.316625 22,11.9991054 C22,17.9426745 20.7551411,21.9991054 18,21.9991054 L11.0344006,21.9985135 C10.3408482,22.0111947 9.50544052,21.9186578 8.66312366,21.6172857 C8.29521907,21.4856533 7.9567386,21.3218904 7.65336736,21.1256786 Z M8,17.9991054 C8,18.9013355 8.45196659,19.4175764 9.33687634,19.7341879 C9.91062406,19.9394688 10.5253746,20.0075638 10.963066,19.9997143 C10.9703499,19.9995545 10.9703499,19.9995545 11,19.9991054 L18,19.9991054 C19.015127,19.9991054 20,16.7898506 20,11.9991054 C20,11.3589955 19.6912225,10.9991054 19,10.9991054 L15,10.9991054 C13.8054549,10.9991054 13.5555377,10.0754586 13.8046536,9.07541689 C13.8632547,8.84017106 13.9489218,8.5812741 14.0789589,8.22965366 C14.1358033,8.07594642 14.3689242,7.46470447 14.4229225,7.31976744 C14.5944107,6.85947528 14.7161494,6.4986824 14.8101464,6.1577119 C14.9359344,5.70142019 15,5.31568707 15,4.99910538 C15,4.54813166 14.7621788,4.30870189 14.1891338,4.1418399 C13.9483736,4.07173418 13.7113931,4.0330943 13.4599624,4.01423587 C11.914268,5.86195611 8.40663864,9.70054105 8.14171093,10.3190878 C8.04443154,10.5462133 8,10.7589101 8,10.9991054 L8,17.9991054 Z M4,11 L4,20 L6,20 L6,11 L4,11 Z"})}));function qe(t,e){var r;let n=t.cloneNode(!0);n.style.top=`${t.offsetTop}px`,n.style.left=`${t.offsetLeft}px`,n.style.position="absolute",e.split(" ").forEach(s=>{n.classList.add(s)}),n.addEventListener("animationend",()=>n.remove()),(r=t.parentElement)==null||r.appendChild(n)}var Yr={};X(Yr,{enUS:()=>Pg,nlNL:()=>Ig});var Pg={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},Ig={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var Xa={thumbs:"dd-5F1zq",fadeup:"dd-eTmY-",fadedown:"dd-sS85z",selected:"dd-rid-f",thumbsUp:"dd-4poEf",thumbsDown:"dd-3KozS"};import{useSelector as Ja}from"react-redux";var Xe=t=>e=>{let{passwordlessToken:{token:n},settings:{isEmbedded:o,adminUrl:r}}=e,s=r||window.location.origin;return o&&!n?null:o&&n?`${s}/apis/admin/session/passwordless/login/?token=${n}&redirect=${encodeURIComponent(t)}`:`${s}${t}`};import{jsx as Ft,jsxs as Mg}from"react/jsx-runtime";var Ag=({assistantCode:t,assistantOutput:e,evaluationId:n,feedbackType:o,feedbackText:r})=>{let s=S("FeedbackThumbs",Xa),i=k("enableFeedbackForm"),a=Ja(Se),d=Ja(Xe(`/admin/feedback?conversationId=${a}&evaluationId=${n}&type=${o}&text=${r}&assistantCode=${t}&assistantOutput=${e}`)),l=R(Yr),c=K(),[p,u]=Lg(null),f=g=>{c("Assistant response feedback",{assistantCode:t,assistantOutput:e,evaluationId:n,rating:g})},h=g=>{g.stopPropagation(),qe(g.target,s.fadeup),u("up"),f("up")},m=g=>{g.stopPropagation(),qe(g.target,s.fadedown),u("down"),f("down")};return Mg("div",{className:s.thumbs,children:[Ft(I.Button,{title:l("thumbsUp"),onClick:h,icon:Ft(qa,{}),className:es(s.thumbsUp,p==="up"&&s.selected),disabled:!!p}),i&&d?Ft(I.Button,{as:"a",title:l("thumbsDown"),href:d,target:"_blank",rel:"noreferrer",onClick:m,icon:Ft(Zr,{}),className:es(s.thumbsDown,p==="down"&&s.selected),disabled:!!p}):Ft(I.Button,{title:l("thumbsDown"),onClick:m,icon:Ft(Zr,{}),className:es(s.thumbsDown,p==="down"&&s.selected),disabled:!!p})]})},To=Ag;import Gg from"dompurify";import{Fragment as ol,useMemo as qg,useRef as Xg,useState as Jg}from"react";import tl from"classnames";import{createRef as Wg,useCallback as ns,useMemo as Vg,useRef as jg,useState as $g}from"react";import{useState as Ng,useLayoutEffect as Og}from"react";var Dg=["bottom","height","left","right","top","width"],_g=(t={},e={})=>Dg.some(n=>t[n]!==e[n]),Oe=new Map,Qa,Za=()=>{let t=[],e=[];Oe.forEach((n,o)=>{if(o instanceof Element&&!o.isConnected){e.push(o);return}let r=o.getBoundingClientRect();_g(r,n.rect)&&(n.rect=r,t.push(n))}),e.forEach(n=>{Oe.delete(n)}),t.forEach(n=>{n.callbacks.forEach(o=>o(n.rect))}),Qa=window.requestAnimationFrame(Za)};function Fg(t,e){return{observe(){let n=Oe.size===0;if(Oe.has(t)){let o=Oe.get(t);o.callbacks.push(e),o.rect&&e(o.rect)}else Oe.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});n&&Za()},unobserve(){let n=Oe.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||Oe.delete(t),Oe.size||cancelAnimationFrame(Qa)}}}}function ts(t){let[e,n]=Ng(null);return Og(()=>{if(!t.current)return;let o=Fg(t.current,r=>{n(r)});return o.observe(),()=>{o.unobserve()}},[t]),e}import{useContext as Bg,useLayoutEffect as Ug,useState as Kg}from"react";import{createPortal as zg}from"react-dom";import{useEffect as Hg}from"react";function ct(t){Hg(()=>{let e=n=>{n.isWithinRoot||t(n)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function ut(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var Ya={root:"dd-r-dgo"};var el=({children:t,parentNode:e})=>{let[n,o]=Kg(null),r=Bg(rn);return Ug(()=>{let s=document.createElement("div");return ut(s),s.classList.add(Ya.root),r!=null&&r.portalRootNode&&s.classList.add(r==null?void 0:r.portalRootNode),(e||document.body).appendChild(s),o(s),()=>{s.isConnected&&s.remove()}},[]),n?zg(t,n):null};var Te={ref:"dd-iz-KP",root:"dd-vEMon",positionAbove:"dd-mUCxM",positionBelow:"dd-7oZI7",positionLeft:"dd-BiWvD",positionRight:"dd-JIWea",alignStart:"dd-5ivu6",alignCenter:"dd-rnVkP",alignEnd:"dd-gZBp4"};import{jsx as os}from"react/jsx-runtime";var wo=(t=!1)=>{let[e,n]=$g(t),o=ns(()=>n(!0),[]),r=ns(()=>n(!1),[]),s=ns(()=>n(a=>!a),[]),i=jg(null);return{opened:e,open:o,close:r,toggle:s,triggerRef:i}};function rs(t,e=null,n=0){if(!t)return{display:"none"};let o=e?t.top-e.top<0||t.top<e.top-n?e.top-n:t.top+t.height>e.top+e.height+n?e.top+e.height+n-t.height:t.top:t.top,r=e?t.left<e.left-n?e.left-n:t.left+t.width>e.left+e.width+n?e.left+e.width+n-t.width:t.left:t.left;return{top:o,left:r,height:t.height,width:t.width}}var Ht=l=>{var c=l,{className:t,triggerRef:e,boundaryRef:n=Wg(),position:o="above",align:r="center",children:s,toStyle:i=rs,parentNode:a}=c,d=M(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let p=ts(e),u=ts(n),f=Vg(()=>i(p,u,0),[p,u]);return os(el,{parentNode:a,children:os("div",x(y({className:tl(Te.ref,{[Te.positionAbove]:o==="above",[Te.positionBelow]:o==="below",[Te.positionLeft]:o==="left",[Te.positionRight]:o==="right",[Te.alignStart]:r==="start",[Te.alignCenter]:r==="center",[Te.alignEnd]:r==="end"}),style:f},d),{role:"dialog",children:os("div",{className:tl(t,Te.root),children:s})}))})};var nl={root:"dd-L7b3z",popover:"dd-OQOTB",options:"dd-Y12RE",arrow:"dd-cv33T",copyIcon:"dd-6xOsH",option:"dd-9oFX4",divider:"dd-aiZf8",fadeup:"dd-Jq9pd"};import{marked as Qg}from"marked";import{jsx as wn,jsxs as Eo}from"react/jsx-runtime";function Zg(t){return`<button type="button" data-copy-icon class=${t}><svg version="1.1" x="0px" y="0px" viewBox="0 0 115.77 122.88" width="10px" height="10px" fill="black"><g><path d="M89.62,13.96v7.73h12.19h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02v0.02 v73.27v0.01h-0.02c-0.01,3.84-1.57,7.33-4.1,9.86c-2.51,2.5-5.98,4.06-9.82,4.07v0.02h-0.02h-61.7H40.1v-0.02 c-3.84-0.01-7.34-1.57-9.86-4.1c-2.5-2.51-4.06-5.98-4.07-9.82h-0.02v-0.02V92.51H13.96h-0.01v-0.02c-3.84-0.01-7.34-1.57-9.86-4.1 c-2.5-2.51-4.06-5.98-4.07-9.82H0v-0.02V13.96v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07V0h0.02h61.7 h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02V13.96L89.62,13.96z M79.04,21.69v-7.73v-0.02h0.02 c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v64.59v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h12.19V35.65 v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07v-0.02h0.02H79.04L79.04,21.69z M105.18,108.92V35.65v-0.02 h0.02c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v73.27v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h61.7h0.02 v0.02c0.91,0,1.75-0.39,2.37-1.01c0.61-0.61,1-1.46,1-2.37h-0.02V108.92L105.18,108.92z"/></g></svg></button>`}function ss(t){var n,o;let e=t.cloneNode(!0);return e.querySelectorAll("div,button").forEach(r=>r.remove()),(o=(n=e.textContent)==null?void 0:n.trim())!=null?o:""}function Yg(t){return t.replace(/\r\n/g,`
4
+ `)}var em=({content:t,useLabel:e,copyLabel:n,onCopy:o,onUse:r})=>{let s=S("Markdown",nl),i=Xg(null),[a,d]=Jg(null),l=qg(()=>{let m=Qg.parse(Yg(t));return Gg.sanitize(m.toString()).replaceAll("</code>",`${Zg(s.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[t]),c=m=>{var T;let g=m.target,b=!!((T=i.current)!=null&&T.querySelector("code"));if(["A","BUTTON"].includes(g.tagName)){d(null);return}a||b&&g.tagName!=="CODE"||!b&&g!==i.current||(g.addEventListener("mouseleave",()=>d(null),{once:!0}),d(g))},p=()=>{if(!a)return;d(null);let m=a.querySelector("button");m&&(qe(m,s.fadeup),o==null||o(ss(a)))},u=m=>{let g=m.target,b=g instanceof HTMLElement?g:null;if(g instanceof Element?g.closest("a"):null){m.stopPropagation();return}b&&"copyIcon"in b.dataset&&(qe(b,s.fadeup),o==null||o(ss(b.parentElement)))},f=()=>{!a||!r||(d(null),r(ss(a)))},h=m=>{if(m===null)return;let g=m.getBoundingClientRect();g.left<0?m.style.transform=`translateX(${-g.left+2}px)`:g.right>window.innerWidth&&(m.style.transform=`translateX(${window.innerWidth-g.right-2}px)`)};return Eo(ol,{children:[a&&(o||r)&&Eo(Ht,{triggerRef:{current:a},className:s.popover,parentNode:a,children:[Eo("div",{className:s.options,ref:h,children:[o&&(a==null?void 0:a.tagName)==="CODE"&&wn("button",{type:"button",className:s.option,onClick:p,children:n}),r&&Eo(ol,{children:[wn("div",{className:s.divider}),wn("button",{type:"button",className:s.option,onClick:f,children:e})]})]}),wn("div",{className:s.arrow})]}),wn("div",{ref:i,"data-testid":"widget-markdown-content",className:s.root,dangerouslySetInnerHTML:{__html:l},onMouseOver:c,onClick:u})]})},pt=em;import{useRef as om}from"react";var rl={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};import{jsx as nm}from"react/jsx-runtime";var tm=({width:t})=>{let e=S("LoadingProgressBar",rl);return nm("div",{className:e.loadingBar,style:{width:t}})},ko=tm;import{jsx as Bt,jsxs as rm}from"react/jsx-runtime";var Ro=({title:t})=>{let e=om(null);return Gn(e),Bt(I,{ref:e,children:Bt(D,{children:rm(D.Content,{children:[Bt(D.Title,{children:t}),Bt(ko,{width:"60%"}),Bt(ko,{width:"90%"}),Bt(ko,{width:"50%"})]})})})};var Ut={};X(Ut,{enUS:()=>sm,nlNL:()=>im});var sm={inputPlaceholder:[{type:0,value:"What is your question?"}],useCue:[{type:0,value:"Add to message"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Submit"}],resetLabel:[{type:0,value:"Reset"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},im={inputPlaceholder:[{type:0,value:"Wat is je vraag?"}],useCue:[{type:0,value:"Voeg toe aan bericht"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Verzend"}],resetLabel:[{type:0,value:"Gesprek wissen"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var Po={form:"dd-pleCH",formInput:"dd-pGJMY",formSubmit:"dd--gkRg",actionButton:"dd-I2NEH",resetContainer:"dd-qKIDX",sources:"dd-xf9c6",source:"dd-a-vyX",tooltip:"dd-EsgcZ",linkContent:"dd-gARDA",showMoreSources:"dd-uDGi-"};import*as we from"react";import{useFloating as am,autoUpdate as lm,useClick as dm,useDismiss as cm,useRole as um,useInteractions as pm,useMergeRefs as il,FloatingPortal as gm,FloatingFocusManager as mm,useHover as fm,offset as hm,flip as ym,shift as vm,safePolygon as xm}from"@floating-ui/react";var Io={tooltip:"dd-XpCXd",tooltipTrigger:"dd-8TKeF",arrow:"dd-ZEu2Y"};import{jsx as Je,jsxs as sl}from"react/jsx-runtime";function Sm({initialOpen:t=!1,placement:e="bottom",modal:n,tooltip:o,open:r,onOpenChange:s}={}){let[i,a]=we.useState(t),d=r!=null?r:i,l=s!=null?s:a,c=am({placement:e,open:d,onOpenChange:l,whileElementsMounted:lm,middleware:[hm(5),ym({crossAxis:e.includes("-"),fallbackAxisSideDirection:"end",padding:5}),vm({padding:10})]}),p=c.context,u=dm(p,{enabled:r==null}),f=cm(p),h=um(p),m=fm(p,{enabled:o!=null?o:!1,handleClose:xm()}),g=pm([u,f,h,m]);return we.useMemo(()=>x(y(y({open:d,setOpen:l},g),c),{modal:n}),[d,l,g,c,n])}var al=we.createContext(null),is=()=>{let t=we.useContext(al);if(t==null)throw new Error("Popover components must be wrapped in <Popover />");return t},gt=o=>{var r=o,{children:t,modal:e=!1}=r,n=M(r,["children","modal"]);let s=Sm(y({modal:e},n));return Je(al.Provider,{value:s,children:t})};function bm(o){var r=o,{as:t,children:e}=r,n=M(r,["as","children"]);let s=is(),i=t||"button",a=e.ref,d=il([s.refs.setReference,a]);return Je(i,x(y({ref:d,type:"button"},s.getReferenceProps(n)),{children:e}))}var Cm=we.forwardRef(function(r,o){var s=r,{style:e}=s,n=M(s,["style"]);let l=is(),{context:i}=l,a=M(l,["context"]),d=il([a.refs.setFloating,o]);return i.open?Je(gm,{children:Je(mm,{context:i,modal:a.modal,disabled:n.disableFocusManager,children:Je("div",x(y({ref:d,style:y(x(y({},a.floatingStyles),{zIndex:1e7}),e)},a.getFloatingProps(n)),{children:n.children}))})}):null});function Tm(r){var s=r,{as:t,children:e,onClick:n}=s,o=M(s,["as","children","onClick"]);let{setOpen:i}=is();return Je(t||"button",x(y({type:"button",onClick:l=>{n(l),i(!1),l.stopPropagation()}},o),{children:e}))}function ll({trigger:t,children:e,placement:n="top"}){return sl(gt,{tooltip:!0,placement:n,children:[sl(gt.Content,{className:Io.tooltip,children:[e,Je("div",{className:Io.arrow})]}),Je(gt.Trigger,{className:Io.tooltipTrigger,children:t})]})}gt.Trigger=bm;gt.Content=Cm;gt.Button=Tm;var $=gt;import{useRef as km}from"react";var dl={error:"dd-CoAuB"};var as={};X(as,{enUS:()=>wm,nlNL:()=>Em});var wm={errorPrefix:[{type:0,value:"Error:"}]},Em={errorPrefix:[{type:0,value:"Foutmelding:"}]};import{jsx as cl,jsxs as Rm}from"react/jsx-runtime";var ul=({message:t})=>{let e=km(null),n=S("WidgetCardError",dl),o=R(as);return Gn(e),cl(I,{ref:e,children:cl(D,{children:Rm(D.Content,{className:n.error,children:[o("errorPrefix")," ",t]})})})};import{jsx as H,jsxs as De}from"react/jsx-runtime";var Nm=3,Om=({sources:t,onClick:e})=>{let n=R(Ut),o=S("WidgetKnowledgeAssistant",Po),[r,s]=mt(!1),i=r?t:t.slice(0,Nm);return i.length===0?null:De("ul",{className:o.sources,children:[i.map(a=>H("li",{className:o.source,"data-testid":"knowledge-assist-source",children:De($,{tooltip:!0,placement:"top-start",children:[H($.Trigger,{as:"a",rel:"noreferrer",target:"_blank",href:a.url,onClick:d=>{d.stopPropagation(),e(a)},children:H("span",{className:o.linkContent,children:a.name})}),a.url&&H($.Content,{className:o.tooltip,children:decodeURIComponent(a.url)})]})},a.name)),i<t&&H("button",{type:"button",className:o.showMoreSources,onClick:()=>s(!0),children:n("showMore",{amount:t.length-i.length})})]})},Dm=({title:t,description:e})=>H(I,{"data-testid":"knowledge-assist-empty-state",children:H(D,{children:De(D.Content,{children:[H(D.Title,{children:t}),H(pt,{content:e})]})})}),_m=({innerRef:t,item:e,hasKeyboardInput:n,onCopy:o,onUse:r,onSourceClick:s})=>{var d;let i=R(Ut),a=ls(Lo);return De(I,{"data-testid":"knowledge-assist-answer",ref:t,children:[H(D,{children:De(D.Content,{children:[H(D.Title,{children:e.question}),H(pt,{content:e.answer.answer,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:o,onUse:n?r:void 0}),H(Om,{sources:(d=e.answer.sources)!=null?d:[],onClick:s})]})}),a.assistantCode&&De(I.ButtonsContainer,{children:[H("div",{}),H(To,{evaluationId:e.evaluationId,feedbackType:"assistant",assistantCode:a.assistantCode,assistantOutput:e.answer.answer,feedbackText:e.answer.answer})]})]})},Lo=Pm(null),Ao=({assistantCode:t,evaluateKnowledgeAssistFn:e,initialQuestion:n,children:o})=>{let[r,s]=mt(null),[i,a]=mt(!1),[d,l]=mt(null),[c,p]=mt(!!n),[u,f]=mt(null),h=Am(),m=K(),g=uo(C=>{if(!t)throw new Error("No knowledge assistant was defined");return l(null),e({assistantCode:t,input:C,threadId:r,onNewThreadId(w){s(w)}})},{onSuccess(C){var w;m("Assistant response displayed",{evaluationId:C.evaluationId,assistantCode:t,assistantOutput:C.answer.answer,input:C.question,sources:(w=C.answer.sources)!=null?w:[]}),p(!1)},onError(C){var w;l((w=C.message)!=null?w:"Unknown error")}}),b=C=>v(null,null,function*(){a(!0),f(C),yield g.call(C),a(!1),f(null)}),T={isEnabled:!!t,assistantCode:t,isSubmitting:i,threadId:r,pendingInput:u,errorMessage:d,onSubmit:b,onReset(){r&&h(Ua(r)),l(null),s(null),t&&m("Assistant thread reset",{threadId:r!=null?r:void 0,assistantCode:t})}};return Lm(()=>{n&&T.isEnabled&&b(n)},[n]),H(Lo.Provider,{value:T,children:o})},Mo=()=>{let t=R(Ut),e=S("WidgetKnowledgeAssistant",Po),n=ls(Lo),o=pl(null),[r,s]=mt(""),i=d=>{s(d.target.value)},a=d=>{d.preventDefault(),n.onSubmit(r).then(()=>{var l;o.current&&((l=o.current)==null||l.focus(),s(""))})};return n.isEnabled?De("form",{className:e.form,onSubmit:a,children:[H("input",{ref:o,className:e.formInput,placeholder:t("inputPlaceholder"),type:"text",disabled:n.isSubmitting,value:r,onChange:i}),H("button",{type:"submit",disabled:n.isSubmitting||r==="",className:e.formSubmit,children:t("submitLabel")})]}):null},No=({title:t,emptyState:e})=>{var h,m;let n=R(Ut),o=K(),r=S("WidgetKnowledgeAssistant",Po),s=pl(null),i=ls(Lo),a=(m=Mm(Ha((h=i.threadId)!=null?h:-1)))!=null?m:[],d=k("hasKeyboardInput"),l=ne(),c=(g,b)=>{Ce(g),i.assistantCode&&o("Assistant response copied",{assistantCode:i.assistantCode,assistantOutput:g,copiedText:g,evaluationId:b.evaluationId})},p=(g,b)=>{i.assistantCode&&o("Assistant source clicked",{evaluationId:b.evaluationId,assistantCode:i.assistantCode,source:g})},u=g=>{g.preventDefault(),i.onReset()},f=(g,b)=>{l.send(Me,{text:g,suggestion:{source:"assistant",sourceText:g}}),i.assistantCode&&o("Assistant response used",{assistantCode:i.assistantCode,evaluationId:b.evaluationId,assistantOutput:b.answer.answer,usedText:g})};return!i.isEnabled||(a==null?void 0:a.length)===0&&!i.isSubmitting&&!e&&!i.errorMessage?null:De(Im,{children:[H(Le,{type:"knowledge",title:t,"data-testid":"knowledge",children:De(te,{withDivider:!0,children:[e&&a.length===0&&!i.pendingInput&&H(Dm,y({},e)),a.map((g,b)=>H(_m,{innerRef:b===a.length-1?s:void 0,item:g,hasKeyboardInput:d,onCopy:T=>c(T,g),onUse:T=>f(T,g),onSourceClick:T=>p(T,g)},`${g.question}_${g.answer}_${b}`)),i.pendingInput&&H(Ro,{title:i.pendingInput}),i.errorMessage&&H(ul,{message:i.errorMessage})]})}),a.length>0&&H("div",{className:r.resetContainer,children:H(I.Button,{disabled:i.threadId===null||i.isSubmitting,onClick:u,children:n("resetLabel")})})]})};import{createRoot as tt}from"react-dom/client";import{Fragment as kh}from"react";import{useSelector as Sl}from"react-redux";import cs from"classnames";import{useCallback as vl,useEffect as jm,useMemo as $m,useState as us}from"react";import{useDispatch as Gm,useSelector as qm}from"react-redux";import{useEffect as Fm,useRef as Hm}from"react";var ml={root:"dd-tvkOF",content:"dd-eXA1D"};import{jsx as fl}from"react/jsx-runtime";var Bm=({isOpen:t,autoFocus:e,children:n,onClose:o,onBack:r,onKeyDown:s,overlayAriaLabel:i,contentAriaLabel:a})=>{let d=Hm(null),l=S("Dialog",ml),c=u=>{if(u.key==="Escape"){u.preventDefault(),u.stopPropagation(),r();return}s&&s(u)},p=u=>{u.target===d.current&&t&&o()};return Fm(()=>{var u,f;!d.current||!t||!e||(f=(u=d.current)==null?void 0:u.querySelector("input, textarea"))==null||f.focus()},[t,e,d]),t?fl("div",{role:"dialog","data-testid":"dialog",className:l.root,"aria-label":i,ref:d,onKeyDown:c,onMouseDown:p,children:fl("div",{"data-testid":"dialog-content",className:l.content,"aria-label":a,children:n})}):null},Kt=Bm;import Um from"classnames";var hl={root:"dd-ranhW"};import{jsx as zm}from"react/jsx-runtime";var Km=o=>{var r=o,{className:t,value:e}=r,n=M(r,["className","value"]);let s=S("TextInput",hl);return zm("input",y({className:Um(t,s.root),type:"text",value:e},n))},En=Km;var ds={};X(ds,{enUS:()=>Wm,nlNL:()=>Vm});var Wm={back:[{type:0,value:"Back"}],promptTitle:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Paste the code from your email"}],verifyCodeBody:[{type:0,value:"Copy the code from the email you just received and paste it here."}],verifyCodeInputPlaceholder:[{type:0,value:"Paste link or code here"}],verifyCodeSubmitLabel:[{type:0,value:"Sign in"}],verifyCodeError:[{type:0,value:"Sign in failed. The code is probably no longer valid. Please "},{type:8,value:"login",children:[{type:0,value:"request new code"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Have a code sent to your email"}],requestCodeBody:[{type:0,value:"Enter your email and request a code. If you are an existing "},{type:1,value:"productName"},{type:0,value:" user you will receive an email with a code. If you are a new user you will receive an email asking to request access to "},{type:1,value:"productName"},{type:0,value:" first."}],requestCodeInputPlaceholder:[{type:0,value:"Enter your email"}],requestCodeSubmitLabel:[{type:0,value:"Request code"}]},Vm={back:[{type:0,value:"Terug"}],promptTitle:[{type:0,value:"Login bij "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Plak de code uit je email"}],verifyCodeBody:[{type:0,value:"Kopieer de code uit de email en plak deze hier."}],verifyCodeInputPlaceholder:[{type:0,value:"Plak hier de code"}],verifyCodeSubmitLabel:[{type:0,value:"Inloggen"}],verifyCodeError:[{type:0,value:"Inloggen is niet gelukt. De code is waarschijnlijk niet meer geldig. "},{type:8,value:"login",children:[{type:0,value:"Vraag een nieuwe code aan"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Verstuur een login code naar je email"}],requestCodeBody:[{type:0,value:"Voer je e-mailadres in en krijg een login code. Als je een bestaande "},{type:1,value:"productName"},{type:0,value:" gebruiker bent krijg je een email met een code. Als je een nieuwe gebruiker bent wordt er een email verstuurd met een toegangsverzoek voor "},{type:1,value:"productName"},{type:0,value:"."}],requestCodeInputPlaceholder:[{type:0,value:"Typ hier je e-mailadres"}],requestCodeSubmitLabel:[{type:0,value:"Code aanvragen"}]};var yl={root:"dd-lWxnE",anchorButton:"dd-TZ4in",errorMessage:"dd-fIsPg",title:"dd-pGhJx",subtitle:"dd-f5l29",text:"dd-iamoD",input:"dd-uhQZ3",actions:"dd-lubvx",button:"dd-CJsNI",primaryButton:"dd-MWBfl"};import{jsx as oe,jsxs as Oo}from"react/jsx-runtime";var Xm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch(e){return t}},Jm=({agentEmail:t,isOpen:e,origin:n="",onSuccess:o,onDismiss:r})=>{let s=R(ds),i=S("LoginTokenDialog",yl),a=qm(_i),d=Gm(),l=k("productName"),[c,p]=us(t||""),[u,f]=us(0),[h,m]=us(""),g=vl(w=>v(null,null,function*(){w.preventDefault(),d(Bi({email:c})),f(1)}),[n,c]),b=()=>{m(""),f(0)},T=vl(w=>v(null,null,function*(){w.preventDefault();let L=Xm(w.target.elements.token.value);if(!L){m(s("verifyCodeError",{login:C}));return}d(ln({token:L}))}),[n]),C=$m(()=>w=>oe("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:b,children:w},"back-button"),[]);return jm(()=>{a==="error"&&m(s("verifyCodeError",{login:C})),a==="done"&&o()},[a]),oe(Kt,{autoFocus:!0,isOpen:e,contentAriaLabel:s("promptTitle",{productName:l}),overlayAriaLabel:s("promptTitle",{productName:l}),onClose:r,onBack:r,children:Oo("div",{className:i.root,children:[oe("h1",{className:i.title,children:s("promptTitle",{productName:l})}),u===0&&Oo("form",{onSubmit:g,children:[oe("h2",{className:i.subtitle,children:s("requestCodeTitle")}),oe("p",{className:i.text,children:s("requestCodeBody",{productName:l})}),oe(En,{className:i.input,name:"email",placeholder:s("requestCodeInputPlaceholder"),value:c,onChange:w=>p(w.target.value)}),oe("div",{className:i.actions,children:oe("button",{type:"submit",className:cs(i.button,i.primaryButton),children:s("requestCodeSubmitLabel")})})]}),u===1&&Oo("form",{onSubmit:T,children:[oe("h2",{className:i.subtitle,children:s("verifyCodeTitle")}),oe("p",{className:i.text,children:s("verifyCodeBody")}),oe(En,{className:i.input,name:"token",placeholder:s("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),h&&oe("div",{className:i.errorMessage,children:h}),Oo("div",{className:i.actions,children:[oe("button",{type:"button",className:cs(i.button),onClick:b,children:s("back")}),oe("button",{type:"submit",className:cs(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:s("verifyCodeSubmitLabel")})]})]})]})})},xl=Jm;import{jsx as Zm}from"react/jsx-runtime";var Qm=()=>{let t=Sl(Fi),e=Sl(Ot),n=k("adminUrl"),o=ne(),r=()=>o.send(_t,!1),s=()=>{o.send(_t,!1),o.send(pn)};return Zm(xl,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:n,onDismiss:r,onSuccess:s})},bl=Qm;import yh from"lodash.debounce";import{Fragment as vh,useCallback as pd,useEffect as gd,useMemo as xh,useState as ws}from"react";import{useDispatch as Sh,useSelector as yt}from"react-redux";import{createAsyncThunk as Ym,createSlice as ef}from"@reduxjs/toolkit";var tf={data:null,fetchState:"idle"},Cl=t=>t.contentTypes.data,kn=Ym("contentTypes/getContentTypes",(t,e)=>v(null,null,function*(){return e.extra.deepdeskAPI.getContentTypes()})),nf=ef({name:"contentTypes",initialState:tf,reducers:{},extraReducers:t=>{t.addCase(kn.pending,e=>{e.fetchState="loading"}).addCase(kn.rejected,e=>{e.fetchState="error"}).addCase(kn.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),Tl=nf.reducer;import{createAsyncThunk as of,createSelector as rf,createSlice as sf}from"@reduxjs/toolkit";var af={data:null,fetchState:"idle"},lf=[],ft=t=>t.profile.data,df=t=>t.profile.data?t.profile.data.uiConfig.widget.types:lf,Pn=rf([df],t=>t.filter(e=>e.isActive)),wl=t=>{var e;return((e=t.profile.data)==null?void 0:e.onDemandAssistants)||[]},El=t=>e=>Pn(e).find(n=>n.type===t),kl=t=>t.profile.data?!!t.profile.data.uiConfig.widget.types.find(e=>e.type==="custom-data"):!1,Rl=t=>{var e,n;return(n=(e=t.profile.data)==null?void 0:e.knowledgeAssistantNew)!=null?n:null},Rn=of("profile/getProfile",(t,e)=>v(null,null,function*(){var s;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=o.conversation.current;if(!r||!r.profileCode)throw new Error("No conversation of conversation profileCode found");return((s=o.profile.data)==null?void 0:s.code)===r.profileCode?o.profile.data:n.getProfile(r.profileCode)})),cf=sf({name:"profile",initialState:af,reducers:{},extraReducers:t=>{t.addCase(Rn.pending,e=>{e.fetchState="loading"}).addCase(Rn.rejected,e=>{e.fetchState="error"}).addCase(Rn.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),Pl=cf.reducer;import{useEffect as $l,useState as _f,useRef as Ff,useCallback as Hf}from"react";import{useState as gf}from"react";import ps from"classnames";var ie={root:"dd-U2SX4",list:"dd-cYTlj",listWrapper:"dd-GLQFR",listHorizontal:"dd-x-knl",page:"dd-1F4vk",search:"dd-nvbxc",pageNav:"dd-sRUuT",pageTitle:"dd-t-MKS",pageBackButton:"dd-cjptm",listHeader:"dd-Fg666",listHeading:"dd-w-xhJ",listMoreButton:"dd--mKep",listItem:"dd-wpvuA",listItemContent:"dd-V-mKo",listItemText:"dd-ukCHL",listItemDescription:"dd-sSyu4",listItemActions:"dd-xelho",listItemTooltip:"dd-SWFsE",listItemTooltipContent:"dd-I7J9N",truncate:"dd-IlopJ",lineClamp:"dd-Twaca",listItemTitle:"dd-lMGHq",listItemAction:"dd-xPLAs",listItemSelected:"dd-jFX0Y",sources:"dd-pZx4v",sourcesTitle:"dd-phYVd",source:"dd-DaR6h",sourceShowMore:"dd-M1-8j",icon:"dd-m6yxD",searchIcon:"dd-0AU-O",searchInputWrapper:"dd-DUFcE",searchInput:"dd-ukrlD",select:"dd--Tifv",selectType:"dd-IkZb2",selectWrapper:"dd-J14mx",image:"dd-RQgsB",imageSrc:"dd-jxh8F",imageSrcHidden:"dd-e20Jk",imageSrcStatus:"dd-j50Tt",imageTitle:"dd-qCjfW",actions:"dd-3mfWc",actionsWrapper:"dd-TjDyI",actionsBar:"dd-LiA35",actionButton:"dd-4wk0u",hasShortKeys:"dd-XilV-",actionShortcut:"dd-s4Mla",actionShortcutFixKerning:"dd-lyh5e"};var _e={};X(_e,{enUS:()=>uf,nlNL:()=>pf});var uf={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}],showAll:[{type:0,value:"Show more"}],sources:[{type:0,value:"Sources"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},pf={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}],showAll:[{type:0,value:"Toon meer"}],sources:[{type:0,value:"Bronnen"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};import{jsx as In,jsxs as ff}from"react/jsx-runtime";var mf=({src:t,title:e})=>{let n=S("CommandPalette",ie),[o,r]=gf("loading"),s=R(_e);return ff("div",{className:n.image,children:[In("img",{src:t,alt:e,onLoad:()=>r("done"),onError:()=>r("error"),className:ps(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(o)})}),o==="loading"&&In("span",{className:ps(n.imageSrc,n.imageSrcStatus),children:s("loading")}),o==="error"&&In("span",{className:ps(n.imageSrc,n.imageSrcStatus),children:In(Vn,{})}),e&&In("span",{className:n.imageTitle,children:e})]})},Il=mf;import hf from"react";import yf from"classnames";import{jsx as gs,jsxs as Ll}from"react/jsx-runtime";function ms({children:t,heading:e,orientation:n,hasMore:o,onShowAll:r}){let s=R(_e),i=S("CommandPalette",ie);return hf.Children.count(t)===0?null:Ll("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||o)&&Ll("div",{className:i.listHeader,children:[e&&gs("h4",{className:i.listHeading,children:e}),o&&r&&gs("button",{onClick:r,className:i.listMoreButton,type:"button",children:s("showAll")})]}),gs("div",{className:yf(i.listWrapper,n==="horizontal"&&i.listHorizontal),children:t})]})}import _o from"classnames";import{Interweave as Dl}from"interweave";import{useEffect as kf,useMemo as _l,useState as Fl}from"react";var vf=/[.*+?^${}()|[\]\\]/g,xf=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function Sf(t){return t.replace(vf,"\\$&")}function bf(t,e){let n=t.split("").findIndex((o,r)=>o!==e[r]);return n>-1?n:Math.min(t.length,e.length)}function Cf(t){return t.search(xf)}function Al(t,e=[]){let n=t;return e.forEach(o=>{if(!o)return;let r=new RegExp(`\\b(${Sf(o)})\\b`,"gi");n=n.replace(r,"<strong>$1</strong>")}),n}function Ml(t){return t.replace(qn,'<mark data-type="placeholder">$1</mark>')}function Ln(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Tf(t,e){return t.split("").map((i,a)=>({char:i,index:a})).filter(({char:i,index:a})=>/\s/.test(i)&&a<=e).map(({index:i})=>i).reverse()[0]}function fs(t,e,n={}){if(e){let o=bf(e.toLowerCase(),t.toLowerCase()),r=Ln(t.substring(o,t.length));if(n.stripAgentPart){let d=t.substring(0,o),l=Cf(d);return`<span style="opacity: 0.5">${d.substring(l+1)}</span>${r}`}let i=e.split(Ni).length>3||e.length>30?Tf(e.trim(),o):0;return`${`${i>0?"\u2026":""}${Ln(t.substring(i,o))}`}<strong>${r}</strong>`}return t}var wf=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function Do(t){return wf.test(t)}function hs(t){var n;let e=document.createElement("template");return e.innerHTML=t,(n=e.content.textContent)!=null?n:""}import ys from"react";import{jsx as Ef}from"react/jsx-runtime";var Nl=ys.createContext(void 0);function zt(){let t=ys.useContext(Nl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Ol=({children:t,page:e,isOpen:n,onChangeOpen:o,selected:r,setSelected:s})=>{let i=ys.useMemo(()=>({page:e,isOpen:n,onChangeOpen:o,selected:r,setSelected:s}),[n,e,r]);return Ef(Nl.Provider,{value:i,children:t})};import{jsx as Fe,jsxs as Fo}from"react/jsx-runtime";var Rf=3,Pf=90,Hl=({children:t})=>{let e=S("CommandPalette",ie);return Fe("div",{className:e.listItemActions,children:t})};function vs(f){var h=f,{closeOnSelect:t=!0,lineClamp:e,tooltip:n,children:o,onClick:r,extra:s,onSourceClick:i,description:a,sources:d,id:l,styles:c,defaultSourcesAmount:p=Rf}=h,u=M(h,["closeOnSelect","lineClamp","tooltip","children","onClick","extra","onSourceClick","description","sources","id","styles","defaultSourcesAmount"]);var ae;let m=R(_e),[g,b]=Fl(!1),{selected:T,onChangeOpen:C}=zt(),[w,L]=Fl(!1),N=S("CommandPalette",ie);function _(O){r(O),t&&C(!1)}let W=_l(()=>typeof a!="string"?a:Do(a)?hs(a).trim():a,[a]),ce=_l(()=>typeof n!="string"?n:Do(n)?hs(n).trim():n,[n]);return kf(()=>{L(T===l)},[T]),Fo("div",{className:_o(N.listItem,l===T&&N.listItemSelected),children:[Fo($,{placement:"right-start",tooltip:!0,onOpenChange:L,open:w,children:[Fe($.Trigger,x(y({className:N.listItemAction,"aria-disabled":(ae=u.disabled)!=null?ae:!1,onClick:_,"data-command-palette-item":!0,"data-item-id":l},u),{children:Fo("div",{className:N.listItemContent,children:[typeof o=="string"?Fe("p",{className:_o(N.listItemText,N.truncate,c==null?void 0:c.title),children:o}):o,W&&typeof W=="string"?Fe(Dl,{tagName:"p",allowList:[],content:W,className:_o(N.listItemDescription,c==null?void 0:c.description,e?N.lineClamp:N.truncate)}):a]})})),ce&&ce.length>Pf&&Fe($.Content,{className:N.listItemTooltip,disableFocusManager:!0,children:Fe(Dl,{className:N.listItemTooltipContent,allowList:["h1","h2","h3","h4","h5","h6","a","p","br"],tagName:"div",content:ce.replace(/\n/g,"<br />")})})]}),l===T&&s,d&&d.length>0&&Fo("div",{className:N.sources,children:[Fe("span",{className:N.sourcesTitle,children:m("sources")}),d.slice(0,g?d.length:p).map(O=>Fe("a",{className:N.source,href:O.url,target:"_blank",title:O.url,rel:"noopener noreferrer","data-testid":"source",onClick:()=>i==null?void 0:i(O),children:O.name},O.url)),!g&&d.length>p&&Fe("button",{className:_o(N.source,N.sourceShowMore),type:"button",onClick:()=>b(!0),children:m("showMore",{amount:d.length-p})})]})]})}import{jsx as Bl,jsxs as If}from"react/jsx-runtime";var Ul=()=>If("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[Bl("title",{id:"angleLeftTitle",children:"AngleLeft"}),Bl("path",{d:"M192 448c-8.188 0-16.38-3.125-22.62-9.375l-160-160c-12.5-12.5-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L77.25 256l137.4 137.4c12.5 12.5 12.5 32.75 0 45.25C208.4 444.9 200.2 448 192 448z"})]});import{jsx as Kl,jsxs as xs}from"react/jsx-runtime";function Ss({children:t,title:e,id:n,onDismiss:o}){let r=R(_e),s=S("CommandPalette",ie),{page:i}=zt();return i!==n?null:xs("div",{className:s.page,id:`page_${n}`,tabIndex:-1,children:[o&&xs("div",{className:s.pageNav,children:[xs("button",{className:s.pageBackButton,type:"button",onClick:o,children:[Kl(Ul,{}),r("back")]}),e&&Kl("h3",{className:s.pageTitle,children:e})]}),t]})}import{forwardRef as Af}from"react";import{jsx as zl,jsxs as Lf}from"react/jsx-runtime";var Wt=()=>Lf("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[zl("path",{d:"M0 0h24v24H0z",fill:"none"}),zl("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});import{jsx as Vt,jsxs as bs}from"react/jsx-runtime";function Mf({onChange:t,onChangeType:e,placeholder:n,typePlaceholder:o,types:r,value:s,selectedType:i},a){let d=S("CommandPalette",ie);return bs("div",{className:d.search,children:[Vt("div",{className:d.searchIcon,children:Vt(Wt,{})}),bs("div",{className:d.searchInputWrapper,children:[Vt("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:l=>{t(l.currentTarget.value)},onFocus:l=>{l.currentTarget.select()},className:d.searchInput,placeholder:n,value:s,type:"text",id:"command-palette-search-input",autoFocus:!0}),r&&r.length>0&&Vt("div",{className:d.selectWrapper,children:bs("select",{"data-testid":"command-palette-type-select",className:d.select,onChange:l=>e(l.target.value===o?void 0:l.target.value),value:i||o,children:[o&&Vt("option",{children:o}),r.map(l=>Vt("option",{value:l.value,children:l.label},l.value))]})})]})]})}var Wl=Af(Mf);import Vl from"classnames";import{jsx as Of,jsxs as Df}from"react/jsx-runtime";var Nf=r=>{var s=r,{onClick:t,shortKeys:e,children:n}=s,o=M(s,["onClick","shortKeys","children"]);let i=S("CommandPalette",ie);return Df("button",x(y({type:"button"},o),{onClick:t,className:Vl(i.actionButton,o.className,{[i.hasShortKeys]:e&&e.length>0}),children:[n,e==null?void 0:e.map(a=>Of("span",{className:Vl(i.actionShortcut,a===8629&&i.actionShortcutFixKerning),children:typeof a=="number"?String.fromCharCode(a):a},a))]}))},jl=Nf;import{jsx as Gl,jsxs as Uf}from"react/jsx-runtime";var Bf="[data-command-palette-item]";function ht({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:n="search",page:o,onChangePage:r,onChangeSearch:s,onChangeType:i,onChangeOpen:a,selectedType:d,types:l,children:c,isOpen:p,search:u,updateDeps:f=[]}){let[h,m]=_f(),g=Ff(null),b=()=>{r&&r(n),i(void 0),s(""),a(!1)},T=()=>{var O;if(o!==n&&r){r(n);return}if(d&&i){i(void 0),(O=g.current)==null||O.focus();return}if(u.length>0){s("");return}a(!1)},C=()=>{let O=w();O.length!==0&&m(O[0].dataset.itemId)},w=()=>Array.from(document.querySelectorAll(Bf)||[]),L=O=>document.querySelector(`[data-item-id=${O}]`),N=O=>{let U=L(O);U&&m(U.dataset.itemId)},_=O=>{let U=L(O);U&&U.scrollIntoView({behavior:"smooth"})},W=()=>{if(!h)return;let O=w(),U=L(h);if(!U)return;let Ie=O.indexOf(U),le=O[Ie+1];le!=null&&le.dataset.itemId?N(le.dataset.itemId):C()},ce=()=>{if(!h)return;let O=w(),U=L(h);if(!U)return;let Ie=O.indexOf(U),le=O[Ie-1];le!=null&&le.dataset.itemId?N(le.dataset.itemId):N(O[O.length-1].dataset.itemId)},ae=Hf(O=>{switch(O.key){case"ArrowDown":{O.preventDefault(),W();break}case"ArrowUp":{O.preventDefault(),ce();break}case"Enter":{if(h){let U=L(h);U==null||U.click()}break}}},[h]);return $l(()=>{C()},[u,o,d,p,...f]),$l(()=>{h&&_(h)},[h]),Gl(Kt,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:p,onBack:T,onClose:b,onKeyDown:ae,children:Uf(Ol,{selected:h,setSelected:m,isOpen:p,onChangeOpen:a,page:o,children:[o===n&&Gl(Wl,{ref:g,onChange:s,onChangeType:i,placeholder:t,value:u,selectedType:d,types:l,typePlaceholder:e}),c]})})}ht.Page=Ss;ht.List=ms;ht.Image=Il;ht.ListItem=vs;ht.ListItemActions=Hl;ht.Button=jl;var G=ht;import{useEffect as Kf}from"react";function ql(t,e){Kf(()=>{let n=o=>{var r;((r=navigator==null?void 0:navigator.platform)!=null&&r.toLowerCase().includes("mac")?o.metaKey:o.ctrlKey)&&o.key===t&&(o.preventDefault(),o.stopPropagation(),e())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}import{useEffect as Zl,useRef as Jf}from"react";import{useSelector as Qf,useDispatch as Zf}from"react-redux";import{createAsyncThunk as zf,createSelector as Wf,createSlice as Vf}from"@reduxjs/toolkit";var Xl={data:null,fetchState:"idle"},jf=t=>{var e;return(e=t.entities.data)!=null?e:null},Ho=Wf([jf,Ot,da],(t,e,n)=>{var a;let o=[],{visitorName:r}=n!=null?n:{},{agentName:s,agentNickname:i}=e!=null?e:{};return s&&s!==r&&o.push(s),i&&i!==r&&o.push(i),(a=t==null?void 0:t.filter(d=>!o.includes(d.text)))!=null?a:null}),fe=zf("entities/getEntities",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra;if(!o.conversationQuery)return Promise.resolve([]);let r=o.conversationQuery,s=yield r();return s.length===0?Promise.resolve([]):n.getEntities(s)})),$f=t=>t.filter((e,n)=>n===t.findIndex(o=>o.text===e.text)),Gf=Vf({name:"entities",initialState:Xl,reducers:{},extraReducers:t=>{t.addCase(fe.pending,e=>{e.fetchState="loading"}).addCase(fe.rejected,e=>{e.fetchState="error"}).addCase(fe.fulfilled,(e,n)=>{e.fetchState="done",e.data=$f(e.data?[...e.data,...n.payload]:n.payload)}).addCase(V,()=>Xl)}}),Jl=Gf.reducer;var Cs={};X(Cs,{enUS:()=>qf,nlNL:()=>Xf});var qf={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Xf={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Ql={root:"dd-TYTKs",empty:"dd-AU7uT"};import{jsx as Ts,jsxs as eh}from"react/jsx-runtime";var Yf=({onCopy:t})=>{let e=Jf(null),n=S("EntitiesList",Ql),o=Qf(Ho),{setSelected:r}=zt(),s=R(Cs),i=Zf();return Zl(()=>{i(fe())},[]),Zl(()=>{e.current&&(e.current.focus(),r("entity-0"))},[e]),eh("div",{className:n.root,ref:e,tabIndex:-1,children:[o&&o.length>0&&Ts(G.List,{children:o.map((a,d)=>Ts(G.ListItem,{id:`entity-${d}`,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities"),o&&o.length===0&&Ts("p",{className:n.empty,children:s("noResults")})]})},Yl=Yf;import{jsx as ed}from"react/jsx-runtime";var Bo=t=>ed("svg",x(y({xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512"},t),{children:ed("path",{fill:"currentColor",d:"M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"})}));var An={};X(An,{enUS:()=>th,nlNL:()=>nh});var th={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],giveFeedback:[{type:0,value:"Give feedback"}],answer:[{type:0,value:"Answer"}]},nh={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],giveFeedback:[{type:0,value:"Geef feedback"}],answer:[{type:0,value:"Antwoord"}]};import{useSelector as td}from"react-redux";var Uo={trigger:"dd-dQ-OH",content:"dd-9k0N3",item:"dd-va6pa"};import{jsx as Ko,jsxs as rh}from"react/jsx-runtime";var oh=({suggestion:t,source:e,context:n})=>{let o=R(An),r=td(Se),s=K(),i=k("enableSuggestionFeedback"),a=`${t.text}`,d=td(Xe(`/admin/feedback?conversationId=${r}&type=${e}&text=${a}&data=${JSON.stringify({context:n})}`)),l=()=>{s("suggestion feedback",{text:t.text,source:e,context:n})};return!i||!d?null:rh($,{placement:"top-end",children:[Ko($.Trigger,{className:Uo.trigger,children:Ko(Bo,{"data-testid":"feedback-dropdown-trigger"})}),Ko($.Content,{className:Uo.content,children:Ko($.Button,{className:Uo.item,as:"a",onClick:l,target:"_blank",href:d,children:o("giveFeedback")})})]})},zo=oh;var Mn={};X(Mn,{enUS:()=>sh,nlNL:()=>ih});var sh={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"URL suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},ih={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"URL suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};import{useEffect as uh}from"react";import{useDispatch as ph,useSelector as gh}from"react-redux";import{createAction as dh,createAsyncThunk as sd,createSlice as ch}from"@reduxjs/toolkit";var ah=["{amount}"," {amount}","{date}","{email}","{iban}","{name}","{postal_code}","{street}","{tarif}","{usage}","{3_digits}","{4_digits}","{5_digits}","{6_digits}","{7_digits}","{8_digits}","{9_digits}","{10_digits}"],lh=new RegExp(ah.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function nd(t,e){let n=t.split(lh),o=0,r=[];for(let s=0;s<n.length;s++){let i=n[s];if(r.push(i),s===n.length-1)break;if(e.indexOf(i)===-1)return t;let a=n[s+1],d=s===n.length-2;o+=i.length;let l=o;if(d){let p=a.charAt(0),u=0;do l=p?e.indexOf(p,l+1):-1,u+=1;while(l!==-1&&a.indexOf(e.slice(l))!==0);if(l===-1&&u>2)return t}else l=a&&a!==""?e.indexOf(a,o):-1;let c=l===-1?e.slice(o):e.slice(o,l);r.push(c),o=l}return r.join("")}function od(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var id={suggestions:[],fetchState:"idle"},rd={default:id},ad=t=>e=>{var n,o;return(o=(n=e.textSuggestions[t])==null?void 0:n.suggestions)!=null?o:[]},Wo=t=>t.textSuggestions,ld=t=>{let e=t.toLowerCase();return n=>{let o=n.text.toLowerCase();return o.startsWith(e)&&o.length>e.length}},Vo=dh("textSuggestions/refresh"),he=sd("textSuggestions/recommendations",(t,e)=>v(null,null,function*(){var c,p,u;let{deepdeskAPI:n}=e.extra,o=e.getState(),{platformVariables:r}=o.info,{textSuggestionsCount:s,inlineSuggestions:i}=o.settings,a=At(o),d=(c=o.conversation.current)==null?void 0:c.id;if(!d)throw new Error("No current conversation to fetch text suggestions");if(!((p=o.profile.data)!=null&&p.recommendationEngine))return[];let l=[];if(t==="sticky-messages"){let f=(u=o.profile.data)==null?void 0:u.code;if(!f)throw new Error("No current profile to fetch pinned messages");l=yield n.getPinnedMessages(f)}else l=yield n.getTextSuggestions(d,un(o),t);if(r&&(l=l.map(f=>y(x(y({},f),{text:ge(f.text,r)}),f.title?{title:ge(f.title,r)}:{}))),t==="default"){let f=i?l.filter(ld(a)):l;e.dispatch(Ge(f.slice(0,s)))}return l})),Nn=sd("textSuggestions/autocompletions",(t,e)=>v(null,null,function*(){var c,p;let{deepdeskAPI:n}=e.extra,o=e.getState(),r=(c=o.conversation.current)==null?void 0:c.id,{platformVariables:s}=o.info,{textSuggestionsCount:i,deanonymize:a,inlineSuggestions:d}=o.settings;if(!((p=o.profile.data)!=null&&p.recommendationEngine))return[];if(!r)throw new Error("No current conversation to fetch text suggestions");let l=yield n.getAutocompleteSuggestions(r,x(y({},un(o)),{input:t}));if(!e.getState().input.text)throw new Error("Abort");return d&&(l=l.filter(ld(t))),s&&(l=l.map(u=>x(y({},u),{text:ge(u.text,s)}))),a&&(l=l.map(u=>x(y({},u),{text:u.source!=="trie-with-typos"?nd(u.text,t):u.text}))),l=od(l,i),e.dispatch(Ge(l)),l})),dd=ch({name:"textSuggestions",initialState:rd,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:n}=e.payload;t[n].fetchState="done",t[n].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}}},extraReducers:t=>{t.addCase(he.pending,(e,n)=>{let o=n.meta.arg,r=e[o]||id;return x(y({},e),{[o]:x(y({},r),{fetchState:"loading"})})}).addCase(he.rejected,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="error")}).addCase(he.fulfilled,(e,n)=>{let o=n.meta.arg;e[o]&&(e[o].fetchState="done",e[o].suggestions=n.payload)}).addCase(Nn.pending,e=>{e.default.fetchState="loading"}).addCase(Nn.rejected,e=>{e.default.fetchState="error"}).addCase(Nn.fulfilled,(e,n)=>{e.default.fetchState="done",e.default.suggestions=n.payload}).addCase(V,()=>rd)}}),{setTextSuggestions:OP}=dd.actions,cd=dd.reducer;import{jsx as jo,jsxs as fh}from"react/jsx-runtime";var mh=({types:t,commands:e,onClick:n})=>{let o=ph(),r=R(Mn),s=gh(Wo);return uh(()=>{t.forEach(({type:i})=>{(!s[i]||s[i].suggestions.length===0)&&o(he(i))})},[]),fh("div",{children:[e.length>0&&jo(G.List,{heading:r("commands"),children:e.map((i,a)=>jo(G.ListItem,{id:`command-${a}`,closeOnSelect:!1,onClick:i.onClick,children:i.label},i.label))}),t.map(({type:i,title:a})=>{var d;return jo(G.List,{heading:a,orientation:"vertical",children:(d=s[i])==null?void 0:d.suggestions.map((l,c)=>jo(G.ListItem,{id:`${i}-${c}`,closeOnSelect:!1,description:l.title&&l.text,onClick:()=>n(l.text,l),"data-testid":"search-overlay-suggestion",children:l.title||l.text},`${l.id}-${l.text}`))},i)})]})},ud=mh;import{jsx as Ee,jsxs as ks}from"react/jsx-runtime";var bh=200,Ch=5,Th=4,Es=(t,e,n)=>t.slice(0,n?10:e.toLowerCase()==="image"?Th:Ch),wh=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Eh=()=>{var Ie,le,hi;let t=Sh(),e=ne(),n=R(Mn),[o,r]=ws(!1),[s,i]=ws(""),a=yt(xa),d=yt(ft),[l,c]=ws(),p=yt(J),u=k("showSearch"),f=k("enableSuggestionFeedback"),h=k("showEntitiesCommand"),m=k("showImageSearch"),g=k("searchTriggerKey"),b=yt(Cl),T=yt(Hr),C=yt(Sa),w=yt(va),L=((hi=(le=(Ie=d==null?void 0:d.uiConfig)==null?void 0:Ie.search)==null?void 0:le.initialTypes)==null?void 0:hi.filter(({isActive:A})=>A))||[],N=K(),_=xh(()=>{let A=ee=>Es(T.filter(z=>z.type===ee.toUpperCase()),ee,l),j=(b==null?void 0:b.map(ee=>({value:ee.code.toUpperCase(),label:`${ee.name}s`,list:A(ee.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[];if(j.push({value:"PERSONAL",label:n("personalSuggestions"),list:A("PERSONAL"),lineClamp:!1,listOrientation:"vertical"},{value:"URL",label:n("urlSuggestions"),list:A("URL"),lineClamp:!1,listOrientation:"vertical"},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:A("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical"}),m&&j.push({value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:A("IMAGE"),listOrientation:"horizontal"}),L.length===0)return j;let on=L.map(ee=>j.find(z=>z.value.toLowerCase()===ee.type)).filter(ee=>!!ee),Tr=j.filter(ee=>!on.find(z=>z.value===ee.value));return[...on,...Tr]},[b,L,m,l]),W=[{label:n("entitiesClipboard"),onClick:()=>t(Dt("entities")),shouldShow:h&&wh(n("entitiesClipboard"),s)}].filter(A=>A.shouldShow).filter(()=>!l),ce=pd(yh((A,j)=>{t(at({query:A,type:j,tags:["search-overlay"],size:l?50:20}))},bh),[l]),ae=pd((A,j)=>{j.type==="IMAGE"?e.send(Ur,{suggestion:j}):e.send(Me,{text:A,suggestion:j}),t(me(!1))},[t]),O=A=>{Ce(A.text),N("entity copied",{entity:A,type:"copy"}),t(me(!1))};function U(A){return j=>{o?window.confirm(n("warning"))&&(A(j),r(!1)):A(j)}}return gd(()=>{s?ce(s,l):t(ao())},[s,l]),gd(()=>{p&&t(kn())},[p]),ql(g,()=>{t(me(!0)),N("open search",{via:"ctrl+k"})}),!u||!d?null:ks(G,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:i,onChangeOpen:U(A=>t(me(A))),onChangeType:A=>c(A),onChangePage:U(A=>t(Dt(A))),selectedType:l,search:s,page:a,isOpen:w,types:_,updateDeps:[T],children:[ks(G.Page,{id:"search",children:[s.length===0&&Ee(ud,{types:L,commands:W,onClick:ae}),s.length>0&&ks(vh,{children:[W.length>0&&Ee(G.List,{heading:n("commands"),children:W.map((A,j)=>Ee(G.ListItem,{closeOnSelect:!1,onClick:A.onClick,id:`commands-${j}`,children:A.label},A.label))}),_.map(({value:A,label:j,list:on,lineClamp:Tr,listOrientation:ee})=>Ee(G.List,{heading:j,orientation:ee==="horizontal"?"horizontal":"vertical",onShowAll:()=>c(A),hasMore:!l&&C[A.toLowerCase()]>Es(on,A,l).length,children:Es(on,A,l).map(z=>Ee(G.ListItem,{id:`${A}-${z.id}`,closeOnSelect:!1,lineClamp:Tr,onClick:()=>ae(z.text,z),description:A!=="IMAGE"?z.title&&z.text:void 0,tooltip:z.text,extra:f&&Ee(G.ListItemActions,{children:Ee(zo,{context:s,source:"search",suggestion:z})}),children:A==="IMAGE"?Ee(G.Image,{title:z.title||z.text,src:z.image}):z.title||z.text},`${z.id}-${z.text}`))},A))]})]}),Ee(G.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:U(()=>{t(Dt("search"))}),children:Ee(Yl,{onCopy:O})})]})},md=Eh;import{jsx as fd,jsxs as Ph}from"react/jsx-runtime";var Rh=()=>{let t=k("showSearch"),e=k("isEmbedded");return Ph(kh,{children:[t&&fd(md,{}),e&&fd(bl,{})]})},hd=Rh;import Mh from"classnames";import{useSelector as Nh}from"react-redux";import{jsx as Rs}from"react/jsx-runtime";var yd=({className:t})=>Rs("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 512 512",xmlSpace:"preserve",className:t,children:Rs("g",{children:Rs("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
4
5
  c-17.9,17.9-27.3,40.1-27.3,65.7C163.4,163,163.4,233,163.4,233z M465.5,267.9V477c0,9.4-3.4,17.9-10.2,24.7
5
6
  c-6.8,6.8-15.4,10.2-24.7,10.2h-349c-9.4,0-17.9-3.4-24.7-10.2c-6.8-6.8-10.2-15.4-10.2-24.7V267.9c0-9.4,3.4-17.9,10.2-24.7
6
7
  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
7
- 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`})})});import{jsx as Vl}from"react/jsx-runtime";var Mf={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},jl=({className:t,color:e})=>Vl("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Vl("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:Mf[e||"pink"]})});var $l={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var ys={};X(ys,{enUS:()=>Nf,nlNL:()=>Of});var Nf={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},Of={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};import{useDispatch as Ff}from"react-redux";import{jsx as vs,jsxs as Gl}from"react/jsx-runtime";var ql=({onLogIn:t})=>{let e=R(ys),n=E("floatingMenu"),o=E("productName"),r=Ff(),s=_f(J),i=S("FloatingMenu",$l);if(s===null||n===!1)return null;let a=()=>{s===!0?r(me(!0)):t()};return Gl("button",{type:"button",className:Df(i.root,{[i.isLoggedIn]:s,[i.isLoggedOut]:!s}),onClick:a,children:[vs("div",{className:i.text,children:e(s?"search":"signin",{productName:o})}),Gl("div",{className:i.icon,children:[vs(jl,{className:i.logo,color:"pink"}),s===!1&&vs(Wl,{className:i.lock})]})]})};import{useEffect as rh,useRef as sh}from"react";import{useDispatch as ih,useSelector as Kt}from"react-redux";import{useEffect as Hf}from"react";function gt(t){Hf(()=>{let e=n=>{n.isWithinRoot||t(n)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function mt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}function we(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:o}=t.settings,{text:r,selection:s}=t.input;return s.start!==s.end?!1:s.end>=r.length?!0:e?n&&new RegExp(n).test(r.substring(s.end))||o&&new RegExp(o).test(r.substring(0,s.end))?!0:n===!1&&o===!1:!1}import{createSlice as Bf}from"@reduxjs/toolkit";var Uf={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Mo=({ui:t})=>t.overlayCollapsed,Xl=Bf({name:"ui",initialState:Uf,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputFocus(t,e){t.overlayCollapsedUserOverwrite!==!0&&(e.payload===!0&&(t.overlayCollapsed=!1),t.inputHasFocus=e.payload)},setOverlayCollapsed(t,e){e.payload.collapse===!1&&(t.openOverlayWhenTyping=!1),!(e.payload.skipWhenInputFocus&&t.inputHasFocus)&&(t.overlayCollapsed=e.payload.collapse)},setOpenOverlayWhenTyping(t,e){t.openOverlayWhenTyping=e.payload},setOverlayCollapsedUserOverwrite(t,e){t.overlayCollapsedUserOverwrite=e.payload,t.overlayCollapsed=e.payload}}}),{setShowTabHint:Mn,setInputFocus:No,setOverlayCollapsed:Je,setOpenOverlayWhenTyping:Jl,setOverlayCollapsedUserOverwrite:Ql}=Xl.actions,Zl=Xl.reducer;import{useMemo as th}from"react";import{Interweave as od}from"interweave";import{useEffect as $f,useMemo as Gf,useRef as qf,useState as Xf}from"react";import{useDispatch as Jf,useSelector as rd}from"react-redux";import{useEffect as Kf}from"react";function Yl(t,e,n){Kf(()=>{let o=t.current;return o?(o.addEventListener(e,n),()=>{o.removeEventListener(e,n)}):()=>{}},[t,e,n])}var ed={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"};import{jsx as td,jsxs as zf}from"react/jsx-runtime";var nd=({title:t})=>zf("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18px",height:"18px",viewBox:"0 0 24 24","aria-labelledby":"closeTitle",children:[td("title",{id:"closeTitle",children:t}),td("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 xs={};X(xs,{enUS:()=>Wf,nlNL:()=>Vf});var Wf={assistant:[{type:0,value:"Assistant"}],close:[{type:0,value:"Close"}]},Vf={assistant:[{type:0,value:"Assistent"}],close:[{type:0,value:"Sluiten"}]};import{jsx as _e,jsxs as sd}from"react/jsx-runtime";var Qf=["search","personal-collection-search","search-autocomplete"];function Zf(t,e,n,o={}){var s;let r="";return Qf.includes(e)?r=Ya(ns(t,n,{stripAgentPart:!0}),(s=o.searchKeywords)!=null?s:[n]):r=ns(t,n,o),o.placeholders===!0&&(r=el(r)),r}var Yf=()=>{},eh=({selected:t,suggestion:e})=>{let n=R(xs),o=E("inlineSuggestions"),r=rd(At),[s,i]=Xf(!1),a=E("enableSuggestionFeedback"),d=rd(h=>h.input.text),l=Jf(),c=S("TextSuggestion",ed),p=qf(null),u=e.source==="assistant",f=a&&!u;$f(()=>{let h=setTimeout(()=>{l(ea({text:e.text,suggestion:e}))},500);return()=>{clearTimeout(h)}},[e]),Yl(p,"click",()=>{l(re({suggestion:e,text:e.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let m=()=>{l(st({source:e.source,text:e.text,assistantCode:e.assistantCode}))},g=Gf(()=>Zf(e.text,e.source,r,{stripAgentPart:o,placeholders:!0,searchKeywords:e.searchKeywords}),[o,e.text,e.source,r,e.searchKeywords]);return e.source==="gpt"&&!o?null:sd("div",{className:c.root,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[_e(I,{ref:p,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:Yf,children:e.source==="assistant"?sd("div",{className:c.assistantContainer,children:[_e(od,{containerTagName:"div",tagName:"span",className:c.formattedTextTruncated,content:g}),_e("span",{className:c.assistantBadge,children:n("assistant")})]}):_e(od,{containerTagName:"div",tagName:"span",className:c.formattedText,content:g})}),f&&s&&_e("div",{className:c.actions,children:_e(Po,{source:"overlay",context:d,suggestion:e})}),u&&s&&_e("div",{className:c.closeIconContainer,children:_e("button",{type:"button",className:c.closeIcon,onClick:m,title:n("close"),children:_e(nd,{title:n("close")})})})]})},id=eh;import{jsx as oh}from"react/jsx-runtime";var nh=({suggestions:t,selectedIndex:e,reverse:n})=>th(()=>{let r=t.map((s,i)=>oh(id,{index:i,selected:i===e,suggestion:s},`${s.text}-${s.source}`));return n?r.reverse():r},[t,e,n]),Oo=nh;var ad={root:"dd-PfvRI",paper:"dd-HYlyY"};import{jsx as Do}from"react/jsx-runtime";var ah=()=>{let t=sh(null),e=S("InlineSuggestionsOverlay",ad),n=Kt(we),o=ih(),r=Kt(J),s=Kt(Lt),i=Kt(Mo),a=E("showTextSuggestions"),d=Kt(rt),l=Kt(dn);return gt(()=>{setTimeout(()=>{o(Je({collapse:!0,skipWhenInputFocus:!0}))})}),rh(()=>{let c=t.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let p=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-p.right,0)}px`}),i||!n||!a||d.length===0||r!==!0||s===!1?null:Do("div",{className:e.root,"data-variant":"inline",children:Do("div",{ref:t,className:e.paper,children:Do(te,{children:Do(Oo,{suggestions:d,selectedIndex:l})})})})},ld=ah;import{Provider as lh}from"react-redux";import{jsx as _o}from"react/jsx-runtime";var dh=({children:t})=>{let n=E("locale").replace("-","");return _o(Xr.Provider,{value:n,children:t})},ch=({store:t,customStyles:e={},children:n})=>_o(lh,{store:t,children:_o(dh,{children:_o(rn.Provider,{value:e,children:n})})}),Fe=ch;import ws from"classnames";import{useEffect as Ch,useRef as Th,useState as wh}from"react";import{useDispatch as Eh,useSelector as Qe}from"react-redux";import{useState as uh}from"react";function dd(t,e){let[n,o]=uh(()=>{if(typeof window=="undefined")return e;try{let s=window.localStorage.getItem(t);return s?JSON.parse(s):e}catch(s){return k.error(s),e}});return[n,s=>{try{let i=s instanceof Function?s(n):s;o(i),typeof window!="undefined"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){k.error(i)}}]}var cd=()=>/Mac/i.test(navigator.platform);import mh from"classnames";import{Fragment as fh,useCallback as bs,useMemo as pd}from"react";var Ss={};X(Ss,{enUS:()=>ph,nlNL:()=>gh});var ph={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"}]}]},gh={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 ud={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};import{jsx as Fo,jsxs as gd}from"react/jsx-runtime";var Cs=(t,e,n)=>o=>Fo("button",{className:t.anchorButton,type:"button",value:e,onClick:n,children:o},e),hh=({className:t,loginUrl:e,isEmbedded:n,onSnooze:o,onLogIn:r})=>{let s=R(Ss),i=ne(),a=S("Login",ud),d=E("productName"),l=bs(h=>{h.preventDefault(),o&&o(Number.parseInt(h.target.value,10))},[]),c=bs(h=>{h.preventDefault(),i.send(_t,!0)},[e]),p=pd(()=>h=>Fo("a",{onClick:T=>{T.preventDefault(),r()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[e]),u=bs(h=>Fo("button",{type:"button",className:a.anchorButton,onClick:c,children:h},"prompt"),[c]),{min:f,hour:m,day:g}=pd(()=>({min:Cs(a,600,l),hour:Cs(a,3600,l),day:Cs(a,3600*12,l)}),[]);return gd("div",{className:mh(t,a.root),children:[s("loginPlease",{login:n?u:p,productName:d}),o&&gd(fh,{children:[Fo("br",{}),s("snooze",{min:f,hour:m,day:g})]})]})},Ho=hh;import{useDispatch as yh}from"react-redux";var md={root:"dd-DoQhb",text:"dd-Jwnev"};import{jsx as fd,jsxs as xh}from"react/jsx-runtime";var vh=({title:t})=>{let e=S("SearchTrigger",md),n=yh(),o=K();return xh("button",{type:"button",className:e.root,onClick:()=>{n(me(!0)),o("open search",{via:"autocomplete-overlay"})},children:[fd(Bt,{}),fd("span",{className:e.text,children:t})]})},hd=vh;var Ts={};X(Ts,{enUS:()=>Sh,nlNL:()=>bh});var Sh={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"}]},bh={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 yd={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"};import{jsx as q,jsxs as ft}from"react/jsx-runtime";var kh=({onLogIn:t})=>{let e=S("SuggestionsOverlay",yd),n=R(Ts),o=Qe(we),r=Qe(Yi),s=Eh(),i=Th(null),a=E("searchTriggerKey"),d=E("productName"),l=Qe(Mo),c=Qe(J),p=Qe(Ui),u=Qe(Lt),[f,m]=wh(null),g=E("showSearch"),h=E("showTextSuggestions"),b=E("adminUrl"),T=E("isEmbedded"),C=E("suggestionsPlacement"),[w,L]=dd("dd-snooze-until-ms",0),N=l||w>Date.now(),_=Qe(rt),W=Qe(dn),ce=_.filter(U=>U.source!=="gpt").length,ae=()=>{N&&L(0),s(Ql(!N))},O=U=>{let Ie=Date.now()+U*1e3;L(Ie),k.info(`Snooze until: ${new Date(Ie)}`),s(Je({collapse:!0}))};return Ch(()=>{ce===0&&m(null)},[_,ce]),gt(()=>{s(Je({collapse:!0,skipWhenInputFocus:!0}))}),c===null||u===!1?null:c===!1?ft("div",{ref:i,className:ws(e.root,{[e.isCollapsed]:N}),children:[!N&&ft("div",{className:e.triggers,children:[q("div",{style:{flex:1}}),q("div",{className:e.triggersRight,children:q(Et,{className:e.toggleButton,title:n("collapse"),onClick:ae,isCollapsed:!1})})]}),q("div",{className:e.toggleButtonWrapper,children:q(Et,{className:e.toggleButton,title:n("open",{productName:d}),onClick:ae,isCollapsed:!0})}),ft("div",{className:e.collapsible,children:[p&&ft("div",{className:e.loginError,children:[q("span",{className:e.loginErrorMessage,children:p}),q("button",{type:"button",className:e.loginErrorDismiss,onClick:()=>s(Zn()),"aria-label":n("dismissError"),children:n("dismiss")})]}),q(Ho,{loginUrl:b,isEmbedded:T,onLogIn:t,onSnooze:O})]})]}):!r||!o?null:ft("div",{ref:i,className:ws(e.root,{[e.isCollapsed]:N}),children:[!N&&ft("div",{className:e.triggers,children:[q("div",{style:{flex:1},children:g&&q("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>m(n(cd()?"searchHintMac":"searchHintWindows",{searchTriggerKey:a.toUpperCase()})),onMouseLeave:()=>m(null),children:q(hd,{title:n("search")})})}),ft("div",{className:e.triggersRight,onFocus:()=>{},children:[q("div",{className:ws(!f&&e.hintsHidden,e.hints),children:f}),q(Et,{className:e.toggleButton,title:n("collapse"),onClick:ae,isCollapsed:!1})]})]}),q("div",{className:e.toggleButtonWrapper,children:q(Et,{className:e.toggleButton,title:n("open",{productName:d}),onClick:ae,isCollapsed:!0})}),ce>0&&h&&q("div",{className:e.collapsible,onFocus:()=>{},children:q(te,{children:q(Oo,{suggestions:_,selectedIndex:W,reverse:C==="above"})})})]})},vd=kh;import Os from"classnames";import{Interweave as Ey}from"interweave";import{useCallback as ky,useEffect as Ry,useMemo as Wd,useRef as Py}from"react";import{connect as Iy}from"react-redux";import{useEffect as Rh,useRef as Ph,useState as Ih}from"react";function Bo(t){return t.contentEditable==="true"}function Lh(t){let e=0,n=0,o=window.getSelection();if(o.rangeCount!==0){let r=o.getRangeAt(0),s=r.cloneRange();s.selectNodeContents(t),s.setEnd(r.endContainer,r.endOffset),n=s.toString().length,s.selectNodeContents(t),s.setEnd(r.startContainer,r.startOffset),e=s.toString().length}return{selectionStart:e,selectionEnd:n}}function xd(t){let{selectionStart:e,selectionEnd:n}=Bo(t)?Lh(t):t;return[e,n]}function Sd(t){let[,e]=Ih(),n=Ph(null);return n.current=xd(t),Rh(()=>{let o=()=>{var a;let[r,s]=(a=n.current)!=null?a:[],i=xd(t);(!i||r!==i[0]||s!==i[1])&&(n.current=i,e({}))};return t.addEventListener("keyup",o),t.addEventListener("click",o),t.addEventListener("focus",o),document.addEventListener("selectionchange",o),()=>{t.removeEventListener("keyup",o),t.removeEventListener("click",o),t.removeEventListener("focus",o),document.removeEventListener("selectionchange",o)}},[t]),n.current}function bd(t,e){if(!e)return;let n=t,{value:o}=n,[r,s]=e,i=o.match(qn);if(!i||i.length===0)return;let a=0;i.find(d=>{let l=o.indexOf(d,a);return r>l&&s<l+d.length?(n.selectionStart=l,n.selectionEnd=l+d.length,!0):(a=l+d.length,!1)})}import{cloneElement as Ah}from"react";var Mh=["div","span","mark","strong","b","i","u","em"];function Es(t,e,n=0){var s;let o=t[t.length-1],r=typeof o=="object"&&o!==null?(s=o.props)==null?void 0:s.tagName:void 0;if(r==="br")return t.pop(),[...t,...e,o];if(Mh.includes(r)){let i=Array.isArray(o.props.children)?o.props.children:[o.props.children];return[...t.slice(0,t.length-1),Ah(o,{children:Es(i,e,n+1)})]}return[...t,...e]}function ht(t){return t.tagName.toLowerCase()==="textarea"}var Cd={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"};import Zh from"classnames";import{Matcher as Yh}from"interweave";import{useEffect as ey,useMemo as ty}from"react";import{useEffect as Nh,useRef as Oh,useState as Dh}from"react";function Td(t,e){let n;return[(...o)=>{window.cancelAnimationFrame(n);let r=e?e(...o):o;n=window.requestAnimationFrame(()=>{t(...r)})},()=>window.cancelAnimationFrame(n)]}function Uo(t){let e=Oh(null),[n,o]=Dh(!1);return Nh(()=>{var c;let r=!1,s=Number.parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[i,a]=Td((p,u)=>{let f=e.current;if(!f)return;let m=p/s,g=u/s,h=f.getBoundingClientRect(),b=m>h.x&&m<h.x+h.width&&g>h.y&&g<h.y+h.height;b&&!r?(r=!0,o(!0)):!b&&r&&(r=!1,o(!1))},({clientX:p,clientY:u})=>[p,u]),[d,l]=Td(()=>{r=!1,o(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",d),()=>{a(),l(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",d)}},[e]),[e,n]}function wd(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Ko(t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}function Ed(t){return t!=null}import Ld from"classnames";import{createRef as jh,useCallback as Rs,useMemo as $h,useRef as Gh,useState as qh}from"react";import{useState as _h,useLayoutEffect as Fh}from"react";var Hh=["bottom","height","left","right","top","width"],Bh=(t={},e={})=>Hh.some(n=>t[n]!==e[n]),He=new Map,kd,Rd=()=>{let t=[],e=[];He.forEach((n,o)=>{if(o instanceof Element&&!o.isConnected){e.push(o);return}let r=o.getBoundingClientRect();Bh(r,n.rect)&&(n.rect=r,t.push(n))}),e.forEach(n=>{He.delete(n)}),t.forEach(n=>{n.callbacks.forEach(o=>o(n.rect))}),kd=window.requestAnimationFrame(Rd)};function Uh(t,e){return{observe(){let n=He.size===0;if(He.has(t)){let o=He.get(t);o.callbacks.push(e),o.rect&&e(o.rect)}else He.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});n&&Rd()},unobserve(){let n=He.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||He.delete(t),He.size||cancelAnimationFrame(kd)}}}}function ks(t){let[e,n]=_h(null);return Fh(()=>{if(!t.current)return;let o=Uh(t.current,r=>{n(r)});return o.observe(),()=>{o.unobserve()}},[t]),e}import{useContext as Kh,useLayoutEffect as zh,useState as Wh}from"react";import{createPortal as Vh}from"react-dom";var Pd={root:"dd-r-dgo"};var Id=({children:t,parentNode:e})=>{let[n,o]=Wh(null),r=Kh(rn);return zh(()=>{let s=document.createElement("div");return mt(s),s.classList.add(Pd.root),r!=null&&r.portalRootNode&&s.classList.add(r==null?void 0:r.portalRootNode),(e||document.body).appendChild(s),o(s),()=>{s.isConnected&&s.remove()}},[]),n?Vh(t,n):null};var Ee={ref:"dd-iz-KP",root:"dd-vEMon",positionAbove:"dd-mUCxM",positionBelow:"dd-7oZI7",positionLeft:"dd-BiWvD",positionRight:"dd-JIWea",alignStart:"dd-5ivu6",alignCenter:"dd-rnVkP",alignEnd:"dd-gZBp4"};import{jsx as Ps}from"react/jsx-runtime";var zo=(t=!1)=>{let[e,n]=qh(t),o=Rs(()=>n(!0),[]),r=Rs(()=>n(!1),[]),s=Rs(()=>n(a=>!a),[]),i=Gh(null);return{opened:e,open:o,close:r,toggle:s,triggerRef:i}};function Is(t,e=null,n=0){if(!t)return{display:"none"};let o=e?t.top-e.top<0||t.top<e.top-n?e.top-n:t.top+t.height>e.top+e.height+n?e.top+e.height+n-t.height:t.top:t.top,r=e?t.left<e.left-n?e.left-n:t.left+t.width>e.left+e.width+n?e.left+e.width+n-t.width:t.left:t.left;return{top:o,left:r,height:t.height,width:t.width}}var zt=l=>{var c=l,{className:t,triggerRef:e,boundaryRef:n=jh(),position:o="above",align:r="center",children:s,toStyle:i=Is,parentNode:a}=c,d=M(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let p=ks(e),u=ks(n),f=$h(()=>i(p,u,0),[p,u]);return Ps(Id,{parentNode:a,children:Ps("div",x(y({className:Ld(Ee.ref,{[Ee.positionAbove]:o==="above",[Ee.positionBelow]:o==="below",[Ee.positionLeft]:o==="left",[Ee.positionRight]:o==="right",[Ee.alignStart]:r==="start",[Ee.alignCenter]:r==="center",[Ee.alignEnd]:r==="end"}),style:f},d),{role:"dialog",children:Ps("div",{className:Ld(t,Ee.root),children:s})}))})};import Xh from"classnames";import{forwardRef as Jh,useRef as Qh}from"react";var Be={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"};import{jsx as Ad}from"react/jsx-runtime";var Wo=Jh((r,o)=>{var s=r,{className:t,children:e}=s,n=M(s,["className","children"]);let i=Qh(null),a=S("TabCompletion",Be);return Ad("div",x(y({ref:Ko([i,o]),className:Xh(t,a.popoverContentContainer)},n),{children:Ad("div",{className:a.popoverContent,children:e})}))});import{jsx as Nn,jsxs as ry}from"react/jsx-runtime";var ny=t=>e=>{let n=Is(e);return"top"in n&&(n.width=t.width-(e.left-t.left)-10),n},oy=({inputElement:t,boundaryRef:e,inputStyle:n,children:o,suggestion:r})=>{let s=S("TabCompletion",Be),i=zo(),a=ty(()=>ny(t.getBoundingClientRect()),[t]),[d,l]=Uo(t);return ey(()=>{l?i.open():i.close()},[l]),ry("span",{children:[Nn("mark",{ref:Ko([d,i.triggerRef]),className:Zh(s.matchKeyword,{[s.hover]:l}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:o}),i.opened&&Nn(zt,{className:s.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:Nn(Wo,{style:n,children:Nn("div",{className:s.hintText,children:r})})})]})},Vo=class extends Yh{constructor(){super(...arguments);this.keywordMatches=[];this.preparedKeywordMatches=[];this.usedKeywordMatches=new Set}onBeforeParse(n,o){return o.keywordMatches&&o.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=o.keywordMatches.map(r=>x(y({},r),{keywordRegex:new RegExp(`\\b${wd(r.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let o=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),d=n.charAt(i.index+s.keyword.length);return a==="{"&&d==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(Ed);if(o.length===0)return null;let r=o.reduce((s,i)=>i.index<s.index?i:s);return this.usedKeywordMatches.add(r.preparedKeywordMatch),r}replaceWith(n,o){return Nn(oy,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:n},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import{Matcher as sy}from"interweave";import iy from"classnames";import{jsx as Md}from"react/jsx-runtime";var ay=({inputElement:t,children:e})=>{let n=S("TabCompletion",Be),[o,r]=Uo(t);return Md("mark",{ref:o,className:iy(n.matchPlaceholder,{[n.hover]:r}),children:e})},jo=class extends sy{match(e){let n=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(e,n){return Md(ay,{inputElement:n.inputElement,children:e},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};import Ns from"classnames";import{Matcher as yy}from"interweave";import{createRef as vy,forwardRef as xy,useCallback as Sy,useEffect as Ud,useRef as Kd,useState as zd}from"react";import{useDispatch as by,useSelector as Cy}from"react-redux";import{jsx as Nd}from"react/jsx-runtime";var Od=()=>Nd("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:Nd("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"})});import{useCallback as ly,useEffect as _d,useMemo as dy,useState as Fd}from"react";import{useDispatch as cy,useSelector as Hd}from"react-redux";import uy from"lodash.debounce";var Dd={root:"dd-ky-Bv",content:"dd-kV5e1"};function $o(t,e,n){var r;let o=((r=t.imageSizes)==null?void 0:r[e])||t.image||n;if(!o)return null;try{return new URL(o).toString()}catch(s){return null}}function Ls(t){return t.replace("https://www.","").replace("https://","")}import{jsx as yt,jsxs as As}from"react/jsx-runtime";var py=3,gy=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),my=({onSelectLink:t,onDismiss:e,placeholder:n,visitUrlText:o,linkCount:r=py})=>{let s=S("LinkSearch",Dd),[i,a]=Fd(""),d=cy(),l=Hd(Nl("url")),c=Hd(Ta("URL")),p=dy(()=>c.map(gy),[c]),[u,f]=Fd(p.length-1),m=E("fallbackImage"),g=C=>{let w=C.target;a(w.value)},h=(C,w)=>{C.stopPropagation(),C.preventDefault(),window.open(w,"_blank")},b=C=>{var N;let w=u-1<0?p.length-1:u-1,L=u+1===p.length?0:u+1;C.code==="Escape"&&(a(""),e()),C.code==="ArrowUp"&&f(w),C.code==="ArrowDown"&&f(L),C.code==="Enter"&&t(((N=p[u])==null?void 0:N.text)||i)},T=ly(uy(C=>{d(at({query:C,type:"URL",tags:["link-search"]}))},300),[]);return _d(()=>{i&&T(i)},[i]),_d(()=>()=>{d(lo())},[]),As("div",{className:s.root,children:[yt(te,{withDivider:!0,children:(i?p:l).slice(0,r).map((C,w)=>yt(I,{selected:u===w,onClick:()=>t(C.text),"data-testid":"linksearch-suggestion",children:As(D,{children:[yt(D.Image,{src:$o(C,"small",m||void 0),title:C.title||C.text}),As(D.Content,{className:s.content,cropText:!0,children:[yt(D.Title,{children:C.title||Ls(C.text)}),C.title&&Ls(C.text)]}),yt(I.Actions,{children:yt(I.ActionButton,{label:o,onClick:L=>h(L,C.text)})})]})},C.text))}),yt(Tn,{value:i,onChange:g,autoFocus:!0,placeholder:n,onKeyUp:b})]})},Bd=my;var Ms={};X(Ms,{enUS:()=>fy,nlNL:()=>hy});var fy={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"}]},hy={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"}]};import{jsx as ye,jsxs as Go}from"react/jsx-runtime";var Ty=xy((t,e)=>{let n=S("TabCompletion",Be);return ye("mark",{ref:e,className:Ns(n.matchSelection)},"selection-start")}),wy=({startRef:t,boundaryRef:e,inputStyle:n,inputElement:o,children:r})=>{let s=R(Ms),i=S("TabCompletion",Be),a=E("addToPersonalCollection"),d=Cy(Xe("/admin/personal-collection/new")),l=Kd(null),c=Kd(null),[p,u]=zd(null),f=by(),m=zo(document.activeElement===o),[g]=zd(()=>document.createRange());m.triggerRef.current=g,Ud(()=>()=>g.detach(),[]),Ud(()=>{let b=t.current,T=l.current;!b||!T||(g.setStart(b,0),g.setEnd(T,0))},[t.current,l.current]),gt(()=>{m.close()});let h=Sy(b=>{let T=g.toString(),C=/^http(s?):\/\//.test(b)?b:`https://${b}`,w=`[${T}](${C})`;f(re({text:w,suggestion:{text:w,source:"search-url",type:"url"},eventMetrics:{inputType:"mouse"},replace:"selection"}))},[]);return Go("span",{children:[ye("mark",{ref:l,className:Ns(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":m.opened?"true":"false",children:r}),m.opened&&ye(zt,{className:i.popoverRoot,triggerRef:m.triggerRef,boundaryRef:e,position:"above",align:"start",children:Go(Wo,{style:n,ref:c,children:[Go("div",{className:Ns(i.selectionOptions,{[i.selectionOptionsIsHidden]:p!==null}),children:[Go("button",{type:"button",tabIndex:p===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>u("insertLink"),children:[ye(Od,{}),ye("span",{children:"\xA0"}),ye("span",{children:s("insertLink")})]}),a&&d&&ye("button",{type:"button",tabIndex:p===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>{let b=g.toString(),T=`${d}?text=${encodeURIComponent(b)}`;window.open(T,"_blank")},children:ye("span",{children:s("addToPersonalCollection")})})]}),p==="insertLink"&&ye(Bd,{placeholder:s("linkInputPlaceholder"),visitUrlText:s("visitUrl"),onSelectLink:h,onDismiss:()=>{u(null),m.close()}})]})})]},"selection-end")},qo=class extends yy{constructor(){super(...arguments);this.charCount=0;this.foundIndex=0;this.startRef=null}onBeforeParse(n,o){return this.props=o,this.charCount=0,this.startRef=vy(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,r]=this.props.selection;if(o===r)return null;let s=this.foundIndex===0?o:r,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?y({isStart:a},i):null}replaceWith(n,o){return o.isStart?ye(Ty,{ref:this.startRef}):ye(wy,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};import{useSelector as Ly}from"react-redux";import{jsx as Wt,jsxs as Ny}from"react/jsx-runtime";var Ay=({enabled:t,content:e,tabText:n,showTabHint:o,showTabCompletion:r,showStyleSuggestions:s,keywordMatches:i,inputElement:a,source:d})=>{let l=S("TabCompletion",Cd),c=E("insertLink"),p=E("addToPersonalCollection"),u=E("showMidSentenceSuggestions"),f=E("inlineSuggestions"),m=Sd(a),g=Py(null),h=Ly(J);Ry(()=>{ht(a)&&m&&bd(a,m)},[m]);let b=ky(w=>{if(!r||!n)return w;let L=[Wt("span",{className:l.resetIndent,children:"\u200B"},"u200B"),Wt("span",{"data-testid":"tab-completion",className:Os(l.tabText,l.resetIndent),"data-source":d,children:n},"tabText")];return o&&L.push(Wt("span",{className:Os(l.hint,l.resetIndent),children:Wt(kr,{keyCode:"tab"},"tabHint")},"tabHint")),Es(w,L)},[r,n,o]),T=Wd(()=>{let w=[];return(c||p)&&w.push(new qo("selection")),w.push(new jo("placeholders")),s&&w.push(new Vo("keywords")),w},[f,c,p,s]),C=Wd(()=>{let w=window.getComputedStyle(a);return{"--dd-color":w.color,"--dd-font-size":w.fontSize,"--dd-font-family":w.fontFamily,"--dd-font-variant":w.fontVariant}},[]);return!t||!h?null:Ny("div",{ref:w=>{w!=null&&w.parentElement&&(g.current=w==null?void 0:w.parentElement)},className:l.root,style:C,children:[Wt(Ey,{tagName:"span",containerTagName:"div",className:Os(l.container,l.agentText),disableLineBreaks:ht(a),content:e||"\u200B",onAfterParse:b,matchers:T,selection:m,keywordMatches:i,inputElement:a,inputStyle:C,boundaryRef:g,inlineSuggestionsOnlyAtEnd:!u}),Wt("br",{})]},"tab-completion")},My=t=>{var h,b,T;let{input:e,ui:n,settings:o,styleSuggestions:r,conversation:s}=t,i=Mt({input:e}),a=(i==null?void 0:i.text)||"",d=(i==null?void 0:i.source)||"",l=(h=e.html)!=null?h:Pn(e.text),c=a.indexOf(e.text)===0?a.slice(e.text.length):"",{showTabHint:p}=n,{isSupported:u}=s,{showTabCompletion:f,visible:m,showStyleSuggestions:g}=o;return{showTabHint:p,showStyleSuggestions:g,showTabCompletion:f&&we(t),content:l,tabText:c,source:d,keywordMatches:(T=(b=r.list)==null?void 0:b.keywordMatches)!=null?T:[],enabled:m&&u!==!1}},Vd=Iy(My)(Ay);import{Fragment as nx,useEffect as Xs,useState as ox}from"react";import{useDispatch as jc,useSelector as Z}from"react-redux";import{createAction as $d,createAsyncThunk as Gd,createSlice as Dy}from"@reduxjs/toolkit";import{Marked as Oy}from"marked";var Xo=(t,e)=>{let n=[],o=new Oy,r=s=>{s.type==="code"&&s.lang===e&&n.push(s.text)};return o.use({walkTokens:r}),o.parse(t),n};var jd={cues:[],threads:{},pending:[]},qd=t=>{var e;return(e=t.assistants)==null?void 0:e.cues};var Xd=t=>e=>{var n,o;return(o=(n=e.assistants)==null?void 0:n.threads[t])!=null?o:null},Jo=$d("assistants/callToAction"),On=Gd("assistants/evaluateKnowledgeAssistant",(t,e)=>v(null,null,function*(){var l,c,p;let{threadId:n}=t,{onNewThreadId:o}=t,{deepdeskAPI:r}=e.extra,s=e.getState(),{platformVariables:i}=s.info;n||(n=(yield r.createAssistantThread({assistantCode:t.assistantCode})).id,o&&o(n)),yield r.postMessageToAssistantThread({assistantCode:t.assistantCode,threadId:n,message:t.input});let a=yield e.dispatch(ke(x(y({skipState:!0},t),{input:{},threadId:n})));if(a.error)throw new Error(a.error.message);let d=(l=a.payload.output[0])!=null?l:{response:"",sources:[]};return{threadId:n,question:t.input,evaluationId:a.payload.evaluationId,answer:{answer:(c=ge(d.response,i!=null?i:{}))!=null?c:"",sources:(p=d.sources)!=null?p:[]}}})),fM=$d("assistants/extractedTextSuggestions");function _y(t,e){var n,o;return Array.isArray(t.output)?t.output:typeof t.output=="string"?[{code:e,name:e,response:t.output}]:[x(y({code:e,name:e},t.output&&typeof t.output=="object"?t.output:{}),{response:(o=(n=t.output)==null?void 0:n.response)!=null?o:""})]}var ke=Gd("assistants/evaluate",(t,e)=>v(null,null,function*(){var g;let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra,{transcript:r,input:s={},threadId:i}=t,a=e.getState(),{platformVariables:d}=a.info,l=(g=a.conversation.current)==null?void 0:g.externalId,c;if(r==="in-memory-transcript"){if(!o.conversationQuery)throw new Error("Can't include in-memory-transcript, setConversationQuery is not defined");c=yield o.conversationQuery()}else Array.isArray(r)&&(c=r);if(t.includeMetadata){if(!a.conversation.current)throw new Error("Can't include metadata, no current conversation");let{metadata:h}=a.conversation.current;Object.assign(s,{metadata:h})}let p=yield n.evaluateAssistant(t.assistantCode,{input:s,transcript:c,externalConversationId:l,threadId:i});if(p.evaluationStatus!=="success")return e.rejectWithValue(`Assistant ${t.assistantCode} evaluation failed: ${p.evaluationStatus}`);let f=_y(p,t.assistantCode).map(h=>x(y({},h),{name:ge(h.name,d),response:ge(h.response,d)||""})),m=[];return f.forEach(h=>{if(!h.response)return;let b=Xo(h.response,"reply");b.length!==0&&m.push(...b.map(T=>({text:T,type:"text",source:"assistant",assistantCode:h.code,sourceLabel:h.name})))}),m.length>0&&e.dispatch(Nt(m)),x(y({},p),{output:f})})),Jd=Dy({name:"assistants",initialState:jd,reducers:{resetCues(t){t.cues=[]},removeCueByCode(t,e){t.cues=t.cues.filter(n=>n.code!==e.payload.code)},removeThreadById(t,e){delete t.threads[e.payload]},receiveChunk(t,e){let{code:n,name:o,payload:r,evaluationId:s}=e.payload,i=t.cues.findIndex(a=>a.code===n);i!==-1?t.cues[i].response+=r.text:t.cues.push({code:n,name:o,evaluationId:s,response:r.text})},userNotification(t,e){let n=t.cues.filter(d=>d.code!==e.payload.code),{code:o,name:r,evaluationId:s,payload:i}=e.payload,{callToAction:a}=i;t.cues=[...n,{code:o,name:r,evaluationId:s,response:i.message,editable:i.editableMessage,callToAction:a&&{label:a.displayName,event:a.onClickEvent,value:a.eventPayload}}]}},extraReducers:t=>{t.addCase(ke.pending,(e,n)=>{e.pending.includes(n.meta.arg.assistantCode)&&k.warn(`Assistant ${n.meta.arg.assistantCode} already evaluating`),e.pending.push(n.meta.arg.assistantCode)}).addCase(ke.rejected,(e,n)=>{var r;k.warn((r=n.error)==null?void 0:r.message);let o=e.pending.indexOf(n.meta.arg.assistantCode);o!==-1&&e.pending.splice(o,1)}).addCase(ke.fulfilled,(e,n)=>{let o=e.pending.indexOf(n.meta.arg.assistantCode);if(o!==-1&&e.pending.splice(o,1),n.meta.arg.skipState)return;let{evaluationId:r,output:s}=n.payload,i=s.map(l=>l.code),a=e.cues.filter(l=>!i.includes(l.code)),d=s.map(l=>x(y({},l),{evaluationId:r}));e.cues=[...a,...d]}).addCase(On.fulfilled,(e,n)=>{let s=n.payload,{threadId:o}=s,r=M(s,["threadId"]);e.threads[o]=[...e.threads[o]||[],r]}).addCase(V,()=>jd)}}),{removeCueByCode:Qo,resetCues:hM,removeThreadById:Qd,receiveChunk:Zd,userNotification:Yd}=Jd.actions,ec=Jd.reducer;import{createAsyncThunk as tc,createSlice as Fy}from"@reduxjs/toolkit";var Hy={token:null,interval:null},Ds=tc("passwordlessToken/getTemporaryPasswordlessToken",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra;return{token:yield n.requestPasswordlessToken()}})),_s=tc("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:n=1e3*60*10}=t,{dispatch:o}=e;return o(Ds()),setInterval(()=>o(Ds()),n)}),nc=Fy({name:"passwordlessToken",initialState:Hy,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Ds.fulfilled,(e,n)=>{e.token=n.payload.token}),t.addCase(_s.fulfilled,(e,n)=>{e.interval=n.payload})}}),{stopPollPasswordlessToken:oc}=nc.actions,rc=nc.reducer;import{createSelector as By}from"@reduxjs/toolkit";function Uy(t){return"buttonText"in t&&"eventName"in t}function sc(t){if(t)return Uy(t)?{label:t.buttonText,event:t.eventName,value:t.payload}:t}function Ky(t){return t==null?void 0:t.map(e=>sc(e))}function zy(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}var ic=By([qd],t=>t.map(n=>{let o=sc(n.callToAction),r=Ky(n.callToActions);return x(y(y(y({text:n.response,title:n.name},o?{callToAction:o}:{}),r!=null&&r.length?{callToActions:r}:{}),n.message!==void 0?{message:n.message}:{}),{editable:n.editable,isLoading:n.isLoading,evaluationId:n.evaluationId,rule:{id:zy(n.code),label:n.code,name:n.name,description:n.name}})}));import{useEffect as Wy,useState as Vy}from"react";import dc from"classnames";import{jsx as ac}from"react/jsx-runtime";var Vt=()=>ac("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:ac("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 lc={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};import{jsx as jt,jsxs as cc}from"react/jsx-runtime";var jy=({entities:t})=>{let e=S("EntitiesWidgetList",lc),[n,o]=Vy(void 0),r=K(),s=()=>{o(void 0)},i=a=>{t&&(o(t.indexOf(a)),be(a.text),r("entity copied",{entity:a,type:"copy"}))};return Wy(()=>{let a=setTimeout(s,500);return()=>{clearTimeout(a)}},[n]),!t||t.length===0?null:jt("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,d)=>cc("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[jt("span",{className:e.entityText,children:a.text}),cc("span",{className:e.iconWrapper,children:[jt("span",{className:dc(e.icon),children:jt(Vt,{})}),jt("span",{className:dc(e.icon,n===d&&e.iconClicked),children:jt(Vt,{})})]})]},a.text))})},uc=jy;import{jsx as pc}from"react/jsx-runtime";var gc=()=>pc("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:pc("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});import{useRef as Yy}from"react";import{useSelector as ev}from"react-redux";import{useRef as $y,useState as Fs}from"react";import{useDispatch as Gy}from"react-redux";function Zo(t,e){let n=$y(t);n.current=t;let[o,r]=Fs(void 0),[s,i]=Fs(void 0),[a,d]=Fs("idle"),l=Gy();return{error:s,state:a,data:o,call:u=>v(null,null,function*(){d("loading"),yield l(n.current(u)).unwrap().then(f=>{r(f),d("done"),e!=null&&e.onSuccess&&(e==null||e.onSuccess(f))}).catch(f=>{i(f),d("error"),e!=null&&e.onError&&(e==null||e.onError(f))})}),reset:()=>{d("idle"),r(void 0),i(void 0)}}}var mc={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var fc={root:"dd-nazq3",rotation:"dd-3EHTv"};import{jsx as Xy}from"react/jsx-runtime";var qy=({size:t=12})=>{let e=S("LoadingSpinner",fc);return Xy("span",{"data-testid":"loading-spinner",style:{width:`${t}px`,height:`${t}px`},className:e.root})},hc=qy;import{jsx as yc}from"react/jsx-runtime";var vc=()=>yc("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512",fill:"currentColor",children:yc("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"})});import{jsx as xc,jsxs as Jy}from"react/jsx-runtime";var Sc=t=>Jy("svg",x(y({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 448 512","aria-labelledby":"checkTitle"},t),{children:[xc("title",{id:"checkTitle",children:"Check"}),xc("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 Hs={};X(Hs,{enUS:()=>Qy,nlNL:()=>Zy});var Qy={error:[{type:0,value:"Something went wrong"}]},Zy={error:[{type:0,value:"Er ging iets fout"}]};import{jsx as Ue,jsxs as bc}from"react/jsx-runtime";var tv=3e3,nv=({assistantOptions:t})=>{let e=S("OnDemandAssistants",mc),n=R(Hs),o=Yy(),r=Zo(ke),s=ev($a),i=K(),a=s.filter(c=>c.isPinned),d=s.filter(c=>!c.isPinned),l=c=>v(null,null,function*(){clearTimeout(o.current),i("trigger on demand assistant",{assistantCode:c}),yield r.call(x(y({},t),{assistantCode:c})),o.current=setTimeout(()=>r.reset(),tv)});return s.length===0?null:bc("div",{className:e.root,children:[a.map(({assistant:c,assistantName:p,displayName:u})=>Ue("button",{type:"button",className:e.button,disabled:r.state==="loading",onClick:()=>l(c),children:u||p},c)),d.length>0&&bc($,{placement:"top-end",children:[Ue($.Trigger,{className:e.trigger,disabled:r.state==="loading",children:Ue(Eo,{"data-testid":"trigger"})}),Ue($.Content,{className:e.nav,"data-testid":"popover",children:d.map(({assistant:c,assistantName:p,displayName:u})=>Ue($.Button,{className:e.item,disabled:r.state==="loading",onClick:()=>l(c),children:u||p},c))})]}),r.state==="loading"&&Ue(hc,{}),r.state==="done"&&Ue(Sc,{"data-testid":"trigger-done"}),r.state==="error"&&Ue(il,{trigger:Ue(vc,{}),children:n("error")})]})},Cc=nv;import{useDispatch as Pv}from"react-redux";import{useRef as sv}from"react";var Tc={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};import{jsx as rv}from"react/jsx-runtime";var ov=({width:t})=>{let e=S("LoadingProgressBar",Tc);return rv("div",{className:e.loadingBar,style:{width:t}})},Yo=ov;import{jsx as $t,jsxs as iv}from"react/jsx-runtime";var er=({title:t})=>{let e=sv(null);return Gn(e),$t(I,{ref:e,children:$t(D,{children:iv(D.Content,{children:[$t(D.Title,{children:t}),$t(Yo,{width:"60%"}),$t(Yo,{width:"90%"}),$t(Yo,{width:"50%"})]})})})};var Dn={};X(Dn,{enUS:()=>av,nlNL:()=>lv});var av={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"}]},lv={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"}]};import{useEffect as Ac,useRef as Cv,useState as Tv}from"react";import Ks from"classnames";import{useState as uv}from"react";import{jsx as wc}from"react/jsx-runtime";var Bs=t=>wc("svg",x(y({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:wc("path",{fillRule:"evenodd",d:"M6.57086468,14.9173453 C6.38997052,14.9711236 6.19835748,15 6,15 L4,15 C2.8954305,15 2,14.1045695 2,13 L2,4 C2,2.8954305 2.8954305,2 4,2 L6,2 C6.68685475,2 7.29284112,2.34623869 7.65294381,2.87370078 C7.95642355,2.67736738 8.29504785,2.51351337 8.66312366,2.3818197 C9.50544052,2.08044754 10.3408482,1.9879107 10.9989281,1.99971266 C11.0150698,2.00005426 13.3487605,2.00015005 18,2 C20.7551411,2 22,6.05643086 22,12 C22,13.6824804 20.8695981,15 19,15 L15.9269768,15 C15.9359266,15.0245465 15.9451954,15.0497804 15.9547911,15.0757271 C16.007193,15.2174219 16.2391583,15.8256341 16.2970775,15.9810953 C16.4872151,16.4914441 16.6259612,16.9026411 16.7382242,17.3098712 C16.9079007,17.9253665 17,18.4798886 17,19 C17,20.4720069 16.091867,21.3862822 14.748281,21.777514 C14.1422801,21.9539723 13.6147967,22.0000922 13.0076976,22.0000008 L12.5204954,22 L12.2202699,21.6261158 C11.2556275,20.4248034 7.64562469,16.4822788 6.57086468,14.9173453 Z M8,13 C8,13.2401953 8.04443154,13.4528921 8.14171093,13.6800176 C8.40663864,14.2985643 11.914268,18.1371493 13.4599624,19.9848695 C13.7113931,19.9660111 13.9483736,19.9273712 14.1891338,19.8572655 C14.7621788,19.6904035 15,19.4509737 15,19 C15,18.6834183 14.9359344,18.2976852 14.8101464,17.8413935 C14.7161494,17.500423 14.5944107,17.1396301 14.4229225,16.6793379 C14.3689242,16.5344009 14.1358033,15.923159 14.0789589,15.7694517 C13.9489218,15.4178313 13.8632547,15.1589343 13.8046536,14.9236885 C13.5555377,13.9236468 13.8054549,13 15,13 L19,13 C19.6912225,13 20,12.6401099 20,12 C20,7.20925475 19.015127,4 18,4 C15.9322103,4 15.9322103,4 10.9655994,3.99940813 C10.5253746,3.99154158 9.91062406,4.05963657 9.33687634,4.2649175 C8.45196659,4.58152894 8,5.09776992 8,6 L8,13 Z M4,4 L4,13 L6,13 L6,4 L4,4 Z"})}));import{jsx as Ec}from"react/jsx-runtime";var kc=t=>Ec("svg",x(y({width:"16",height:"16",fill:"#000000"},t),{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Ec("path",{fillRule:"evenodd",d:"M7.65336736,21.1256786 C7.2933164,21.6534897 6.68712411,22 6,22 L4,22 C2.8954305,22 2,21.1045695 2,20 L2,11 C2,9.8954305 2.8954305,9 4,9 L6,9 C6.198171,9 6.38961023,9.02882212 6.57035446,9.08250314 C7.6444817,7.51807482 11.2554748,3.57449216 12.2202699,2.37298955 L12.5204954,1.99910538 L13,1.99910538 C13.6147967,1.99901314 14.1422801,2.04513312 14.748281,2.22159137 C16.091867,2.61282321 17,3.52709845 17,4.99910538 C17,5.51921677 16.9079007,6.07373891 16.7382242,6.68923415 C16.6259612,7.09646424 16.4872151,7.50766133 16.2970775,8.01801005 C16.2391583,8.17347129 16.007193,8.78168345 15.9547911,8.92337824 C15.9451954,8.94932503 15.9359266,8.9745589 15.9269768,8.99910538 L19,8.99910538 C20.8695981,8.99910538 22,10.316625 22,11.9991054 C22,17.9426745 20.7551411,21.9991054 18,21.9991054 L11.0344006,21.9985135 C10.3408482,22.0111947 9.50544052,21.9186578 8.66312366,21.6172857 C8.29521907,21.4856533 7.9567386,21.3218904 7.65336736,21.1256786 Z M8,17.9991054 C8,18.9013355 8.45196659,19.4175764 9.33687634,19.7341879 C9.91062406,19.9394688 10.5253746,20.0075638 10.963066,19.9997143 C10.9703499,19.9995545 10.9703499,19.9995545 11,19.9991054 L18,19.9991054 C19.015127,19.9991054 20,16.7898506 20,11.9991054 C20,11.3589955 19.6912225,10.9991054 19,10.9991054 L15,10.9991054 C13.8054549,10.9991054 13.5555377,10.0754586 13.8046536,9.07541689 C13.8632547,8.84017106 13.9489218,8.5812741 14.0789589,8.22965366 C14.1358033,8.07594642 14.3689242,7.46470447 14.4229225,7.31976744 C14.5944107,6.85947528 14.7161494,6.4986824 14.8101464,6.1577119 C14.9359344,5.70142019 15,5.31568707 15,4.99910538 C15,4.54813166 14.7621788,4.30870189 14.1891338,4.1418399 C13.9483736,4.07173418 13.7113931,4.0330943 13.4599624,4.01423587 C11.914268,5.86195611 8.40663864,9.70054105 8.14171093,10.3190878 C8.04443154,10.5462133 8,10.7589101 8,10.9991054 L8,17.9991054 Z M4,11 L4,20 L6,20 L6,11 L4,11 Z"})}));function Ze(t,e){var r;let n=t.cloneNode(!0);n.style.top=`${t.offsetTop}px`,n.style.left=`${t.offsetLeft}px`,n.style.position="absolute",e.split(" ").forEach(s=>{n.classList.add(s)}),n.addEventListener("animationend",()=>n.remove()),(r=t.parentElement)==null||r.appendChild(n)}var Us={};X(Us,{enUS:()=>dv,nlNL:()=>cv});var dv={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},cv={thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var Rc={thumbs:"dd-5F1zq",fadeup:"dd-eTmY-",fadedown:"dd-sS85z",selected:"dd-rid-f",thumbsUp:"dd-4poEf",thumbsDown:"dd-3KozS"};import{useSelector as Pc}from"react-redux";import{jsx as Gt,jsxs as gv}from"react/jsx-runtime";var pv=({assistantCode:t,assistantOutput:e,evaluationId:n,feedbackType:o,feedbackText:r})=>{let s=S("FeedbackThumbs",Rc),i=E("enableFeedbackForm"),a=Pc(Se),d=Pc(Xe(`/admin/feedback?conversationId=${a}&evaluationId=${n}&type=${o}&text=${r}&assistantCode=${t}&assistantOutput=${e}`)),l=R(Us),c=K(),[p,u]=uv(null),f=h=>{c("Assistant response feedback",{assistantCode:t,assistantOutput:e,evaluationId:n,rating:h})},m=h=>{h.stopPropagation(),Ze(h.target,s.fadeup),u("up"),f("up")},g=h=>{h.stopPropagation(),Ze(h.target,s.fadedown),u("down"),f("down")};return gv("div",{className:s.thumbs,children:[Gt(I.Button,{title:l("thumbsUp"),onClick:m,icon:Gt(kc,{}),className:Ks(s.thumbsUp,p==="up"&&s.selected),disabled:!!p}),i&&d?Gt(I.Button,{as:"a",title:l("thumbsDown"),href:d,target:"_blank",rel:"noreferrer",onClick:g,icon:Gt(Bs,{}),className:Ks(s.thumbsDown,p==="down"&&s.selected),disabled:!!p}):Gt(I.Button,{title:l("thumbsDown"),onClick:g,icon:Gt(Bs,{}),className:Ks(s.thumbsDown,p==="down"&&s.selected),disabled:!!p})]})},tr=pv;import mv from"dompurify";import{Fragment as Lc,useMemo as fv,useRef as hv,useState as yv}from"react";var Ic={root:"dd-L7b3z",popover:"dd-OQOTB",options:"dd-Y12RE",arrow:"dd-cv33T",copyIcon:"dd-6xOsH",option:"dd-9oFX4",divider:"dd-aiZf8",fadeup:"dd-Jq9pd"};import{marked as vv}from"marked";import{jsx as _n,jsxs as nr}from"react/jsx-runtime";function xv(t){return`<button type="button" data-copy-icon class=${t}><svg version="1.1" x="0px" y="0px" viewBox="0 0 115.77 122.88" width="10px" height="10px" fill="black"><g><path d="M89.62,13.96v7.73h12.19h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02v0.02 v73.27v0.01h-0.02c-0.01,3.84-1.57,7.33-4.1,9.86c-2.51,2.5-5.98,4.06-9.82,4.07v0.02h-0.02h-61.7H40.1v-0.02 c-3.84-0.01-7.34-1.57-9.86-4.1c-2.5-2.51-4.06-5.98-4.07-9.82h-0.02v-0.02V92.51H13.96h-0.01v-0.02c-3.84-0.01-7.34-1.57-9.86-4.1 c-2.5-2.51-4.06-5.98-4.07-9.82H0v-0.02V13.96v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07V0h0.02h61.7 h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02V13.96L89.62,13.96z M79.04,21.69v-7.73v-0.02h0.02 c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v64.59v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h12.19V35.65 v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07v-0.02h0.02H79.04L79.04,21.69z M105.18,108.92V35.65v-0.02 h0.02c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v73.27v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h61.7h0.02 v0.02c0.91,0,1.75-0.39,2.37-1.01c0.61-0.61,1-1.46,1-2.37h-0.02V108.92L105.18,108.92z"/></g></svg></button>`}function zs(t){var n,o;let e=t.cloneNode(!0);return e.querySelectorAll("div,button").forEach(r=>r.remove()),(o=(n=e.textContent)==null?void 0:n.trim())!=null?o:""}function Sv(t){return t.replace(/\r\n/g,`
8
- `)}var bv=({content:t,useLabel:e,copyLabel:n,onCopy:o,onUse:r})=>{let s=S("Markdown",Ic),i=hv(null),[a,d]=yv(null),l=fv(()=>{let g=vv.parse(Sv(t));return mv.sanitize(g.toString()).replaceAll("</code>",`${xv(s.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[t]),c=g=>{var T;let h=g.target,b=!!((T=i.current)!=null&&T.querySelector("code"));if(["A","BUTTON"].includes(h.tagName)){d(null);return}a||b&&h.tagName!=="CODE"||!b&&h!==i.current||(h.addEventListener("mouseleave",()=>d(null),{once:!0}),d(h))},p=()=>{if(!a)return;d(null);let g=a.querySelector("button");g&&(Ze(g,s.fadeup),o==null||o(zs(a)))},u=g=>{let h=g.target,b=h instanceof HTMLElement?h:null;if(h instanceof Element?h.closest("a"):null){g.stopPropagation();return}b&&"copyIcon"in b.dataset&&(Ze(b,s.fadeup),o==null||o(zs(b.parentElement)))},f=()=>{!a||!r||(d(null),r(zs(a)))},m=g=>{if(g===null)return;let h=g.getBoundingClientRect();h.left<0?g.style.transform=`translateX(${-h.left+2}px)`:h.right>window.innerWidth&&(g.style.transform=`translateX(${window.innerWidth-h.right-2}px)`)};return nr(Lc,{children:[a&&(o||r)&&nr(zt,{triggerRef:{current:a},className:s.popover,parentNode:a,children:[nr("div",{className:s.options,ref:m,children:[o&&(a==null?void 0:a.tagName)==="CODE"&&_n("button",{type:"button",className:s.option,onClick:p,children:n}),r&&nr(Lc,{children:[_n("div",{className:s.divider}),_n("button",{type:"button",className:s.option,onClick:f,children:e})]})]}),_n("div",{className:s.arrow})]}),_n("div",{ref:i,"data-testid":"widget-markdown-content",className:s.root,dangerouslySetInnerHTML:{__html:l},onMouseOver:c,onClick:u})]})},vt=bv;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"};import{jsx as ve,jsxs as or}from"react/jsx-runtime";var wv=500,Ev=100,kv=({content:t,onChange:e,onCopy:n})=>{let o=Cv(null),r=S("WidgetCue",Ws);return Ac(()=>{let s=o.current;if(!s)return;s.style.setProperty("height","0px");let i=Math.min(Math.max(s.scrollHeight,Ev),wv);s.style.setProperty("height",`${i}px`)},[t]),ve("textarea",{ref:o,className:r.editableCue,onCopy:n,onChange:e,value:t})},Rv=({cue:t,onCallToAction:e,onRemove:n,onCopy:o,onUse:r})=>{var g;let s=S("WidgetCue",Ws),i=R(Dn),a=K(),d=E("hasKeyboardInput"),[l,c]=Tv(t.text),p=h=>{let b=h?x(y({},t),{callToAction:h}):t;e&&e(l,b),n(t)},u=(h,b)=>{o&&o(h,t),b&&Ze(b,s.fadeup)},f=h=>{r&&r(h,t)},m=h=>{h.preventDefault(),h.stopPropagation(),n(t)};return Ac(()=>{a("Assistant response displayed",{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text})},[]),or(I,{"data-testid":"cue",children:[ve(D,{children:or(D.Content,{children:[t.title&&ve(D.Title,{className:s.title,"data-testid":"widget-cue-title",children:t.rule.label.startsWith("__")?i(t.rule.label):t.title}),t.message&&ve("p",{className:s.ctaMessage,children:t.message}),t.editable?ve(kv,{content:l,onCopy:()=>{let h=document.getSelection();h&&u(h.toString())},onChange:h=>{var b;return c((b=h.target.value)!=null?b:"")}}):ve(vt,{content:t.text,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:u,onUse:d?f:void 0})]})}),or(I.ButtonsContainer,{children:[or("div",{className:s.actions,children:[ve(I.Button,{onClick:h=>{var b;return u((b=Xo(l,"reply")[0])!=null?b:l,h.target)},variant:"primary",children:i("copyCue")}),t.callToAction&&ve(I.Button,{onClick:()=>p(),variant:"primary",children:t.callToAction.label}),(g=t.callToActions)==null?void 0:g.map((h,b)=>ve(I.Button,{onClick:()=>p(h),variant:"primary",children:h.label},`${h.event}-${h.label}-${b}`)),ve(I.Button,{onClick:m,variant:"secondary",children:i("removeCue")})]}),ve(tr,{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text,feedbackText:t.text,feedbackType:"assistant"})]})]})},Mc=Rv;import{Fragment as Lv,jsx as Vs}from"react/jsx-runtime";var Iv=({cues:t})=>{let e=Pv(),n=ne(),o=R(Dn),r=K(),s=l=>{e(Qo({code:l.rule.label})),r("Assistant response closed",{evaluationId:l.evaluationId,assistantCode:l.rule.label,assistantOutput:l.text})},i=(l,c)=>{be(l),r("Assistant response copied",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,copiedText:l})},a=(l,c)=>{var p;c.callToAction&&(e(Jo(c)),r("Assistant call to action",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,eventName:c.callToAction.event,value:(p=c.callToAction.value)!=null?p:l}))},d=(l,c)=>{var p;n.send(Me,{text:l,suggestion:{source:"assistant",assistantCode:(p=c.rule)==null?void 0:p.label,sourceText:l}}),r("Assistant response used",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,usedText:l})};return Vs(Lv,{children:t.map(l=>l.isLoading?Vs(er,{title:l.rule.label.startsWith("__")?o(l.rule.label):l.title},l.rule.id):Vs(Mc,{cue:l,onCallToAction:a,onRemove:s,onCopy:i,onUse:d},l.evaluationId))})},Nc=Iv;import{Fragment as Av,useEffect as Mv}from"react";var Oc={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};import{jsx as Ke,jsxs as js}from"react/jsx-runtime";function Nv(t,e){return e.split(".").reduce((n,o)=>!n||typeof n!="object"||!(o in n)?null:n[o],t)}var Dc=({data:t,schema:e})=>{let n=S("WidgetCustomData",Oc),o=r=>{be(r)};return Mv(()=>{k.info("Custom data",t,e)},[t]),Ke("dl",{className:n.root,children:e.map(r=>{let s=Nv(t,r.path);return js(Av,{children:[Ke("dt",{className:n.label,children:r.label}),Ke("dd",{className:n.value,children:r.type==="boolean"&&s?Ke("span",{className:n.isTrue,children:r.trueValue}):r.type==="boolean"&&!s?Ke("span",{className:n.isFalse,children:r.falseValue}):r.type==="array"&&Array.isArray(s)&&s.length>0?js("button",{type:"button",onClick:()=>o(s.join(", ")),className:n.copyButton,children:[Ke("span",{className:n.copyButtonText,children:s.join(", ")}),Ke(Vt,{})]}):typeof s=="string"||typeof s=="number"?js("button",{type:"button",onClick:()=>o(`${s}`),className:n.copyButton,children:[Ke("span",{className:n.copyButtonText,children:s}),Ke(Vt,{})]}):"-"})]},r.label)})})};import{createContext as Uv,Fragment as Kv,useContext as Gs,useEffect as zv,useRef as Bc,useState as xt}from"react";import{useDispatch as Wv,useSelector as Vv}from"react-redux";var qt={};X(qt,{enUS:()=>Ov,nlNL:()=>Dv});var Ov={inputPlaceholder:[{type:0,value:"What is your question?"}],useCue:[{type:0,value:"Add to message"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Submit"}],resetLabel:[{type:0,value:"Reset"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},Dv={inputPlaceholder:[{type:0,value:"Wat is je vraag?"}],useCue:[{type:0,value:"Voeg toe aan bericht"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Verzend"}],resetLabel:[{type:0,value:"Gesprek wissen"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var rr={form:"dd-pleCH",formInput:"dd-pGJMY",formSubmit:"dd--gkRg",actionButton:"dd-I2NEH",resetContainer:"dd-qKIDX",sources:"dd-xf9c6",source:"dd-a-vyX",tooltip:"dd-EsgcZ",linkContent:"dd-gARDA",showMoreSources:"dd-uDGi-"};import{useRef as Hv}from"react";var _c={error:"dd-CoAuB"};var $s={};X($s,{enUS:()=>_v,nlNL:()=>Fv});var _v={errorPrefix:[{type:0,value:"Error:"}]},Fv={errorPrefix:[{type:0,value:"Foutmelding:"}]};import{jsx as Fc,jsxs as Bv}from"react/jsx-runtime";var Hc=({message:t})=>{let e=Hv(null),n=S("WidgetCardError",_c),o=R($s);return Gn(e),Fc(I,{ref:e,children:Fc(D,{children:Bv(D.Content,{className:n.error,children:[o("errorPrefix")," ",t]})})})};import{jsx as H,jsxs as ze}from"react/jsx-runtime";var jv=3,$v=({sources:t,onClick:e})=>{let n=R(qt),o=S("WidgetKnowledgeAssistant",rr),[r,s]=xt(!1),i=r?t:t.slice(0,jv);return i.length===0?null:ze("ul",{className:o.sources,children:[i.map(a=>H("li",{className:o.source,"data-testid":"knowledge-assist-source",children:ze($,{tooltip:!0,placement:"top-start",children:[H($.Trigger,{as:"a",rel:"noreferrer",target:"_blank",href:a.url,onClick:d=>{d.stopPropagation(),e(a)},children:H("span",{className:o.linkContent,children:a.name})}),a.url&&H($.Content,{className:o.tooltip,children:decodeURIComponent(a.url)})]})},a.name)),i<t&&H("button",{type:"button",className:o.showMoreSources,onClick:()=>s(!0),children:n("showMore",{amount:t.length-i.length})})]})},Gv=({title:t,description:e})=>H(I,{"data-testid":"knowledge-assist-empty-state",children:H(D,{children:ze(D.Content,{children:[H(D.Title,{children:t}),H(vt,{content:e})]})})}),qv=({innerRef:t,item:e,hasKeyboardInput:n,onCopy:o,onUse:r,onSourceClick:s})=>{var d;let i=R(qt),a=Gs(sr);return ze(I,{"data-testid":"knowledge-assist-answer",ref:t,children:[H(D,{children:ze(D.Content,{children:[H(D.Title,{children:e.question}),H(vt,{content:e.answer.answer,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:o,onUse:n?r:void 0}),H($v,{sources:(d=e.answer.sources)!=null?d:[],onClick:s})]})}),a.assistantCode&&ze(I.ButtonsContainer,{children:[H("div",{}),H(tr,{evaluationId:e.evaluationId,feedbackType:"assistant",assistantCode:a.assistantCode,assistantOutput:e.answer.answer,feedbackText:e.answer.answer})]})]})},sr=Uv(null),ir=({assistantCode:t,evaluateKnowledgeAssistFn:e,initialQuestion:n,children:o})=>{let[r,s]=xt(null),[i,a]=xt(!1),[d,l]=xt(null),[c,p]=xt(!!n),[u,f]=xt(null),m=Wv(),g=K(),h=Zo(C=>{if(!t)throw new Error("No knowledge assistant was defined");return l(null),e({assistantCode:t,input:C,threadId:r,onNewThreadId(w){s(w)}})},{onSuccess(C){var w;g("Assistant response displayed",{evaluationId:C.evaluationId,assistantCode:t,assistantOutput:C.answer.answer,input:C.question,sources:(w=C.answer.sources)!=null?w:[]}),p(!1)},onError(C){var w;l((w=C.message)!=null?w:"Unknown error")}}),b=C=>v(null,null,function*(){a(!0),f(C),yield h.call(C),a(!1),f(null)}),T={isEnabled:!!t,assistantCode:t,isSubmitting:i,threadId:r,pendingInput:u,errorMessage:d,onSubmit:b,onReset(){r&&m(Qd(r)),l(null),s(null),t&&g("Assistant thread reset",{threadId:r!=null?r:void 0,assistantCode:t})}};return zv(()=>{n&&T.isEnabled&&b(n)},[n]),H(sr.Provider,{value:T,children:o})},ar=()=>{let t=R(qt),e=S("WidgetKnowledgeAssistant",rr),n=Gs(sr),o=Bc(null),[r,s]=xt(""),i=d=>{s(d.target.value)},a=d=>{d.preventDefault(),n.onSubmit(r).then(()=>{var l;o.current&&((l=o.current)==null||l.focus(),s(""))})};return n.isEnabled?ze("form",{className:e.form,onSubmit:a,children:[H("input",{ref:o,className:e.formInput,placeholder:t("inputPlaceholder"),type:"text",disabled:n.isSubmitting,value:r,onChange:i}),H("button",{type:"submit",disabled:n.isSubmitting||r==="",className:e.formSubmit,children:t("submitLabel")})]}):null},lr=({title:t,emptyState:e})=>{var m,g;let n=R(qt),o=K(),r=S("WidgetKnowledgeAssistant",rr),s=Bc(null),i=Gs(sr),a=(g=Vv(Xd((m=i.threadId)!=null?m:-1)))!=null?g:[],d=E("hasKeyboardInput"),l=ne(),c=(h,b)=>{be(h),i.assistantCode&&o("Assistant response copied",{assistantCode:i.assistantCode,assistantOutput:h,copiedText:h,evaluationId:b.evaluationId})},p=(h,b)=>{i.assistantCode&&o("Assistant source clicked",{evaluationId:b.evaluationId,assistantCode:i.assistantCode,source:h})},u=h=>{h.preventDefault(),i.onReset()},f=(h,b)=>{l.send(Me,{text:h,suggestion:{source:"assistant",sourceText:h}}),i.assistantCode&&o("Assistant response used",{assistantCode:i.assistantCode,evaluationId:b.evaluationId,assistantOutput:b.answer.answer,usedText:h})};return!i.isEnabled||(a==null?void 0:a.length)===0&&!i.isSubmitting&&!e&&!i.errorMessage?null:ze(Kv,{children:[H(Le,{type:"knowledge",title:t,"data-testid":"knowledge",children:ze(te,{withDivider:!0,children:[e&&a.length===0&&!i.pendingInput&&H(Gv,y({},e)),a.map((h,b)=>H(qv,{innerRef:b===a.length-1?s:void 0,item:h,hasKeyboardInput:d,onCopy:T=>c(T,h),onUse:T=>f(T,h),onSourceClick:T=>p(T,h)},`${h.question}_${h.answer}_${b}`)),i.pendingInput&&H(er,{title:i.pendingInput}),i.errorMessage&&H(Hc,{message:i.errorMessage})]})}),a.length>0&&H("div",{className:r.resetContainer,children:H(I.Button,{disabled:i.threadId===null||i.isSubmitting,onClick:u,children:n("resetLabel")})})]})};import{useCallback as Jv}from"react";var Xv=/(https?:\/\/[^\s]+)/,Kc=t=>t.split(" ").find(e=>Xv.test(e));import{jsx as Xt,jsxs as dr}from"react/jsx-runtime";var Qv=({suggestion:t,lines:e,onUse:n})=>{var p;let o=t.text||t.url||t.message,r=Kc(o),s=R(In),i=E("showImages"),a=E("fallbackImage"),d=E("hasKeyboardInput"),l=u=>{u.preventDefault(),u.stopPropagation(),d&&n(o)},c=Jv(u=>{window.open(r,"_blank"),u.stopPropagation(),u.preventDefault()},[r]);return dr(I,{onClick:d?l:void 0,"data-testid":"edit-suggestion",children:[dr(D,{children:[i&&t.image&&Xt(D.Image,{src:$o(t,"small",a||void 0),title:t.title}),dr(D.Content,{children:[t.title&&Xt(D.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((p=t.searchKeywords)==null?void 0:p.length)>0&&Xt(I.Labels,{labels:t.searchKeywords}),Xt(D.Content,{cropText:e==="single",lineClamp:e==="multiple",children:o})]})]}),dr(I.Actions,{children:[r&&Xt(I.ActionButton,{onClick:c,label:s("visitUrl")}),d&&Xt(I.ActionButton,{primary:!0,onClick:l,label:s("useSuggestion")})]})]})},zc=Qv;import{Fragment as Yv,jsx as Wc}from"react/jsx-runtime";var Zv=({lines:t,suggestions:e})=>{let n=ne(),o=(r,s)=>{n.send(Me,{text:r,suggestion:x(y({},s),{source:s.source,sourceText:s.text})})};return Wc(Yv,{children:e.map(r=>Wc(zc,{suggestion:r,lines:t,onUse:s=>o(s,r)},r.text||r.url||r.message))})},Vc=Zv;var Fn={};X(Fn,{enUS:()=>ex,nlNL:()=>tx});var ex={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"}]},tx={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 Jt={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",footer:"dd-tvofr",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",footerShortcut:"dd-dH7XJ",link:"dd-DRo0x"};import{jsx as P,jsxs as Hn}from"react/jsx-runtime";var $c=(t,e)=>{let n=Z(J);Xs(()=>n?e.every(o=>!!o)?t():()=>{}:()=>{},[...e,n])},rx=({onLogIn:t})=>{let e=S("Widget",Jt),n=E("isEmbedded"),o=E("adminUrl");return P("div",{className:e.loginText,children:P("div",{children:P(Ho,{isEmbedded:n,loginUrl:o,onLogIn:t})})},"login")},qs=({text:t})=>{let e=S("Widget",Jt);return P("div",{className:e.stateText,children:P("div",{children:P("p",{children:t})})},"notification")},sx=()=>{let t=R(Fn),e=jc(),n=S("Widget",Jt),o=E("showSearch"),r=E("isEmbedded"),s=Z(Xe("/admin/")),i=ne(),a=E("productName"),d=K();return $c(()=>{if(r)return e(_s()),()=>{e(oc())}},[e,r]),!o&&!s?null:Hn("div",{className:n.shortcutList,children:[o&&P(I.Button,{"data-testid":"shortcut-search","aria-label":t("linkSearch"),className:n.shortcut,icon:P(Bt,{}),onClick:()=>{i.send("ShowCommandPalette",{isOpen:!0}),d("open search",{via:"widget-shortcut"})},children:t("linkSearch")}),s&&P(I.Button,{as:"a",target:"_blank",icon:P(gc,{}),href:s,"data-testid":"shortcut-studio-login","aria-label":t("linkStudioLogin",{productName:a}),className:n.shortcut,rel:"noreferrer",onClick:()=>{d("open my deepdesk",{via:"widget-shortcut"})},children:t("linkStudioLogin",{productName:a})})]})},ix=({title:t,content:e})=>{let n=R(Fn),[o,r]=ox(!0);return o?P(Le,{"data-testid":"custom-data-banner",type:"custom-data-banner",title:t,children:P(te,{withDivider:!0,children:Hn(I,{children:[P(D,{children:P(D.Content,{children:P(vt,{content:e})})}),P(I.ButtonsContainer,{children:P(I.Button,{onClick:()=>r(!1),children:n("close")})})]})})}):null},ax=()=>{let t=jc(),e=Z(kn),n=Z(qa),o=Z(ic),r=Z(pa),s=Z(wo),i=Z(Io),a=Z(dt),d=Z(Se);return Xs(()=>{r&&!n&&k.warn("Custom data provided, but no schema.")},[r,n]),$c(()=>{e.forEach(({type:l})=>{l==="entities"?t(fe()):Xn.includes(l)||t(he(l))})},[t,d,a]),Xs(()=>{o.length>0&&!e.some(l=>l.type==="cues")&&k.warn("Received cues, but cues are not configured in widget.")},[e,o]),P(nx,{children:e.map(({type:l,title:c,amount:p,lines:u,schema:f,property:m})=>{var g,h;switch(l){case"entities":return s&&s.length>0&&P(Le,{type:l,title:c,"data-testid":`type-${l}`,children:P(uc,{entities:s})},l);case"cues":return o&&o.length>0&&P(Le,{type:l,title:c,"data-testid":`type-${l}`,children:P(te,{withDivider:!0,children:P(Nc,{cues:o})})},l);case"custom-data-banner":return r&&m&&r[m]&&P(ix,{title:c,content:String(r[m])},l);case"custom-data":return r&&f&&P(Le,{type:l,title:c,"data-testid":`type-${l}`,children:P(te,{withDivider:!0,children:P(Dc,{data:r,schema:f})})},l);default:return((h=(g=i[l])==null?void 0:g.suggestions)==null?void 0:h.length)>0&&P(Le,{type:l,title:c,"data-testid":`type-${l}`,children:P(te,{withDivider:!0,children:P(Vc,{lines:u,contentType:l,suggestions:i[l].suggestions.slice(0,p)||[]})})},l)}})})},Js=({children:t})=>{let e=S("Widget",Jt);return P("div",{className:e.footer,children:t})},Qs=({children:t})=>{let e=S("Widget",Jt);return P("div",{className:e.root,"data-testid":"widget",children:t})},lx=({onLogIn:t,knowledgeAssistOptions:e={},assistantOptions:n={transcript:"in-memory-transcript"}})=>{let o=R(Fn),r=Z(Lt),s=Z(J),i=Z(Xi),a=Z(dt),d=Z(Ga("knowledge-assist")),l=Z(Xa);return r===!1?P(qs,{text:o("notSupported")}):s===!1?P(rx,{onLogIn:t}):s===null?P(qs,{text:o("waiting")}):!i||!a?P(qs,{text:o("waitingForConversation")}):P(Qs,{children:Hn(ir,{initialQuestion:e.initialQuestion,assistantCode:l!=null?l:void 0,evaluateKnowledgeAssistFn:On,children:[Hn(sn,{children:[P(sx,{}),P(ax,{}),d&&P(lr,{title:d.title,emptyState:e.emptyState})]}),Hn(Js,{children:[d&&P(ar,{}),P(Cc,{assistantOptions:n})]})]})})},Gc=lx;function Un(t){let e=new Range;return e.selectNodeContents(t),e}function qc(t,e,n){try{return St(t,e,n),!0}catch(o){return!1}}function cr(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function ur(t){return"tagName"in t&&t.tagName==="BR"}var Bn=/[\u200B-\u200D\uFEFF]/g;function St(t,e,n){let o=new Range;if(t.firstChild===null&&e===0&&n===0)return o.selectNodeContents(t),o;let r=0,s=!1;function i(d,l){let c=-1,p=/[\u200B-\u200D\uFEFF]/;if(!p.test(d))return l;for(let u=0;u<=d.length;u++)if(p.test(d[u])||c++,c===l)return u;throw new Error("Offset out of range")}function a(d){switch(d.nodeType){case Node.TEXT_NODE:{let l=d.textContent,c=l.replace(Bn,""),p=r+c.length,u=e>=r&&e<=p,f=n>=r&&n<=p;if(u){let m=i(l,e-r);m===0&&!f?o.setStartBefore(d):o.setStart(d,m)}f&&(o.setEnd(d,i(l,n-r)),s=!0),r=p;break}case Node.ELEMENT_NODE:{if(ur(d)&&(r===e&&o.setStartBefore(d),r++,r===n)){o.setEndAfter(d),s=!0;return}for(let c=0;c<d.childNodes.length&&(a(d.childNodes[c]),!s);c++);let l=d.lastChild;cr(d)&&l&&!cr(l)&&!ur(l)&&r++;break}default:break}}if(a(t),o.startContainer===document)throw new Error("Offsets out of bound");return o}function pr(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:r,endOffset:s,collapsed:i}=e,a,d,l=0;function c(p){let u=p===t,f=p===n,m=p===r;switch(p.nodeType){case Node.TEXT_NODE:{let g=p.textContent;f&&(a=l+g.substring(0,o).replace(Bn,"").length),m&&(d=l+g.substring(0,s).replace(Bn,"").length),l+=g.replace(Bn,"").length;break}case Node.ELEMENT_NODE:{if(ur(p)&&p.nextSibling){l++;break}!u&&cr(p)&&p.previousSibling&&l++;for(let g=0;g<p.childNodes.length;g++){let h=f&&g===o,b=m&&g===s;if(h&&(a=l),b&&(d=l),d!==void 0||((!h||!i)&&c(p.childNodes[g]),m&&g===s-1&&(d=l),d!==void 0))break}m&&(d=l);break}default:break}}if(c(t),d===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:d,end:d}}function gr(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:r,endOffset:s,collapsed:i}=e,a=0,d="";function l(c){let p=c===t,u=c===n,f=c===r;switch(u&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let m=u?o:0,g=f?s:void 0;d+=c.textContent.replace(Bn,"").substring(m,g);break}case Node.ELEMENT_NODE:{if(!i&&a===1&&ur(c)&&c.nextSibling){d+=`
9
- `;break}!p&&!i&&a===1&&cr(c)&&c.previousSibling&&(d+=`
10
- `);let m=u?o:0,g=f?Math.min(s,c.childNodes.length):c.childNodes.length;for(let h=m;h<g&&(l(c.childNodes[h]),a!==2);h++);break}default:break}f&&(a=2)}return l(t),d}var Xc=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(Xc||{}),Ye=class{constructor(e){this.element=e;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(e,n){let o=r=>{n(r)};this.element.addEventListener(e,o),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,o)})}removeEventListener(e,n){this.element.removeEventListener(e,n)}handleInteraction(){let e=this.getText(),n=this.getHTML(),o=this.getSelection(),r=this.cachedCaretPosition===null;if(!this.isActive||(e===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),e!==this.cachedText?(this.cachedText=e,this.cachedHTML=n,r=!0,this.emit("change",{plainText:e,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,r=!0,this.emit("change",{plainText:e,rawHTML:n})),(o.start!==this.cachedSelection.start||o.end!==this.cachedSelection.end)&&(this.cachedSelection=o,r=!0,this.emit("selection",o)),!r))return;let s=this.getCaretPosition();$e(s,this.cachedCaretPosition)||(this.cachedCaretPosition=s,this.emit("caretposition",s))}handleClick(){this.handleInteraction()}handleFocus(){let e=!this.isFocused;this.isFocused=!0,e&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let e=this.isFocused;this.isFocused=!1,e&&this.emit("blur")}handleKeyDown(e){let{key:n,ctrlKey:o,metaKey:r}=e;this.isPossibleClearInputAction=Object.values(Xc).includes(n)||n.toLowerCase()==="z"&&(o||r),this.emit("keydown",e)}handleKeyUp(e){this.handleInteraction(),this.emit("keyup",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var o,r;let n=((o=e.clipboardData)==null?void 0:o.getData("text"))||((r=e.clipboardData)==null?void 0:r.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 e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()})}focus(){this.element.focus()}emit(e,...n){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(o=>{o(...n)})}on(e,n){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n))}off(e,n){if(!this.eventListeners[e])return;let o=this.eventListeners[e].indexOf(n);o!==-1&&this.eventListeners[e].splice(o,1)}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};function Jc(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Qt=class extends Ye{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),gr(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){let n=this.getRootNode();if(n.activeElement!==this.element)return null;let o="getSelection"in n?n.getSelection():window.getSelection();if(!o)return null;let r=o.rangeCount>0?o.getRangeAt(0):null;if(!r)return null;let s=this.element.ownerDocument.createRange();return s.setStart(r==null?void 0:r.startContainer,r==null?void 0:r.startOffset),s.setEnd(r==null?void 0:r.endContainer,r==null?void 0:r.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 o=n.getBoundingClientRect();return!Jc(o)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=n.getBoundingClientRect(),n.deleteContents(),!Jc(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let n=this.getRange();if(n)return pr(this.element,n);let o=this.lastKnownSelection;if(o&&qc(this.element,o.start,o.end))return o;let r=Un(this.element);return r.collapse(!1),pr(this.element,r)}getSelectedText(){let{start:n,end:o}=this.getSelection();return gr(this.element,St(this.element,n,o))}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 o=this.element.isContentEditable,r=new MutationObserver(()=>{this.element.isContentEditable!==o&&(o=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>r.disconnect())}};var dx=["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 Qc(t,e){let n="mozInnerScreenX"in window,o=document.createElement("div");o.id="input-textarea-caret-position-mirror-div";let r=o.style,s=window.getComputedStyle(t),i=t.ownerDocument.body;r.whiteSpace="pre-wrap",r.wordWrap="break-word",r.position="absolute",r.visibility="hidden",dx.forEach(c=>{r[c]=s[c]}),n?t.scrollHeight>Number.parseInt(s.height)&&(r.overflowY="scroll"):r.overflow="hidden",o.textContent=t.value.substring(0,e);let a=document.createElement("span");a.textContent=t.value.substring(e)||".",o.appendChild(a),i.appendChild(o);let d=t.getBoundingClientRect(),l={top:d.top-t.scrollTop+a.offsetTop+Number.parseInt(s.borderTopWidth)+a.offsetHeight,left:d.left-t.scrollLeft+a.offsetLeft+Number.parseInt(s.borderLeftWidth)};return i.removeChild(o),l}var Zt=class extends Ye{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:o}=this.element;return{start:n,end:o}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return Qc(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 o=this.element.disabled,r=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>r.disconnect())}};function Zc(t,e,n){let o=`deepdesk-iframe-${t}`,r=document.getElementById(o);if(r)return r;let s=document.createElement("iframe"),i=new URL(e);return Object.entries(n).forEach(([a,d])=>{i.searchParams.append(a,d)}),s.style.position="absolute",s.style.left="-999em",s.style.width="0px",s.style.height="0px",s.tabIndex=-1,s.id=o,s.title=`iframe-${t}`,s.src=i.toString(),window.document.body.appendChild(s),s}function cx(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch(e){return t}}var Zs=class{constructor(e){this.name=e;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(e)}onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(JSON.stringify(e))}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},Ys=class{constructor(e,n,o){this.name=e;this.targetOrigin=n;this.options=o;this.disposeHandlers=[];this.iframe=Zc(e,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(e),this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(n=>n()),(e=this.iframe)==null||e.remove()}},ei=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.externalId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setExternalId(e){this.externalId!==e&&(this.cleanup(),k.info("Set externalId",e),this.externalId=e,this.channel=this.createChannel(e))}createChannel(e){let n=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new Ys(e,this.deepdeskUrl,{debug:!0}):new Zs(e),o=r=>{var i,a;if(r.origin!==this.deepdeskUrl)return;let s=cx(r.data);typeof s!="object"||s.type!=="event"||s.channel!==e||(k.info("Received broadcast event",this.externalId,r),(a=(i=this.eventMap)[s.name])==null||a.call(i,s.payload))};return n.onMessage(o),n}send(e,n,o){var i,a;k.info("Broadcast event",{externalId:this.externalId,name:e,payload:n});let r={type:"event",name:e,payload:n};o!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,n));let s=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage(x(y({},r),{channel:this.externalId}))}cleanup(e=!1){var n,o;(n=this.channel)==null||n.close(),this.channel=void 0,e&&((o=this.defaultChannel)==null||o.close(),this.defaultChannel=void 0)}},Yc=ei;function ux(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function B(t){return Array.isArray(t)?t.map(B):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>x(y({},e),{[ux(n)]:B(t[n])}),{}):t}function px(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function Y(t){return Array.isArray(t)?t.map(Y):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>x(y({},e),{[px(n)]:Y(t[n])}),{}):t}var Yt=class extends Error{constructor(n,o){super(n);this.body=o;this.name="CustomError"}};var ti=t=>new Promise(e=>{setTimeout(e,t)});var bt=class extends Yt{constructor(){super(...arguments);this.name="ClientError"}},oi=class extends Yt{constructor(){super(...arguments);this.name="ServerError"}},ni=new Map;function gx(t){return v(this,null,function*(){if(t.status===204)return t.text().catch(()=>{}),null;let e=t.headers.get("content-type");if(e!=null&&e.includes("application/json"))return t.json();let n=yield t.text();return n===""?null:(k.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var en=class{constructor(e="",n={}){this.baseUrl=e;this.options=n;this.latestRequestByUrl={};this.refreshingToken=null;this.lastFailedRefreshAt=null;this.failedRefreshCooldown=1e4;var o;this.fetch=(o=n.fetch)!=null?o:window.fetch.bind(window)}patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,n={}){return new Promise((o,r)=>{let s={isAborted:!1,reject:r},i=`${this.baseUrl}${e}`,a=this.fetch,d=n.method===void 0||n.method.toLowerCase()==="get",N=n,{useCache:l=!1,abortLatest:c=!1,attempts:p=1,retryDelay:u=500,refreshTokenOn401:f=!0,retryOnError:m=_=>_ instanceof TypeError,retryOnResponse:g=_=>_.status>=500,version:h=null}=N,b=M(N,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(l){if(!d)throw new Error(`Can't use 'useCache' for ${n.method}`);if(ni.has(i)){o(ni.get(i));return}}let T=x(y({credentials:"include"},b),{headers:y({Accept:"application/json","Content-Type":"application/json"},b.headers)});!d&&this.csrfToken&&(T.headers=x(y({},T.headers),{"X-CSRFToken":this.csrfToken})),typeof h=="string"&&(T.headers=x(y({},T.headers),{"X-Deepdesk-API-Version":h}));let C=p,w=!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 L=()=>v(this,null,function*(){return C--,a(i,T).then(_=>v(this,null,function*(){return g(_)&&!s.isAborted&&C>0?(yield ti(u),L()):_.status===401&&f===!0&&w===!1?(w=!0,yield this.refreshToken(),L()):_})).catch(_=>v(this,null,function*(){if(m(_)&&!s.isAborted&&C>0)return yield ti(u),L();throw _}))});L().then(_=>v(this,null,function*(){let W=yield gx(_);if(delete this.latestRequestByUrl[i],_.status>=500){r(new oi("Server Error",W));return}if(_.status===401){r(new bt("Unauthorized",W));return}if(_.status===403){r(new bt("Forbidden",W));return}if(_.status===404){r(new bt("Not Found",W));return}if(_.status>=400){r(new bt("Bad Request",W));return}l&&ni.set(i,W),o(W)})).catch(_=>{r(_)})})}validateToken(){return v(this,null,function*(){let e,n,o;try{({has_valid_access_token:e,is_logged_in:n,has_valid_refresh_token:o}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1}))}catch(r){return!1}if(!e){if(!o)return!1;try{yield this.refreshToken();let{is_logged_in:r}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1});return r}catch(r){return!1}}return n})}refreshToken(){let e=Date.now();return this.lastFailedRefreshAt&&e-this.lastFailedRefreshAt<this.failedRefreshCooldown?Promise.reject(new bt("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(e,n){return this.request(e,n)}post(e,n,o){return this.request(e,y({method:"POST",body:JSON.stringify(n)},o))}patch(e,n,o){return this.request(e,y({method:"PATCH",body:JSON.stringify(n)},o))}put(e,n,o){return this.request(e,y({method:"PUT",body:JSON.stringify(n)},o))}delete(e,n){return this.request(e,y({method:"DELETE"},n))}};var eu;(e=>{let t;(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"))(t=e.EvaluationStatus||(e.EvaluationStatus={}))})(eu||(eu={}));function ri(t){return x(y({},B(t)),{metadata:t.metadata})}var Ct=class Ct{constructor(e,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new en(e,{fetch:n.fetch}),this.client.patchFetch(o=>(r,s)=>v(this,null,function*(){let i=yield o(r,s);return this.handleDeepdeskVersionHeaders(i),i}))}preflight(){return v(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=yield this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(Ct.exchangeTokenPromise||(Ct.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),Ct.exchangeTokenPromise):Promise.resolve()})}createConversation(e){return v(this,null,function*(){var o;yield this.preflight(),k.info(`Creating conversation for session ${e.externalId} and agent ${e.agentId}`);let n=yield this.client.post("/api/v2/conversations",x(y({chat_start_time:new Date().toISOString()},Y(e)),{metadata:(o=e.metadata)!=null?o:{}}));return ri(n)})}getMe(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/session/me/");return B(e)})}postIdentity(e){return v(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",Y(e))})}patchMe(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",Y(e));return B(n)})}getProfile(e){return v(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${e}/`,{useCache:!0});return B(n)})}getKnowledgeAssistant(e){return v(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{useCache:!0});return B(n)})}getContentTypes(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return B(e)})}getAccount(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/account/",{useCache:!0});return B(e)})}getPlatformConfig(e){return v(this,null,function*(){let n=e!==void 0?`/platform/config/${e}/`:"/platform/config/",{config:o}=yield this.client.get(n,{useCache:!0});return B(o)})}checkUserExists(e){return v(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${e}`,{version:"v1"});return n})}getConversationByExternalId(o){return v(this,arguments,function*(e,n={}){yield this.preflight(),k.info(`Getting conversation for session ${e}`);let{attempts:r=1,retryDelay:s=1e3}=n,i=yield this.client.get(`/api/v2/conversations/by_external_id/${e}`,{attempts:r,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return k.info(`Successfully retrieved conversation ${i.id} for session ${e}`),ri(i)})}isConversationSupported(o){return v(this,arguments,function*(e,n={}){k.info(`Check if conversation for session ${e} is supported`);let{attempts:r=1,retryDelay:s=1e3}=n;return(yield this.client.get(`/api/v2/conversations/by_external_id/${e}/has_active_profile`,{attempts:r,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500})).has_active_profile})}updateConversation(e,n){return v(this,null,function*(){var s;yield this.preflight();let o=Y(n);n.metadata&&(o.metadata=(s=n.metadata)!=null?s:{});let r=yield this.client.put(`/api/v2/conversations/${e}`,o);return ri(r)})}postMessages(e,n){return v(this,null,function*(){yield this.preflight(),yield this.client.post(`/api/v2/conversations/${e}/messages`,n.map(o=>x(y({},Y(o)),{metadata:o.metadata})))})}sendEvent(e,n){return v(this,null,function*(){yield this.preflight();let a=n,{data:o}=a,r=M(a,["data"]),s=Object.entries(this.latestReceivedDeepdeskVersions).reduce((d,[l,c])=>x(y({},d),{[l]:c}),{}),i=["platform","agentId","agentName","agentEmail","conversationId"].reduce((d,l)=>(r[l]&&(d[l]=r[l]),d),{});return this.client.post("/api/v2/events",Y(x(y(y({},s),i),{data:o,name:e})),{version:"v2"})})}getEntities(e){return v(this,null,function*(){return yield this.preflight(),yield this.client.post("/api/v2/entities",{messages:e.filter(o=>o.text)})})}getTemporaryExchangeToken(){return v(this,null,function*(){return(yield this.client.get("/apis/admin/session/exchange-token/")).jwt})}exchangeTokenForAccessCookie(e){return v(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:e}).catch(n=>{throw k.warn(`Invalid token '${e}'`),n})})}authenticateWithKey(e,n){return v(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Y(n),{refreshTokenOn401:!1,headers:{apikey:e}})})}getTextSuggestions(r){return v(this,arguments,function*(e,n={},o){if(yield this.preflight(),o==="sticky-messages")throw new Error("Use getPinnedMessages instead");return(yield this.client.post(`/api/v2/conversations/${e}/recommend/${o}`,Y(n),{abortLatest:!0})).map(i=>x(y({},B(i)),{text:i.text||i.url||i.message,source:o,type:o})).filter((i,a,d)=>a===d.findIndex(l=>l.text===i.text))})}isLoggedIn(){return v(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(e,n){return v(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${e}/autocomplete`,Y(n),{abortLatest:!0})).map(r=>({score:1,source:r.source,sourceText:r.source_text,text:r.label,trainingJobs:r.training_jobs,searchKeywords:r.search_keywords,type:r.source})).filter((r,s,i)=>s===i.findIndex(a=>a.text===r.text))})}getPinnedMessages(e){return v(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${e}/pinned-messages`,{abortLatest:!0});return B(n).map(o=>x(y({},o),{text:o.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(e){return v(this,null,function*(){let n=yield this.client.post("/api/v2/style-suggestions",Y(e),{abortLatest:!0,version:"v2"});return B(n)})}search(e){return v(this,null,function*(){let n=yield this.client.post(`/api/v2/profiles/${e.profile}/search`,Y(e));return B(n)})}requestLoginByEmail(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:e});return B(n)})}requestPasswordlessToken(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/session/passwordless/request/");return B(e.token)})}getCsrfToken(){return v(this,null,function*(){let{token:e}=yield this.client.get("/apis/admin/session/csrf/");return e})}verifyLoginToken(e){return v(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:e});return B(n)})}evaluateAssistant(e,n){return v(this,null,function*(){var i;yield this.preflight();let o=new URLSearchParams;n!=null&&n.externalConversationId&&o.append("external_conversation_id",n.externalConversationId);let r=n!=null&&n.threadId?`/api/v2/assistants/${e}/threads/${n==null?void 0:n.threadId}/evaluate?${o.toString()}`:`/api/v2/assistants/${e}/evaluate?${o.toString()}`,s=yield this.client.post(r,{input:(i=n==null?void 0:n.input)!=null?i:{},conversation:n==null?void 0:n.transcript});return B(s)})}createAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n}=e,o=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return B(o)})}postMessageToAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:o,message:r}=e,s=yield this.client.post(`/apis/admin/assistants/${n}/threads/${o}/messages/`,{content:r,role:"user"});return B(s)})}translateMessages(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/v2/translate",Y(e));return B(n)})}handleDeepdeskVersionHeaders(e){e.headers.forEach((n,o)=>{let r=o.toLowerCase(),s=r.match(Oi);if(!n||!s)return;let i=s[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&k.warn(`Overwritten Version header ${r}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};Ct.exchangeTokenPromise=null;var et=Ct;import{combineReducers as Sx,configureStore as bx}from"@reduxjs/toolkit";import{createSlice as mx}from"@reduxjs/toolkit";var tu={startTime:null,stopTime:null},nu=t=>t.handlingTime,ou=mx({name:"handlingTime",initialState:tu,reducers:{handlingTimeStart(t){if(t.startTime&&!t.stopTime)throw new Error("Timing already started");t.startTime=new Date,t.stopTime=null},handlingTimeStop(t){if(!t.startTime)throw new Error("Timing not started");t.stopTime=new Date},handlingTimeReset(t){t.startTime=null,t.stopTime=null}},extraReducers:t=>{t.addCase(V,()=>tu)}}),{handlingTimeStart:ru,handlingTimeStop:mr,handlingTimeReset:su}=ou.actions,iu=ou.reducer;var au=(t={})=>{let e=y({onAuthError:Pt(!1)},t);return n=>o=>r=>("error"in r&&r.error.message==="Unauthorized"&&n.dispatch(e.onAuthError),o(r))};import{createAsyncThunk as fx,createSlice as hx}from"@reduxjs/toolkit";var fr={list:{keywordMatches:[]},fetchState:"idle"};var Tt=fx("styleSuggestions/getAll",(n,o)=>v(null,[n,o],function*({text:t},e){var d;let{deepdeskAPI:r}=e.extra,s=e.getState(),{showStyleSuggestions:i}=s.settings,a=(d=s.conversation.current)==null?void 0:d.profileCode;if(!i)return fr.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return r.getStyleSuggestions({profileCode:a,message:t})})),yx=hx({name:"styleSuggestions",initialState:fr,reducers:{},extraReducers:t=>{t.addCase(Tt.pending,e=>{e.fetchState="loading"}).addCase(Tt.rejected,e=>{e.fetchState="error"}).addCase(Tt.fulfilled,(e,n)=>{e.fetchState="done",$e(e.list,n.payload)||(e.list=n.payload)}).addCase(it,e=>{e.list=fr.list}).addCase(V,()=>fr)}}),lu=yx.reducer;var du=(t={})=>{let e,n=!0,o=y({getStyleSuggestions:Tt,debounce:500},t);return r=>s=>i=>{var f;let a=r.getState().input.text,d=s(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return d;let{showStyleSuggestions:c}=l.settings;if(!((f=l.conversation.current)==null?void 0:f.id)||!c)return d;let{text:u}=l.input;return u===a&&!n||(clearTimeout(e),u==="")||(e=setTimeout(()=>{n=!1,r.dispatch(o.getStyleSuggestions({text:u}))},t.debounce)),d}};function vx(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var cu=(t={})=>{let e=y({getTextSuggestions:he,getAutocompleteSuggestions:An,debounce:200,check:we},t),n;return o=>r=>s=>{var g;let{input:i}=o.getState(),a=r(s),d=o.getState();if(d.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:l,showTabCompletion:c}=d.settings,p=(g=d.conversation.current)==null?void 0:g.id,u=s.type===Lo.toString();if(!p||!l&&!c)return a;let{input:f}=d;return vx(f,i)&&!u||(clearTimeout(n),!e.check(d))||(n=setTimeout(()=>{let h=At(d);h===""?o.dispatch(e.getTextSuggestions("default")):o.dispatch(e.getAutocompleteSuggestions(h))},u?0:e.debounce)),a}};var uu=Tt.fulfilled.toString();function xx(t,e){let n=new Set([...e.keywordMatches.map(r=>r.keyword)]),o=[];return n.forEach(r=>{let s=t.keywordMatches.filter(d=>d.keyword===r),i=e.keywordMatches.filter(d=>d.keyword===r),a=i.length-s.length;a<=0||o.push(...i.slice(0,a))}),o}var pu=t=>e=>n=>o=>{var l;if(o.type!==uu){n(o);return}let r=e.getState().styleSuggestions.list;n(o);let s=e.getState(),i=s.styleSuggestions.list,a=(l=s.conversation)==null?void 0:l.current;if(r===i)return;let d=xx(r,i);o.type===uu&&d.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:d}})};var Cx=Sx({assistants:ec,auth:Vi,conversation:Ji,contentTypes:ja,passwordlessToken:rc,entities:Cl,handlingTime:iu,info:xa,input:da,settings:Fi,profile:Ja,search:Ea,styleSuggestions:lu,ui:Zl,textSuggestions:_l});function gu(t){return bx({reducer:Cx,middleware:e=>{var o;let n=e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI}},serializableCheck:!1}).concat(au()).concat(cu({debounce:200})).concat(du({debounce:500})).concat(pu(t.deepdeskAPI));return((o=t.middleware)!=null?o:[]).reduce((r,s)=>r.concat(s),n)},preloadedState:t.preloadedState})}var Tx=t=>{var e,n;return(n=(e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())!=null?n:"unknown"},wx=t=>e=>n=>o=>{var a,d;let r=e.getState(),s=Rt("inlineSuggestions")(r);switch(o.type){case Pt.toString():{!o.payload&&t.emit("logout",void 0);break}case fe.fulfilled.toString():o.payload.length>0&&t.sendEvent("entities found",{conversationId:(a=r.conversation.current)==null?void 0:a.id,data:{entities:o.payload}});break;case it.toString():t.logSendMessage(o.payload);break;case Jo.toString():t.emit("call-to-action",{cue:o.payload});break;case ke.fulfilled.toString():o.isBroadcasted||t.broadcast(Br,o,!1);break;default:break}let i=n(o);switch(o.type){case it.toString():t.handleAfterSendMessage(o.payload);break;case Mn.toString():t.onUpdateShowTabHint(o.payload);break;case mr.toString():t.logHandlingTime();break;case Nt.toString():t.broadcast(uo,o);break;case st.toString():t.broadcast(uo,o);break;case Qo.toString():e.dispatch(st({source:"assistant",assistantCode:o.payload.code}));break;case"analytics/logEvent/fulfilled":{let l=r.assistants.cues.find(c=>c.code===o.meta.arg.data.assistantCode);t.emit("event",x(y({},o.meta.arg),{cue:l}));break}case re.toString():{let{start:l,end:c}=r.input.selection;t.emit("select-suggestion",x(y({type:Tx(o.payload.suggestion)},o.payload),{replace:o.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}})),s&&e.dispatch(Ge([]));break}case no.toString():t.emit("select-image",o.payload),t.sendEvent("Image attached",{conversationId:(d=r.conversation.current)==null?void 0:d.id,data:{path:o.payload.suggestion.image,title:o.payload.suggestion.title}});break;case Ge.toString():{s&&o.payload.length>0&&e.dispatch(oo(0));break}default:break}return i},mu=wx;import{createSelector as Ex}from"@reduxjs/toolkit";function si(t){return t.toISOString().replace("T"," ").replace("Z","")}var kx=(t,e)=>e.version,fu=Ex([Ot,Se,nu,kx],(t,e,n,o)=>{if(!e)return k.warn("No conversationId for handling time metrics"),null;let{startTime:r,stopTime:s}=n;return!r||!s?(k.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:e,clientVersion:o,agentId:t==null?void 0:t.agentId,agentName:t==null?void 0:t.agentName,agentEmail:t==null?void 0:t.agentEmail,timeStart:si(r),timeStop:si(s)}});function hu(t,e){let{text:n,metrics:{numPaste:o,pastes:r,textSuggestions:s}}=t.input,i=n.length;return{source:"agent",clientVersion:e.version,pastes:r,lenTextTotal:i,numPastes:o,suggestions:s}}function ii(t,e){var s;let n=t.closest(e);if(n)return n;let o=t.getRootNode().host;if(o instanceof HTMLElement)return ii(o,e);let r=(s=t.ownerDocument.defaultView)==null?void 0:s.frameElement;return r?ii(r,e):null}function ai(t,e){return ii(t,e)}function yu(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Rx(t){return typeof t=="object"&&t!==null&&"tagName"in t}function li(t){return Rx(t)&&(ht(t)||Bo(t))}var xu,Re=new Map,Px=["bottom","height","left","right","top","width"],vu=(t,e)=>!t&&!e?!1:t&&!e||!t&&e?!0:Px.some(n=>t[n]!==e[n]);function Su(t){var n,o,r;if(t.ownerDocument===document)return[];let e=(r=(o=(n=t.ownerDocument)==null?void 0:n.defaultView)==null?void 0:o.frameElement)!=null?r:null;return e?[e,...Su(e)]:[]}function bu(t,e){return!t||!e?null:x(y({},t),{top:t.top+e.top,left:t.left+e.left})}var hr=!1,Cu=()=>{hr=!0;let t=[];if(Re.forEach((e,n)=>{if(!n.isConnected){e.rect=null,t.push(e),Re.delete(n);return}let o=n.getBoundingClientRect();vu(o,e.rect)&&(e.rect=o,t.push(e))}),t.forEach(e=>{let n=e.parentRects?e.parentRects.reduce(bu,e.rect):e.rect;vu(n,e.totalRect)&&e.callbacks.forEach(o=>o(n)),e.totalRect=n}),Re.size===0){hr=!1;return}xu=window.requestAnimationFrame(Cu)};function di(t,e){let n=Su(t),o=[],r=n.map((s,i)=>di(s,a=>{o[i]=a;let d=Re.get(t);if(!d)return;let l=o.reduce(bu,d.rect);d.callbacks.forEach(c=>c(l))}));return{observe(s=!0){if(r.forEach(i=>i.observe(!1)),Re.has(t)){let i=Re.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Re.set(t,{rect:void 0,callbacks:[e],parentRects:o});s&&!hr&&Cu()},unobserve(){r.forEach(i=>i.unobserve());let s=Re.get(t);if(s){let i=s.callbacks.indexOf(e);i>=0&&s.callbacks.splice(i,1),s.callbacks.length||Re.delete(t),Re.size||(cancelAnimationFrame(xu),hr=!1)}}}}var Tu,Pe=new Map,wu=()=>{Pe.forEach((t,e)=>{if(!e.isConnected){Pe.delete(e);return}let{clientHeight:n,scrollHeight:o}=e,r=o>n;t.visible!==r&&(t.visible=r,t.callbacks.forEach(s=>s(t.visible)))}),Pe.size!==0&&(Tu=window.requestAnimationFrame(wu))};function Eu(t,e){return{observe(){let n=Pe.size===0;Pe.has(t)?Pe.get(t).callbacks.push(e):Pe.set(t,{visible:void 0,callbacks:[e]}),n&&wu()},unobserve(){let n=Pe.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||Pe.delete(t),Pe.size||cancelAnimationFrame(Tu)}}}}var ci=["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 ui(t,e,n){return n.forEach(o=>{e.style[o]=t[o]})}function tn(t){return Number.parseFloat(t)}function yr(t){return Math.round(t*1e6)}function ku(t){return t/1e6}function pi(t,e,n){if(t.boxSizing==="content-box")return;let{clientWidth:o}=e,r=tn(t.width),s=tn(t.borderLeftWidth),i=tn(t.borderRightWidth),a=tn(t.paddingRight),d=ku(yr(r)-yr(s)-yr(i)),l=ku(yr(o));if(d-l>2){let c=d-l;n.style.paddingRight=`${a+c}px`}}function vr(t,e={}){var c,p;let n=e.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(c=e.position)!=null?c:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",mt(n);let o=window.getComputedStyle(t),r=!0,s=()=>{n.scrollTop=t.scrollTop};ui(o,n,ci),pi(o,t,n),e.mirrorOverflow&&(n.style.overflow="hidden",t.addEventListener("scroll",s));let i=Eu(t,()=>{ui(o,n,ci),pi(o,t,n),s(),setTimeout(s,0)}),a,d=!0,l=di(t,u=>{if(u===null){e.onRemove&&e.onRemove(),n.remove();return}if(!d&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),d=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),d=!1},200),u.height===0&&u.width===0){if(r===!0)return;e.onHide&&e.onHide(),n.style.display="none",r=!0;return}if(ui(o,n,ci),pi(o,t,n),s(),e.placement==="below"&&n.classList.add("below"),n.style.top=`${u.top}px`,n.style.left=`${u.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let f=e.closestScrollElement.getBoundingClientRect(),m=window.getComputedStyle(e.closestScrollElement),g=tn(m.borderTopWidth),h=tn(m.borderBottomWidth),b=f.top+g-u.top,T=u.top+u.height+-(f.top+f.height-h);n.style.clipPath=`inset(${b}px 0px ${T}px 0px)`}r&&(n.style.display="block",e.onShow&&e.onShow(),r=!1)});return e.appendTo?e.appendTo.appendChild(n):(p=t.parentElement)==null||p.appendChild(n),l.observe(),i.observe(),[n,()=>{t.removeEventListener("scroll",s),l.unobserve(),i.unobserve(),n.remove()}]}var Ru=(t,e)=>({value(){try{let n=sessionStorage.getItem(`dd-${t}`);if(!n)return e;try{return JSON.parse(n)}catch(o){return e}}catch(n){return e}},update(n){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(n))}catch(o){k.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Ix(t){return t.offsetParent!==null}function Pu(t){if(!Ix(t))return!1;let e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function gi(t,e,n=100){let o=Pu(t);e({isVisible:o});let r=setInterval(()=>{let s=Pu(t);s!==o&&(o=s,e({isVisible:o}))},n);return()=>{clearTimeout(r)}}var Kn=class extends Error{};function Lx(){let t,e;return{promise:new Promise((o,r)=>{t=o,e=r}),resolve:t,reject:e}}var xr=class{constructor(){this.queues={}}push(e,n){let o=()=>{let s=this.queues[e][1];s?(this.queues[e]=[s.promise,null],s.resolve()):delete this.queues[e]};if(!this.queues[e]){let s=n().finally(o);return this.queues[e]=[s,null],s}this.queues[e][1]&&this.queues[e][1].reject(new Kn("Queued async function is outdated"));let r=Lx();return this.queues[e][1]=r,r.promise.then(()=>n().finally(o))}};var Ax={accepted:"onConversationAcceptedAssistants","new-message":"onConversationNewMessageAssistants",ended:"onConversationEndedAssistants"},Iu=(t,e)=>{var r,s,i;if(!((i=(s=(r=t.uiConfig)==null?void 0:r.widget)==null?void 0:s.types.find(a=>a.type==="cues"))==null?void 0:i.isActive))return k.warn("Triggered a conversation assistant, but cues are not configured in widget."),[];let o=t[Ax[e]];return o&&o.length>0?o.map(a=>a.code):(k.warn(`No assistant set in profile for conversation event "${e}"`),[])};var Sr=class{constructor(e){this.options=e;this.socket=null;this.maxReconnectAttempts=5;this.reconnectInterval=25e3;this.cleanupCallbacks=[];var n,o;this.socket,this.eventListeners=new Map,this.url=e.url,this.maxReconnectAttempts=(n=e.maxReconnectAttempts)!=null?n:this.maxReconnectAttempts,this.reconnectInterval=(o=e.reconnectInterval)!=null?o:this.reconnectInterval,this.shouldReconnect=e.shouldReconnect}connect(){let e=()=>this.cleanup();window.addEventListener("beforeunload",e),this.cleanupCallbacks.push(()=>window.removeEventListener("beforeunload",e)),this.reconnect()}setupListeners(){this.socket&&(this.socket.onmessage=e=>{var n;try{let o=B(JSON.parse(e.data));o.event&&this.eventListeners.has(o.event)&&((n=this.eventListeners.get(o.event))==null||n.forEach(r=>r(o.data)))}catch(o){console.error("Error parsing WebSocket message:",o)}},this.socket.onclose=e=>{console.log("WebSocket connection closed:",e),setTimeout(()=>{this.reconnect()},this.reconnectInterval)},this.socket.onerror=e=>{console.error("WebSocket error:",e)})}reconnect(){var e,n;if(this.maxReconnectAttempts<=0){console.error("Max reconnect attempts reached, closing WebSocket connection."),(e=this.socket)==null||e.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(e,n){if(!this.socket){console.error("WebSocket connection is not open.");return}this.socket.send(JSON.stringify({event:e,data:n}))}on(e,n){this.eventListeners.has(e)||this.eventListeners.set(e,[]);let o=this.eventListeners.get(e);o&&!o.includes(n)&&o.push(n)}close(){var e;(e=this.socket)==null||e.close()}cleanup(){this.close(),this.cleanupCallbacks.forEach(e=>e()),this.cleanupCallbacks=[]}};import Ox,{useState as fi,useEffect as Dx}from"react";var Lu={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"};import{useSelector as _x}from"react-redux";var mi={};X(mi,{enUS:()=>Mx,nlNL:()=>Nx});var Mx={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."}]},Nx={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."}]};import{Fragment as Fx,jsx as xe,jsxs as br}from"react/jsx-runtime";var Au=({onClose:t,onSave:e,id:n,error:o})=>{let[r,s]=fi(""),[i,a]=fi(!1),[d,l]=fi(!1),c=S("Nickname",Lu),p=Ox.useRef(null),u=_x(b=>b.info.showNicknameDialog),f=R(mi),m=E("adminUrl");Dx(()=>{o&&a(!0)},[o]);let g=()=>{if(!p.current)return;r.trim()?p.current.setCustomValidity(""):p.current.setCustomValidity(f("nicknameDialogError")),p.current.reportValidity()},h=b=>{b.preventDefault();let T=r.trim(),C=b.currentTarget.querySelector("#nickname-input");if(!T){C.setCustomValidity(f("nicknameDialogError")),C.reportValidity();return}C.setCustomValidity(""),e(T)};return br(Ft,{isOpen:u,"datatest-id":n,onClose:t||(()=>{}),onBack:t||(()=>{}),children:[xe("div",{className:c.titleWrapper,children:xe("h1",{className:c.title,children:f("title")})}),br("form",{className:c.dialogContent,onSubmit:h,children:[xe("p",{children:f("nicknameDialogTitle")}),i&&o&&xe("div",{className:c.errorMessage,children:m?(()=>{let b=f("nicknameDialogSaveError",{account:m}),T=`${m}.deepdesk.com/admin/user-settings`,C=b.indexOf(T);if(C!==-1){let w=b.substring(0,C),L=b.substring(C+T.length);return br(Fx,{children:[w,xe("a",{href:T,target:"_blank",rel:"noopener noreferrer",className:c.errorLink,children:T}),L]})}return b})():f("nicknameDialogSaveErrorWithoutLink")}),xe("input",{required:!0,minLength:1,maxLength:20,"data-testid":"nickname-input",id:"nickname-input",className:c.nicknameInput,type:"text",placeholder:f("nicknameDialogInputPlaceholder"),value:r,onChange:b=>{l(new RegExp("\\p{Extended_Pictographic}","u").test(b.target.value)),s(b.target.value)},onBlur:g,ref:p}),d&&xe("div",{className:c.errorMessage,role:"alert",children:f("nicknameDialogEmojiError")}),br("div",{className:c.buttonsWrapper,children:[o?xe("div",{className:c.closeButtonWrapper,children:xe("button",{type:"button",className:c.closeButton,onClick:()=>t==null?void 0:t(),children:f("close")})}):null,xe("div",{className:c.buttonContinueWrapper,children:xe("button",{type:"submit",className:c.continueButton,disabled:!r.trim()||new RegExp("\\p{Extended_Pictographic}","u").test(r),children:f("nicknameDialogContinueButton")})})]})]})]})};import{jsx as F,jsxs as Hx}from"react/jsx-runtime";var Mu=Ru("showTabHint",!0),nn=class nn{constructor({deepdeskUrl:e,version:n=nn.version||"unknown",locale:o="en-US",token:r,fetch:s,productName:i,createCustomChannel:a,websocketClient:d=Sr}){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 xr;this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let l=e.replace(/\/api$/,"");this.deepdeskApi=new et(l,{token:r,fetch:s}),this.version=n,this.instanceId=nn.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[mu({broadcast:(m,g,h)=>{this.broadcastEvents.send(m,g,h)},emit:(m,g)=>this.emit(m,g),handleAfterSendMessage:m=>this.handleAfterSendMessage(m),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:m=>this.logSendMessage(m),onUpdateShowTabHint:m=>Mu.update(m),sendEvent:(m,g)=>this.deepdeskApi.sendEvent(m,g)})]};this.store=gu(c),this.broadcastEvents=new Yc({debug:!0,deepdeskUrl:l,eventMap:ka(this.store),createCustomChannel:a}),this.disposeHandlers.push(()=>{this.broadcastEvents.cleanup()}),this.ws=new d({url:`${l}/api/v2/me/realtime`.replace("https","wss"),reconnectInterval:25e3,shouldReconnect:()=>v(this,null,function*(){var m;return(m=J(this.state))!=null?m:!1})}),this.whenLoggedIn(()=>this.ws.connect()),this.store.dispatch(Mn(Mu.value())),this.store.dispatch(Qn({locale:o,adminUrl:l,productName:i}));let p=[],u=m=>{if(!m.conversationId)return;let g=()=>{this.conversationId()===m.conversationId&&this.store.dispatch(Yd(m))};this.hasConversation()?g():p.push(g)};this.ws.on("assistants::direct_response",u),this.ws.on("assistants::user_notification",u),this.ws.on("assistants::response_chunk",m=>{if(!m.conversationId)return;let g=()=>{this.conversationId()===m.conversationId&&this.store.dispatch(Zd(m))};this.hasConversation()?g():p.push(g)}),this.ws.on("assistants::suggest_as_reply",m=>{if(!m.conversationId)return;let g=()=>{this.conversationId()===m.conversationId&&this.store.dispatch(Nt([{text:m.payload.message,type:"text",source:"assistant",assistantCode:m.code,sourceLabel:m.name}]))};this.hasConversation()?g():p.push(g)});let f=this.whenConversationLoaded(()=>{var m;this.broadcastEvents.setExternalId((m=this.state.conversation.current)==null?void 0:m.externalId),p.forEach(g=>g()),p.length=0});this.disposeHandlers.push(()=>{this.ws.cleanup(),p.length=0,f()})}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var e;return(e=rt(this.state)[this.state.input.selectedSuggestionIndex])!=null?e: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?(k.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(k.warn("Profile has not been loaded (yet)"),!0):(k.warn("No conversation loaded (yet)"),!0)}whenLoggedIn(e){if(J(this.state))e();else{let n=this.subscribe(J,o=>{o&&e()});this.disposeHandlers.push(()=>{n()})}}login(){return this.store.dispatch(Pt(null)),this.store.dispatch(Ae()),new Promise(e=>{this.whenLoggedIn(()=>e())})}isLoggedIn(){return v(this,null,function*(){return(yield this.store.dispatch(Ae())).payload})}isConversationSupported(e,n){return v(this,null,function*(){return(yield this.store.dispatch(Mr({externalId:e,options:n}))).payload})}createConversation(e){return v(this,null,function*(){var o;return this.hasConversation()&&this.externalId()!==e.externalId&&this.resetConversation(),(yield this.store.dispatch(Yn(x(y({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}getConversationByExternalId(e,n){return v(this,null,function*(){return this.hasConversation()&&this.externalId()!==e&&this.resetConversation(),(yield this.store.dispatch(eo({externalId:e,options:n}))).payload})}upsertConversation(e){return v(this,null,function*(){var o;return this.hasConversation()&&this.externalId()!==e.externalId&&this.resetConversation(),(yield this.store.dispatch(Nr(x(y({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}postMessages(e){return v(this,null,function*(){yield this.store.dispatch(Or(e))})}updateConversation(e){return v(this,null,function*(){return(yield this.store.dispatch(to(e))).payload})}resetConversation(){this.store.dispatch(V()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(e){this.store.dispatch(Qn(e))}setVisitorInfo(e){this.store.dispatch(fa(e))}setCustomData(e){this.store.dispatch(ha(e))}setAgentInfo(e,n){return v(this,null,function*(){var r;yield this.store.dispatch(cn(y(y({},e),n))),(r=this.state.info.agentInfo)!=null&&r.agentNickname||this.broadcastEvents.send(co,{showNicknameDialog:!0})})}setAgentSettings(e){return v(this,null,function*(){yield this.store.dispatch(_r(e))})}getAgentSettings(){return v(this,null,function*(){return(yield this.store.dispatch(Fr())).payload})}refresh(){return v(this,null,function*(){if(this.shouldAbort())return Promise.resolve();let e=[];return e.push(this.refreshTextSuggestions()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})})}syncInputMediator(){this.inputMediator&&this.store.dispatch(ro({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}))}notifyExternalSuggestion(e){this.store.dispatch(re(e))}evaluateAssistant(e,n){return v(this,null,function*(){var d;let{input:o={},transcript:r,showCuesInWidget:s=!0,includeMetadata:i}=n||{},a=yield this.store.dispatch(ke({assistantCode:e,transcript:r,includeMetadata:i,input:o,skipState:!s}));if(a.error)throw new Error(`Assistant evaluation failed: ${(d=a.payload)!=null?d:a.error.message}`);return a.payload.output})}evaluateConversationAssistant(e,n){return v(this,null,function*(){yield this.loadProfileConfig();let o=this.state.profile.data;if(!o){k.warn("Can't evaluate assistant when profile is not loaded yet.");return}let r=Iu(o,e);yield Promise.all(r.map(s=>this.queues.push(s,()=>v(this,null,function*(){yield this.evaluateAssistant(s,y({includeMetadata:!0},n))})).catch(i=>{if(i instanceof Kn){k.warn(`Queued assistant "${s}" was outdated and dropped`);return}throw i})))})}handleKeyDown(e){let{overlayCollapsed:n,openOverlayWhenTyping:o}=this.state.ui,{textSuggestions:r,selectedSuggestionIndex:s,selection:i}=this.state.input,{inlineSuggestions:a,showTextSuggestions:d,suggestionsPlacement:l}=this.settings,c=l==="inline"||l==="below"?"below":"above",p=r.length>0;if(this.store.dispatch(na(Dr(e))),!we(this.state)||e.key!=="Tab"&&!d)return;let u=()=>{n||!p||i&&(e.shiftKey||(this.store.dispatch(sa()),e.preventDefault()))},f=()=>{n||!p||a&&s<=0||i&&(e.shiftKey||(this.store.dispatch(ia()),e.preventDefault()))};switch(e.key){case"ArrowUp":c==="below"?f():u();break;case"ArrowDown":{c==="below"?u():f();break}case"Escape":{n||(this.store.dispatch(oo(-1)),this.store.dispatch(Je({collapse:!0})),this.store.dispatch(Jl(!0)),e.preventDefault());break}case"Tab":{e.preventDefault();let m=Mt(this.state);if(!m)return;this.store.dispatch(Mn(!1)),this.store.dispatch(re({text:m.text,suggestion:m,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let m=Mt(this.state);if(!m)return;this.store.dispatch(re({text:m.text,suggestion:m,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.settings.inlineSuggestions||e.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let m=Mt(this.state);if(!m)return;this.store.dispatch(re({text:m.text,suggestion:m,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),e.preventDefault();break}default:}n&&o&&this.store.dispatch(Je({collapse:!1}))}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ge([]))}handlingTimeStart(){this.state.handlingTime.startTime||(k.info("Start handling time"),this.store.dispatch(ru()))}handlingTimeStop(){this.state.handlingTime.startTime&&(k.info("Stop handling time"),this.store.dispatch(mr()))}logSendMessage(e){let n=hu(this.state,{version:this.version});n&&(e&&(Object.assign(n,{text:e}),Object.assign(n,{lenTextTotal:e.length})),this.deepdeskApi.sendEvent("Send Message",{conversationId:this.conversationId(),data:n}),this.emit("send-message-event",n))}logHandlingTime(){let e=fu(this.state,{version:this.version});e&&(this.deepdeskApi.sendEvent("Handling Time",{conversationId:this.conversationId(),data:e}),this.store.dispatch(su()))}notifySubmit(e={}){var n;this.shouldAbort()||(this.store.dispatch(it((n=e.text)!=null?n:this.state.input.text)),this.store.dispatch(la()))}emit(e,n){let o=this.eventListeners[e];o&&o.forEach(r=>{try{r(n)}catch(s){k.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),k.error(s)}})}on(e,n){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n),()=>{this.off(e,n)}}off(e,n){if(!e&&!n){this.eventListeners={};return}let o;this.eventListeners[e]&&(o=this.eventListeners[e].indexOf(n),o>-1&&this.eventListeners[e].splice(o,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}setPlatformVariables(e){this.store.dispatch(ya(e))}whenConversationLoaded(e){let n=s=>{var i;return(i=s.conversation.current)==null?void 0:i.id},o=()=>this.loadProfileConfig().then(()=>e());return n(this.state)&&o(),this.subscribe(n,s=>{s&&o()})}overlayContainerFactory(e,n,o,r){let[s,i]=vr(n,o);return s.setAttribute("translate","no"),s.dataset.testid=e,r&&s.classList.add(r),[s,i]}createInlineContainer(e,n){var a;let o=document.createElement("div");o.style.position="absolute",o.style.top="0px",o.style.left="0px",o.style.height="0px",o.style.width="0px";let r=document.createElement("div");r.style.display="none",r.style.position="absolute",r.style.height="0px",r.style.width="0px",r.style.backgroundColor="red",o.appendChild(r);let s=(a=e.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[d,l]=vr(s,{appendTo:document.body,onMoveStart:()=>{r.style.display="none"}});d.dataset.testid=n,d.style.zIndex="2",d.appendChild(o),this.unmountHandlers.push(()=>{l()})}else document.body.appendChild(o);return r}createContainer(e,n=document.body){let o=window.getComputedStyle(n),r=document.createElement("div");return mt(r),r.dataset.testid=e,r.style.color=o.color,r.style.fontSize=o.fontSize,r.style.fontFamily=o.fontFamily,r.style.fontVariant=o.fontVariant,r.setAttribute("translate","no"),n.appendChild(r),r}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,n),k.info(`Stored analytics for ${this.conversationId()}`)}catch(e){}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(e);if(!n)return;let o=JSON.parse(n);o.text.trim()===this.state.input.text.trim()?(k.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(aa(o.metrics))):k.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch(e){}}mount(e,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!li(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let u=n,{customStyles:o,closestScrollSelector:r,floatingMenuParent:s,appendOverlayTo:i,inputMediator:a}=u,d=M(u,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),l={customStyles:o,closestScrollSelector:r,floatingMenuParent:s,appendOverlayTo:i};this.configure(d),this.settings.automaticHandlingTime&&this.setupHandlingTime(e),mt(e),this.inputMediator=a||(ht(e)?new Zt(e):new Qt(e)),this.inputMediator.on("change",({plainText:f,rawHTML:m})=>{this.store.dispatch(ro({text:f,html:m}))}),this.inputMediator.on("keyup",f=>{this.store.dispatch(oa(Dr(f)))}),this.inputMediator.on("keydown",f=>{this.handleKeyDown(f)}),this.inputMediator.on("paste",({pastedText:f,selectionText:m})=>{this.store.dispatch(ra({text:f,selectionText:m}))}),this.inputMediator.on("cut",({selectionText:f})=>{this.store.dispatch(ta(f))});let c;this.inputMediator.on("selection",f=>{clearTimeout(c),f===null?c=setTimeout(()=>{f!==null&&this.store.dispatch(so(f))},500):this.store.dispatch(so(f))}),this.unmountHandlers.push(()=>{clearTimeout(c)}),this.inputMediator.on("disabled",()=>{var f;(f=this.inputMediator)==null||f.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(No(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(No(!0))}),this.renderSuggestions(e,l),this.subscribe(Rt("inlineSuggestions"),()=>{this.renderSuggestions(e,l)}),this.subscribe(Rt("suggestionsPlacement"),()=>{this.renderSuggestions(e,l)});let p=this.renderOverlays(n);this.unmountHandlers.push(()=>{p.unmount()}),this.store.dispatch(ro({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(so(this.inputMediator.getSelection())),this.store.dispatch(No(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(e){if(this.nicknameDialogUnsubscribe||this.nicknameDialogFailed)return;let n=this.createContainer("nickname-dialog",document.body);document.body.appendChild(n);let o=tt(n),r=null,s=a=>{r=a,i()},i=()=>{o==null||o.render(F(Fe,{store:this.store,children:F(Ne,{broadcastEvents:this.broadcastEvents,children:F(Au,{id:"deepdesk-nickname-dialog",error:r,onSave:a=>v(this,null,function*(){try{yield this.store.dispatch(ga({agentNickname:a})).unwrap(),console.log("setAgentNickname",a),this.broadcastEvents.send(co,{showNicknameDialog:!1}),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe()}catch(d){k.error("Error setting agent nickname",d),s("error"),this.nicknameDialogFailed=!0}})})})}))};i(),this.nicknameDialogUnsubscribe=()=>{o.unmount(),n.remove(),this.nicknameDialogUnsubscribe=null}}subscribe(e,n){let o=e(this.store.getState());return this.store.subscribe(()=>{let r=e(this.store.getState());r!==o&&(o=r,n(o))})}unmount(){var e,n,o,r,s;(e=this.inlineSuggestions)==null||e.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(o=this.belowSuggestions)==null||o.unmount(),(r=this.floatingMenu)==null||r.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(e=>e()),this.disposeHandlers=[],this.off()}renderSuggestions(e,n){var o,r,s,i;(o=this.floatingMenu)==null||o.unmount(),(r=this.inlineSuggestions)==null||r.unmount(),(s=this.aboveSuggestions)==null||s.unmount(),(i=this.belowSuggestions)==null||i.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(e,n)),this.settings.inlineSuggestions||this.settings.suggestionsPlacement==="inline"?this.inlineSuggestions=this.renderInlineSuggestions(e,n):this.settings.suggestionsPlacement==="below"?this.belowSuggestions=this.renderAboveOrBelowSuggestions(e,n,"below"):this.aboveSuggestions=this.renderAboveOrBelowSuggestions(e,n,"above")}renderInlineSuggestions(e,n){let{customStyles:o}=n,r=this.createInlineContainer(e,"deepdesk-caret"),s=tt(r);s.render(F(Fe,{store:this.store,customStyles:o,children:F(Ne,{broadcastEvents:this.broadcastEvents,children:F(ld,{})})}));let i=a=>{a?(r.style.display="block",r.style.top=`${a.top}px`,r.style.left=`${a.left}px`):r.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var a;(a=this.inputMediator)==null||a.off("caretposition",i),s.unmount(),r.remove()}}}renderAboveOrBelowSuggestions(e,n,o){let{customStyles:r,closestScrollSelector:s,appendOverlayTo:i}=n,a=s&&ai(e,s)||void 0,[d,l]=this.overlayContainerFactory("deepdesk-tab-completion",a||e,{appendTo:i,closestScrollElement:a,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),[c,p]=this.overlayContainerFactory("deepdesk-suggestions-overlay",a||e,{appendTo:i,placement:o},r==null?void 0:r.suggestionsRootNode),u=tt(d);u.render(F(Fe,{store:this.store,customStyles:r,children:F(Ne,{broadcastEvents:this.broadcastEvents,children:F(Vd,{inputElement:e})})}));let f=tt(c);return f.render(F(Fe,{store:this.store,customStyles:r,children:F(Ne,{broadcastEvents:this.broadcastEvents,children:F(vd,{onLogIn:()=>this.loginViaPopup().catch(m=>k.warn(m.message))})})})),{unmount(){u.unmount(),f.unmount(),l(),p()}}}renderFloatingMenu(e,n){let{customStyles:o,closestScrollSelector:r,appendOverlayTo:s,floatingMenuParent:i}=n,a=r&&ai(e,r)||void 0,[d,l]=this.overlayContainerFactory("floating-menu",a||e,{appendTo:i!=null?i:s},o==null?void 0:o.floatingMenuParent),c=tt(d);return c.render(F(Fe,{store:this.store,customStyles:o,children:F(Ne,{broadcastEvents:this.broadcastEvents,children:F(ql,{onLogIn:()=>this.loginViaPopup().catch(p=>k.warn(p.message))})})})),{unmount(){c.unmount(),l()}}}renderOverlays(e){let{customStyles:n}=e,o=this.createContainer("deepdesk-overlays"),r=tt(o);return r.render(F(Fe,{store:this.store,customStyles:n,children:F(Ne,{broadcastEvents:this.broadcastEvents,children:F(zl,{})})})),{unmount(){r.unmount(),o.remove()}}}renderWidget(e,n={}){if(this.widgetElement&&k.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:o,showImages:r,isEmbedded:s}=n;this.widgetElement=e,this.configure({showImages:r,isEmbedded:s}),this.widgetRoot=tt(e),this.widgetRoot.render(F(Fe,{store:this.store,customStyles:o,children:F(Ne,{broadcastEvents:this.broadcastEvents,children:F(Gc,{assistantOptions:n.assistantOptions,knowledgeAssistOptions:n.knowledgeAssist,onLogIn:()=>this.loginViaPopup().catch(i=>k.warn(i.message))})})}))}unmountWidget(){var e,n;(n=(e=this.widgetRoot)==null?void 0:e.unmount)==null||n.call(e),this.widgetRoot=null,this.widgetElement=null}renderKnowledgeAssistantWidget(e,n,o={}){let{customStyles:r,initialQuestion:s}=o,i=tt(n);return i.render(F(Fe,{store:this.store,customStyles:r,children:F(Ne,{broadcastEvents:this.broadcastEvents,children:F(Qs,{children:Hx(ir,{assistantCode:e,initialQuestion:s,evaluateKnowledgeAssistFn:On,children:[F(sn,{children:F(lr,{title:o.title,emptyState:o.emptyState})}),F(Js,{children:F(ar,{})})]})})})})),{unmount(){i.unmount()}}}setupHandlingTime(e){let n=gi(e,({isVisible:o})=>{o?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){yu(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>v(this,null,function*(){yield this.store.dispatch(En());let e=dt(this.state);e&&this.store.dispatch(Qn({showSearch:e.search,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:!!e.summarizerAssistantNew,showKnowledgeSearch:!!e.knowledgeAssistantNew||!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions}))})),this.loadProfileConfigPromise)}loginViaPopup(e){return v(this,null,function*(){return new Promise((n,o)=>{this.store.dispatch(Zn());let r=new MessageChannel,s=r.port1,i=this.settings.adminUrl,a=new URL(e!=null&&e.url?e==null?void 0:e.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let d=!1,l=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",p),clearInterval(u)};s.onmessage=f=>v(this,null,function*(){var m,g;if((m=f.data)!=null&&m.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((g=f.data)==null?void 0:g.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(pn),d=!0,r.port1.close(),n()}catch(h){console.error(h),o(h)}finally{d=!0,l()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&o(new Error("Popup blocked by browser"));let p=f=>v(this,null,function*(){var m;if(f.origin===a.origin)switch((m=f.data)==null?void 0:m.type){case"deepdesk-popup-request-origin":{try{let g=JSON.stringify({type:"deepdesk-popup-parent-origin"});c==null||c.postMessage(g,a.origin)}catch(g){k.error("Error posting message to popup",g),o(g)}break}case"deepdesk-popup-loaded":{try{let g=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(g,a.origin,[r.port2])}catch(g){k.error("Error posting message to popup",g),o(g)}break}case"deepdesk-popup-error":{if(l(),f.data.message==="Platform account url mismatch"){let g=`Please contact your administrator: The platform account url (${f.data.targetOrigin}) is misconfigured as it differs from the origin of the page that opened the popup (${f.data.openerOrigin}).`;k.warn(g),this.store.dispatch(Ar(g)),o(new Error(g))}if(f.data.message==="Timeout"){let g="Please contact your administrator: Popup timed out. Check if the account's platform url is configured correctly.";k.warn(g),this.store.dispatch(Ar(g)),o(new Error(g))}o(new Error(f.data.message));break}}});window.addEventListener("message",p);let u=setInterval(()=>{c&&!c.closed||(l(),d||o(new Error("Popup closed by user")))},200);this.disposeHandlers.push(l)})})}translateMessages(e){return this.deepdeskApi.translateMessages(e)}refreshTextSuggestions(){return v(this,null,function*(){this.isMounted&&(yield this.store.dispatch(Lo()))})}refreshWidgetSuggestions(){return v(this,null,function*(){if(!this.widgetRoot)return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let n=kn(this.state);try{n.forEach(({type:o})=>{switch(o){case"entities":this.store.dispatch(fe());break;case"pinned-messages":case"sticky-messages":break;default:Xn.includes(o)||this.store.dispatch(he(o))}})}catch(o){this.handleError(o)}})}};nn.version="19.1.2-beta.1",nn.count=0;var Cr=nn;function Bx(t){return v(this,null,function*(){var r,s,i;let n=yield((r=t.fetch)!=null?r:window.fetch)(t.url),o=yield n.blob();return new File([o],t.name,{type:(i=(s=t.mimeType)!=null?s:n.headers.get("Content-Type"))!=null?i:"image/jpeg"})})}function Ux(t,e){return v(this,null,function*(){let n=yield Bx(e),o=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(t,"files",{configurable:!0,get:()=>[n]}),t.dispatchEvent(o)}finally{Object.hasOwn(t,"files")&&delete t.files}})}function Kx(t,e,n){return v(this,null,function*(){yield new et(t).authenticateWithKey(e,n)})}function zx(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function Wx(o,r){return v(this,arguments,function*(t,e,n={}){var p,u;let{value:s}=t,{start:i,end:a}=(p=n.replace)!=null?p:{start:0,end:s.length},d=`${s.slice(0,i)}${e}${s.slice(a)}`,l=(u=n.selectionAfter)!=null?u:{start:i+e.length,end:i+e.length},c=()=>{if(n.setValue)return n.setValue(d);t.value=d};return Promise.resolve(c()).then(()=>{t.selectionStart=l.start,t.selectionEnd=l.end,t.blur(),t.focus()})})}function Vx(o,r){return v(this,arguments,function*(t,e,n={}){let s=n.replace?St(t,n.replace.start,n.replace.end):Un(t),i,a=()=>{if(n.setRange)return n.setRange(s.cloneRange());s.deleteContents(),i=document.createElement("span"),s.insertNode(i),n.insertBRs!==!1?e.split(`
11
- `).reverse().forEach((d,l)=>{l>0&&s.insertNode(document.createElement("br")),s.insertNode(document.createTextNode(d))}):s.insertNode(document.createTextNode(e))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){t.focus();let d=n.selectionAfter?St(t,n.selectionAfter.start,n.selectionAfter.end):(s.collapse(!1),s),l=window.getSelection();l==null||l.removeAllRanges(),l==null||l.addRange(d)}if(!i)return;i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}function jx(t){let e=document.createElement("template");return e.innerHTML=t.replace(/(\[([^\]]+)])\(([^)]+)\)/g,'<a href="$3" target="_blank" rel="noopener noreferrer">$2</a>'),e.content}function $x(t){let e=document.createDocumentFragment();return t.split(`
12
- `).forEach((n,o)=>{o>0&&e.appendChild(document.createElement("br"));let r={index:0},s=0;for(;r=n.slice(s).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=r[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(r[2])),e.appendChild(document.createTextNode(n.slice(s,s+r.index))),e.appendChild(i),s=s+r.index+r[0].length}e.appendChild(document.createTextNode(n.slice(s)))}),e}function Nu(t,e){let n=t.parentElement;if(!n){console.warn("No insert point found");return}let{display:o}=window.getComputedStyle(n);o.includes("block")||o==="table-cell"?n==null||n.insertBefore(e,t.nextSibling):Nu(n,e)}function Gx(r,s){return v(this,arguments,function*(t,e,{isBlock:n,isHTML:o}={}){let i;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let a=()=>{var u;let d=(u=t.ownerDocument.defaultView)!=null?u:window,l=d.getSelection();if((!l||l.rangeCount===0)&&(t.focus(),l=d.getSelection()),!l||l.rangeCount===0)return;let c=l.getRangeAt(0);if(!c)return;i=document.createElement("span"),c.insertNode(i);let p=o?jx(e):$x(e);n?Nu(c.startContainer,p):(c.insertNode(p),c.collapse(!1))};return Promise.resolve(a()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!i)try{i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}export{D as Card,Qt as ContentEditableInput,et as DeepdeskAPI,Cr as DeepdeskSDK,en as HTTPClient,Ye as InputMediator,kt as InputType,kr as KeyboardHint,Yu as Label,Jn as Locale,Le as Section,sn as SectionList,je as Sources,I as Suggestion,te as SuggestionList,Zt as TextAreaInput,Et as ToggleButton,Ux as attachFile,Kx as authenticateWithKey,Un as createFullRange,vr as createOverlayContainer,St as createRangeFromOffsets,Pn as escapeHTML,zx as formatTextMarkup,pr as getRangeOffsets,gr as getRangeText,Gx as insertCKEditor,So as isHTML,li as isSupportedInputElement,ps as logEvent,Vx as updateContentEditable,Wx as updateTextArea,gt as useClickOutsideRoot,S as useStyles,gi as waitForElementVisibilityChange};
8
+ 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`})})});import{jsx as vd}from"react/jsx-runtime";var Ih={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},xd=({className:t,color:e})=>vd("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:vd("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:Ih[e||"pink"]})});var Sd={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var Ps={};X(Ps,{enUS:()=>Lh,nlNL:()=>Ah});var Lh={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},Ah={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};import{useDispatch as Oh}from"react-redux";import{jsx as Is,jsxs as bd}from"react/jsx-runtime";var Cd=({onLogIn:t})=>{let e=R(Ps),n=k("floatingMenu"),o=k("productName"),r=Oh(),s=Nh(J),i=S("FloatingMenu",Sd);if(s===null||n===!1)return null;let a=()=>{s===!0?r(me(!0)):t()};return bd("button",{type:"button",className:Mh(i.root,{[i.isLoggedIn]:s,[i.isLoggedOut]:!s}),onClick:a,children:[Is("div",{className:i.text,children:e(s?"search":"signin",{productName:o})}),bd("div",{className:i.icon,children:[Is(xd,{className:i.logo,color:"pink"}),s===!1&&Is(yd,{className:i.lock})]})]})};import{useEffect as ey,useRef as ty}from"react";import{useDispatch as ny,useSelector as jt}from"react-redux";function ke(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:o}=t.settings,{text:r,selection:s}=t.input;return s.start!==s.end?!1:s.end>=r.length?!0:e?n&&new RegExp(n).test(r.substring(s.end))||o&&new RegExp(o).test(r.substring(0,s.end))?!0:n===!1&&o===!1:!1}import{createSlice as Dh}from"@reduxjs/toolkit";var _h={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},$o=({ui:t})=>t.overlayCollapsed,Td=Dh({name:"ui",initialState:_h,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputFocus(t,e){t.overlayCollapsedUserOverwrite!==!0&&(e.payload===!0&&(t.overlayCollapsed=!1),t.inputHasFocus=e.payload)},setOverlayCollapsed(t,e){e.payload.collapse===!1&&(t.openOverlayWhenTyping=!1),!(e.payload.skipWhenInputFocus&&t.inputHasFocus)&&(t.overlayCollapsed=e.payload.collapse)},setOpenOverlayWhenTyping(t,e){t.openOverlayWhenTyping=e.payload},setOverlayCollapsedUserOverwrite(t,e){t.overlayCollapsedUserOverwrite=e.payload,t.overlayCollapsed=e.payload}}}),{setShowTabHint:On,setInputFocus:Go,setOverlayCollapsed:Qe,setOpenOverlayWhenTyping:wd,setOverlayCollapsedUserOverwrite:Ed}=Td.actions,kd=Td.reducer;import{useMemo as Qh}from"react";import{Interweave as Ad}from"interweave";import{useEffect as zh,useMemo as Wh,useRef as Vh,useState as jh}from"react";import{useDispatch as $h,useSelector as Md}from"react-redux";import{useEffect as Fh}from"react";function Rd(t,e,n){Fh(()=>{let o=t.current;return o?(o.addEventListener(e,n),()=>{o.removeEventListener(e,n)}):()=>{}},[t,e,n])}var Pd={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"};import{jsx as Id,jsxs as Hh}from"react/jsx-runtime";var Ld=({title:t})=>Hh("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18px",height:"18px",viewBox:"0 0 24 24","aria-labelledby":"closeTitle",children:[Id("title",{id:"closeTitle",children:t}),Id("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 Ls={};X(Ls,{enUS:()=>Bh,nlNL:()=>Uh});var Bh={assistant:[{type:0,value:"Assistant"}],close:[{type:0,value:"Close"}]},Uh={assistant:[{type:0,value:"Assistent"}],close:[{type:0,value:"Sluiten"}]};import{jsx as He,jsxs as Nd}from"react/jsx-runtime";var Gh=["search","personal-collection-search","search-autocomplete"];function qh(t,e,n,o={}){var s;let r="";return Gh.includes(e)?r=Al(fs(t,n,{stripAgentPart:!0}),(s=o.searchKeywords)!=null?s:[n]):r=fs(t,n,o),o.placeholders===!0&&(r=Ml(r)),r}var Xh=()=>{},Jh=({selected:t,suggestion:e})=>{let n=R(Ls),o=k("inlineSuggestions"),r=Md(At),[s,i]=jh(!1),a=k("enableSuggestionFeedback"),d=Md(g=>g.input.text),l=$h(),c=S("TextSuggestion",Pd),p=Vh(null),u=e.source==="assistant",f=a&&!u;zh(()=>{let g=setTimeout(()=>{l(Zi({text:e.text,suggestion:e}))},500);return()=>{clearTimeout(g)}},[e]),Rd(p,"click",()=>{l(re({suggestion:e,text:e.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let h=()=>{l(st({source:e.source,text:e.text,assistantCode:e.assistantCode}))},m=Wh(()=>qh(e.text,e.source,r,{stripAgentPart:o,placeholders:!0,searchKeywords:e.searchKeywords}),[o,e.text,e.source,r,e.searchKeywords]);return e.source==="gpt"&&!o?null:Nd("div",{className:c.root,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[He(I,{ref:p,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:Xh,children:e.source==="assistant"?Nd("div",{className:c.assistantContainer,children:[He(Ad,{containerTagName:"div",tagName:"span",className:c.formattedTextTruncated,content:m}),He("span",{className:c.assistantBadge,children:n("assistant")})]}):He(Ad,{containerTagName:"div",tagName:"span",className:c.formattedText,content:m})}),f&&s&&He("div",{className:c.actions,children:He(zo,{source:"overlay",context:d,suggestion:e})}),u&&s&&He("div",{className:c.closeIconContainer,children:He("button",{type:"button",className:c.closeIcon,onClick:h,title:n("close"),children:He(Ld,{title:n("close")})})})]})},Od=Jh;import{jsx as Yh}from"react/jsx-runtime";var Zh=({suggestions:t,selectedIndex:e,reverse:n})=>Qh(()=>{let r=t.map((s,i)=>Yh(Od,{index:i,selected:i===e,suggestion:s},`${s.text}-${s.source}`));return n?r.reverse():r},[t,e,n]),qo=Zh;var Dd={root:"dd-PfvRI",paper:"dd-HYlyY"};import{jsx as Xo}from"react/jsx-runtime";var oy=()=>{let t=ty(null),e=S("InlineSuggestionsOverlay",Dd),n=jt(ke),o=ny(),r=jt(J),s=jt(Lt),i=jt($o),a=k("showTextSuggestions"),d=jt(rt),l=jt(dn);return ct(()=>{setTimeout(()=>{o(Qe({collapse:!0,skipWhenInputFocus:!0}))})}),ey(()=>{let c=t.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let p=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-p.right,0)}px`}),i||!n||!a||d.length===0||r!==!0||s===!1?null:Xo("div",{className:e.root,"data-variant":"inline",children:Xo("div",{ref:t,className:e.paper,children:Xo(te,{children:Xo(qo,{suggestions:d,selectedIndex:l})})})})},_d=oy;import iy,{useState as Ms,useEffect as ay}from"react";var Fd={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"};import{useSelector as ly}from"react-redux";var As={};X(As,{enUS:()=>ry,nlNL:()=>sy});var ry={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."}]},sy={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."}]};import{Fragment as dy,jsx as ye,jsxs as Jo}from"react/jsx-runtime";var Hd=({onClose:t,onSave:e,id:n,error:o})=>{let[r,s]=Ms(""),[i,a]=Ms(!1),[d,l]=Ms(!1),c=S("Nickname",Fd),p=iy.useRef(null),u=ly(b=>b.info.showNicknameDialog),f=R(As),h=k("adminUrl");ay(()=>{o&&a(!0)},[o]);let m=()=>{if(!p.current)return;r.trim()?p.current.setCustomValidity(""):p.current.setCustomValidity(f("nicknameDialogError")),p.current.reportValidity()},g=b=>{b.preventDefault();let T=r.trim(),C=b.currentTarget.querySelector("#nickname-input");if(!T){C.setCustomValidity(f("nicknameDialogError")),C.reportValidity();return}C.setCustomValidity(""),e(T)};return Jo(Kt,{isOpen:u,"datatest-id":n,onClose:t||(()=>{}),onBack:t||(()=>{}),children:[ye("div",{className:c.titleWrapper,children:ye("h1",{className:c.title,children:f("title")})}),Jo("form",{className:c.dialogContent,onSubmit:g,children:[ye("p",{children:f("nicknameDialogTitle")}),i&&o&&ye("div",{className:c.errorMessage,children:h?(()=>{let b=f("nicknameDialogSaveError",{account:h}),T=`${h}.deepdesk.com/admin/user-settings`,C=b.indexOf(T);if(C!==-1){let w=b.substring(0,C),L=b.substring(C+T.length);return Jo(dy,{children:[w,ye("a",{href:T,target:"_blank",rel:"noopener noreferrer",className:c.errorLink,children:T}),L]})}return b})():f("nicknameDialogSaveErrorWithoutLink")}),ye("input",{required:!0,minLength:1,maxLength:20,"data-testid":"nickname-input",id:"nickname-input",className:c.nicknameInput,type:"text",placeholder:f("nicknameDialogInputPlaceholder"),value:r,onChange:b=>{l(new RegExp("\\p{Extended_Pictographic}","u").test(b.target.value)),s(b.target.value)},onBlur:m,ref:p}),d&&ye("div",{className:c.errorMessage,role:"alert",children:f("nicknameDialogEmojiError")}),Jo("div",{className:c.buttonsWrapper,children:[o?ye("div",{className:c.closeButtonWrapper,children:ye("button",{type:"button",className:c.closeButton,onClick:()=>t==null?void 0:t(),children:f("close")})}):null,ye("div",{className:c.buttonContinueWrapper,children:ye("button",{type:"submit",className:c.continueButton,disabled:!r.trim()||new RegExp("\\p{Extended_Pictographic}","u").test(r),children:f("nicknameDialogContinueButton")})})]})]})]})};import{Provider as cy}from"react-redux";import{jsx as Qo}from"react/jsx-runtime";var uy=({children:t})=>{let n=k("locale").replace("-","");return Qo(Qr.Provider,{value:n,children:t})},py=({store:t,customStyles:e={},children:n})=>Qo(cy,{store:t,children:Qo(uy,{children:Qo(rn.Provider,{value:e,children:n})})}),Be=py;import Fs from"classnames";import{useEffect as wy,useRef as Ey,useState as ky}from"react";import{useDispatch as Ry,useSelector as Ze}from"react-redux";import{useState as gy}from"react";function Bd(t,e){let[n,o]=gy(()=>{if(typeof window=="undefined")return e;try{let s=window.localStorage.getItem(t);return s?JSON.parse(s):e}catch(s){return E.error(s),e}});return[n,s=>{try{let i=s instanceof Function?s(n):s;o(i),typeof window!="undefined"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){E.error(i)}}]}var Ud=()=>/Mac/i.test(navigator.platform);import hy from"classnames";import{Fragment as yy,useCallback as Os,useMemo as zd}from"react";var Ns={};X(Ns,{enUS:()=>my,nlNL:()=>fy});var my={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"}]}]},fy={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 Kd={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};import{jsx as Zo,jsxs as Wd}from"react/jsx-runtime";var Ds=(t,e,n)=>o=>Zo("button",{className:t.anchorButton,type:"button",value:e,onClick:n,children:o},e),vy=({className:t,loginUrl:e,isEmbedded:n,onSnooze:o,onLogIn:r})=>{let s=R(Ns),i=ne(),a=S("Login",Kd),d=k("productName"),l=Os(g=>{g.preventDefault(),o&&o(Number.parseInt(g.target.value,10))},[]),c=Os(g=>{g.preventDefault(),i.send(_t,!0)},[e]),p=zd(()=>g=>Zo("a",{onClick:T=>{T.preventDefault(),r()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[e]),u=Os(g=>Zo("button",{type:"button",className:a.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:f,hour:h,day:m}=zd(()=>({min:Ds(a,600,l),hour:Ds(a,3600,l),day:Ds(a,3600*12,l)}),[]);return Wd("div",{className:hy(t,a.root),children:[s("loginPlease",{login:n?u:p,productName:d}),o&&Wd(yy,{children:[Zo("br",{}),s("snooze",{min:f,hour:h,day:m})]})]})},Yo=vy;import{useDispatch as xy}from"react-redux";var Vd={root:"dd-DoQhb",text:"dd-Jwnev"};import{jsx as jd,jsxs as by}from"react/jsx-runtime";var Sy=({title:t})=>{let e=S("SearchTrigger",Vd),n=xy(),o=K();return by("button",{type:"button",className:e.root,onClick:()=>{n(me(!0)),o("open search",{via:"autocomplete-overlay"})},children:[jd(Wt,{}),jd("span",{className:e.text,children:t})]})},$d=Sy;var _s={};X(_s,{enUS:()=>Cy,nlNL:()=>Ty});var Cy={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"}]},Ty={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 Gd={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"};import{jsx as q,jsxs as vt}from"react/jsx-runtime";var Py=({onLogIn:t})=>{let e=S("SuggestionsOverlay",Gd),n=R(_s),o=Ze(ke),r=Ze(Qi),s=Ry(),i=Ey(null),a=k("searchTriggerKey"),d=k("productName"),l=Ze($o),c=Ze(J),p=Ze(Hi),u=Ze(Lt),[f,h]=ky(null),m=k("showSearch"),g=k("showTextSuggestions"),b=k("adminUrl"),T=k("isEmbedded"),C=k("suggestionsPlacement"),[w,L]=Bd("dd-snooze-until-ms",0),N=l||w>Date.now(),_=Ze(rt),W=Ze(dn),ce=_.filter(U=>U.source!=="gpt").length,ae=()=>{N&&L(0),s(Ed(!N))},O=U=>{let Ie=Date.now()+U*1e3;L(Ie),E.info(`Snooze until: ${new Date(Ie)}`),s(Qe({collapse:!0}))};return wy(()=>{ce===0&&h(null)},[_,ce]),ct(()=>{s(Qe({collapse:!0,skipWhenInputFocus:!0}))}),c===null||u===!1?null:c===!1?vt("div",{ref:i,className:Fs(e.root,{[e.isCollapsed]:N}),children:[!N&&vt("div",{className:e.triggers,children:[q("div",{style:{flex:1}}),q("div",{className:e.triggersRight,children:q(kt,{className:e.toggleButton,title:n("collapse"),onClick:ae,isCollapsed:!1})})]}),q("div",{className:e.toggleButtonWrapper,children:q(kt,{className:e.toggleButton,title:n("open",{productName:d}),onClick:ae,isCollapsed:!0})}),vt("div",{className:e.collapsible,children:[p&&vt("div",{className:e.loginError,children:[q("span",{className:e.loginErrorMessage,children:p}),q("button",{type:"button",className:e.loginErrorDismiss,onClick:()=>s(Qn()),"aria-label":n("dismissError"),children:n("dismiss")})]}),q(Yo,{loginUrl:b,isEmbedded:T,onLogIn:t,onSnooze:O})]})]}):!r||!o?null:vt("div",{ref:i,className:Fs(e.root,{[e.isCollapsed]:N}),children:[!N&&vt("div",{className:e.triggers,children:[q("div",{style:{flex:1},children:m&&q("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>h(n(Ud()?"searchHintMac":"searchHintWindows",{searchTriggerKey:a.toUpperCase()})),onMouseLeave:()=>h(null),children:q($d,{title:n("search")})})}),vt("div",{className:e.triggersRight,onFocus:()=>{},children:[q("div",{className:Fs(!f&&e.hintsHidden,e.hints),children:f}),q(kt,{className:e.toggleButton,title:n("collapse"),onClick:ae,isCollapsed:!1})]})]}),q("div",{className:e.toggleButtonWrapper,children:q(kt,{className:e.toggleButton,title:n("open",{productName:d}),onClick:ae,isCollapsed:!0})}),ce>0&&g&&q("div",{className:e.collapsible,onFocus:()=>{},children:q(te,{children:q(qo,{suggestions:_,selectedIndex:W,reverse:C==="above"})})})]})},qd=Py;import Ws from"classnames";import{Interweave as mv}from"interweave";import{useCallback as fv,useEffect as hv,useMemo as mc,useRef as yv}from"react";import{connect as vv}from"react-redux";import{useEffect as Iy,useRef as Ly,useState as Ay}from"react";function er(t){return t.contentEditable==="true"}function My(t){let e=0,n=0,o=window.getSelection();if(o.rangeCount!==0){let r=o.getRangeAt(0),s=r.cloneRange();s.selectNodeContents(t),s.setEnd(r.endContainer,r.endOffset),n=s.toString().length,s.selectNodeContents(t),s.setEnd(r.startContainer,r.startOffset),e=s.toString().length}return{selectionStart:e,selectionEnd:n}}function Xd(t){let{selectionStart:e,selectionEnd:n}=er(t)?My(t):t;return[e,n]}function Jd(t){let[,e]=Ay(),n=Ly(null);return n.current=Xd(t),Iy(()=>{let o=()=>{var a;let[r,s]=(a=n.current)!=null?a:[],i=Xd(t);(!i||r!==i[0]||s!==i[1])&&(n.current=i,e({}))};return t.addEventListener("keyup",o),t.addEventListener("click",o),t.addEventListener("focus",o),document.addEventListener("selectionchange",o),()=>{t.removeEventListener("keyup",o),t.removeEventListener("click",o),t.removeEventListener("focus",o),document.removeEventListener("selectionchange",o)}},[t]),n.current}function Qd(t,e){if(!e)return;let n=t,{value:o}=n,[r,s]=e,i=o.match(qn);if(!i||i.length===0)return;let a=0;i.find(d=>{let l=o.indexOf(d,a);return r>l&&s<l+d.length?(n.selectionStart=l,n.selectionEnd=l+d.length,!0):(a=l+d.length,!1)})}import{cloneElement as Ny}from"react";var Oy=["div","span","mark","strong","b","i","u","em"];function Hs(t,e,n=0){var s;let o=t[t.length-1],r=typeof o=="object"&&o!==null?(s=o.props)==null?void 0:s.tagName:void 0;if(r==="br")return t.pop(),[...t,...e,o];if(Oy.includes(r)){let i=Array.isArray(o.props.children)?o.props.children:[o.props.children];return[...t.slice(0,t.length-1),Ny(o,{children:Hs(i,e,n+1)})]}return[...t,...e]}function xt(t){return t.tagName.toLowerCase()==="textarea"}var Zd={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"};import Ky from"classnames";import{Matcher as zy}from"interweave";import{useEffect as Wy,useMemo as Vy}from"react";import{useEffect as Dy,useRef as _y,useState as Fy}from"react";function Yd(t,e){let n;return[(...o)=>{window.cancelAnimationFrame(n);let r=e?e(...o):o;n=window.requestAnimationFrame(()=>{t(...r)})},()=>window.cancelAnimationFrame(n)]}function tr(t){let e=_y(null),[n,o]=Fy(!1);return Dy(()=>{var c;let r=!1,s=Number.parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[i,a]=Yd((p,u)=>{let f=e.current;if(!f)return;let h=p/s,m=u/s,g=f.getBoundingClientRect(),b=h>g.x&&h<g.x+g.width&&m>g.y&&m<g.y+g.height;b&&!r?(r=!0,o(!0)):!b&&r&&(r=!1,o(!1))},({clientX:p,clientY:u})=>[p,u]),[d,l]=Yd(()=>{r=!1,o(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",d),()=>{a(),l(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",d)}},[e]),[e,n]}function ec(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function nr(t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}function tc(t){return t!=null}import Hy from"classnames";import{forwardRef as By,useRef as Uy}from"react";var Ue={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"};import{jsx as nc}from"react/jsx-runtime";var or=By((r,o)=>{var s=r,{className:t,children:e}=s,n=M(s,["className","children"]);let i=Uy(null),a=S("TabCompletion",Ue);return nc("div",x(y({ref:nr([i,o]),className:Hy(t,a.popoverContentContainer)},n),{children:nc("div",{className:a.popoverContent,children:e})}))});import{jsx as Dn,jsxs as Gy}from"react/jsx-runtime";var jy=t=>e=>{let n=rs(e);return"top"in n&&(n.width=t.width-(e.left-t.left)-10),n},$y=({inputElement:t,boundaryRef:e,inputStyle:n,children:o,suggestion:r})=>{let s=S("TabCompletion",Ue),i=wo(),a=Vy(()=>jy(t.getBoundingClientRect()),[t]),[d,l]=tr(t);return Wy(()=>{l?i.open():i.close()},[l]),Gy("span",{children:[Dn("mark",{ref:nr([d,i.triggerRef]),className:Ky(s.matchKeyword,{[s.hover]:l}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:o}),i.opened&&Dn(Ht,{className:s.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:Dn(or,{style:n,children:Dn("div",{className:s.hintText,children:r})})})]})},rr=class extends zy{constructor(){super(...arguments);this.keywordMatches=[];this.preparedKeywordMatches=[];this.usedKeywordMatches=new Set}onBeforeParse(n,o){return o.keywordMatches&&o.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=o.keywordMatches.map(r=>x(y({},r),{keywordRegex:new RegExp(`\\b${ec(r.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let o=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),d=n.charAt(i.index+s.keyword.length);return a==="{"&&d==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(tc);if(o.length===0)return null;let r=o.reduce((s,i)=>i.index<s.index?i:s);return this.usedKeywordMatches.add(r.preparedKeywordMatch),r}replaceWith(n,o){return Dn($y,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:n},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import{Matcher as qy}from"interweave";import Xy from"classnames";import{jsx as oc}from"react/jsx-runtime";var Jy=({inputElement:t,children:e})=>{let n=S("TabCompletion",Ue),[o,r]=tr(t);return oc("mark",{ref:o,className:Xy(n.matchPlaceholder,{[n.hover]:r}),children:e})},sr=class extends qy{match(e){let n=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(e,n){return oc(Jy,{inputElement:n.inputElement,children:e},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};import zs from"classnames";import{Matcher as iv}from"interweave";import{createRef as av,forwardRef as lv,useCallback as dv,useEffect as uc,useRef as pc,useState as gc}from"react";import{useDispatch as cv,useSelector as uv}from"react-redux";import{jsx as rc}from"react/jsx-runtime";var sc=()=>rc("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:rc("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"})});import{useCallback as Qy,useEffect as ac,useMemo as Zy,useState as lc}from"react";import{useDispatch as Yy,useSelector as dc}from"react-redux";import ev from"lodash.debounce";var ic={root:"dd-ky-Bv",content:"dd-kV5e1"};function ir(t,e,n){var r;let o=((r=t.imageSizes)==null?void 0:r[e])||t.image||n;if(!o)return null;try{return new URL(o).toString()}catch(s){return null}}function Bs(t){return t.replace("https://www.","").replace("https://","")}import{jsx as St,jsxs as Us}from"react/jsx-runtime";var tv=3,nv=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),ov=({onSelectLink:t,onDismiss:e,placeholder:n,visitUrlText:o,linkCount:r=tv})=>{let s=S("LinkSearch",ic),[i,a]=lc(""),d=Yy(),l=dc(ad("url")),c=dc(ba("URL")),p=Zy(()=>c.map(nv),[c]),[u,f]=lc(p.length-1),h=k("fallbackImage"),m=C=>{let w=C.target;a(w.value)},g=(C,w)=>{C.stopPropagation(),C.preventDefault(),window.open(w,"_blank")},b=C=>{var N;let w=u-1<0?p.length-1:u-1,L=u+1===p.length?0:u+1;C.code==="Escape"&&(a(""),e()),C.code==="ArrowUp"&&f(w),C.code==="ArrowDown"&&f(L),C.code==="Enter"&&t(((N=p[u])==null?void 0:N.text)||i)},T=Qy(ev(C=>{d(at({query:C,type:"URL",tags:["link-search"]}))},300),[]);return ac(()=>{i&&T(i)},[i]),ac(()=>()=>{d(ao())},[]),Us("div",{className:s.root,children:[St(te,{withDivider:!0,children:(i?p:l).slice(0,r).map((C,w)=>St(I,{selected:u===w,onClick:()=>t(C.text),"data-testid":"linksearch-suggestion",children:Us(D,{children:[St(D.Image,{src:ir(C,"small",h||void 0),title:C.title||C.text}),Us(D.Content,{className:s.content,cropText:!0,children:[St(D.Title,{children:C.title||Bs(C.text)}),C.title&&Bs(C.text)]}),St(I.Actions,{children:St(I.ActionButton,{label:o,onClick:L=>g(L,C.text)})})]})},C.text))}),St(En,{value:i,onChange:m,autoFocus:!0,placeholder:n,onKeyUp:b})]})},cc=ov;var Ks={};X(Ks,{enUS:()=>rv,nlNL:()=>sv});var rv={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"}]},sv={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"}]};import{jsx as ve,jsxs as ar}from"react/jsx-runtime";var pv=lv((t,e)=>{let n=S("TabCompletion",Ue);return ve("mark",{ref:e,className:zs(n.matchSelection)},"selection-start")}),gv=({startRef:t,boundaryRef:e,inputStyle:n,inputElement:o,children:r})=>{let s=R(Ks),i=S("TabCompletion",Ue),a=k("addToPersonalCollection"),d=uv(Xe("/admin/personal-collection/new")),l=pc(null),c=pc(null),[p,u]=gc(null),f=cv(),h=wo(document.activeElement===o),[m]=gc(()=>document.createRange());h.triggerRef.current=m,uc(()=>()=>m.detach(),[]),uc(()=>{let b=t.current,T=l.current;!b||!T||(m.setStart(b,0),m.setEnd(T,0))},[t.current,l.current]),ct(()=>{h.close()});let g=dv(b=>{let T=m.toString(),C=/^http(s?):\/\//.test(b)?b:`https://${b}`,w=`[${T}](${C})`;f(re({text:w,suggestion:{text:w,source:"search-url",type:"url"},eventMetrics:{inputType:"mouse"},replace:"selection"}))},[]);return ar("span",{children:[ve("mark",{ref:l,className:zs(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":h.opened?"true":"false",children:r}),h.opened&&ve(Ht,{className:i.popoverRoot,triggerRef:h.triggerRef,boundaryRef:e,position:"above",align:"start",children:ar(or,{style:n,ref:c,children:[ar("div",{className:zs(i.selectionOptions,{[i.selectionOptionsIsHidden]:p!==null}),children:[ar("button",{type:"button",tabIndex:p===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>u("insertLink"),children:[ve(sc,{}),ve("span",{children:"\xA0"}),ve("span",{children:s("insertLink")})]}),a&&d&&ve("button",{type:"button",tabIndex:p===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>{let b=m.toString(),T=`${d}?text=${encodeURIComponent(b)}`;window.open(T,"_blank")},children:ve("span",{children:s("addToPersonalCollection")})})]}),p==="insertLink"&&ve(cc,{placeholder:s("linkInputPlaceholder"),visitUrlText:s("visitUrl"),onSelectLink:g,onDismiss:()=>{u(null),h.close()}})]})})]},"selection-end")},lr=class extends iv{constructor(){super(...arguments);this.charCount=0;this.foundIndex=0;this.startRef=null}onBeforeParse(n,o){return this.props=o,this.charCount=0,this.startRef=av(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,r]=this.props.selection;if(o===r)return null;let s=this.foundIndex===0?o:r,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?y({isStart:a},i):null}replaceWith(n,o){return o.isStart?ve(pv,{ref:this.startRef}):ve(gv,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};import{useSelector as xv}from"react-redux";import{jsx as $t,jsxs as Cv}from"react/jsx-runtime";var Sv=({enabled:t,content:e,tabText:n,showTabHint:o,showTabCompletion:r,showStyleSuggestions:s,keywordMatches:i,inputElement:a,source:d})=>{let l=S("TabCompletion",Zd),c=k("insertLink"),p=k("addToPersonalCollection"),u=k("showMidSentenceSuggestions"),f=k("inlineSuggestions"),h=Jd(a),m=yv(null),g=xv(J);hv(()=>{xt(a)&&h&&Qd(a,h)},[h]);let b=fv(w=>{if(!r||!n)return w;let L=[$t("span",{className:l.resetIndent,children:"\u200B"},"u200B"),$t("span",{"data-testid":"tab-completion",className:Ws(l.tabText,l.resetIndent),"data-source":d,children:n},"tabText")];return o&&L.push($t("span",{className:Ws(l.hint,l.resetIndent),children:$t(kr,{keyCode:"tab"},"tabHint")},"tabHint")),Hs(w,L)},[r,n,o]),T=mc(()=>{let w=[];return(c||p)&&w.push(new lr("selection")),w.push(new sr("placeholders")),s&&w.push(new rr("keywords")),w},[f,c,p,s]),C=mc(()=>{let w=window.getComputedStyle(a);return{"--dd-color":w.color,"--dd-font-size":w.fontSize,"--dd-font-family":w.fontFamily,"--dd-font-variant":w.fontVariant}},[]);return!t||!g?null:Cv("div",{ref:w=>{w!=null&&w.parentElement&&(m.current=w==null?void 0:w.parentElement)},className:l.root,style:C,children:[$t(mv,{tagName:"span",containerTagName:"div",className:Ws(l.container,l.agentText),disableLineBreaks:xt(a),content:e||"\u200B",onAfterParse:b,matchers:T,selection:h,keywordMatches:i,inputElement:a,inputStyle:C,boundaryRef:m,inlineSuggestionsOnlyAtEnd:!u}),$t("br",{})]},"tab-completion")},bv=t=>{var g,b,T;let{input:e,ui:n,settings:o,styleSuggestions:r,conversation:s}=t,i=Mt({input:e}),a=(i==null?void 0:i.text)||"",d=(i==null?void 0:i.source)||"",l=(g=e.html)!=null?g:Ln(e.text),c=a.indexOf(e.text)===0?a.slice(e.text.length):"",{showTabHint:p}=n,{isSupported:u}=s,{showTabCompletion:f,visible:h,showStyleSuggestions:m}=o;return{showTabHint:p,showStyleSuggestions:m,showTabCompletion:f&&ke(t),content:l,tabText:c,source:d,keywordMatches:(T=(b=r.list)==null?void 0:b.keywordMatches)!=null?T:[],enabled:h&&u!==!1}},fc=vv(bv)(Sv);import{Fragment as lx,useEffect as Qs,useState as dx}from"react";import{useDispatch as Gc,useSelector as Z}from"react-redux";import{createAsyncThunk as hc,createSlice as Tv}from"@reduxjs/toolkit";var wv={token:null,interval:null},Vs=hc("passwordlessToken/getTemporaryPasswordlessToken",(t,e)=>v(null,null,function*(){let{deepdeskAPI:n}=e.extra;return{token:yield n.requestPasswordlessToken()}})),js=hc("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:n=1e3*60*10}=t,{dispatch:o}=e;return o(Vs()),setInterval(()=>o(Vs()),n)}),yc=Tv({name:"passwordlessToken",initialState:wv,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Vs.fulfilled,(e,n)=>{e.token=n.payload.token}),t.addCase(js.fulfilled,(e,n)=>{e.interval=n.payload})}}),{stopPollPasswordlessToken:vc}=yc.actions,xc=yc.reducer;import{createSelector as Ev}from"@reduxjs/toolkit";function kv(t){return"buttonText"in t&&"eventName"in t}function Sc(t){if(t)return kv(t)?{label:t.buttonText,event:t.eventName,value:t.payload}:t}function Rv(t){return t==null?void 0:t.map(e=>Sc(e))}function Pv(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}var bc=Ev([Fa],t=>t.map(n=>{let o=Sc(n.callToAction),r=Rv(n.callToActions);return x(y(y(y({text:n.response,title:n.name},o?{callToAction:o}:{}),r!=null&&r.length?{callToActions:r}:{}),n.message!==void 0?{message:n.message}:{}),{editable:n.editable,isLoading:n.isLoading,evaluationId:n.evaluationId,rule:{id:Pv(n.code),label:n.code,name:n.name,description:n.name}})}));import{useEffect as Iv,useState as Lv}from"react";import wc from"classnames";import{jsx as Cc}from"react/jsx-runtime";var Gt=()=>Cc("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:Cc("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 Tc={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};import{jsx as qt,jsxs as Ec}from"react/jsx-runtime";var Av=({entities:t})=>{let e=S("EntitiesWidgetList",Tc),[n,o]=Lv(void 0),r=K(),s=()=>{o(void 0)},i=a=>{t&&(o(t.indexOf(a)),Ce(a.text),r("entity copied",{entity:a,type:"copy"}))};return Iv(()=>{let a=setTimeout(s,500);return()=>{clearTimeout(a)}},[n]),!t||t.length===0?null:qt("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,d)=>Ec("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[qt("span",{className:e.entityText,children:a.text}),Ec("span",{className:e.iconWrapper,children:[qt("span",{className:wc(e.icon),children:qt(Gt,{})}),qt("span",{className:wc(e.icon,n===d&&e.iconClicked),children:qt(Gt,{})})]})]},a.text))})},kc=Av;import{jsx as Rc}from"react/jsx-runtime";var Pc=()=>Rc("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Rc("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});import{useRef as Fv}from"react";import{useSelector as Hv}from"react-redux";var Ic={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var Lc={root:"dd-nazq3",rotation:"dd-3EHTv"};import{jsx as Nv}from"react/jsx-runtime";var Mv=({size:t=12})=>{let e=S("LoadingSpinner",Lc);return Nv("span",{"data-testid":"loading-spinner",style:{width:`${t}px`,height:`${t}px`},className:e.root})},Ac=Mv;import{jsx as Mc}from"react/jsx-runtime";var Nc=()=>Mc("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512",fill:"currentColor",children:Mc("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"})});import{jsx as Oc,jsxs as Ov}from"react/jsx-runtime";var Dc=t=>Ov("svg",x(y({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 448 512","aria-labelledby":"checkTitle"},t),{children:[Oc("title",{id:"checkTitle",children:"Check"}),Oc("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 $s={};X($s,{enUS:()=>Dv,nlNL:()=>_v});var Dv={error:[{type:0,value:"Something went wrong"}]},_v={error:[{type:0,value:"Er ging iets fout"}]};import{jsx as Ke,jsxs as _c}from"react/jsx-runtime";var Bv=3e3,Uv=({assistantOptions:t})=>{let e=S("OnDemandAssistants",Ic),n=R($s),o=Fv(),r=uo(be),s=Hv(wl),i=K(),a=s.filter(c=>c.isPinned),d=s.filter(c=>!c.isPinned),l=c=>v(null,null,function*(){clearTimeout(o.current),i("trigger on demand assistant",{assistantCode:c}),yield r.call(x(y({},t),{assistantCode:c})),o.current=setTimeout(()=>r.reset(),Bv)});return s.length===0?null:_c("div",{className:e.root,children:[a.map(({assistant:c,assistantName:p,displayName:u})=>Ke("button",{type:"button",className:e.button,disabled:r.state==="loading",onClick:()=>l(c),children:u||p},c)),d.length>0&&_c($,{placement:"top-end",children:[Ke($.Trigger,{className:e.trigger,disabled:r.state==="loading",children:Ke(Bo,{"data-testid":"trigger"})}),Ke($.Content,{className:e.nav,"data-testid":"popover",children:d.map(({assistant:c,assistantName:p,displayName:u})=>Ke($.Button,{className:e.item,disabled:r.state==="loading",onClick:()=>l(c),children:u||p},c))})]}),r.state==="loading"&&Ke(Ac,{}),r.state==="done"&&Ke(Dc,{"data-testid":"trigger-done"}),r.state==="error"&&Ke(ll,{trigger:Ke(Nc,{}),children:n("error")})]})},Fc=Uv;import{useDispatch as Xv}from"react-redux";var _n={};X(_n,{enUS:()=>Kv,nlNL:()=>zv});var Kv={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"}]},zv={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"}]};import{useEffect as Hc,useRef as Wv,useState as Vv}from"react";var Gs={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"};import{jsx as xe,jsxs as dr}from"react/jsx-runtime";var jv=500,$v=100,Gv=({content:t,onChange:e,onCopy:n})=>{let o=Wv(null),r=S("WidgetCue",Gs);return Hc(()=>{let s=o.current;if(!s)return;s.style.setProperty("height","0px");let i=Math.min(Math.max(s.scrollHeight,$v),jv);s.style.setProperty("height",`${i}px`)},[t]),xe("textarea",{ref:o,className:r.editableCue,onCopy:n,onChange:e,value:t})},qv=({cue:t,onCallToAction:e,onRemove:n,onCopy:o,onUse:r})=>{var m;let s=S("WidgetCue",Gs),i=R(_n),a=K(),d=k("hasKeyboardInput"),[l,c]=Vv(t.text),p=g=>{let b=g?x(y({},t),{callToAction:g}):t;e&&e(l,b),n(t)},u=(g,b)=>{o&&o(g,t),b&&qe(b,s.fadeup)},f=g=>{r&&r(g,t)},h=g=>{g.preventDefault(),g.stopPropagation(),n(t)};return Hc(()=>{a("Assistant response displayed",{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text})},[]),dr(I,{"data-testid":"cue",children:[xe(D,{children:dr(D.Content,{children:[t.title&&xe(D.Title,{className:s.title,"data-testid":"widget-cue-title",children:t.rule.label.startsWith("__")?i(t.rule.label):t.title}),t.message&&xe("p",{className:s.ctaMessage,children:t.message}),t.editable?xe(Gv,{content:l,onCopy:()=>{let g=document.getSelection();g&&u(g.toString())},onChange:g=>{var b;return c((b=g.target.value)!=null?b:"")}}):xe(pt,{content:t.text,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:u,onUse:d?f:void 0})]})}),dr(I.ButtonsContainer,{children:[dr("div",{className:s.actions,children:[xe(I.Button,{onClick:g=>{var b;return u((b=xo(l,"reply")[0])!=null?b:l,g.target)},variant:"primary",children:i("copyCue")}),t.callToAction&&xe(I.Button,{onClick:()=>p(),variant:"primary",children:t.callToAction.label}),(m=t.callToActions)==null?void 0:m.map((g,b)=>xe(I.Button,{onClick:()=>p(g),variant:"primary",children:g.label},`${g.event}-${g.label}-${b}`)),xe(I.Button,{onClick:h,variant:"secondary",children:i("removeCue")})]}),xe(To,{evaluationId:t.evaluationId,assistantCode:t.rule.label,assistantOutput:t.text,feedbackText:t.text,feedbackType:"assistant"})]})]})},Bc=qv;import{Fragment as Qv,jsx as qs}from"react/jsx-runtime";var Jv=({cues:t})=>{let e=Xv(),n=ne(),o=R(_n),r=K(),s=l=>{e(bo({code:l.rule.label})),r("Assistant response closed",{evaluationId:l.evaluationId,assistantCode:l.rule.label,assistantOutput:l.text})},i=(l,c)=>{Ce(l),r("Assistant response copied",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,copiedText:l})},a=(l,c)=>{var p;c.callToAction&&(e(So(c)),r("Assistant call to action",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,eventName:c.callToAction.event,value:(p=c.callToAction.value)!=null?p:l}))},d=(l,c)=>{var p;n.send(Me,{text:l,suggestion:{source:"assistant",assistantCode:(p=c.rule)==null?void 0:p.label,sourceText:l}}),r("Assistant response used",{evaluationId:c.evaluationId,assistantCode:c.rule.label,assistantOutput:c.text,usedText:l})};return qs(Qv,{children:t.map(l=>l.isLoading?qs(Ro,{title:l.rule.label.startsWith("__")?o(l.rule.label):l.title},l.rule.id):qs(Bc,{cue:l,onCallToAction:a,onRemove:s,onCopy:i,onUse:d},l.evaluationId))})},Uc=Jv;import{Fragment as Zv,useEffect as Yv}from"react";var Kc={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};import{jsx as ze,jsxs as Xs}from"react/jsx-runtime";function ex(t,e){return e.split(".").reduce((n,o)=>!n||typeof n!="object"||!(o in n)?null:n[o],t)}var zc=({data:t,schema:e})=>{let n=S("WidgetCustomData",Kc),o=r=>{Ce(r)};return Yv(()=>{E.info("Custom data",t,e)},[t]),ze("dl",{className:n.root,children:e.map(r=>{let s=ex(t,r.path);return Xs(Zv,{children:[ze("dt",{className:n.label,children:r.label}),ze("dd",{className:n.value,children:r.type==="boolean"&&s?ze("span",{className:n.isTrue,children:r.trueValue}):r.type==="boolean"&&!s?ze("span",{className:n.isFalse,children:r.falseValue}):r.type==="array"&&Array.isArray(s)&&s.length>0?Xs("button",{type:"button",onClick:()=>o(s.join(", ")),className:n.copyButton,children:[ze("span",{className:n.copyButtonText,children:s.join(", ")}),ze(Gt,{})]}):typeof s=="string"||typeof s=="number"?Xs("button",{type:"button",onClick:()=>o(`${s}`),className:n.copyButton,children:[ze("span",{className:n.copyButtonText,children:s}),ze(Gt,{})]}):"-"})]},r.label)})})};import{useCallback as nx}from"react";var tx=/(https?:\/\/[^\s]+)/,Wc=t=>t.split(" ").find(e=>tx.test(e));import{jsx as Xt,jsxs as cr}from"react/jsx-runtime";var ox=({suggestion:t,lines:e,onUse:n})=>{var p;let o=t.text||t.url||t.message,r=Wc(o),s=R(An),i=k("showImages"),a=k("fallbackImage"),d=k("hasKeyboardInput"),l=u=>{u.preventDefault(),u.stopPropagation(),d&&n(o)},c=nx(u=>{window.open(r,"_blank"),u.stopPropagation(),u.preventDefault()},[r]);return cr(I,{onClick:d?l:void 0,"data-testid":"edit-suggestion",children:[cr(D,{children:[i&&t.image&&Xt(D.Image,{src:ir(t,"small",a||void 0),title:t.title}),cr(D.Content,{children:[t.title&&Xt(D.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((p=t.searchKeywords)==null?void 0:p.length)>0&&Xt(I.Labels,{labels:t.searchKeywords}),Xt(D.Content,{cropText:e==="single",lineClamp:e==="multiple",children:o})]})]}),cr(I.Actions,{children:[r&&Xt(I.ActionButton,{onClick:c,label:s("visitUrl")}),d&&Xt(I.ActionButton,{primary:!0,onClick:l,label:s("useSuggestion")})]})]})},Vc=ox;import{Fragment as sx,jsx as jc}from"react/jsx-runtime";var rx=({lines:t,suggestions:e})=>{let n=ne(),o=(r,s)=>{n.send(Me,{text:r,suggestion:x(y({},s),{source:s.source,sourceText:s.text})})};return jc(sx,{children:e.map(r=>jc(Vc,{suggestion:r,lines:t,onUse:s=>o(s,r)},r.text||r.url||r.message))})},$c=rx;var Fn={};X(Fn,{enUS:()=>ix,nlNL:()=>ax});var ix={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"}]},ax={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 Jt={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",footer:"dd-tvofr",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",footerShortcut:"dd-dH7XJ",link:"dd-DRo0x"};import{jsx as P,jsxs as Hn}from"react/jsx-runtime";var qc=(t,e)=>{let n=Z(J);Qs(()=>n?e.every(o=>!!o)?t():()=>{}:()=>{},[...e,n])},cx=({onLogIn:t})=>{let e=S("Widget",Jt),n=k("isEmbedded"),o=k("adminUrl");return P("div",{className:e.loginText,children:P("div",{children:P(Yo,{isEmbedded:n,loginUrl:o,onLogIn:t})})},"login")},Js=({text:t})=>{let e=S("Widget",Jt);return P("div",{className:e.stateText,children:P("div",{children:P("p",{children:t})})},"notification")},ux=()=>{let t=R(Fn),e=Gc(),n=S("Widget",Jt),o=k("showSearch"),r=k("isEmbedded"),s=Z(Xe("/admin/")),i=ne(),a=k("productName"),d=K();return qc(()=>{if(r)return e(js()),()=>{e(vc())}},[e,r]),!o&&!s?null:Hn("div",{className:n.shortcutList,children:[o&&P(I.Button,{"data-testid":"shortcut-search","aria-label":t("linkSearch"),className:n.shortcut,icon:P(Wt,{}),onClick:()=>{i.send("ShowCommandPalette",{isOpen:!0}),d("open search",{via:"widget-shortcut"})},children:t("linkSearch")}),s&&P(I.Button,{as:"a",target:"_blank",icon:P(Pc,{}),href:s,"data-testid":"shortcut-studio-login","aria-label":t("linkStudioLogin",{productName:a}),className:n.shortcut,rel:"noreferrer",onClick:()=>{d("open my deepdesk",{via:"widget-shortcut"})},children:t("linkStudioLogin",{productName:a})})]})},px=({title:t,content:e})=>{let n=R(Fn),[o,r]=dx(!0);return o?P(Le,{"data-testid":"custom-data-banner",type:"custom-data-banner",title:t,children:P(te,{withDivider:!0,children:Hn(I,{children:[P(D,{children:P(D.Content,{children:P(pt,{content:e})})}),P(I.ButtonsContainer,{children:P(I.Button,{onClick:()=>r(!1),children:n("close")})})]})})}):null},gx=()=>{let t=Gc(),e=Z(Pn),n=Z(kl),o=Z(bc),r=Z(ca),s=Z(Ho),i=Z(Wo),a=Z(ft),d=Z(Se);return Qs(()=>{r&&!n&&E.warn("Custom data provided, but no schema.")},[r,n]),qc(()=>{e.forEach(({type:l})=>{l==="entities"?t(fe()):Xn.includes(l)||t(he(l))})},[t,d,a]),Qs(()=>{o.length>0&&!e.some(l=>l.type==="cues")&&E.warn("Received cues, but cues are not configured in widget.")},[e,o]),P(lx,{children:e.map(({type:l,title:c,amount:p,lines:u,schema:f,property:h})=>{var m,g;switch(l){case"entities":return s&&s.length>0&&P(Le,{type:l,title:c,"data-testid":`type-${l}`,children:P(kc,{entities:s})},l);case"cues":return o&&o.length>0&&P(Le,{type:l,title:c,"data-testid":`type-${l}`,children:P(te,{withDivider:!0,children:P(Uc,{cues:o})})},l);case"custom-data-banner":return r&&h&&r[h]&&P(px,{title:c,content:String(r[h])},l);case"custom-data":return r&&f&&P(Le,{type:l,title:c,"data-testid":`type-${l}`,children:P(te,{withDivider:!0,children:P(zc,{data:r,schema:f})})},l);default:return((g=(m=i[l])==null?void 0:m.suggestions)==null?void 0:g.length)>0&&P(Le,{type:l,title:c,"data-testid":`type-${l}`,children:P(te,{withDivider:!0,children:P($c,{lines:u,contentType:l,suggestions:i[l].suggestions.slice(0,p)||[]})})},l)}})})},Zs=({children:t})=>{let e=S("Widget",Jt);return P("div",{className:e.footer,children:t})},Ys=({children:t})=>{let e=S("Widget",Jt);return P("div",{className:e.root,"data-testid":"widget",children:t})},mx=({onLogIn:t,knowledgeAssistOptions:e={},assistantOptions:n={transcript:"in-memory-transcript"}})=>{let o=R(Fn),r=Z(Lt),s=Z(J),i=Z(Gi),a=Z(ft),d=Z(El("knowledge-assist")),l=Z(Rl);return r===!1?P(Js,{text:o("notSupported")}):s===!1?P(cx,{onLogIn:t}):s===null?P(Js,{text:o("waiting")}):!i||!a?P(Js,{text:o("waitingForConversation")}):P(Ys,{children:Hn(Ao,{initialQuestion:e.initialQuestion,assistantCode:l!=null?l:void 0,evaluateKnowledgeAssistFn:Tn,children:[Hn(sn,{children:[P(ux,{}),P(gx,{}),d&&P(No,{title:d.title,emptyState:e.emptyState})]}),Hn(Zs,{children:[d&&P(Mo,{}),P(Fc,{assistantOptions:n})]})]})})},Xc=mx;function Un(t){let e=new Range;return e.selectNodeContents(t),e}function Jc(t,e,n){try{return bt(t,e,n),!0}catch(o){return!1}}function ur(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function pr(t){return"tagName"in t&&t.tagName==="BR"}var Bn=/[\u200B-\u200D\uFEFF]/g;function bt(t,e,n){let o=new Range;if(t.firstChild===null&&e===0&&n===0)return o.selectNodeContents(t),o;let r=0,s=!1;function i(d,l){let c=-1,p=/[\u200B-\u200D\uFEFF]/;if(!p.test(d))return l;for(let u=0;u<=d.length;u++)if(p.test(d[u])||c++,c===l)return u;throw new Error("Offset out of range")}function a(d){switch(d.nodeType){case Node.TEXT_NODE:{let l=d.textContent,c=l.replace(Bn,""),p=r+c.length,u=e>=r&&e<=p,f=n>=r&&n<=p;if(u){let h=i(l,e-r);h===0&&!f?o.setStartBefore(d):o.setStart(d,h)}f&&(o.setEnd(d,i(l,n-r)),s=!0),r=p;break}case Node.ELEMENT_NODE:{if(pr(d)&&(r===e&&o.setStartBefore(d),r++,r===n)){o.setEndAfter(d),s=!0;return}for(let c=0;c<d.childNodes.length&&(a(d.childNodes[c]),!s);c++);let l=d.lastChild;ur(d)&&l&&!ur(l)&&!pr(l)&&r++;break}default:break}}if(a(t),o.startContainer===document)throw new Error("Offsets out of bound");return o}function gr(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:r,endOffset:s,collapsed:i}=e,a,d,l=0;function c(p){let u=p===t,f=p===n,h=p===r;switch(p.nodeType){case Node.TEXT_NODE:{let m=p.textContent;f&&(a=l+m.substring(0,o).replace(Bn,"").length),h&&(d=l+m.substring(0,s).replace(Bn,"").length),l+=m.replace(Bn,"").length;break}case Node.ELEMENT_NODE:{if(pr(p)&&p.nextSibling){l++;break}!u&&ur(p)&&p.previousSibling&&l++;for(let m=0;m<p.childNodes.length;m++){let g=f&&m===o,b=h&&m===s;if(g&&(a=l),b&&(d=l),d!==void 0||((!g||!i)&&c(p.childNodes[m]),h&&m===s-1&&(d=l),d!==void 0))break}h&&(d=l);break}default:break}}if(c(t),d===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:d,end:d}}function mr(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:r,endOffset:s,collapsed:i}=e,a=0,d="";function l(c){let p=c===t,u=c===n,f=c===r;switch(u&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let h=u?o:0,m=f?s:void 0;d+=c.textContent.replace(Bn,"").substring(h,m);break}case Node.ELEMENT_NODE:{if(!i&&a===1&&pr(c)&&c.nextSibling){d+=`
9
+ `;break}!p&&!i&&a===1&&ur(c)&&c.previousSibling&&(d+=`
10
+ `);let h=u?o:0,m=f?Math.min(s,c.childNodes.length):c.childNodes.length;for(let g=h;g<m&&(l(c.childNodes[g]),a!==2);g++);break}default:break}f&&(a=2)}return l(t),d}var Qc=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(Qc||{}),Ye=class{constructor(e){this.element=e;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(e,n){let o=r=>{n(r)};this.element.addEventListener(e,o),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,o)})}removeEventListener(e,n){this.element.removeEventListener(e,n)}handleInteraction(){let e=this.getText(),n=this.getHTML(),o=this.getSelection(),r=this.cachedCaretPosition===null;if(!this.isActive||(e===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),e!==this.cachedText?(this.cachedText=e,this.cachedHTML=n,r=!0,this.emit("change",{plainText:e,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,r=!0,this.emit("change",{plainText:e,rawHTML:n})),(o.start!==this.cachedSelection.start||o.end!==this.cachedSelection.end)&&(this.cachedSelection=o,r=!0,this.emit("selection",o)),!r))return;let s=this.getCaretPosition();$e(s,this.cachedCaretPosition)||(this.cachedCaretPosition=s,this.emit("caretposition",s))}handleClick(){this.handleInteraction()}handleFocus(){let e=!this.isFocused;this.isFocused=!0,e&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let e=this.isFocused;this.isFocused=!1,e&&this.emit("blur")}handleKeyDown(e){let{key:n,ctrlKey:o,metaKey:r}=e;this.isPossibleClearInputAction=Object.values(Qc).includes(n)||n.toLowerCase()==="z"&&(o||r),this.emit("keydown",e)}handleKeyUp(e){this.handleInteraction(),this.emit("keyup",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var o,r;let n=((o=e.clipboardData)==null?void 0:o.getData("text"))||((r=e.clipboardData)==null?void 0:r.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 e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()})}focus(){this.element.focus()}emit(e,...n){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(o=>{o(...n)})}on(e,n){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n))}off(e,n){if(!this.eventListeners[e])return;let o=this.eventListeners[e].indexOf(n);o!==-1&&this.eventListeners[e].splice(o,1)}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};function Zc(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Qt=class extends Ye{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),mr(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){let n=this.getRootNode();if(n.activeElement!==this.element)return null;let o="getSelection"in n?n.getSelection():window.getSelection();if(!o)return null;let r=o.rangeCount>0?o.getRangeAt(0):null;if(!r)return null;let s=this.element.ownerDocument.createRange();return s.setStart(r==null?void 0:r.startContainer,r==null?void 0:r.startOffset),s.setEnd(r==null?void 0:r.endContainer,r==null?void 0:r.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 o=n.getBoundingClientRect();return!Zc(o)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=n.getBoundingClientRect(),n.deleteContents(),!Zc(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let n=this.getRange();if(n)return gr(this.element,n);let o=this.lastKnownSelection;if(o&&Jc(this.element,o.start,o.end))return o;let r=Un(this.element);return r.collapse(!1),gr(this.element,r)}getSelectedText(){let{start:n,end:o}=this.getSelection();return mr(this.element,bt(this.element,n,o))}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 o=this.element.isContentEditable,r=new MutationObserver(()=>{this.element.isContentEditable!==o&&(o=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>r.disconnect())}};var fx=["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 Yc(t,e){let n="mozInnerScreenX"in window,o=document.createElement("div");o.id="input-textarea-caret-position-mirror-div";let r=o.style,s=window.getComputedStyle(t),i=t.ownerDocument.body;r.whiteSpace="pre-wrap",r.wordWrap="break-word",r.position="absolute",r.visibility="hidden",fx.forEach(c=>{r[c]=s[c]}),n?t.scrollHeight>Number.parseInt(s.height)&&(r.overflowY="scroll"):r.overflow="hidden",o.textContent=t.value.substring(0,e);let a=document.createElement("span");a.textContent=t.value.substring(e)||".",o.appendChild(a),i.appendChild(o);let d=t.getBoundingClientRect(),l={top:d.top-t.scrollTop+a.offsetTop+Number.parseInt(s.borderTopWidth)+a.offsetHeight,left:d.left-t.scrollLeft+a.offsetLeft+Number.parseInt(s.borderLeftWidth)};return i.removeChild(o),l}var Zt=class extends Ye{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:o}=this.element;return{start:n,end:o}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return Yc(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 o=this.element.disabled,r=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>r.disconnect())}};function eu(t,e,n){let o=`deepdesk-iframe-${t}`,r=document.getElementById(o);if(r)return r;let s=document.createElement("iframe"),i=new URL(e);return Object.entries(n).forEach(([a,d])=>{i.searchParams.append(a,d)}),s.style.position="absolute",s.style.left="-999em",s.style.width="0px",s.style.height="0px",s.tabIndex=-1,s.id=o,s.title=`iframe-${t}`,s.src=i.toString(),window.document.body.appendChild(s),s}function hx(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch(e){return t}}var ei=class{constructor(e){this.name=e;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(e)}onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(JSON.stringify(e))}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},ti=class{constructor(e,n,o){this.name=e;this.targetOrigin=n;this.options=o;this.disposeHandlers=[];this.iframe=eu(e,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(e),this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(n=>n()),(e=this.iframe)==null||e.remove()}},ni=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.externalId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setExternalId(e){this.externalId!==e&&(this.cleanup(),E.info("Set externalId",e),this.externalId=e,this.channel=this.createChannel(e))}createChannel(e){let n=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new ti(e,this.deepdeskUrl,{debug:!0}):new ei(e),o=r=>{var i,a;if(r.origin!==this.deepdeskUrl)return;let s=hx(r.data);typeof s!="object"||s.type!=="event"||s.channel!==e||(E.info("Received broadcast event",this.externalId,r),(a=(i=this.eventMap)[s.name])==null||a.call(i,s.payload))};return n.onMessage(o),n}send(e,n,o){var i,a;E.info("Broadcast event",{externalId:this.externalId,name:e,payload:n});let r={type:"event",name:e,payload:n};o!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,n));let s=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage(x(y({},r),{channel:this.externalId}))}cleanup(e=!1){var n,o;(n=this.channel)==null||n.close(),this.channel=void 0,e&&((o=this.defaultChannel)==null||o.close(),this.defaultChannel=void 0)}},tu=ni;function yx(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function B(t){return Array.isArray(t)?t.map(B):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>x(y({},e),{[yx(n)]:B(t[n])}),{}):t}function vx(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function Y(t){return Array.isArray(t)?t.map(Y):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>x(y({},e),{[vx(n)]:Y(t[n])}),{}):t}var Yt=class extends Error{constructor(n,o){super(n);this.body=o;this.name="CustomError"}};var oi=t=>new Promise(e=>{setTimeout(e,t)});var Ct=class extends Yt{constructor(){super(...arguments);this.name="ClientError"}},si=class extends Yt{constructor(){super(...arguments);this.name="ServerError"}},ri=new Map;function xx(t){return v(this,null,function*(){if(t.status===204)return t.text().catch(()=>{}),null;let e=t.headers.get("content-type");if(e!=null&&e.includes("application/json"))return t.json();let n=yield t.text();return n===""?null:(E.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var en=class{constructor(e="",n={}){this.baseUrl=e;this.options=n;this.latestRequestByUrl={};this.refreshingToken=null;this.lastFailedRefreshAt=null;this.failedRefreshCooldown=1e4;var o;this.fetch=(o=n.fetch)!=null?o:window.fetch.bind(window)}patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,n={}){return new Promise((o,r)=>{let s={isAborted:!1,reject:r},i=`${this.baseUrl}${e}`,a=this.fetch,d=n.method===void 0||n.method.toLowerCase()==="get",N=n,{useCache:l=!1,abortLatest:c=!1,attempts:p=1,retryDelay:u=500,refreshTokenOn401:f=!0,retryOnError:h=_=>_ instanceof TypeError,retryOnResponse:m=_=>_.status>=500,version:g=null}=N,b=M(N,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(l){if(!d)throw new Error(`Can't use 'useCache' for ${n.method}`);if(ri.has(i)){o(ri.get(i));return}}let T=x(y({credentials:"include"},b),{headers:y({Accept:"application/json","Content-Type":"application/json"},b.headers)});!d&&this.csrfToken&&(T.headers=x(y({},T.headers),{"X-CSRFToken":this.csrfToken})),typeof g=="string"&&(T.headers=x(y({},T.headers),{"X-Deepdesk-API-Version":g}));let C=p,w=!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 L=()=>v(this,null,function*(){return C--,a(i,T).then(_=>v(this,null,function*(){return m(_)&&!s.isAborted&&C>0?(yield oi(u),L()):_.status===401&&f===!0&&w===!1?(w=!0,yield this.refreshToken(),L()):_})).catch(_=>v(this,null,function*(){if(h(_)&&!s.isAborted&&C>0)return yield oi(u),L();throw _}))});L().then(_=>v(this,null,function*(){let W=yield xx(_);if(delete this.latestRequestByUrl[i],_.status>=500){r(new si("Server Error",W));return}if(_.status===401){r(new Ct("Unauthorized",W));return}if(_.status===403){r(new Ct("Forbidden",W));return}if(_.status===404){r(new Ct("Not Found",W));return}if(_.status>=400){r(new Ct("Bad Request",W));return}l&&ri.set(i,W),o(W)})).catch(_=>{r(_)})})}validateToken(){return v(this,null,function*(){let e,n,o;try{({has_valid_access_token:e,is_logged_in:n,has_valid_refresh_token:o}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1}))}catch(r){return!1}if(!e){if(!o)return!1;try{yield this.refreshToken();let{is_logged_in:r}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1});return r}catch(r){return!1}}return n})}refreshToken(){let e=Date.now();return this.lastFailedRefreshAt&&e-this.lastFailedRefreshAt<this.failedRefreshCooldown?Promise.reject(new Ct("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(e,n){return this.request(e,n)}post(e,n,o){return this.request(e,y({method:"POST",body:JSON.stringify(n)},o))}patch(e,n,o){return this.request(e,y({method:"PATCH",body:JSON.stringify(n)},o))}put(e,n,o){return this.request(e,y({method:"PUT",body:JSON.stringify(n)},o))}delete(e,n){return this.request(e,y({method:"DELETE"},n))}};var nu;(e=>{let t;(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"))(t=e.EvaluationStatus||(e.EvaluationStatus={}))})(nu||(nu={}));function ii(t){return x(y({},B(t)),{metadata:t.metadata})}var Tt=class Tt{constructor(e,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new en(e,{fetch:n.fetch}),this.client.patchFetch(o=>(r,s)=>v(this,null,function*(){let i=yield o(r,s);return this.handleDeepdeskVersionHeaders(i),i}))}preflight(){return v(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=yield this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(Tt.exchangeTokenPromise||(Tt.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),Tt.exchangeTokenPromise):Promise.resolve()})}createConversation(e){return v(this,null,function*(){var o;yield this.preflight(),E.info(`Creating conversation for session ${e.externalId} and agent ${e.agentId}`);let n=yield this.client.post("/api/v2/conversations",x(y({chat_start_time:new Date().toISOString()},Y(e)),{metadata:(o=e.metadata)!=null?o:{}}));return ii(n)})}getMe(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/session/me/");return B(e)})}postIdentity(e){return v(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",Y(e))})}patchMe(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",Y(e));return B(n)})}getProfile(e){return v(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${e}/`,{useCache:!0});return B(n)})}getKnowledgeAssistant(e){return v(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{useCache:!0});return B(n)})}getContentTypes(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return B(e)})}getAccount(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/account/",{useCache:!0});return B(e)})}getPlatformConfig(e){return v(this,null,function*(){let n=e!==void 0?`/platform/config/${e}/`:"/platform/config/",{config:o}=yield this.client.get(n,{useCache:!0});return B(o)})}checkUserExists(e){return v(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${e}`,{version:"v1"});return n})}getConversationByExternalId(o){return v(this,arguments,function*(e,n={}){yield this.preflight(),E.info(`Getting conversation for session ${e}`);let{attempts:r=1,retryDelay:s=1e3}=n,i=yield this.client.get(`/api/v2/conversations/by_external_id/${e}`,{attempts:r,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return E.info(`Successfully retrieved conversation ${i.id} for session ${e}`),ii(i)})}isConversationSupported(o){return v(this,arguments,function*(e,n={}){E.info(`Check if conversation for session ${e} is supported`);let{attempts:r=1,retryDelay:s=1e3}=n;return(yield this.client.get(`/api/v2/conversations/by_external_id/${e}/has_active_profile`,{attempts:r,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500})).has_active_profile})}updateConversation(e,n){return v(this,null,function*(){var s;yield this.preflight();let o=Y(n);n.metadata&&(o.metadata=(s=n.metadata)!=null?s:{});let r=yield this.client.put(`/api/v2/conversations/${e}`,o);return ii(r)})}postMessages(e,n){return v(this,null,function*(){yield this.preflight(),yield this.client.post(`/api/v2/conversations/${e}/messages`,n.map(o=>x(y({},Y(o)),{metadata:o.metadata})))})}sendEvent(e,n){return v(this,null,function*(){yield this.preflight();let a=n,{data:o}=a,r=M(a,["data"]),s=Object.entries(this.latestReceivedDeepdeskVersions).reduce((d,[l,c])=>x(y({},d),{[l]:c}),{}),i=["platform","agentId","agentName","agentEmail","conversationId"].reduce((d,l)=>(r[l]&&(d[l]=r[l]),d),{});return this.client.post("/api/v2/events",Y(x(y(y({},s),i),{data:o,name:e})),{version:"v2"})})}getEntities(e){return v(this,null,function*(){return yield this.preflight(),yield this.client.post("/api/v2/entities",{messages:e.filter(o=>o.text)})})}getTemporaryExchangeToken(){return v(this,null,function*(){return(yield this.client.get("/apis/admin/session/exchange-token/")).jwt})}exchangeTokenForAccessCookie(e){return v(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:e}).catch(n=>{throw E.warn(`Invalid token '${e}'`),n})})}authenticateWithKey(e,n){return v(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Y(n),{refreshTokenOn401:!1,headers:{apikey:e}})})}getTextSuggestions(r){return v(this,arguments,function*(e,n={},o){if(yield this.preflight(),o==="sticky-messages")throw new Error("Use getPinnedMessages instead");return(yield this.client.post(`/api/v2/conversations/${e}/recommend/${o}`,Y(n),{abortLatest:!0})).map(i=>x(y({},B(i)),{text:i.text||i.url||i.message,source:o,type:o})).filter((i,a,d)=>a===d.findIndex(l=>l.text===i.text))})}isLoggedIn(){return v(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(e,n){return v(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${e}/autocomplete`,Y(n),{abortLatest:!0})).map(r=>({score:1,source:r.source,sourceText:r.source_text,text:r.label,trainingJobs:r.training_jobs,searchKeywords:r.search_keywords,type:r.source})).filter((r,s,i)=>s===i.findIndex(a=>a.text===r.text))})}getPinnedMessages(e){return v(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${e}/pinned-messages`,{abortLatest:!0});return B(n).map(o=>x(y({},o),{text:o.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(e){return v(this,null,function*(){let n=yield this.client.post("/api/v2/style-suggestions",Y(e),{abortLatest:!0,version:"v2"});return B(n)})}search(e){return v(this,null,function*(){let n=yield this.client.post(`/api/v2/profiles/${e.profile}/search`,Y(e));return B(n)})}requestLoginByEmail(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:e});return B(n)})}requestPasswordlessToken(){return v(this,null,function*(){let e=yield this.client.get("/apis/admin/session/passwordless/request/");return B(e.token)})}getCsrfToken(){return v(this,null,function*(){let{token:e}=yield this.client.get("/apis/admin/session/csrf/");return e})}verifyLoginToken(e){return v(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:e});return B(n)})}evaluateAssistant(e,n){return v(this,null,function*(){var i;yield this.preflight();let o=new URLSearchParams;n!=null&&n.externalConversationId&&o.append("external_conversation_id",n.externalConversationId);let r=n!=null&&n.threadId?`/api/v2/assistants/${e}/threads/${n==null?void 0:n.threadId}/evaluate?${o.toString()}`:`/api/v2/assistants/${e}/evaluate?${o.toString()}`,s=yield this.client.post(r,{input:(i=n==null?void 0:n.input)!=null?i:{},conversation:n==null?void 0:n.transcript});return B(s)})}createAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n}=e,o=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return B(o)})}postMessageToAssistantThread(e){return v(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:o,message:r}=e,s=yield this.client.post(`/apis/admin/assistants/${n}/threads/${o}/messages/`,{content:r,role:"user"});return B(s)})}translateMessages(e){return v(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/v2/translate",Y(e));return B(n)})}handleDeepdeskVersionHeaders(e){e.headers.forEach((n,o)=>{let r=o.toLowerCase(),s=r.match(Oi);if(!n||!s)return;let i=s[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&E.warn(`Overwritten Version header ${r}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};Tt.exchangeTokenPromise=null;var et=Tt;var fr=class{constructor(e){this.options=e;this.socket=null;this.maxReconnectAttempts=5;this.reconnectInterval=25e3;this.cleanupCallbacks=[];var n,o;this.socket,this.eventListeners=new Map,this.url=e.url,this.maxReconnectAttempts=(n=e.maxReconnectAttempts)!=null?n:this.maxReconnectAttempts,this.reconnectInterval=(o=e.reconnectInterval)!=null?o:this.reconnectInterval,this.shouldReconnect=e.shouldReconnect}connect(){let e=()=>this.cleanup();window.addEventListener("beforeunload",e),this.cleanupCallbacks.push(()=>window.removeEventListener("beforeunload",e)),this.reconnect()}setupListeners(){this.socket&&(this.socket.onmessage=e=>{var n;try{let o=B(JSON.parse(e.data));o.event&&this.eventListeners.has(o.event)&&((n=this.eventListeners.get(o.event))==null||n.forEach(r=>r(o.data)))}catch(o){console.error("Error parsing WebSocket message:",o)}},this.socket.onclose=e=>{console.log("WebSocket connection closed:",e),setTimeout(()=>{this.reconnect()},this.reconnectInterval)},this.socket.onerror=e=>{console.error("WebSocket error:",e)})}reconnect(){var e,n;if(this.maxReconnectAttempts<=0){console.error("Max reconnect attempts reached, closing WebSocket connection."),(e=this.socket)==null||e.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(e,n){if(!this.socket){console.error("WebSocket connection is not open.");return}this.socket.send(JSON.stringify({event:e,data:n}))}on(e,n){this.eventListeners.has(e)||this.eventListeners.set(e,[]);let o=this.eventListeners.get(e);o&&!o.includes(n)&&o.push(n)}close(){var e;(e=this.socket)==null||e.close()}cleanup(){this.close(),this.cleanupCallbacks.forEach(e=>e()),this.cleanupCallbacks=[]}};import{combineReducers as kx,configureStore as Rx}from"@reduxjs/toolkit";import{createSlice as Sx}from"@reduxjs/toolkit";var ou={startTime:null,stopTime:null},ru=t=>t.handlingTime,su=Sx({name:"handlingTime",initialState:ou,reducers:{handlingTimeStart(t){if(t.startTime&&!t.stopTime)throw new Error("Timing already started");t.startTime=new Date,t.stopTime=null},handlingTimeStop(t){if(!t.startTime)throw new Error("Timing not started");t.stopTime=new Date},handlingTimeReset(t){t.startTime=null,t.stopTime=null}},extraReducers:t=>{t.addCase(V,()=>ou)}}),{handlingTimeStart:iu,handlingTimeStop:hr,handlingTimeReset:au}=su.actions,lu=su.reducer;var du=(t={})=>{let e=y({onAuthError:Pt(!1)},t);return n=>o=>r=>("error"in r&&r.error.message==="Unauthorized"&&n.dispatch(e.onAuthError),o(r))};import{createAsyncThunk as bx,createSlice as Cx}from"@reduxjs/toolkit";var yr={list:{keywordMatches:[]},fetchState:"idle"};var wt=bx("styleSuggestions/getAll",(n,o)=>v(null,[n,o],function*({text:t},e){var d;let{deepdeskAPI:r}=e.extra,s=e.getState(),{showStyleSuggestions:i}=s.settings,a=(d=s.conversation.current)==null?void 0:d.profileCode;if(!i)return yr.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return r.getStyleSuggestions({profileCode:a,message:t})})),Tx=Cx({name:"styleSuggestions",initialState:yr,reducers:{},extraReducers:t=>{t.addCase(wt.pending,e=>{e.fetchState="loading"}).addCase(wt.rejected,e=>{e.fetchState="error"}).addCase(wt.fulfilled,(e,n)=>{e.fetchState="done",$e(e.list,n.payload)||(e.list=n.payload)}).addCase(it,e=>{e.list=yr.list}).addCase(V,()=>yr)}}),cu=Tx.reducer;var uu=(t={})=>{let e,n=!0,o=y({getStyleSuggestions:wt,debounce:500},t);return r=>s=>i=>{var f;let a=r.getState().input.text,d=s(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return d;let{showStyleSuggestions:c}=l.settings;if(!((f=l.conversation.current)==null?void 0:f.id)||!c)return d;let{text:u}=l.input;return u===a&&!n||(clearTimeout(e),u==="")||(e=setTimeout(()=>{n=!1,r.dispatch(o.getStyleSuggestions({text:u}))},t.debounce)),d}};function wx(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var pu=(t={})=>{let e=y({getTextSuggestions:he,getAutocompleteSuggestions:Nn,debounce:200,check:ke},t),n;return o=>r=>s=>{var m;let{input:i}=o.getState(),a=r(s),d=o.getState();if(d.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:l,showTabCompletion:c}=d.settings,p=(m=d.conversation.current)==null?void 0:m.id,u=s.type===Vo.toString();if(!p||!l&&!c)return a;let{input:f}=d;return wx(f,i)&&!u||(clearTimeout(n),!e.check(d))||(n=setTimeout(()=>{let g=At(d);g===""?o.dispatch(e.getTextSuggestions("default")):o.dispatch(e.getAutocompleteSuggestions(g))},u?0:e.debounce)),a}};var gu=wt.fulfilled.toString();function Ex(t,e){let n=new Set([...e.keywordMatches.map(r=>r.keyword)]),o=[];return n.forEach(r=>{let s=t.keywordMatches.filter(d=>d.keyword===r),i=e.keywordMatches.filter(d=>d.keyword===r),a=i.length-s.length;a<=0||o.push(...i.slice(0,a))}),o}var mu=t=>e=>n=>o=>{var l;if(o.type!==gu){n(o);return}let r=e.getState().styleSuggestions.list;n(o);let s=e.getState(),i=s.styleSuggestions.list,a=(l=s.conversation)==null?void 0:l.current;if(r===i)return;let d=Ex(r,i);o.type===gu&&d.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:d}})};var Px=kx({assistants:Wa,auth:zi,conversation:qi,contentTypes:Tl,passwordlessToken:xc,entities:Jl,handlingTime:lu,info:ya,input:aa,settings:ja,profile:Pl,search:Ta,styleSuggestions:cu,ui:kd,textSuggestions:cd});function fu(t){return Rx({reducer:Px,middleware:e=>{var o;let n=e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI}},serializableCheck:!1}).concat(du()).concat(pu({debounce:200})).concat(uu({debounce:500})).concat(mu(t.deepdeskAPI));return((o=t.middleware)!=null?o:[]).reduce((r,s)=>r.concat(s),n)},preloadedState:t.preloadedState})}var Ix=t=>{var e,n;return(n=(e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())!=null?n:"unknown"},Lx=t=>e=>n=>o=>{var d,l;let r=e.getState(),s=dt("inlineSuggestions")(r),i=dt("autoSelectSuggestion")(r)||s;switch(o.type){case Pt.toString():{!o.payload&&t.emit("logout",void 0);break}case fe.fulfilled.toString():o.payload.length>0&&t.sendEvent("entities found",{conversationId:(d=r.conversation.current)==null?void 0:d.id,data:{entities:o.payload}});break;case it.toString():t.logSendMessage(o.payload);break;case So.toString():t.emit("call-to-action",{cue:o.payload});break;case be.fulfilled.toString():o.isBroadcasted||t.broadcast(Br,o,!1);break;default:break}let a=n(o);switch(o.type){case it.toString():t.handleAfterSendMessage(o.payload);break;case On.toString():t.onUpdateShowTabHint(o.payload);break;case hr.toString():t.logHandlingTime();break;case Nt.toString():t.broadcast(co,o);break;case st.toString():t.broadcast(co,o);break;case bo.toString():e.dispatch(st({source:"assistant",assistantCode:o.payload.code}));break;case"analytics/logEvent/fulfilled":{let c=r.assistants.cues.find(p=>p.code===o.meta.arg.data.assistantCode);t.emit("event",x(y({},o.meta.arg),{cue:c}));break}case re.toString():{let{start:c,end:p}=r.input.selection;t.emit("select-suggestion",x(y({type:Ix(o.payload.suggestion)},o.payload),{replace:o.payload.replace==="selection"?{start:c,end:p}:{start:0,end:p}})),s&&e.dispatch(Ge([]));break}case to.toString():t.emit("select-image",o.payload),t.sendEvent("Image attached",{conversationId:(l=r.conversation.current)==null?void 0:l.id,data:{path:o.payload.suggestion.image,title:o.payload.suggestion.title}});break;case Ge.toString():{i&&o.payload.length>0&&e.dispatch(no(0));break}default:break}return a},hu=Lx;import{createSelector as Ax}from"@reduxjs/toolkit";function ai(t){return t.toISOString().replace("T"," ").replace("Z","")}var Mx=(t,e)=>e.version,yu=Ax([Ot,Se,ru,Mx],(t,e,n,o)=>{if(!e)return E.warn("No conversationId for handling time metrics"),null;let{startTime:r,stopTime:s}=n;return!r||!s?(E.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:e,clientVersion:o,agentId:t==null?void 0:t.agentId,agentName:t==null?void 0:t.agentName,agentEmail:t==null?void 0:t.agentEmail,timeStart:ai(r),timeStop:ai(s)}});function vu(t,e){let{text:n,metrics:{numPaste:o,pastes:r,textSuggestions:s}}=t.input,i=n.length;return{source:"agent",clientVersion:e.version,pastes:r,lenTextTotal:i,numPastes:o,suggestions:s}}var Kn=class extends Error{};function Nx(){let t,e;return{promise:new Promise((o,r)=>{t=o,e=r}),resolve:t,reject:e}}var vr=class{constructor(){this.queues={}}push(e,n){let o=()=>{let s=this.queues[e][1];s?(this.queues[e]=[s.promise,null],s.resolve()):delete this.queues[e]};if(!this.queues[e]){let s=n().finally(o);return this.queues[e]=[s,null],s}this.queues[e][1]&&this.queues[e][1].reject(new Kn("Queued async function is outdated"));let r=Nx();return this.queues[e][1]=r,r.promise.then(()=>n().finally(o))}};function li(t,e){var s;let n=t.closest(e);if(n)return n;let o=t.getRootNode().host;if(o instanceof HTMLElement)return li(o,e);let r=(s=t.ownerDocument.defaultView)==null?void 0:s.frameElement;return r?li(r,e):null}function di(t,e){return li(t,e)}var Ox={accepted:"onConversationAcceptedAssistants","new-message":"onConversationNewMessageAssistants",ended:"onConversationEndedAssistants"},xu=(t,e)=>{var r,s,i;if(!((i=(s=(r=t.uiConfig)==null?void 0:r.widget)==null?void 0:s.types.find(a=>a.type==="cues"))==null?void 0:i.isActive))return E.warn("Triggered a conversation assistant, but cues are not configured in widget."),[];let o=t[Ox[e]];return o&&o.length>0?o.map(a=>a.code):(E.warn(`No assistant set in profile for conversation event "${e}"`),[])};function Su(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Dx(t){return typeof t=="object"&&t!==null&&"tagName"in t}function ci(t){return Dx(t)&&(xt(t)||er(t))}var Cu,Re=new Map,_x=["bottom","height","left","right","top","width"],bu=(t,e)=>!t&&!e?!1:t&&!e||!t&&e?!0:_x.some(n=>t[n]!==e[n]);function Tu(t){var n,o,r;if(t.ownerDocument===document)return[];let e=(r=(o=(n=t.ownerDocument)==null?void 0:n.defaultView)==null?void 0:o.frameElement)!=null?r:null;return e?[e,...Tu(e)]:[]}function wu(t,e){return!t||!e?null:x(y({},t),{top:t.top+e.top,left:t.left+e.left})}var xr=!1,Eu=()=>{xr=!0;let t=[];if(Re.forEach((e,n)=>{if(!n.isConnected){e.rect=null,t.push(e),Re.delete(n);return}let o=n.getBoundingClientRect();bu(o,e.rect)&&(e.rect=o,t.push(e))}),t.forEach(e=>{let n=e.parentRects?e.parentRects.reduce(wu,e.rect):e.rect;bu(n,e.totalRect)&&e.callbacks.forEach(o=>o(n)),e.totalRect=n}),Re.size===0){xr=!1;return}Cu=window.requestAnimationFrame(Eu)};function ui(t,e){let n=Tu(t),o=[],r=n.map((s,i)=>ui(s,a=>{o[i]=a;let d=Re.get(t);if(!d)return;let l=o.reduce(wu,d.rect);d.callbacks.forEach(c=>c(l))}));return{observe(s=!0){if(r.forEach(i=>i.observe(!1)),Re.has(t)){let i=Re.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Re.set(t,{rect:void 0,callbacks:[e],parentRects:o});s&&!xr&&Eu()},unobserve(){r.forEach(i=>i.unobserve());let s=Re.get(t);if(s){let i=s.callbacks.indexOf(e);i>=0&&s.callbacks.splice(i,1),s.callbacks.length||Re.delete(t),Re.size||(cancelAnimationFrame(Cu),xr=!1)}}}}var ku,Pe=new Map,Ru=()=>{Pe.forEach((t,e)=>{if(!e.isConnected){Pe.delete(e);return}let{clientHeight:n,scrollHeight:o}=e,r=o>n;t.visible!==r&&(t.visible=r,t.callbacks.forEach(s=>s(t.visible)))}),Pe.size!==0&&(ku=window.requestAnimationFrame(Ru))};function Pu(t,e){return{observe(){let n=Pe.size===0;Pe.has(t)?Pe.get(t).callbacks.push(e):Pe.set(t,{visible:void 0,callbacks:[e]}),n&&Ru()},unobserve(){let n=Pe.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||Pe.delete(t),Pe.size||cancelAnimationFrame(ku)}}}}var pi=["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 gi(t,e,n){return n.forEach(o=>{e.style[o]=t[o]})}function tn(t){return Number.parseFloat(t)}function Sr(t){return Math.round(t*1e6)}function Iu(t){return t/1e6}function mi(t,e,n){if(t.boxSizing==="content-box")return;let{clientWidth:o}=e,r=tn(t.width),s=tn(t.borderLeftWidth),i=tn(t.borderRightWidth),a=tn(t.paddingRight),d=Iu(Sr(r)-Sr(s)-Sr(i)),l=Iu(Sr(o));if(d-l>2){let c=d-l;n.style.paddingRight=`${a+c}px`}}function br(t,e={}){var c,p;let n=e.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(c=e.position)!=null?c:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",ut(n);let o=window.getComputedStyle(t),r=!0,s=()=>{n.scrollTop=t.scrollTop};gi(o,n,pi),mi(o,t,n),e.mirrorOverflow&&(n.style.overflow="hidden",t.addEventListener("scroll",s));let i=Pu(t,()=>{gi(o,n,pi),mi(o,t,n),s(),setTimeout(s,0)}),a,d=!0,l=ui(t,u=>{if(u===null){e.onRemove&&e.onRemove(),n.remove();return}if(!d&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),d=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),d=!1},200),u.height===0&&u.width===0){if(r===!0)return;e.onHide&&e.onHide(),n.style.display="none",r=!0;return}if(gi(o,n,pi),mi(o,t,n),s(),e.placement==="below"&&n.classList.add("below"),n.style.top=`${u.top}px`,n.style.left=`${u.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let f=e.closestScrollElement.getBoundingClientRect(),h=window.getComputedStyle(e.closestScrollElement),m=tn(h.borderTopWidth),g=tn(h.borderBottomWidth),b=f.top+m-u.top,T=u.top+u.height+-(f.top+f.height-g);n.style.clipPath=`inset(${b}px 0px ${T}px 0px)`}r&&(n.style.display="block",e.onShow&&e.onShow(),r=!1)});return e.appendTo?e.appendTo.appendChild(n):(p=t.parentElement)==null||p.appendChild(n),l.observe(),i.observe(),[n,()=>{t.removeEventListener("scroll",s),l.unobserve(),i.unobserve(),n.remove()}]}function Fx(t){return t.offsetParent!==null}function Lu(t){if(!Fx(t))return!1;let e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function fi(t,e,n=100){let o=Lu(t);e({isVisible:o});let r=setInterval(()=>{let s=Lu(t);s!==o&&(o=s,e({isVisible:o}))},n);return()=>{clearTimeout(r)}}var Au=(t,e)=>({value(){try{let n=sessionStorage.getItem(`dd-${t}`);if(!n)return e;try{return JSON.parse(n)}catch(o){return e}}catch(n){return e}},update(n){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(n))}catch(o){E.warn("[Deepdesk] SessionStorage is blocked by browser")}}});import{jsx as F,jsxs as Hx}from"react/jsx-runtime";var Mu=Au("showTabHint",!0),nn=class nn{constructor({deepdeskUrl:e,version:n=nn.version||"unknown",locale:o="en-US",token:r,fetch:s,productName:i,createCustomChannel:a,websocketClient:d=fr}){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 vr;this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let l=e.replace(/\/api$/,"");this.deepdeskApi=new et(l,{token:r,fetch:s}),this.version=n,this.instanceId=nn.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[hu({broadcast:(h,m,g)=>{this.broadcastEvents.send(h,m,g)},emit:(h,m)=>this.emit(h,m),handleAfterSendMessage:h=>this.handleAfterSendMessage(h),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:h=>this.logSendMessage(h),onUpdateShowTabHint:h=>Mu.update(h),sendEvent:(h,m)=>this.deepdeskApi.sendEvent(h,m)})]};this.store=fu(c),this.broadcastEvents=new tu({debug:!0,deepdeskUrl:l,eventMap:wa(this.store),createCustomChannel:a}),this.disposeHandlers.push(()=>{this.broadcastEvents.cleanup()}),this.ws=new d({url:`${l}/api/v2/me/realtime`.replace("https","wss"),reconnectInterval:25e3,shouldReconnect:()=>v(this,null,function*(){var h;return(h=J(this.state))!=null?h:!1})}),this.whenLoggedIn(()=>this.ws.connect()),this.store.dispatch(On(Mu.value())),this.store.dispatch(Co({locale:o,adminUrl:l,productName:i}));let p=[],u=h=>{if(!h.conversationId)return;let m=()=>{this.conversationId()===h.conversationId&&this.store.dispatch(za(h))};this.hasConversation()?m():p.push(m)};this.ws.on("assistants::direct_response",u),this.ws.on("assistants::user_notification",u),this.ws.on("assistants::response_chunk",h=>{if(!h.conversationId)return;let m=()=>{this.conversationId()===h.conversationId&&this.store.dispatch(Ka(h))};this.hasConversation()?m():p.push(m)}),this.ws.on("assistants::suggest_as_reply",h=>{if(!h.conversationId)return;let m=()=>{this.conversationId()===h.conversationId&&this.store.dispatch(Nt([{text:h.payload.message,type:"text",source:"assistant",assistantCode:h.code,sourceLabel:h.name}]))};this.hasConversation()?m():p.push(m)});let f=this.whenConversationLoaded(()=>{var h;this.broadcastEvents.setExternalId((h=this.state.conversation.current)==null?void 0:h.externalId),p.forEach(m=>m()),p.length=0});this.disposeHandlers.push(()=>{this.ws.cleanup(),p.length=0,f()})}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var e;return(e=rt(this.state)[this.state.input.selectedSuggestionIndex])!=null?e: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?(E.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(E.warn("Profile has not been loaded (yet)"),!0):(E.warn("No conversation loaded (yet)"),!0)}whenLoggedIn(e){if(J(this.state))e();else{let n=this.subscribe(J,o=>{o&&e()});this.disposeHandlers.push(()=>{n()})}}login(){return this.store.dispatch(Pt(null)),this.store.dispatch(Ae()),new Promise(e=>{this.whenLoggedIn(()=>e())})}isLoggedIn(){return v(this,null,function*(){return(yield this.store.dispatch(Ae())).payload})}isConversationSupported(e,n){return v(this,null,function*(){return(yield this.store.dispatch(Mr({externalId:e,options:n}))).payload})}createConversation(e){return v(this,null,function*(){var o;return this.hasConversation()&&this.externalId()!==e.externalId&&this.resetConversation(),(yield this.store.dispatch(Zn(x(y({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}getConversationByExternalId(e,n){return v(this,null,function*(){return this.hasConversation()&&this.externalId()!==e&&this.resetConversation(),(yield this.store.dispatch(Yn({externalId:e,options:n}))).payload})}upsertConversation(e){return v(this,null,function*(){var o;return this.hasConversation()&&this.externalId()!==e.externalId&&this.resetConversation(),(yield this.store.dispatch(Nr(x(y({},e),{metadata:(o=e.metadata)!=null?o:{}})))).payload})}postMessages(e){return v(this,null,function*(){yield this.store.dispatch(Or(e))})}updateConversation(e){return v(this,null,function*(){return(yield this.store.dispatch(eo(e))).payload})}resetConversation(){this.store.dispatch(V()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(e){this.store.dispatch(Co(e))}setVisitorInfo(e){this.store.dispatch(ga(e))}setCustomData(e){this.store.dispatch(ma(e))}setAgentInfo(e,n){return v(this,null,function*(){var r;yield this.store.dispatch(cn(y(y({},e),n))),(r=this.state.info.agentInfo)!=null&&r.agentNickname||this.broadcastEvents.send(lo,{showNicknameDialog:!0})})}setAgentSettings(e){return v(this,null,function*(){yield this.store.dispatch(_r(e))})}getAgentSettings(){return v(this,null,function*(){return(yield this.store.dispatch(Fr())).payload})}refresh(){return v(this,null,function*(){if(this.shouldAbort())return Promise.resolve();let e=[];return e.push(this.refreshTextSuggestions()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})})}syncInputMediator(){this.inputMediator&&this.store.dispatch(oo({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}))}notifyExternalSuggestion(e){this.store.dispatch(re(e))}evaluateAssistant(e,n){return v(this,null,function*(){var d;let{input:o={},transcript:r,showCuesInWidget:s=!0,includeMetadata:i}=n||{},a=yield this.store.dispatch(be({assistantCode:e,transcript:r,includeMetadata:i,input:o,skipState:!s}));if(a.error)throw new Error(`Assistant evaluation failed: ${(d=a.payload)!=null?d:a.error.message}`);return a.payload.output})}evaluateConversationAssistant(e,n){return v(this,null,function*(){yield this.loadProfileConfig();let o=this.state.profile.data;if(!o){E.warn("Can't evaluate assistant when profile is not loaded yet.");return}let r=xu(o,e);yield Promise.all(r.map(s=>this.queues.push(s,()=>v(this,null,function*(){yield this.evaluateAssistant(s,y({includeMetadata:!0},n))})).catch(i=>{if(i instanceof Kn){E.warn(`Queued assistant "${s}" was outdated and dropped`);return}throw i})))})}handleKeyDown(e){let{overlayCollapsed:n,openOverlayWhenTyping:o}=this.state.ui,{textSuggestions:r,selectedSuggestionIndex:s,selection:i}=this.state.input,{inlineSuggestions:a,autoSelectSuggestion:d,showTextSuggestions:l,suggestionsPlacement:c}=this.settings,p=a||d,u=c==="inline"||c==="below"?"below":"above",f=r.length>0;if(this.store.dispatch(ea(Dr(e))),!ke(this.state)||e.key!=="Tab"&&!l)return;let h=()=>{n||!f||i&&(e.shiftKey||(this.store.dispatch(oa()),e.preventDefault()))},m=()=>{n||!f||p&&s<=0||i&&(e.shiftKey||(this.store.dispatch(ra()),e.preventDefault()))};switch(e.key){case"ArrowUp":u==="below"?m():h();break;case"ArrowDown":{u==="below"?h():m();break}case"Escape":{n||(this.store.dispatch(no(-1)),this.store.dispatch(Qe({collapse:!0})),this.store.dispatch(wd(!0)),e.preventDefault());break}case"Tab":{e.preventDefault();let g=Mt(this.state);if(!g)return;this.store.dispatch(On(!1)),this.store.dispatch(re({text:g.text,suggestion:g,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(p||this.state.input.selectedSuggestionIndex===-1)return;let g=Mt(this.state);if(!g)return;this.store.dispatch(re({text:g.text,suggestion:g,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(p||e.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let g=Mt(this.state);if(!g)return;this.store.dispatch(re({text:g.text,suggestion:g,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),e.preventDefault();break}default:}n&&o&&this.store.dispatch(Qe({collapse:!1}))}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ge([]))}handlingTimeStart(){this.state.handlingTime.startTime||(E.info("Start handling time"),this.store.dispatch(iu()))}handlingTimeStop(){this.state.handlingTime.startTime&&(E.info("Stop handling time"),this.store.dispatch(hr()))}logSendMessage(e){let n=vu(this.state,{version:this.version});n&&(e&&(Object.assign(n,{text:e}),Object.assign(n,{lenTextTotal:e.length})),this.deepdeskApi.sendEvent("Send Message",{conversationId:this.conversationId(),data:n}),this.emit("send-message-event",n))}logHandlingTime(){let e=yu(this.state,{version:this.version});e&&(this.deepdeskApi.sendEvent("Handling Time",{conversationId:this.conversationId(),data:e}),this.store.dispatch(au()))}notifySubmit(e={}){var n;this.shouldAbort()||(this.store.dispatch(it((n=e.text)!=null?n:this.state.input.text)),this.store.dispatch(ia()))}emit(e,n){let o=this.eventListeners[e];o&&o.forEach(r=>{try{r(n)}catch(s){E.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),E.error(s)}})}on(e,n){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n),()=>{this.off(e,n)}}off(e,n){if(!e&&!n){this.eventListeners={};return}let o;this.eventListeners[e]&&(o=this.eventListeners[e].indexOf(n),o>-1&&this.eventListeners[e].splice(o,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}setPlatformVariables(e){this.store.dispatch(fa(e))}whenConversationLoaded(e){let n=s=>{var i;return(i=s.conversation.current)==null?void 0:i.id},o=()=>this.loadProfileConfig().then(()=>e());return n(this.state)&&o(),this.subscribe(n,s=>{s&&o()})}overlayContainerFactory(e,n,o,r){let[s,i]=br(n,o);return s.setAttribute("translate","no"),s.dataset.testid=e,r&&s.classList.add(r),[s,i]}createInlineContainer(e,n){var a;let o=document.createElement("div");o.style.position="absolute",o.style.top="0px",o.style.left="0px",o.style.height="0px",o.style.width="0px";let r=document.createElement("div");r.style.display="none",r.style.position="absolute",r.style.height="0px",r.style.width="0px",r.style.backgroundColor="red",o.appendChild(r);let s=(a=e.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[d,l]=br(s,{appendTo:document.body,onMoveStart:()=>{r.style.display="none"}});d.dataset.testid=n,d.style.zIndex="2",d.appendChild(o),this.unmountHandlers.push(()=>{l()})}else document.body.appendChild(o);return r}createContainer(e,n=document.body){let o=window.getComputedStyle(n),r=document.createElement("div");return ut(r),r.dataset.testid=e,r.style.color=o.color,r.style.fontSize=o.fontSize,r.style.fontFamily=o.fontFamily,r.style.fontVariant=o.fontVariant,r.setAttribute("translate","no"),n.appendChild(r),r}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,n),E.info(`Stored analytics for ${this.conversationId()}`)}catch(e){}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(e);if(!n)return;let o=JSON.parse(n);o.text.trim()===this.state.input.text.trim()?(E.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(sa(o.metrics))):E.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch(e){}}mount(e,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!ci(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let u=n,{customStyles:o,closestScrollSelector:r,floatingMenuParent:s,appendOverlayTo:i,inputMediator:a}=u,d=M(u,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),l={customStyles:o,closestScrollSelector:r,floatingMenuParent:s,appendOverlayTo:i};this.configure(d),this.settings.automaticHandlingTime&&this.setupHandlingTime(e),ut(e),this.inputMediator=a||(xt(e)?new Zt(e):new Qt(e)),this.inputMediator.on("change",({plainText:f,rawHTML:h})=>{this.store.dispatch(oo({text:f,html:h}))}),this.inputMediator.on("keyup",f=>{this.store.dispatch(ta(Dr(f)))}),this.inputMediator.on("keydown",f=>{this.handleKeyDown(f)}),this.inputMediator.on("paste",({pastedText:f,selectionText:h})=>{this.store.dispatch(na({text:f,selectionText:h}))}),this.inputMediator.on("cut",({selectionText:f})=>{this.store.dispatch(Yi(f))});let c;this.inputMediator.on("selection",f=>{clearTimeout(c),f===null?c=setTimeout(()=>{f!==null&&this.store.dispatch(ro(f))},500):this.store.dispatch(ro(f))}),this.unmountHandlers.push(()=>{clearTimeout(c)}),this.inputMediator.on("disabled",()=>{var f;(f=this.inputMediator)==null||f.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(Go(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(Go(!0))}),this.renderSuggestions(e,l),this.subscribe(dt("inlineSuggestions"),()=>{this.renderSuggestions(e,l)}),this.subscribe(dt("suggestionsPlacement"),()=>{this.renderSuggestions(e,l)});let p=this.renderOverlays(n);this.unmountHandlers.push(()=>{p.unmount()}),this.store.dispatch(oo({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(ro(this.inputMediator.getSelection())),this.store.dispatch(Go(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(e){if(this.nicknameDialogUnsubscribe||this.nicknameDialogFailed)return;let n=this.createContainer("nickname-dialog",document.body);document.body.appendChild(n);let o=tt(n),r=null,s=a=>{r=a,i()},i=()=>{o==null||o.render(F(Be,{store:this.store,children:F(Ne,{broadcastEvents:this.broadcastEvents,children:F(Hd,{id:"deepdesk-nickname-dialog",error:r,onSave:a=>v(this,null,function*(){try{yield this.store.dispatch(ua({agentNickname:a})).unwrap(),console.log("setAgentNickname",a),this.broadcastEvents.send(lo,{showNicknameDialog:!1}),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe()}catch(d){E.error("Error setting agent nickname",d),s("error"),this.nicknameDialogFailed=!0}})})})}))};i(),this.nicknameDialogUnsubscribe=()=>{o.unmount(),n.remove(),this.nicknameDialogUnsubscribe=null}}subscribe(e,n){let o=e(this.store.getState());return this.store.subscribe(()=>{let r=e(this.store.getState());r!==o&&(o=r,n(o))})}unmount(){var e,n,o,r,s;(e=this.inlineSuggestions)==null||e.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(o=this.belowSuggestions)==null||o.unmount(),(r=this.floatingMenu)==null||r.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(e=>e()),this.disposeHandlers=[],this.off()}renderSuggestions(e,n){var o,r,s,i;(o=this.floatingMenu)==null||o.unmount(),(r=this.inlineSuggestions)==null||r.unmount(),(s=this.aboveSuggestions)==null||s.unmount(),(i=this.belowSuggestions)==null||i.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(e,n)),this.settings.inlineSuggestions||this.settings.suggestionsPlacement==="inline"?this.inlineSuggestions=this.renderInlineSuggestions(e,n):this.settings.suggestionsPlacement==="below"?this.belowSuggestions=this.renderAboveOrBelowSuggestions(e,n,"below"):this.aboveSuggestions=this.renderAboveOrBelowSuggestions(e,n,"above")}renderInlineSuggestions(e,n){let{customStyles:o}=n,r=this.createInlineContainer(e,"deepdesk-caret"),s=tt(r);s.render(F(Be,{store:this.store,customStyles:o,children:F(Ne,{broadcastEvents:this.broadcastEvents,children:F(_d,{})})}));let i=a=>{a?(r.style.display="block",r.style.top=`${a.top}px`,r.style.left=`${a.left}px`):r.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var a;(a=this.inputMediator)==null||a.off("caretposition",i),s.unmount(),r.remove()}}}renderAboveOrBelowSuggestions(e,n,o){let{customStyles:r,closestScrollSelector:s,appendOverlayTo:i}=n,a=s&&di(e,s)||void 0,[d,l]=this.overlayContainerFactory("deepdesk-tab-completion",a||e,{appendTo:i,closestScrollElement:a,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),[c,p]=this.overlayContainerFactory("deepdesk-suggestions-overlay",a||e,{appendTo:i,placement:o},r==null?void 0:r.suggestionsRootNode),u=tt(d);u.render(F(Be,{store:this.store,customStyles:r,children:F(Ne,{broadcastEvents:this.broadcastEvents,children:F(fc,{inputElement:e})})}));let f=tt(c);return f.render(F(Be,{store:this.store,customStyles:r,children:F(Ne,{broadcastEvents:this.broadcastEvents,children:F(qd,{onLogIn:()=>this.loginViaPopup().catch(h=>E.warn(h.message))})})})),{unmount(){u.unmount(),f.unmount(),l(),p()}}}renderFloatingMenu(e,n){let{customStyles:o,closestScrollSelector:r,appendOverlayTo:s,floatingMenuParent:i}=n,a=r&&di(e,r)||void 0,[d,l]=this.overlayContainerFactory("floating-menu",a||e,{appendTo:i!=null?i:s},o==null?void 0:o.floatingMenuParent),c=tt(d);return c.render(F(Be,{store:this.store,customStyles:o,children:F(Ne,{broadcastEvents:this.broadcastEvents,children:F(Cd,{onLogIn:()=>this.loginViaPopup().catch(p=>E.warn(p.message))})})})),{unmount(){c.unmount(),l()}}}renderOverlays(e){let{customStyles:n}=e,o=this.createContainer("deepdesk-overlays"),r=tt(o);return r.render(F(Be,{store:this.store,customStyles:n,children:F(Ne,{broadcastEvents:this.broadcastEvents,children:F(hd,{})})})),{unmount(){r.unmount(),o.remove()}}}renderWidget(e,n={}){if(this.widgetElement&&E.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:o,showImages:r,isEmbedded:s}=n;this.widgetElement=e,this.configure({showImages:r,isEmbedded:s}),this.widgetRoot=tt(e),this.widgetRoot.render(F(Be,{store:this.store,customStyles:o,children:F(Ne,{broadcastEvents:this.broadcastEvents,children:F(Xc,{assistantOptions:n.assistantOptions,knowledgeAssistOptions:n.knowledgeAssist,onLogIn:()=>this.loginViaPopup().catch(i=>E.warn(i.message))})})}))}unmountWidget(){var e,n;(n=(e=this.widgetRoot)==null?void 0:e.unmount)==null||n.call(e),this.widgetRoot=null,this.widgetElement=null}renderKnowledgeAssistantWidget(e,n,o={}){let{customStyles:r,initialQuestion:s}=o,i=tt(n);return i.render(F(Be,{store:this.store,customStyles:r,children:F(Ne,{broadcastEvents:this.broadcastEvents,children:F(Ys,{children:Hx(Ao,{assistantCode:e,initialQuestion:s,evaluateKnowledgeAssistFn:Tn,children:[F(sn,{children:F(No,{title:o.title,emptyState:o.emptyState})}),F(Zs,{children:F(Mo,{})})]})})})})),{unmount(){i.unmount()}}}setupHandlingTime(e){let n=fi(e,({isVisible:o})=>{o?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Su(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>v(this,null,function*(){yield this.store.dispatch(Rn());let e=ft(this.state);e&&this.store.dispatch(Co({showSearch:e.search,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:!!e.summarizerAssistantNew,showKnowledgeSearch:!!e.knowledgeAssistantNew||!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions}))})),this.loadProfileConfigPromise)}loginViaPopup(e){return v(this,null,function*(){return new Promise((n,o)=>{this.store.dispatch(Qn());let r=new MessageChannel,s=r.port1,i=this.settings.adminUrl,a=new URL(e!=null&&e.url?e==null?void 0:e.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let d=!1,l=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",p),clearInterval(u)};s.onmessage=f=>v(this,null,function*(){var h,m;if((h=f.data)!=null&&h.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((m=f.data)==null?void 0:m.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(pn),d=!0,r.port1.close(),n()}catch(g){console.error(g),o(g)}finally{d=!0,l()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&o(new Error("Popup blocked by browser"));let p=f=>v(this,null,function*(){var h;if(f.origin===a.origin)switch((h=f.data)==null?void 0:h.type){case"deepdesk-popup-request-origin":{try{let m=JSON.stringify({type:"deepdesk-popup-parent-origin"});c==null||c.postMessage(m,a.origin)}catch(m){E.error("Error posting message to popup",m),o(m)}break}case"deepdesk-popup-loaded":{try{let m=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(m,a.origin,[r.port2])}catch(m){E.error("Error posting message to popup",m),o(m)}break}case"deepdesk-popup-error":{if(l(),f.data.message==="Platform account url mismatch"){let m=`Please contact your administrator: The platform account url (${f.data.targetOrigin}) is misconfigured as it differs from the origin of the page that opened the popup (${f.data.openerOrigin}).`;E.warn(m),this.store.dispatch(Ar(m)),o(new Error(m))}if(f.data.message==="Timeout"){let m="Please contact your administrator: Popup timed out. Check if the account's platform url is configured correctly.";E.warn(m),this.store.dispatch(Ar(m)),o(new Error(m))}o(new Error(f.data.message));break}}});window.addEventListener("message",p);let u=setInterval(()=>{c&&!c.closed||(l(),d||o(new Error("Popup closed by user")))},200);this.disposeHandlers.push(l)})})}translateMessages(e){return this.deepdeskApi.translateMessages(e)}refreshTextSuggestions(){return v(this,null,function*(){this.isMounted&&(yield this.store.dispatch(Vo()))})}refreshWidgetSuggestions(){return v(this,null,function*(){if(!this.widgetRoot)return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let n=Pn(this.state);try{n.forEach(({type:o})=>{switch(o){case"entities":this.store.dispatch(fe());break;case"pinned-messages":case"sticky-messages":break;default:Xn.includes(o)||this.store.dispatch(he(o))}})}catch(o){this.handleError(o)}})}};nn.version="19.2.0",nn.count=0;var Cr=nn;function Bx(t){return v(this,null,function*(){var r,s,i;let n=yield((r=t.fetch)!=null?r:window.fetch)(t.url),o=yield n.blob();return new File([o],t.name,{type:(i=(s=t.mimeType)!=null?s:n.headers.get("Content-Type"))!=null?i:"image/jpeg"})})}function Ux(t,e){return v(this,null,function*(){let n=yield Bx(e),o=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(t,"files",{configurable:!0,get:()=>[n]}),t.dispatchEvent(o)}finally{Object.hasOwn(t,"files")&&delete t.files}})}function Kx(t,e,n){return v(this,null,function*(){yield new et(t).authenticateWithKey(e,n)})}function zx(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function Wx(o,r){return v(this,arguments,function*(t,e,n={}){var p,u;let{value:s}=t,{start:i,end:a}=(p=n.replace)!=null?p:{start:0,end:s.length},d=`${s.slice(0,i)}${e}${s.slice(a)}`,l=(u=n.selectionAfter)!=null?u:{start:i+e.length,end:i+e.length},c=()=>{if(n.setValue)return n.setValue(d);t.value=d};return Promise.resolve(c()).then(()=>{t.selectionStart=l.start,t.selectionEnd=l.end,t.blur(),t.focus()})})}function Vx(o,r){return v(this,arguments,function*(t,e,n={}){let s=n.replace?bt(t,n.replace.start,n.replace.end):Un(t),i,a=()=>{if(n.setRange)return n.setRange(s.cloneRange());s.deleteContents(),i=document.createElement("span"),s.insertNode(i),n.insertBRs!==!1?e.split(`
11
+ `).reverse().forEach((d,l)=>{l>0&&s.insertNode(document.createElement("br")),s.insertNode(document.createTextNode(d))}):s.insertNode(document.createTextNode(e))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){t.focus();let d=n.selectionAfter?bt(t,n.selectionAfter.start,n.selectionAfter.end):(s.collapse(!1),s),l=window.getSelection();l==null||l.removeAllRanges(),l==null||l.addRange(d)}if(!i)return;i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}function jx(t){let e=document.createElement("template");return e.innerHTML=t.replace(/(\[([^\]]+)])\(([^)]+)\)/g,'<a href="$3" target="_blank" rel="noopener noreferrer">$2</a>'),e.content}function $x(t){let e=document.createDocumentFragment();return t.split(`
12
+ `).forEach((n,o)=>{o>0&&e.appendChild(document.createElement("br"));let r={index:0},s=0;for(;r=n.slice(s).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=r[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(r[2])),e.appendChild(document.createTextNode(n.slice(s,s+r.index))),e.appendChild(i),s=s+r.index+r[0].length}e.appendChild(document.createTextNode(n.slice(s)))}),e}function Nu(t,e){let n=t.parentElement;if(!n){console.warn("No insert point found");return}let{display:o}=window.getComputedStyle(n);o.includes("block")||o==="table-cell"?n==null||n.insertBefore(e,t.nextSibling):Nu(n,e)}function Gx(r,s){return v(this,arguments,function*(t,e,{isBlock:n,isHTML:o}={}){let i;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let a=()=>{var u;let d=(u=t.ownerDocument.defaultView)!=null?u:window,l=d.getSelection();if((!l||l.rangeCount===0)&&(t.focus(),l=d.getSelection()),!l||l.rangeCount===0)return;let c=l.getRangeAt(0);if(!c)return;i=document.createElement("span"),c.insertNode(i);let p=o?jx(e):$x(e);n?Nu(c.startContainer,p):(c.insertNode(p),c.collapse(!1))};return Promise.resolve(a()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!i)try{i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}export{D as Card,Qt as ContentEditableInput,et as DeepdeskAPI,Cr as DeepdeskSDK,en as HTTPClient,Ye as InputMediator,Rt as InputType,kr as KeyboardHint,Yu as Label,Jn as Locale,Le as Section,sn as SectionList,je as Sources,I as Suggestion,te as SuggestionList,Zt as TextAreaInput,kt as ToggleButton,Ux as attachFile,Kx as authenticateWithKey,Un as createFullRange,br as createOverlayContainer,bt as createRangeFromOffsets,Ln as escapeHTML,zx as formatTextMarkup,gr as getRangeOffsets,mr as getRangeText,Gx as insertCKEditor,Do as isHTML,ci as isSupportedInputElement,Kr as logEvent,Vx as updateContentEditable,Wx as updateTextArea,ct as useClickOutsideRoot,S as useStyles,fi as waitForElementVisibilityChange};