@deepdesk/deepdesk-sdk 10.10.2 → 10.10.3-beta.1

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,11 +1,11 @@
1
- var Td=Object.defineProperty;var j=(t,e)=>{for(var o in e)Td(t,o,{get:e[o],enumerable:!0})};import ds from"classnames";import Pd,{createContext as Ad,useContext as us,useEffect as Ld,useState as Md}from"react";import Ed,{useContext as kd}from"react";import Rd from"classnames";var zt=Ed.createContext({});function v(t,e){let{debug:o,...n}=kd(zt),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:Rd(a,l,o?`${t}__${i}`:!1)}},{}):e}var ci={root:"_root_vr71j_1"};import{jsx as ko,jsxs as Id}from"react/jsx-runtime";var Ro=()=>Id("svg",{className:ci.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[ko("defs",{children:ko("style",{children:".cls-1 { fill: #b3b3b3; }"})}),ko("title",{children:"Failed loading image"}),ko("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 ps={root:"_root_4e7lf_1",imageWrapper:"_imageWrapper_4e7lf_7",image:"_image_4e7lf_7",content:"_content_4e7lf_24",title:"_title_4e7lf_35",contentIsCropped:"_contentIsCropped_4e7lf_45",lineClamp:"_lineClamp_4e7lf_51"};import{jsx as ct}from"react/jsx-runtime";var Io=Ad(ps),Nd=({title:t,src:e})=>{let o=us(Io),[n,s]=Md(!1);return Ld(()=>{s(!1)},[e]),ct("div",{className:o.imageWrapper,children:e&&!n?ct("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):ct(Ro,{})})},Od=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=us(Io);return ct("div",{className:ds(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Dd=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=us(Io);return Pd.createElement(t,{className:ds(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Po=({children:t})=>{let e=v("Card",ps);return ct("div",{className:ds(e.root),children:ct(Io.Provider,{value:e,children:t})})};Po.Image=Nd;Po.Content=Od;Po.Title=Dd;var H=Po;import Hd from"classnames";var pi={root:"_root_cq1yq_1"};import{jsx as Kd}from"react/jsx-runtime";var Bd={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Fd=({className:t,keyCode:e,...o})=>{let n=v("KeyboardHint",pi);return Kd("span",{"data-key":Bd[e],className:Hd(t,n.root),...o})},gs=Fd;import Ud from"classnames";var di={root:"_root_4a08n_1"};import{jsx as jd}from"react/jsx-runtime";var zd=({className:t,children:e,...o})=>{let n=v("Label",di);return jd("span",{...o,className:Ud(t,n.root),children:e})},ms=zd;var ui={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};import{jsx as fs,jsxs as qd}from"react/jsx-runtime";var Vd=({title:t,children:e,type:o,...n})=>{let s=v("Section",ui);return qd("section",{...n,className:s.root,"data-section-type":o,children:[t&&fs("div",{className:s.subTitleContainer,children:fs("span",{className:s.subtitle,children:t})}),fs("div",{className:s.suggestions,children:e})]})},Ve=Vd;import Wd from"classnames";import Gd from"react";var gi={root:"_root_19wxp_1"};import{jsx as Xd}from"react/jsx-runtime";var $d=Gd.forwardRef(({className:t,children:e},o)=>{let n=v("SectionList",gi);return Xd("div",{ref:o,className:Wd(n.root,t),children:e})}),hs=$d;import Ao from"classnames";import Qd,{createContext as Zd,useCallback as Jd,useContext as jt}from"react";var ys={root:"_root_ipo0b_11",fadein:"_fadein_ipo0b_1",isClickable:"_isClickable_ipo0b_46",isSelected:"_isSelected_ipo0b_51",actions:"_actions_ipo0b_75",actionsIsFixed:"_actionsIsFixed_ipo0b_97",actionButton:"_actionButton_ipo0b_105",dropdownList:"_dropdownList_ipo0b_126",dropdownButton:"_dropdownButton_ipo0b_141",dropdownItem:"_dropdownItem_ipo0b_151",dropdownItemButton:"_dropdownItemButton_ipo0b_160",actionButtonIsPrimary:"_actionButtonIsPrimary_ipo0b_174",actionButtonIsDisabled:"_actionButtonIsDisabled_ipo0b_178",labels:"_labels_ipo0b_186",label:"_label_ipo0b_186"};import{jsx as Se,jsxs as nu}from"react/jsx-runtime";var pt=Zd(ys),Yd=({fixed:t,children:e,...o})=>{let n=jt(pt);return Se("div",{...o,className:Ao(n.actions,{[n.actionsIsFixed]:t}),children:e})},eu=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=jt(pt);return nu("div",{className:Ao(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,Se("ul",{className:r.dropdownList,children:s})]})},tu=({index:t,label:e,onClick:o})=>{let n=jt(pt);return Se("li",{className:n.dropdownItem,children:Se("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},ou=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=jt(pt);return Se("button",{type:"button",className:Ao(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},vs=({labels:t})=>{let e=jt(pt);return Se("div",{className:e.labels,children:t.map(o=>Se("span",{className:e.label,children:o},o))})},dt=Qd.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=v("Suggestion",ys),l=Jd(c=>{c.preventDefault(),o&&o(c)},[o]);return Se(s,{...r,ref:i,className:Ao(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:Se(pt.Provider,{value:a,children:n})})});dt.Labels=vs;dt.Actions=Yd;dt.ActionButton=ou;dt.DropdownButton=eu;dt.DropdownItem=tu;var D=dt;import su from"classnames";var mi={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};import{jsx as iu}from"react/jsx-runtime";var ru=({withDivider:t,children:e})=>{let o=v("SuggestionList",mi);return iu("div",{"data-testid":"suggestions-overlay-list",className:su(o.root,{[o.isWithDivider]:t}),children:e})},re=ru;import au from"classnames";var fi={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};import{jsx as Ss}from"react/jsx-runtime";var lu=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=v("ToggleButton",fi);return Ss("button",{type:"button",className:au(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:Ss("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:Ss("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},ut=lu;var hi=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,gt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var yi=/x-deepdesk-(([a-z0-9\-_])+-version)/,ue=(f=>(f.SEARCH="search",f.TEMPLATE="template",f.ELASTIC_SEARCH="search-autocomplete",f.GPT="gpt",f.TRIE="trie",f.TRIE_WITH_TYPOS="trie-with-typos",f.SEMANTIC="semantic",f.TEXT_RECOMMENDATION="text_recommendation",f.URL_RECOMMENDATION="url_recommendation",f.LINK_RECOMMENDATION="link_recommendation",f.PERSONAL_COLLECTION="personal-collection",f.PERSONAL_COLLECTION_SEARCH="personal-collection-search",f.SEARCH_OVERLAY="search-overlay",f.SEARCH_PREVIEW="search-preview",f.SEARCH_URL="search-url",f))(ue||{}),qe=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(qe||{});import{render as Ft,unmountComponentAtNode as as}from"react-dom";import{Fragment as Xf}from"react";import{createSlice as cu}from"@reduxjs/toolkit";import{useSelector as pu}from"react-redux";var Lo=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Lo||{});var du={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!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,inlineSuggestions:!1,floatingMenu:!1,adminUrl:void 0,productName:"Deepdesk"},vi=cu({name:"settings",initialState:du,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:Vt}=vi.actions,_s=t=>e=>e.settings[t],C=t=>pu(_s(t)),Si=vi.reducer;import{useState as km}from"react";import{useDispatch as Rm,useSelector as ur}from"react-redux";import{createAction as We,createSlice as Su}from"@reduxjs/toolkit";import{diffChars as _u}from"diff";import{useSelector as xu}from"react-redux";function _i(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Ae(t,e,o=10){let n=typeof t,s=typeof e;if(o===0)throw new Error("Max depth deepEqual, possible circular references?");return n!==s?!1:t==null||n==="string"||n==="number"||n==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>Ae(r,e[i],o-1)):_i(t)&&_i(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Ae(t[i],e[i],o-1)):!1}function uu(t){return Math.max(...t.map(e=>e.length))}function gu(t,e){let o=t.reduce((n,s)=>{if(s){let r=n[s]?n[s]+1:1;return{...n,[s]:r}}return n},{});return Object.keys(o).reduce((n,s)=>(o[s]<e&&n.push(s),n),[])}function xi(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<uu(n);s++){let r=gu(n.map(a=>a[s]),e),i=n.filter(a=>!r.includes(a[s]));if(i.length>=e)n=i;else return{text:n[0].slice(0,s).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var mu=2;function xs(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=xi(t,mu);return o&&o.text!==e?o:t[0]}import{createAction as fu,createAsyncThunk as mt,createSlice as hu}from"@reduxjs/toolkit";var bi={current:null,isSupported:null},L=fu("resetConversation"),Mo=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},No=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},ft=t=>t.conversation.isSupported,bs=mt("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Oo=mt("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Do=mt("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Ho=mt("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=No(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),Cs=mt("conversation/upsert",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId).catch(()=>null).then(n=>{if(!n)return o.createConversation(t);let{agentId:s,agentName:r,agentEmail:i,agentNickname:a,tags:l}=t;return o.updateConversation(n.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,tags:l})})}),Bo=mt("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=No(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),yu=[Oo.rejected,Do.rejected,Ho.rejected,Bo.rejected].map(t=>t==null?void 0:t.toString()),vu=hu({name:"conversation",initialState:bi,reducers:{},extraReducers:t=>{t.addCase(bs.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Oo.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Do.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Cs.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Ho.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Bo.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(L,()=>bi).addMatcher(e=>yu.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),Ci=vu.reducer;var Le={text:"",html:null,selection:{start:0,end:0},stagedSuggestion:null,userCommitted:{text:"",selection:{start:0,end:0}},tabCompletionSuggestion:void 0,previousKeyDownEvent:null,textSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Ko(t){let{key:e,shiftKey:o,ctrlKey:n,metaKey:s,altKey:r}=t;return{key:e,shiftKey:o,ctrlKey:n,metaKey:s,altKey:r}}var Uo=We("input/replaceText"),zo=We("input/keyDown"),Ge=We("input/sendMessage"),jo=We("input/sendEditSuggestionMessage"),Vo=We("input/uiInputChange"),qo=We("input/applyImageSuggestion"),V=We("input/sendEvent");function Fo(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:l},eventMetrics:{inputType:c},replace:p}=t.stagedSuggestion,d=o==="search"||o==="personal-collection-search",u=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(d||p==="selection")&&(u=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(u=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:u,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:d?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var wi=t=>Su({name:t,initialState:Le,reducers:{initialInput(e,o){let{text:n,selection:s,html:r}=o.payload;e.text=n,e.selection.start=(s==null?void 0:s.start)??n.length,e.selection.end=(s==null?void 0:s.end)??n.length,e.userCommitted.text=n,e.userCommitted.selection.start=(s==null?void 0:s.start)??n.length,e.userCommitted.selection.end=(s==null?void 0:s.end)??n.length,e.html=r||null},reset(e){Object.assign(e,{...Le,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=xs(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(Ae(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Fo(e)))},platformInput(e,o){let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end),e.text=n,e.html=s||null},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:d,ctrlKey:u,metaKey:g,altKey:m}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:f}=e,{text:h}=o.payload,w=_u(f,h);f.length-h.length>1&&e.metrics.deletions.push(...w.filter(y=>y.removed).map(y=>y.value)),e.metrics.numCharsDeleted+=f.length-h.length;break}case"C":case"V":case"X":if(!u&&!g){e.metrics.numCharsTyped+=1;let f=((i=e.selection)==null?void 0:i.start)!==void 0&&((a=e.selection)==null?void 0:a.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}break;case"Shift":break;default:if(!u&&!g&&!m){e.metrics.numCharsTyped+=1;let f=((l=e.selection)==null?void 0:l.start)!==void 0&&((c=e.selection)==null?void 0:c.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=Le.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Fo(e);let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end,e.userCommitted.selection.start=r.start,e.userCommitted.selection.end=r.end),e.text=n,e.html=s||null,e.userCommitted.text=n,e.previousKeyDownEvent=null},stageSuggestion(e,o){let{text:n}=o.payload;switch(e.stagedSuggestion=o.payload,e.tabCompletionSuggestion=void 0,o.payload.replace){case"selection":e.text=`${e.text.slice(0,e.selection.start)}${n}${e.text.slice(e.selection.end)}`,e.selection.end=e.selection.start+n.length,e.selection.start+=n.length;break;case"until-selection-end":e.text=`${n}${e.text.slice(e.selection.end)}`,e.selection.start=n.length,e.selection.end=n.length;break;default:throw new Error(`Unknown replace ${o.payload.replace}`)}o.payload.eventMetrics.inputType==="tab"&&Fo(e)},commitSuggestion(e){Fo(e)},offeredTextSuggestion(e,o){let{text:n,suggestion:{source:s}}=o.payload;e.metrics.offeredTextSuggestions.find(i=>i.text===n)||e.metrics.offeredTextSuggestions.push({text:n,source:s})},registerCut(e,o){let{metrics:n}=e,s=o.payload;e.metrics={...e.metrics,numCharsCut:n.numCharsCut+s.length,cuts:[...n.cuts,s]}},registerPaste(e,o){let{metrics:n}=e,{text:s,selectionText:r}=o.payload,i=n.numCharsDeleted+(r&&r.length?r.length:0),a=r&&r.length?[...n.deletions,r]:n.deletions;e.metrics={...e.metrics,numCharsDeleted:i,deletions:a,numCharsPasted:n.numCharsPasted+s.length,numPaste:n.numPaste+1,pastes:[...n.pastes,s]}},registerKeyDown(e,o){e.previousKeyDownEvent=o.payload},nextTextSuggestionIndex(e){let o=e.textSuggestions.length;e.selectedSuggestionIndex=e.selectedSuggestionIndex<o-1?e.selectedSuggestionIndex+1:e.selectedSuggestionIndex},previousTextSuggestionIndex(e){e.selectedSuggestionIndex=e.selectedSuggestionIndex>=0?e.selectedSuggestionIndex-1:e.selectedSuggestionIndex},setTextSuggestions(e,o){if(e.selectedSuggestionIndex=-1,e.textSuggestions=o.payload,o.payload.length===0)return;let n=e.userCommitted.text.substring(0,e.userCommitted.selection.end),s=xs(o.payload,n);e.tabCompletionSuggestion=s!=null&&s.text.includes(n)?s:void 0},setSelectedTextSuggestionIndex(e,o){e.selectedSuggestionIndex=o.payload},mergeMetrics(e,{payload:o}){let n=o.agentStartedTypingTimestamp!=null?o.agentStartedTypingTimestamp:Date.now(),s=(Date.now()-n)/1e3;e.metrics.externalTimeTotalSeconds=s,e.metrics.numCharsTyped+=o.numCharsTyped,e.metrics.numCharsPasted+=o.numCharsPasted,e.metrics.numCharsCut+=o.numCharsCut,e.metrics.numCharsDeleted+=o.numCharsDeleted,e.metrics.numPaste+=o.numPaste,e.metrics.pastes.push(...o.pastes),e.metrics.deletions.push(...o.deletions)},setMetrics(e,{payload:o}){e.metrics=o}},extraReducers:e=>{e.addCase(L,o=>{o.tabCompletionSuggestion=Le.tabCompletionSuggestion,o.previousKeyDownEvent=Le.previousKeyDownEvent,o.textSuggestions=Le.textSuggestions,o.selectedSuggestionIndex=Le.selectedSuggestionIndex,o.metrics=Le.metrics})}}),ws=wi("input"),ht=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),bu=t=>t.input.selection,Ti=()=>xu(bu),{userInput:Ei,changeSelection:Ts,initialInput:ki,mergeMetrics:Ri,nextTextSuggestionIndex:Ii,offeredTextSuggestion:Pi,previousTextSuggestionIndex:Ai,registerCut:Li,registerKeyDown:Mi,registerPaste:Ni,reset:Oi,resetToCommitted:qt,platformInput:Di,setSelectedTextSuggestionIndex:Me,setTextSuggestions:ge,stageSuggestion:ie,commitSuggestion:_e,setMetrics:Hi}=ws.actions,Q=wi("overlay");import{useEffect as Fi,useRef as Ki}from"react";var Bi={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};import{jsx as Ui}from"react/jsx-runtime";var Cu=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=Ki(null),l=Ki(null),c=v("Dialog",Bi);return Fi(()=>{var u,g;let p=m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),s())},d=m=>{let f=window.getSelection();f!=null&&f.toString()||m.target===a.current&&t&&n()};return(u=a.current)==null||u.addEventListener("click",d),(g=a.current)==null||g.addEventListener("keyup",p),()=>{var m,f;(m=a.current)==null||m.removeEventListener("click",d),(f=a.current)==null||f.removeEventListener("keyup",p)}},[a,l,s,n]),Fi(()=>{var p,d;!a.current||!t||!e||(d=(p=a.current)==null?void 0:p.querySelector("input, textarea"))==null||d.focus()},[t,e,a]),t?Ui("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:Ui("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},yt=Cu;import{useEffect as Qa}from"react";import{useDispatch as lm,useSelector as cm}from"react-redux";var Es={};j(Es,{enUS:()=>wu,nlNL:()=>Tu});var wu={dismiss:[{type:0,value:"Close"}],add:[{type:0,value:"Add to message"}],next:[{type:0,value:"Next"}],previous:[{type:0,value:"Previous"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},Tu={dismiss:[{type:0,value:"Sluiten"}],add:[{type:0,value:"Toevoegen"}],next:[{type:0,value:"Volgende"}],previous:[{type:0,value:"Vorige"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var zi={root:"_root_l80t9_1",content:"_content_l80t9_3",title:"_title_l80t9_7",actions:"_actions_l80t9_15",pagination:"_pagination_l80t9_20",primaryButton:"_primaryButton_l80t9_51",primaryButtons:"_primaryButtons_l80t9_55"};import{createContext as Hu,useContext as Bu}from"react";var ks=function(t,e){return ks=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,n){o.__proto__=n}||function(o,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(o[s]=n[s])},ks(t,e)};function Wt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ks(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var te=function(){return te=Object.assign||function(e){for(var o,n=1,s=arguments.length;n<s;n++){o=arguments[n];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},te.apply(this,arguments)};function ji(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(o[n[s]]=t[n[s]]);return o}function Wo(t,e,o){if(o||arguments.length===2)for(var n=0,s=e.length,r;n<s;n++)(r||!(n in e))&&(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return t.concat(r||Array.prototype.slice.call(e))}var Go;(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"})(Go||(Go={}));var $o=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var ae;(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"})(ae||(ae={}));var Xo;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Xo||(Xo={}));function Rs(t){return t.type===ae.literal}function Vi(t){return t.type===ae.argument}function Qo(t){return t.type===ae.number}function Zo(t){return t.type===ae.date}function Jo(t){return t.type===ae.time}function Yo(t){return t.type===ae.select}function en(t){return t.type===ae.plural}function qi(t){return t.type===ae.pound}function tn(t){return t.type===ae.tag}function on(t){return!!(t&&typeof t=="object"&&t.type===Xo.number)}function Gt(t){return!!(t&&typeof t=="object"&&t.type===Xo.dateTime)}function Is(t){t.forEach(function(e){if(delete e.location,Yo(e)||en(e))for(var o in e.options)delete e.options[o].location,Is(e.options[o].value);else Qo(e)&&on(e.style)||(Zo(e)||Jo(e))&&Gt(e.style)?delete e.style.location:tn(e)&&Is(e.children)})}function Wi(t,e){e===void 0&&(e={}),e=te({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new $o(t,e).parse();if(o.err){var n=SyntaxError(Go[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||Is(o.val),o.val}function nn(t,e){var o=e&&e.cache?e.cache:Au,n=e&&e.serializer?e.serializer:Pu,s=e&&e.strategy?e.strategy:ku;return s(t,{cache:o,serializer:n})}function Eu(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Gi(t,e,o,n){var s=Eu(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function $i(t,e,o){var n=Array.prototype.slice.call(arguments,3),s=o(n),r=e.get(s);return typeof r>"u"&&(r=t.apply(this,n),e.set(s,r)),r}function Ps(t,e,o,n,s){return o.bind(e,t,n,s)}function ku(t,e){var o=t.length===1?Gi:$i;return Ps(t,this,o,e.cache.create(),e.serializer)}function Ru(t,e){return Ps(t,this,$i,e.cache.create(),e.serializer)}function Iu(t,e){return Ps(t,this,Gi,e.cache.create(),e.serializer)}var Pu=function(){return JSON.stringify(arguments)};function As(){this.cache=Object.create(null)}As.prototype.get=function(t){return this.cache[t]};As.prototype.set=function(t,e){this.cache[t]=e};var Au={create:function(){return new As}},sn={variadic:Ru,monadic:Iu};var $e;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})($e||($e={}));var $t=function(t){Wt(e,t);function e(o,n,s){var r=t.call(this,o)||this;return r.code=n,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e}(Error);var Ls=function(t){Wt(e,t);function e(o,n,s,r){return t.call(this,'Invalid values for "'.concat(o,'": "').concat(n,'". Options are "').concat(Object.keys(s).join('", "'),'"'),$e.INVALID_VALUE,r)||this}return e}($t);var Xi=function(t){Wt(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),$e.INVALID_VALUE,s)||this}return e}($t);var Qi=function(t){Wt(e,t);function e(o,n){return t.call(this,'The intl string context variable "'.concat(o,'" was not provided to the string "').concat(n,'"'),$e.MISSING_VALUE,n)||this}return e}($t);var q;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(q||(q={}));function Lu(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==q.literal||o.type!==q.literal?e.push(o):n.value+=o.value,e},[])}function Mu(t){return typeof t=="function"}function Xt(t,e,o,n,s,r,i){if(t.length===1&&Rs(t[0]))return[{type:q.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(Rs(p)){a.push({type:q.literal,value:p.value});continue}if(qi(p)){typeof r=="number"&&a.push({type:q.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new Qi(d,i);var u=s[d];if(Vi(p)){(!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(Zo(p)){var g=typeof p.style=="string"?n.date[p.style]:Gt(p.style)?p.style.parsedOptions:void 0;a.push({type:q.literal,value:o.getDateTimeFormat(e,g).format(u)});continue}if(Jo(p)){var g=typeof p.style=="string"?n.time[p.style]:Gt(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:q.literal,value:o.getDateTimeFormat(e,g).format(u)});continue}if(Qo(p)){var g=typeof p.style=="string"?n.number[p.style]:on(p.style)?p.style.parsedOptions:void 0;g&&g.scale&&(u=u*(g.scale||1)),a.push({type:q.literal,value:o.getNumberFormat(e,g).format(u)});continue}if(tn(p)){var m=p.children,f=p.value,h=s[f];if(!Mu(h))throw new Xi(f,"function",i);var w=Xt(m,e,o,n,s,r),y=h(w.map(function(_){return _.value}));Array.isArray(y)||(y=[y]),a.push.apply(a,y.map(function(_){return{type:typeof _=="string"?q.literal:q.object,value:_}}))}if(Yo(p)){var x=p.options[u]||p.options.other;if(!x)throw new Ls(p.value,u,Object.keys(p.options),i);a.push.apply(a,Xt(x.value,e,o,n,s));continue}if(en(p)){var x=p.options["=".concat(u)];if(!x){if(!Intl.PluralRules)throw new $t(`Intl.PluralRules is not available in this environment.
1
+ var Ed=Object.defineProperty;var z=(t,e)=>{for(var o in e)Ed(t,o,{get:e[o],enumerable:!0})};import ds from"classnames";import Ad,{createContext as Ld,useContext as us,useEffect as Md,useState as Nd}from"react";import kd,{useContext as Rd}from"react";import Id from"classnames";var zt=kd.createContext({});function v(t,e){let{debug:o,...n}=Rd(zt),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:Id(a,l,o?`${t}__${i}`:!1)}},{}):e}var li={root:"_root_vr71j_1"};import{jsx as Ro,jsxs as Pd}from"react/jsx-runtime";var Io=()=>Pd("svg",{className:li.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[Ro("defs",{children:Ro("style",{children:".cls-1 { fill: #b3b3b3; }"})}),Ro("title",{children:"Failed loading image"}),Ro("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 ps={root:"_root_4e7lf_1",imageWrapper:"_imageWrapper_4e7lf_7",image:"_image_4e7lf_7",content:"_content_4e7lf_24",title:"_title_4e7lf_35",contentIsCropped:"_contentIsCropped_4e7lf_45",lineClamp:"_lineClamp_4e7lf_51"};import{jsx as ct}from"react/jsx-runtime";var Po=Ld(ps),Od=({title:t,src:e})=>{let o=us(Po),[n,s]=Nd(!1);return Md(()=>{s(!1)},[e]),ct("div",{className:o.imageWrapper,children:e&&!n?ct("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):ct(Io,{})})},Dd=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=us(Po);return ct("div",{className:ds(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Hd=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=us(Po);return Ad.createElement(t,{className:ds(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Ao=({children:t})=>{let e=v("Card",ps);return ct("div",{className:ds(e.root),children:ct(Po.Provider,{value:e,children:t})})};Ao.Image=Od;Ao.Content=Dd;Ao.Title=Hd;var H=Ao;import Bd from"classnames";var ci={root:"_root_cq1yq_1"};import{jsx as Ud}from"react/jsx-runtime";var Fd={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Kd=({className:t,keyCode:e,...o})=>{let n=v("KeyboardHint",ci);return Ud("span",{"data-key":Fd[e],className:Bd(t,n.root),...o})},gs=Kd;import jd from"classnames";var pi={root:"_root_4a08n_1"};import{jsx as Vd}from"react/jsx-runtime";var zd=({className:t,children:e,...o})=>{let n=v("Label",pi);return Vd("span",{...o,className:jd(t,n.root),children:e})},ms=zd;var di={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};import{jsx as fs,jsxs as Wd}from"react/jsx-runtime";var qd=({title:t,children:e,type:o,...n})=>{let s=v("Section",di);return Wd("section",{...n,className:s.root,"data-section-type":o,children:[t&&fs("div",{className:s.subTitleContainer,children:fs("span",{className:s.subtitle,children:t})}),fs("div",{className:s.suggestions,children:e})]})},Ve=qd;import Gd from"classnames";import $d from"react";var ui={root:"_root_19wxp_1"};import{jsx as Zd}from"react/jsx-runtime";var Xd=$d.forwardRef(({className:t,children:e},o)=>{let n=v("SectionList",ui);return Zd("div",{ref:o,className:Gd(n.root,t),children:e})}),hs=Xd;import Lo from"classnames";import Qd,{createContext as Jd,useCallback as Yd,useContext as Vt}from"react";var ys={root:"_root_ipo0b_11",fadein:"_fadein_ipo0b_1",isClickable:"_isClickable_ipo0b_46",isSelected:"_isSelected_ipo0b_51",actions:"_actions_ipo0b_75",actionsIsFixed:"_actionsIsFixed_ipo0b_97",actionButton:"_actionButton_ipo0b_105",dropdownList:"_dropdownList_ipo0b_126",dropdownButton:"_dropdownButton_ipo0b_141",dropdownItem:"_dropdownItem_ipo0b_151",dropdownItemButton:"_dropdownItemButton_ipo0b_160",actionButtonIsPrimary:"_actionButtonIsPrimary_ipo0b_174",actionButtonIsDisabled:"_actionButtonIsDisabled_ipo0b_178",labels:"_labels_ipo0b_186",label:"_label_ipo0b_186"};import{jsx as Se,jsxs as su}from"react/jsx-runtime";var pt=Jd(ys),eu=({fixed:t,children:e,...o})=>{let n=Vt(pt);return Se("div",{...o,className:Lo(n.actions,{[n.actionsIsFixed]:t}),children:e})},tu=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=Vt(pt);return su("div",{className:Lo(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,Se("ul",{className:r.dropdownList,children:s})]})},ou=({index:t,label:e,onClick:o})=>{let n=Vt(pt);return Se("li",{className:n.dropdownItem,children:Se("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},nu=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=Vt(pt);return Se("button",{type:"button",className:Lo(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},vs=({labels:t})=>{let e=Vt(pt);return Se("div",{className:e.labels,children:t.map(o=>Se("span",{className:e.label,children:o},o))})},dt=Qd.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=v("Suggestion",ys),l=Yd(c=>{c.preventDefault(),o&&o(c)},[o]);return Se(s,{...r,ref:i,className:Lo(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:Se(pt.Provider,{value:a,children:n})})});dt.Labels=vs;dt.Actions=eu;dt.ActionButton=nu;dt.DropdownButton=tu;dt.DropdownItem=ou;var D=dt;import ru from"classnames";var gi={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};import{jsx as au}from"react/jsx-runtime";var iu=({withDivider:t,children:e})=>{let o=v("SuggestionList",gi);return au("div",{"data-testid":"suggestions-overlay-list",className:ru(o.root,{[o.isWithDivider]:t}),children:e})},re=iu;import lu from"classnames";var mi={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};import{jsx as Ss}from"react/jsx-runtime";var cu=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=v("ToggleButton",mi);return Ss("button",{type:"button",className:lu(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:Ss("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:Ss("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},ut=cu;var fi=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,gt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var hi=/x-deepdesk-(([a-z0-9\-_])+-version)/,ue=(f=>(f.SEARCH="search",f.TEMPLATE="template",f.ELASTIC_SEARCH="search-autocomplete",f.GPT="gpt",f.TRIE="trie",f.TRIE_WITH_TYPOS="trie-with-typos",f.SEMANTIC="semantic",f.TEXT_RECOMMENDATION="text_recommendation",f.URL_RECOMMENDATION="url_recommendation",f.LINK_RECOMMENDATION="link_recommendation",f.PERSONAL_COLLECTION="personal-collection",f.PERSONAL_COLLECTION_SEARCH="personal-collection-search",f.SEARCH_OVERLAY="search-overlay",f.SEARCH_PREVIEW="search-preview",f.SEARCH_URL="search-url",f))(ue||{}),qe=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(qe||{});import{render as Kt,unmountComponentAtNode as as}from"react-dom";import{Fragment as Qf}from"react";import{createSlice as pu}from"@reduxjs/toolkit";import{useSelector as du}from"react-redux";var Mo=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Mo||{});var uu={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!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,inlineSuggestions:!1,floatingMenu:!1,adminUrl:void 0,productName:"Deepdesk"},yi=pu({name:"settings",initialState:uu,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:qt}=yi.actions,_s=t=>e=>e.settings[t],C=t=>du(_s(t)),vi=yi.reducer;import{useState as Im}from"react";import{useDispatch as Pm,useSelector as dr}from"react-redux";import{createAction as We,createSlice as _u}from"@reduxjs/toolkit";import{diffChars as xu}from"diff";import{useSelector as bu}from"react-redux";function Si(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Ae(t,e,o=10){let n=typeof t,s=typeof e;if(o===0)throw new Error("Max depth deepEqual, possible circular references?");return n!==s?!1:t==null||n==="string"||n==="number"||n==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>Ae(r,e[i],o-1)):Si(t)&&Si(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Ae(t[i],e[i],o-1)):!1}function gu(t){return Math.max(...t.map(e=>e.length))}function mu(t,e){let o=t.reduce((n,s)=>{if(s){let r=n[s]?n[s]+1:1;return{...n,[s]:r}}return n},{});return Object.keys(o).reduce((n,s)=>(o[s]<e&&n.push(s),n),[])}function _i(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<gu(n);s++){let r=mu(n.map(a=>a[s]),e),i=n.filter(a=>!r.includes(a[s]));if(i.length>=e)n=i;else return{text:n[0].slice(0,s).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var fu=2;function xs(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=_i(t,fu);return o&&o.text!==e?o:t[0]}import{createAction as hu,createAsyncThunk as mt,createSlice as yu}from"@reduxjs/toolkit";var xi={current:null,isSupported:null},L=hu("resetConversation"),No=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Oo=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},ft=t=>t.conversation.isSupported,bs=mt("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Do=mt("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Ho=mt("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Bo=mt("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Oo(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),Cs=mt("conversation/upsert",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId).catch(()=>null).then(n=>{if(!n)return o.createConversation(t);let{agentId:s,agentName:r,agentEmail:i,agentNickname:a,tags:l}=t;return o.updateConversation(n.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,tags:l})})}),Fo=mt("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Oo(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),vu=[Do.rejected,Ho.rejected,Bo.rejected,Fo.rejected].map(t=>t==null?void 0:t.toString()),Su=yu({name:"conversation",initialState:xi,reducers:{},extraReducers:t=>{t.addCase(bs.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Do.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Ho.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Cs.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Bo.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Fo.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(L,()=>xi).addMatcher(e=>vu.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),bi=Su.reducer;var Le={text:"",html:null,selection:{start:0,end:0},stagedSuggestion:null,userCommitted:{text:"",selection:{start:0,end:0}},tabCompletionSuggestion:void 0,previousKeyDownEvent:null,textSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Uo(t){let{key:e,shiftKey:o,ctrlKey:n,metaKey:s,altKey:r}=t;return{key:e,shiftKey:o,ctrlKey:n,metaKey:s,altKey:r}}var jo=We("input/replaceText"),zo=We("input/keyDown"),Ge=We("input/sendMessage"),Vo=We("input/sendEditSuggestionMessage"),qo=We("input/uiInputChange"),Wo=We("input/applyImageSuggestion"),V=We("input/sendEvent");function Ko(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:l},eventMetrics:{inputType:c},replace:p}=t.stagedSuggestion,d=o==="search"||o==="personal-collection-search",u=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(d||p==="selection")&&(u=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(u=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:u,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:d?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var Ci=t=>_u({name:t,initialState:Le,reducers:{initialInput(e,o){let{text:n,selection:s,html:r}=o.payload;e.text=n,e.selection.start=(s==null?void 0:s.start)??n.length,e.selection.end=(s==null?void 0:s.end)??n.length,e.userCommitted.text=n,e.userCommitted.selection.start=(s==null?void 0:s.start)??n.length,e.userCommitted.selection.end=(s==null?void 0:s.end)??n.length,e.html=r||null},reset(e){Object.assign(e,{...Le,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=xs(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(Ae(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Ko(e)))},platformInput(e,o){let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end),e.text=n,e.html=s||null},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:d,ctrlKey:u,metaKey:g,altKey:m}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:f}=e,{text:h}=o.payload,w=xu(f,h);f.length-h.length>1&&e.metrics.deletions.push(...w.filter(y=>y.removed).map(y=>y.value)),e.metrics.numCharsDeleted+=f.length-h.length;break}case"C":case"V":case"X":if(!u&&!g){e.metrics.numCharsTyped+=1;let f=((i=e.selection)==null?void 0:i.start)!==void 0&&((a=e.selection)==null?void 0:a.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}break;case"Shift":break;default:if(!u&&!g&&!m){e.metrics.numCharsTyped+=1;let f=((l=e.selection)==null?void 0:l.start)!==void 0&&((c=e.selection)==null?void 0:c.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=Le.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Ko(e);let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end,e.userCommitted.selection.start=r.start,e.userCommitted.selection.end=r.end),e.text=n,e.html=s||null,e.userCommitted.text=n,e.previousKeyDownEvent=null},stageSuggestion(e,o){let{text:n}=o.payload;switch(e.stagedSuggestion=o.payload,e.tabCompletionSuggestion=void 0,o.payload.replace){case"selection":e.text=`${e.text.slice(0,e.selection.start)}${n}${e.text.slice(e.selection.end)}`,e.selection.end=e.selection.start+n.length,e.selection.start+=n.length;break;case"until-selection-end":e.text=`${n}${e.text.slice(e.selection.end)}`,e.selection.start=n.length,e.selection.end=n.length;break;default:throw new Error(`Unknown replace ${o.payload.replace}`)}o.payload.eventMetrics.inputType==="tab"&&Ko(e)},commitSuggestion(e){Ko(e)},offeredTextSuggestion(e,o){let{text:n,suggestion:{source:s}}=o.payload;e.metrics.offeredTextSuggestions.find(i=>i.text===n)||e.metrics.offeredTextSuggestions.push({text:n,source:s})},registerCut(e,o){let{metrics:n}=e,s=o.payload;e.metrics={...e.metrics,numCharsCut:n.numCharsCut+s.length,cuts:[...n.cuts,s]}},registerPaste(e,o){let{metrics:n}=e,{text:s,selectionText:r}=o.payload,i=n.numCharsDeleted+(r&&r.length?r.length:0),a=r&&r.length?[...n.deletions,r]:n.deletions;e.metrics={...e.metrics,numCharsDeleted:i,deletions:a,numCharsPasted:n.numCharsPasted+s.length,numPaste:n.numPaste+1,pastes:[...n.pastes,s]}},registerKeyDown(e,o){e.previousKeyDownEvent=o.payload},nextTextSuggestionIndex(e){let o=e.textSuggestions.length;e.selectedSuggestionIndex=e.selectedSuggestionIndex<o-1?e.selectedSuggestionIndex+1:e.selectedSuggestionIndex},previousTextSuggestionIndex(e){e.selectedSuggestionIndex=e.selectedSuggestionIndex>=0?e.selectedSuggestionIndex-1:e.selectedSuggestionIndex},setTextSuggestions(e,o){if(e.selectedSuggestionIndex=-1,e.textSuggestions=o.payload,o.payload.length===0)return;let n=e.userCommitted.text.substring(0,e.userCommitted.selection.end),s=xs(o.payload,n);e.tabCompletionSuggestion=s!=null&&s.text.includes(n)?s:void 0},setSelectedTextSuggestionIndex(e,o){e.selectedSuggestionIndex=o.payload},mergeMetrics(e,{payload:o}){let n=o.agentStartedTypingTimestamp!=null?o.agentStartedTypingTimestamp:Date.now(),s=(Date.now()-n)/1e3;e.metrics.externalTimeTotalSeconds=s,e.metrics.numCharsTyped+=o.numCharsTyped,e.metrics.numCharsPasted+=o.numCharsPasted,e.metrics.numCharsCut+=o.numCharsCut,e.metrics.numCharsDeleted+=o.numCharsDeleted,e.metrics.numPaste+=o.numPaste,e.metrics.pastes.push(...o.pastes),e.metrics.deletions.push(...o.deletions)},setMetrics(e,{payload:o}){e.metrics=o}},extraReducers:e=>{e.addCase(L,o=>{o.tabCompletionSuggestion=Le.tabCompletionSuggestion,o.previousKeyDownEvent=Le.previousKeyDownEvent,o.textSuggestions=Le.textSuggestions,o.selectedSuggestionIndex=Le.selectedSuggestionIndex,o.metrics=Le.metrics})}}),ws=Ci("input"),ht=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),Cu=t=>t.input.selection,wi=()=>bu(Cu),{userInput:Ti,changeSelection:Ts,initialInput:Ei,mergeMetrics:ki,nextTextSuggestionIndex:Ri,offeredTextSuggestion:Ii,previousTextSuggestionIndex:Pi,registerCut:Ai,registerKeyDown:Li,registerPaste:Mi,reset:Ni,resetToCommitted:Wt,platformInput:Oi,setSelectedTextSuggestionIndex:Me,setTextSuggestions:ge,stageSuggestion:ie,commitSuggestion:_e,setMetrics:Di}=ws.actions,Z=Ci("overlay");import{useEffect as Bi,useRef as Fi}from"react";var Hi={root:"_root_1h19b_1",content:"_content_1h19b_24"};import{jsx as Ki}from"react/jsx-runtime";var wu=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=Fi(null),l=Fi(null),c=v("Dialog",Hi);return Bi(()=>{var u,g;let p=m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),s())},d=m=>{let f=window.getSelection();f!=null&&f.toString()||m.target===a.current&&t&&n()};return(u=a.current)==null||u.addEventListener("click",d),(g=a.current)==null||g.addEventListener("keyup",p),()=>{var m,f;(m=a.current)==null||m.removeEventListener("click",d),(f=a.current)==null||f.removeEventListener("keyup",p)}},[a,l,s,n]),Bi(()=>{var p,d;!a.current||!t||!e||(d=(p=a.current)==null?void 0:p.querySelector("input, textarea"))==null||d.focus()},[t,e,a]),t?Ki("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:Ki("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},yt=wu;import{useEffect as Qa}from"react";import{useDispatch as pm,useSelector as dm}from"react-redux";var Es={};z(Es,{enUS:()=>Tu,nlNL:()=>Eu});var Tu={dismiss:[{type:0,value:"Close"}],add:[{type:0,value:"Add to message"}],next:[{type:0,value:"Next"}],previous:[{type:0,value:"Previous"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},Eu={dismiss:[{type:0,value:"Sluiten"}],add:[{type:0,value:"Toevoegen"}],next:[{type:0,value:"Volgende"}],previous:[{type:0,value:"Vorige"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var Ui={root:"_root_jcr8j_1",content:"_content_jcr8j_3",title:"_title_jcr8j_7",actions:"_actions_jcr8j_15",pagination:"_pagination_jcr8j_19",primaryButton:"_primaryButton_jcr8j_50",primaryButtons:"_primaryButtons_jcr8j_54"};import{createContext as Bu,useContext as Fu}from"react";var ks=function(t,e){return ks=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,n){o.__proto__=n}||function(o,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(o[s]=n[s])},ks(t,e)};function Gt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ks(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var te=function(){return te=Object.assign||function(e){for(var o,n=1,s=arguments.length;n<s;n++){o=arguments[n];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},te.apply(this,arguments)};function ji(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(o[n[s]]=t[n[s]]);return o}function Go(t,e,o){if(o||arguments.length===2)for(var n=0,s=e.length,r;n<s;n++)(r||!(n in e))&&(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return t.concat(r||Array.prototype.slice.call(e))}var $o;(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"})($o||($o={}));var Xo=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var ae;(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"})(ae||(ae={}));var Zo;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Zo||(Zo={}));function Rs(t){return t.type===ae.literal}function zi(t){return t.type===ae.argument}function Qo(t){return t.type===ae.number}function Jo(t){return t.type===ae.date}function Yo(t){return t.type===ae.time}function en(t){return t.type===ae.select}function tn(t){return t.type===ae.plural}function Vi(t){return t.type===ae.pound}function on(t){return t.type===ae.tag}function nn(t){return!!(t&&typeof t=="object"&&t.type===Zo.number)}function $t(t){return!!(t&&typeof t=="object"&&t.type===Zo.dateTime)}function Is(t){t.forEach(function(e){if(delete e.location,en(e)||tn(e))for(var o in e.options)delete e.options[o].location,Is(e.options[o].value);else Qo(e)&&nn(e.style)||(Jo(e)||Yo(e))&&$t(e.style)?delete e.style.location:on(e)&&Is(e.children)})}function qi(t,e){e===void 0&&(e={}),e=te({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new Xo(t,e).parse();if(o.err){var n=SyntaxError($o[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||Is(o.val),o.val}function sn(t,e){var o=e&&e.cache?e.cache:Lu,n=e&&e.serializer?e.serializer:Au,s=e&&e.strategy?e.strategy:Ru;return s(t,{cache:o,serializer:n})}function ku(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Wi(t,e,o,n){var s=ku(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function Gi(t,e,o){var n=Array.prototype.slice.call(arguments,3),s=o(n),r=e.get(s);return typeof r>"u"&&(r=t.apply(this,n),e.set(s,r)),r}function Ps(t,e,o,n,s){return o.bind(e,t,n,s)}function Ru(t,e){var o=t.length===1?Wi:Gi;return Ps(t,this,o,e.cache.create(),e.serializer)}function Iu(t,e){return Ps(t,this,Gi,e.cache.create(),e.serializer)}function Pu(t,e){return Ps(t,this,Wi,e.cache.create(),e.serializer)}var Au=function(){return JSON.stringify(arguments)};function As(){this.cache=Object.create(null)}As.prototype.get=function(t){return this.cache[t]};As.prototype.set=function(t,e){this.cache[t]=e};var Lu={create:function(){return new As}},rn={variadic:Iu,monadic:Pu};var $e;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})($e||($e={}));var Xt=function(t){Gt(e,t);function e(o,n,s){var r=t.call(this,o)||this;return r.code=n,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e}(Error);var Ls=function(t){Gt(e,t);function e(o,n,s,r){return t.call(this,'Invalid values for "'.concat(o,'": "').concat(n,'". Options are "').concat(Object.keys(s).join('", "'),'"'),$e.INVALID_VALUE,r)||this}return e}(Xt);var $i=function(t){Gt(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),$e.INVALID_VALUE,s)||this}return e}(Xt);var Xi=function(t){Gt(e,t);function e(o,n){return t.call(this,'The intl string context variable "'.concat(o,'" was not provided to the string "').concat(n,'"'),$e.MISSING_VALUE,n)||this}return e}(Xt);var q;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(q||(q={}));function Mu(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==q.literal||o.type!==q.literal?e.push(o):n.value+=o.value,e},[])}function Nu(t){return typeof t=="function"}function Zt(t,e,o,n,s,r,i){if(t.length===1&&Rs(t[0]))return[{type:q.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(Rs(p)){a.push({type:q.literal,value:p.value});continue}if(Vi(p)){typeof r=="number"&&a.push({type:q.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new Xi(d,i);var u=s[d];if(zi(p)){(!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(Jo(p)){var g=typeof p.style=="string"?n.date[p.style]:$t(p.style)?p.style.parsedOptions:void 0;a.push({type:q.literal,value:o.getDateTimeFormat(e,g).format(u)});continue}if(Yo(p)){var g=typeof p.style=="string"?n.time[p.style]:$t(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:q.literal,value:o.getDateTimeFormat(e,g).format(u)});continue}if(Qo(p)){var g=typeof p.style=="string"?n.number[p.style]:nn(p.style)?p.style.parsedOptions:void 0;g&&g.scale&&(u=u*(g.scale||1)),a.push({type:q.literal,value:o.getNumberFormat(e,g).format(u)});continue}if(on(p)){var m=p.children,f=p.value,h=s[f];if(!Nu(h))throw new $i(f,"function",i);var w=Zt(m,e,o,n,s,r),y=h(w.map(function(_){return _.value}));Array.isArray(y)||(y=[y]),a.push.apply(a,y.map(function(_){return{type:typeof _=="string"?q.literal:q.object,value:_}}))}if(en(p)){var x=p.options[u]||p.options.other;if(!x)throw new Ls(p.value,u,Object.keys(p.options),i);a.push.apply(a,Zt(x.value,e,o,n,s));continue}if(tn(p)){var x=p.options["=".concat(u)];if(!x){if(!Intl.PluralRules)throw new Xt(`Intl.PluralRules is not available in this environment.
2
2
  Try polyfilling it using "@formatjs/intl-pluralrules"
3
- `,$e.MISSING_INTL_API,i);var b=o.getPluralRules(e,{type:p.pluralType}).select(u-(p.offset||0));x=p.options[b]||p.options.other}if(!x)throw new Ls(p.value,u,Object.keys(p.options),i);a.push.apply(a,Xt(x.value,e,o,n,s,u-(p.offset||0)));continue}}return Lu(a)}function Nu(t,e){return e?te(te(te({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=te(te({},t[n]),e[n]||{}),o},{})):t}function Ou(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Nu(t[n],e[n]),o},te({},t)):t}function Ms(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Du(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:nn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,Wo([void 0],o,!1)))},{cache:Ms(t.number),strategy:sn.variadic}),getDateTimeFormat:nn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,Wo([void 0],o,!1)))},{cache:Ms(t.dateTime),strategy:sn.variadic}),getPluralRules:nn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,Wo([void 0],o,!1)))},{cache:Ms(t.pluralRules),strategy:sn.variadic})}}var Zi=function(){function t(e,o,n,s){o===void 0&&(o=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var p=r.formatToParts(c);if(p.length===1)return p[0].value;var d=p.reduce(function(u,g){return!u.length||g.type!==q.literal||typeof u[u.length-1]!="string"?u.push(g.value):u[u.length-1]+=g.value,u},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return Xt(r.ast,r.locales,r.formatters,r.formats,c,void 0,r.message)},this.resolvedOptions=function(){var c;return{locale:((c=r.resolvedLocale)===null||c===void 0?void 0:c.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=o,this.resolvedLocale=t.resolveLocale(o),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=s||{},a=i.formatters,l=ji(i,["formatters"]);this.ast=t.__parse(e,te(te({},l),{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=Ou(t.formats,n),this.formatters=s&&s.formatters||Du(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>"u")){var o=Intl.NumberFormat.supportedLocalesOf(e);return o.length>0?new Intl.Locale(o[0]):new Intl.Locale(typeof e=="string"?e:e[0])}},t.__parse=Wi,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 Fu(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var Ku="dummy",Ns=Hu(null);function T(t){let e=Bu(Ns);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let o=t[e]??{};return(n,s)=>{let r=Fu(o,n);return r?new Zi(r).format(s):(e!==Ku&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}import{jsx as Ji,jsxs as Uu}from"react/jsx-runtime";var rn=()=>Uu("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[Ji("title",{id:"angleLeftTitle",children:"AngleLeft"}),Ji("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 Yi,jsxs as zu}from"react/jsx-runtime";var ea=()=>zu("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[Yi("title",{id:"angleRightTitle",children:"AngleRight"}),Yi("path",{d:"M64 448c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L178.8 256L41.38 118.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l160 160c12.5 12.5 12.5 32.75 0 45.25l-160 160C80.38 444.9 72.19 448 64 448z"})]});import{useEffect as Zt,useRef as Vs,useState as dg}from"react";import{useDispatch as ug}from"react-redux";import{Interweave as Sa}from"interweave";import _a from"classnames";var Os={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};import{Matcher as Wu}from"interweave";import Gu from"classnames";import{useEffect as ju,useRef as Vu,useState as qu}from"react";function ta(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function an(t){let e=Vu(null),[o,n]=qu(!1);return ju(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=ta((p,d)=>{let u=e.current;if(!u)return;let g=p/r,m=d/r,f=u.getBoundingClientRect(),h=g>f.x&&g<f.x+f.width&&m>f.y&&m<f.y+f.height;h&&!s?(s=!0,n(!0)):!h&&s&&(s=!1,n(!1))},({clientX:p,clientY:d})=>[p,d]),[l,c]=ta(()=>{s=!1,n(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",l),()=>{a(),c(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",l)}},[e]),[e,o]}var xe={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};import{jsx as oa}from"react/jsx-runtime";var $u=({inputElement:t,children:e})=>{let o=v("TabCompletion",xe),[n,s]=an(t);return oa("mark",{ref:n,className:Gu(o.matchPlaceholder,{[o.hover]:s}),children:e})},vt=class extends Wu{match(e){let o=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return o?{index:o.index,length:o[0].length,match:o[0],matchString:o[0],valid:!0}:null}replaceWith(e,o){return oa($u,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import{useEffect as Xu,useRef as Qu,useState as Zu}from"react";function ln(t){return t.contentEditable==="true"}function Ju(t){let e=0,o=0,n=window.getSelection();if(n.rangeCount!==0){let s=n.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),o=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:o}}function na(t){let{selectionStart:e,selectionEnd:o}=ln(t)?Ju(t):t;return[e,o]}function cn(t){let[,e]=Zu(),o=Qu(null);return o.current=na(t),Xu(()=>{let n=()=>{let[s,r]=o.current??[],i=na(t);(!i||s!==i[0]||r!==i[1])&&(o.current=i,e({}))};return t.addEventListener("keyup",n),t.addEventListener("click",n),t.addEventListener("focus",n),document.addEventListener("selectionchange",n),()=>{t.removeEventListener("keyup",n),t.removeEventListener("click",n),t.removeEventListener("focus",n),document.removeEventListener("selectionchange",n)}},[t]),o.current}function pn(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(gt);if(!i||i.length===0)return;let a=0;i.find(l=>{let c=n.indexOf(l,a);return s>c&&r<c+l.length?(o.selectionStart=c,o.selectionEnd=c+l.length,!0):(a=c+l.length,!1)})}import{useEffect as Yu}from"react";function St(t){Yu(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Xe(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var sa,me=new Map,eg=["bottom","height","left","right","top","width"],tg=(t={},e={})=>eg.some(o=>t[o]!==e[o]);function ra(t){var o,n;if(t.ownerDocument===document)return[];let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...ra(e)]:[]}function ia(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var dn=!1,aa=()=>{dn=!0;let t=[];if(me.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),me.delete(o);return}let n=o.getBoundingClientRect();tg(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(ia,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),me.size===0){dn=!1;return}sa=window.requestAnimationFrame(aa)};function Ds(t,e){let o=ra(t),n=[],s=o.map((r,i)=>Ds(r,a=>{n[i]=a;let l=me.get(t);if(!l)return;let c=n.reduce(ia,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),me.has(t)){let i=me.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else me.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!dn&&aa()},unobserve(){s.forEach(i=>i.unobserve());let r=me.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||me.delete(t),me.size||(cancelAnimationFrame(sa),dn=!1)}}}}var la,fe=new Map,ca=()=>{fe.forEach((t,e)=>{if(!e.isConnected){fe.delete(e);return}let{clientHeight:o,scrollHeight:n}=e,s=n>o;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),fe.size!==0&&(la=window.requestAnimationFrame(ca))};function pa(t,e){return{observe(){let o=fe.size===0;fe.has(t)?fe.get(t).callbacks.push(e):fe.set(t,{visible:void 0,callbacks:[e]}),o&&ca()},unobserve(){let o=fe.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||fe.delete(t),fe.size||cancelAnimationFrame(la)}}}}var Hs=["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 Bs(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function _t(t){return parseFloat(t)}function un(t){return Math.round(t*1e6)}function da(t){return t/1e6}function Fs(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=_t(t.width),r=_t(t.borderLeftWidth),i=_t(t.borderRightWidth),a=_t(t.paddingRight),l=da(un(s)-un(r)-un(i)),c=da(un(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function xt(t,e={}){var p;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",Xe(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Bs(n,o,Hs),Fs(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=pa(t,()=>{Bs(n,o,Hs),Fs(n,t,o),r(),setTimeout(r,0)}),a,l=!0,c=Ds(t,d=>{if(d===null){e.onRemove&&e.onRemove(),o.remove();return}if(!l&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Bs(n,o,Hs),Fs(n,t,o),r(),o.style.top=`${d.top}px`,o.style.left=`${d.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let u=e.closestScrollElement.getBoundingClientRect(),g=window.getComputedStyle(e.closestScrollElement),m=_t(g.borderTopWidth),f=_t(g.borderBottomWidth),h=u.top+m-d.top,w=d.top+d.height+-(u.top+u.height-f);o.style.clipPath=`inset(${h}px 0px ${w}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(p=t.parentElement)==null||p.appendChild(o),c.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),c.unobserve(),i.unobserve()}]}var Ks={};j(Ks,{enUS:()=>og,nlNL:()=>ng});var og={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"No placeholders found"}]},one:{value:[{type:0,value:"There is one placeholder in your message"}]},other:{value:[{type:0,value:"There are "},{type:7},{type:0,value:" placeholders in your message"}]}},offset:0,pluralType:"cardinal"}]},ng={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"Alle placeholders zijn uit je bericht"}]},one:{value:[{type:0,value:"Er is 1 placeholder in jouw bericht"}]},other:{value:[{type:0,value:"Er zijn "},{type:7},{type:0,value:" placeholders in jouw bericht"}]}},offset:0,pluralType:"cardinal"}]};import{jsx as ua,jsxs as sg}from"react/jsx-runtime";var ga=()=>sg("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[ua("title",{id:"circleCheckTitle",children:"Check"}),ua("path",{d:"M243.8 339.8C232.9 350.7 215.1 350.7 204.2 339.8L140.2 275.8C129.3 264.9 129.3 247.1 140.2 236.2C151.1 225.3 168.9 225.3 179.8 236.2L224 280.4L332.2 172.2C343.1 161.3 360.9 161.3 371.8 172.2C382.7 183.1 382.7 200.9 371.8 211.8L243.8 339.8zM512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256zM256 48C141.1 48 48 141.1 48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48z"})]});import{jsx as ma}from"react/jsx-runtime";var fa=()=>ma("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:ma("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var ha=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(ha||{}),Ne=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentCaret=null;currentSelection={start:0,end:0};currentHTML="";isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(e,o){let n=s=>{o(s)};this.element.addEventListener(e,n),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,n)})}removeEventListener(e,o){this.element.removeEventListener(e,o)}triggerChange(){let e=this.getText(),o=this.getHTML(),n=e!==this.currentText;this.isActive&&(e===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&n&&!this.isSubmitting&&this.emit("change",{plainText:e}),n&&(this.currentSelection=this.getSelection()),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==o||o===null&&n)&&(this.emit("updated",{plainText:e}),this.triggerCaretPosition(),this.currentHTML=o))}triggerSelection(){let e=this.getSelection();(e.start!==this.currentSelection.start||e.end!==this.currentSelection.end)&&(this.currentSelection=e,this.emit("selection",e),this.triggerCaretPosition())}triggerCaretPosition(){let e=this.getCaretPosition();Ae(e,this.currentCaret)||(this.currentCaret=e,this.emit("caret",e))}handleKeyUp(e){let{key:o,shiftKey:n}=e;(o==="Enter"&&n===!0||o==="Backspace")&&this.triggerChange(),this.triggerSelection()}handleClick(){this.triggerSelection()}handleFocus(){this.isFocused||this.emit("focus"),this.triggerSelection(),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(e){let{key:o,ctrlKey:n,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(ha).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var n,s;let o=((n=e.clipboardData)==null?void 0:n.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",o=>this.handleKeyDown(o)),this.addEventListener("keyup",o=>this.handleKeyUp(o)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",o=>this.handlePaste(o)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},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()}),this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};var Oe=class extends Ne{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){let e=this.getSelection();return e?this.getText().slice(e.start,e.end):""}getCaretPosition(){return null}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let o=this.element.disabled,n=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>n.disconnect())}};var rg=/[.*+?^${}()|[\]\\]/g,ig=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function ag(t){return t.replace(rg,"\\$&")}function lg(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function cg(t){return t.search(ig)}function ya(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${ag(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function va(t){return t.replace(gt,'<mark data-type="placeholder">$1</mark>')}function Qt(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function pg(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 Us(t,e,o={}){if(e){let n=lg(e.toLowerCase(),t.toLowerCase()),s=Qt(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=cg(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(hi).length>3||e.length>30?pg(e.trim(),n):0;return`${`${i>0?"\u2026":""}${Qt(t.substring(i,n))}`}<strong>${s}</strong>`}return t}function zs(t){return/<\/?[a-z][\s\S]*>/i.test(t)}function gn(t){if(zs(t)){let o=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(t);return o?o[1]:""}return t}import{jsx as le,jsxs as js}from"react/jsx-runtime";var gg=({value:t,onUse:e,...o})=>{var d;let n=T(Ks),s=ug(),r=zs(t),i=v("EditSuggestionTextInput",Os),[a,l]=dg(null),c=Vs(null),p=((d=t.match(gt))==null?void 0:d.length)||0;return Zt(()=>{let u;return c.current&&(l(c.current),u=new Oe(c.current),u.on("change",({plainText:g})=>{s(Q.actions.userInput({text:g,selection:u.getSelection()}))}),u.on("keydown",g=>{s(Q.actions.registerKeyDown(Ko(g))),g.code==="Enter"&&g.shiftKey&&e(u.getText())}),u.on("paste",({pastedText:g,selectionText:m})=>{s(Q.actions.registerPaste({text:g,selectionText:m}))}),u.on("cut",({selectionText:g})=>{s(Q.actions.registerCut(g))})),()=>{s(Q.actions.reset()),u.dispose(),u.deactivate()}},[c]),Zt(()=>{t&&c.current&&(c.current.value=t)},[t,c]),Zt(()=>{c.current&&setTimeout(()=>{if(!c.current)return;let u=c.current.value.length;c.current.setSelectionRange(u,u),c.current.focus()},0)},[c]),r?le("div",{className:i.textInputWrapper,children:le(Sa,{className:i.textInput,tagName:"div",content:t})}):js("div",{className:i.textInputWrapper,children:[le("textarea",{...o,ref:c,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:t,onChange:()=>{}}),a&&le(mg,{inputElement:c.current,value:t}),js("div",{className:_a(i.alert,p===0?i.success:i.warning),children:[le("div",{className:i.alertText,children:n("placeholders",{placeholderSize:p})}),p===0?le(ga,{}):le(fa,{})]})]})},mg=({inputElement:t,value:e})=>{let o=v("EditSuggestionTextInput",Os),n=Vs(null),s=cn(t);return Zt(()=>{pn(t,s)},[s,t]),le(fg,{inputElement:t,children:js("div",{ref:n,className:_a(o.root,o.agentText),children:[le(Sa,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new vt("placeholders")],inputElement:t,boundaryRef:n}),le("br",{})]})})},fg=({inputElement:t,children:e})=>{let o=Vs(null);return Zt(()=>{if(!o.current)return()=>{};let[n,s]=xt(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),le("div",{ref:o,children:e})},xa=gg;import{useEffect as sm,useState as rm,useRef as im}from"react";import{useState as vg}from"react";import qs from"classnames";var Z={root:"_root_pc5uy_1",list:"_list_pc5uy_2",listWrapper:"_listWrapper_pc5uy_6",listHorizontal:"_listHorizontal_pc5uy_10",page:"_page_pc5uy_19",search:"_search_pc5uy_25",pageNav:"_pageNav_pc5uy_33",pageTitle:"_pageTitle_pc5uy_41",pageBackButton:"_pageBackButton_pc5uy_48",listHeading:"_listHeading_pc5uy_62",listItem:"_listItem_pc5uy_70",listItemContent:"_listItemContent_pc5uy_79",listItemText:"_listItemText_pc5uy_97",listItemDescription:"_listItemDescription_pc5uy_105",listItemActions:"_listItemActions_pc5uy_112",truncate:"_truncate_pc5uy_123",lineClamp:"_lineClamp_pc5uy_129",listItemTitle:"_listItemTitle_pc5uy_136",listItemAction:"_listItemAction_pc5uy_112",listItemPrimaryAction:"_listItemPrimaryAction_pc5uy_157",listItemSelected:"_listItemSelected_pc5uy_162",sources:"_sources_pc5uy_166",sourcesTitle:"_sourcesTitle_pc5uy_173",source:"_source_pc5uy_166",icon:"_icon_pc5uy_188",searchIcon:"_searchIcon_pc5uy_205",searchInputWrapper:"_searchInputWrapper_pc5uy_210",searchInput:"_searchInput_pc5uy_210",select:"_select_pc5uy_231",selectType:"_selectType_pc5uy_248",selectWrapper:"_selectWrapper_pc5uy_252",image:"_image_pc5uy_282",imageSrc:"_imageSrc_pc5uy_289",imageSrcHidden:"_imageSrcHidden_pc5uy_300",imageSrcStatus:"_imageSrcStatus_pc5uy_304",imageTitle:"_imageTitle_pc5uy_314",actions:"_actions_pc5uy_319",actionsWrapper:"_actionsWrapper_pc5uy_323",actionsBar:"_actionsBar_pc5uy_329",actionButton:"_actionButton_pc5uy_338",actionShortcut:"_actionShortcut_pc5uy_356",actionShortcutFixKerning:"_actionShortcutFixKerning_pc5uy_363"};var Qe={};j(Qe,{enUS:()=>hg,nlNL:()=>yg});var hg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},yg={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};import{jsx as Jt,jsxs as _g}from"react/jsx-runtime";var Sg=({src:t,title:e})=>{let o=v("CommandPalette",Z),[n,s]=vg("loading"),r=T(Qe);return _g("div",{className:o.image,children:[Jt("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:qs(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&Jt("span",{className:qs(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&Jt("span",{className:qs(o.imageSrc,o.imageSrcStatus),children:Jt(Ro,{})}),e&&Jt("span",{className:o.imageTitle,children:e})]})},ba=Sg;import xg from"react";import bg from"classnames";import{jsx as Ca,jsxs as Cg}from"react/jsx-runtime";function Ws({children:t,heading:e,orientation:o}){let n=v("CommandPalette",Z);return xg.Children.count(t)===0?null:Cg("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&Ca("h4",{className:n.listHeading,children:e}),Ca("div",{className:bg(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}import hn from"classnames";import Gs from"react";import{jsx as wg}from"react/jsx-runtime";var wa=Gs.createContext(void 0);function De(){let t=Gs.useContext(wa);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Ta=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=Gs.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return wg(wa.Provider,{value:i,children:t})};import Tg,{useState as Ea,useEffect as ka,useMemo as Eg,useRef as Ra,useCallback as kg,useContext as Rg}from"react";import Ig from"classnames";var $s={root:"_root_1oh4w_1",trigger:"_trigger_1oh4w_5",content:"_content_1oh4w_19",contentOpen:"_contentOpen_1oh4w_33",contentTop:"_contentTop_1oh4w_37",contentBottom:"_contentBottom_1oh4w_41",item:"_item_1oh4w_45"};import{jsx as mn,jsxs as Mg}from"react/jsx-runtime";var Pg=0,Ia=Tg.createContext(null),Ag=()=>{let t=Rg(Ia);if(!t)throw new Error("Invalid DropdownContext");return t},Pa=({trigger:t,children:e,position:o="bottom"})=>{let n=Eg(()=>++Pg,[]),s=Ra(null),r=Ra(null),i=v("Dropdown",$s),[a,l]=Ea(!1),[c,p]=Ea(o),d=g=>{g.preventDefault(),g.stopPropagation(),l(!a)},u=kg(([g])=>{!g.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return ka(()=>{let g=m=>{s.current&&!s.current.contains(m.target)&&l(!1)};return document.addEventListener("click",g),()=>{document.removeEventListener("click",g)}},[]),ka(()=>{if(!r.current&&!a)return()=>{};let g=new IntersectionObserver(u,{root:null,rootMargin:"0px",threshold:1});return r.current&&g.observe(r.current),()=>{r.current&&g.unobserve(r.current)}},[r,a]),mn(Ia.Provider,{value:{setIsOpen:l},children:Mg("div",{ref:s,className:i.root,children:[mn("button",{id:`dropdown-${n}`,"data-testid":"dropdown-trigger","aria-haspopup":"true","aria-expanded":a,"aria-label":"Dropdown trigger",type:"button",className:i.trigger,onClick:d,children:t}),mn("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:Ig(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function Lg({as:t,children:e,onClick:o,...n}){let s=t||"button",r=v("Dropdown",$s),{setIsOpen:i}=Ag(),a=l=>{i(!1),o(l),l.stopPropagation()};return mn(s,{type:"button",className:r.item,onClick:a,...n,children:e})}Pa.Item=Lg;var Xs=Pa;import{jsx as Aa}from"react/jsx-runtime";var La=t=>Aa("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:Aa("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 Ze={};j(Ze,{enUS:()=>Ng,nlNL:()=>Og});var Ng={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"}]},Og={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{jsx as Qs}from"react/jsx-runtime";var Dg="%0d%0a%0d%0a%0d%0a",Hg=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(Dg)}`},Bg=({suggestion:t,onFeedback:e})=>{let o=T(Ze),n=C("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:Qs(Xs,{trigger:Qs(La,{"data-testid":"feedback-dropdown-trigger"}),children:Qs(Xs.Item,{as:"a",href:Hg(n,t),onClick:e,children:o("giveFeedback")})})},fn=Bg;import{Interweave as Fg}from"interweave";import{jsx as He,jsxs as Zs}from"react/jsx-runtime";function Js({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onFeedback:s,onSourceClick:r,index:i,description:a,sources:l,styles:c,...p}){let{selected:d,setSelected:u,onChangeOpen:g}=De(),m=v("CommandPalette",Z);function f(h){n(h),t&&g(!1)}return Zs("div",{className:hn(m.listItem,d===i&&m.listItemSelected),children:[He("button",{onMouseEnter:()=>u(i),type:"button",className:hn("command-palette-list-item",m.listItemAction,m.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:f,...p,children:Zs("div",{className:m.listItemContent,children:[typeof o=="string"?He("p",{className:hn(m.listItemText,m.truncate,c==null?void 0:c.title),children:o}):o,a&&He(Fg,{tagName:"p",allowList:[],content:gn(a),className:hn(m.listItemDescription,c==null?void 0:c.description,e?m.lineClamp:m.truncate)})]})}),s&&d===i&&He("div",{className:m.listItemActions,children:He(fn,{suggestion:String(o),onFeedback:s})}),l&&Zs("div",{className:m.sources,children:[He("span",{className:m.sourcesTitle,children:"Sources"}),l.map(h=>h.url?He("a",{className:m.source,href:h.url,target:"_blank",title:h.url,rel:"noopener noreferrer",onClick:()=>r&&r(h),children:h.name},h.url):He("span",{className:m.source,children:h.name},h.name))]})]})}import{jsx as Ma,jsxs as Ys}from"react/jsx-runtime";function er({children:t,title:e,id:o,onDismiss:n}){let s=T(Qe),r=v("CommandPalette",Z),{page:i}=De();return i!==o?null:Ys("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&Ys("div",{className:r.pageNav,children:[Ys("button",{className:r.pageBackButton,type:"button",onClick:n,children:[Ma(rn,{}),s("back")]}),e&&Ma("h3",{className:r.pageTitle,children:e})]}),t]})}import{Fragment as Qg,useCallback as Zg,useEffect as Jg,useRef as Yg}from"react";var yn=()=>/Mac/i.test(navigator.platform);import{createAsyncThunk as Vg,createSlice as qg}from"@reduxjs/toolkit";var Kg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},E=Kg;import{createAsyncThunk as or,createSlice as zg}from"@reduxjs/toolkit";function Ug(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function A(t){return Array.isArray(t)?t.map(A):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Ug(o)]:A(t[o])}),{}):t}function tr(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function K(t){return Array.isArray(t)?t.map(K):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[tr(o)]:K(t[o])}),{}):t}var jg={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},eo=t=>{var e,o,n;return{timezone:((e=t.info.visitorInfo)==null?void 0:e.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((o=t.info.agentInfo)==null?void 0:o.agentNickname)||"",visitorName:((n=t.info.visitorInfo)==null?void 0:n.visitorName)||""}},Yt=or("info/setAgentInfo",async(t,e)=>{let{deepdeskAPI:o}=e.extra;if(!t.agentId&&!t.agentNickname)throw new Error("At least provide agentId or agentNickname");let n=await o.client.get("/apis/admin/session/me/",{version:null}),s={};return n.external_id||(s.external_id=t.agentId),n.nickname||(s.nickname=t.agentNickname),!s.external_id&&!s.nickname?A(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),A(n))}),nr=or("info/setAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.client.get("/apis/admin/session/me/",{version:null}),s={...typeof n.ui_config=="object"?n.ui_config:{},...t};return await o.client.patch("/apis/admin/session/me/",{ui_config:s}),s}),sr=or("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),Na=t=>t.info.agentInfo,Oa=zg({name:"info",initialState:jg,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Yt.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Yt.rejected,e=>{e.fetchState="error"}).addCase(Yt.fulfilled,(e,o)=>{e.fetchState="done",e.agentInfo={...e.agentInfo,...o.meta.arg,agentId:o.payload.externalId||o.meta.arg.agentId||"",agentNickname:o.payload.nickname||o.meta.arg.agentNickname||""}}).addCase(nr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(sr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(L,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Da}=Oa.actions,Ha=Oa.reducer;var vn={list:[],fetchState:"idle",isOpen:!1,page:"search"},Ba=t=>t.search.isOpen,Fa=t=>t.search.page,Ka=t=>t.search.list;function Ua(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Je=Vg("search/getAll",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r}=await o.search({profile:s,query:t.query,filters:{type:t.type},params:eo(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),za=qg({name:"search",initialState:vn,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=vn.fetchState,t.list=vn.list}},extraReducers:t=>{t.addCase(Je.pending,e=>{e.fetchState="loading"}).addCase(Je.rejected,(e,o)=>{e.fetchState="error",E.error(o.error)}).addCase(Je.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(L,()=>vn)}}),{resetSearch:Sn,setIsOpen:W,setPage:G}=za.actions,ja=za.reducer;var Wg=/(https?:\/\/[^\s]+)/,_n=t=>t.split(" ").find(e=>Wg.test(e));import Va from"classnames";import{jsx as $g,jsxs as Xg}from"react/jsx-runtime";var Gg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=v("CommandPalette",Z);return Xg("button",{type:"button",...n,onClick:t,className:Va(s.actionButton,n.className),children:[o,e&&e.map(r=>$g("span",{className:Va(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},bt=Gg;import{jsx as xn,jsxs as rr}from"react/jsx-runtime";var em=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=v("CommandPalette",Z),a=T(Qe),{selected:l,setSelected:c}=De(),p=r[l],d=p&&typeof p.text=="string"&&_n(p.text),u=Yg(null);function g(x){if(!u.current)return;let b=u.current.querySelectorAll(".command-palette-list-item"),_=0,I=0;x==="down"?(b.forEach(($,P)=>{P===l&&(_=P)}),I=_===b.length-1?0:_+1):x==="up"?(b.forEach(($,P)=>{P===l&&(_=P)}),I=_?_-1:b.length-1):c(0);let N=b[I];N&&typeof I=="number"&&(c(I),N.scrollIntoView&&N.scrollIntoView({behavior:"smooth",block:I?"center":"end"}))}function m(){if(!u.current)return;let x=u.current.querySelectorAll(".command-palette-list-item"),b=0;x.forEach((I,N)=>{N===l&&(b=N)});let _=x[b];_&&_.click()}let f=()=>{d&&window.open(d,"_blank")},h=()=>{p&&n(p,l)},w=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},y=Zg(x=>{if(x.key==="Enter"&&x.altKey&&d){f();return}if(x.key==="Enter"&&x.shiftKey){w();return}if(x.key==="ArrowDown"){x.preventDefault(),x.stopPropagation(),g("down");return}if(x.key==="ArrowUp"){x.preventDefault(),x.stopPropagation(),g("up");return}x.key==="Enter"&&l!==-1&&(x.preventDefault(),x.stopPropagation(),m())},[l]);return Jg(()=>(window.addEventListener("keyup",y),()=>{window.removeEventListener("keyup",y)}),[y]),rr("div",{className:i.actions,children:[xn("div",{className:i.actionsWrapper,ref:u,children:t}),rr("div",{className:i.actionsBar,children:[d&&xn(bt,{onClick:f,shortKeys:[yn()?8997:"ALT",8629],children:a("visitUrl")}),p&&rr(Qg,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&xn(bt,{onClick:w,shortKeys:[8679,8629],children:o}),xn(bt,{onClick:h,shortKeys:[8629],children:e})]})]})]})},Wa=em;import{forwardRef as om}from"react";import{jsx as Ga,jsxs as tm}from"react/jsx-runtime";var Ct=()=>tm("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[Ga("path",{d:"M0 0h24v24H0z",fill:"none"}),Ga("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 wt,jsxs as ir}from"react/jsx-runtime";function nm({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=v("CommandPalette",Z);return ir("div",{className:l.search,children:[wt("div",{className:l.searchIcon,children:wt(Ct,{})}),ir("div",{className:l.searchInputWrapper,children:[wt("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:c=>{t(c.currentTarget.value)},onFocus:c=>{c.currentTarget.select()},className:l.searchInput,placeholder:o,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&wt("div",{className:l.selectWrapper,children:ir("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:c=>e(c.target.value===n?void 0:c.target.value),value:i||n,children:[n&&wt("option",{children:n}),s.map(c=>wt("option",{value:c.value,children:c.label},c.value))]})})]})]})}var $a=om(nm);import{jsx as Xa,jsxs as am}from"react/jsx-runtime";function Ye({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:o="search",page:n,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:l,types:c,children:p,isOpen:d,search:u}){let[g,m]=rm(0),f=im(null),h=()=>{s&&s(o),i(void 0),r(""),a(!1)},w=()=>{var y;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(y=f.current)==null||y.focus();return}if(u.length>0){r("");return}a(!1)};return sm(()=>{m(0)},[u,n]),Xa(yt,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:w,onClose:h,children:am(Ta,{selected:g,setSelected:m,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&Xa($a,{ref:f,onChange:r,onChangeType:i,placeholder:t,value:u,selectedType:l,types:c,typePlaceholder:e}),p]})})}Ye.Page=er;Ye.List=Ws;Ye.Image=ba;Ye.ListItem=Js;Ye.ActionsBar=Wa;Ye.Button=bt;var k=Ye;import{jsx as be,jsxs as to}from"react/jsx-runtime";var pm=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=v("EditSuggestionForm",zi),l=lm(),c=T(Es),p=cm(m=>m.overlayInput.text);Qa(()=>{t&&(l(Q.actions.reset()),l(Q.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(Q.actions.commitSuggestion()))},[t]);let d=m=>{m.preventDefault(),u(p)},u=m=>{l(jo(m)),e(m)},g=m=>f=>{p!==i?window.confirm(c("warning"))&&m(f):m(f)};return Qa(()=>{n&&n(p!==i)},[n,t,p]),to("div",{className:a.root,children:[to("div",{className:a.content,children:[t.title&&be("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&be(vs,{labels:t.searchKeywords}),be(xa,{onUse:u,value:gn(p)})]}),to("form",{className:a.actions,onSubmit:d,children:[to("div",{children:[be("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&g(r),children:be(rn,{})}),be("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&g(s),children:be(ea,{})})]}),to("div",{className:a.primaryButtons,children:[be(k.Button,{onClick:g(o),shortKeys:["esc"],children:c("dismiss")}),be(k.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},bn=pm;import{createAction as gm,createAsyncThunk as el,createSlice as mm}from"@reduxjs/toolkit";var dm=["{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}"],um=new RegExp(dm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Za(t,e){let o=t.split(um),n=0,s=[];for(let r=0;r<o.length;r++){let i=o[r];if(s.push(i),r===o.length-1)break;if(e.indexOf(i)===-1)return t;let a=o[r+1],l=r===o.length-2;n+=i.length;let c=n;if(l){let d=a.charAt(0),u=0;do c=d?e.indexOf(d,c+1):-1,u+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&u>2)return t}else c=a&&a!==""?e.indexOf(a,n):-1;let p=c===-1?e.slice(n):e.slice(n,c);s.push(p),n=c}return s.join("")}function Ja(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var tl={suggestions:[],fetchState:"idle",isInitialRequest:null},Ya={default:tl},Cn=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},ol=t=>{let e=Object.keys(t.textSuggestions).map(o=>{var n;return(n=t.textSuggestions[o])==null?void 0:n.fetchState});return e.length===0?!0:e.every(o=>o!=="done")},Be=t=>t.textSuggestions,nl=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},wn=gm("textSuggestions/refresh"),ce=el("textSuggestions/recommendations",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,inlineSuggestions:i}=n.settings,a=ht(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,eo(n),t);if(t==="default"){let p=i?l.filter(nl(a)):l;e.dispatch(ge(p.slice(0,r)))}return l}),oo=el("textSuggestions/autocompletions",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,deanonymize:i,inlineSuggestions:a}=n.settings;if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getAutocompleteSuggestions(s,{...eo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(nl(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?Za(p.text,t):p.text}))),l=Ja(l,r),e.dispatch(ge(l)),l}),sl=mm({name:"textSuggestions",initialState:Ya,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:o}=e.payload;t[o].fetchState="done",t[o].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}},setSuggestionState(t,e){return e.payload}},extraReducers:t=>{t.addCase(ce.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||tl;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(ce.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(ce.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(oo.pending,e=>{e.default.fetchState="loading"}).addCase(oo.rejected,e=>{e.default.fetchState="error"}).addCase(oo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(L,()=>Ya)}}),{setTextSuggestions:rl,setSuggestionState:il}=sl.actions,al=sl.reducer;import{createSlice as fm}from"@reduxjs/toolkit";var ll={contentType:null,suggestion:null},cl=t=>t.activeSuggestion.suggestion,pl=t=>t.activeSuggestion.contentType,dl=fm({name:"activeSuggestion",initialState:ll,reducers:{setActiveSuggestion(t,e){let{contentType:o,suggestion:n}=e.payload;t.contentType=o,t.suggestion=n},resetActiveSuggestion(t){t.contentType=null,t.suggestion=null}},extraReducers:t=>{t.addCase(L,()=>ll)}}),{setActiveSuggestion:Ce,resetActiveSuggestion:ar}=dl.actions,ul=dl.reducer;var lr={};j(lr,{enUS:()=>hm,nlNL:()=>ym});var hm={warning:[{type:0,value:"Are you sure you want to discard the message?"}],editContentLabel:[{type:0,value:"Edit and view suggestion"}],overlayLabel:[{type:0,value:"Close dialog"}]},ym={warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}],editContentLabel:[{type:0,value:"Bewerk en bekijk suggestie"}],overlayLabel:[{type:0,value:"Sluit"}]};import{createSlice as vm}from"@reduxjs/toolkit";var Sm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Tn=({ui:t})=>t.overlayCollapsed;var gl=vm({name:"ui",initialState:Sm,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputHasFocus(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:no,setInputHasFocus:Tt,setOverlayCollapsed:Fe,setOpenOverlayWhenTyping:ml,setOverlayCollapsedUserOverwrite:fl}=gl.actions,hl=gl.reducer;import yl,{useContext as _m}from"react";import{jsx as xm}from"react/jsx-runtime";var vl=yl.createContext(null),et=({broadcastEvents:t,children:e})=>{let o=yl.useMemo(()=>t,[]);return xm(vl.Provider,{value:o,children:e})},se=()=>{let t=_m(vl);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import{createAsyncThunk as cr,createSlice as bm}from"@reduxjs/toolkit";var Cm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},oe=t=>t.auth.isLoggedIn,Sl=t=>t.auth.loginFetchState,_l=t=>t.auth.verifyFetchState,xl=t=>t.auth.showLoginOverlay,we=cr("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),bl=cr("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),so=cr("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),Cl=bm({name:"auth",initialState:Cm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(we.pending,e=>{e.loginFetchState="loading"}),t.addCase(we.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(we.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(so.pending,e=>{e.verifyFetchState="loading"}),t.addCase(so.rejected,e=>{e.verifyFetchState="error"}),t.addCase(so.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Et,setShowLoginOverlay:wl}=Cl.actions,Tl=Cl.reducer;var pr="SetActiveSuggestion",kt="ShowLoginOverlay",ro="UserLoggedIn",wm="UserLoggedOut",Te="ApplySuggestion",dr="ApplyImageSuggestion",Tm="ShowCommandPalette",Em=t=>({[pr]:e=>{t.dispatch(il(e.state)),t.dispatch(Ce({contentType:e.contentType,suggestion:e.suggestion}))},[Tm]:e=>{t.dispatch(W(e.isOpen)),e.page&&t.dispatch(G(e.page))},[kt]:e=>{t.dispatch(wl(e))},[ro]:()=>{t.dispatch(we())},[wm]:()=>{t.dispatch(we())},[dr]:e=>{t.dispatch(qo({suggestion:e.suggestion}))},[Te]:e=>{t.dispatch(ie({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(_e())}}),El=Em;import{jsx as kl}from"react/jsx-runtime";var Im=()=>{var m;let[t,e]=km(!1),o=ur(cl),n=ur(pl),s=ur(Be),r=Rm(),i=se(),a=T(lr),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(ar()),r(Tt(!0)),r(Q.actions.reset())},p=(f,h)=>{r(ar()),r(Tt(!0)),i.send(Te,{text:f,suggestion:{...h,source:`${h.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let d=(m=s[n])==null?void 0:m.suggestions.indexOf(o),u=d===0||d===null?void 0:()=>r(Ce({contentType:n,suggestion:s[n].suggestions[d-1]})),g=d===s[n].suggestions.length-1||d===null?void 0:()=>r(Ce({contentType:n,suggestion:s[n].suggestions[d+1]}));return kl(yt,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:kl(bn,{onTouched:e,onDismiss:c,onUse:f=>p(f,o),suggestion:o,onNext:g,onPrevious:u})})},Rl=Im;import{useSelector as Ml}from"react-redux";import mr from"classnames";import{useCallback as Al,useEffect as Om,useMemo as Dm,useState as fr}from"react";import{useDispatch as Hm,useSelector as Bm}from"react-redux";import Pm from"classnames";var Il={root:"_root_1ukx5_1"};import{jsx as Lm}from"react/jsx-runtime";var Am=({className:t,value:e,...o})=>{let n=v("TextInput",Il);return Lm("input",{className:Pm(t,n.root),type:"text",value:e,...o})},io=Am;var gr={};j(gr,{enUS:()=>Mm,nlNL:()=>Nm});var Mm={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"}]},Nm={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 Pl={root:"_root_1edpl_1",anchorButton:"_anchorButton_1edpl_5",errorMessage:"_errorMessage_1edpl_19",title:"_title_1edpl_25",subtitle:"_subtitle_1edpl_31",text:"_text_1edpl_38",input:"_input_1edpl_43",actions:"_actions_1edpl_48",button:"_button_1edpl_55",primaryButton:"_primaryButton_1edpl_70"};import{jsx as J,jsxs as En}from"react/jsx-runtime";var Fm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Km=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=T(gr),i=v("LoginTokenDialog",Pl),a=Bm(_l),l=Hm(),c=C("productName"),[p,d]=fr(t||""),[u,g]=fr(0),[m,f]=fr(""),h=Al(async b=>{b.preventDefault(),l(bl({email:p})),g(1)},[o,p]),w=()=>{f(""),g(0)},y=Al(async b=>{b.preventDefault();let _=Fm(b.target.elements.token.value);if(!_){f(r("verifyCodeError",{login:x}));return}l(so({token:_}))},[o]),x=Dm(()=>b=>J("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:b},"back-button"),[]);return Om(()=>{a==="error"&&f(r("verifyCodeError",{login:x})),a==="done"&&n()},[a]),J(yt,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:En("div",{className:i.root,children:[J("h1",{className:i.title,children:r("promptTitle",{productName:c})}),u===0&&En("form",{onSubmit:h,children:[J("h2",{className:i.subtitle,children:r("requestCodeTitle")}),J("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),J(io,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:b=>d(b.target.value)}),J("div",{className:i.actions,children:J("button",{type:"submit",className:mr(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),u===1&&En("form",{onSubmit:y,children:[J("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),J("p",{className:i.text,children:r("verifyCodeBody")}),J(io,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),m&&J("div",{className:i.errorMessage,children:m}),En("div",{className:i.actions,children:[J("button",{type:"button",className:mr(i.button),onClick:w,children:r("back")}),J("button",{type:"submit",className:mr(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},Ll=Km;import{jsx as zm}from"react/jsx-runtime";var Um=()=>{let t=Ml(xl),e=Ml(Na),o=C("adminUrl"),n=se(),s=()=>n.send(kt,!1),r=()=>{n.send(kt,!1),n.send(ro)};return zm(Ll,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},Nl=Um;import zf from"lodash.debounce";import{useCallback as Ln,useEffect as br,useState as go}from"react";import{useDispatch as jf,useSelector as At}from"react-redux";import{createAsyncThunk as jm,createSlice as Vm}from"@reduxjs/toolkit";var qm={data:null,fetchState:"idle"},Ol=t=>t.contentTypes.data,ao=jm("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Wm=Vm({name:"contentTypes",initialState:qm,reducers:{},extraReducers:t=>{t.addCase(ao.pending,e=>{e.fetchState="loading"}).addCase(ao.rejected,e=>{e.fetchState="error"}).addCase(ao.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Dl=Wm.reducer;function lo(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 Gm}from"react";function Hl(t,e){Gm(()=>{let o=n=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?n.metaKey:n.ctrlKey)&&n.key===t&&(n.preventDefault(),n.stopPropagation(),e())};return document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o)}},[])}import{useEffect as Ul,useRef as ef}from"react";import{useSelector as tf,useDispatch as of}from"react-redux";import{createAsyncThunk as $m,createSlice as Xm}from"@reduxjs/toolkit";var Bl={data:null,fetchState:"idle"},kn=t=>{var r;let e=[],{visitorName:o}=t.info.visitorInfo??{},{agentName:n,agentNickname:s}=t.info.agentInfo??{};return n&&n!==o&&e.push(n),s&&s!==o&&e.push(s),((r=t.entities.data)==null?void 0:r.filter(i=>!e.includes(i.text)))??null},pe=$m("entities/getEntities",async(t,e)=>{let{deepdeskAPI:o,dynamicThunkObject:n}=e.extra;if(!n.conversationQuery)return Promise.resolve([]);let s=n.conversationQuery,r=await s();return r.length===0?Promise.resolve([]):o.getEntities(r)}),Qm=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Zm=Xm({name:"entities",initialState:Bl,reducers:{},extraReducers:t=>{t.addCase(pe.pending,e=>{e.fetchState="loading"}).addCase(pe.rejected,e=>{e.fetchState="error"}).addCase(pe.fulfilled,(e,o)=>{e.fetchState="done",e.data=Qm(e.data?[...e.data,...o.payload]:o.payload)}).addCase(L,()=>Bl)}}),Fl=Zm.reducer;var hr={};j(hr,{enUS:()=>Jm,nlNL:()=>Ym});var Jm={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Ym={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Kl={root:"_root_17kae_1",empty:"_empty_17kae_5"};import{jsx as Rn,jsxs as sf}from"react/jsx-runtime";var nf=({onCopy:t,onUse:e})=>{let o=ef(null),n=v("EntitiesList",Kl),s=T(hr),r=tf(kn),i=of();return Ul(()=>{i(pe())},[]),Ul(()=>{o.current&&o.current.focus()},[o]),sf("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&Rn(k.ActionsBar,{primaryLabel:s("copy"),secondaryLabel:s("use"),onPrimary:(a,l)=>t(r[l]),onSecondary:(a,l)=>e(r[l]),list:r.map(a=>({text:a.text,type:a.label,primaryAction:"copy",secondaryAction:"use"})),children:Rn(k.List,{children:r.map((a,l)=>Rn(k.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&Rn("p",{className:n.empty,children:s("noResults")})]})},zl=nf;import{Fragment as df,useEffect as In,useRef as uf,useState as gf}from"react";import{useSelector as $l,useDispatch as mf}from"react-redux";import{createAsyncThunk as rf,createSlice as af}from"@reduxjs/toolkit";var jl={data:null,fetchState:"idle"},Vl=t=>t.summary.data,ql=t=>t.summary.fetchState==="error",Ee=rf("summary/getSummary",async(t,e)=>{let o=e.getState().profile.data;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:n,dynamicThunkObject:s}=e.extra;if(!s.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let r=s.conversationQuery,i=await r();if(i.length===0)return Promise.reject(new Error("No messages are included"));let a=await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return a?{summary:a}:Promise.reject(new Error("Summary is not provided"))}),lf=af({name:"summary",initialState:jl,reducers:{},extraReducers:t=>{t.addCase(Ee.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(Ee.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(Ee.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(L,()=>jl)}}),Wl=lf.reducer;var yr={};j(yr,{enUS:()=>cf,nlNL:()=>pf});var cf={copy:[{type:0,value:"Copy"}],error:[{type:0,value:"Could not generate a summary"}],loading:[{type:0,value:"Generating summary, this may take a few moments."}]},pf={copy:[{type:0,value:"Kopieer"}],error:[{type:0,value:"Kon helaas geen samenvatting genereren."}],loading:[{type:0,value:"Samenvatting wordt gemaakt, dit kan even duren."}]};var Gl={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};import{jsx as Rt,jsxs as hf}from"react/jsx-runtime";var ff=({onCopy:t})=>{let e=uf(null),o=v("SummaryForm",Gl),[n,s]=gf(""),r=T(yr),i=$l(Vl),a=$l(ql),l=mf(),c=()=>{l(V({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let d=document.getSelection();d&&l(V({name:"summary copied to clipboard",data:{originalText:i,finalText:d==null?void 0:d.toString()},options:{includeConversationData:!0}}))};return In(()=>{l(Ee())},[]),In(()=>{s(i||"")},[i]),In(()=>{e.current&&i&&e.current.focus()},[e,i]),In(()=>{let d=u=>{u.key==="Enter"&&u.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[n]),Rt("div",{className:o.root,tabIndex:-1,children:a?Rt("p",{className:o.error,children:r("error")}):hf(df,{children:[Rt("div",{className:o.main,children:Rt("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:d=>s(d.target.value)})}),Rt("div",{className:o.actions,children:Rt(k.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},Xl=ff;var co={};j(co,{enUS:()=>yf,nlNL:()=>vf});var yf={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link 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"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],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?"}]},vf={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:"Link 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"}],summaryClipboard:[{type:0,value:"Gesprek samenvatten"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],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 Pf,{useEffect as _r,useRef as Af}from"react";import{useDispatch as Lf,useSelector as sc}from"react-redux";var vr={};j(vr,{enUS:()=>Sf,nlNL:()=>_f});var Sf={use:[{type:0,value:"Use"}],loading:[{type:0,value:"Loading..."}],error:[{type:0,value:"Something went wrong, please try again later."}],anotherQuestion:[{type:0,value:"Send a message..."}],reset:[{type:0,value:"Reset conversation"}]},_f={use:[{type:0,value:"Gebruik"}],loading:[{type:0,value:"Laden..."}],error:[{type:0,value:"Er ging iets mis, probeer het later opnieuw."}],anotherQuestion:[{type:0,value:"Stuur een bericht..."}],reset:[{type:0,value:"Reset gesprek"}]};var Ql={root:"_root_1g4pq_1",title:"_title_1g4pq_9",empty:"_empty_1g4pq_20",status:"_status_1g4pq_24",form:"_form_1g4pq_30",input:"_input_1g4pq_43",submit:"_submit_1g4pq_55",question:"_question_1g4pq_63",answer:"_answer_1g4pq_67",alignRight:"_alignRight_1g4pq_73"};import{createAction as Tf,createAsyncThunk as Ef,createSlice as kf}from"@reduxjs/toolkit";import{createAsyncThunk as xf,createSlice as bf}from"@reduxjs/toolkit";var Cf={data:null,fetchState:"idle"},Zl=t=>{var e;return(e=t.knowledgeAssistant)==null?void 0:e.data},po=xf("knowledgeAssistant/getKnoeledgeAssistant",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");let r=(i=n.profile.data)==null?void 0:i.knowledgeAssistant;return r?o.getKnowledgeAssistant(r):null}),wf=bf({name:"knowledgeAssistant",initialState:Cf,reducers:{},extraReducers:t=>{t.addCase(po.pending,e=>{e.fetchState="loading"}).addCase(po.rejected,e=>{e.fetchState="error"}).addCase(po.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Jl=wf.reducer;var Sr={data:[],fetchState:"idle"},Yl=t=>{var e;return(e=t.answer)==null?void 0:e.data},ec=t=>t.answer.fetchState,Pt=Tf("answer/resetKnowledgeSearch"),It=Ef("answer/getAnswer",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=Zl(e.getState());if(!s)throw new Error("KnowledgeAssistant is not defined");let r=await o.knowledgeAssist({promptInstruction:s.prompt,question:t},n,s.code);return{question:t,answer:r}}),Rf=kf({name:"answer",initialState:Sr,reducers:{},extraReducers:t=>{t.addCase(It.pending,e=>{e.fetchState="loading"}).addCase(It.rejected,e=>{e.fetchState="error"}).addCase(It.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(L,()=>Sr).addCase(Pt,()=>Sr)}}),tc=Rf.reducer;import{jsx as oc,jsxs as If}from"react/jsx-runtime";var nc=()=>If("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[oc("title",{id:"paperPlaneTitle",children:"PaperPlane"}),oc("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});import{jsx as ke,jsxs as xr}from"react/jsx-runtime";var Mf=({onUse:t,onResetQuestion:e,question:o})=>{let[n,s]=Pf.useState(""),{setSelected:r}=De(),i=Af(null),a=v("EntitiesList",Ql),l=T(vr),c=Lf(),p=sc(Yl),d=sc(ec),u=async m=>{m.preventDefault(),m.stopPropagation(),n!==""&&c(It(n))},g=(m,f)=>{c(V({name:"knowledge assist source viewed",data:{question:f,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return _r(()=>{var m;o&&d==="idle"?c(It(o)):(m=i.current)==null||m.focus()},[i,d]),_r(()=>{d==="done"&&(c(V({name:"knowledge assist question answered",data:{question:n||o,sources:p[p.length-1].answer.sources,answer:p[p.length-1].answer.answer,isFollowUpQuestion:p.length>1},options:{includeConversationData:!0}})),r(p.length-1),s(""))},[d,p]),_r(()=>{i.current&&i.current.scrollIntoView({behavior:"smooth"})},[i,p]),xr("div",{className:a.root,children:[p.length>0&&ke("div",{className:a.alignRight,children:ke(k.Button,{onClick:e,children:l("reset")})}),xr(k.ActionsBar,{list:p.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:l("use"),onPrimary:m=>t(m.text),children:[p.map(({question:m,answer:f},h)=>ke(k.List,{children:ke(k.ListItem,{"data-testid":"knowledge-search-answer",index:h,description:f.answer,closeOnSelect:!0,onClick:()=>t(f.answer),onSourceClick:w=>g(w,m),sources:f.sources,styles:{title:a.question,description:a.answer},children:m})},`${f.answer}_${h}`)),d==="loading"&&ke("p",{className:a.status,children:l("loading")}),d==="error"&&ke("p",{className:a.status,children:l("error")}),xr("form",{className:a.form,onSubmit:u,children:[ke("input",{ref:i,placeholder:l("anotherQuestion"),className:a.input,type:"text",value:n,onFocus:()=>{r(-1)},onChange:m=>{r(-1),s(m.target.value)}}),ke("button",{type:"submit",className:a.submit,children:ke(nc,{})})]})]})]})},rc=Mf;import{createAsyncThunk as Nf,createSlice as Of}from"@reduxjs/toolkit";var Df={data:null,fetchState:"idle"},Ke=t=>t.profile.data,Pn=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],uo=Nf("profile/getProfile",async(t,e)=>{var r;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");return((r=n.profile.data)==null?void 0:r.code)===s.profileCode?n.profile.data:o.getProfile(s.profileCode)}),Hf=Of({name:"profile",initialState:Df,reducers:{},extraReducers:t=>{t.addCase(uo.pending,e=>{e.fetchState="loading"}).addCase(uo.rejected,e=>{e.fetchState="error"}).addCase(uo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),ic=Hf.reducer;import{useEffect as Bf}from"react";import{useDispatch as Ff}from"react-redux";import{useSelector as ac}from"react-redux";import{jsx as An,jsxs as Uf}from"react/jsx-runtime";var Kf=({commands:t,onClick:e,onEdit:o})=>{var p,d,u;let n=Ff(),s=T(co),r=ac(Ke),i=ac(Be),a=((u=(d=(p=r==null?void 0:r.uiConfig)==null?void 0:p.search)==null?void 0:d.initialTypes)==null?void 0:u.filter(({isActive:g})=>g))||[],l=0,c=a.map(({type:g})=>{var m;return(m=i[g])==null?void 0:m.suggestions.map(f=>({text:f.text||f.url||f.message,type:g}))}).flat(1);return Bf(()=>{a.forEach(({type:g})=>{(!i[g]||i[g].suggestions.length===0)&&n(ce(g))})},[]),Uf(k.ActionsBar,{list:[...t.map(g=>({text:g.label,type:"command"})),...c],primaryLabel:s("use"),secondaryLabel:s("preview"),onPrimary:({text:g},m)=>e(g,c[m]),onSecondary:(g,m)=>{o(c[m],i[c[m].type].suggestions)},children:[t.length>0&&An(k.List,{heading:s("commands"),children:t.map((g,m)=>An(k.ListItem,{index:m,closeOnSelect:!1,onClick:g.onClick,children:g.label},g.label))}),a.map(({type:g,title:m})=>{var f;return An(k.List,{heading:m,orientation:"vertical",children:(f=i[g])==null?void 0:f.suggestions.map(h=>(l++,An(k.ListItem,{index:l+t.length-1,closeOnSelect:!1,description:h.text,onClick:()=>e(h.text,h),"data-testid":"search-overlay-suggestion",children:h.title},`${h.id}-${h.text}`)))},g)})]})},lc=Kf;import{jsx as Y,jsxs as Cr}from"react/jsx-runtime";var Vf=200,qf=5,Wf=4,Gf=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),cc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),$f=()=>{let t=jf(),e=se(),o=T(co),[n,s]=go(!1),[r,i]=go(""),a=At(Fa),l=At(Ke),[c,p]=go(null),[d,u]=go([]),[g,m]=go(),f=At(oe),h=C("showSearch"),w=C("showEntitiesCommand"),y=C("showSummaryCommand"),x=C("showKnowledgeSearch"),b=C("showImageSearch"),_=C("searchTriggerKey"),I=At(Ol),N=At(Ka),$=At(Ba),P=S=>cs(N.filter(O=>O.type===S.toUpperCase()),S),X=[{value:"PERSONAL",label:o("personalSuggestions"),list:P("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:P("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:P("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:P("IMAGE"),listOrientation:"horizontal",shouldShow:b}].filter(S=>S.shouldShow),R=[{label:o("entitiesClipboard"),onClick:()=>t(G("entities")),shouldShow:w&&cc(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(G("summary")),shouldShow:y&&cc(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(G("knowledgeAssist")),shouldShow:x}].filter(S=>S.shouldShow),B=(I==null?void 0:I.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:P(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],at=Ln(zf((S,O)=>{t(Je({query:S,type:O,tags:["search-overlay"]}))},Vf),[]),Kt=Gf([...B,...X]),Ut=Ln((S,O)=>{t(G("edit")),p({...S,searchTerm:void 0}),u(O)},[t,c,B]),wo=Ln((S,O)=>{switch(O.type){case"IMAGE":e.send(dr,{suggestion:O});break;default:e.send(Te,{text:S,suggestion:O})}t(W(!1))},[t]),fd=S=>{lo(S.text),t(V({name:"entity copied",data:{entity:S,type:"copy"}})),t(W(!1))},hd=Ln(S=>{t(V({name:"suggestion feedback",data:{text:S.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),yd=S=>{e.send(Te,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(V({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(G("search")),t(Pt()),t(W(!1))},vd=S=>{lo(S),t(W(!1))},Sd=S=>{e.send(Te,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(W(!1))},_d=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),xd=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function cs(S,O){return S.slice(0,g?10:O.toLowerCase()==="image"?Wf:qf)}function li(S,O,de){return O.reduce((To,Eo)=>de&&g===de?Eo.length+To:cs(Eo,de).length+To,S)}function lt(S){return O=>{n?window.confirm(o("warning"))&&(S(O),s(!1)):S(O)}}return br(()=>{r?at(r,g):t(Sn())},[r,g]),br(()=>{a==="search"&&t(Pt())},[a]),br(()=>{f&&t(ao())},[f]),Hl(_,()=>t(W(!0))),!h||!l?null:Cr(k,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:lt(S=>t(W(S))),onChangeType:S=>m(S),onChangePage:lt(S=>t(G(S))),selectedType:g,search:r,page:a,isOpen:$,types:[...B,...X],children:[Cr(k.Page,{id:"search",children:[r.length===0&&Y(lc,{commands:R,onClick:wo,onEdit:Ut}),r.length>0&&Cr(k.ActionsBar,{list:[...R.map(S=>({text:S.label,type:"command"})),...Kt.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},O)=>wo(S,Kt[O]),onSecondary:(S,O)=>{let de=Kt[O-R.length];!de||!de.type||Ut(de,P(de.type))},children:[R.length>0&&Y(k.List,{heading:o("commands"),children:R.map((S,O)=>Y(k.ListItem,{index:li(O,[],"commands"),closeOnSelect:!1,onClick:S.onClick,children:S.label},S.label))}),[...B,...X].map(({value:S,label:O,list:de,lineClamp:To,listOrientation:Eo},bd)=>Y(k.List,{heading:O,orientation:Eo==="horizontal"?"horizontal":"vertical",children:cs(de,S).map((ne,Cd)=>Y(k.ListItem,{index:li(R.length+Cd,[...B,...X].slice(0,bd).map(({list:wd})=>wd),S),closeOnSelect:!1,lineClamp:To,onClick:()=>wo(ne.text,ne),description:S!=="IMAGE"?ne.title&&ne.text:void 0,onFeedback:S!=="IMAGE"?()=>hd(ne):void 0,children:S==="IMAGE"?Y(k.Image,{title:ne.title||ne.text,src:ne.image}):ne.title||ne.text},`${ne.id}-${ne.text}`))},S))]})]}),Y(k.Page,{id:"edit",onDismiss:lt(()=>{t(G("search")),p(null)}),children:c&&Y(bn,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(G("search")),p(null),u([])},onNext:xd,onPrevious:_d,onUse:S=>{t(G("search")),wo(S,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(W(!1)),u([]),p(null)}})}),Y(k.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:lt(()=>{t(G("search"))}),children:Y(zl,{onUse:Sd,onCopy:fd})}),Y(k.Page,{id:"summary",title:o("summaryTitle"),onDismiss:lt(()=>{t(G("search"))}),children:Y(Xl,{onCopy:vd})}),Y(k.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:lt(()=>{t(Pt()),t(G("search"))}),children:Y(rc,{question:r,onUse:yd,onResetQuestion:()=>{t(Pt()),i("")}})})]})},pc=$f;import{jsx as wr,jsxs as Zf}from"react/jsx-runtime";var Qf=()=>{let t=C("showSearch"),e=C("isEmbedded");return Zf(Xf,{children:[t&&wr(pc,{}),wr(Rl,{}),e&&wr(Nl,{})]})},dc=Qf;import{useEffect as mh,useRef as fh}from"react";import{connect as hh,useDispatch as yh,useSelector as On}from"react-redux";function Lt(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:o,showSuggestionsAfterPattern:n}=t.settings,{text:s,selection:r}=t.input.userCommitted;return r.start!==r.end?!1:r.end>=s.length?!0:e?o&&new RegExp(o).test(s.substring(r.end))||n&&new RegExp(n).test(s.substring(0,r.end))?!0:o===!1&&n===!1:!1}import{Fragment as dh,useMemo as uh}from"react";import{Interweave as eh}from"interweave";import{useEffect as th,useMemo as oh,useRef as nh}from"react";import{useDispatch as sh,useSelector as rh}from"react-redux";import{useEffect as Jf}from"react";function uc(t,e,o){Jf(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var gc={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};import{jsx as Mn,jsxs as ph}from"react/jsx-runtime";var ih=["search","personal-collection-search","search-autocomplete"];function ah(t,e,o,n={}){let s="";return ih.includes(e)?s=ya(Us(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=Us(t,o,n),n.placeholders===!0&&(s=va(s)),s}var lh=()=>{},ch=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=C("inlineSuggestions"),r=rh(ht),i=sh(),a=v("TextSuggestion",gc),l=nh(null);th(()=>{let p=setTimeout(()=>{i(Pi({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),uc(l,"click",()=>{i(Me(t)),i(ie({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=oh(()=>ah(o.text,o.source,r,{stripAgentPart:s,placeholders:!0,searchKeywords:o.searchKeywords}),[s,o.text,o.source,r,o.searchKeywords]);return o.source==="gpt"&&!s?null:ph("div",{className:a.root,onMouseEnter:()=>i(Me(t)),children:[Mn(D,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:lh,children:Mn(eh,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&Mn("div",{className:a.actions,children:Mn(fn,{onFeedback:()=>n(o),suggestion:o.text})})]})},mc=ch;import{jsx as fc}from"react/jsx-runtime";var gh=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=uh(()=>{let r=e.map((i,a)=>fc(mc,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return fc(dh,{children:s})},Nn=gh;var hc={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};import{jsx as Dn}from"react/jsx-runtime";var vh=({textSuggestions:t,selectedIndex:e})=>{let o=fh(null),n=v("InlineSuggestionsOverlay",hc),s=On(Lt),r=yh(),i=On(oe),a=On(ft),l=On(Tn),c=C("showTextSuggestions");return St(()=>{r(Fe({collapse:!0,skipWhenInputFocus:!0}))}),mh(()=>{let p=o.current;if(!p||!p.parentElement)return;p.parentElement.style.left="0px";let d=p.getBoundingClientRect();p.parentElement.style.left=`${Math.min(window.innerWidth-4-d.right,0)}px`}),l||!s||!c||t.length===0||i!==!0||a===!1?null:Dn("div",{className:n.root,"data-variant":"inline",children:Dn("div",{ref:o,className:n.paper,children:Dn(re,{children:Dn(Nn,{suggestions:t,selectedIndex:e})})})})},Sh=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),yc=hh(Sh)(vh);import Ir from"classnames";import{useEffect as Ah,useRef as Lh,useState as Mh}from"react";import{connect as Nh,useDispatch as Oh,useSelector as mo}from"react-redux";import{useState as _h}from"react";function vc(t,e){let[o,n]=_h(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return E.error(r),e}});return[o,r=>{try{let i=r instanceof Function?r(o):r;n(i),typeof window<"u"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){E.error(i)}}]}import Ch from"classnames";import{Fragment as wh,useCallback as Er,useMemo as _c}from"react";var Tr={};j(Tr,{enUS:()=>xh,nlNL:()=>bh});var xh={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"}]}]},bh={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 Sc={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};import{jsx as Hn,jsxs as xc}from"react/jsx-runtime";var kr=(t,e,o)=>n=>Hn("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),Th=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=T(Tr),i=se(),a=v("Login",Sc),l=C("productName"),c=Er(h=>{h.preventDefault(),n&&n(parseInt(h.target.value,10))},[]),p=Er(h=>{h.preventDefault(),i.send(kt,!0)},[e]),d=_c(()=>h=>Hn("a",{onClick:y=>{y.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[e]),u=Er(h=>Hn("button",{type:"button",className:a.anchorButton,onClick:p,children:h},"prompt"),[p]),{min:g,hour:m,day:f}=_c(()=>({min:kr(a,60*10,c),hour:kr(a,60*60,c),day:kr(a,60*60*12,c)}),[]);return xc("div",{className:Ch(t,a.root),children:[r("loginPlease",{login:o?u:d,productName:l}),n&&xc(wh,{children:[Hn("br",{}),r("snooze",{min:g,hour:m,day:f})]})]})},Bn=Th;import{useDispatch as Eh}from"react-redux";var bc={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};import{jsx as Cc,jsxs as Rh}from"react/jsx-runtime";var kh=({title:t})=>{let e=v("SearchTrigger",bc),o=Eh();return Rh("button",{type:"button",className:e.root,onClick:()=>o(W(!0)),children:[Cc(Ct,{}),Cc("span",{className:e.text,children:t})]})},wc=kh;var Rr={};j(Rr,{enUS:()=>Ih,nlNL:()=>Ph});var Ih={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"}]},Ph={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"}]};var Tc={root:"_root_onpov_1",isInline:"_isInline_onpov_14",toggleButton:"_toggleButton_onpov_21",toggleButtonWrapper:"_toggleButtonWrapper_onpov_25",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_onpov_32",isCollapsed:"_isCollapsed_onpov_36",collapsible:"_collapsible_onpov_36",hints:"_hints_onpov_44",hintsHidden:"_hintsHidden_onpov_51",triggers:"_triggers_onpov_56",triggersRight:"_triggersRight_onpov_71"};import{jsx as z,jsxs as fo}from"react/jsx-runtime";var Dh=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=v("SuggestionsOverlay",Tc),s=T(Rr),r=mo(Lt),i=Ti(),a=Oh(),l=Lh(null),c=C("searchTriggerKey"),p=C("productName"),d=mo(Tn),u=mo(oe),g=mo(ft),[m,f]=Mh(null),h=C("showSearch"),w=C("showTextSuggestions"),y=C("adminUrl"),x=C("isEmbedded"),[b,_]=vc("dd-snooze-until-ms",0),I=d||b>Date.now(),N=mo(B=>B.input.text),$=t.filter(B=>B.source!=="gpt").length,P=()=>{I&&_(0),a(fl(!I))},X=B=>{a(V({name:"suggestion feedback",data:{text:B.text,source:"overlay",context:N},options:{includeConversationData:!0}}))},R=B=>{let at=Date.now()+B*1e3;_(at),E.info(`Snooze until: ${new Date(at)}`),a(Fe({collapse:!0}))};return Ah(()=>{$===0&&f(null)},[t,$]),St(()=>{a(Fe({collapse:!0,skipWhenInputFocus:!0}))}),u===null||g===!1?null:u===!1?fo("div",{ref:l,className:Ir(n.root,{[n.isCollapsed]:I}),children:[!I&&fo("div",{className:n.triggers,children:[z("div",{style:{flex:1}}),z("div",{className:n.triggersRight,children:z(ut,{className:n.toggleButton,title:s("collapse"),onClick:P,isCollapsed:!1})})]}),z("div",{className:n.toggleButtonWrapper,children:z(ut,{className:n.toggleButton,title:s("open",{productName:p}),onClick:P,isCollapsed:!0})}),z("div",{className:n.collapsible,children:z(Bn,{loginUrl:y,isEmbedded:x,onLogIn:o,onSnooze:R})})]}):!i||!r?null:fo("div",{ref:l,className:Ir(n.root,{[n.isCollapsed]:I}),children:[!I&&fo("div",{className:n.triggers,children:[z("div",{style:{flex:1},children:h&&z("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(s(yn()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>f(null),children:z(wc,{title:s("search")})})}),fo("div",{className:n.triggersRight,onFocus:()=>{},children:[z("div",{className:Ir(!m&&n.hintsHidden,n.hints),children:m}),z(ut,{className:n.toggleButton,title:s("collapse"),onClick:P,isCollapsed:!1})]})]}),z("div",{className:n.toggleButtonWrapper,children:z(ut,{className:n.toggleButton,title:s("open",{productName:p}),onClick:P,isCollapsed:!0})}),$>0&&w&&z("div",{className:n.collapsible,onFocus:()=>{},children:z(re,{children:z(Nn,{onFeedback:X,suggestions:t,selectedIndex:e,reverse:!0})})})]})},Hh=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Ec=Nh(Hh)(Dh);import{Provider as Bh}from"react-redux";import{jsx as Fn}from"react/jsx-runtime";var Fh=({children:t})=>{let o=C("locale").replace("-","");return Fn(Ns.Provider,{value:o,children:t})},Kh=({store:t,customStyles:e={},children:o})=>Fn(Bh,{store:t,children:Fn(Fh,{children:Fn(zt.Provider,{value:e,children:o})})}),tt=Kh;import Kr from"classnames";import{Interweave as ky}from"interweave";import{useCallback as Ry,useEffect as Iy,useMemo as Wc,useRef as Py}from"react";import{connect as Ay}from"react-redux";import{cloneElement as Uh}from"react";var zh=["div","span","mark","strong","b","i","u","em"];function Pr(t,e,o=0){var r;let n=t[t.length-1],s=typeof n=="object"&&n!==null?(r=n.props)==null?void 0:r.tagName:void 0;if(s==="br")return t.pop(),[...t,...e,n];if(zh.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),Uh(n,{children:Pr(i,e,o+1)})]}return[...t,...e]}function Ue(t){return t.tagName.toLowerCase()==="textarea"}var kc={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};import ry from"classnames";import{Matcher as iy}from"interweave";import{useEffect as ay,useMemo as ly}from"react";function Rc(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Kn(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function Ic(t){return t!=null}import Nc from"classnames";import{createRef as Jh,useCallback as Lr,useMemo as Yh,useRef as ey,useState as ty}from"react";import{useState as jh,useLayoutEffect as Vh}from"react";var qh=["bottom","height","left","right","top","width"],Wh=(t={},e={})=>qh.some(o=>t[o]!==e[o]),Re=new Map,Pc,Ac=()=>{let t=[],e=[];Re.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Wh(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Re.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),Pc=window.requestAnimationFrame(Ac)};function Gh(t,e){return{observe(){let o=Re.size===0;if(Re.has(t)){let n=Re.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Re.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&Ac()},unobserve(){let o=Re.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Re.delete(t),Re.size||cancelAnimationFrame(Pc)}}}}function Ar(t){let[e,o]=jh(null);return Vh(()=>{if(!t.current)return;let n=Gh(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}import{useContext as $h,useLayoutEffect as Xh,useState as Qh}from"react";import{createPortal as Zh}from"react-dom";var Lc={root:"_root_1jq08_1"};var Mc=({children:t})=>{let[e,o]=Qh(null),n=$h(zt);return Xh(()=>{let s=document.createElement("div");return Xe(s),s.classList.add(Lc.root),n!=null&&n.portalRootNode&&s.classList.add(n==null?void 0:n.portalRootNode),document.body.appendChild(s),o(s),()=>{s.isConnected&&document.body.removeChild(s)}},[]),e?Zh(t,e):null};var he={ref:"_ref_1rcyi_1",root:"_root_1rcyi_7",positionAbove:"_positionAbove_1rcyi_13",positionBelow:"_positionBelow_1rcyi_17",positionLeft:"_positionLeft_1rcyi_21",positionRight:"_positionRight_1rcyi_25",alignStart:"_alignStart_1rcyi_29",alignCenter:"_alignCenter_1rcyi_34",alignEnd:"_alignEnd_1rcyi_40"};import{jsx as Mr}from"react/jsx-runtime";var Un=(t=!1)=>{let[e,o]=ty(t),n=Lr(()=>o(!0),[]),s=Lr(()=>o(!1),[]),r=Lr(()=>o(a=>!a),[]),i=ey(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function Nr(t,e=null,o=0){if(!t)return{display:"none"};let n=e?t.top-e.top<0||t.top<e.top-o?e.top-o:t.top+t.height>e.top+e.height+o?e.top+e.height+o-t.height:t.top:t.top,s=e?t.left<e.left-o?e.left-o:t.left+t.width>e.left+e.width+o?e.left+e.width+o-t.width:t.left:t.left;return{top:n,left:s,height:t.height,width:t.width}}var zn=({className:t,triggerRef:e,boundaryRef:o=Jh(),position:n="above",align:s="center",children:r,toStyle:i=Nr,...a})=>{let l=Ar(e),c=Ar(o),p=Yh(()=>i(l,c,0),[l,c]);return Mr(Mc,{children:Mr("div",{className:Nc(he.ref,{[he.positionAbove]:n==="above",[he.positionBelow]:n==="below",[he.positionLeft]:n==="left",[he.positionRight]:n==="right",[he.alignStart]:s==="start",[he.alignCenter]:s==="center",[he.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:Mr("div",{className:Nc(t,he.root),children:r})})})};import oy from"classnames";import{forwardRef as ny,useRef as sy}from"react";import{jsx as Oc}from"react/jsx-runtime";var jn=ny(({className:t,children:e,...o},n)=>{let s=sy(null),r=v("TabCompletion",xe);return Oc("div",{ref:Kn([s,n]),className:oy(t,r.popoverContentContainer),...o,children:Oc("div",{className:r.popoverContent,children:e})})});import{jsx as ho,jsxs as dy}from"react/jsx-runtime";var cy=t=>e=>{let o=Nr(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},py=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=v("TabCompletion",xe),i=Un(),a=ly(()=>cy(t.getBoundingClientRect()),[t]),[l,c]=an(t);return ay(()=>{c?i.open():i.close()},[c]),dy("span",{children:[ho("mark",{ref:Kn([l,i.triggerRef]),className:ry(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&ho(zn,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:ho(jn,{style:o,children:ho("div",{className:r.hintText,children:s})})})]})},Vn=class extends iy{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(e,o){return o.keywordMatches&&o.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=o.keywordMatches.map(n=>({...n,keywordRegex:new RegExp(`\\b${Rc(n.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),e}match(e){let o=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let r=e.match(s.keywordRegex);if(!r)return null;let i=e.charAt(r.index-1),a=e.charAt(r.index+s.keyword.length);return i==="{"&&a==="}"?null:{index:r.index,length:r[0].length,match:r[0],matchString:r[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(Ic);if(o.length===0)return null;let n=o.reduce((s,r)=>r.index<s.index?r:s);return this.usedKeywordMatches.add(n.preparedKeywordMatch),n}replaceWith(e,o){return ho(py,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import Fr from"classnames";import{Matcher as _y}from"interweave";import{createRef as xy,forwardRef as by,useCallback as Cy,useEffect as jc,useRef as Vc,useState as qc}from"react";import{useDispatch as wy}from"react-redux";import{jsx as Dc}from"react/jsx-runtime";var Hc=()=>Dc("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:Dc("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 uy,useEffect as Fc,useState as Kc}from"react";import{useDispatch as gy,useSelector as Uc}from"react-redux";import my from"lodash.debounce";var Bc={root:"_root_1muu8_1",content:"_content_1muu8_7"};function qn(t,e,o){var s;let n=((s=t.imageSizes)==null?void 0:s[e])||t.image||o;if(!n)return null;try{return new URL(n).toString()}catch{return null}}function Or(t){return t.replace("https://www.","").replace("https://","")}import{jsx as ot,jsxs as Dr}from"react/jsx-runtime";var fy=3,hy=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),yy=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=fy})=>{let r=v("LinkSearch",Bc),[i,a]=Kc(""),l=gy(),c=Uc(Cn("url")),p=Uc(Ua("URL",hy)),[d,u]=Kc(p.length-1),g=C("fallbackImage"),m=y=>{let x=y.target;a(x.value)},f=(y,x)=>{y.stopPropagation(),y.preventDefault(),window.open(x,"_blank")},h=y=>{var _;let x=d-1<0?p.length-1:d-1,b=d+1===p.length?0:d+1;y.code==="Escape"&&(a(""),e()),y.code==="ArrowUp"&&u(x),y.code==="ArrowDown"&&u(b),y.code==="Enter"&&t(((_=p[d])==null?void 0:_.text)||i)},w=uy(my(y=>{l(Je({query:y,type:"URL",tags:["link-search"]}))},300),[]);return Fc(()=>{i&&w(i)},[i]),Fc(()=>()=>{l(Sn())},[]),Dr("div",{className:r.root,children:[ot(re,{withDivider:!0,children:(i?p:c).slice(0,s).map((y,x)=>ot(D,{selected:d===x,onClick:()=>t(y.text),"data-testid":"linksearch-suggestion",children:Dr(H,{children:[ot(H.Image,{src:qn(y,"small",g||void 0),title:y.title||y.text}),Dr(H.Content,{className:r.content,cropText:!0,children:[ot(H.Title,{children:y.title||Or(y.text)}),y.title&&Or(y.text)]}),ot(D.Actions,{children:ot(D.ActionButton,{label:n,onClick:b=>f(b,y.text)})})]})},y.text))}),ot(io,{value:i,onChange:m,autoFocus:!0,placeholder:o,onKeyUp:h})]})},zc=yy;var Hr={};j(Hr,{enUS:()=>vy,nlNL:()=>Sy});var vy={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Sy={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};import{jsx as ye,jsxs as Br}from"react/jsx-runtime";var Ty=by((t,e)=>{let o=v("TabCompletion",xe);return ye("mark",{ref:e,className:Fr(o.matchSelection)},"selection-start")}),Ey=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=T(Hr),i=v("TabCompletion",xe),a=Vc(null),l=Vc(null),[c,p]=qc(null),d=wy(),u=Un(document.activeElement===n),[g]=qc(()=>document.createRange());u.triggerRef.current=g,jc(()=>()=>g.detach(),[]),jc(()=>{let f=t.current,h=a.current;!f||!h||(g.setStart(f,0),g.setEnd(h,0))},[t.current,a.current]),St(()=>{u.close()});let m=Cy(f=>{let h=g.toString(),w=/^http(s?):\/\//.test(f)?f:`https://${f}`;d(Uo({text:`[${h}](${w})`,replace:"selection"}))},[]);return Br("span",{children:[ye("mark",{ref:a,className:Fr(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":u.opened?"true":"false",children:s}),u.opened&&ye(zn,{className:i.popoverRoot,triggerRef:u.triggerRef,boundaryRef:e,position:"above",align:"start",children:Br(jn,{style:o,ref:l,children:[ye("div",{className:Fr(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:Br("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[ye(Hc,{}),ye("span",{children:"\xA0"}),ye("span",{children:r("insertLink")})]})}),c==="insertLink"&&ye(zc,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:m,onDismiss:()=>{p(null),u.close()}})]})})]},"selection-end")},Wn=class extends _y{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=xy(),this.foundIndex=0,e}match(e){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,n]=this.props.selection;if(o===n)return null;let s=this.foundIndex===0?o:n,r=s>=this.charCount&&s<=this.charCount+e.length?{index:s-this.charCount,length:0,match:"",valid:!0}:null;r&&this.foundIndex++;let i=this.foundIndex===1;return r&&i?this.charCount+=s-this.charCount:this.charCount+=e.length,r?{isStart:i,...r}:null}replaceWith(e,o){return o.isStart?ye(Ty,{ref:this.startRef}):ye(Ey,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};import{jsx as Mt,jsxs as Ny}from"react/jsx-runtime";var Ly=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=v("TabCompletion",kc),p=C("insertLink"),d=C("showMidSentenceSuggestions"),u=C("inlineSuggestions"),g=cn(a),m=Py(null);Iy(()=>{Ue(a)&&g&&pn(a,g)},[g]);let f=Ry(y=>{if(!s||!o)return y;let x=[Mt("span",{className:c.resetIndent,children:"\u200B"},"u200B"),Mt("span",{"data-testid":"tab-completion",className:Kr(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&x.push(Mt("span",{className:Kr(c.hint,c.resetIndent),children:Mt(gs,{keyCode:"tab"},"tabHint")})),Pr(y,x)},[s,o,n]),h=Wc(()=>{let y=[];return p&&y.push(new Wn("selection")),y.push(new vt("placeholders")),r&&y.push(new Vn("keywords")),y},[u,p,r]),w=Wc(()=>{let y=window.getComputedStyle(a);return{"--dd-color":y.color,"--dd-font-size":y.fontSize,"--dd-font-family":y.fontFamily,"--dd-font-variant":y.fontVariant}},[]);return t?Ny("div",{ref:y=>{y!=null&&y.parentElement&&(m.current=y==null?void 0:y.parentElement)},className:c.root,style:w,children:[Mt(ky,{tagName:"span",containerTagName:"div",className:Kr(c.container,c.agentText),disableLineBreaks:Ue(a),content:e||"\u200B",onAfterParse:f,matchers:h,selection:g,keywordMatches:i,inputElement:a,inputStyle:w,boundaryRef:m,inlineSuggestionsOnlyAtEnd:!d}),Mt("br",{})]}):null},My=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var f;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??Qt(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:u,visible:g,showStyleSuggestions:m}=o;return{showTabHint:p,showStyleSuggestions:m,showTabCompletion:u,content:l,tabText:c,source:a,keywordMatches:((f=n.list)==null?void 0:f.keywordMatches)??[],enabled:g&&d!==!1}},Gc=Ay(My)(Ly);import fv from"classnames";import{useEffect as hv}from"react";import{useDispatch as yv,useSelector as ee}from"react-redux";import{createAsyncThunk as yo,createSlice as Oy}from"@reduxjs/toolkit";var $c={list:[],fetchState:"idle",isInitialRequest:null},Qc=t=>t.autoflows.list||[],Xc=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},Ie=yo("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Ur=yo("autoflows/start",async(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");await n.startAutoflowSession(t),await o(Ie(t.platformSessionId))}),zr=yo("autoflows/stop",async(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");await n.stopAutoflowSession(t.platformSessionId),await o(Ie(t.platformSessionId))}),Dy=Oy({name:"autoflows",initialState:$c,reducers:{},extraReducers:t=>{t.addCase(Ur.pending,(e,o)=>{let n=Xc(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(zr.pending,(e,o)=>{let n=Xc(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(Ie.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(Ie.rejected,e=>{e.fetchState="error"}),t.addCase(Ie.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(L,()=>$c)}}),Zc=yo("autoflows/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");let s=n.openStream(t);s.on("sessionAborted",()=>{o(Ie(t))}),s.on("sessionCompleted",()=>{o(Ie(t))})}),Jc=yo("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Yc=Dy.reducer;import{createAsyncThunk as So,createSlice as Hy}from"@reduxjs/toolkit";var ep={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},tp=t=>t.customMessages.list,op=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),np=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),sp=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),vo=So("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),Gn=So("customMessages/send",async(t,e)=>{let{platformSessionId:o,suggestion:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.sendCustomMessage(o,n)}),$n=So("customMessages/answer",async(t,e)=>{let{platformSessionId:o,reply:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.answerCustomMessage(o,n)}),rp=Hy({name:"customMessages",initialState:ep,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(vo.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(vo.rejected,e=>{e.fetchState="error"}).addCase(vo.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(Gn.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(Gn.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase($n.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase($n.rejected,(e,o)=>{let n=e.answeredSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1)),e.answeredSuggestions.splice(n,1)}).addCase(L,()=>ep)}}),ip=So("customMessages/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.openStream(t).on("customMessageSuggestion",r=>{o(rp.actions.onCustomMessage(r))})}),ap=So("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),lp=rp.reducer;import{createAsyncThunk as cp,createSlice as By}from"@reduxjs/toolkit";var Fy={token:null,accountUrl:null,interval:null},pp=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},jr=cp("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),Vr=cp("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(jr()),setInterval(()=>n(jr()),o)}),dp=By({name:"passwordlessToken",initialState:Fy,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(jr.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(Vr.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:up}=dp.actions,gp=dp.reducer;function mp(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}import{Fragment as Xy}from"react";import{connect as Qy}from"react-redux";import Wy from"classnames";import{Fragment as Gy}from"react";import Ky from"classnames";var fp={root:"_root_838fd_1"};import{jsx as zy}from"react/jsx-runtime";var Uy=({className:t,children:e})=>{let o=v("Unicode",fp);return zy("span",{className:Ky(t,o.root),children:e})},hp=Uy;var yp={isDisabled:"_isDisabled_1rmfm_1",buttonStart:"_buttonStart_1rmfm_5",root:"_root_1rmfm_8",buttonStop:"_buttonStop_1rmfm_8",stateBadge:"_stateBadge_1rmfm_19",isCompleted:"_isCompleted_1rmfm_26",isStarted:"_isStarted_1rmfm_30",isAborted:"_isAborted_1rmfm_34"};var qr={};j(qr,{enUS:()=>jy,nlNL:()=>Vy});var jy={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]},Vy={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]};import{jsx as nt,jsxs as Xn}from"react/jsx-runtime";var $y=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=v("Autoflow",yp),a=T(qr),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return Xn(D,{className:Wy(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[nt(H,{children:Xn(H.Content,{children:[Xn(H.Title,{children:[e&&nt("span",{className:i.stateBadge,children:a(e)}),o]}),nt("span",{children:n})]})}),nt(D.Actions,{fixed:e==="Started",children:nt(D.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:Xn(Gy,{children:[nt(hp,{children:c})," ",nt("span",{children:a(l)})]})})})]})},vp=$y;import{jsx as Sp}from"react/jsx-runtime";var Zy=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Jy=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>Sp(Xy,{children:t.map(s=>Sp(vp,{displayName:s.displayName,description:s.description,disabled:s.isBusy||Zy(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),Yy=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},ev={onStartAutoflow:Ur,onStopAutoflow:zr},_p=Qy(Yy,ev)(Jy);import{useEffect as tv,useState as ov}from"react";import{useDispatch as nv}from"react-redux";import Cp from"classnames";import{jsx as xp}from"react/jsx-runtime";var Wr=()=>xp("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:xp("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 bp={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};import{jsx as Nt,jsxs as wp}from"react/jsx-runtime";var sv=({entities:t})=>{let e=v("EntitiesWidgetList",bp),[o,n]=ov(void 0),s=nv(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),lo(a.text),s(V({name:"entity copied",data:{entity:a,type:"copy"}})))};return tv(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:Nt("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>wp("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[Nt("span",{className:e.entityText,children:a.text}),wp("span",{className:e.iconWrapper,children:[Nt("span",{className:Cp(e.icon),children:Nt(Wr,{})}),Nt("span",{className:Cp(e.icon,o===l&&e.iconClicked),children:Nt(Wr,{})})]})]},a.text))})},Tp=sv;import rv from"classnames";import{useCallback as Ep}from"react";import{useDispatch as iv,useSelector as Qn}from"react-redux";var Pe={root:"_root_1e6ej_1",title:"_title_1e6ej_8",isUsed:"_isUsed_1e6ej_13",quickReplies:"_quickReplies_1e6ej_22",quickReply:"_quickReply_1e6ej_29",hasError:"_hasError_1e6ej_39",label:"_label_1e6ej_43",errorIcon:"_errorIcon_1e6ej_48"};import{jsx as ze,jsxs as Zn}from"react/jsx-runtime";var av=({suggestion:t})=>{let e=T(Ze),o=iv(),n=Qn(op(t.text)),s=Qn(np(t.text)),r=Qn(sp(t.text)),i=Qn(Mo),{replyOptions:a}=t,l=Ep(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(Gn({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=Ep(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),u=a[d];o($n({platformSessionId:i,reply:u,suggestion:t}))},[t,n,o,i]);return Zn(D,{onClick:l,className:rv(Pe.root,{[Pe.isUsed]:n,[Pe.hasError]:r}),children:[ze(H,{children:Zn(H.Content,{children:[Zn(H.Title,{className:Pe.title,children:[t.text," ",ze(ms,{className:Pe.label,children:"analyse tool"})," ",r&&ze("span",{className:Pe.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&ze("ul",{className:Pe.quickReplies,children:a.map(p=>ze("li",{className:Pe.quickReply,children:p.title},p.title))})]})}),Zn(D.Actions,{fixed:r||n,children:[a&&a.length>0&&ze(D.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>ze(D.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),ze(D.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},kp=av;import{jsx as Rp}from"react/jsx-runtime";var Ip=()=>Rp("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Rp("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});import{useSelector as pv}from"react-redux";import{useCallback as lv}from"react";import{jsx as st,jsxs as Jn}from"react/jsx-runtime";var cv=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var u;let s=t.text||t.url||t.message,r=_n(s),i=T(Ze),a=C("showImages"),l=C("fallbackImage"),c=g=>{g.preventDefault(),g.stopPropagation(),n(s)},p=g=>{g.preventDefault(),g.stopPropagation(),o(t)},d=lv(g=>{window.open(r,"_blank"),g.stopPropagation(),g.preventDefault()},[r]);return Jn(D,{onClick:c,"data-testid":"edit-suggestion",children:[Jn(H,{children:[a&&t.image&&st(H.Image,{src:qn(t,"small",l||void 0),title:t.title}),Jn(H.Content,{children:[t.title&&st(H.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&st(D.Labels,{labels:t.searchKeywords}),st(H.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),Jn(D.Actions,{children:[r&&st(D.ActionButton,{onClick:d,label:i("visitUrl")}),st(D.ActionButton,{primary:!0,onClick:p,label:i("preview")}),st(D.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},Pp=cv;import{Fragment as uv,jsx as Ap}from"react/jsx-runtime";var dv=({contentType:t,lines:e,suggestions:o})=>{let n=se(),s=pv(Be),r=a=>{n.send(pr,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(Te,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return Ap(uv,{children:o.map(a=>Ap(Pp,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},Lp=dv;var Gr={};j(Gr,{enUS:()=>gv,nlNL:()=>mv});var gv={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],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"}]},mv={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],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"}]};var Mp={root:"_root_x0pwe_1",loginText:"_loginText_x0pwe_7",stateText:"_stateText_x0pwe_8",sectionList:"_sectionList_x0pwe_20",shortcutList:"_shortcutList_x0pwe_24",shortcut:"_shortcut_x0pwe_24",link:"_link_x0pwe_52"};import{jsx as Np}from"react/jsx-runtime";var Op=()=>Np("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:Np("path",{d:"M543-340q16.595 0 28.798-12.202Q584-364.405 584-381t-12.202-28.798Q559.595-422 543-422t-28.798 12.202Q502-397.595 502-381t12.202 28.798Q526.405-340 543-340Zm-25-126h47q2-29 8.5-43t32.5-39q27-26 37.5-45.395Q654-612.79 654-639q0-45.882-31.5-74.941Q591-743 540-743q-38 0-68 20.5T428-665l45 19q11-25 27.5-38t39.5-13q29.778 0 48.389 17Q607-663 607-637q0 20-9 35t-32 32q-32 29-40 46.5t-8 57.5ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-620h60v620h620v60H140Zm120-740v560-560Z"})});import{jsx as Dp}from"react/jsx-runtime";var Hp=()=>Dp("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:Dp("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});import{jsx as M,jsxs as Ot}from"react/jsx-runtime";var Yn=(t,e)=>{let o=ee(oe);hv(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},vv=({onLogIn:t})=>{let e=T(Gr),o=yv(),n=C("isEmbedded"),s=v("Widget",Mp),r=C("showAutoflows"),i=C("showCustomMessages"),a=C("showSummaryCommand"),l=C("showKnowledgeSearch"),c=C("showSearch"),p=ee(Ke),d=ee(Pn),u=ee(Qc),g=ee(kn),m=ee(tp),f=ee(No),h=ee(ft),w=ee(oe),y=ee(Mo),x=ee(mp),b=ee(Be),_=se(),I=ee(ol),N=ee(pp("/admin/")),$=C("adminUrl"),P=C("productName");if(Yn(()=>(o(vo(y)),o(ip(y)),()=>{o(ap(y))}),[o,h,i,y]),Yn(()=>(o(Ie(y)),o(Zc(y)),()=>{o(Jc(y))}),[o,h,r,y]),Yn(()=>{d.forEach(({type:R})=>{o(R==="entities"?pe():ce(R))})},[o,h,f,p]),Yn(()=>(o(Vr()),()=>{o(up())}),[o]),h===!1)return M("div",{className:s.stateText,children:M("div",{children:M("p",{children:e("notSupported")})})},"supported");if(w===!1)return M("div",{className:s.loginText,children:M("div",{children:M(Bn,{isEmbedded:n,loginUrl:$,onLogIn:t})})},"login");if(!p||!y||w===null||I||x)return M("div",{className:s.stateText,children:M("div",{children:M("p",{children:e("waiting")})})},"waiting");let X=c||a||l||N;return M("div",{className:fv(s.root),"data-testid":"widget",children:Ot(hs,{className:s.sectionList,children:[X&&M(Ve,{title:e("actions"),type:"shortcuts",children:Ot("div",{className:s.shortcutList,children:[c&&Ot("button",{className:s.shortcut,"data-testid":"shortcut-search",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0}),children:[M(Ct,{}),e("linkSearch")]}),a&&Ot("button",{className:s.shortcut,"data-testid":"shortcut-summary",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[M(Hp,{}),e("linkSummary")]}),l&&Ot("button",{className:s.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[M(Op,{}),e("linkKnowledgeSearch")]}),N&&Ot("a",{className:s.shortcut,target:"_blank",href:N,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[M(Ip,{}),e("linkStudioLogin",{productName:P})]})]})}),i&&m.length>0&&M(Ve,{type:"custom-messages","data-testid":"custom-messages",children:M(re,{withDivider:!0,children:m.map(R=>M(kp,{suggestion:R},R.text))})}),r&&u.length>0&&M(Ve,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:M(re,{withDivider:!0,children:M(_p,{})})}),d.map(({type:R,title:B,amount:at,lines:Kt})=>{var Ut;switch(R){case"entities":return g&&g.length>0&&M(Ve,{type:R,title:B,"data-testid":`type-${R}`,children:M(Tp,{entities:g})},R);default:return((Ut=b[R])==null?void 0:Ut.fetchState)==="done"&&b[R].suggestions.length>0&&M(Ve,{type:R,title:B,"data-testid":`type-${R}`,children:M(re,{withDivider:!0,children:M(Lp,{lines:Kt,contentType:R,suggestions:b[R].suggestions.slice(0,at)||[]})})},R)}})]})})},Bp=vv;function xo(t){let e=new Range;return e.selectNodeContents(t),e}function Fp(t,e,o){try{return rt(t,e,o),!0}catch{return!1}}function es(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function ts(t){return"tagName"in t&&t.tagName==="BR"}var _o=/[\u200B-\u200D\uFEFF]/g;function rt(t,e,o){let n=new Range;if(t.firstChild===null&&e===0&&o===0)return n.selectNodeContents(t),n;let s=0,r=!1;function i(l,c){let p=-1,d=/[\u200B-\u200D\uFEFF]/;if(!d.test(l))return c;for(let u=0;u<=l.length;u++)if(d.test(l[u])||p++,p===c)return u;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(_o,""),d=s+p.length,u=e>=s&&e<=d,g=o>=s&&o<=d;if(u){let m=i(c,e-s);m===0&&!g?n.setStartBefore(l):n.setStart(l,m)}g&&(n.setEnd(l,i(c,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(ts(l)&&(s===e&&n.setStartBefore(l),s++,s===o)){n.setEndAfter(l),r=!0;return}for(let p=0;p<l.childNodes.length&&(a(l.childNodes[p]),!r);p++);let c=l.lastChild;es(l)&&c&&!es(c)&&!ts(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function os(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r,collapsed:i}=e,a,l,c=0;function p(d){let u=d===o,g=d===s;switch(d.nodeType){case Node.TEXT_NODE:{let m=d.textContent;u&&(a=c+m.substring(0,n).replace(_o,"").length),g&&(l=c+m.substring(0,r).replace(_o,"").length),c+=m.replace(_o,"").length;break}case Node.ELEMENT_NODE:{let m=d.nextSibling===null;ts(d)&&!m&&c++;for(let f=0;f<d.childNodes.length;f++){let h=u&&f===n,w=g&&f===r;if(h&&(a=c),w&&(l=c),l!==void 0||((!h||!i)&&p(d.childNodes[f]),g&&f===r-1&&(l=c),l!==void 0))break}!g&&es(d)&&!m&&c++,g&&(l=c);break}default:break}}if(p(t),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function ns(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let p=c===o,d=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let u=p?n:0,g=d?r:void 0,m=c.textContent.replace(_o,"");u===0&&g===void 0?a+=m:a+=m.substring(u,g);break}case Node.ELEMENT_NODE:{let u=c.nextSibling===null;i===0&&ts(c)&&!u&&(a+=`
3
+ `,$e.MISSING_INTL_API,i);var b=o.getPluralRules(e,{type:p.pluralType}).select(u-(p.offset||0));x=p.options[b]||p.options.other}if(!x)throw new Ls(p.value,u,Object.keys(p.options),i);a.push.apply(a,Zt(x.value,e,o,n,s,u-(p.offset||0)));continue}}return Mu(a)}function Ou(t,e){return e?te(te(te({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=te(te({},t[n]),e[n]||{}),o},{})):t}function Du(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Ou(t[n],e[n]),o},te({},t)):t}function Ms(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Hu(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:sn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,Go([void 0],o,!1)))},{cache:Ms(t.number),strategy:rn.variadic}),getDateTimeFormat:sn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,Go([void 0],o,!1)))},{cache:Ms(t.dateTime),strategy:rn.variadic}),getPluralRules:sn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,Go([void 0],o,!1)))},{cache:Ms(t.pluralRules),strategy:rn.variadic})}}var Zi=function(){function t(e,o,n,s){o===void 0&&(o=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var p=r.formatToParts(c);if(p.length===1)return p[0].value;var d=p.reduce(function(u,g){return!u.length||g.type!==q.literal||typeof u[u.length-1]!="string"?u.push(g.value):u[u.length-1]+=g.value,u},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return Zt(r.ast,r.locales,r.formatters,r.formats,c,void 0,r.message)},this.resolvedOptions=function(){var c;return{locale:((c=r.resolvedLocale)===null||c===void 0?void 0:c.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=o,this.resolvedLocale=t.resolveLocale(o),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=s||{},a=i.formatters,l=ji(i,["formatters"]);this.ast=t.__parse(e,te(te({},l),{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=Du(t.formats,n),this.formatters=s&&s.formatters||Hu(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>"u")){var o=Intl.NumberFormat.supportedLocalesOf(e);return o.length>0?new Intl.Locale(o[0]):new Intl.Locale(typeof e=="string"?e:e[0])}},t.__parse=qi,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 Ku(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var Uu="dummy",Ns=Bu(null);function T(t){let e=Fu(Ns);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let o=t[e]??{};return(n,s)=>{let r=Ku(o,n);return r?new Zi(r).format(s):(e!==Uu&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}import{jsx as Qi,jsxs as ju}from"react/jsx-runtime";var an=()=>ju("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[Qi("title",{id:"angleLeftTitle",children:"AngleLeft"}),Qi("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 Ji,jsxs as zu}from"react/jsx-runtime";var Yi=()=>zu("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[Ji("title",{id:"angleRightTitle",children:"AngleRight"}),Ji("path",{d:"M64 448c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L178.8 256L41.38 118.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l160 160c12.5 12.5 12.5 32.75 0 45.25l-160 160C80.38 444.9 72.19 448 64 448z"})]});import{useEffect as Jt,useRef as zs,useState as gg}from"react";import{useDispatch as mg}from"react-redux";import{Interweave as _a}from"interweave";import xa from"classnames";var Os={root:"_root_smoda_1",agentText:"_agentText_smoda_3",textInput:"_textInput_smoda_8",textInputWrapper:"_textInputWrapper_smoda_27",alert:"_alert_smoda_31",alertText:"_alertText_smoda_50",warning:"_warning_smoda_60",success:"_success_smoda_69"};import{Matcher as Gu}from"interweave";import $u from"classnames";import{useEffect as Vu,useRef as qu,useState as Wu}from"react";function ea(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function ln(t){let e=qu(null),[o,n]=Wu(!1);return Vu(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=ea((p,d)=>{let u=e.current;if(!u)return;let g=p/r,m=d/r,f=u.getBoundingClientRect(),h=g>f.x&&g<f.x+f.width&&m>f.y&&m<f.y+f.height;h&&!s?(s=!0,n(!0)):!h&&s&&(s=!1,n(!1))},({clientX:p,clientY:d})=>[p,d]),[l,c]=ea(()=>{s=!1,n(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",l),()=>{a(),c(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",l)}},[e]),[e,o]}var xe={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};import{jsx as ta}from"react/jsx-runtime";var Xu=({inputElement:t,children:e})=>{let o=v("TabCompletion",xe),[n,s]=ln(t);return ta("mark",{ref:n,className:$u(o.matchPlaceholder,{[o.hover]:s}),children:e})},vt=class extends Gu{match(e){let o=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return o?{index:o.index,length:o[0].length,match:o[0],matchString:o[0],valid:!0}:null}replaceWith(e,o){return ta(Xu,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import{useEffect as Zu,useRef as Qu,useState as Ju}from"react";function cn(t){return t.contentEditable==="true"}function Yu(t){let e=0,o=0,n=window.getSelection();if(n.rangeCount!==0){let s=n.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),o=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:o}}function oa(t){let{selectionStart:e,selectionEnd:o}=cn(t)?Yu(t):t;return[e,o]}function pn(t){let[,e]=Ju(),o=Qu(null);return o.current=oa(t),Zu(()=>{let n=()=>{let[s,r]=o.current??[],i=oa(t);(!i||s!==i[0]||r!==i[1])&&(o.current=i,e({}))};return t.addEventListener("keyup",n),t.addEventListener("click",n),t.addEventListener("focus",n),document.addEventListener("selectionchange",n),()=>{t.removeEventListener("keyup",n),t.removeEventListener("click",n),t.removeEventListener("focus",n),document.removeEventListener("selectionchange",n)}},[t]),o.current}function dn(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(gt);if(!i||i.length===0)return;let a=0;i.find(l=>{let c=n.indexOf(l,a);return s>c&&r<c+l.length?(o.selectionStart=c,o.selectionEnd=c+l.length,!0):(a=c+l.length,!1)})}import{useEffect as eg}from"react";function St(t){eg(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Xe(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var na,me=new Map,tg=["bottom","height","left","right","top","width"],og=(t={},e={})=>tg.some(o=>t[o]!==e[o]);function sa(t){var o,n;if(t.ownerDocument===document)return[];let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...sa(e)]:[]}function ra(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var un=!1,ia=()=>{un=!0;let t=[];if(me.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),me.delete(o);return}let n=o.getBoundingClientRect();og(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(ra,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),me.size===0){un=!1;return}na=window.requestAnimationFrame(ia)};function Ds(t,e){let o=sa(t),n=[],s=o.map((r,i)=>Ds(r,a=>{n[i]=a;let l=me.get(t);if(!l)return;let c=n.reduce(ra,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),me.has(t)){let i=me.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else me.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!un&&ia()},unobserve(){s.forEach(i=>i.unobserve());let r=me.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||me.delete(t),me.size||(cancelAnimationFrame(na),un=!1)}}}}var aa,fe=new Map,la=()=>{fe.forEach((t,e)=>{if(!e.isConnected){fe.delete(e);return}let{clientHeight:o,scrollHeight:n}=e,s=n>o;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),fe.size!==0&&(aa=window.requestAnimationFrame(la))};function ca(t,e){return{observe(){let o=fe.size===0;fe.has(t)?fe.get(t).callbacks.push(e):fe.set(t,{visible:void 0,callbacks:[e]}),o&&la()},unobserve(){let o=fe.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||fe.delete(t),fe.size||cancelAnimationFrame(aa)}}}}var Hs=["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 Bs(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function _t(t){return parseFloat(t)}function gn(t){return Math.round(t*1e6)}function pa(t){return t/1e6}function Fs(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=_t(t.width),r=_t(t.borderLeftWidth),i=_t(t.borderRightWidth),a=_t(t.paddingRight),l=pa(gn(s)-gn(r)-gn(i)),c=pa(gn(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function xt(t,e={}){var p;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",Xe(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Bs(n,o,Hs),Fs(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=ca(t,()=>{Bs(n,o,Hs),Fs(n,t,o),r(),setTimeout(r,0)}),a,l=!0,c=Ds(t,d=>{if(d===null){e.onRemove&&e.onRemove(),o.remove();return}if(!l&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Bs(n,o,Hs),Fs(n,t,o),r(),o.style.top=`${d.top}px`,o.style.left=`${d.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let u=e.closestScrollElement.getBoundingClientRect(),g=window.getComputedStyle(e.closestScrollElement),m=_t(g.borderTopWidth),f=_t(g.borderBottomWidth),h=u.top+m-d.top,w=d.top+d.height+-(u.top+u.height-f);o.style.clipPath=`inset(${h}px 0px ${w}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(p=t.parentElement)==null||p.appendChild(o),c.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),c.unobserve(),i.unobserve()}]}var Ks={};z(Ks,{enUS:()=>ng,nlNL:()=>sg});var ng={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"No placeholders found"}]},one:{value:[{type:0,value:"There is one placeholder in your message"}]},other:{value:[{type:0,value:"There are "},{type:7},{type:0,value:" placeholders in your message"}]}},offset:0,pluralType:"cardinal"}]},sg={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"Alle placeholders zijn uit je bericht"}]},one:{value:[{type:0,value:"Er is 1 placeholder in jouw bericht"}]},other:{value:[{type:0,value:"Er zijn "},{type:7},{type:0,value:" placeholders in jouw bericht"}]}},offset:0,pluralType:"cardinal"}]};import{jsx as da,jsxs as rg}from"react/jsx-runtime";var ua=()=>rg("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[da("title",{id:"circleCheckTitle",children:"Check"}),da("path",{d:"M243.8 339.8C232.9 350.7 215.1 350.7 204.2 339.8L140.2 275.8C129.3 264.9 129.3 247.1 140.2 236.2C151.1 225.3 168.9 225.3 179.8 236.2L224 280.4L332.2 172.2C343.1 161.3 360.9 161.3 371.8 172.2C382.7 183.1 382.7 200.9 371.8 211.8L243.8 339.8zM512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256zM256 48C141.1 48 48 141.1 48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48z"})]});import{jsx as ga}from"react/jsx-runtime";var ma=()=>ga("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:ga("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var fa=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(fa||{}),Ne=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentCaret=null;currentSelection={start:0,end:0};currentHTML="";isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(e,o){let n=s=>{o(s)};this.element.addEventListener(e,n),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,n)})}removeEventListener(e,o){this.element.removeEventListener(e,o)}triggerChange(){let e=this.getText(),o=this.getHTML(),n=e!==this.currentText;this.isActive&&(e===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&n&&!this.isSubmitting&&this.emit("change",{plainText:e}),n&&(this.currentSelection=this.getSelection()),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==o||o===null&&n)&&(this.emit("updated",{plainText:e}),this.triggerCaretPosition(),this.currentHTML=o))}triggerSelection(){let e=this.getSelection();(e.start!==this.currentSelection.start||e.end!==this.currentSelection.end)&&(this.currentSelection=e,this.emit("selection",e),this.triggerCaretPosition())}triggerCaretPosition(){let e=this.getCaretPosition();Ae(e,this.currentCaret)||(this.currentCaret=e,this.emit("caret",e))}handleKeyUp(e){let{key:o,shiftKey:n}=e;(o==="Enter"&&n===!0||o==="Backspace")&&this.triggerChange(),this.triggerSelection()}handleClick(){this.triggerSelection()}handleFocus(){this.isFocused||this.emit("focus"),this.triggerSelection(),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(e){let{key:o,ctrlKey:n,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(fa).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var n,s;let o=((n=e.clipboardData)==null?void 0:n.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",o=>this.handleKeyDown(o)),this.addEventListener("keyup",o=>this.handleKeyUp(o)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",o=>this.handlePaste(o)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},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()}),this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};var Oe=class extends Ne{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){let e=this.getSelection();return e?this.getText().slice(e.start,e.end):""}getCaretPosition(){return null}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let o=this.element.disabled,n=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>n.disconnect())}};var ig=/[.*+?^${}()|[\]\\]/g,ag=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function lg(t){return t.replace(ig,"\\$&")}function cg(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function pg(t){return t.search(ag)}function ha(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${lg(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function ya(t){return t.replace(gt,'<mark data-type="placeholder">$1</mark>')}function Qt(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function dg(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 Us(t,e,o={}){if(e){let n=cg(e.toLowerCase(),t.toLowerCase()),s=Qt(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=pg(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(fi).length>3||e.length>30?dg(e.trim(),n):0;return`${`${i>0?"\u2026":""}${Qt(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var ug=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function bt(t){return ug.test(t)}function va(t){if(bt(t)){let o=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(t);return o?o[1]:""}return t}function Sa(t){let e=document.createElement("template");return e.innerHTML=t,e.content.textContent??""}import{jsx as le,jsxs as js}from"react/jsx-runtime";var fg=({value:t,onUse:e,...o})=>{var d;let n=T(Ks),s=mg(),r=bt(t),i=v("EditSuggestionTextInput",Os),[a,l]=gg(null),c=zs(null),p=((d=t.match(gt))==null?void 0:d.length)||0;return Jt(()=>{let u;return c.current&&(l(c.current),u=new Oe(c.current),u.on("change",({plainText:g})=>{s(Z.actions.userInput({text:g,selection:u.getSelection()}))}),u.on("keydown",g=>{s(Z.actions.registerKeyDown(Uo(g))),g.code==="Enter"&&g.shiftKey&&e(u.getText())}),u.on("paste",({pastedText:g,selectionText:m})=>{s(Z.actions.registerPaste({text:g,selectionText:m}))}),u.on("cut",({selectionText:g})=>{s(Z.actions.registerCut(g))})),()=>{s(Z.actions.reset()),u.dispose(),u.deactivate()}},[c]),Jt(()=>{t&&c.current&&(c.current.value=t)},[t,c]),Jt(()=>{c.current&&setTimeout(()=>{if(!c.current)return;let u=c.current.value.length;c.current.setSelectionRange(u,u),c.current.focus()},0)},[c]),r?le("div",{className:i.textInputWrapper,children:le(_a,{className:i.textInput,tagName:"div",content:t})}):js("div",{className:i.textInputWrapper,children:[le("textarea",{...o,ref:c,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:t,onChange:()=>{}}),a&&le(hg,{inputElement:c.current,value:t}),js("div",{className:xa(i.alert,p===0?i.success:i.warning),children:[le("div",{className:i.alertText,children:n("placeholders",{placeholderSize:p})}),p===0?le(ua,{}):le(ma,{})]})]})},hg=({inputElement:t,value:e})=>{let o=v("EditSuggestionTextInput",Os),n=zs(null),s=pn(t);return Jt(()=>{dn(t,s)},[s,t]),le(yg,{inputElement:t,children:js("div",{ref:n,className:xa(o.root,o.agentText),children:[le(_a,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new vt("placeholders")],inputElement:t,boundaryRef:n}),le("br",{})]})})},yg=({inputElement:t,children:e})=>{let o=zs(null);return Jt(()=>{if(!o.current)return()=>{};let[n,s]=xt(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),le("div",{ref:o,children:e})},ba=fg;import{useEffect as im,useState as am,useRef as lm}from"react";import{useState as _g}from"react";import Vs from"classnames";var Q={root:"_root_1mc8f_1",list:"_list_1mc8f_2",listWrapper:"_listWrapper_1mc8f_6",listHorizontal:"_listHorizontal_1mc8f_10",page:"_page_1mc8f_19",search:"_search_1mc8f_25",pageNav:"_pageNav_1mc8f_33",pageTitle:"_pageTitle_1mc8f_41",pageBackButton:"_pageBackButton_1mc8f_48",listHeading:"_listHeading_1mc8f_62",listItem:"_listItem_1mc8f_70",listItemContent:"_listItemContent_1mc8f_79",listItemText:"_listItemText_1mc8f_97",listItemDescription:"_listItemDescription_1mc8f_105",listItemActions:"_listItemActions_1mc8f_112",truncate:"_truncate_1mc8f_123",lineClamp:"_lineClamp_1mc8f_129",listItemTitle:"_listItemTitle_1mc8f_136",listItemAction:"_listItemAction_1mc8f_112",listItemPrimaryAction:"_listItemPrimaryAction_1mc8f_157",listItemSelected:"_listItemSelected_1mc8f_162",sources:"_sources_1mc8f_166",sourcesTitle:"_sourcesTitle_1mc8f_173",source:"_source_1mc8f_166",icon:"_icon_1mc8f_188",searchIcon:"_searchIcon_1mc8f_205",searchInputWrapper:"_searchInputWrapper_1mc8f_210",searchInput:"_searchInput_1mc8f_210",select:"_select_1mc8f_231",selectType:"_selectType_1mc8f_248",selectWrapper:"_selectWrapper_1mc8f_252",image:"_image_1mc8f_282",imageSrc:"_imageSrc_1mc8f_289",imageSrcHidden:"_imageSrcHidden_1mc8f_300",imageSrcStatus:"_imageSrcStatus_1mc8f_304",imageTitle:"_imageTitle_1mc8f_314",actions:"_actions_1mc8f_319",actionsWrapper:"_actionsWrapper_1mc8f_323",actionsBar:"_actionsBar_1mc8f_329",actionButton:"_actionButton_1mc8f_338",hasShortKeys:"_hasShortKeys_1mc8f_351",actionShortcut:"_actionShortcut_1mc8f_360",actionShortcutFixKerning:"_actionShortcutFixKerning_1mc8f_367"};var Ze={};z(Ze,{enUS:()=>vg,nlNL:()=>Sg});var vg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},Sg={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};import{jsx as Yt,jsxs as bg}from"react/jsx-runtime";var xg=({src:t,title:e})=>{let o=v("CommandPalette",Q),[n,s]=_g("loading"),r=T(Ze);return bg("div",{className:o.image,children:[Yt("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:Vs(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&Yt("span",{className:Vs(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&Yt("span",{className:Vs(o.imageSrc,o.imageSrcStatus),children:Yt(Io,{})}),e&&Yt("span",{className:o.imageTitle,children:e})]})},Ca=xg;import Cg from"react";import wg from"classnames";import{jsx as wa,jsxs as Tg}from"react/jsx-runtime";function qs({children:t,heading:e,orientation:o}){let n=v("CommandPalette",Q);return Cg.Children.count(t)===0?null:Tg("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&wa("h4",{className:n.listHeading,children:e}),wa("div",{className:wg(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}import hn from"classnames";import{Interweave as Ug}from"interweave";import Eg,{useState as Ta,useEffect as Ea,useMemo as kg,useRef as ka,useCallback as Rg,useContext as Ig}from"react";import Pg from"classnames";var Ws={root:"_root_1oh4w_1",trigger:"_trigger_1oh4w_5",content:"_content_1oh4w_19",contentOpen:"_contentOpen_1oh4w_33",contentTop:"_contentTop_1oh4w_37",contentBottom:"_contentBottom_1oh4w_41",item:"_item_1oh4w_45"};import{jsx as mn,jsxs as Ng}from"react/jsx-runtime";var Ag=0,Ra=Eg.createContext(null),Lg=()=>{let t=Ig(Ra);if(!t)throw new Error("Invalid DropdownContext");return t},Ia=({trigger:t,children:e,position:o="bottom"})=>{let n=kg(()=>++Ag,[]),s=ka(null),r=ka(null),i=v("Dropdown",Ws),[a,l]=Ta(!1),[c,p]=Ta(o),d=g=>{g.preventDefault(),g.stopPropagation(),l(!a)},u=Rg(([g])=>{!g.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return Ea(()=>{let g=m=>{s.current&&!s.current.contains(m.target)&&l(!1)};return document.addEventListener("click",g),()=>{document.removeEventListener("click",g)}},[]),Ea(()=>{if(!r.current&&!a)return()=>{};let g=new IntersectionObserver(u,{root:null,rootMargin:"0px",threshold:1});return r.current&&g.observe(r.current),()=>{r.current&&g.unobserve(r.current)}},[r,a]),mn(Ra.Provider,{value:{setIsOpen:l},children:Ng("div",{ref:s,className:i.root,children:[mn("button",{id:`dropdown-${n}`,"data-testid":"dropdown-trigger","aria-haspopup":"true","aria-expanded":a,"aria-label":"Dropdown trigger",type:"button",className:i.trigger,onClick:d,children:t}),mn("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:Pg(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function Mg({as:t,children:e,onClick:o,...n}){let s=t||"button",r=v("Dropdown",Ws),{setIsOpen:i}=Lg(),a=l=>{i(!1),o(l),l.stopPropagation()};return mn(s,{type:"button",className:r.item,onClick:a,...n,children:e})}Ia.Item=Mg;var Gs=Ia;import{jsx as Pa}from"react/jsx-runtime";var Aa=t=>Pa("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:Pa("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 Qe={};z(Qe,{enUS:()=>Og,nlNL:()=>Dg});var Og={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"}]},Dg={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{jsx as $s}from"react/jsx-runtime";var Hg="%0d%0a%0d%0a%0d%0a",Bg=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(Hg)}`},Fg=({suggestion:t,onFeedback:e})=>{let o=T(Qe),n=C("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:$s(Gs,{trigger:$s(Aa,{"data-testid":"feedback-dropdown-trigger"}),children:$s(Gs.Item,{as:"a",href:Bg(n,t),onClick:e,children:o("giveFeedback")})})},fn=Fg;import Xs from"react";import{jsx as Kg}from"react/jsx-runtime";var La=Xs.createContext(void 0);function De(){let t=Xs.useContext(La);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Ma=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=Xs.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return Kg(La.Provider,{value:i,children:t})};import{jsx as He,jsxs as Zs}from"react/jsx-runtime";function Qs({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onFeedback:s,onSourceClick:r,index:i,description:a,sources:l,styles:c,...p}){let{selected:d,setSelected:u,onChangeOpen:g}=De(),m=v("CommandPalette",Q);function f(h){n(h),t&&g(!1)}return Zs("div",{className:hn(m.listItem,d===i&&m.listItemSelected),children:[He("button",{onMouseEnter:()=>u(i),type:"button",className:hn("command-palette-list-item",m.listItemAction,m.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:f,...p,children:Zs("div",{className:m.listItemContent,children:[typeof o=="string"?He("p",{className:hn(m.listItemText,m.truncate,c==null?void 0:c.title),children:o}):o,a&&He(Ug,{tagName:"p",allowList:[],content:bt(a)?Sa(a):a,className:hn(m.listItemDescription,c==null?void 0:c.description,e?m.lineClamp:m.truncate)})]})}),s&&d===i&&He("div",{className:m.listItemActions,children:He(fn,{suggestion:String(o),onFeedback:s})}),l&&Zs("div",{className:m.sources,children:[He("span",{className:m.sourcesTitle,children:"Sources"}),l.map(h=>h.url?He("a",{className:m.source,href:h.url,target:"_blank",title:h.url,rel:"noopener noreferrer",onClick:()=>r&&r(h),children:h.name},h.url):He("span",{className:m.source,children:h.name},h.name))]})]})}import{jsx as Na,jsxs as Js}from"react/jsx-runtime";function Ys({children:t,title:e,id:o,onDismiss:n}){let s=T(Ze),r=v("CommandPalette",Q),{page:i}=De();return i!==o?null:Js("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&Js("div",{className:r.pageNav,children:[Js("button",{className:r.pageBackButton,type:"button",onClick:n,children:[Na(an,{}),s("back")]}),e&&Na("h3",{className:r.pageTitle,children:e})]}),t]})}import{Fragment as Jg,useCallback as Yg,useEffect as em,useRef as tm}from"react";var yn=()=>/Mac/i.test(navigator.platform);import{createAsyncThunk as Wg,createSlice as Gg}from"@reduxjs/toolkit";var jg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},E=jg;import{createAsyncThunk as tr,createSlice as Vg}from"@reduxjs/toolkit";function zg(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function A(t){return Array.isArray(t)?t.map(A):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[zg(o)]:A(t[o])}),{}):t}function er(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function K(t){return Array.isArray(t)?t.map(K):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[er(o)]:K(t[o])}),{}):t}var qg={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},to=t=>{var e,o,n;return{timezone:((e=t.info.visitorInfo)==null?void 0:e.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((o=t.info.agentInfo)==null?void 0:o.agentNickname)||"",visitorName:((n=t.info.visitorInfo)==null?void 0:n.visitorName)||""}},eo=tr("info/setAgentInfo",async(t,e)=>{let{deepdeskAPI:o}=e.extra;if(!t.agentId&&!t.agentNickname)throw new Error("At least provide agentId or agentNickname");let n=await o.client.get("/apis/admin/session/me/",{version:null}),s={};return n.external_id||(s.external_id=t.agentId),n.nickname||(s.nickname=t.agentNickname),!s.external_id&&!s.nickname?A(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),A(n))}),or=tr("info/setAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.client.get("/apis/admin/session/me/",{version:null}),s={...typeof n.ui_config=="object"?n.ui_config:{},...t};return await o.client.patch("/apis/admin/session/me/",{ui_config:s}),s}),nr=tr("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),Oa=t=>t.info.agentInfo,Da=Vg({name:"info",initialState:qg,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(eo.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(eo.rejected,e=>{e.fetchState="error"}).addCase(eo.fulfilled,(e,o)=>{e.fetchState="done",e.agentInfo={...e.agentInfo,...o.meta.arg,agentId:o.payload.externalId||o.meta.arg.agentId||"",agentNickname:o.payload.nickname||o.meta.arg.agentNickname||""}}).addCase(or.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(nr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(L,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Ha}=Da.actions,Ba=Da.reducer;var vn={list:[],fetchState:"idle",isOpen:!1,page:"search"},Fa=t=>t.search.isOpen,Ka=t=>t.search.page,Ua=t=>t.search.list;function ja(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Je=Wg("search/getAll",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r}=await o.search({profile:s,query:t.query,filters:{type:t.type},params:to(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),za=Gg({name:"search",initialState:vn,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=vn.fetchState,t.list=vn.list}},extraReducers:t=>{t.addCase(Je.pending,e=>{e.fetchState="loading"}).addCase(Je.rejected,(e,o)=>{e.fetchState="error",E.error(o.error)}).addCase(Je.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(L,()=>vn)}}),{resetSearch:Sn,setIsOpen:W,setPage:G}=za.actions,Va=za.reducer;var $g=/(https?:\/\/[^\s]+)/,_n=t=>t.split(" ").find(e=>$g.test(e));import qa from"classnames";import{jsx as Zg,jsxs as Qg}from"react/jsx-runtime";var Xg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=v("CommandPalette",Q);return Qg("button",{type:"button",...n,onClick:t,className:qa(s.actionButton,n.className,{[s.hasShortKeys]:e&&e.length>0}),children:[o,e&&e.map(r=>Zg("span",{className:qa(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},Ct=Xg;import{jsx as xn,jsxs as sr}from"react/jsx-runtime";var om=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=v("CommandPalette",Q),a=T(Ze),{selected:l,setSelected:c}=De(),p=r[l],d=p&&typeof p.text=="string"&&_n(p.text),u=tm(null);function g(x){if(!u.current)return;let b=u.current.querySelectorAll(".command-palette-list-item"),_=0,I=0;x==="down"?(b.forEach(($,P)=>{P===l&&(_=P)}),I=_===b.length-1?0:_+1):x==="up"?(b.forEach(($,P)=>{P===l&&(_=P)}),I=_?_-1:b.length-1):c(0);let N=b[I];N&&typeof I=="number"&&(c(I),N.scrollIntoView&&N.scrollIntoView({behavior:"smooth",block:I?"center":"end"}))}function m(){if(!u.current)return;let x=u.current.querySelectorAll(".command-palette-list-item"),b=0;x.forEach((I,N)=>{N===l&&(b=N)});let _=x[b];_&&_.click()}let f=()=>{d&&window.open(d,"_blank")},h=()=>{p&&n(p,l)},w=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},y=Yg(x=>{if(x.key==="Enter"&&x.altKey&&d){f();return}if(x.key==="Enter"&&x.shiftKey){w();return}if(x.key==="ArrowDown"){x.preventDefault(),x.stopPropagation(),g("down");return}if(x.key==="ArrowUp"){x.preventDefault(),x.stopPropagation(),g("up");return}x.key==="Enter"&&l!==-1&&(x.preventDefault(),x.stopPropagation(),m())},[l]);return em(()=>(window.addEventListener("keyup",y),()=>{window.removeEventListener("keyup",y)}),[y]),sr("div",{className:i.actions,children:[xn("div",{className:i.actionsWrapper,ref:u,children:t}),sr("div",{className:i.actionsBar,children:[d&&xn(Ct,{onClick:f,shortKeys:[yn()?8997:"ALT",8629],children:a("visitUrl")}),p&&sr(Jg,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&xn(Ct,{onClick:w,shortKeys:[8679,8629],children:o}),xn(Ct,{onClick:h,shortKeys:[8629],children:e})]})]})]})},Ga=om;import{forwardRef as sm}from"react";import{jsx as $a,jsxs as nm}from"react/jsx-runtime";var wt=()=>nm("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[$a("path",{d:"M0 0h24v24H0z",fill:"none"}),$a("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 Tt,jsxs as rr}from"react/jsx-runtime";function rm({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=v("CommandPalette",Q);return rr("div",{className:l.search,children:[Tt("div",{className:l.searchIcon,children:Tt(wt,{})}),rr("div",{className:l.searchInputWrapper,children:[Tt("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:c=>{t(c.currentTarget.value)},onFocus:c=>{c.currentTarget.select()},className:l.searchInput,placeholder:o,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&Tt("div",{className:l.selectWrapper,children:rr("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:c=>e(c.target.value===n?void 0:c.target.value),value:i||n,children:[n&&Tt("option",{children:n}),s.map(c=>Tt("option",{value:c.value,children:c.label},c.value))]})})]})]})}var Xa=sm(rm);import{jsx as Za,jsxs as cm}from"react/jsx-runtime";function Ye({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:o="search",page:n,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:l,types:c,children:p,isOpen:d,search:u}){let[g,m]=am(0),f=lm(null),h=()=>{s&&s(o),i(void 0),r(""),a(!1)},w=()=>{var y;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(y=f.current)==null||y.focus();return}if(u.length>0){r("");return}a(!1)};return im(()=>{m(0)},[u,n]),Za(yt,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:w,onClose:h,children:cm(Ma,{selected:g,setSelected:m,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&Za(Xa,{ref:f,onChange:r,onChangeType:i,placeholder:t,value:u,selectedType:l,types:c,typePlaceholder:e}),p]})})}Ye.Page=Ys;Ye.List=qs;Ye.Image=Ca;Ye.ListItem=Qs;Ye.ActionsBar=Ga;Ye.Button=Ct;var k=Ye;import{jsx as be,jsxs as oo}from"react/jsx-runtime";var um=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=v("EditSuggestionForm",Ui),l=pm(),c=T(Es),p=dm(m=>m.overlayInput.text);Qa(()=>{t&&(l(Z.actions.reset()),l(Z.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(Z.actions.commitSuggestion()))},[t]);let d=m=>{m.preventDefault(),u(p)},u=m=>{l(Vo(m)),e(m)},g=m=>f=>{p!==i?window.confirm(c("warning"))&&m(f):m(f)};return Qa(()=>{n&&n(p!==i)},[n,t,p]),oo("div",{className:a.root,children:[oo("div",{className:a.content,children:[t.title&&be("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&be(vs,{labels:t.searchKeywords}),be(ba,{onUse:u,value:va(p)})]}),oo("form",{className:a.actions,onSubmit:d,children:[oo("div",{children:[be("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&g(r),children:be(an,{})}),be("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&g(s),children:be(Yi,{})})]}),oo("div",{className:a.primaryButtons,children:[be(k.Button,{onClick:g(o),shortKeys:["esc"],children:c("dismiss")}),be(k.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},bn=um;import{createAction as fm,createAsyncThunk as tl,createSlice as hm}from"@reduxjs/toolkit";var gm=["{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}"],mm=new RegExp(gm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Ja(t,e){let o=t.split(mm),n=0,s=[];for(let r=0;r<o.length;r++){let i=o[r];if(s.push(i),r===o.length-1)break;if(e.indexOf(i)===-1)return t;let a=o[r+1],l=r===o.length-2;n+=i.length;let c=n;if(l){let d=a.charAt(0),u=0;do c=d?e.indexOf(d,c+1):-1,u+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&u>2)return t}else c=a&&a!==""?e.indexOf(a,n):-1;let p=c===-1?e.slice(n):e.slice(n,c);s.push(p),n=c}return s.join("")}function Ya(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var ol={suggestions:[],fetchState:"idle",isInitialRequest:null},el={default:ol},Cn=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},nl=t=>{let e=Object.keys(t.textSuggestions).map(o=>{var n;return(n=t.textSuggestions[o])==null?void 0:n.fetchState});return e.length===0?!0:e.every(o=>o!=="done")},Be=t=>t.textSuggestions,sl=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},wn=fm("textSuggestions/refresh"),ce=tl("textSuggestions/recommendations",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,inlineSuggestions:i}=n.settings,a=ht(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,to(n),t);if(t==="default"){let p=i?l.filter(sl(a)):l;e.dispatch(ge(p.slice(0,r)))}return l}),no=tl("textSuggestions/autocompletions",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,deanonymize:i,inlineSuggestions:a}=n.settings;if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getAutocompleteSuggestions(s,{...to(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(sl(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?Ja(p.text,t):p.text}))),l=Ya(l,r),e.dispatch(ge(l)),l}),rl=hm({name:"textSuggestions",initialState:el,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:o}=e.payload;t[o].fetchState="done",t[o].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}},setSuggestionState(t,e){return e.payload}},extraReducers:t=>{t.addCase(ce.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||ol;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(ce.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(ce.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(no.pending,e=>{e.default.fetchState="loading"}).addCase(no.rejected,e=>{e.default.fetchState="error"}).addCase(no.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(L,()=>el)}}),{setTextSuggestions:il,setSuggestionState:al}=rl.actions,ll=rl.reducer;import{createSlice as ym}from"@reduxjs/toolkit";var cl={contentType:null,suggestion:null},pl=t=>t.activeSuggestion.suggestion,dl=t=>t.activeSuggestion.contentType,ul=ym({name:"activeSuggestion",initialState:cl,reducers:{setActiveSuggestion(t,e){let{contentType:o,suggestion:n}=e.payload;t.contentType=o,t.suggestion=n},resetActiveSuggestion(t){t.contentType=null,t.suggestion=null}},extraReducers:t=>{t.addCase(L,()=>cl)}}),{setActiveSuggestion:Ce,resetActiveSuggestion:ir}=ul.actions,gl=ul.reducer;var ar={};z(ar,{enUS:()=>vm,nlNL:()=>Sm});var vm={warning:[{type:0,value:"Are you sure you want to discard the message?"}],editContentLabel:[{type:0,value:"Edit and view suggestion"}],overlayLabel:[{type:0,value:"Close dialog"}]},Sm={warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}],editContentLabel:[{type:0,value:"Bewerk en bekijk suggestie"}],overlayLabel:[{type:0,value:"Sluit"}]};import{createSlice as _m}from"@reduxjs/toolkit";var xm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Tn=({ui:t})=>t.overlayCollapsed;var ml=_m({name:"ui",initialState:xm,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputHasFocus(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:so,setInputHasFocus:Et,setOverlayCollapsed:Fe,setOpenOverlayWhenTyping:fl,setOverlayCollapsedUserOverwrite:hl}=ml.actions,yl=ml.reducer;import vl,{useContext as bm}from"react";import{jsx as Cm}from"react/jsx-runtime";var Sl=vl.createContext(null),et=({broadcastEvents:t,children:e})=>{let o=vl.useMemo(()=>t,[]);return Cm(Sl.Provider,{value:o,children:e})},se=()=>{let t=bm(Sl);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import{createAsyncThunk as lr,createSlice as wm}from"@reduxjs/toolkit";var Tm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},oe=t=>t.auth.isLoggedIn,_l=t=>t.auth.loginFetchState,xl=t=>t.auth.verifyFetchState,bl=t=>t.auth.showLoginOverlay,we=lr("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),Cl=lr("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),ro=lr("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),wl=wm({name:"auth",initialState:Tm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(we.pending,e=>{e.loginFetchState="loading"}),t.addCase(we.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(we.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(ro.pending,e=>{e.verifyFetchState="loading"}),t.addCase(ro.rejected,e=>{e.verifyFetchState="error"}),t.addCase(ro.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:kt,setShowLoginOverlay:Tl}=wl.actions,El=wl.reducer;var cr="SetActiveSuggestion",Rt="ShowLoginOverlay",io="UserLoggedIn",Em="UserLoggedOut",Te="ApplySuggestion",pr="ApplyImageSuggestion",km="ShowCommandPalette",Rm=t=>({[cr]:e=>{t.dispatch(al(e.state)),t.dispatch(Ce({contentType:e.contentType,suggestion:e.suggestion}))},[km]:e=>{t.dispatch(W(e.isOpen)),e.page&&t.dispatch(G(e.page))},[Rt]:e=>{t.dispatch(Tl(e))},[io]:()=>{t.dispatch(we())},[Em]:()=>{t.dispatch(we())},[pr]:e=>{t.dispatch(Wo({suggestion:e.suggestion}))},[Te]:e=>{t.dispatch(ie({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(_e())}}),kl=Rm;import{jsx as Rl}from"react/jsx-runtime";var Am=()=>{var m;let[t,e]=Im(!1),o=dr(pl),n=dr(dl),s=dr(Be),r=Pm(),i=se(),a=T(ar),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(ir()),r(Et(!0)),r(Z.actions.reset())},p=(f,h)=>{r(ir()),r(Et(!0)),i.send(Te,{text:f,suggestion:{...h,source:`${h.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let d=(m=s[n])==null?void 0:m.suggestions.indexOf(o),u=d===0||d===null?void 0:()=>r(Ce({contentType:n,suggestion:s[n].suggestions[d-1]})),g=d===s[n].suggestions.length-1||d===null?void 0:()=>r(Ce({contentType:n,suggestion:s[n].suggestions[d+1]}));return Rl(yt,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:Rl(bn,{onTouched:e,onDismiss:c,onUse:f=>p(f,o),suggestion:o,onNext:g,onPrevious:u})})},Il=Am;import{useSelector as Nl}from"react-redux";import gr from"classnames";import{useCallback as Ll,useEffect as Hm,useMemo as Bm,useState as mr}from"react";import{useDispatch as Fm,useSelector as Km}from"react-redux";import Lm from"classnames";var Pl={root:"_root_1ukx5_1"};import{jsx as Nm}from"react/jsx-runtime";var Mm=({className:t,value:e,...o})=>{let n=v("TextInput",Pl);return Nm("input",{className:Lm(t,n.root),type:"text",value:e,...o})},ao=Mm;var ur={};z(ur,{enUS:()=>Om,nlNL:()=>Dm});var Om={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"}]},Dm={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 Al={root:"_root_1edpl_1",anchorButton:"_anchorButton_1edpl_5",errorMessage:"_errorMessage_1edpl_19",title:"_title_1edpl_25",subtitle:"_subtitle_1edpl_31",text:"_text_1edpl_38",input:"_input_1edpl_43",actions:"_actions_1edpl_48",button:"_button_1edpl_55",primaryButton:"_primaryButton_1edpl_70"};import{jsx as J,jsxs as En}from"react/jsx-runtime";var Um=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},jm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=T(ur),i=v("LoginTokenDialog",Al),a=Km(xl),l=Fm(),c=C("productName"),[p,d]=mr(t||""),[u,g]=mr(0),[m,f]=mr(""),h=Ll(async b=>{b.preventDefault(),l(Cl({email:p})),g(1)},[o,p]),w=()=>{f(""),g(0)},y=Ll(async b=>{b.preventDefault();let _=Um(b.target.elements.token.value);if(!_){f(r("verifyCodeError",{login:x}));return}l(ro({token:_}))},[o]),x=Bm(()=>b=>J("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:b},"back-button"),[]);return Hm(()=>{a==="error"&&f(r("verifyCodeError",{login:x})),a==="done"&&n()},[a]),J(yt,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:En("div",{className:i.root,children:[J("h1",{className:i.title,children:r("promptTitle",{productName:c})}),u===0&&En("form",{onSubmit:h,children:[J("h2",{className:i.subtitle,children:r("requestCodeTitle")}),J("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),J(ao,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:b=>d(b.target.value)}),J("div",{className:i.actions,children:J("button",{type:"submit",className:gr(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),u===1&&En("form",{onSubmit:y,children:[J("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),J("p",{className:i.text,children:r("verifyCodeBody")}),J(ao,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),m&&J("div",{className:i.errorMessage,children:m}),En("div",{className:i.actions,children:[J("button",{type:"button",className:gr(i.button),onClick:w,children:r("back")}),J("button",{type:"submit",className:gr(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},Ml=jm;import{jsx as Vm}from"react/jsx-runtime";var zm=()=>{let t=Nl(bl),e=Nl(Oa),o=C("adminUrl"),n=se(),s=()=>n.send(Rt,!1),r=()=>{n.send(Rt,!1),n.send(io)};return Vm(Ml,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},Ol=zm;import Vf from"lodash.debounce";import{useCallback as Ln,useEffect as xr,useState as mo}from"react";import{useDispatch as qf,useSelector as Lt}from"react-redux";import{createAsyncThunk as qm,createSlice as Wm}from"@reduxjs/toolkit";var Gm={data:null,fetchState:"idle"},Dl=t=>t.contentTypes.data,lo=qm("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),$m=Wm({name:"contentTypes",initialState:Gm,reducers:{},extraReducers:t=>{t.addCase(lo.pending,e=>{e.fetchState="loading"}).addCase(lo.rejected,e=>{e.fetchState="error"}).addCase(lo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Hl=$m.reducer;function co(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 Xm}from"react";function Bl(t,e){Xm(()=>{let o=n=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?n.metaKey:n.ctrlKey)&&n.key===t&&(n.preventDefault(),n.stopPropagation(),e())};return document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o)}},[])}import{useEffect as jl,useRef as of}from"react";import{useSelector as nf,useDispatch as sf}from"react-redux";import{createAsyncThunk as Zm,createSlice as Qm}from"@reduxjs/toolkit";var Fl={data:null,fetchState:"idle"},kn=t=>{var r;let e=[],{visitorName:o}=t.info.visitorInfo??{},{agentName:n,agentNickname:s}=t.info.agentInfo??{};return n&&n!==o&&e.push(n),s&&s!==o&&e.push(s),((r=t.entities.data)==null?void 0:r.filter(i=>!e.includes(i.text)))??null},pe=Zm("entities/getEntities",async(t,e)=>{let{deepdeskAPI:o,dynamicThunkObject:n}=e.extra;if(!n.conversationQuery)return Promise.resolve([]);let s=n.conversationQuery,r=await s();return r.length===0?Promise.resolve([]):o.getEntities(r)}),Jm=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Ym=Qm({name:"entities",initialState:Fl,reducers:{},extraReducers:t=>{t.addCase(pe.pending,e=>{e.fetchState="loading"}).addCase(pe.rejected,e=>{e.fetchState="error"}).addCase(pe.fulfilled,(e,o)=>{e.fetchState="done",e.data=Jm(e.data?[...e.data,...o.payload]:o.payload)}).addCase(L,()=>Fl)}}),Kl=Ym.reducer;var fr={};z(fr,{enUS:()=>ef,nlNL:()=>tf});var ef={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},tf={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Ul={root:"_root_17kae_1",empty:"_empty_17kae_5"};import{jsx as Rn,jsxs as af}from"react/jsx-runtime";var rf=({onCopy:t,onUse:e})=>{let o=of(null),n=v("EntitiesList",Ul),s=T(fr),r=nf(kn),i=sf();return jl(()=>{i(pe())},[]),jl(()=>{o.current&&o.current.focus()},[o]),af("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&Rn(k.ActionsBar,{primaryLabel:s("copy"),secondaryLabel:s("use"),onPrimary:(a,l)=>t(r[l]),onSecondary:(a,l)=>e(r[l]),list:r.map(a=>({text:a.text,type:a.label,primaryAction:"copy",secondaryAction:"use"})),children:Rn(k.List,{children:r.map((a,l)=>Rn(k.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&Rn("p",{className:n.empty,children:s("noResults")})]})},zl=rf;import{Fragment as gf,useEffect as In,useRef as mf,useState as ff}from"react";import{useSelector as Xl,useDispatch as hf}from"react-redux";import{createAsyncThunk as lf,createSlice as cf}from"@reduxjs/toolkit";var Vl={data:null,fetchState:"idle"},ql=t=>t.summary.data,Wl=t=>t.summary.fetchState==="error",Ee=lf("summary/getSummary",async(t,e)=>{let o=e.getState().profile.data;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:n,dynamicThunkObject:s}=e.extra;if(!s.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let r=s.conversationQuery,i=await r();if(i.length===0)return Promise.reject(new Error("No messages are included"));let a=await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return a?{summary:a}:Promise.reject(new Error("Summary is not provided"))}),pf=cf({name:"summary",initialState:Vl,reducers:{},extraReducers:t=>{t.addCase(Ee.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(Ee.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(Ee.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(L,()=>Vl)}}),Gl=pf.reducer;var hr={};z(hr,{enUS:()=>df,nlNL:()=>uf});var df={copy:[{type:0,value:"Copy"}],error:[{type:0,value:"Could not generate a summary"}],loading:[{type:0,value:"Generating summary, this may take a few moments."}]},uf={copy:[{type:0,value:"Kopieer"}],error:[{type:0,value:"Kon helaas geen samenvatting genereren."}],loading:[{type:0,value:"Samenvatting wordt gemaakt, dit kan even duren."}]};var $l={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};import{jsx as It,jsxs as vf}from"react/jsx-runtime";var yf=({onCopy:t})=>{let e=mf(null),o=v("SummaryForm",$l),[n,s]=ff(""),r=T(hr),i=Xl(ql),a=Xl(Wl),l=hf(),c=()=>{l(V({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let d=document.getSelection();d&&l(V({name:"summary copied to clipboard",data:{originalText:i,finalText:d==null?void 0:d.toString()},options:{includeConversationData:!0}}))};return In(()=>{l(Ee())},[]),In(()=>{s(i||"")},[i]),In(()=>{e.current&&i&&e.current.focus()},[e,i]),In(()=>{let d=u=>{u.key==="Enter"&&u.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[n]),It("div",{className:o.root,tabIndex:-1,children:a?It("p",{className:o.error,children:r("error")}):vf(gf,{children:[It("div",{className:o.main,children:It("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:d=>s(d.target.value)})}),It("div",{className:o.actions,children:It(k.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},Zl=yf;var po={};z(po,{enUS:()=>Sf,nlNL:()=>_f});var Sf={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link 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"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],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?"}]},_f={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:"Link 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"}],summaryClipboard:[{type:0,value:"Gesprek samenvatten"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],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 Lf,{useEffect as Sr,useRef as Mf}from"react";import{useDispatch as Nf,useSelector as rc}from"react-redux";var yr={};z(yr,{enUS:()=>xf,nlNL:()=>bf});var xf={use:[{type:0,value:"Use"}],loading:[{type:0,value:"Loading..."}],error:[{type:0,value:"Something went wrong, please try again later."}],anotherQuestion:[{type:0,value:"Send a message..."}],reset:[{type:0,value:"Reset conversation"}]},bf={use:[{type:0,value:"Gebruik"}],loading:[{type:0,value:"Laden..."}],error:[{type:0,value:"Er ging iets mis, probeer het later opnieuw."}],anotherQuestion:[{type:0,value:"Stuur een bericht..."}],reset:[{type:0,value:"Reset gesprek"}]};var Ql={root:"_root_1g4pq_1",title:"_title_1g4pq_9",empty:"_empty_1g4pq_20",status:"_status_1g4pq_24",form:"_form_1g4pq_30",input:"_input_1g4pq_43",submit:"_submit_1g4pq_55",question:"_question_1g4pq_63",answer:"_answer_1g4pq_67",alignRight:"_alignRight_1g4pq_73"};import{createAction as kf,createAsyncThunk as Rf,createSlice as If}from"@reduxjs/toolkit";import{createAsyncThunk as Cf,createSlice as wf}from"@reduxjs/toolkit";var Tf={data:null,fetchState:"idle"},Jl=t=>{var e;return(e=t.knowledgeAssistant)==null?void 0:e.data},uo=Cf("knowledgeAssistant/getKnoeledgeAssistant",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");let r=(i=n.profile.data)==null?void 0:i.knowledgeAssistant;return r?o.getKnowledgeAssistant(r):null}),Ef=wf({name:"knowledgeAssistant",initialState:Tf,reducers:{},extraReducers:t=>{t.addCase(uo.pending,e=>{e.fetchState="loading"}).addCase(uo.rejected,e=>{e.fetchState="error"}).addCase(uo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Yl=Ef.reducer;var vr={data:[],fetchState:"idle"},ec=t=>{var e;return(e=t.answer)==null?void 0:e.data},tc=t=>t.answer.fetchState,At=kf("answer/resetKnowledgeSearch"),Pt=Rf("answer/getAnswer",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=Jl(e.getState());if(!s)throw new Error("KnowledgeAssistant is not defined");let r=await o.knowledgeAssist({promptInstruction:s.prompt,question:t},n,s.code);return{question:t,answer:r}}),Pf=If({name:"answer",initialState:vr,reducers:{},extraReducers:t=>{t.addCase(Pt.pending,e=>{e.fetchState="loading"}).addCase(Pt.rejected,e=>{e.fetchState="error"}).addCase(Pt.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(L,()=>vr).addCase(At,()=>vr)}}),oc=Pf.reducer;import{jsx as nc,jsxs as Af}from"react/jsx-runtime";var sc=()=>Af("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[nc("title",{id:"paperPlaneTitle",children:"PaperPlane"}),nc("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});import{jsx as ke,jsxs as _r}from"react/jsx-runtime";var Of=({onUse:t,onResetQuestion:e,question:o})=>{let[n,s]=Lf.useState(""),{setSelected:r}=De(),i=Mf(null),a=v("EntitiesList",Ql),l=T(yr),c=Nf(),p=rc(ec),d=rc(tc),u=async m=>{m.preventDefault(),m.stopPropagation(),n!==""&&c(Pt(n))},g=(m,f)=>{c(V({name:"knowledge assist source viewed",data:{question:f,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return Sr(()=>{var m;o&&d==="idle"?c(Pt(o)):(m=i.current)==null||m.focus()},[i,d]),Sr(()=>{d==="done"&&(c(V({name:"knowledge assist question answered",data:{question:n||o,sources:p[p.length-1].answer.sources,answer:p[p.length-1].answer.answer,isFollowUpQuestion:p.length>1},options:{includeConversationData:!0}})),r(p.length-1),s(""))},[d,p]),Sr(()=>{i.current&&i.current.scrollIntoView({behavior:"smooth"})},[i,p]),_r("div",{className:a.root,children:[p.length>0&&ke("div",{className:a.alignRight,children:ke(k.Button,{onClick:e,children:l("reset")})}),_r(k.ActionsBar,{list:p.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:l("use"),onPrimary:m=>t(m.text),children:[p.map(({question:m,answer:f},h)=>ke(k.List,{children:ke(k.ListItem,{"data-testid":"knowledge-search-answer",index:h,description:f.answer,closeOnSelect:!0,onClick:()=>t(f.answer),onSourceClick:w=>g(w,m),sources:f.sources,styles:{title:a.question,description:a.answer},children:m})},`${f.answer}_${h}`)),d==="loading"&&ke("p",{className:a.status,children:l("loading")}),d==="error"&&ke("p",{className:a.status,children:l("error")}),_r("form",{className:a.form,onSubmit:u,children:[ke("input",{ref:i,placeholder:l("anotherQuestion"),className:a.input,type:"text",value:n,onFocus:()=>{r(-1)},onChange:m=>{r(-1),s(m.target.value)}}),ke("button",{type:"submit",className:a.submit,children:ke(sc,{})})]})]})]})},ic=Of;import{createAsyncThunk as Df,createSlice as Hf}from"@reduxjs/toolkit";var Bf={data:null,fetchState:"idle"},Ke=t=>t.profile.data,Pn=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],go=Df("profile/getProfile",async(t,e)=>{var r;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");return((r=n.profile.data)==null?void 0:r.code)===s.profileCode?n.profile.data:o.getProfile(s.profileCode)}),Ff=Hf({name:"profile",initialState:Bf,reducers:{},extraReducers:t=>{t.addCase(go.pending,e=>{e.fetchState="loading"}).addCase(go.rejected,e=>{e.fetchState="error"}).addCase(go.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),ac=Ff.reducer;import{useEffect as Kf}from"react";import{useDispatch as Uf}from"react-redux";import{useSelector as lc}from"react-redux";import{jsx as An,jsxs as zf}from"react/jsx-runtime";var jf=({commands:t,onClick:e,onEdit:o})=>{var p,d,u;let n=Uf(),s=T(po),r=lc(Ke),i=lc(Be),a=((u=(d=(p=r==null?void 0:r.uiConfig)==null?void 0:p.search)==null?void 0:d.initialTypes)==null?void 0:u.filter(({isActive:g})=>g))||[],l=0,c=a.map(({type:g})=>{var m;return(m=i[g])==null?void 0:m.suggestions.map(f=>({text:f.text||f.url||f.message,type:g}))}).flat(1);return Kf(()=>{a.forEach(({type:g})=>{(!i[g]||i[g].suggestions.length===0)&&n(ce(g))})},[]),zf(k.ActionsBar,{list:[...t.map(g=>({text:g.label,type:"command"})),...c],primaryLabel:s("use"),secondaryLabel:s("preview"),onPrimary:({text:g},m)=>e(g,c[m]),onSecondary:(g,m)=>{let f=m-t.length;o(c[f],i[c[f].type].suggestions)},children:[t.length>0&&An(k.List,{heading:s("commands"),children:t.map((g,m)=>An(k.ListItem,{index:m,closeOnSelect:!1,onClick:g.onClick,children:g.label},g.label))}),a.map(({type:g,title:m})=>{var f;return An(k.List,{heading:m,orientation:"vertical",children:(f=i[g])==null?void 0:f.suggestions.map(h=>(l++,An(k.ListItem,{index:l+t.length-1,closeOnSelect:!1,description:h.text,onClick:()=>e(h.text,h),"data-testid":"search-overlay-suggestion",children:h.title},`${h.id}-${h.text}`)))},g)})]})},cc=jf;import{jsx as Y,jsxs as br}from"react/jsx-runtime";var Wf=200,Gf=5,$f=4,Xf=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),pc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Zf=()=>{let t=qf(),e=se(),o=T(po),[n,s]=mo(!1),[r,i]=mo(""),a=Lt(Ka),l=Lt(Ke),[c,p]=mo(null),[d,u]=mo([]),[g,m]=mo(),f=Lt(oe),h=C("showSearch"),w=C("showEntitiesCommand"),y=C("showSummaryCommand"),x=C("showKnowledgeSearch"),b=C("showImageSearch"),_=C("searchTriggerKey"),I=Lt(Dl),N=Lt(Ua),$=Lt(Fa),P=S=>cs(N.filter(O=>O.type===S.toUpperCase()),S),X=[{value:"PERSONAL",label:o("personalSuggestions"),list:P("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:P("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:P("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:P("IMAGE"),listOrientation:"horizontal",shouldShow:b}].filter(S=>S.shouldShow),R=[{label:o("entitiesClipboard"),onClick:()=>t(G("entities")),shouldShow:w&&pc(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(G("summary")),shouldShow:y&&pc(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(G("knowledgeAssist")),shouldShow:x}].filter(S=>S.shouldShow),B=(I==null?void 0:I.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:P(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],at=Ln(Vf((S,O)=>{t(Je({query:S,type:O,tags:["search-overlay"]}))},Wf),[]),Ut=Xf([...B,...X]),jt=Ln((S,O)=>{t(G("edit")),p({...S,searchTerm:void 0}),u(O)},[t,c,B]),To=Ln((S,O)=>{switch(O.type){case"IMAGE":e.send(pr,{suggestion:O});break;default:e.send(Te,{text:S,suggestion:O})}t(W(!1))},[t]),hd=S=>{co(S.text),t(V({name:"entity copied",data:{entity:S,type:"copy"}})),t(W(!1))},yd=Ln(S=>{t(V({name:"suggestion feedback",data:{text:S.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),vd=S=>{e.send(Te,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(V({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(G("search")),t(At()),t(W(!1))},Sd=S=>{co(S),t(W(!1))},_d=S=>{e.send(Te,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(W(!1))},xd=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),bd=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function cs(S,O){return S.slice(0,g?10:O.toLowerCase()==="image"?$f:Gf)}function ai(S,O,de){return O.reduce((Eo,ko)=>de&&g===de?ko.length+Eo:cs(ko,de).length+Eo,S)}function lt(S){return O=>{n?window.confirm(o("warning"))&&(S(O),s(!1)):S(O)}}return xr(()=>{r?at(r,g):t(Sn())},[r,g]),xr(()=>{a==="search"&&t(At())},[a]),xr(()=>{f&&t(lo())},[f]),Bl(_,()=>t(W(!0))),!h||!l?null:br(k,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:lt(S=>t(W(S))),onChangeType:S=>m(S),onChangePage:lt(S=>t(G(S))),selectedType:g,search:r,page:a,isOpen:$,types:[...B,...X],children:[br(k.Page,{id:"search",children:[r.length===0&&Y(cc,{commands:R,onClick:To,onEdit:jt}),r.length>0&&br(k.ActionsBar,{list:[...R.map(S=>({text:S.label,type:"command"})),...Ut.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},O)=>To(S,Ut[O]),onSecondary:(S,O)=>{let de=Ut[O-R.length];!de||!de.type||jt(de,P(de.type))},children:[R.length>0&&Y(k.List,{heading:o("commands"),children:R.map((S,O)=>Y(k.ListItem,{index:ai(O,[],"commands"),closeOnSelect:!1,onClick:S.onClick,children:S.label},S.label))}),[...B,...X].map(({value:S,label:O,list:de,lineClamp:Eo,listOrientation:ko},Cd)=>Y(k.List,{heading:O,orientation:ko==="horizontal"?"horizontal":"vertical",children:cs(de,S).map((ne,wd)=>Y(k.ListItem,{index:ai(R.length+wd,[...B,...X].slice(0,Cd).map(({list:Td})=>Td),S),closeOnSelect:!1,lineClamp:Eo,onClick:()=>To(ne.text,ne),description:S!=="IMAGE"?ne.title&&ne.text:void 0,onFeedback:S!=="IMAGE"?()=>yd(ne):void 0,children:S==="IMAGE"?Y(k.Image,{title:ne.title||ne.text,src:ne.image}):ne.title||ne.text},`${ne.id}-${ne.text}`))},S))]})]}),Y(k.Page,{id:"edit",onDismiss:lt(()=>{t(G("search")),p(null)}),children:c&&Y(bn,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(G("search")),p(null),u([])},onNext:bd,onPrevious:xd,onUse:S=>{t(G("search")),To(S,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(W(!1)),u([]),p(null)}})}),Y(k.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:lt(()=>{t(G("search"))}),children:Y(zl,{onUse:_d,onCopy:hd})}),Y(k.Page,{id:"summary",title:o("summaryTitle"),onDismiss:lt(()=>{t(G("search"))}),children:Y(Zl,{onCopy:Sd})}),Y(k.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:lt(()=>{t(At()),t(G("search"))}),children:Y(ic,{question:r,onUse:vd,onResetQuestion:()=>{t(At()),i("")}})})]})},dc=Zf;import{jsx as Cr,jsxs as Yf}from"react/jsx-runtime";var Jf=()=>{let t=C("showSearch"),e=C("isEmbedded");return Yf(Qf,{children:[t&&Cr(dc,{}),Cr(Il,{}),e&&Cr(Ol,{})]})},uc=Jf;import{useEffect as hh,useRef as yh}from"react";import{connect as vh,useDispatch as Sh,useSelector as On}from"react-redux";function Mt(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:o,showSuggestionsAfterPattern:n}=t.settings,{text:s,selection:r}=t.input.userCommitted;return r.start!==r.end?!1:r.end>=s.length?!0:e?o&&new RegExp(o).test(s.substring(r.end))||n&&new RegExp(n).test(s.substring(0,r.end))?!0:o===!1&&n===!1:!1}import{Fragment as gh,useMemo as mh}from"react";import{Interweave as oh}from"interweave";import{useEffect as nh,useMemo as sh,useRef as rh}from"react";import{useDispatch as ih,useSelector as ah}from"react-redux";import{useEffect as eh}from"react";function gc(t,e,o){eh(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var mc={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};import{jsx as Mn,jsxs as uh}from"react/jsx-runtime";var lh=["search","personal-collection-search","search-autocomplete"];function ch(t,e,o,n={}){let s="";return lh.includes(e)?s=ha(Us(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=Us(t,o,n),n.placeholders===!0&&(s=ya(s)),s}var ph=()=>{},dh=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=C("inlineSuggestions"),r=ah(ht),i=ih(),a=v("TextSuggestion",mc),l=rh(null);nh(()=>{let p=setTimeout(()=>{i(Ii({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),gc(l,"click",()=>{i(Me(t)),i(ie({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=sh(()=>ch(o.text,o.source,r,{stripAgentPart:s,placeholders:!0,searchKeywords:o.searchKeywords}),[s,o.text,o.source,r,o.searchKeywords]);return o.source==="gpt"&&!s?null:uh("div",{className:a.root,onMouseEnter:()=>i(Me(t)),children:[Mn(D,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:ph,children:Mn(oh,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&Mn("div",{className:a.actions,children:Mn(fn,{onFeedback:()=>n(o),suggestion:o.text})})]})},fc=dh;import{jsx as hc}from"react/jsx-runtime";var fh=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=mh(()=>{let r=e.map((i,a)=>hc(fc,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return hc(gh,{children:s})},Nn=fh;var yc={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};import{jsx as Dn}from"react/jsx-runtime";var _h=({textSuggestions:t,selectedIndex:e})=>{let o=yh(null),n=v("InlineSuggestionsOverlay",yc),s=On(Mt),r=Sh(),i=On(oe),a=On(ft),l=On(Tn),c=C("showTextSuggestions");return St(()=>{r(Fe({collapse:!0,skipWhenInputFocus:!0}))}),hh(()=>{let p=o.current;if(!p||!p.parentElement)return;p.parentElement.style.left="0px";let d=p.getBoundingClientRect();p.parentElement.style.left=`${Math.min(window.innerWidth-4-d.right,0)}px`}),l||!s||!c||t.length===0||i!==!0||a===!1?null:Dn("div",{className:n.root,"data-variant":"inline",children:Dn("div",{ref:o,className:n.paper,children:Dn(re,{children:Dn(Nn,{suggestions:t,selectedIndex:e})})})})},xh=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),vc=vh(xh)(_h);import Rr from"classnames";import{useEffect as Mh,useRef as Nh,useState as Oh}from"react";import{connect as Dh,useDispatch as Hh,useSelector as fo}from"react-redux";import{useState as bh}from"react";function Sc(t,e){let[o,n]=bh(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return E.error(r),e}});return[o,r=>{try{let i=r instanceof Function?r(o):r;n(i),typeof window<"u"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){E.error(i)}}]}import Th from"classnames";import{Fragment as Eh,useCallback as Tr,useMemo as xc}from"react";var wr={};z(wr,{enUS:()=>Ch,nlNL:()=>wh});var Ch={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"}]}]},wh={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 _c={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};import{jsx as Hn,jsxs as bc}from"react/jsx-runtime";var Er=(t,e,o)=>n=>Hn("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),kh=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=T(wr),i=se(),a=v("Login",_c),l=C("productName"),c=Tr(h=>{h.preventDefault(),n&&n(parseInt(h.target.value,10))},[]),p=Tr(h=>{h.preventDefault(),i.send(Rt,!0)},[e]),d=xc(()=>h=>Hn("a",{onClick:y=>{y.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[e]),u=Tr(h=>Hn("button",{type:"button",className:a.anchorButton,onClick:p,children:h},"prompt"),[p]),{min:g,hour:m,day:f}=xc(()=>({min:Er(a,60*10,c),hour:Er(a,60*60,c),day:Er(a,60*60*12,c)}),[]);return bc("div",{className:Th(t,a.root),children:[r("loginPlease",{login:o?u:d,productName:l}),n&&bc(Eh,{children:[Hn("br",{}),r("snooze",{min:g,hour:m,day:f})]})]})},Bn=kh;import{useDispatch as Rh}from"react-redux";var Cc={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};import{jsx as wc,jsxs as Ph}from"react/jsx-runtime";var Ih=({title:t})=>{let e=v("SearchTrigger",Cc),o=Rh();return Ph("button",{type:"button",className:e.root,onClick:()=>o(W(!0)),children:[wc(wt,{}),wc("span",{className:e.text,children:t})]})},Tc=Ih;var kr={};z(kr,{enUS:()=>Ah,nlNL:()=>Lh});var Ah={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"}]},Lh={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"}]};var Ec={root:"_root_onpov_1",isInline:"_isInline_onpov_14",toggleButton:"_toggleButton_onpov_21",toggleButtonWrapper:"_toggleButtonWrapper_onpov_25",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_onpov_32",isCollapsed:"_isCollapsed_onpov_36",collapsible:"_collapsible_onpov_36",hints:"_hints_onpov_44",hintsHidden:"_hintsHidden_onpov_51",triggers:"_triggers_onpov_56",triggersRight:"_triggersRight_onpov_71"};import{jsx as j,jsxs as ho}from"react/jsx-runtime";var Bh=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=v("SuggestionsOverlay",Ec),s=T(kr),r=fo(Mt),i=wi(),a=Hh(),l=Nh(null),c=C("searchTriggerKey"),p=C("productName"),d=fo(Tn),u=fo(oe),g=fo(ft),[m,f]=Oh(null),h=C("showSearch"),w=C("showTextSuggestions"),y=C("adminUrl"),x=C("isEmbedded"),[b,_]=Sc("dd-snooze-until-ms",0),I=d||b>Date.now(),N=fo(B=>B.input.text),$=t.filter(B=>B.source!=="gpt").length,P=()=>{I&&_(0),a(hl(!I))},X=B=>{a(V({name:"suggestion feedback",data:{text:B.text,source:"overlay",context:N},options:{includeConversationData:!0}}))},R=B=>{let at=Date.now()+B*1e3;_(at),E.info(`Snooze until: ${new Date(at)}`),a(Fe({collapse:!0}))};return Mh(()=>{$===0&&f(null)},[t,$]),St(()=>{a(Fe({collapse:!0,skipWhenInputFocus:!0}))}),u===null||g===!1?null:u===!1?ho("div",{ref:l,className:Rr(n.root,{[n.isCollapsed]:I}),children:[!I&&ho("div",{className:n.triggers,children:[j("div",{style:{flex:1}}),j("div",{className:n.triggersRight,children:j(ut,{className:n.toggleButton,title:s("collapse"),onClick:P,isCollapsed:!1})})]}),j("div",{className:n.toggleButtonWrapper,children:j(ut,{className:n.toggleButton,title:s("open",{productName:p}),onClick:P,isCollapsed:!0})}),j("div",{className:n.collapsible,children:j(Bn,{loginUrl:y,isEmbedded:x,onLogIn:o,onSnooze:R})})]}):!i||!r?null:ho("div",{ref:l,className:Rr(n.root,{[n.isCollapsed]:I}),children:[!I&&ho("div",{className:n.triggers,children:[j("div",{style:{flex:1},children:h&&j("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(s(yn()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>f(null),children:j(Tc,{title:s("search")})})}),ho("div",{className:n.triggersRight,onFocus:()=>{},children:[j("div",{className:Rr(!m&&n.hintsHidden,n.hints),children:m}),j(ut,{className:n.toggleButton,title:s("collapse"),onClick:P,isCollapsed:!1})]})]}),j("div",{className:n.toggleButtonWrapper,children:j(ut,{className:n.toggleButton,title:s("open",{productName:p}),onClick:P,isCollapsed:!0})}),$>0&&w&&j("div",{className:n.collapsible,onFocus:()=>{},children:j(re,{children:j(Nn,{onFeedback:X,suggestions:t,selectedIndex:e,reverse:!0})})})]})},Fh=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),kc=Dh(Fh)(Bh);import{Provider as Kh}from"react-redux";import{jsx as Fn}from"react/jsx-runtime";var Uh=({children:t})=>{let o=C("locale").replace("-","");return Fn(Ns.Provider,{value:o,children:t})},jh=({store:t,customStyles:e={},children:o})=>Fn(Kh,{store:t,children:Fn(Uh,{children:Fn(zt.Provider,{value:e,children:o})})}),tt=jh;import Fr from"classnames";import{Interweave as Iy}from"interweave";import{useCallback as Py,useEffect as Ay,useMemo as Gc,useRef as Ly}from"react";import{connect as My}from"react-redux";import{cloneElement as zh}from"react";var Vh=["div","span","mark","strong","b","i","u","em"];function Ir(t,e,o=0){var r;let n=t[t.length-1],s=typeof n=="object"&&n!==null?(r=n.props)==null?void 0:r.tagName:void 0;if(s==="br")return t.pop(),[...t,...e,n];if(Vh.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),zh(n,{children:Ir(i,e,o+1)})]}return[...t,...e]}function Ue(t){return t.tagName.toLowerCase()==="textarea"}var Rc={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};import ay from"classnames";import{Matcher as ly}from"interweave";import{useEffect as cy,useMemo as py}from"react";function Ic(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Kn(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function Pc(t){return t!=null}import Oc from"classnames";import{createRef as ey,useCallback as Ar,useMemo as ty,useRef as oy,useState as ny}from"react";import{useState as qh,useLayoutEffect as Wh}from"react";var Gh=["bottom","height","left","right","top","width"],$h=(t={},e={})=>Gh.some(o=>t[o]!==e[o]),Re=new Map,Ac,Lc=()=>{let t=[],e=[];Re.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();$h(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Re.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),Ac=window.requestAnimationFrame(Lc)};function Xh(t,e){return{observe(){let o=Re.size===0;if(Re.has(t)){let n=Re.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Re.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&Lc()},unobserve(){let o=Re.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Re.delete(t),Re.size||cancelAnimationFrame(Ac)}}}}function Pr(t){let[e,o]=qh(null);return Wh(()=>{if(!t.current)return;let n=Xh(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}import{useContext as Zh,useLayoutEffect as Qh,useState as Jh}from"react";import{createPortal as Yh}from"react-dom";var Mc={root:"_root_1jq08_1"};var Nc=({children:t})=>{let[e,o]=Jh(null),n=Zh(zt);return Qh(()=>{let s=document.createElement("div");return Xe(s),s.classList.add(Mc.root),n!=null&&n.portalRootNode&&s.classList.add(n==null?void 0:n.portalRootNode),document.body.appendChild(s),o(s),()=>{s.isConnected&&document.body.removeChild(s)}},[]),e?Yh(t,e):null};var he={ref:"_ref_1rcyi_1",root:"_root_1rcyi_7",positionAbove:"_positionAbove_1rcyi_13",positionBelow:"_positionBelow_1rcyi_17",positionLeft:"_positionLeft_1rcyi_21",positionRight:"_positionRight_1rcyi_25",alignStart:"_alignStart_1rcyi_29",alignCenter:"_alignCenter_1rcyi_34",alignEnd:"_alignEnd_1rcyi_40"};import{jsx as Lr}from"react/jsx-runtime";var Un=(t=!1)=>{let[e,o]=ny(t),n=Ar(()=>o(!0),[]),s=Ar(()=>o(!1),[]),r=Ar(()=>o(a=>!a),[]),i=oy(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function Mr(t,e=null,o=0){if(!t)return{display:"none"};let n=e?t.top-e.top<0||t.top<e.top-o?e.top-o:t.top+t.height>e.top+e.height+o?e.top+e.height+o-t.height:t.top:t.top,s=e?t.left<e.left-o?e.left-o:t.left+t.width>e.left+e.width+o?e.left+e.width+o-t.width:t.left:t.left;return{top:n,left:s,height:t.height,width:t.width}}var jn=({className:t,triggerRef:e,boundaryRef:o=ey(),position:n="above",align:s="center",children:r,toStyle:i=Mr,...a})=>{let l=Pr(e),c=Pr(o),p=ty(()=>i(l,c,0),[l,c]);return Lr(Nc,{children:Lr("div",{className:Oc(he.ref,{[he.positionAbove]:n==="above",[he.positionBelow]:n==="below",[he.positionLeft]:n==="left",[he.positionRight]:n==="right",[he.alignStart]:s==="start",[he.alignCenter]:s==="center",[he.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:Lr("div",{className:Oc(t,he.root),children:r})})})};import sy from"classnames";import{forwardRef as ry,useRef as iy}from"react";import{jsx as Dc}from"react/jsx-runtime";var zn=ry(({className:t,children:e,...o},n)=>{let s=iy(null),r=v("TabCompletion",xe);return Dc("div",{ref:Kn([s,n]),className:sy(t,r.popoverContentContainer),...o,children:Dc("div",{className:r.popoverContent,children:e})})});import{jsx as yo,jsxs as gy}from"react/jsx-runtime";var dy=t=>e=>{let o=Mr(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},uy=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=v("TabCompletion",xe),i=Un(),a=py(()=>dy(t.getBoundingClientRect()),[t]),[l,c]=ln(t);return cy(()=>{c?i.open():i.close()},[c]),gy("span",{children:[yo("mark",{ref:Kn([l,i.triggerRef]),className:ay(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&yo(jn,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:yo(zn,{style:o,children:yo("div",{className:r.hintText,children:s})})})]})},Vn=class extends ly{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(e,o){return o.keywordMatches&&o.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=o.keywordMatches.map(n=>({...n,keywordRegex:new RegExp(`\\b${Ic(n.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),e}match(e){let o=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let r=e.match(s.keywordRegex);if(!r)return null;let i=e.charAt(r.index-1),a=e.charAt(r.index+s.keyword.length);return i==="{"&&a==="}"?null:{index:r.index,length:r[0].length,match:r[0],matchString:r[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(Pc);if(o.length===0)return null;let n=o.reduce((s,r)=>r.index<s.index?r:s);return this.usedKeywordMatches.add(n.preparedKeywordMatch),n}replaceWith(e,o){return yo(uy,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import Br from"classnames";import{Matcher as by}from"interweave";import{createRef as Cy,forwardRef as wy,useCallback as Ty,useEffect as Vc,useRef as qc,useState as Wc}from"react";import{useDispatch as Ey}from"react-redux";import{jsx as Hc}from"react/jsx-runtime";var Bc=()=>Hc("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:Hc("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 my,useEffect as Kc,useState as Uc}from"react";import{useDispatch as fy,useSelector as jc}from"react-redux";import hy from"lodash.debounce";var Fc={root:"_root_1muu8_1",content:"_content_1muu8_7"};function qn(t,e,o){var s;let n=((s=t.imageSizes)==null?void 0:s[e])||t.image||o;if(!n)return null;try{return new URL(n).toString()}catch{return null}}function Nr(t){return t.replace("https://www.","").replace("https://","")}import{jsx as ot,jsxs as Or}from"react/jsx-runtime";var yy=3,vy=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Sy=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=yy})=>{let r=v("LinkSearch",Fc),[i,a]=Uc(""),l=fy(),c=jc(Cn("url")),p=jc(ja("URL",vy)),[d,u]=Uc(p.length-1),g=C("fallbackImage"),m=y=>{let x=y.target;a(x.value)},f=(y,x)=>{y.stopPropagation(),y.preventDefault(),window.open(x,"_blank")},h=y=>{var _;let x=d-1<0?p.length-1:d-1,b=d+1===p.length?0:d+1;y.code==="Escape"&&(a(""),e()),y.code==="ArrowUp"&&u(x),y.code==="ArrowDown"&&u(b),y.code==="Enter"&&t(((_=p[d])==null?void 0:_.text)||i)},w=my(hy(y=>{l(Je({query:y,type:"URL",tags:["link-search"]}))},300),[]);return Kc(()=>{i&&w(i)},[i]),Kc(()=>()=>{l(Sn())},[]),Or("div",{className:r.root,children:[ot(re,{withDivider:!0,children:(i?p:c).slice(0,s).map((y,x)=>ot(D,{selected:d===x,onClick:()=>t(y.text),"data-testid":"linksearch-suggestion",children:Or(H,{children:[ot(H.Image,{src:qn(y,"small",g||void 0),title:y.title||y.text}),Or(H.Content,{className:r.content,cropText:!0,children:[ot(H.Title,{children:y.title||Nr(y.text)}),y.title&&Nr(y.text)]}),ot(D.Actions,{children:ot(D.ActionButton,{label:n,onClick:b=>f(b,y.text)})})]})},y.text))}),ot(ao,{value:i,onChange:m,autoFocus:!0,placeholder:o,onKeyUp:h})]})},zc=Sy;var Dr={};z(Dr,{enUS:()=>_y,nlNL:()=>xy});var _y={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},xy={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};import{jsx as ye,jsxs as Hr}from"react/jsx-runtime";var ky=wy((t,e)=>{let o=v("TabCompletion",xe);return ye("mark",{ref:e,className:Br(o.matchSelection)},"selection-start")}),Ry=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=T(Dr),i=v("TabCompletion",xe),a=qc(null),l=qc(null),[c,p]=Wc(null),d=Ey(),u=Un(document.activeElement===n),[g]=Wc(()=>document.createRange());u.triggerRef.current=g,Vc(()=>()=>g.detach(),[]),Vc(()=>{let f=t.current,h=a.current;!f||!h||(g.setStart(f,0),g.setEnd(h,0))},[t.current,a.current]),St(()=>{u.close()});let m=Ty(f=>{let h=g.toString(),w=/^http(s?):\/\//.test(f)?f:`https://${f}`;d(jo({text:`[${h}](${w})`,replace:"selection"}))},[]);return Hr("span",{children:[ye("mark",{ref:a,className:Br(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":u.opened?"true":"false",children:s}),u.opened&&ye(jn,{className:i.popoverRoot,triggerRef:u.triggerRef,boundaryRef:e,position:"above",align:"start",children:Hr(zn,{style:o,ref:l,children:[ye("div",{className:Br(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:Hr("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[ye(Bc,{}),ye("span",{children:"\xA0"}),ye("span",{children:r("insertLink")})]})}),c==="insertLink"&&ye(zc,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:m,onDismiss:()=>{p(null),u.close()}})]})})]},"selection-end")},Wn=class extends by{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=Cy(),this.foundIndex=0,e}match(e){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,n]=this.props.selection;if(o===n)return null;let s=this.foundIndex===0?o:n,r=s>=this.charCount&&s<=this.charCount+e.length?{index:s-this.charCount,length:0,match:"",valid:!0}:null;r&&this.foundIndex++;let i=this.foundIndex===1;return r&&i?this.charCount+=s-this.charCount:this.charCount+=e.length,r?{isStart:i,...r}:null}replaceWith(e,o){return o.isStart?ye(ky,{ref:this.startRef}):ye(Ry,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};import{jsx as Nt,jsxs as Dy}from"react/jsx-runtime";var Ny=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=v("TabCompletion",Rc),p=C("insertLink"),d=C("showMidSentenceSuggestions"),u=C("inlineSuggestions"),g=pn(a),m=Ly(null);Ay(()=>{Ue(a)&&g&&dn(a,g)},[g]);let f=Py(y=>{if(!s||!o)return y;let x=[Nt("span",{className:c.resetIndent,children:"\u200B"},"u200B"),Nt("span",{"data-testid":"tab-completion",className:Fr(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&x.push(Nt("span",{className:Fr(c.hint,c.resetIndent),children:Nt(gs,{keyCode:"tab"},"tabHint")})),Ir(y,x)},[s,o,n]),h=Gc(()=>{let y=[];return p&&y.push(new Wn("selection")),y.push(new vt("placeholders")),r&&y.push(new Vn("keywords")),y},[u,p,r]),w=Gc(()=>{let y=window.getComputedStyle(a);return{"--dd-color":y.color,"--dd-font-size":y.fontSize,"--dd-font-family":y.fontFamily,"--dd-font-variant":y.fontVariant}},[]);return t?Dy("div",{ref:y=>{y!=null&&y.parentElement&&(m.current=y==null?void 0:y.parentElement)},className:c.root,style:w,children:[Nt(Iy,{tagName:"span",containerTagName:"div",className:Fr(c.container,c.agentText),disableLineBreaks:Ue(a),content:e||"\u200B",onAfterParse:f,matchers:h,selection:g,keywordMatches:i,inputElement:a,inputStyle:w,boundaryRef:m,inlineSuggestionsOnlyAtEnd:!d}),Nt("br",{})]}):null},Oy=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var f;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??Qt(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:u,visible:g,showStyleSuggestions:m}=o;return{showTabHint:p,showStyleSuggestions:m,showTabCompletion:u,content:l,tabText:c,source:a,keywordMatches:((f=n.list)==null?void 0:f.keywordMatches)??[],enabled:g&&d!==!1}},$c=My(Oy)(Ny);import yv from"classnames";import{useEffect as vv}from"react";import{useDispatch as Sv,useSelector as ee}from"react-redux";import{createAsyncThunk as vo,createSlice as Hy}from"@reduxjs/toolkit";var Xc={list:[],fetchState:"idle",isInitialRequest:null},Qc=t=>t.autoflows.list||[],Zc=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},Ie=vo("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Kr=vo("autoflows/start",async(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");await n.startAutoflowSession(t),await o(Ie(t.platformSessionId))}),Ur=vo("autoflows/stop",async(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");await n.stopAutoflowSession(t.platformSessionId),await o(Ie(t.platformSessionId))}),By=Hy({name:"autoflows",initialState:Xc,reducers:{},extraReducers:t=>{t.addCase(Kr.pending,(e,o)=>{let n=Zc(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Ur.pending,(e,o)=>{let n=Zc(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(Ie.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(Ie.rejected,e=>{e.fetchState="error"}),t.addCase(Ie.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(L,()=>Xc)}}),Jc=vo("autoflows/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");let s=n.openStream(t);s.on("sessionAborted",()=>{o(Ie(t))}),s.on("sessionCompleted",()=>{o(Ie(t))})}),Yc=vo("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),ep=By.reducer;import{createAsyncThunk as _o,createSlice as Fy}from"@reduxjs/toolkit";var tp={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},op=t=>t.customMessages.list,np=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),sp=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),rp=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),So=_o("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),Gn=_o("customMessages/send",async(t,e)=>{let{platformSessionId:o,suggestion:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.sendCustomMessage(o,n)}),$n=_o("customMessages/answer",async(t,e)=>{let{platformSessionId:o,reply:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.answerCustomMessage(o,n)}),ip=Fy({name:"customMessages",initialState:tp,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(So.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(So.rejected,e=>{e.fetchState="error"}).addCase(So.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(Gn.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(Gn.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase($n.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase($n.rejected,(e,o)=>{let n=e.answeredSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1)),e.answeredSuggestions.splice(n,1)}).addCase(L,()=>tp)}}),ap=_o("customMessages/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.openStream(t).on("customMessageSuggestion",r=>{o(ip.actions.onCustomMessage(r))})}),lp=_o("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),cp=ip.reducer;import{createAsyncThunk as pp,createSlice as Ky}from"@reduxjs/toolkit";var Uy={token:null,accountUrl:null,interval:null},dp=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},jr=pp("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),zr=pp("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(jr()),setInterval(()=>n(jr()),o)}),up=Ky({name:"passwordlessToken",initialState:Uy,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(jr.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(zr.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:gp}=up.actions,mp=up.reducer;function fp(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}import{Fragment as Qy}from"react";import{connect as Jy}from"react-redux";import $y from"classnames";import{Fragment as Xy}from"react";import jy from"classnames";var hp={root:"_root_838fd_1"};import{jsx as Vy}from"react/jsx-runtime";var zy=({className:t,children:e})=>{let o=v("Unicode",hp);return Vy("span",{className:jy(t,o.root),children:e})},yp=zy;var vp={isDisabled:"_isDisabled_1rmfm_1",buttonStart:"_buttonStart_1rmfm_5",root:"_root_1rmfm_8",buttonStop:"_buttonStop_1rmfm_8",stateBadge:"_stateBadge_1rmfm_19",isCompleted:"_isCompleted_1rmfm_26",isStarted:"_isStarted_1rmfm_30",isAborted:"_isAborted_1rmfm_34"};var Vr={};z(Vr,{enUS:()=>qy,nlNL:()=>Wy});var qy={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]},Wy={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]};import{jsx as nt,jsxs as Xn}from"react/jsx-runtime";var Zy=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=v("Autoflow",vp),a=T(Vr),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return Xn(D,{className:$y(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[nt(H,{children:Xn(H.Content,{children:[Xn(H.Title,{children:[e&&nt("span",{className:i.stateBadge,children:a(e)}),o]}),nt("span",{children:n})]})}),nt(D.Actions,{fixed:e==="Started",children:nt(D.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:Xn(Xy,{children:[nt(yp,{children:c})," ",nt("span",{children:a(l)})]})})})]})},Sp=Zy;import{jsx as _p}from"react/jsx-runtime";var Yy=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},ev=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>_p(Qy,{children:t.map(s=>_p(Sp,{displayName:s.displayName,description:s.description,disabled:s.isBusy||Yy(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),tv=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},ov={onStartAutoflow:Kr,onStopAutoflow:Ur},xp=Jy(tv,ov)(ev);import{useEffect as nv,useState as sv}from"react";import{useDispatch as rv}from"react-redux";import wp from"classnames";import{jsx as bp}from"react/jsx-runtime";var qr=()=>bp("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:bp("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 Cp={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};import{jsx as Ot,jsxs as Tp}from"react/jsx-runtime";var iv=({entities:t})=>{let e=v("EntitiesWidgetList",Cp),[o,n]=sv(void 0),s=rv(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),co(a.text),s(V({name:"entity copied",data:{entity:a,type:"copy"}})))};return nv(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:Ot("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>Tp("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[Ot("span",{className:e.entityText,children:a.text}),Tp("span",{className:e.iconWrapper,children:[Ot("span",{className:wp(e.icon),children:Ot(qr,{})}),Ot("span",{className:wp(e.icon,o===l&&e.iconClicked),children:Ot(qr,{})})]})]},a.text))})},Ep=iv;import av from"classnames";import{useCallback as kp}from"react";import{useDispatch as lv,useSelector as Zn}from"react-redux";var Pe={root:"_root_1e6ej_1",title:"_title_1e6ej_8",isUsed:"_isUsed_1e6ej_13",quickReplies:"_quickReplies_1e6ej_22",quickReply:"_quickReply_1e6ej_29",hasError:"_hasError_1e6ej_39",label:"_label_1e6ej_43",errorIcon:"_errorIcon_1e6ej_48"};import{jsx as je,jsxs as Qn}from"react/jsx-runtime";var cv=({suggestion:t})=>{let e=T(Qe),o=lv(),n=Zn(np(t.text)),s=Zn(sp(t.text)),r=Zn(rp(t.text)),i=Zn(No),{replyOptions:a}=t,l=kp(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(Gn({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=kp(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),u=a[d];o($n({platformSessionId:i,reply:u,suggestion:t}))},[t,n,o,i]);return Qn(D,{onClick:l,className:av(Pe.root,{[Pe.isUsed]:n,[Pe.hasError]:r}),children:[je(H,{children:Qn(H.Content,{children:[Qn(H.Title,{className:Pe.title,children:[t.text," ",je(ms,{className:Pe.label,children:"analyse tool"})," ",r&&je("span",{className:Pe.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&je("ul",{className:Pe.quickReplies,children:a.map(p=>je("li",{className:Pe.quickReply,children:p.title},p.title))})]})}),Qn(D.Actions,{fixed:r||n,children:[a&&a.length>0&&je(D.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>je(D.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),je(D.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},Rp=cv;import{jsx as Ip}from"react/jsx-runtime";var Pp=()=>Ip("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Ip("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});import{useSelector as uv}from"react-redux";import{useCallback as pv}from"react";import{jsx as st,jsxs as Jn}from"react/jsx-runtime";var dv=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var u;let s=t.text||t.url||t.message,r=_n(s),i=T(Qe),a=C("showImages"),l=C("fallbackImage"),c=g=>{g.preventDefault(),g.stopPropagation(),n(s)},p=g=>{g.preventDefault(),g.stopPropagation(),o(t)},d=pv(g=>{window.open(r,"_blank"),g.stopPropagation(),g.preventDefault()},[r]);return Jn(D,{onClick:c,"data-testid":"edit-suggestion",children:[Jn(H,{children:[a&&t.image&&st(H.Image,{src:qn(t,"small",l||void 0),title:t.title}),Jn(H.Content,{children:[t.title&&st(H.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&st(D.Labels,{labels:t.searchKeywords}),st(H.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),Jn(D.Actions,{children:[r&&st(D.ActionButton,{onClick:d,label:i("visitUrl")}),st(D.ActionButton,{primary:!0,onClick:p,label:i("preview")}),st(D.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},Ap=dv;import{Fragment as mv,jsx as Lp}from"react/jsx-runtime";var gv=({contentType:t,lines:e,suggestions:o})=>{let n=se(),s=uv(Be),r=a=>{n.send(cr,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(Te,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return Lp(mv,{children:o.map(a=>Lp(Ap,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},Mp=gv;var Wr={};z(Wr,{enUS:()=>fv,nlNL:()=>hv});var fv={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],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"}]},hv={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],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"}]};var Np={root:"_root_x0pwe_1",loginText:"_loginText_x0pwe_7",stateText:"_stateText_x0pwe_8",sectionList:"_sectionList_x0pwe_20",shortcutList:"_shortcutList_x0pwe_24",shortcut:"_shortcut_x0pwe_24",link:"_link_x0pwe_52"};import{jsx as Op}from"react/jsx-runtime";var Dp=()=>Op("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:Op("path",{d:"M543-340q16.595 0 28.798-12.202Q584-364.405 584-381t-12.202-28.798Q559.595-422 543-422t-28.798 12.202Q502-397.595 502-381t12.202 28.798Q526.405-340 543-340Zm-25-126h47q2-29 8.5-43t32.5-39q27-26 37.5-45.395Q654-612.79 654-639q0-45.882-31.5-74.941Q591-743 540-743q-38 0-68 20.5T428-665l45 19q11-25 27.5-38t39.5-13q29.778 0 48.389 17Q607-663 607-637q0 20-9 35t-32 32q-32 29-40 46.5t-8 57.5ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-620h60v620h620v60H140Zm120-740v560-560Z"})});import{jsx as Hp}from"react/jsx-runtime";var Bp=()=>Hp("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:Hp("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});import{jsx as M,jsxs as Dt}from"react/jsx-runtime";var Yn=(t,e)=>{let o=ee(oe);vv(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},_v=({onLogIn:t})=>{let e=T(Wr),o=Sv(),n=C("isEmbedded"),s=v("Widget",Np),r=C("showAutoflows"),i=C("showCustomMessages"),a=C("showSummaryCommand"),l=C("showKnowledgeSearch"),c=C("showSearch"),p=ee(Ke),d=ee(Pn),u=ee(Qc),g=ee(kn),m=ee(op),f=ee(Oo),h=ee(ft),w=ee(oe),y=ee(No),x=ee(fp),b=ee(Be),_=se(),I=ee(nl),N=ee(dp("/admin/")),$=C("adminUrl"),P=C("productName");if(Yn(()=>(o(So(y)),o(ap(y)),()=>{o(lp(y))}),[o,h,i,y]),Yn(()=>(o(Ie(y)),o(Jc(y)),()=>{o(Yc(y))}),[o,h,r,y]),Yn(()=>{d.forEach(({type:R})=>{o(R==="entities"?pe():ce(R))})},[o,h,f,p]),Yn(()=>(o(zr()),()=>{o(gp())}),[o]),h===!1)return M("div",{className:s.stateText,children:M("div",{children:M("p",{children:e("notSupported")})})},"supported");if(w===!1)return M("div",{className:s.loginText,children:M("div",{children:M(Bn,{isEmbedded:n,loginUrl:$,onLogIn:t})})},"login");if(!p||!y||w===null||I||x)return M("div",{className:s.stateText,children:M("div",{children:M("p",{children:e("waiting")})})},"waiting");let X=c||a||l||N;return M("div",{className:yv(s.root),"data-testid":"widget",children:Dt(hs,{className:s.sectionList,children:[X&&M(Ve,{title:e("actions"),type:"shortcuts",children:Dt("div",{className:s.shortcutList,children:[c&&Dt("button",{className:s.shortcut,"data-testid":"shortcut-search",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0}),children:[M(wt,{}),e("linkSearch")]}),a&&Dt("button",{className:s.shortcut,"data-testid":"shortcut-summary",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[M(Bp,{}),e("linkSummary")]}),l&&Dt("button",{className:s.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[M(Dp,{}),e("linkKnowledgeSearch")]}),N&&Dt("a",{className:s.shortcut,target:"_blank",href:N,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[M(Pp,{}),e("linkStudioLogin",{productName:P})]})]})}),i&&m.length>0&&M(Ve,{type:"custom-messages","data-testid":"custom-messages",children:M(re,{withDivider:!0,children:m.map(R=>M(Rp,{suggestion:R},R.text))})}),r&&u.length>0&&M(Ve,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:M(re,{withDivider:!0,children:M(xp,{})})}),d.map(({type:R,title:B,amount:at,lines:Ut})=>{var jt;switch(R){case"entities":return g&&g.length>0&&M(Ve,{type:R,title:B,"data-testid":`type-${R}`,children:M(Ep,{entities:g})},R);default:return((jt=b[R])==null?void 0:jt.fetchState)==="done"&&b[R].suggestions.length>0&&M(Ve,{type:R,title:B,"data-testid":`type-${R}`,children:M(re,{withDivider:!0,children:M(Mp,{lines:Ut,contentType:R,suggestions:b[R].suggestions.slice(0,at)||[]})})},R)}})]})})},Fp=_v;function bo(t){let e=new Range;return e.selectNodeContents(t),e}function Kp(t,e,o){try{return rt(t,e,o),!0}catch{return!1}}function es(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function ts(t){return"tagName"in t&&t.tagName==="BR"}var xo=/[\u200B-\u200D\uFEFF]/g;function rt(t,e,o){let n=new Range;if(t.firstChild===null&&e===0&&o===0)return n.selectNodeContents(t),n;let s=0,r=!1;function i(l,c){let p=-1,d=/[\u200B-\u200D\uFEFF]/;if(!d.test(l))return c;for(let u=0;u<=l.length;u++)if(d.test(l[u])||p++,p===c)return u;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(xo,""),d=s+p.length,u=e>=s&&e<=d,g=o>=s&&o<=d;if(u){let m=i(c,e-s);m===0&&!g?n.setStartBefore(l):n.setStart(l,m)}g&&(n.setEnd(l,i(c,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(ts(l)&&(s===e&&n.setStartBefore(l),s++,s===o)){n.setEndAfter(l),r=!0;return}for(let p=0;p<l.childNodes.length&&(a(l.childNodes[p]),!r);p++);let c=l.lastChild;es(l)&&c&&!es(c)&&!ts(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function os(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r,collapsed:i}=e,a,l,c=0;function p(d){let u=d===o,g=d===s;switch(d.nodeType){case Node.TEXT_NODE:{let m=d.textContent;u&&(a=c+m.substring(0,n).replace(xo,"").length),g&&(l=c+m.substring(0,r).replace(xo,"").length),c+=m.replace(xo,"").length;break}case Node.ELEMENT_NODE:{let m=d.nextSibling===null;ts(d)&&!m&&c++;for(let f=0;f<d.childNodes.length;f++){let h=u&&f===n,w=g&&f===r;if(h&&(a=c),w&&(l=c),l!==void 0||((!h||!i)&&p(d.childNodes[f]),g&&f===r-1&&(l=c),l!==void 0))break}!g&&es(d)&&!m&&c++,g&&(l=c);break}default:break}}if(p(t),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function ns(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let p=c===o,d=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let u=p?n:0,g=d?r:void 0,m=c.textContent.replace(xo,"");u===0&&g===void 0?a+=m:a+=m.substring(u,g);break}case Node.ELEMENT_NODE:{let u=c.nextSibling===null;i===0&&ts(c)&&!u&&(a+=`
4
4
  `);for(let g=p?n:0;g<(d?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[g]),i!==1);g++);!d&&i===0&&es(c)&&!u&&(a+=`
5
- `);break}default:break}d&&i++}return l(t),a}function Kp(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Dt=class extends Ne{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),ns(this.element,e)}getHTML(){return this.element.innerHTML||""}getRange(){var r;let e=this.getRootNode();if(e.activeElement!==this.element)return null;let o="getSelection"in e?e.getSelection():window.getSelection();if(!o)return null;let n="getComposedRanges"in o&&e instanceof ShadowRoot?(r=o.getComposedRanges(e))==null?void 0:r[0]:o.rangeCount>0?o.getRangeAt(0):null;if(!n)return null;let s=this.element.ownerDocument.createRange();return s.setStart(n==null?void 0:n.startContainer,n==null?void 0:n.startOffset),s.setEnd(n==null?void 0:n.endContainer,n==null?void 0:n.endOffset),!s||!this.element.contains(s.startContainer)||!this.element.contains(s.endContainer)?null:s}getCaretPosition(){let e=this.getRange();if(!e||!e.collapsed||!("getBoundingClientRect"in e))return null;let o=e.getBoundingClientRect();return!Kp(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!Kp(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return os(this.element,e);let o=this.lastKnownSelection;if(o&&Fp(this.element,o.start,o.end))return o;let n=xo(this.element);return n.collapse(!1),os(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return ns(this.element,rt(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return(s=this.observer)==null||s.takeRecords(),Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};function Up(t,e,o){let n=`deepdesk-iframe-${t}`,s=document.getElementById(n);if(s)return s;let r=document.createElement("iframe"),i=new URL(e);return Object.entries(o).forEach(([a,l])=>{i.searchParams.append(a,l)}),r.style.position="absolute",r.style.left="-999em",r.style.width="0px",r.style.height="0px",r.tabIndex=-1,r.id=n,r.title=`iframe-${t}`,r.src=i.toString(),window.document.body.appendChild(r),r}var $r=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(e)}broadcastChannel;disposeHandlers=[];onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(e)}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},Xr=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=Up(e,`${this.targetOrigin}/v2/widget/liveengage/channel.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(e,this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},Qr=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),E.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new Xr(e,this.deepdeskUrl,{debug:!0}):new $r(e),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&s.data.channel===e&&(E.info("Received broadcast event",this.sessionId,s),(i=(r=this.eventMap)[s.data.name])==null||i.call(r,s.data.payload))};return o.onMessage(n),o}send(e,o){var r,i;E.info("broadcast event",{sessionId:this.sessionId,name:e,payload:o});let n={type:"event",name:e,payload:o};(i=(r=this.eventMap)[e])==null||i.call(r,o);let s=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage({...n,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},zp=Qr;var Ht=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Zr=t=>new Promise(e=>{setTimeout(e,t)});var Bt=class extends Ht{name="ClientError"},Jr=class extends Ht{name="ServerError"},ve=class t{constructor(e="",o={}){this.baseUrl=e;this.options=o;o.fetch&&(this.fetch=o.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,o={}){return new Promise((n,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,{abortLatest:l=!1,attempts:c=1,retryDelay:p=500,refreshTokenOn401:d=!0,retryOnError:u=b=>b instanceof TypeError,retryOnResponse:g=b=>b.status>=500,version:m="v1",...f}=o,h={credentials:"include",...f,headers:{"Content-Type":"application/json",...f.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(h.headers={...h.headers,"X-CSRFToken":this.csrfToken}),typeof m=="string"&&(h.headers={...h.headers,"X-Deepdesk-API-Version":m});let w=c,y=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&l&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let x=async()=>(w--,a(i,h).then(async b=>g(b)&&!r.isAborted&&w>0?(await Zr(p),x()):b.status===401&&d===!0&&y===!1?(y=!0,await this.refreshToken(),x()):b).catch(async b=>{if(u(b)&&!r.isAborted&&w>0)return await Zr(p),x();throw b}));x().then(b=>b.json().catch(()=>null).then(_=>{b.status>=500?s(new Jr("Server Error",_)):b.status===401?s(new Bt("Unauthorized",_)):b.status===403?s(new Bt("Forbidden",_)):b.status===404?s(new Bt("Not Found",_)):b.status>=400&&s(new Bt("Bad Request",_)),delete this.latestRequestByUrl[i],n(_)})).catch(b=>{s(b)})})}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var Sv;(e=>{let t;(l=>(l.SEND_MESSAGE="Send Message",l.HANDLING_TIME="Handling Time",l.START_AUTOFLOW="Start Autoflow",l.ABORT_AUTOFLOW="Abort Autoflow",l.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",l.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(t=e.EventType||={})})(Sv||={});function ss(t){return{...A(t),tags:t.tags}}var je=class t{constructor(e,o={}){this.options=o;this.client=new ve(e,{fetch:o.fetch}),this.client.patchFetch(n=>async(s,r)=>{let i=await n(s,r);return this.handleDeepdeskVersionHeaders(i),i})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=await this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(t.exchangeTokenPromise||(t.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),t.exchangeTokenPromise):Promise.resolve()}async createConversation(e){await this.preflight(),E.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...K(e),tags:e.tags},{version:"v2"});return ss(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return A(o)}async getKnowledgeAssistant(e){let o=await this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{version:null});return A(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return A(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return A(e)}async checkUserExists(e){let{exists:o}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return o}async getConversationBySessionId(e,o={}){await this.preflight(),E.info(`Getting conversation for session ${e}`);let{attempts:n=1,retryDelay:s=1e3}=o,r=await this.client.get(`/api/conversations/by_session_id/${e}`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"});return ss(r)}async isConversationSupported(e,o={}){E.info(`Check if conversation for session ${e} is supported`);let{attempts:n=1,retryDelay:s=1e3}=o;return(await this.client.get(`/api/conversations/by_session_id/${e}/active_profile`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"})).has_active_profile}async updateConversation(e,o){let n=K(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return ss(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...K(s),tags:s.tags})),{version:"v2"})).map(s=>ss(s))}async sendEvent(e,o){let{data:n,...s}=o,r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((i,[a,l])=>({...i,[a]:l}),{});return this.client.post("/api/events",K({...r,...s,data:n,name:e}),{version:"v2"})}async sendEventV1(e,o){let n=Object.entries(this.latestReceivedDeepdeskVersions).reduce((s,[r,i])=>({...s,[r]:i}),{});return this.client.post("/api/events",{event:e,data:K({...o,...n})})}async getEntities(e){return(await this.client.post("/api/entities",{messages:e.filter(n=>n.text)})).entities}async getSummary(e,o={}){return(await this.client.post("/api/summary",{conversation:{messages:e.filter(s=>s.text&&s.source)},prompt_instruction:o.promptInstruction,model:o.model})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(e){return this.client.post("/apis/admin/session/jwt/",{jwt:e},{version:null}).catch(o=>{throw E.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",K(o),{version:null,refreshTokenOn401:!1,headers:{apikey:e}})}async getTextSuggestions(e,o={},n){return n==="sticky-messages"?this.getPinnedMessages(e):(await this.client.post(`/api/conversations/${e}/recommend/${n}`,K(o),{abortLatest:!0})).map(r=>({...A(r),text:r.text||r.url||r.message,source:n,type:n})).filter((r,i,a)=>i===a.findIndex(l=>l.text===r.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(e,o){return(await this.client.post(`/api/conversations/${e}/autocomplete`,K(o),{abortLatest:!0})).map(s=>({score:1,source:s.source,sourceText:s.source_text,text:s.label,trainingJobs:s.training_jobs,searchKeywords:s.search_keywords,type:s.source})).filter((s,r,i)=>r===i.findIndex(a=>a.text===s.text))}async getPinnedMessages(e){let o=await this.client.get(`/api/conversations/${e}/sticky-messages`,{abortLatest:!0});return A(o).map(n=>({...n,text:n.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(e){let o=await this.client.post("/api/style-suggestions",K(e),{abortLatest:!0});return A(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,K(e),{version:"v2"});return A(o)}async knowledgeAssist(e,o,n){let s=await this.client.post(`/api/knowledge-assist/assistants/${n}/search`,K({question:e.question,promptInstruction:e.promptInstruction,chatHistory:o.map(r=>({question:r.question,answer:r.answer.answer}))}),{version:"v2"});return A(s)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return A(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return A(e.token)}async getCsrfToken(){let{token:e}=await this.client.get("/apis/admin/session/csrf/",{version:null});return e}async verifyLoginToken(e){let o=await this.client.post("/apis/admin/session/passwordless/login/",{token:e},{version:null});return A(o)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(yi);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&E.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var bo=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(tr(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,A(s))}catch{E.warn(`Invalid JSON for ${e}: ${n}`)}})}connect(){clearTimeout(this.timeoutTimer);let e=new EventSource(this.url,{withCredentials:!0});this.eventSource=e;let o=!1;e.onopen=()=>{o=!0},e.onerror=()=>{o&&e.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{e.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(n=>{this.proxyEvent(n)})}disconnect(){var e;clearTimeout(this.timeoutTimer),this.eventListeners={},(e=this.eventSource)==null||e.close()}emit(e,o){this.eventListeners[e]&&this.eventListeners[e].forEach(n=>n(o))}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),this.proxyEvent(e),()=>{this.off(e,o)}}off(e,o){let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}};var _v;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(_v||={});var Co=class{constructor(e,o={}){this.apiUrl=e;this.client=new ve(e,o)}client;streams={};logger=E;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return A(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,K(o));return A(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,K(o))}async getAutoflows(e){let o=await this.client.get(`/sessions/${e}/autoflows`);return A(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",K(e));return A(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new bo(`${this.apiUrl}/sessions/${e}/events`),this.streams[e].connect()),this.streams[e]}closeStream(e){this.streams[e]||(this.streams[e].disconnect(),delete this.streams[e])}};import{combineReducers as kv,configureStore as Rv}from"@reduxjs/toolkit";import{createSlice as xv}from"@reduxjs/toolkit";var jp={startTime:null,stopTime:null},Vp=xv({name:"handlingTime",initialState:jp,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(L,()=>jp)}}),{handlingTimeStart:qp,handlingTimeStop:rs,handlingTimeReset:Wp}=Vp.actions,Gp=Vp.reducer;var $p=(t={})=>{let e={onAuthError:Et(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};import{createAsyncThunk as bv,createSlice as Cv}from"@reduxjs/toolkit";var is={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var it=bv("styleSuggestions/getAll",async({text:t},e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),{showStyleSuggestions:s}=n.settings,r=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)return is.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),wv=Cv({name:"styleSuggestions",initialState:is,reducers:{},extraReducers:t=>{t.addCase(it.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(it.rejected,e=>{e.fetchState="error"}).addCase(it.fulfilled,(e,o)=>{e.fetchState="done",Ae(e.list,o.payload)||(e.list=o.payload)}).addCase(Ge,e=>{e.list=is.list}).addCase(L,()=>is)}}),Xp=wv.reducer;var Qp=(t={})=>{let e,o=!0,n={getStyleSuggestions:it,debounce:500,...t};return s=>r=>i=>{var g;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:p}=c.settings;if(!((g=c.conversation.current)==null?void 0:g.id)||!p)return l;let{text:u}=c.input;return u===a&&!o||(clearTimeout(e),u==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:u}))},t.debounce)),l}};function Tv(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Zp=(t={})=>{let e={getTextSuggestions:ce,getAutocompleteSuggestions:oo,debounce:200,check:Lt,...t},o;return n=>s=>r=>{var f;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:p}=l.settings,d=(f=l.conversation.current)==null?void 0:f.id,u=r.type===wn.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:g}}=l;return Tv(g,i)&&!u||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let h=ht(l);h===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(h))},u?0:e.debounce)),a}};var Jp=it.fulfilled.toString();function Ev(t,e){let o=new Set([...e.keywordMatches.map(s=>s.keyword)]),n=[];return o.forEach(s=>{let r=t.keywordMatches.filter(l=>l.keyword===s),i=e.keywordMatches.filter(l=>l.keyword===s),a=i.length-r.length;a<=0||n.push(...i.slice(0,a))}),n}var Yp=t=>e=>o=>n=>{var c;if(n.type!==Jp){o(n);return}let s=e.getState().styleSuggestions.list;o(n);let r=e.getState(),i=r.styleSuggestions.list,a=(c=r.conversation)==null?void 0:c.current;if(s===i)return;let l=Ev(s,i);n.type===Jp&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var Iv=kv({activeSuggestion:ul,answer:tc,auth:Tl,autoflows:Yc,conversation:Ci,contentTypes:Dl,customMessages:lp,passwordlessToken:gp,entities:Fl,knowledgeAssistant:Jl,handlingTime:Gp,info:Ha,input:ws.reducer,overlayInput:Q.reducer,settings:Si,profile:ic,search:ja,summary:Wl,styleSuggestions:Xp,ui:hl,textSuggestions:al});function ed(t){return Rv({reducer:Iv,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),$p(),Zp({debounce:200}),Qp({debounce:500}),Yp(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Pv=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Av=t=>e=>o=>n=>{var a;let s=e.getState(),r=_s("inlineSuggestions")(s);switch(n.type){case Ce.toString():{let l=Cn(n.payload.contentType)(e.getState()),c=l.indexOf(n.payload.suggestion);t.emit("edit-suggestion",{contentType:n.payload.contentType,index:c,suggestions:l});break}case Et.toString():{!n.payload&&t.emit("logout",void 0);break}case ie.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:Pv(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Uo.toString():{let{start:l,end:c}=s.input.selection;t.emit("replace",{...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case qt.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case qo.toString():t.emit("select-image",n.payload,{mayApplyChanges:!0}),t.sendEvent("Image attached",{conversationId:s.conversation.current.id,data:{path:n.payload.suggestion.image,title:n.payload.suggestion.title}});break;case pe.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case Ee.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary}});break;case V.toString():t.sendEvent(n.payload.name,{conversationId:((a=n.payload.options)==null?void 0:a.includeConversationData)&&s.conversation.current.id,data:n.payload.data});break;case zo.toString():t.handleKeyDown(n.payload);break;case Ge.toString():t.logSendMessage(n.payload);break;case jo.toString():t.logSendEditSuggestionMessage(n.payload);break;case Vo.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case Ge.toString():t.handleAfterSendMessage(n.payload);break;case no.toString():t.onUpdateShowTabHint(n.payload);break;case rs.toString():t.logHandlingTime();break;case ie.toString():{r&&(e.dispatch(ge([])),e.dispatch(_e()));break}case ge.toString():{r&&n.payload.length>0&&e.dispatch(Me(0));break}default:break}return i},td=Av;function Yr(t){return t.toISOString().replace("T"," ").replace("Z","")}function od(t,e){var s,r,i;let{startTime:o,stopTime:n}=t.handlingTime;if(!o||!n)throw new Error("No startTime and stopTime for handling time metrics");return{conversationId:t.conversation.current.id,clientVersion:e.version,agentId:(s=t.info.agentInfo)==null?void 0:s.agentId,agentName:(r=t.info.agentInfo)==null?void 0:r.agentName,agentEmail:(i=t.info.agentInfo)==null?void 0:i.agentEmail,timeStart:Yr(o),timeStop:Yr(n)}}function ei(t,e,o){var N,$,P;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:d,cuts:u,deletions:g,textSuggestions:m,offeredTextSuggestions:f}}=e[t],h=n.length,y=m.reduce((X,{text:R,searchTerm:B})=>X+R.length-(B?B.length:0),0),x=c??Date.now(),b=(Date.now()-x)/1e3+(p||0),_=s/b,I=m.reduce((X,{searchTerm:R})=>X+(R?R.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:d,cuts:u,deletions:g,lenTextTyped:s+I,lenTextTotal:h,lenTextAssisted:y,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:b,charsPerSecond:_,numPastes:l,textSuggestionsV2:m,suggestionsCounters:[{source:"gpt",countOffered:f.filter(X=>X.source==="gpt").length}],agentId:(N=e.info.agentInfo)==null?void 0:N.agentId,agentName:($=e.info.agentInfo)==null?void 0:$.agentName,agentEmail:(P=e.info.agentInfo)==null?void 0:P.agentEmail}}function ti(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return ti(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?ti(s,e):null}function nd(t,e){return ti(t,e)}function sd(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Lv(t){return typeof t=="object"&&t!==null&&"tagName"in t}function oi(t){return Lv(t)&&(Ue(t)||ln(t))}var rd=(t,e)=>({value(){try{let o=sessionStorage.getItem(`dd-${t}`);if(!o)return e;try{return JSON.parse(o)}catch{return e}}catch{return e}},update(o){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(o))}catch{E.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Mv(t){return t.offsetParent!==null}function id(t){if(!Mv(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 ni(t,e,o=100){let n=id(t);e({isVisible:n});let s=setInterval(()=>{let r=id(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}import Hv from"classnames";import{useSelector as Bv}from"react-redux";import{jsx as si}from"react/jsx-runtime";var ad=({className:t})=>si("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:si("g",{children:si("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
5
+ `);break}default:break}d&&i++}return l(t),a}function Up(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Ht=class extends Ne{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),ns(this.element,e)}getHTML(){return this.element.innerHTML||""}getRange(){var r;let e=this.getRootNode();if(e.activeElement!==this.element)return null;let o="getSelection"in e?e.getSelection():window.getSelection();if(!o)return null;let n="getComposedRanges"in o&&e instanceof ShadowRoot?(r=o.getComposedRanges(e))==null?void 0:r[0]:o.rangeCount>0?o.getRangeAt(0):null;if(!n)return null;let s=this.element.ownerDocument.createRange();return s.setStart(n==null?void 0:n.startContainer,n==null?void 0:n.startOffset),s.setEnd(n==null?void 0:n.endContainer,n==null?void 0:n.endOffset),!s||!this.element.contains(s.startContainer)||!this.element.contains(s.endContainer)?null:s}getCaretPosition(){let e=this.getRange();if(!e||!e.collapsed||!("getBoundingClientRect"in e))return null;let o=e.getBoundingClientRect();return!Up(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!Up(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return os(this.element,e);let o=this.lastKnownSelection;if(o&&Kp(this.element,o.start,o.end))return o;let n=bo(this.element);return n.collapse(!1),os(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return ns(this.element,rt(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return(s=this.observer)==null||s.takeRecords(),Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};function jp(t,e,o){let n=`deepdesk-iframe-${t}`,s=document.getElementById(n);if(s)return s;let r=document.createElement("iframe"),i=new URL(e);return Object.entries(o).forEach(([a,l])=>{i.searchParams.append(a,l)}),r.style.position="absolute",r.style.left="-999em",r.style.width="0px",r.style.height="0px",r.tabIndex=-1,r.id=n,r.title=`iframe-${t}`,r.src=i.toString(),window.document.body.appendChild(r),r}var Gr=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(e)}broadcastChannel;disposeHandlers=[];onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(e)}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},$r=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=jp(e,`${this.targetOrigin}/v2/widget/liveengage/channel.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(e,this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},Xr=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),E.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new $r(e,this.deepdeskUrl,{debug:!0}):new Gr(e),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&s.data.channel===e&&(E.info("Received broadcast event",this.sessionId,s),(i=(r=this.eventMap)[s.data.name])==null||i.call(r,s.data.payload))};return o.onMessage(n),o}send(e,o){var r,i;E.info("broadcast event",{sessionId:this.sessionId,name:e,payload:o});let n={type:"event",name:e,payload:o};(i=(r=this.eventMap)[e])==null||i.call(r,o);let s=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage({...n,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},zp=Xr;var Bt=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Zr=t=>new Promise(e=>{setTimeout(e,t)});var Ft=class extends Bt{name="ClientError"},Qr=class extends Bt{name="ServerError"},ve=class t{constructor(e="",o={}){this.baseUrl=e;this.options=o;o.fetch&&(this.fetch=o.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,o={}){return new Promise((n,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,{abortLatest:l=!1,attempts:c=1,retryDelay:p=500,refreshTokenOn401:d=!0,retryOnError:u=b=>b instanceof TypeError,retryOnResponse:g=b=>b.status>=500,version:m="v1",...f}=o,h={credentials:"include",...f,headers:{"Content-Type":"application/json",...f.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(h.headers={...h.headers,"X-CSRFToken":this.csrfToken}),typeof m=="string"&&(h.headers={...h.headers,"X-Deepdesk-API-Version":m});let w=c,y=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&l&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let x=async()=>(w--,a(i,h).then(async b=>g(b)&&!r.isAborted&&w>0?(await Zr(p),x()):b.status===401&&d===!0&&y===!1?(y=!0,await this.refreshToken(),x()):b).catch(async b=>{if(u(b)&&!r.isAborted&&w>0)return await Zr(p),x();throw b}));x().then(b=>b.json().catch(()=>null).then(_=>{b.status>=500?s(new Qr("Server Error",_)):b.status===401?s(new Ft("Unauthorized",_)):b.status===403?s(new Ft("Forbidden",_)):b.status===404?s(new Ft("Not Found",_)):b.status>=400&&s(new Ft("Bad Request",_)),delete this.latestRequestByUrl[i],n(_)})).catch(b=>{s(b)})})}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var xv;(e=>{let t;(l=>(l.SEND_MESSAGE="Send Message",l.HANDLING_TIME="Handling Time",l.START_AUTOFLOW="Start Autoflow",l.ABORT_AUTOFLOW="Abort Autoflow",l.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",l.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(t=e.EventType||={})})(xv||={});function ss(t){return{...A(t),tags:t.tags}}var ze=class t{constructor(e,o={}){this.options=o;this.client=new ve(e,{fetch:o.fetch}),this.client.patchFetch(n=>async(s,r)=>{let i=await n(s,r);return this.handleDeepdeskVersionHeaders(i),i})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=await this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(t.exchangeTokenPromise||(t.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),t.exchangeTokenPromise):Promise.resolve()}async createConversation(e){await this.preflight(),E.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...K(e),tags:e.tags},{version:"v2"});return ss(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return A(o)}async getKnowledgeAssistant(e){let o=await this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{version:null});return A(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return A(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return A(e)}async checkUserExists(e){let{exists:o}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return o}async getConversationBySessionId(e,o={}){await this.preflight(),E.info(`Getting conversation for session ${e}`);let{attempts:n=1,retryDelay:s=1e3}=o,r=await this.client.get(`/api/conversations/by_session_id/${e}`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"});return ss(r)}async isConversationSupported(e,o={}){E.info(`Check if conversation for session ${e} is supported`);let{attempts:n=1,retryDelay:s=1e3}=o;return(await this.client.get(`/api/conversations/by_session_id/${e}/active_profile`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"})).has_active_profile}async updateConversation(e,o){let n=K(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return ss(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...K(s),tags:s.tags})),{version:"v2"})).map(s=>ss(s))}async sendEvent(e,o){let{data:n,...s}=o,r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((i,[a,l])=>({...i,[a]:l}),{});return this.client.post("/api/events",K({...r,...s,data:n,name:e}),{version:"v2"})}async sendEventV1(e,o){let n=Object.entries(this.latestReceivedDeepdeskVersions).reduce((s,[r,i])=>({...s,[r]:i}),{});return this.client.post("/api/events",{event:e,data:K({...o,...n})})}async getEntities(e){return(await this.client.post("/api/entities",{messages:e.filter(n=>n.text)})).entities}async getSummary(e,o={}){return(await this.client.post("/api/summary",{conversation:{messages:e.filter(s=>s.text&&s.source)},prompt_instruction:o.promptInstruction,model:o.model})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(e){return this.client.post("/apis/admin/session/jwt/",{jwt:e},{version:null}).catch(o=>{throw E.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",K(o),{version:null,refreshTokenOn401:!1,headers:{apikey:e}})}async getTextSuggestions(e,o={},n){return n==="sticky-messages"?this.getPinnedMessages(e):(await this.client.post(`/api/conversations/${e}/recommend/${n}`,K(o),{abortLatest:!0})).map(r=>({...A(r),text:r.text||r.url||r.message,source:n,type:n})).filter((r,i,a)=>i===a.findIndex(l=>l.text===r.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(e,o){return(await this.client.post(`/api/conversations/${e}/autocomplete`,K(o),{abortLatest:!0})).map(s=>({score:1,source:s.source,sourceText:s.source_text,text:s.label,trainingJobs:s.training_jobs,searchKeywords:s.search_keywords,type:s.source})).filter((s,r,i)=>r===i.findIndex(a=>a.text===s.text))}async getPinnedMessages(e){let o=await this.client.get(`/api/conversations/${e}/sticky-messages`,{abortLatest:!0});return A(o).map(n=>({...n,text:n.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(e){let o=await this.client.post("/api/style-suggestions",K(e),{abortLatest:!0});return A(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,K(e),{version:"v2"});return A(o)}async knowledgeAssist(e,o,n){let s=await this.client.post(`/api/knowledge-assist/assistants/${n}/search`,K({question:e.question,promptInstruction:e.promptInstruction,chatHistory:o.map(r=>({question:r.question,answer:r.answer.answer}))}),{version:"v2"});return A(s)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return A(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return A(e.token)}async getCsrfToken(){let{token:e}=await this.client.get("/apis/admin/session/csrf/",{version:null});return e}async verifyLoginToken(e){let o=await this.client.post("/apis/admin/session/passwordless/login/",{token:e},{version:null});return A(o)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(hi);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&E.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var Co=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(er(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,A(s))}catch{E.warn(`Invalid JSON for ${e}: ${n}`)}})}connect(){clearTimeout(this.timeoutTimer);let e=new EventSource(this.url,{withCredentials:!0});this.eventSource=e;let o=!1;e.onopen=()=>{o=!0},e.onerror=()=>{o&&e.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{e.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(n=>{this.proxyEvent(n)})}disconnect(){var e;clearTimeout(this.timeoutTimer),this.eventListeners={},(e=this.eventSource)==null||e.close()}emit(e,o){this.eventListeners[e]&&this.eventListeners[e].forEach(n=>n(o))}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),this.proxyEvent(e),()=>{this.off(e,o)}}off(e,o){let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}};var bv;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(bv||={});var wo=class{constructor(e,o={}){this.apiUrl=e;this.client=new ve(e,o)}client;streams={};logger=E;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return A(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,K(o));return A(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,K(o))}async getAutoflows(e){let o=await this.client.get(`/sessions/${e}/autoflows`);return A(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",K(e));return A(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new Co(`${this.apiUrl}/sessions/${e}/events`),this.streams[e].connect()),this.streams[e]}closeStream(e){this.streams[e]||(this.streams[e].disconnect(),delete this.streams[e])}};import{combineReducers as Iv,configureStore as Pv}from"@reduxjs/toolkit";import{createSlice as Cv}from"@reduxjs/toolkit";var Vp={startTime:null,stopTime:null},qp=Cv({name:"handlingTime",initialState:Vp,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(L,()=>Vp)}}),{handlingTimeStart:Wp,handlingTimeStop:rs,handlingTimeReset:Gp}=qp.actions,$p=qp.reducer;var Xp=(t={})=>{let e={onAuthError:kt(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};import{createAsyncThunk as wv,createSlice as Tv}from"@reduxjs/toolkit";var is={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var it=wv("styleSuggestions/getAll",async({text:t},e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),{showStyleSuggestions:s}=n.settings,r=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)return is.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),Ev=Tv({name:"styleSuggestions",initialState:is,reducers:{},extraReducers:t=>{t.addCase(it.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(it.rejected,e=>{e.fetchState="error"}).addCase(it.fulfilled,(e,o)=>{e.fetchState="done",Ae(e.list,o.payload)||(e.list=o.payload)}).addCase(Ge,e=>{e.list=is.list}).addCase(L,()=>is)}}),Zp=Ev.reducer;var Qp=(t={})=>{let e,o=!0,n={getStyleSuggestions:it,debounce:500,...t};return s=>r=>i=>{var g;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:p}=c.settings;if(!((g=c.conversation.current)==null?void 0:g.id)||!p)return l;let{text:u}=c.input;return u===a&&!o||(clearTimeout(e),u==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:u}))},t.debounce)),l}};function kv(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Jp=(t={})=>{let e={getTextSuggestions:ce,getAutocompleteSuggestions:no,debounce:200,check:Mt,...t},o;return n=>s=>r=>{var f;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:p}=l.settings,d=(f=l.conversation.current)==null?void 0:f.id,u=r.type===wn.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:g}}=l;return kv(g,i)&&!u||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let h=ht(l);h===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(h))},u?0:e.debounce)),a}};var Yp=it.fulfilled.toString();function Rv(t,e){let o=new Set([...e.keywordMatches.map(s=>s.keyword)]),n=[];return o.forEach(s=>{let r=t.keywordMatches.filter(l=>l.keyword===s),i=e.keywordMatches.filter(l=>l.keyword===s),a=i.length-r.length;a<=0||n.push(...i.slice(0,a))}),n}var ed=t=>e=>o=>n=>{var c;if(n.type!==Yp){o(n);return}let s=e.getState().styleSuggestions.list;o(n);let r=e.getState(),i=r.styleSuggestions.list,a=(c=r.conversation)==null?void 0:c.current;if(s===i)return;let l=Rv(s,i);n.type===Yp&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var Av=Iv({activeSuggestion:gl,answer:oc,auth:El,autoflows:ep,conversation:bi,contentTypes:Hl,customMessages:cp,passwordlessToken:mp,entities:Kl,knowledgeAssistant:Yl,handlingTime:$p,info:Ba,input:ws.reducer,overlayInput:Z.reducer,settings:vi,profile:ac,search:Va,summary:Gl,styleSuggestions:Zp,ui:yl,textSuggestions:ll});function td(t){return Pv({reducer:Av,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Xp(),Jp({debounce:200}),Qp({debounce:500}),ed(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Lv=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Mv=t=>e=>o=>n=>{var a;let s=e.getState(),r=_s("inlineSuggestions")(s);switch(n.type){case Ce.toString():{let l=Cn(n.payload.contentType)(e.getState()),c=l.indexOf(n.payload.suggestion);t.emit("edit-suggestion",{contentType:n.payload.contentType,index:c,suggestions:l});break}case kt.toString():{!n.payload&&t.emit("logout",void 0);break}case ie.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:Lv(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case jo.toString():{let{start:l,end:c}=s.input.selection;t.emit("replace",{...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Wt.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case Wo.toString():t.emit("select-image",n.payload,{mayApplyChanges:!0}),t.sendEvent("Image attached",{conversationId:s.conversation.current.id,data:{path:n.payload.suggestion.image,title:n.payload.suggestion.title}});break;case pe.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case Ee.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary}});break;case V.toString():t.sendEvent(n.payload.name,{conversationId:((a=n.payload.options)==null?void 0:a.includeConversationData)&&s.conversation.current.id,data:n.payload.data});break;case zo.toString():t.handleKeyDown(n.payload);break;case Ge.toString():t.logSendMessage(n.payload);break;case Vo.toString():t.logSendEditSuggestionMessage(n.payload);break;case qo.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case Ge.toString():t.handleAfterSendMessage(n.payload);break;case so.toString():t.onUpdateShowTabHint(n.payload);break;case rs.toString():t.logHandlingTime();break;case ie.toString():{r&&(e.dispatch(ge([])),e.dispatch(_e()));break}case ge.toString():{r&&n.payload.length>0&&e.dispatch(Me(0));break}default:break}return i},od=Mv;function Jr(t){return t.toISOString().replace("T"," ").replace("Z","")}function nd(t,e){var s,r,i;let{startTime:o,stopTime:n}=t.handlingTime;if(!o||!n)throw new Error("No startTime and stopTime for handling time metrics");return{conversationId:t.conversation.current.id,clientVersion:e.version,agentId:(s=t.info.agentInfo)==null?void 0:s.agentId,agentName:(r=t.info.agentInfo)==null?void 0:r.agentName,agentEmail:(i=t.info.agentInfo)==null?void 0:i.agentEmail,timeStart:Jr(o),timeStop:Jr(n)}}function Yr(t,e,o){var N,$,P;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:d,cuts:u,deletions:g,textSuggestions:m,offeredTextSuggestions:f}}=e[t],h=n.length,y=m.reduce((X,{text:R,searchTerm:B})=>X+R.length-(B?B.length:0),0),x=c??Date.now(),b=(Date.now()-x)/1e3+(p||0),_=s/b,I=m.reduce((X,{searchTerm:R})=>X+(R?R.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:d,cuts:u,deletions:g,lenTextTyped:s+I,lenTextTotal:h,lenTextAssisted:y,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:b,charsPerSecond:_,numPastes:l,textSuggestionsV2:m,suggestionsCounters:[{source:"gpt",countOffered:f.filter(X=>X.source==="gpt").length}],agentId:(N=e.info.agentInfo)==null?void 0:N.agentId,agentName:($=e.info.agentInfo)==null?void 0:$.agentName,agentEmail:(P=e.info.agentInfo)==null?void 0:P.agentEmail}}function ei(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return ei(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?ei(s,e):null}function sd(t,e){return ei(t,e)}function rd(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Nv(t){return typeof t=="object"&&t!==null&&"tagName"in t}function ti(t){return Nv(t)&&(Ue(t)||cn(t))}var id=(t,e)=>({value(){try{let o=sessionStorage.getItem(`dd-${t}`);if(!o)return e;try{return JSON.parse(o)}catch{return e}}catch{return e}},update(o){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(o))}catch{E.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Ov(t){return t.offsetParent!==null}function ad(t){if(!Ov(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 oi(t,e,o=100){let n=ad(t);e({isVisible:n});let s=setInterval(()=>{let r=ad(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}import Fv from"classnames";import{useSelector as Kv}from"react-redux";import{jsx as ni}from"react/jsx-runtime";var ld=({className:t})=>ni("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:ni("g",{children:ni("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
6
6
  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
7
7
  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
8
8
  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
9
- 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 ld}from"react/jsx-runtime";var Nv={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},cd=({className:t,color:e})=>ld("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:ld("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:Nv[e||"pink"]})});var pd={root:"_root_1tvv4_1",text:"_text_1tvv4_18",isLoggedIn:"_isLoggedIn_1tvv4_25",isLoggedOut:"_isLoggedOut_1tvv4_29",icon:"_icon_1tvv4_39",logo:"_logo_1tvv4_44",lock:"_lock_1tvv4_49"};var ri={};j(ri,{enUS:()=>Ov,nlNL:()=>Dv});var Ov={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},Dv={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};import{useDispatch as Fv}from"react-redux";import{jsx as ii,jsxs as dd}from"react/jsx-runtime";var ud=({onLogIn:t})=>{let e=T(ri),o=C("productName"),n=Fv(),s=Bv(oe),r=v("FloatingMenu",pd);if(s===null)return null;let i=()=>{s===!0?n(W(!0)):t()};return dd("button",{className:Hv(r.root,{[r.isLoggedIn]:s,[r.isLoggedOut]:!s}),onClick:i,children:[ii("div",{className:r.text,children:e(s?"search":"signin",{productName:o})}),dd("div",{className:r.icon,children:[ii(cd,{className:r.logo,color:"pink"}),s===!1&&ii(ad,{className:r.lock})]})]})};async function ai(t){let o=await new ve(t).get("/platform/config/",{version:null});return A(o)}import{jsx as U}from"react/jsx-runtime";var gd=rd("showTabHint",!0),ls=class t{static version="10.10.2";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new je(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[td({emit:(d,u,g)=>this.emit(d,u,g),handleAfterSendMessage:d=>this.handleAfterSendMessage(d),handleInputChanged:d=>this.handleInputChanged(d),handleKeyDown:d=>this.handleKeyDown(d),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:d=>this.logSendMessage(d),logSendEditSuggestionMessage:d=>this.logSendEditMessage(d),onUpdateShowTabHint:d=>gd.update(d),sendEvent:(d,u)=>this.deepdeskApi.sendEvent(d,u)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new Co(o)}),this.store=ed(p),this.broadcastEvents=new zp({debug:!0,deepdeskUrl:c,eventMap:El(this.store),createCustomChannel:l}),this.store.dispatch(Vt),this.store.dispatch(no(gd.value())),this.store.dispatch(Vt({locale:s,adminUrl:c,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}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)}login(){return this.store.dispatch(Et(null)),this.store.dispatch(we()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();oe(n)&&Sl(n)!=="loading"&&(o(),e())});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(we())).payload}async setPlatformAgentId(e){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:e}),version:null})}catch(o){E.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(bs({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Oo(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Do({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Cs(e))).payload}async postMessages(e){return(await this.store.dispatch(Bo(e))).payload}async updateConversation(e){return(await this.store.dispatch(Ho(e))).payload}resetConversation(){this.store.dispatch(L()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(Ee());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Vt(e))}setVisitorInfo(e){this.store.dispatch(Da(e))}async setAgentInfo(e){await this.store.dispatch(Yt(e))}async setAgentSettings(e){await this.store.dispatch(nr(e))}async getAgentSettings(){return(await this.store.dispatch(sr())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(wn()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Vo(e))}notifyKeyDown(e){this.store.dispatch(zo(e))}notifyPaste(e,o){this.store.dispatch(Ni({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Li(e))}notifyExternalSuggestion(e){this.store.dispatch(ie(e)),this.store.dispatch(_e())}notifyEditSuggestion(e){this.store.dispatch(rl(e.contentType,e.suggestions)),this.store.dispatch(Ce({contentType:e.contentType,suggestion:typeof e.index=="number"?e.suggestions[e.index]:null}))}handleInputChanged(e){let{overlayCollapsed:o,openOverlayWhenTyping:n}=this.state.ui;o&&n&&this.store.dispatch(Fe({collapse:!1})),this.inputMediator&&this.store.dispatch(Ei({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(ge([])))}handleKeyDown(e){let{overlayCollapsed:o}=this.state.ui,{textSuggestions:n,selectedSuggestionIndex:s,selection:r}=this.state.input,{inlineSuggestions:i}=this.state.settings,a=n.length>0,l=s!==-1;if(this.store.dispatch(Mi(Ko(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(Ii()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Ai());let{selectedSuggestionIndex:d}=this.state.input;e.preventDefault(),!i&&(d===-1?this.store.dispatch(qt()):this.stageSelectedSuggestion({inputType:"arrow"}))};switch(e.key){case"Up":case"ArrowUp":i?p():c();return;case"Down":case"ArrowDown":{i?c():p();return}case"Esc":case"Escape":{i&&l&&this.store.dispatch(Me(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(Me(-1)),this.store.dispatch(qt()),e.preventDefault()):o||(this.store.dispatch(Fe({collapse:!0})),this.store.dispatch(ml(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:d}=this.state.input,u=d.text.substring(0,d.selection.end),{tabCompletionSuggestion:g}=this.state.input;this.store.dispatch(no(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&g&&g.text.startsWith(u)&&(this.store.dispatch(ie({text:g.text,suggestion:g,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(_e())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Oi()),this.store.dispatch(ge([]))}handlingTimeStart(){this.state.handlingTime.startTime||(E.info("Start handling time"),this.store.dispatch(qp()))}handlingTimeStop(){this.state.handlingTime.startTime&&(E.info("Stop handling time"),this.store.dispatch(rs()))}logSendMessage(e){let o=ei("input",this.state,{version:this.version});e&&(Object.assign(o,{text:e}),Object.assign(o,{lenTextTotal:e.length})),this.deepdeskApi.sendEventV1("Send Message",o),this.emit("send-message-event",o)}logSendEditMessage(e){let o=ei("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(Ri(this.state.overlayInput.metrics))}logHandlingTime(){let e=od(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Wp())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(_e()),this.store.dispatch(Ge(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(ie({text:n[o].text,suggestion:n[o],eventMetrics:e,replace:"until-selection-end"}))}emit(e,o,n={}){let s=()=>{this.eventListeners[e]&&this.eventListeners[e].forEach(r=>{try{r(o)}catch(i){E.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),E.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=xt(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{as(r),i(),r.remove()}),r}createInlineContainer(e,o){var i;let n=document.createElement("div");n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.style.height="0px",n.style.width="0px";let s=document.createElement("div");s.style.display="none",s.style.position="absolute",s.style.height="0px",s.style.width="0px",s.style.backgroundColor="red",n.appendChild(s);let r=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;if(r){let[a,l]=xt(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{as(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Xe(s),s.dataset.testid=e,s.style.color=n.color,s.style.fontSize=n.fontSize,s.style.fontFamily=n.fontFamily,s.style.fontVariant=n.fontVariant,s.setAttribute("translate","no"),o.appendChild(s),this.unmountHandlers.push(()=>{as(s),s.remove()}),s}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,o),E.info(`Stored analytics for ${this.conversationId()}`)}catch{}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=window.sessionStorage.getItem(e);if(!o)return;let n=JSON.parse(o);n.text.trim()===this.state.input.text.trim()?(E.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(Hi(n.metrics))):E.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch{}}mount(e,o={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!oi(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:n={},showStyleSuggestions:s,showTabCompletion:r,showTextSuggestions:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,isEmbedded:d,detectSubmit:u,insertLink:g,inputMediator:m,closestScrollSelector:f,appendOverlayTo:h,inlineSuggestions:w,floatingMenu:y}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:g,isEmbedded:d,inlineSuggestions:w,floatingMenu:!!y}),o.automaticHandlingTime&&this.setupHandlingTime(e),Xe(e),this.inputMediator=m||(Ue(e)?new Oe(e):new Dt(e)),this.inputMediator.on("change",({plainText:_})=>{this.notifyInputChanged(_)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Di({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",_=>{this.notifyKeyDown(_)}),this.inputMediator.on("paste",({pastedText:_,selectionText:I})=>{this.notifyPaste(_,I)}),this.inputMediator.on("cut",({selectionText:_})=>{this.notifyCut(_)});let x=f&&nd(e,f)||void 0;if(w){let{customStyles:_,appendOverlayTo:I}=o;if(Ue(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let N=this.createInlineContainer(e,"deepdesk-caret");Ft(U(tt,{store:this.store,customStyles:_,children:U(et,{broadcastEvents:this.broadcastEvents,children:U(yc,{})})}),N),this.inputMediator.on("caret",P=>{this.store.dispatch(ge([])),P?(N.style.display="block",N.style.top=`${P.top}px`,N.style.left=`${P.left}px`):N.style.display="none"});let $=this.overlayContainerFactory("floating-menu",x||e,{appendTo:typeof y=="object"&&"appendOverlayTo"in y?y.appendOverlayTo:I},_==null?void 0:_.floatingMenuRootNode);Ft(U(tt,{store:this.store,customStyles:_,children:U(et,{broadcastEvents:this.broadcastEvents,children:U(ud,{onLogIn:()=>this.loginViaPopup().catch(P=>E.warn(P.message))})})}),$)}else{let _=this.overlayContainerFactory("deepdesk-tab-completion",x||e,{appendTo:h,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),I=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||e,{appendTo:h},n==null?void 0:n.suggestionsRootNode);Ft(U(tt,{store:this.store,customStyles:n,children:U(et,{broadcastEvents:this.broadcastEvents,children:U(Gc,{inputElement:e})})}),_),Ft(U(tt,{store:this.store,customStyles:n,children:U(et,{broadcastEvents:this.broadcastEvents,children:U(Ec,{onLogIn:()=>this.loginViaPopup().catch(N=>E.warn(N.message))})})}),I)}Ft(U(tt,{store:this.store,customStyles:n,children:U(et,{broadcastEvents:this.broadcastEvents,children:U(dc,{})})}),this.createContainer("deepdesk-overlays"));let b;this.inputMediator.on("selection",_=>{clearTimeout(b),_===null?b=setTimeout(()=>{_!==null&&this.store.dispatch(Ts(_))},500):this.store.dispatch(Ts(_))}),this.inputMediator.on("disabled",()=>{var _;(_=this.inputMediator)==null||_.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{u&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(Tt(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(Tt(!0))),this.store.dispatch(ki({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(_e()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var _;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((_=this.state.conversation.current)==null?void 0:_.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&E.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:n,showImages:s,isEmbedded:r}=o;this.widgetRoot=e,this.configure({showImages:s,isEmbedded:r}),Ft(U(tt,{store:this.store,customStyles:n,children:U(et,{broadcastEvents:this.broadcastEvents,children:U(Bp,{onLogIn:()=>this.loginViaPopup().catch(i=>E.warn(i.message))})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setSessionId((i=this.state.conversation.current)==null?void 0:i.sessionId)})}unmountWidget(){this.widgetRoot&&as(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=ni(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){sd(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(uo());let e=Ke(this.state);e&&(await this.store.dispatch(po()),this.store.dispatch(Vt({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions})))}),this.loadProfileConfigPromise)}async loginViaPopup(){let e=this.state.settings.adminUrl,o=new URL(e),n=await ai(o.origin);return new Promise((s,r)=>{let i=new MessageChannel,a=i.port1,l=new URL(n.config.platform.hasSso?`${e}/platform/sso/`:`${e}/admin/`);l.searchParams.append("redirect","/sdk/popup/close.html");let c=!1,p=()=>{d&&!d.closed&&d.close(),window.removeEventListener("message",u),clearInterval(g)};a.onmessage=async m=>{var f,h;if((f=m.data)!=null&&f.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((h=m.data)==null?void 0:h.jwt),await this.isLoggedIn(),this.broadcastEvents.send(ro),p(),c=!0,i.port1.close(),s()}catch(w){r(w)}};let d=window.open(l.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");d===null&&r(new Error("Popup blocked by browser"));let u=async m=>{var f;if(m.origin===l.origin)switch((f=m.data)==null?void 0:f.type){case"deepdesk-popup-loaded":{d==null||d.postMessage({type:"deepdesk-popup-create-channel"},l.origin,[i.port2]);break}case"deepdesk-popup-error":{p(),m.data.message==="Timeout"&&E.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(m.data.message));break}}};window.addEventListener("message",u);let g=setInterval(()=>{d&&!d.closed||(p(),c||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(p)})}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(E.info("Trial is active"),!await this.deepdeskApi.checkUserExists(e))throw new Error("User is not in trial");this.shouldRender=!0}catch(o){let{message:n}=o;E.info(n),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let o=Pn(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(pe()):this.store.dispatch(ce(n))})}catch(n){this.handleError(n)}}};async function Kv(t,e,o={}){let{value:n}=t,{start:s,end:r}=o.replace??{start:0,end:n.length},i=`${n.slice(0,s)}${e}${n.slice(r)}`,a=o.selectionAfter??{start:s+e.length,end:s+e.length},l=()=>{if(o.setValue)return o.setValue(i);t.value=i};return Promise.resolve(l()).then(()=>{t.selectionStart=a.start,t.selectionEnd=a.end,t.blur(),t.focus()})}async function Uv(t,e,o={}){let n=o.replace?rt(t,o.replace.start,o.replace.end):xo(t),s,r=()=>{if(o.setRange)return o.setRange(n.cloneRange());n.deleteContents(),s=document.createElement("span"),n.insertNode(s),o.insertBRs!==!1?e.split(`
10
- `).reverse().forEach((i,a)=>{a>0&&n.insertNode(document.createElement("br")),n.insertNode(document.createTextNode(i))}):n.insertNode(document.createTextNode(e))};return Promise.resolve(r()).then(()=>{try{if(o.selectionAfter!==!1){t.focus();let i=o.selectionAfter?rt(t,o.selectionAfter.start,o.selectionAfter.end):(n.collapse(!1),n),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(i)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function zv(t){let e=document.createElement("template");return e.innerHTML=t,e.content}function jv(t){let e=document.createDocumentFragment();return t.split(`
11
- `).forEach((o,n)=>{n>0&&e.appendChild(document.createElement("br")),e.appendChild(document.createTextNode(o))}),e}function md(t,e){return!t.contains(e)||e===t?null:e.parentNode===t?e:md(t,e.parentNode)}async function Vv(t,e,{isBlock:o,isHTML:n}={}){let s;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let r=()=>{let i=t.ownerDocument.defaultView??window,a=i.getSelection();if((!a||a.rangeCount===0)&&(t.focus(),a=i.getSelection()),!a||a.rangeCount===0)return;let l=a.getRangeAt(0);if(!l)return;s=document.createElement("span"),l.insertNode(s);let c=n?zv(e):jv(e);if(o){let p=md(t,l.startContainer)??t.firstChild;t.insertBefore(c,(p==null?void 0:p.nextSibling)??null)}else l.insertNode(c),l.collapse(!1)};return Promise.resolve(r()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!s)try{s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function qv(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function Wv(t,e,o){await new je(t).authenticateWithKey(e,o)}async function Gv(t){let o=await(t.fetch??window.fetch)(t.url),n=await o.blob();return new File([n],t.name,{type:t.mimeType??o.headers.get("Content-Type")??"image/jpeg"})}async function $v(t,e){let o=await Gv(e),n=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(t,"files",{configurable:!0,get:()=>[o]}),t.dispatchEvent(n)}finally{Object.hasOwn(t,"files")&&delete t.files}}export{H as Card,Dt as ContentEditableInput,je as DeepdeskAPI,ls as DeepdeskSDK,ve as HTTPClient,Ne as InputMediator,qe as InputType,gs as KeyboardHint,ms as Label,Lo as Locale,Ve as Section,hs as SectionList,ue as Sources,D as Suggestion,re as SuggestionList,Oe as TextAreaInput,ut as ToggleButton,$v as attachFile,Wv as authenticateWithKey,xo as createFullRange,xt as createOverlayContainer,rt as createRangeFromOffsets,Qt as escapeHTML,ai as fetchPlatformConfig,qv as formatTextMarkup,os as getRangeOffsets,ns as getRangeText,Vv as insertCKEditor,oi as isSupportedInputElement,Uv as updateContentEditable,Kv as updateTextArea,v as useStyles,ni as waitForElementVisibilityChange};
9
+ 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 cd}from"react/jsx-runtime";var Dv={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},pd=({className:t,color:e})=>cd("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:cd("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:Dv[e||"pink"]})});var dd={root:"_root_1tvv4_1",text:"_text_1tvv4_18",isLoggedIn:"_isLoggedIn_1tvv4_25",isLoggedOut:"_isLoggedOut_1tvv4_29",icon:"_icon_1tvv4_39",logo:"_logo_1tvv4_44",lock:"_lock_1tvv4_49"};var si={};z(si,{enUS:()=>Hv,nlNL:()=>Bv});var Hv={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},Bv={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};import{useDispatch as Uv}from"react-redux";import{jsx as ri,jsxs as ud}from"react/jsx-runtime";var gd=({onLogIn:t})=>{let e=T(si),o=C("productName"),n=Uv(),s=Kv(oe),r=v("FloatingMenu",dd);if(s===null)return null;let i=()=>{s===!0?n(W(!0)):t()};return ud("button",{className:Fv(r.root,{[r.isLoggedIn]:s,[r.isLoggedOut]:!s}),onClick:i,children:[ri("div",{className:r.text,children:e(s?"search":"signin",{productName:o})}),ud("div",{className:r.icon,children:[ri(pd,{className:r.logo,color:"pink"}),s===!1&&ri(ld,{className:r.lock})]})]})};async function ii(t){let o=await new ve(t).get("/platform/config/",{version:null});return A(o)}import{jsx as U}from"react/jsx-runtime";var md=id("showTabHint",!0),ls=class t{static version="10.10.3-beta.1";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new ze(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[od({emit:(d,u,g)=>this.emit(d,u,g),handleAfterSendMessage:d=>this.handleAfterSendMessage(d),handleInputChanged:d=>this.handleInputChanged(d),handleKeyDown:d=>this.handleKeyDown(d),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:d=>this.logSendMessage(d),logSendEditSuggestionMessage:d=>this.logSendEditMessage(d),onUpdateShowTabHint:d=>md.update(d),sendEvent:(d,u)=>this.deepdeskApi.sendEvent(d,u)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new wo(o)}),this.store=td(p),this.broadcastEvents=new zp({debug:!0,deepdeskUrl:c,eventMap:kl(this.store),createCustomChannel:l}),this.store.dispatch(qt),this.store.dispatch(so(md.value())),this.store.dispatch(qt({locale:s,adminUrl:c,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}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)}login(){return this.store.dispatch(kt(null)),this.store.dispatch(we()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();oe(n)&&_l(n)!=="loading"&&(o(),e())});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(we())).payload}async setPlatformAgentId(e){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:e}),version:null})}catch(o){E.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(bs({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Do(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Ho({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Cs(e))).payload}async postMessages(e){return(await this.store.dispatch(Fo(e))).payload}async updateConversation(e){return(await this.store.dispatch(Bo(e))).payload}resetConversation(){this.store.dispatch(L()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(Ee());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(qt(e))}setVisitorInfo(e){this.store.dispatch(Ha(e))}async setAgentInfo(e){await this.store.dispatch(eo(e))}async setAgentSettings(e){await this.store.dispatch(or(e))}async getAgentSettings(){return(await this.store.dispatch(nr())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(wn()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(qo(e))}notifyKeyDown(e){this.store.dispatch(zo(e))}notifyPaste(e,o){this.store.dispatch(Mi({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Ai(e))}notifyExternalSuggestion(e){this.store.dispatch(ie(e)),this.store.dispatch(_e())}notifyEditSuggestion(e){this.store.dispatch(il(e.contentType,e.suggestions)),this.store.dispatch(Ce({contentType:e.contentType,suggestion:typeof e.index=="number"?e.suggestions[e.index]:null}))}handleInputChanged(e){let{overlayCollapsed:o,openOverlayWhenTyping:n}=this.state.ui;o&&n&&this.store.dispatch(Fe({collapse:!1})),this.inputMediator&&this.store.dispatch(Ti({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(ge([])))}handleKeyDown(e){let{overlayCollapsed:o}=this.state.ui,{textSuggestions:n,selectedSuggestionIndex:s,selection:r}=this.state.input,{inlineSuggestions:i}=this.state.settings,a=n.length>0,l=s!==-1;if(this.store.dispatch(Li(Uo(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(Ri()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{o||!a||i&&s<=0||r&&(e.shiftKey||(this.store.dispatch(Pi()),e.preventDefault(),!i&&(this.state.input.selectedSuggestionIndex===-1?this.store.dispatch(Wt()):this.stageSelectedSuggestion({inputType:"arrow"}))))};switch(e.key){case"Up":case"ArrowUp":i?p():c();return;case"Down":case"ArrowDown":{i?c():p();return}case"Esc":case"Escape":{i&&l&&this.store.dispatch(Me(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(Me(-1)),this.store.dispatch(Wt()),e.preventDefault()):o||(this.store.dispatch(Fe({collapse:!0})),this.store.dispatch(fl(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:d}=this.state.input,u=d.text.substring(0,d.selection.end),{tabCompletionSuggestion:g}=this.state.input;this.store.dispatch(so(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&g&&g.text.startsWith(u)&&(this.store.dispatch(ie({text:g.text,suggestion:g,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(_e())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ni()),this.store.dispatch(ge([]))}handlingTimeStart(){this.state.handlingTime.startTime||(E.info("Start handling time"),this.store.dispatch(Wp()))}handlingTimeStop(){this.state.handlingTime.startTime&&(E.info("Stop handling time"),this.store.dispatch(rs()))}logSendMessage(e){let o=Yr("input",this.state,{version:this.version});e&&(Object.assign(o,{text:e}),Object.assign(o,{lenTextTotal:e.length})),this.deepdeskApi.sendEventV1("Send Message",o),this.emit("send-message-event",o)}logSendEditMessage(e){let o=Yr("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(ki(this.state.overlayInput.metrics))}logHandlingTime(){let e=nd(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Gp())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(_e()),this.store.dispatch(Ge(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(ie({text:n[o].text,suggestion:n[o],eventMetrics:e,replace:"until-selection-end"}))}emit(e,o,n={}){let s=()=>{this.eventListeners[e]&&this.eventListeners[e].forEach(r=>{try{r(o)}catch(i){E.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),E.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=xt(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{as(r),i(),r.remove()}),r}createInlineContainer(e,o){var i;let n=document.createElement("div");n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.style.height="0px",n.style.width="0px";let s=document.createElement("div");s.style.display="none",s.style.position="absolute",s.style.height="0px",s.style.width="0px",s.style.backgroundColor="red",n.appendChild(s);let r=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;if(r){let[a,l]=xt(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{as(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Xe(s),s.dataset.testid=e,s.style.color=n.color,s.style.fontSize=n.fontSize,s.style.fontFamily=n.fontFamily,s.style.fontVariant=n.fontVariant,s.setAttribute("translate","no"),o.appendChild(s),this.unmountHandlers.push(()=>{as(s),s.remove()}),s}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,o),E.info(`Stored analytics for ${this.conversationId()}`)}catch{}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=window.sessionStorage.getItem(e);if(!o)return;let n=JSON.parse(o);n.text.trim()===this.state.input.text.trim()?(E.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(Di(n.metrics))):E.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch{}}mount(e,o={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!ti(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:n={},showStyleSuggestions:s,showTabCompletion:r,showTextSuggestions:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,isEmbedded:d,detectSubmit:u,insertLink:g,inputMediator:m,closestScrollSelector:f,appendOverlayTo:h,inlineSuggestions:w,floatingMenu:y}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:g,isEmbedded:d,inlineSuggestions:w,floatingMenu:!!y}),o.automaticHandlingTime&&this.setupHandlingTime(e),Xe(e),this.inputMediator=m||(Ue(e)?new Oe(e):new Ht(e)),this.inputMediator.on("change",({plainText:_})=>{this.notifyInputChanged(_)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Oi({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",_=>{this.notifyKeyDown(_)}),this.inputMediator.on("paste",({pastedText:_,selectionText:I})=>{this.notifyPaste(_,I)}),this.inputMediator.on("cut",({selectionText:_})=>{this.notifyCut(_)});let x=f&&sd(e,f)||void 0;if(w){let{customStyles:_,appendOverlayTo:I}=o;if(Ue(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let N=this.createInlineContainer(e,"deepdesk-caret");Kt(U(tt,{store:this.store,customStyles:_,children:U(et,{broadcastEvents:this.broadcastEvents,children:U(vc,{})})}),N),this.inputMediator.on("caret",P=>{this.store.dispatch(ge([])),P?(N.style.display="block",N.style.top=`${P.top}px`,N.style.left=`${P.left}px`):N.style.display="none"});let $=this.overlayContainerFactory("floating-menu",x||e,{appendTo:typeof y=="object"&&"appendOverlayTo"in y?y.appendOverlayTo:I},_==null?void 0:_.floatingMenuRootNode);Kt(U(tt,{store:this.store,customStyles:_,children:U(et,{broadcastEvents:this.broadcastEvents,children:U(gd,{onLogIn:()=>this.loginViaPopup().catch(P=>E.warn(P.message))})})}),$)}else{let _=this.overlayContainerFactory("deepdesk-tab-completion",x||e,{appendTo:h,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),I=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||e,{appendTo:h},n==null?void 0:n.suggestionsRootNode);Kt(U(tt,{store:this.store,customStyles:n,children:U(et,{broadcastEvents:this.broadcastEvents,children:U($c,{inputElement:e})})}),_),Kt(U(tt,{store:this.store,customStyles:n,children:U(et,{broadcastEvents:this.broadcastEvents,children:U(kc,{onLogIn:()=>this.loginViaPopup().catch(N=>E.warn(N.message))})})}),I)}Kt(U(tt,{store:this.store,customStyles:n,children:U(et,{broadcastEvents:this.broadcastEvents,children:U(uc,{})})}),this.createContainer("deepdesk-overlays"));let b;this.inputMediator.on("selection",_=>{clearTimeout(b),_===null?b=setTimeout(()=>{_!==null&&this.store.dispatch(Ts(_))},500):this.store.dispatch(Ts(_))}),this.inputMediator.on("disabled",()=>{var _;(_=this.inputMediator)==null||_.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{u&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(Et(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(Et(!0))),this.store.dispatch(Ei({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(_e()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var _;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((_=this.state.conversation.current)==null?void 0:_.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&E.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:n,showImages:s,isEmbedded:r}=o;this.widgetRoot=e,this.configure({showImages:s,isEmbedded:r}),Kt(U(tt,{store:this.store,customStyles:n,children:U(et,{broadcastEvents:this.broadcastEvents,children:U(Fp,{onLogIn:()=>this.loginViaPopup().catch(i=>E.warn(i.message))})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setSessionId((i=this.state.conversation.current)==null?void 0:i.sessionId)})}unmountWidget(){this.widgetRoot&&as(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=oi(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){rd(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(go());let e=Ke(this.state);e&&(await this.store.dispatch(uo()),this.store.dispatch(qt({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions})))}),this.loadProfileConfigPromise)}async loginViaPopup(){let e=this.state.settings.adminUrl,o=new URL(e),n=await ii(o.origin);return new Promise((s,r)=>{let i=new MessageChannel,a=i.port1,l=new URL(n.config.platform.hasSso?`${e}/platform/sso/`:`${e}/admin/`);l.searchParams.append("redirect","/sdk/popup/close.html");let c=!1,p=()=>{d&&!d.closed&&d.close(),window.removeEventListener("message",u),clearInterval(g)};a.onmessage=async m=>{var f,h;if((f=m.data)!=null&&f.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((h=m.data)==null?void 0:h.jwt),await this.isLoggedIn(),this.broadcastEvents.send(io),p(),c=!0,i.port1.close(),s()}catch(w){r(w)}};let d=window.open(l.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");d===null&&r(new Error("Popup blocked by browser"));let u=async m=>{var f;if(m.origin===l.origin)switch((f=m.data)==null?void 0:f.type){case"deepdesk-popup-loaded":{d==null||d.postMessage({type:"deepdesk-popup-create-channel"},l.origin,[i.port2]);break}case"deepdesk-popup-error":{p(),m.data.message==="Timeout"&&E.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(m.data.message));break}}};window.addEventListener("message",u);let g=setInterval(()=>{d&&!d.closed||(p(),c||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(p)})}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(E.info("Trial is active"),!await this.deepdeskApi.checkUserExists(e))throw new Error("User is not in trial");this.shouldRender=!0}catch(o){let{message:n}=o;E.info(n),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let o=Pn(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(pe()):this.store.dispatch(ce(n))})}catch(n){this.handleError(n)}}};async function jv(t,e,o={}){let{value:n}=t,{start:s,end:r}=o.replace??{start:0,end:n.length},i=`${n.slice(0,s)}${e}${n.slice(r)}`,a=o.selectionAfter??{start:s+e.length,end:s+e.length},l=()=>{if(o.setValue)return o.setValue(i);t.value=i};return Promise.resolve(l()).then(()=>{t.selectionStart=a.start,t.selectionEnd=a.end,t.blur(),t.focus()})}async function zv(t,e,o={}){let n=o.replace?rt(t,o.replace.start,o.replace.end):bo(t),s,r=()=>{if(o.setRange)return o.setRange(n.cloneRange());n.deleteContents(),s=document.createElement("span"),n.insertNode(s),o.insertBRs!==!1?e.split(`
10
+ `).reverse().forEach((i,a)=>{a>0&&n.insertNode(document.createElement("br")),n.insertNode(document.createTextNode(i))}):n.insertNode(document.createTextNode(e))};return Promise.resolve(r()).then(()=>{try{if(o.selectionAfter!==!1){t.focus();let i=o.selectionAfter?rt(t,o.selectionAfter.start,o.selectionAfter.end):(n.collapse(!1),n),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(i)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function Vv(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 qv(t){let e=document.createDocumentFragment();return t.split(`
11
+ `).forEach((o,n)=>{n>0&&e.appendChild(document.createElement("br"));let s={index:0},r=0;for(;s=o.slice(r).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=s[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(s[2])),e.appendChild(document.createTextNode(o.slice(r,r+s.index))),e.appendChild(i),r=r+s.index+s[0].length}e.appendChild(document.createTextNode(o.slice(r)))}),e}function fd(t,e){return!t.contains(e)||e===t?null:e.parentNode===t?e:fd(t,e.parentNode)}async function Wv(t,e,{isBlock:o,isHTML:n}={}){let s;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let r=()=>{let i=t.ownerDocument.defaultView??window,a=i.getSelection();if((!a||a.rangeCount===0)&&(t.focus(),a=i.getSelection()),!a||a.rangeCount===0)return;let l=a.getRangeAt(0);if(!l)return;s=document.createElement("span"),l.insertNode(s);let c=n?Vv(e):qv(e);if(o){let p=fd(t,l.startContainer)??t.firstChild;t.insertBefore(c,(p==null?void 0:p.nextSibling)??null)}else l.insertNode(c),l.collapse(!1)};return Promise.resolve(r()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!s)try{s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function Gv(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function $v(t,e,o){await new ze(t).authenticateWithKey(e,o)}async function Xv(t){let o=await(t.fetch??window.fetch)(t.url),n=await o.blob();return new File([n],t.name,{type:t.mimeType??o.headers.get("Content-Type")??"image/jpeg"})}async function Zv(t,e){let o=await Xv(e),n=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(t,"files",{configurable:!0,get:()=>[o]}),t.dispatchEvent(n)}finally{Object.hasOwn(t,"files")&&delete t.files}}export{H as Card,Ht as ContentEditableInput,ze as DeepdeskAPI,ls as DeepdeskSDK,ve as HTTPClient,Ne as InputMediator,qe as InputType,gs as KeyboardHint,ms as Label,Mo as Locale,Ve as Section,hs as SectionList,ue as Sources,D as Suggestion,re as SuggestionList,Oe as TextAreaInput,ut as ToggleButton,Zv as attachFile,$v as authenticateWithKey,bo as createFullRange,xt as createOverlayContainer,rt as createRangeFromOffsets,Qt as escapeHTML,ii as fetchPlatformConfig,Gv as formatTextMarkup,os as getRangeOffsets,ns as getRangeText,Wv as insertCKEditor,bt as isHTML,ti as isSupportedInputElement,zv as updateContentEditable,jv as updateTextArea,v as useStyles,oi as waitForElementVisibilityChange};