@deepdesk/deepdesk-sdk 10.4.1-beta.1 → 10.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
- var Wp=Object.defineProperty;var z=(t,e)=>{for(var o in e)Wp(t,o,{get:e[o],enumerable:!0})};import es from"classnames";import Zp,{createContext as Jp,useContext as ts,useEffect as Yp,useState as ed}from"react";import Gp,{useContext as $p}from"react";import Xp from"classnames";var Ft=Gp.createContext({});function S(t,e){let{debug:o,...n}=$p(Ft),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:Xp(a,l,o?`${t}__${i}`:!1)}},{}):e}var Wr={root:"_root_vr71j_1"};import{jsx as _o,jsxs as Qp}from"react/jsx-runtime";var xo=()=>Qp("svg",{className:Wr.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[_o("defs",{children:_o("style",{children:".cls-1 { fill: #b3b3b3; }"})}),_o("title",{children:"Failed loading image"}),_o("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 Yn={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 st}from"react/jsx-runtime";var bo=Jp(Yn),td=({title:t,src:e})=>{let o=ts(bo),[n,s]=ed(!1);return Yp(()=>{s(!1)},[e]),st("div",{className:o.imageWrapper,children:e&&!n?st("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):st(xo,{})})},od=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=ts(bo);return st("div",{className:es(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},nd=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=ts(bo);return Zp.createElement(t,{className:es(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Co=({children:t})=>{let e=S("Card",Yn);return st("div",{className:es(e.root),children:st(bo.Provider,{value:e,children:t})})};Co.Image=td;Co.Content=od;Co.Title=nd;var D=Co;import sd from"classnames";var Gr={root:"_root_cq1yq_1"};import{jsx as ad}from"react/jsx-runtime";var rd={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},id=({className:t,keyCode:e,...o})=>{let n=S("KeyboardHint",Gr);return ad("span",{"data-key":rd[e],className:sd(t,n.root),...o})},os=id;import ld from"classnames";var $r={root:"_root_4a08n_1"};import{jsx as pd}from"react/jsx-runtime";var cd=({className:t,children:e,...o})=>{let n=S("Label",$r);return pd("span",{...o,className:ld(t,n.root),children:e})},ns=cd;var Xr={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};import{jsx as ss,jsxs as ud}from"react/jsx-runtime";var dd=({title:t,children:e,type:o,...n})=>{let s=S("Section",Xr);return ud("section",{...n,className:s.root,"data-section-type":o,children:[t&&ss("div",{className:s.subTitleContainer,children:ss("span",{className:s.subtitle,children:t})}),ss("div",{className:s.suggestions,children:e})]})},Ue=dd;import gd from"classnames";import md from"react";var Qr={root:"_root_19wxp_1"};import{jsx as hd}from"react/jsx-runtime";var fd=md.forwardRef(({className:t,children:e},o)=>{let n=S("SectionList",Qr);return hd("div",{ref:o,className:gd(n.root,t),children:e})}),rs=fd;import wo from"classnames";import yd,{createContext as Sd,useCallback as vd,useContext as Kt}from"react";var is={root:"_root_fsa1k_10",fadein:"_fadein_fsa1k_1",isClickable:"_isClickable_fsa1k_45",isSelected:"_isSelected_fsa1k_50",actions:"_actions_fsa1k_74",actionsIsFixed:"_actionsIsFixed_fsa1k_96",actionButton:"_actionButton_fsa1k_104",dropdownList:"_dropdownList_fsa1k_125",dropdownButton:"_dropdownButton_fsa1k_140",dropdownItem:"_dropdownItem_fsa1k_150",dropdownItemButton:"_dropdownItemButton_fsa1k_159",actionButtonIsPrimary:"_actionButtonIsPrimary_fsa1k_173",actionButtonIsDisabled:"_actionButtonIsDisabled_fsa1k_177",labels:"_labels_fsa1k_185",label:"_label_fsa1k_185"};import{jsx as he,jsxs as wd}from"react/jsx-runtime";var rt=Sd(is),_d=({fixed:t,children:e,...o})=>{let n=Kt(rt);return he("div",{...o,className:wo(n.actions,{[n.actionsIsFixed]:t}),children:e})},xd=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=Kt(rt);return wd("div",{className:wo(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,he("ul",{className:r.dropdownList,children:s})]})},bd=({index:t,label:e,onClick:o})=>{let n=Kt(rt);return he("li",{className:n.dropdownItem,children:he("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Cd=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=Kt(rt);return he("button",{type:"button",className:wo(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},as=({labels:t})=>{let e=Kt(rt);return he("div",{className:e.labels,children:t.map(o=>he("span",{className:e.label,children:o},o))})},it=yd.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=S("Suggestion",is),l=vd(c=>{c.preventDefault(),o&&o(c)},[o]);return he(s,{...r,ref:i,className:wo(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:he(rt.Provider,{value:a,children:n})})});it.Labels=as;it.Actions=_d;it.ActionButton=Cd;it.DropdownButton=xd;it.DropdownItem=bd;var M=it;import Td from"classnames";var Zr={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};import{jsx as kd}from"react/jsx-runtime";var Ed=({withDivider:t,children:e})=>{let o=S("SuggestionList",Zr);return kd("div",{"data-testid":"suggestions-overlay-list",className:Td(o.root,{[o.isWithDivider]:t}),children:e})},ne=Ed;import Rd from"classnames";var Jr={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};import{jsx as ls}from"react/jsx-runtime";var Id=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=S("ToggleButton",Jr);return ls("button",{type:"button",className:Rd(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:ls("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:ls("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},at=Id;var Yr=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,lt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var ei=/x-deepdesk-(([a-z0-9\-_])+-version)/,ce=(g=>(g.SEARCH="search",g.TEMPLATE="template",g.ELASTIC_SEARCH="search-autocomplete",g.GPT="gpt",g.TRIE="trie",g.TRIE_WITH_TYPOS="trie-with-typos",g.SEMANTIC="semantic",g.TEXT_RECOMMENDATION="text_recommendation",g.URL_RECOMMENDATION="url_recommendation",g.LINK_RECOMMENDATION="link_recommendation",g.PERSONAL_COLLECTION="personal-collection",g.PERSONAL_COLLECTION_SEARCH="personal-collection-search",g.SEARCH_OVERLAY="search-overlay",g.SEARCH_PREVIEW="search-preview",g.SEARCH_URL="search-url",g))(ce||{}),ze=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(ze||{});import{render as So,unmountComponentAtNode as $n}from"react-dom";import{Fragment as zm}from"react";import{createSlice as Pd}from"@reduxjs/toolkit";import{useSelector as Ad}from"react-redux";var To=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(To||{});var Ld={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showPersonalCollectionLink:!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,adminUrl:void 0,productName:"Deepdesk"},ti=Pd({name:"settings",initialState:Ld,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:Ut}=ti.actions,cs=t=>e=>e.settings[t],b=t=>Ad(cs(t)),oi=ti.reducer;import{useState as Ig}from"react";import{useDispatch as Pg,useSelector as Js}from"react-redux";import{createAction as je,createSlice as Kd}from"@reduxjs/toolkit";import{diffChars as Ud}from"diff";import{useSelector as zd}from"react-redux";function ni(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Ie(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)=>Ie(r,e[i],o-1)):ni(t)&&ni(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Ie(t[i],e[i],o-1)):!1}function Md(t){return Math.max(...t.map(e=>e.length))}function Od(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 si(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Md(n);s++){let r=Od(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 Nd=2;function ps(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=si(t,Nd);return o&&o.text!==e?o:t[0]}import{createAction as Dd,createAsyncThunk as ct,createSlice as Hd}from"@reduxjs/toolkit";var ri={current:null,isSupported:null},R=Dd("resetConversation"),Eo=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},ko=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},pt=t=>t.conversation.isSupported,ds=ct("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Ro=ct("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Io=ct("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Po=ct("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=ko(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),us=ct("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})})}),Ao=ct("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=ko(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Bd=[Ro.rejected,Io.rejected,Po.rejected,Ao.rejected].map(t=>t==null?void 0:t.toString()),Fd=Hd({name:"conversation",initialState:ri,reducers:{},extraReducers:t=>{t.addCase(ds.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Ro.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Io.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(us.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Po.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Ao.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(R,()=>ri).addMatcher(e=>Bd.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),ii=Fd.reducer;var Pe={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 Mo(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 Oo=je("input/replaceText"),No=je("input/keyDown"),qe=je("input/sendMessage"),Do=je("input/sendEditSuggestionMessage"),Ho=je("input/uiInputChange"),Bo=je("input/applyImageSuggestion"),Z=je("input/sendEvent");function Lo(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 ai=t=>Kd({name:t,initialState:Pe,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,{...Pe,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=ps(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(Ie(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Lo(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:m,altKey:f}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:g}=e,{text:x}=o.payload,w=Ud(g,x);g.length-x.length>1&&e.metrics.deletions.push(...w.filter(h=>h.removed).map(h=>h.value)),e.metrics.numCharsDeleted+=g.length-x.length;break}case"C":case"V":case"X":if(!u&&!m){e.metrics.numCharsTyped+=1;let g=((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;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}break;case"Shift":break;default:if(!u&&!m&&!f){e.metrics.numCharsTyped+=1;let g=((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;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=Pe.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Lo(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"&&Lo(e)},commitSuggestion(e){Lo(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=ps(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)}},extraReducers:e=>{e.addCase(R,o=>{o.tabCompletionSuggestion=Pe.tabCompletionSuggestion,o.previousKeyDownEvent=Pe.previousKeyDownEvent,o.textSuggestions=Pe.textSuggestions,o.selectedSuggestionIndex=Pe.selectedSuggestionIndex,o.metrics=Pe.metrics})}}),gs=ai("input"),dt=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),jd=t=>t.input.selection,li=()=>zd(jd),{userInput:ci,changeSelection:ms,initialInput:pi,mergeMetrics:di,nextTextSuggestionIndex:ui,offeredTextSuggestion:gi,previousTextSuggestionIndex:mi,registerCut:fi,registerKeyDown:hi,registerPaste:yi,reset:Si,resetToCommitted:zt,platformInput:vi,setSelectedTextSuggestionIndex:Ve,setTextSuggestions:pe,stageSuggestion:se,commitSuggestion:Ae}=gs.actions,W=ai("overlay");import{useEffect as xi,useRef as bi}from"react";var _i={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};import{jsx as Ci}from"react/jsx-runtime";var qd=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=bi(null),l=bi(null),c=S("Dialog",_i);return xi(()=>{var u,m;let p=f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),s())},d=f=>{let g=window.getSelection();g!=null&&g.toString()||f.target===a.current&&t&&n()};return(u=a.current)==null||u.addEventListener("click",d),(m=a.current)==null||m.addEventListener("keyup",p),()=>{var f,g;(f=a.current)==null||f.removeEventListener("click",d),(g=a.current)==null||g.removeEventListener("keyup",p)}},[a,l,s,n]),xi(()=>{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?Ci("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:Ci("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},ut=qd;import{useEffect as ba}from"react";import{useDispatch as pg,useSelector as dg}from"react-redux";var fs={};z(fs,{enUS:()=>Vd,nlNL:()=>Wd});var Vd={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?"}]},Wd={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 wi={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 su,useContext as ru}from"react";var hs=function(t,e){return hs=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])},hs(t,e)};function jt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");hs(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var J=function(){return J=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},J.apply(this,arguments)};function Ti(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 Fo(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 Ko;(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"})(Ko||(Ko={}));var Uo=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var re;(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"})(re||(re={}));var zo;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(zo||(zo={}));function ys(t){return t.type===re.literal}function Ei(t){return t.type===re.argument}function jo(t){return t.type===re.number}function qo(t){return t.type===re.date}function Vo(t){return t.type===re.time}function Wo(t){return t.type===re.select}function Go(t){return t.type===re.plural}function ki(t){return t.type===re.pound}function $o(t){return t.type===re.tag}function Xo(t){return!!(t&&typeof t=="object"&&t.type===zo.number)}function qt(t){return!!(t&&typeof t=="object"&&t.type===zo.dateTime)}function Ss(t){t.forEach(function(e){if(delete e.location,Wo(e)||Go(e))for(var o in e.options)delete e.options[o].location,Ss(e.options[o].value);else jo(e)&&Xo(e.style)||(qo(e)||Vo(e))&&qt(e.style)?delete e.style.location:$o(e)&&Ss(e.children)})}function Ri(t,e){e===void 0&&(e={}),e=J({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new Uo(t,e).parse();if(o.err){var n=SyntaxError(Ko[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||Ss(o.val),o.val}function Qo(t,e){var o=e&&e.cache?e.cache:Jd,n=e&&e.serializer?e.serializer:Zd,s=e&&e.strategy?e.strategy:$d;return s(t,{cache:o,serializer:n})}function Gd(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Ii(t,e,o,n){var s=Gd(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function Pi(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 vs(t,e,o,n,s){return o.bind(e,t,n,s)}function $d(t,e){var o=t.length===1?Ii:Pi;return vs(t,this,o,e.cache.create(),e.serializer)}function Xd(t,e){return vs(t,this,Pi,e.cache.create(),e.serializer)}function Qd(t,e){return vs(t,this,Ii,e.cache.create(),e.serializer)}var Zd=function(){return JSON.stringify(arguments)};function _s(){this.cache=Object.create(null)}_s.prototype.get=function(t){return this.cache[t]};_s.prototype.set=function(t,e){this.cache[t]=e};var Jd={create:function(){return new _s}},Zo={variadic:Xd,monadic:Qd};var We;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(We||(We={}));var Vt=function(t){jt(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 xs=function(t){jt(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('", "'),'"'),We.INVALID_VALUE,r)||this}return e}(Vt);var Ai=function(t){jt(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),We.INVALID_VALUE,s)||this}return e}(Vt);var Li=function(t){jt(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,'"'),We.MISSING_VALUE,n)||this}return e}(Vt);var U;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(U||(U={}));function Yd(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==U.literal||o.type!==U.literal?e.push(o):n.value+=o.value,e},[])}function eu(t){return typeof t=="function"}function Wt(t,e,o,n,s,r,i){if(t.length===1&&ys(t[0]))return[{type:U.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(ys(p)){a.push({type:U.literal,value:p.value});continue}if(ki(p)){typeof r=="number"&&a.push({type:U.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new Li(d,i);var u=s[d];if(Ei(p)){(!u||typeof u=="string"||typeof u=="number")&&(u=typeof u=="string"||typeof u=="number"?String(u):""),a.push({type:typeof u=="string"?U.literal:U.object,value:u});continue}if(qo(p)){var m=typeof p.style=="string"?n.date[p.style]:qt(p.style)?p.style.parsedOptions:void 0;a.push({type:U.literal,value:o.getDateTimeFormat(e,m).format(u)});continue}if(Vo(p)){var m=typeof p.style=="string"?n.time[p.style]:qt(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:U.literal,value:o.getDateTimeFormat(e,m).format(u)});continue}if(jo(p)){var m=typeof p.style=="string"?n.number[p.style]:Xo(p.style)?p.style.parsedOptions:void 0;m&&m.scale&&(u=u*(m.scale||1)),a.push({type:U.literal,value:o.getNumberFormat(e,m).format(u)});continue}if($o(p)){var f=p.children,g=p.value,x=s[g];if(!eu(x))throw new Ai(g,"function",i);var w=Wt(f,e,o,n,s,r),h=x(w.map(function(C){return C.value}));Array.isArray(h)||(h=[h]),a.push.apply(a,h.map(function(C){return{type:typeof C=="string"?U.literal:U.object,value:C}}))}if(Wo(p)){var y=p.options[u]||p.options.other;if(!y)throw new xs(p.value,u,Object.keys(p.options),i);a.push.apply(a,Wt(y.value,e,o,n,s));continue}if(Go(p)){var y=p.options["=".concat(u)];if(!y){if(!Intl.PluralRules)throw new Vt(`Intl.PluralRules is not available in this environment.
1
+ var ru=Object.defineProperty;var q=(t,e)=>{for(var o in e)ru(t,o,{get:e[o],enumerable:!0})};import ss from"classnames";import pu,{createContext as uu,useContext as rs,useEffect as du,useState as gu}from"react";import iu,{useContext as au}from"react";import lu from"classnames";var Kt=iu.createContext({});function S(t,e){let{debug:o,...n}=au(Kt),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:lu(a,l,o?`${t}__${i}`:!1)}},{}):e}var Jr={root:"_root_vr71j_1"};import{jsx as xo,jsxs as cu}from"react/jsx-runtime";var bo=()=>cu("svg",{className:Jr.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[xo("defs",{children:xo("style",{children:".cls-1 { fill: #b3b3b3; }"})}),xo("title",{children:"Failed loading image"}),xo("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 ns={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 it}from"react/jsx-runtime";var Co=uu(ns),mu=({title:t,src:e})=>{let o=rs(Co),[n,s]=gu(!1);return du(()=>{s(!1)},[e]),it("div",{className:o.imageWrapper,children:e&&!n?it("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):it(bo,{})})},fu=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=rs(Co);return it("div",{className:ss(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},hu=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=rs(Co);return pu.createElement(t,{className:ss(r.title,o,{[r.contentIsCropped]:e}),...s},n)},wo=({children:t})=>{let e=S("Card",ns);return it("div",{className:ss(e.root),children:it(Co.Provider,{value:e,children:t})})};wo.Image=mu;wo.Content=fu;wo.Title=hu;var N=wo;import yu from"classnames";var Yr={root:"_root_cq1yq_1"};import{jsx as _u}from"react/jsx-runtime";var Su={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},vu=({className:t,keyCode:e,...o})=>{let n=S("KeyboardHint",Yr);return _u("span",{"data-key":Su[e],className:yu(t,n.root),...o})},is=vu;import xu from"classnames";var ei={root:"_root_4a08n_1"};import{jsx as Cu}from"react/jsx-runtime";var bu=({className:t,children:e,...o})=>{let n=S("Label",ei);return Cu("span",{...o,className:xu(t,n.root),children:e})},as=bu;var ti={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};import{jsx as ls,jsxs as Tu}from"react/jsx-runtime";var wu=({title:t,children:e,type:o,...n})=>{let s=S("Section",ti);return Tu("section",{...n,className:s.root,"data-section-type":o,children:[t&&ls("div",{className:s.subTitleContainer,children:ls("span",{className:s.subtitle,children:t})}),ls("div",{className:s.suggestions,children:e})]})},je=wu;import Eu from"classnames";import ku from"react";var oi={root:"_root_19wxp_1"};import{jsx as Iu}from"react/jsx-runtime";var Ru=ku.forwardRef(({className:t,children:e},o)=>{let n=S("SectionList",oi);return Iu("div",{ref:o,className:Eu(n.root,t),children:e})}),cs=Ru;import To from"classnames";import Pu,{createContext as Au,useCallback as Lu,useContext as Ut}from"react";var ps={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 he,jsxs as Hu}from"react/jsx-runtime";var at=Au(ps),Mu=({fixed:t,children:e,...o})=>{let n=Ut(at);return he("div",{...o,className:To(n.actions,{[n.actionsIsFixed]:t}),children:e})},Ou=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=Ut(at);return Hu("div",{className:To(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,he("ul",{className:r.dropdownList,children:s})]})},Nu=({index:t,label:e,onClick:o})=>{let n=Ut(at);return he("li",{className:n.dropdownItem,children:he("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Du=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=Ut(at);return he("button",{type:"button",className:To(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},us=({labels:t})=>{let e=Ut(at);return he("div",{className:e.labels,children:t.map(o=>he("span",{className:e.label,children:o},o))})},lt=Pu.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=S("Suggestion",ps),l=Lu(c=>{c.preventDefault(),o&&o(c)},[o]);return he(s,{...r,ref:i,className:To(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:he(at.Provider,{value:a,children:n})})});lt.Labels=us;lt.Actions=Mu;lt.ActionButton=Du;lt.DropdownButton=Ou;lt.DropdownItem=Nu;var M=lt;import Bu from"classnames";var ni={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};import{jsx as Ku}from"react/jsx-runtime";var Fu=({withDivider:t,children:e})=>{let o=S("SuggestionList",ni);return Ku("div",{"data-testid":"suggestions-overlay-list",className:Bu(o.root,{[o.isWithDivider]:t}),children:e})},se=Fu;import Uu from"classnames";var si={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};import{jsx as ds}from"react/jsx-runtime";var zu=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=S("ToggleButton",si);return ds("button",{type:"button",className:Uu(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:ds("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:ds("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},ct=zu;var ri=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,pt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var ii=/x-deepdesk-(([a-z0-9\-_])+-version)/,ce=(g=>(g.SEARCH="search",g.TEMPLATE="template",g.ELASTIC_SEARCH="search-autocomplete",g.GPT="gpt",g.TRIE="trie",g.TRIE_WITH_TYPOS="trie-with-typos",g.SEMANTIC="semantic",g.TEXT_RECOMMENDATION="text_recommendation",g.URL_RECOMMENDATION="url_recommendation",g.LINK_RECOMMENDATION="link_recommendation",g.PERSONAL_COLLECTION="personal-collection",g.PERSONAL_COLLECTION_SEARCH="personal-collection-search",g.SEARCH_OVERLAY="search-overlay",g.SEARCH_PREVIEW="search-preview",g.SEARCH_URL="search-url",g))(ce||{}),qe=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(qe||{});import{render as vo,unmountComponentAtNode as Jn}from"react-dom";import{Fragment as hf}from"react";import{createSlice as ju}from"@reduxjs/toolkit";import{useSelector as qu}from"react-redux";var Eo=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Eo||{});var Vu={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showPersonalCollectionLink:!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,adminUrl:void 0,productName:"Deepdesk"},ai=ju({name:"settings",initialState:Vu,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:zt}=ai.actions,gs=t=>e=>e.settings[t],b=t=>qu(gs(t)),li=ai.reducer;import{useState as om}from"react";import{useDispatch as nm,useSelector as rr}from"react-redux";import{createAction as Ve,createSlice as Yu}from"@reduxjs/toolkit";import{diffChars as ed}from"diff";import{useSelector as td}from"react-redux";function ci(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Ie(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)=>Ie(r,e[i],o-1)):ci(t)&&ci(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Ie(t[i],e[i],o-1)):!1}function Wu(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 pi(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Wu(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 $u=2;function ms(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=pi(t,$u);return o&&o.text!==e?o:t[0]}import{createAction as Xu,createAsyncThunk as ut,createSlice as Qu}from"@reduxjs/toolkit";var ui={current:null,isSupported:null},R=Xu("resetConversation"),ko=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Ro=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},dt=t=>t.conversation.isSupported,fs=ut("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Io=ut("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Po=ut("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Ao=ut("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Ro(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),hs=ut("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})})}),Lo=ut("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Ro(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Zu=[Io.rejected,Po.rejected,Ao.rejected,Lo.rejected].map(t=>t==null?void 0:t.toString()),Ju=Qu({name:"conversation",initialState:ui,reducers:{},extraReducers:t=>{t.addCase(fs.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Io.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Po.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(hs.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Ao.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Lo.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(R,()=>ui).addMatcher(e=>Zu.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),di=Ju.reducer;var Pe={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 Oo(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 No=Ve("input/replaceText"),Do=Ve("input/keyDown"),We=Ve("input/sendMessage"),Ho=Ve("input/sendEditSuggestionMessage"),Bo=Ve("input/uiInputChange"),Fo=Ve("input/applyImageSuggestion"),z=Ve("input/sendEvent");function Mo(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,u=o==="search"||o==="personal-collection-search",d=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(u||p==="selection")&&(d=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(d=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:d,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:u?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var gi=t=>Yu({name:t,initialState:Pe,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,{...Pe,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=ms(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(Ie(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Mo(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:u,ctrlKey:d,metaKey:m,altKey:f}=e.previousKeyDownEvent;switch(p){case"Enter":u&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:g}=e,{text:v}=o.payload,w=ed(g,v);g.length-v.length>1&&e.metrics.deletions.push(...w.filter(h=>h.removed).map(h=>h.value)),e.metrics.numCharsDeleted+=g.length-v.length;break}case"C":case"V":case"X":if(!d&&!m){e.metrics.numCharsTyped+=1;let g=((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;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}break;case"Shift":break;default:if(!d&&!m&&!f){e.metrics.numCharsTyped+=1;let g=((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;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=Pe.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Mo(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"&&Mo(e)},commitSuggestion(e){Mo(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=ms(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)}},extraReducers:e=>{e.addCase(R,o=>{o.tabCompletionSuggestion=Pe.tabCompletionSuggestion,o.previousKeyDownEvent=Pe.previousKeyDownEvent,o.textSuggestions=Pe.textSuggestions,o.selectedSuggestionIndex=Pe.selectedSuggestionIndex,o.metrics=Pe.metrics})}}),ys=gi("input"),gt=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),od=t=>t.input.selection,mi=()=>td(od),{userInput:fi,changeSelection:Ss,initialInput:hi,mergeMetrics:yi,nextTextSuggestionIndex:Si,offeredTextSuggestion:vi,previousTextSuggestionIndex:_i,registerCut:xi,registerKeyDown:bi,registerPaste:Ci,reset:wi,resetToCommitted:jt,platformInput:Ti,setSelectedTextSuggestionIndex:Ae,setTextSuggestions:pe,stageSuggestion:re,commitSuggestion:Le}=ys.actions,$=gi("overlay");import{useEffect as ki,useRef as Ri}from"react";var Ei={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};import{jsx as Ii}from"react/jsx-runtime";var nd=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=Ri(null),l=Ri(null),c=S("Dialog",Ei);return ki(()=>{var d,m;let p=f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),s())},u=f=>{let g=window.getSelection();g!=null&&g.toString()||f.target===a.current&&t&&n()};return(d=a.current)==null||d.addEventListener("click",u),(m=a.current)==null||m.addEventListener("keyup",p),()=>{var f,g;(f=a.current)==null||f.removeEventListener("click",u),(g=a.current)==null||g.removeEventListener("keyup",p)}},[a,l,s,n]),ki(()=>{var p,u;!a.current||!t||!e||(u=(p=a.current)==null?void 0:p.querySelector("input, textarea"))==null||u.focus()},[t,e,a]),t?Ii("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:Ii("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},mt=nd;import{useEffect as Na}from"react";import{useDispatch as Hg,useSelector as Bg}from"react-redux";var vs={};q(vs,{enUS:()=>sd,nlNL:()=>rd});var sd={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?"}]},rd={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 Pi={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 yd,useContext as Sd}from"react";var _s=function(t,e){return _s=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])},_s(t,e)};function qt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");_s(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var ee=function(){return ee=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},ee.apply(this,arguments)};function Ai(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 Ko(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 Uo;(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"})(Uo||(Uo={}));var zo=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var ie;(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"})(ie||(ie={}));var jo;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(jo||(jo={}));function xs(t){return t.type===ie.literal}function Li(t){return t.type===ie.argument}function qo(t){return t.type===ie.number}function Vo(t){return t.type===ie.date}function Wo(t){return t.type===ie.time}function Go(t){return t.type===ie.select}function $o(t){return t.type===ie.plural}function Mi(t){return t.type===ie.pound}function Xo(t){return t.type===ie.tag}function Qo(t){return!!(t&&typeof t=="object"&&t.type===jo.number)}function Vt(t){return!!(t&&typeof t=="object"&&t.type===jo.dateTime)}function bs(t){t.forEach(function(e){if(delete e.location,Go(e)||$o(e))for(var o in e.options)delete e.options[o].location,bs(e.options[o].value);else qo(e)&&Qo(e.style)||(Vo(e)||Wo(e))&&Vt(e.style)?delete e.style.location:Xo(e)&&bs(e.children)})}function Oi(t,e){e===void 0&&(e={}),e=ee({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new zo(t,e).parse();if(o.err){var n=SyntaxError(Uo[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||bs(o.val),o.val}function Zo(t,e){var o=e&&e.cache?e.cache:ud,n=e&&e.serializer?e.serializer:pd,s=e&&e.strategy?e.strategy:ad;return s(t,{cache:o,serializer:n})}function id(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Ni(t,e,o,n){var s=id(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function Di(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 Cs(t,e,o,n,s){return o.bind(e,t,n,s)}function ad(t,e){var o=t.length===1?Ni:Di;return Cs(t,this,o,e.cache.create(),e.serializer)}function ld(t,e){return Cs(t,this,Di,e.cache.create(),e.serializer)}function cd(t,e){return Cs(t,this,Ni,e.cache.create(),e.serializer)}var pd=function(){return JSON.stringify(arguments)};function ws(){this.cache=Object.create(null)}ws.prototype.get=function(t){return this.cache[t]};ws.prototype.set=function(t,e){this.cache[t]=e};var ud={create:function(){return new ws}},Jo={variadic:ld,monadic:cd};var Ge;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Ge||(Ge={}));var Wt=function(t){qt(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 Ts=function(t){qt(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('", "'),'"'),Ge.INVALID_VALUE,r)||this}return e}(Wt);var Hi=function(t){qt(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),Ge.INVALID_VALUE,s)||this}return e}(Wt);var Bi=function(t){qt(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,'"'),Ge.MISSING_VALUE,n)||this}return e}(Wt);var j;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(j||(j={}));function dd(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==j.literal||o.type!==j.literal?e.push(o):n.value+=o.value,e},[])}function gd(t){return typeof t=="function"}function Gt(t,e,o,n,s,r,i){if(t.length===1&&xs(t[0]))return[{type:j.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(xs(p)){a.push({type:j.literal,value:p.value});continue}if(Mi(p)){typeof r=="number"&&a.push({type:j.literal,value:o.getNumberFormat(e).format(r)});continue}var u=p.value;if(!(s&&u in s))throw new Bi(u,i);var d=s[u];if(Li(p)){(!d||typeof d=="string"||typeof d=="number")&&(d=typeof d=="string"||typeof d=="number"?String(d):""),a.push({type:typeof d=="string"?j.literal:j.object,value:d});continue}if(Vo(p)){var m=typeof p.style=="string"?n.date[p.style]:Vt(p.style)?p.style.parsedOptions:void 0;a.push({type:j.literal,value:o.getDateTimeFormat(e,m).format(d)});continue}if(Wo(p)){var m=typeof p.style=="string"?n.time[p.style]:Vt(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:j.literal,value:o.getDateTimeFormat(e,m).format(d)});continue}if(qo(p)){var m=typeof p.style=="string"?n.number[p.style]:Qo(p.style)?p.style.parsedOptions:void 0;m&&m.scale&&(d=d*(m.scale||1)),a.push({type:j.literal,value:o.getNumberFormat(e,m).format(d)});continue}if(Xo(p)){var f=p.children,g=p.value,v=s[g];if(!gd(v))throw new Hi(g,"function",i);var w=Gt(f,e,o,n,s,r),h=v(w.map(function(C){return C.value}));Array.isArray(h)||(h=[h]),a.push.apply(a,h.map(function(C){return{type:typeof C=="string"?j.literal:j.object,value:C}}))}if(Go(p)){var y=p.options[d]||p.options.other;if(!y)throw new Ts(p.value,d,Object.keys(p.options),i);a.push.apply(a,Gt(y.value,e,o,n,s));continue}if($o(p)){var y=p.options["=".concat(d)];if(!y){if(!Intl.PluralRules)throw new Wt(`Intl.PluralRules is not available in this environment.
2
2
  Try polyfilling it using "@formatjs/intl-pluralrules"
3
- `,We.MISSING_INTL_API,i);var v=o.getPluralRules(e,{type:p.pluralType}).select(u-(p.offset||0));y=p.options[v]||p.options.other}if(!y)throw new xs(p.value,u,Object.keys(p.options),i);a.push.apply(a,Wt(y.value,e,o,n,s,u-(p.offset||0)));continue}}return Yd(a)}function tu(t,e){return e?J(J(J({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=J(J({},t[n]),e[n]||{}),o},{})):t}function ou(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=tu(t[n],e[n]),o},J({},t)):t}function bs(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function nu(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Qo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,Fo([void 0],o,!1)))},{cache:bs(t.number),strategy:Zo.variadic}),getDateTimeFormat:Qo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,Fo([void 0],o,!1)))},{cache:bs(t.dateTime),strategy:Zo.variadic}),getPluralRules:Qo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,Fo([void 0],o,!1)))},{cache:bs(t.pluralRules),strategy:Zo.variadic})}}var Mi=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,m){return!u.length||m.type!==U.literal||typeof u[u.length-1]!="string"?u.push(m.value):u[u.length-1]+=m.value,u},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return Wt(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=Ti(i,["formatters"]);this.ast=t.__parse(e,J(J({},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||nu(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=Ri,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 iu(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var au="dummy",Cs=su(null);function T(t){let e=ru(Cs);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=iu(o,n);return r?new Mi(r).format(s):(e!==au&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}import{jsx as Oi,jsxs as lu}from"react/jsx-runtime";var Jo=()=>lu("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[Oi("title",{id:"angleLeftTitle",children:"AngleLeft"}),Oi("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 Ni,jsxs as cu}from"react/jsx-runtime";var Di=()=>cu("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[Ni("title",{id:"angleRightTitle",children:"AngleRight"}),Ni("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 Gt,useRef as Ls,useState as ku}from"react";import{useDispatch as Ru}from"react-redux";import{Interweave as Iu}from"interweave";import Yi from"classnames";var ws={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 gu}from"interweave";import mu from"classnames";import{useEffect as pu,useRef as du,useState as uu}from"react";function Hi(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function Yo(t){let e=du(null),[o,n]=uu(!1);return pu(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=Hi((p,d)=>{let u=e.current;if(!u)return;let m=p/r,f=d/r,g=u.getBoundingClientRect(),x=m>g.x&&m<g.x+g.width&&f>g.y&&f<g.y+g.height;x&&!s?(s=!0,n(!0)):!x&&s&&(s=!1,n(!1))},({clientX:p,clientY:d})=>[p,d]),[l,c]=Hi(()=>{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 ye={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 Bi}from"react/jsx-runtime";var fu=({inputElement:t,children:e})=>{let o=S("TabCompletion",ye),[n,s]=Yo(t);return Bi("mark",{ref:n,className:mu(o.matchPlaceholder,{[o.hover]:s}),children:e})},gt=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 Bi(fu,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import{useEffect as hu,useRef as yu,useState as Su}from"react";function en(t){return t.contentEditable==="true"}function vu(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 Fi(t){let{selectionStart:e,selectionEnd:o}=en(t)?vu(t):t;return[e,o]}function tn(t){let[,e]=Su(),o=yu(null);return o.current=Fi(t),hu(()=>{let n=()=>{let[s,r]=o.current??[],i=Fi(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 on(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(lt);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 _u}from"react";function mt(t){_u(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Ge(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var Ki,de=new Map,xu=["bottom","height","left","right","top","width"],bu=(t={},e={})=>xu.some(o=>t[o]!==e[o]);function Ui(t){var o,n;let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...Ui(e)]:[]}function zi(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var Ts=!1,ji=()=>{Ts=!0;let t=[];de.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),de.delete(o);return}let n=o.getBoundingClientRect();bu(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(zi,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),de.size!==0&&(Ki=window.requestAnimationFrame(ji))};function Es(t,e){let o=Ui(t),n=[],s=o.map((r,i)=>Es(r,a=>{n[i]=a;let l=de.get(t);if(!l)return;let c=n.reduce(zi,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),de.has(t)){let i=de.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else de.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!Ts&&ji()},unobserve(){s.forEach(i=>i.unobserve());let r=de.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||de.delete(t),de.size||(cancelAnimationFrame(Ki),Ts=!1)}}}}var qi,ue=new Map,Vi=()=>{ue.forEach((t,e)=>{if(!e.isConnected){ue.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)))}),ue.size!==0&&(qi=window.requestAnimationFrame(Vi))};function Wi(t,e){return{observe(){let o=ue.size===0;ue.has(t)?ue.get(t).callbacks.push(e):ue.set(t,{visible:void 0,callbacks:[e]}),o&&Vi()},unobserve(){let o=ue.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||ue.delete(t),ue.size||cancelAnimationFrame(qi)}}}}var ks=["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 Rs(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function ft(t){return parseFloat(t)}function nn(t){return Math.round(t*1e6)}function Gi(t){return t/1e6}function Is(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=ft(t.width),r=ft(t.borderLeftWidth),i=ft(t.borderRightWidth),a=ft(t.paddingRight),l=Gi(nn(s)-nn(r)-nn(i)),c=Gi(nn(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function ht(t,e={}){var l;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",Ge(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Rs(n,o,ks),Is(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=Wi(t,()=>{Rs(n,o,ks),Is(n,t,o),r(),setTimeout(r,0)}),a=Es(t,c=>{if(c===null){e.onRemove&&e.onRemove(),o.remove();return}if(c.height===0&&c.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Rs(n,o,ks),Is(n,t,o),r(),o.style.top=`${c.top}px`,o.style.left=`${c.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let p=e.closestScrollElement.getBoundingClientRect(),d=window.getComputedStyle(e.closestScrollElement),u=ft(d.borderTopWidth),m=ft(d.borderBottomWidth),f=p.top+u-c.top,g=c.top+c.height+-(p.top+p.height-m);o.style.clipPath=`inset(${f}px 0px ${g}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(l=t.parentElement)==null||l.appendChild(o),a.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),a.unobserve(),i.unobserve()}]}var Ps={};z(Ps,{enUS:()=>Cu,nlNL:()=>wu});var Cu={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"}]},wu={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 $i,jsxs as Tu}from"react/jsx-runtime";var Xi=()=>Tu("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[$i("title",{id:"circleCheckTitle",children:"Check"}),$i("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 Qi}from"react/jsx-runtime";var Zi=()=>Qi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:Qi("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"})});function Eu(t){let e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!n}function sn(t){return t?t instanceof ShadowRoot?sn(t.host):t===t.ownerDocument.body?t.ownerDocument:Eu(t)?t:sn(t.parentNode):document.body}var Ji=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(Ji||{}),Le=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();Ie(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(Ji).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",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),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",n=>this.handlePaste(n)),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()});let o=sn(this.element);if(o){let n=()=>{this.currentCaret!==null&&(this.currentCaret=null,this.emit("caret",null))};o.addEventListener("scroll",n),this.disposeHandlers.push(()=>{o.removeEventListener("scroll",n)})}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 Me=class extends Le{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())}};import{jsx as Se,jsxs as As}from"react/jsx-runtime";var Pu=({value:t,onUse:e,...o})=>{var p;let n=T(Ps),s=Ru(),r=S("EditSuggestionTextInput",ws),[i,a]=ku(null),l=Ls(null),c=((p=t.match(lt))==null?void 0:p.length)||0;return Gt(()=>{let d;return l.current&&(a(l.current),d=new Me(l.current),d.on("change",({plainText:u})=>{s(W.actions.userInput({text:u,selection:d.getSelection()}))}),d.on("keydown",u=>{s(W.actions.registerKeyDown(Mo(u))),u.code==="Enter"&&u.shiftKey&&e(d.getText())}),d.on("paste",({pastedText:u,selectionText:m})=>{s(W.actions.registerPaste({text:u,selectionText:m}))}),d.on("cut",({selectionText:u})=>{s(W.actions.registerCut(u))})),()=>{s(W.actions.reset()),d.dispose(),d.deactivate()}},[l]),Gt(()=>{t&&l.current&&(l.current.value=t)},[t,l]),Gt(()=>{l.current&&setTimeout(()=>{if(!l.current)return;let d=l.current.value.length;l.current.setSelectionRange(d,d),l.current.focus()},0)},[l]),As("div",{className:r.textInputWrapper,children:[Se("textarea",{...o,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:r.textInput,defaultValue:t,onChange:()=>{}}),i&&Se(Au,{inputElement:l.current,value:t}),As("div",{className:Yi(r.alert,c===0?r.success:r.warning),children:[Se("div",{className:r.alertText,children:n("placeholders",{placeholderSize:c})}),c===0?Se(Xi,{}):Se(Zi,{})]})]})},Au=({inputElement:t,value:e})=>{let o=S("EditSuggestionTextInput",ws),n=Ls(null),s=tn(t);return Gt(()=>{on(t,s)},[s,t]),Se(Lu,{inputElement:t,children:As("div",{ref:n,className:Yi(o.root,o.agentText),children:[Se(Iu,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new gt("placeholders")],inputElement:t,boundaryRef:n}),Se("br",{})]})})},Lu=({inputElement:t,children:e})=>{let o=Ls(null);return Gt(()=>{if(!o.current)return()=>{};let[n,s]=ht(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),Se("div",{ref:o,children:e})},ea=Pu;import{useEffect as ig,useState as ag,useRef as lg}from"react";import{useState as Nu}from"react";import Ms from"classnames";var G={root:"_root_185k9_1",list:"_list_185k9_2",listWrapper:"_listWrapper_185k9_6",listHorizontal:"_listHorizontal_185k9_10",page:"_page_185k9_19",search:"_search_185k9_25",pageNav:"_pageNav_185k9_33",pageTitle:"_pageTitle_185k9_41",pageBackButton:"_pageBackButton_185k9_48",listHeading:"_listHeading_185k9_62",listItem:"_listItem_185k9_70",listItemContent:"_listItemContent_185k9_79",listItemText:"_listItemText_185k9_97",listItemDescription:"_listItemDescription_185k9_105",truncate:"_truncate_185k9_112",lineClamp:"_lineClamp_185k9_118",listItemTitle:"_listItemTitle_185k9_125",listItemAction:"_listItemAction_185k9_132",listItemPrimaryAction:"_listItemPrimaryAction_185k9_146",listItemSelected:"_listItemSelected_185k9_151",sources:"_sources_185k9_155",sourcesTitle:"_sourcesTitle_185k9_162",source:"_source_185k9_155",icon:"_icon_185k9_177",searchIcon:"_searchIcon_185k9_194",searchInputWrapper:"_searchInputWrapper_185k9_199",searchInput:"_searchInput_185k9_199",select:"_select_185k9_220",selectType:"_selectType_185k9_237",selectWrapper:"_selectWrapper_185k9_241",image:"_image_185k9_271",imageSrc:"_imageSrc_185k9_278",imageSrcHidden:"_imageSrcHidden_185k9_289",imageSrcStatus:"_imageSrcStatus_185k9_293",imageTitle:"_imageTitle_185k9_303",actions:"_actions_185k9_308",actionsWrapper:"_actionsWrapper_185k9_312",actionsBar:"_actionsBar_185k9_318",actionButton:"_actionButton_185k9_327",actionShortcut:"_actionShortcut_185k9_345",actionShortcutFixKerning:"_actionShortcutFixKerning_185k9_352"};var $e={};z($e,{enUS:()=>Mu,nlNL:()=>Ou});var Mu={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},Ou={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 $t,jsxs as Hu}from"react/jsx-runtime";var Du=({src:t,title:e})=>{let o=S("CommandPalette",G),[n,s]=Nu("loading"),r=T($e);return Hu("div",{className:o.image,children:[$t("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:Ms(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&$t("span",{className:Ms(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&$t("span",{className:Ms(o.imageSrc,o.imageSrcStatus),children:$t(xo,{})}),e&&$t("span",{className:o.imageTitle,children:e})]})},ta=Du;import Bu from"react";import Fu from"classnames";import{jsx as oa,jsxs as Ku}from"react/jsx-runtime";function Os({children:t,heading:e,orientation:o}){let n=S("CommandPalette",G);return Bu.Children.count(t)===0?null:Ku("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&oa("h4",{className:n.listHeading,children:e}),oa("div",{className:Fu(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}import rn from"classnames";import Ns from"react";import{jsx as Uu}from"react/jsx-runtime";var na=Ns.createContext(void 0);function Oe(){let t=Ns.useContext(na);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var sa=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=Ns.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return Uu(na.Provider,{value:i,children:t})};import{jsx as yt,jsxs as Ds}from"react/jsx-runtime";function Hs({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onSourceClick:s,index:r,description:i,sources:a,styles:l,...c}){let{selected:p,onChangeOpen:d}=Oe(),u=S("CommandPalette",G);function m(f){n(f),t&&d(!1)}return Ds("div",{className:rn(u.listItem,p===r&&u.listItemSelected),children:[yt("button",{type:"button",className:rn("command-palette-list-item",u.listItemAction,u.listItemPrimaryAction),"aria-disabled":c.disabled??!1,onClick:m,...c,children:Ds("div",{className:u.listItemContent,children:[typeof o=="string"?yt("p",{className:rn(u.listItemText,u.truncate,l==null?void 0:l.title),children:o}):o,i&&yt("p",{className:rn(u.listItemDescription,l==null?void 0:l.description,e?u.lineClamp:u.truncate),children:i})]})}),a&&Ds("div",{className:u.sources,children:[yt("span",{className:u.sourcesTitle,children:"Sources"}),a.map(f=>f.url?yt("a",{className:u.source,href:f.url,target:"_blank",title:f.url,rel:"noopener noreferrer",onClick:()=>s&&s(f),children:f.name},f.url):yt("span",{className:u.source,children:f.name},f.name))]})]})}import{jsx as ra,jsxs as Bs}from"react/jsx-runtime";function Fs({children:t,title:e,id:o,onDismiss:n}){let s=T($e),r=S("CommandPalette",G),{page:i}=Oe();return i!==o?null:Bs("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&Bs("div",{className:r.pageNav,children:[Bs("button",{className:r.pageBackButton,type:"button",onClick:n,children:[ra(Jo,{}),s("back")]}),e&&ra("h3",{className:r.pageTitle,children:e})]}),t]})}import{Fragment as Ju,useCallback as Yu,useEffect as eg,useRef as tg}from"react";var an=()=>/Mac/i.test(navigator.platform);import{createAsyncThunk as Wu,createSlice as Gu}from"@reduxjs/toolkit";var zu={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},E=zu;import{createAsyncThunk as Us,createSlice as qu}from"@reduxjs/toolkit";function ju(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,[ju(o)]:A(t[o])}),{}):t}function Ks(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function B(t){return Array.isArray(t)?t.map(B):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Ks(o)]:B(t[o])}),{}):t}var Vu={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Qt=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)||""}},Xt=Us("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))}),zs=Us("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}),js=Us("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),ia=t=>t.info.agentInfo,aa=qu({name:"info",initialState:Vu,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Xt.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Xt.rejected,e=>{e.fetchState="error"}).addCase(Xt.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(zs.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(js.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(R,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:la}=aa.actions,ca=aa.reducer;var ln={list:[],fetchState:"idle",isOpen:!1,page:"search"},pa=t=>t.search.isOpen,da=t=>t.search.page,ua=t=>t.search.list;function ga(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Xe=Wu("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:Qt(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),ma=Gu({name:"search",initialState:ln,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=ln.fetchState,t.list=ln.list}},extraReducers:t=>{t.addCase(Xe.pending,e=>{e.fetchState="loading"}).addCase(Xe.rejected,(e,o)=>{e.fetchState="error",E.error(o.error)}).addCase(Xe.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(R,()=>ln)}}),{resetSearch:cn,setIsOpen:Y,setPage:j}=ma.actions,fa=ma.reducer;var $u=/(https?:\/\/[^\s]+)/,pn=t=>t.split(" ").find(e=>$u.test(e));import ha from"classnames";import{jsx as Qu,jsxs as Zu}from"react/jsx-runtime";var Xu=({onClick:t,shortKeys:e,children:o,...n})=>{let s=S("CommandPalette",G);return Zu("button",{type:"button",...n,onClick:t,className:ha(s.actionButton,n.className),children:[o,e&&e.map(r=>Qu("span",{className:ha(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},St=Xu;import{jsx as dn,jsxs as qs}from"react/jsx-runtime";var og=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=S("CommandPalette",G),a=T($e),{selected:l,setSelected:c}=Oe(),p=r[l],d=p&&typeof p.text=="string"&&pn(p.text),u=tg(null);function m(y){if(!u.current)return;let v=u.current.querySelectorAll(".command-palette-list-item"),C=0,H=0;y==="down"?(v.forEach((le,N)=>{N===l&&(C=N)}),H=C===v.length-1?0:C+1):y==="up"?(v.forEach((le,N)=>{N===l&&(C=N)}),H=C?C-1:v.length-1):c(0);let O=v[H];O&&typeof H=="number"&&(c(H),O.scrollIntoView&&O.scrollIntoView({behavior:"smooth",block:H?"center":"end"}))}function f(){if(!u.current)return;let y=u.current.querySelectorAll(".command-palette-list-item"),v=0;y.forEach((H,O)=>{O===l&&(v=O)});let C=y[v];C&&C.click()}let g=()=>{d&&window.open(d,"_blank")},x=()=>{p&&n(p,l)},w=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},h=Yu(y=>{if(y.key==="Enter"&&y.altKey&&d){g();return}if(y.key==="Enter"&&y.shiftKey){w();return}if(y.key==="ArrowDown"){y.preventDefault(),y.stopPropagation(),m("down");return}if(y.key==="ArrowUp"){y.preventDefault(),y.stopPropagation(),m("up");return}y.key==="Enter"&&l!==-1&&(y.preventDefault(),y.stopPropagation(),f())},[l]);return eg(()=>(window.addEventListener("keyup",h),()=>{window.removeEventListener("keyup",h)}),[h]),qs("div",{className:i.actions,children:[dn("div",{className:i.actionsWrapper,ref:u,children:t}),qs("div",{className:i.actionsBar,children:[d&&dn(St,{onClick:g,shortKeys:[an()?8997:"ALT",8629],children:a("visitUrl")}),p&&qs(Ju,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&dn(St,{onClick:w,shortKeys:[8679,8629],children:o}),dn(St,{onClick:x,shortKeys:[8629],children:e})]})]})]})},Sa=og;import{forwardRef as sg}from"react";import{jsx as va,jsxs as ng}from"react/jsx-runtime";var vt=()=>ng("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[va("path",{d:"M0 0h24v24H0z",fill:"none"}),va("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 _t,jsxs as Vs}from"react/jsx-runtime";function rg({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=S("CommandPalette",G);return Vs("div",{className:l.search,children:[_t("div",{className:l.searchIcon,children:_t(vt,{})}),Vs("div",{className:l.searchInputWrapper,children:[_t("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&&_t("div",{className:l.selectWrapper,children:Vs("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&&_t("option",{children:n}),s.map(c=>_t("option",{value:c.value,children:c.label},c.value))]})})]})]})}var _a=sg(rg);import{jsx as xa,jsxs as cg}from"react/jsx-runtime";function Qe({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[m,f]=ag(0),g=lg(null),x=()=>{s&&s(o),i(void 0),r(""),a(!1)},w=()=>{var h;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(h=g.current)==null||h.focus();return}if(u.length>0){r("");return}a(!1)};return ig(()=>{f(0)},[u,n]),xa(ut,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:w,onClose:x,children:cg(sa,{selected:m,setSelected:f,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&xa(_a,{ref:g,onChange:r,onChangeType:i,placeholder:t,value:u,selectedType:l,types:c,typePlaceholder:e}),p]})})}Qe.Page=Fs;Qe.List=Os;Qe.Image=ta;Qe.ListItem=Hs;Qe.ActionsBar=Sa;Qe.Button=St;var I=Qe;import{jsx as ve,jsxs as Zt}from"react/jsx-runtime";var ug=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=S("EditSuggestionForm",wi),l=pg(),c=T(fs),p=dg(f=>f.overlayInput.text);ba(()=>{t&&(l(W.actions.reset()),l(W.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(W.actions.commitSuggestion()))},[t]);let d=f=>{f.preventDefault(),u(p)},u=f=>{l(Do(f)),e(f)},m=f=>g=>{p!==i?window.confirm(c("warning"))&&f(g):f(g)};return ba(()=>{n&&n(p!==i)},[n,t,p]),Zt("div",{className:a.root,children:[Zt("div",{className:a.content,children:[t.title&&ve("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&ve(as,{labels:t.searchKeywords}),ve(ea,{onUse:u,value:p})]}),Zt("form",{className:a.actions,onSubmit:d,children:[Zt("div",{children:[ve("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&m(r),children:ve(Jo,{})}),ve("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&m(s),children:ve(Di,{})})]}),Zt("div",{className:a.primaryButtons,children:[ve(I.Button,{onClick:m(o),shortKeys:["esc"],children:c("dismiss")}),ve(I.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},un=ug;import{createAction as fg,createAsyncThunk as Ea,createSlice as hg}from"@reduxjs/toolkit";var gg=["{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}"],mg=new RegExp(gg.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Ca(t,e){let o=t.split(mg),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 wa(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var ka={suggestions:[],fetchState:"idle",isInitialRequest:null},Ta={default:ka},Ra=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)||[]},Ia=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},Pa=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")},xt=t=>t.textSuggestions,Aa=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},gn=fg("textSuggestions/refresh"),_e=Ea("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=dt(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Qt(n),t);if(t==="default"){let p=i?l.filter(Aa(a)):l;e.dispatch(pe(p.slice(0,r)))}return l}),Jt=Ea("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,{...Qt(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(Aa(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?Ca(p.text,t):p.text}))),l=wa(l,r),e.dispatch(pe(l)),l}),La=hg({name:"textSuggestions",initialState:Ta,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(_e.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||ka;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(_e.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(_e.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Jt.pending,e=>{e.default.fetchState="loading"}).addCase(Jt.rejected,e=>{e.default.fetchState="error"}).addCase(Jt.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(R,()=>Ta)}}),{setTextSuggestions:Ma,setSuggestionState:Oa}=La.actions,Na=La.reducer;import{createSlice as yg}from"@reduxjs/toolkit";var Da={contentType:null,suggestion:null},Ha=t=>t.activeSuggestion.suggestion,Ba=t=>t.activeSuggestion.contentType,Fa=yg({name:"activeSuggestion",initialState:Da,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(R,()=>Da)}}),{setActiveSuggestion:xe,resetActiveSuggestion:Ws}=Fa.actions,Ka=Fa.reducer;var Gs={};z(Gs,{enUS:()=>Sg,nlNL:()=>vg});var Sg={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"}]},vg={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 _g}from"@reduxjs/toolkit";var xg={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var mn=({ui:t})=>t.overlayCollapsed;var Ua=_g({name:"ui",initialState:xg,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:Yt,setInputHasFocus:bt,setOverlayCollapsed:Ne,setOpenOverlayWhenTyping:za,setOverlayCollapsedUserOverwrite:ja}=Ua.actions,qa=Ua.reducer;import Va,{useContext as bg}from"react";import{jsx as Cg}from"react/jsx-runtime";var Wa=Va.createContext(null),Ct=({broadcastEvents:t,children:e})=>{let o=Va.useMemo(()=>t,[]);return Cg(Wa.Provider,{value:o,children:e})},ee=()=>{let t=bg(Wa);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import{createAsyncThunk as $s,createSlice as wg}from"@reduxjs/toolkit";var Tg={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ie=t=>t.auth.isLoggedIn,Ga=t=>t.auth.loginFetchState,$a=t=>t.auth.verifyFetchState,Xa=t=>t.auth.showLoginOverlay,De=$s("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),Qa=$s("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),eo=$s("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),Za=wg({name:"auth",initialState:Tg,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(De.pending,e=>{e.loginFetchState="loading"}),t.addCase(De.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(De.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(eo.pending,e=>{e.verifyFetchState="loading"}),t.addCase(eo.rejected,e=>{e.verifyFetchState="error"}),t.addCase(eo.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:wt,setShowLoginOverlay:Ja}=Za.actions,Ya=Za.reducer;var Xs="SetActiveSuggestion",Tt="ShowLoginOverlay",Qs="UserLoggedIn",Eg="UserLoggedOut",be="ApplySuggestion",Zs="ApplyImageSuggestion",kg="ShowCommandPalette",Rg=t=>({[Xs]:e=>{t.dispatch(Oa(e.state)),t.dispatch(xe({contentType:e.contentType,suggestion:e.suggestion}))},[kg]:e=>{t.dispatch(Y(e.isOpen)),e.page&&t.dispatch(j(e.page))},[Tt]:e=>{t.dispatch(Ja(e))},[Qs]:()=>{t.dispatch(De())},[Eg]:()=>{t.dispatch(De())},[Zs]:e=>{t.dispatch(Bo({suggestion:e.suggestion}))},[be]:e=>{t.dispatch(se({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(Ae())}}),el=Rg;import{jsx as tl}from"react/jsx-runtime";var Ag=()=>{var f;let[t,e]=Ig(!1),o=Js(Ha),n=Js(Ba),s=Js(xt),r=Pg(),i=ee(),a=T(Gs),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(Ws()),r(bt(!0)),r(W.actions.reset())},p=(g,x)=>{r(Ws()),r(bt(!0)),i.send(be,{text:g,suggestion:{...x,source:`${x.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let d=(f=s[n])==null?void 0:f.suggestions.indexOf(o),u=d===0||d===null?void 0:()=>r(xe({contentType:n,suggestion:s[n].suggestions[d-1]})),m=d===s[n].suggestions.length-1||d===null?void 0:()=>r(xe({contentType:n,suggestion:s[n].suggestions[d+1]}));return tl(ut,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:tl(un,{onTouched:e,onDismiss:c,onUse:g=>p(g,o),suggestion:o,onNext:m,onPrevious:u})})},ol=Ag;import{useSelector as al}from"react-redux";import er from"classnames";import{useCallback as rl,useEffect as Hg,useMemo as Bg,useState as tr}from"react";import{useDispatch as Fg,useSelector as Kg}from"react-redux";import Lg from"classnames";var nl={root:"_root_1ukx5_1"};import{jsx as Og}from"react/jsx-runtime";var Mg=({className:t,value:e,...o})=>{let n=S("TextInput",nl);return Og("input",{className:Lg(t,n.root),type:"text",value:e,...o})},to=Mg;var Ys={};z(Ys,{enUS:()=>Ng,nlNL:()=>Dg});var Ng={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"}]},Dg={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 sl={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 $,jsxs as fn}from"react/jsx-runtime";var Ug=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},zg=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=T(Ys),i=S("LoginTokenDialog",sl),a=Kg($a),l=Fg(),c=b("productName"),[p,d]=tr(t||""),[u,m]=tr(0),[f,g]=tr(""),x=rl(async v=>{v.preventDefault(),l(Qa({email:p})),m(1)},[o,p]),w=()=>{g(""),m(0)},h=rl(async v=>{v.preventDefault();let C=Ug(v.target.elements.token.value);if(!C){g(r("verifyCodeError",{login:y}));return}l(eo({token:C}))},[o]),y=Bg(()=>v=>$("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:v},"back-button"),[]);return Hg(()=>{a==="error"&&g(r("verifyCodeError",{login:y})),a==="done"&&n()},[a]),$(ut,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:fn("div",{className:i.root,children:[$("h1",{className:i.title,children:r("promptTitle",{productName:c})}),u===0&&fn("form",{onSubmit:x,children:[$("h2",{className:i.subtitle,children:r("requestCodeTitle")}),$("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),$(to,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:v=>d(v.target.value)}),$("div",{className:i.actions,children:$("button",{type:"submit",className:er(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),u===1&&fn("form",{onSubmit:h,children:[$("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),$("p",{className:i.text,children:r("verifyCodeBody")}),$(to,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&$("div",{className:i.errorMessage,children:f}),fn("div",{className:i.actions,children:[$("button",{type:"button",className:er(i.button),onClick:w,children:r("back")}),$("button",{type:"submit",className:er(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},il=zg;import{jsx as qg}from"react/jsx-runtime";var jg=()=>{let t=al(Xa),e=al(ia),o=b("adminUrl"),n=ee(),s=()=>n.send(Tt,!1),r=()=>{n.send(Tt,!1),n.send(Qs)};return qg(il,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},ll=jg;import Nm from"lodash.debounce";import{useCallback as cr,useEffect as pr,useState as ro}from"react";import{useDispatch as Dm,useSelector as Pt}from"react-redux";import{createAsyncThunk as Vg,createSlice as Wg}from"@reduxjs/toolkit";var Gg={data:null,fetchState:"idle"},cl=t=>t.contentTypes.data,oo=Vg("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),$g=Wg({name:"contentTypes",initialState:Gg,reducers:{},extraReducers:t=>{t.addCase(oo.pending,e=>{e.fetchState="loading"}).addCase(oo.rejected,e=>{e.fetchState="error"}).addCase(oo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),pl=$g.reducer;function no(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 Xg}from"react";function dl(t,e){Xg(()=>{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 fl,useRef as om}from"react";import{useSelector as nm,useDispatch as sm}from"react-redux";import{createAsyncThunk as Qg,createSlice as Zg}from"@reduxjs/toolkit";var ul={data:null,fetchState:"idle"},hn=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},ae=Qg("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)}),Jg=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Yg=Zg({name:"entities",initialState:ul,reducers:{},extraReducers:t=>{t.addCase(ae.pending,e=>{e.fetchState="loading"}).addCase(ae.rejected,e=>{e.fetchState="error"}).addCase(ae.fulfilled,(e,o)=>{e.fetchState="done",e.data=Jg(e.data?[...e.data,...o.payload]:o.payload)}).addCase(R,()=>ul)}}),gl=Yg.reducer;var or={};z(or,{enUS:()=>em,nlNL:()=>tm});var em={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},tm={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var ml={root:"_root_17kae_1",empty:"_empty_17kae_5"};import{jsx as yn,jsxs as im}from"react/jsx-runtime";var rm=({onCopy:t,onUse:e})=>{let o=om(null),n=S("EntitiesList",ml),s=T(or),r=nm(hn),i=sm();return fl(()=>{i(ae())},[]),fl(()=>{o.current&&o.current.focus()},[o]),im("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&yn(I.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:yn(I.List,{children:r.map((a,l)=>yn(I.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&yn("p",{className:n.empty,children:s("noResults")})]})},hl=rm;import{Fragment as um,useEffect as Sn,useRef as gm,useState as mm}from"react";import{useSelector as bl,useDispatch as fm}from"react-redux";import{createAsyncThunk as am,createSlice as lm}from"@reduxjs/toolkit";var yl={data:null,fetchState:"idle"},Sl=t=>t.summary.data,vl=t=>t.summary.fetchState==="error",Ce=am("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();return i.length===0?Promise.reject(new Error("No messages are included")):{summary:await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel})}}),cm=lm({name:"summary",initialState:yl,reducers:{},extraReducers:t=>{t.addCase(Ce.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(Ce.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(Ce.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(R,()=>yl)}}),_l=cm.reducer;var nr={};z(nr,{enUS:()=>pm,nlNL:()=>dm});var pm={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."}]},dm={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 xl={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 Et,jsxs as ym}from"react/jsx-runtime";var hm=({onCopy:t})=>{let e=gm(null),o=S("SummaryForm",xl),[n,s]=mm(""),r=T(nr),i=bl(Sl),a=bl(vl),l=fm(),c=()=>{l(Z({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let d=document.getSelection();d&&l(Z({name:"summary copied to clipboard",data:{originalText:i,finalText:d==null?void 0:d.toString()},options:{includeConversationData:!0}}))};return Sn(()=>{l(Ce())},[]),Sn(()=>{s(i||"")},[i]),Sn(()=>{e.current&&i&&e.current.focus()},[e,i]),Sn(()=>{let d=u=>{u.key==="Enter"&&u.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[n]),Et("div",{className:o.root,tabIndex:-1,children:a?Et("p",{className:o.error,children:r("error")}):ym(um,{children:[Et("div",{className:o.main,children:Et("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:d=>s(d.target.value)})}),Et("div",{className:o.actions,children:Et(I.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},Cl=hm;var sr={};z(sr,{enUS:()=>Sm,nlNL:()=>vm});var Sm={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?"}]},vm={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 km,{useEffect as ar,useRef as Rm}from"react";import{useDispatch as Im,useSelector as Pl}from"react-redux";var rr={};z(rr,{enUS:()=>_m,nlNL:()=>xm});var _m={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"}]},xm={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 wl={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 bm,createAsyncThunk as Cm,createSlice as wm}from"@reduxjs/toolkit";var ir={data:[],fetchState:"idle"},Tl=t=>{var e;return(e=t.answer)==null?void 0:e.data},El=t=>t.answer.fetchState,Rt=bm("answer/resetKnowledgeSearch"),kt=Cm("answer/getAnswer",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=(i=e.getState().conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile is not defined");let r=await o.knowledgeAssist({promptInstruction:t.promptInstruction,question:t.question},n,s);return{question:t.question,answer:r}}),Tm=wm({name:"answer",initialState:ir,reducers:{},extraReducers:t=>{t.addCase(kt.pending,e=>{e.fetchState="loading"}).addCase(kt.rejected,e=>{e.fetchState="error"}).addCase(kt.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(R,()=>ir).addCase(Rt,()=>ir)}}),kl=Tm.reducer;import{jsx as Rl,jsxs as Em}from"react/jsx-runtime";var Il=()=>Em("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[Rl("title",{id:"paperPlaneTitle",children:"PaperPlane"}),Rl("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 we,jsxs as lr}from"react/jsx-runtime";var Pm=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=km.useState(""),{setSelected:i}=Oe(),a=Rm(null),l=S("EntitiesList",wl),c=T(rr),p=Im(),d=Pl(Tl),u=Pl(El),m=async g=>{g.preventDefault(),g.stopPropagation(),s!==""&&p(kt({question:s,promptInstruction:n}))},f=(g,x)=>{p(Z({name:"knowledge assist source viewed",data:{question:x,sourceViewed:g.url||g.name},options:{includeConversationData:!0}}))};return ar(()=>{var g;o&&u==="idle"?p(kt({question:o,promptInstruction:n})):(g=a.current)==null||g.focus()},[a,u]),ar(()=>{u==="done"&&(p(Z({name:"knowledge assist question answered",data:{question:s||o,sources:d[d.length-1].answer.sources,answer:d[d.length-1].answer.answer,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),i(d.length-1),r(""))},[u,d]),ar(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,d]),lr("div",{className:l.root,children:[d.length>0&&we("div",{className:l.alignRight,children:we(I.Button,{onClick:e,children:c("reset")})}),lr(I.ActionsBar,{list:d.map(({answer:g})=>({text:g.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:g=>t(g.text),children:[d.map(({question:g,answer:x},w)=>we(I.List,{children:we(I.ListItem,{"data-testid":"knowledge-search-answer",index:w,description:x.answer,closeOnSelect:!0,onClick:()=>t(x.answer),onSourceClick:h=>f(h,g),sources:x.sources,styles:{title:l.question,description:l.answer},children:g})},`${x.answer}_${w}`)),u==="loading"&&we("p",{className:l.status,children:c("loading")}),u==="error"&&we("p",{className:l.status,children:c("error")}),lr("form",{className:l.form,onSubmit:m,children:[we("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:g=>{i(-1),r(g.target.value)}}),we("button",{type:"submit",className:l.submit,children:we(Il,{})})]})]})]})},Al=Pm;import{createAsyncThunk as Am,createSlice as Lm}from"@reduxjs/toolkit";var Mm={data:null,fetchState:"idle"},It=t=>t.profile.data,vn=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],so=Am("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)}),Om=Lm({name:"profile",initialState:Mm,reducers:{},extraReducers:t=>{t.addCase(so.pending,e=>{e.fetchState="loading"}).addCase(so.rejected,e=>{e.fetchState="error"}).addCase(so.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Ll=Om.reducer;import{jsx as X,jsxs as Ol}from"react/jsx-runtime";var Hm=200,Bm=5,Fm=4,Km=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Ml=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Um=()=>{let t=Dm(),e=ee(),o=T(sr),[n,s]=ro(!1),[r,i]=ro(""),a=Pt(da),l=Pt(It),[c,p]=ro(null),[d,u]=ro([]),[m,f]=ro(),g=Pt(ie),x=b("showSearch"),w=b("showEntitiesCommand"),h=b("showSummaryCommand"),y=b("showKnowledgeSearch"),v=b("showImageSearch"),C=b("searchTriggerKey"),H=Pt(cl),O=Pt(ua),le=Pt(pa),N=_=>Jn(O.filter(P=>P.type===_.toUpperCase()),_),k=[{value:"PERSONAL",label:o("personalSuggestions"),list:N("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:N("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:N("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:N("IMAGE"),listOrientation:"horizontal",shouldShow:v}].filter(_=>_.shouldShow),V=[{label:o("entitiesClipboard"),onClick:()=>t(j("entities")),shouldShow:w&&Ml(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(j("summary")),shouldShow:h&&Ml(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(j("knowledgeAssist")),shouldShow:y}].filter(_=>_.shouldShow),te=(H==null?void 0:H.map(_=>({value:_.code.toUpperCase(),label:`${_.name}s`,list:N(_.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],Qn=cr(Nm((_,P)=>{t(Xe({query:_,type:P,tags:["search-overlay"]}))},Hm),[]),Ke=Km([...te,...k]),Dp=cr((_,P)=>{if(!P)return;let Re=[...k,...te].find(({value:nt})=>nt===P);Re&&(t(j("edit")),p({..._,searchTerm:void 0}),u(Re.list))},[t,c,te]),Zn=cr((_,P)=>{switch(P.type){case"IMAGE":e.send(Zs,{suggestion:P});break;default:e.send(be,{text:_,suggestion:P})}t(Y(!1))},[t]),Hp=_=>{no(_.text),t(Z({name:"entity copied",data:{entity:_,type:"copy"}})),t(Y(!1))},Bp=_=>{e.send(be,{text:_,suggestion:{source:"knowledge-assist",text:_}}),t(Z({name:"answer used",data:{originalText:_},options:{includeConversationData:!0}})),i(""),t(j("search")),t(Rt()),t(Y(!1))},Fp=_=>{no(_),t(Y(!1))},Kp=_=>{e.send(be,{text:_.text,suggestion:{source:"entity",text:_.text}}),t(Y(!1))},Up=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),zp=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function Jn(_,P){return _.slice(0,m?10:P.toLowerCase()==="image"?Fm:Bm)}function Vr(_,P,Re){return P.reduce((nt,vo)=>Re&&m===Re?vo.length+nt:Jn(vo,Re).length+nt,_)}function ot(_){return P=>{n?window.confirm(o("warning"))&&(_(P),s(!1)):_(P)}}return pr(()=>{r?Qn(r,m):t(cn())},[r,m]),pr(()=>{a==="search"&&t(Rt())},[a]),pr(()=>{g&&t(oo())},[g]),dl(C,()=>t(Y(!0))),!x||!l?null:Ol(I,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:ot(_=>t(Y(_))),onChangeType:_=>f(_),onChangePage:ot(_=>t(j(_))),selectedType:m,search:r,page:a,isOpen:le,types:[...te,...k],children:[X(I.Page,{id:"search",children:Ol(I.ActionsBar,{list:[...V.map(_=>({text:_.label,type:"command"})),...Ke.map(_=>({text:_.text||_.url||_.message,type:_.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:_},P)=>Zn(_,Ke[P]),onSecondary:(_,P)=>{Dp(Ke[P-V.length],Ke[P-V.length].type)},children:[V.length>0&&X(I.List,{heading:o("commands"),children:V.map((_,P)=>X(I.ListItem,{index:Vr(P,[],"commands"),closeOnSelect:!1,onClick:_.onClick,children:_.label},_.label))}),[...te,...k].map(({value:_,label:P,list:Re,lineClamp:nt,listOrientation:vo},jp)=>X(I.List,{heading:P,orientation:vo==="horizontal"?"horizontal":"vertical",children:Jn(Re,_).map((oe,qp)=>X(I.ListItem,{index:Vr(V.length+qp,[...te,...k].slice(0,jp).map(({list:Vp})=>Vp),_),closeOnSelect:!1,lineClamp:nt,onClick:()=>Zn(oe.text,oe),description:_!=="IMAGE"?oe.title&&oe.text:void 0,children:_==="IMAGE"?X(I.Image,{title:oe.title||oe.text,src:oe.image}):oe.title||oe.text},`${oe.id}-${oe.text}`))},_))]})}),X(I.Page,{id:"edit",onDismiss:ot(()=>{t(j("search")),p(null)}),children:c&&X(un,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(j("search")),p(null),u([])},onNext:zp,onPrevious:Up,onUse:_=>{t(j("search")),Zn(_,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(Y(!1)),u([]),p(null)}})}),X(I.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:ot(()=>{t(j("search"))}),children:X(hl,{onUse:Kp,onCopy:Hp})}),X(I.Page,{id:"summary",title:o("summaryTitle"),onDismiss:ot(()=>{t(j("search"))}),children:X(Cl,{onCopy:Fp})}),X(I.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:ot(()=>{t(Rt()),t(j("search"))}),children:X(Al,{promptInstruction:l.knowledgeAssistPromptInstruction,question:r,onUse:Bp,onResetQuestion:()=>{t(Rt()),i("")}})})]})},Nl=Um;import{jsx as dr,jsxs as qm}from"react/jsx-runtime";var jm=()=>{let t=b("showSearch"),e=b("isEmbedded");return qm(zm,{children:[t&&dr(Nl,{}),dr(ol,{}),e&&dr(ll,{})]})},Dl=jm;import{connect as gf,useDispatch as mf,useSelector as xn}from"react-redux";function At(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 pf,useMemo as df}from"react";import{Interweave as Ym}from"interweave";import{useEffect as ef,useMemo as tf,useRef as of}from"react";import{useDispatch as nf,useSelector as sf}from"react-redux";import{useEffect as Vm}from"react";function Hl(t,e,o){Vm(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var Wm=/[.*+?^${}()|[\]\\]/g,Gm=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function $m(t){return t.replace(Wm,"\\$&")}function Xm(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function Qm(t){return t.search(Gm)}function Bl(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${$m(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function Fl(t){return t.replace(lt,'<mark data-type="placeholder">$1</mark>')}function io(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Zm(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 ur(t,e,o={}){if(e){let n=Xm(e.toLowerCase(),t.toLowerCase()),s=io(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=Qm(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(Yr).length>3||e.length>30?Zm(e.trim(),n):0;return`${`${i>0?"\u2026":""}${io(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var Kl={badge:"_badge_1syy2_1",formattedText:"_formattedText_1syy2_5"};import{jsx as Ul}from"react/jsx-runtime";var rf=["search","personal-collection-search","search-autocomplete"];function af(t,e,o,n={}){let s="";return rf.includes(e)?s=Bl(ur(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=ur(t,o,n),n.placeholders===!0&&(s=Fl(s)),s}var lf=()=>{},cf=({index:t,selected:e,suggestion:o})=>{let n=b("inlineSuggestions"),s=sf(dt),r=nf(),i=S("TextSuggestion",Kl),a=of(null);ef(()=>{let c=setTimeout(()=>{r(gi({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(c)}},[o]),Hl(a,"click",()=>{r(Ve(t)),r(se({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=tf(()=>af(o.text,o.source,s,{stripAgentPart:n,placeholders:!0,searchKeywords:o.searchKeywords}),[n,o.text,o.source,s,o.searchKeywords]);return o.source==="gpt"&&!n?null:Ul(M,{ref:a,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:lf,children:Ul(Ym,{containerTagName:"div",noWrap:!1,tagName:"span",className:i.formattedText,content:l})})},zl=cf;import{jsx as jl}from"react/jsx-runtime";var uf=({suggestions:t,selectedIndex:e,reverse:o})=>{let n=df(()=>{let s=t.map((r,i)=>jl(zl,{index:i,selected:i===e,suggestion:r},`${r.text}-${r.source}`));return o?s.reverse():s},[t,e,o]);return jl(pf,{children:n})},_n=uf;var ql={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};import{jsx as bn}from"react/jsx-runtime";var ff=({textSuggestions:t,selectedIndex:e})=>{let o=S("InlineSuggestionsOverlay",ql),n=xn(At),s=mf(),r=xn(ie),i=xn(pt),a=xn(mn),l=b("showTextSuggestions");return mt(()=>{s(Ne({collapse:!0,skipWhenInputFocus:!0}))}),a||!n||!l||t.length===0||r!==!0||i===!1?null:bn("div",{className:o.root,"data-variant":"inline",children:bn("div",{className:o.paper,children:bn(ne,{children:bn(_n,{suggestions:t,selectedIndex:e})})})})},hf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Vl=gf(hf)(ff);import yr from"classnames";import{useEffect as Rf,useRef as If,useState as Pf}from"react";import{connect as Af,useDispatch as Lf,useSelector as Tn}from"react-redux";import{useState as yf}from"react";function Wl(t,e){let[o,n]=yf(()=>{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 _f from"classnames";import{Fragment as xf,useCallback as mr,useMemo as $l}from"react";var gr={};z(gr,{enUS:()=>Sf,nlNL:()=>vf});var Sf={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"}]}]},vf={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 Gl={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};import{jsx as Cn,jsxs as Xl}from"react/jsx-runtime";var fr=(t,e,o)=>n=>Cn("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),bf=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n})=>{let s=T(gr),r=ee(),i=S("Login",Gl),a=b("productName"),l=mr(g=>{g.preventDefault(),n&&n(parseInt(g.target.value,10))},[]),c=mr(g=>{g.preventDefault(),r.send(Tt,!0)},[e]),p=$l(()=>g=>Cn("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[e]),d=mr(g=>Cn("button",{type:"button",className:i.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:u,hour:m,day:f}=$l(()=>({min:fr(i,60*10,l),hour:fr(i,60*60,l),day:fr(i,60*60*12,l)}),[]);return Xl("div",{className:_f(t,i.root),children:[s("loginPlease",{login:o?d:p,productName:a}),n&&Xl(xf,{children:[Cn("br",{}),s("snooze",{min:u,hour:m,day:f})]})]})},wn=bf;import{useDispatch as Cf}from"react-redux";var Ql={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};import{jsx as Zl,jsxs as Tf}from"react/jsx-runtime";var wf=({title:t})=>{let e=S("SearchTrigger",Ql),o=Cf();return Tf("button",{type:"button",className:e.root,onClick:()=>o(Y(!0)),children:[Zl(vt,{}),Zl("span",{className:e.text,children:t})]})},Jl=wf;var hr={};z(hr,{enUS:()=>Ef,nlNL:()=>kf});var Ef={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"}]},kf={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 Yl={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 K,jsxs as ao}from"react/jsx-runtime";var Mf=({textSuggestions:t,selectedIndex:e})=>{let o=S("SuggestionsOverlay",Yl),n=T(hr),s=Tn(At),r=li(),i=Lf(),a=If(null),l=b("searchTriggerKey"),c=b("productName"),p=Tn(mn),d=Tn(ie),u=Tn(pt),[m,f]=Pf(null),g=b("showSearch"),x=b("showTextSuggestions"),w=b("adminUrl"),h=b("isEmbedded"),[y,v]=Wl("dd-snooze-until-ms",0),C=p||y>Date.now(),H=t.filter(N=>N.source!=="gpt").length,O=()=>{C&&v(0),i(ja(!C))},le=N=>{let k=Date.now()+N*1e3;v(k),E.info(`Snooze until: ${new Date(k)}`),i(Ne({collapse:!0}))};return Rf(()=>{H===0&&f(null)},[t,H]),mt(()=>{i(Ne({collapse:!0,skipWhenInputFocus:!0}))}),d===null||u===!1?null:d===!1?ao("div",{ref:a,className:yr(o.root,{[o.isCollapsed]:C}),children:[!C&&ao("div",{className:o.triggers,children:[K("div",{style:{flex:1}}),K("div",{className:o.triggersRight,children:K(at,{className:o.toggleButton,title:n("collapse"),onClick:O,isCollapsed:!1})})]}),K("div",{className:o.toggleButtonWrapper,children:K(at,{className:o.toggleButton,title:n("open",{productName:c}),onClick:O,isCollapsed:!0})}),K("div",{className:o.collapsible,children:K(wn,{loginUrl:w,isEmbedded:h,onSnooze:le})})]}):!r||!s?null:ao("div",{ref:a,className:yr(o.root,{[o.isCollapsed]:C}),children:[!C&&ao("div",{className:o.triggers,children:[K("div",{style:{flex:1},children:g&&K("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(n(an()?"searchHintMac":"searchHintWindows",{searchTriggerKey:l.toUpperCase()})),onMouseLeave:()=>f(null),children:K(Jl,{title:n("search")})})}),ao("div",{className:o.triggersRight,onFocus:()=>{},children:[K("div",{className:yr(!m&&o.hintsHidden,o.hints),children:m}),K(at,{className:o.toggleButton,title:n("collapse"),onClick:O,isCollapsed:!1})]})]}),K("div",{className:o.toggleButtonWrapper,children:K(at,{className:o.toggleButton,title:n("open",{productName:c}),onClick:O,isCollapsed:!0})}),H>0&&x&&K("div",{className:o.collapsible,onFocus:()=>{},children:K(ne,{children:K(_n,{suggestions:t,selectedIndex:e,reverse:!0})})})]})},Of=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),ec=Af(Of)(Mf);import{Provider as Nf}from"react-redux";import{jsx as En}from"react/jsx-runtime";var Df=({children:t})=>{let o=b("locale").replace("-","");return En(Cs.Provider,{value:o,children:t})},Hf=({store:t,customStyles:e={},children:o})=>En(Nf,{store:t,children:En(Df,{children:En(Ft.Provider,{value:e,children:o})})}),Lt=Hf;import Rr from"classnames";import{Interweave as wh}from"interweave";import{useCallback as Th,useEffect as Eh,useMemo as _c,useRef as kh}from"react";import{connect as Rh}from"react-redux";import{cloneElement as Bf}from"react";var Ff=["div","span","mark","strong","b","i","u","em"];function Sr(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(Ff.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),Bf(n,{children:Sr(i,e,o+1)})]}return[...t,...e]}function He(t){return t.tagName.toLowerCase()==="textarea"}var tc={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 oh from"classnames";import{Matcher as nh}from"interweave";import{useEffect as sh,useMemo as rh}from"react";function oc(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function kn(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function nc(t){return t!=null}import lc from"classnames";import{createRef as Xf,useCallback as _r,useMemo as Qf,useRef as Zf,useState as Jf}from"react";import{useState as Kf,useLayoutEffect as Uf}from"react";var zf=["bottom","height","left","right","top","width"],jf=(t={},e={})=>zf.some(o=>t[o]!==e[o]),Te=new Map,sc,rc=()=>{let t=[],e=[];Te.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();jf(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Te.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),sc=window.requestAnimationFrame(rc)};function qf(t,e){return{observe(){let o=Te.size===0;if(Te.has(t)){let n=Te.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Te.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&rc()},unobserve(){let o=Te.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Te.delete(t),Te.size||cancelAnimationFrame(sc)}}}}function vr(t){let[e,o]=Kf(null);return Uf(()=>{if(!t.current)return;let n=qf(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}import{useContext as Vf,useLayoutEffect as Wf,useState as Gf}from"react";import{createPortal as $f}from"react-dom";var ic={root:"_root_1jq08_1"};var ac=({children:t})=>{let[e,o]=Gf(null),n=Vf(Ft);return Wf(()=>{let s=document.createElement("div");return Ge(s),s.classList.add(ic.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?$f(t,e):null};var ge={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 xr}from"react/jsx-runtime";var Rn=(t=!1)=>{let[e,o]=Jf(t),n=_r(()=>o(!0),[]),s=_r(()=>o(!1),[]),r=_r(()=>o(a=>!a),[]),i=Zf(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function br(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 In=({className:t,triggerRef:e,boundaryRef:o=Xf(),position:n="above",align:s="center",children:r,toStyle:i=br,...a})=>{let l=vr(e),c=vr(o),p=Qf(()=>i(l,c,0),[l,c]);return xr(ac,{children:xr("div",{className:lc(ge.ref,{[ge.positionAbove]:n==="above",[ge.positionBelow]:n==="below",[ge.positionLeft]:n==="left",[ge.positionRight]:n==="right",[ge.alignStart]:s==="start",[ge.alignCenter]:s==="center",[ge.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:xr("div",{className:lc(t,ge.root),children:r})})})};import Yf from"classnames";import{forwardRef as eh,useRef as th}from"react";import{jsx as cc}from"react/jsx-runtime";var Pn=eh(({className:t,children:e,...o},n)=>{let s=th(null),r=S("TabCompletion",ye);return cc("div",{ref:kn([s,n]),className:Yf(t,r.popoverContentContainer),...o,children:cc("div",{className:r.popoverContent,children:e})})});import{jsx as lo,jsxs as lh}from"react/jsx-runtime";var ih=t=>e=>{let o=br(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},ah=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=S("TabCompletion",ye),i=Rn(),a=rh(()=>ih(t.getBoundingClientRect()),[t]),[l,c]=Yo(t);return sh(()=>{c?i.open():i.close()},[c]),lh("span",{children:[lo("mark",{ref:kn([l,i.triggerRef]),className:oh(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&lo(In,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:lo(Pn,{style:o,children:lo("div",{className:r.hintText,children:s})})})]})},An=class extends nh{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${oc(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(nc);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 lo(ah,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import kr from"classnames";import{Matcher as yh}from"interweave";import{createRef as Sh,forwardRef as vh,useCallback as _h,useEffect as yc,useRef as Sc,useState as vc}from"react";import{useDispatch as xh}from"react-redux";import{jsx as pc}from"react/jsx-runtime";var dc=()=>pc("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:pc("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 ch,useEffect as gc,useState as mc}from"react";import{useDispatch as ph,useSelector as fc}from"react-redux";import dh from"lodash.debounce";var uc={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Ln(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 Cr(t){return t.replace("https://www.","").replace("https://","")}import{jsx as Ze,jsxs as wr}from"react/jsx-runtime";var uh=3,gh=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),mh=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=uh})=>{let r=S("LinkSearch",uc),[i,a]=mc(""),l=ph(),c=fc(Ra("url")),p=fc(ga("URL",gh)),[d,u]=mc(p.length-1),m=b("fallbackImage"),f=h=>{let y=h.target;a(y.value)},g=(h,y)=>{h.stopPropagation(),h.preventDefault(),window.open(y,"_blank")},x=h=>{var C;let y=d-1<0?p.length-1:d-1,v=d+1===p.length?0:d+1;h.code==="Escape"&&(a(""),e()),h.code==="ArrowUp"&&u(y),h.code==="ArrowDown"&&u(v),h.code==="Enter"&&t(((C=p[d])==null?void 0:C.text)||i)},w=ch(dh(h=>{l(Xe({query:h,type:"URL",tags:["link-search"]}))},300),[]);return gc(()=>{i&&w(i)},[i]),gc(()=>()=>{l(cn())},[]),wr("div",{className:r.root,children:[Ze(ne,{withDivider:!0,children:(i?p:c).slice(0,s).map((h,y)=>Ze(M,{selected:d===y,onClick:()=>t(h.text),"data-testid":"linksearch-suggestion",children:wr(D,{children:[Ze(D.Image,{src:Ln(h,"small",m||void 0),title:h.title||h.text}),wr(D.Content,{className:r.content,cropText:!0,children:[Ze(D.Title,{children:h.title||Cr(h.text)}),h.title&&Cr(h.text)]}),Ze(M.Actions,{children:Ze(M.ActionButton,{label:n,onClick:v=>g(v,h.text)})})]})},h.text))}),Ze(to,{value:i,onChange:f,autoFocus:!0,placeholder:o,onKeyUp:x})]})},hc=mh;var Tr={};z(Tr,{enUS:()=>fh,nlNL:()=>hh});var fh={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},hh={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};import{jsx as me,jsxs as Er}from"react/jsx-runtime";var bh=vh((t,e)=>{let o=S("TabCompletion",ye);return me("mark",{ref:e,className:kr(o.matchSelection)},"selection-start")}),Ch=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=T(Tr),i=S("TabCompletion",ye),a=Sc(null),l=Sc(null),[c,p]=vc(null),d=xh(),u=Rn(document.activeElement===n),[m]=vc(()=>document.createRange());u.triggerRef.current=m,yc(()=>()=>m.detach(),[]),yc(()=>{let g=t.current,x=a.current;!g||!x||(m.setStart(g,0),m.setEnd(x,0))},[t.current,a.current]),mt(()=>{u.close()});let f=_h(g=>{let x=m.toString(),w=/^http(s?):\/\//.test(g)?g:`https://${g}`;d(Oo({text:`[${x}](${w})`,replace:"selection"}))},[]);return Er("span",{children:[me("mark",{ref:a,className:kr(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":u.opened?"true":"false",children:s}),u.opened&&me(In,{className:i.popoverRoot,triggerRef:u.triggerRef,boundaryRef:e,position:"above",align:"start",children:Er(Pn,{style:o,ref:l,children:[me("div",{className:kr(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:Er("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[me(dc,{}),me("span",{children:"\xA0"}),me("span",{children:r("insertLink")})]})}),c==="insertLink"&&me(hc,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:f,onDismiss:()=>{p(null),u.close()}})]})})]},"selection-end")},Mn=class extends yh{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=Sh(),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?me(bh,{ref:this.startRef}):me(Ch,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};import{jsx as Mt,jsxs as Ah}from"react/jsx-runtime";var Ih=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=S("TabCompletion",tc),p=b("insertLink"),d=b("showMidSentenceSuggestions"),u=b("inlineSuggestions"),m=tn(a),f=kh(null);Eh(()=>{He(a)&&m&&on(a,m)},[m]);let g=Th(h=>{if(!s||!o)return h;let y=[Mt("span",{className:c.resetIndent,children:"\u200B"},"u200B"),Mt("span",{"data-testid":"tab-completion",className:Rr(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&y.push(Mt("span",{className:Rr(c.hint,c.resetIndent),children:Mt(os,{keyCode:"tab"},"tabHint")})),Sr(h,y)},[s,o,n]),x=_c(()=>{let h=[];return p&&h.push(new Mn("selection")),h.push(new gt("placeholders")),r&&h.push(new An("keywords")),h},[u,p,r]),w=_c(()=>{let h=window.getComputedStyle(a);return{"--dd-color":h.color,"--dd-font-size":h.fontSize,"--dd-font-family":h.fontFamily,"--dd-font-variant":h.fontVariant}},[]);return t?Ah("div",{ref:h=>{h!=null&&h.parentElement&&(f.current=h==null?void 0:h.parentElement)},className:c.root,style:w,children:[Mt(wh,{tagName:"span",containerTagName:"div",className:Rr(c.container,c.agentText),disableLineBreaks:He(a),content:e||"\u200B",onAfterParse:g,matchers:x,selection:m,keywordMatches:i,inputElement:a,inputStyle:w,boundaryRef:f,inlineSuggestionsOnlyAtEnd:!d}),Mt("br",{})]}):null},Ph=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var g;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??io(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:u,visible:m,showStyleSuggestions:f}=o;return{showTabHint:p,showStyleSuggestions:f,showTabCompletion:u,content:l,tabText:c,source:a,keywordMatches:((g=n.list)==null?void 0:g.keywordMatches)??[],enabled:m&&d!==!1}},xc=Rh(Ph)(Ih);import my from"classnames";import{useEffect as fy}from"react";import{useDispatch as hy,useSelector as Q}from"react-redux";import{createAsyncThunk as co,createSlice as Lh}from"@reduxjs/toolkit";var bc={list:[],fetchState:"idle",isInitialRequest:null},wc=t=>t.autoflows.list||[],Cc=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},Ee=co("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Ir=co("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(Ee(t.platformSessionId))}),Pr=co("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(Ee(t.platformSessionId))}),Mh=Lh({name:"autoflows",initialState:bc,reducers:{},extraReducers:t=>{t.addCase(Ir.pending,(e,o)=>{let n=Cc(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Pr.pending,(e,o)=>{let n=Cc(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(Ee.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(Ee.rejected,e=>{e.fetchState="error"}),t.addCase(Ee.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(R,()=>bc)}}),Tc=co("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(Ee(t))}),s.on("sessionCompleted",()=>{o(Ee(t))})}),Ec=co("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),kc=Mh.reducer;import{createAsyncThunk as uo,createSlice as Oh}from"@reduxjs/toolkit";var Rc={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Ic=t=>t.customMessages.list,Pc=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Ac=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Lc=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),po=uo("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),On=uo("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)}),Nn=uo("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)}),Mc=Oh({name:"customMessages",initialState:Rc,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(po.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(po.rejected,e=>{e.fetchState="error"}).addCase(po.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(On.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(On.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(Nn.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(Nn.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(R,()=>Rc)}}),Oc=uo("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(Mc.actions.onCustomMessage(r))})}),Nc=uo("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Dc=Mc.reducer;import{createAsyncThunk as Hc,createSlice as Nh}from"@reduxjs/toolkit";var Dh={jwt:null,accountUrl:null,interval:null},Bc=t=>e=>{let{exchangeToken:{jwt:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/jwt/?jwt=${o}&redirect=${t}`:null},Ar=Hc("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.getTemporaryExchangeToken();return{accountUrl:o.client.baseUrl,jwt:n}}),Lr=Hc("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:o=1e3*60*30}=t,{dispatch:n}=e;return n(Ar()),setInterval(()=>n(Ar()),o)}),Fc=Nh({name:"exchangeToken",initialState:Dh,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Ar.fulfilled,(e,o)=>{e.jwt=o.payload.jwt,e.accountUrl=o.payload.accountUrl}),t.addCase(Lr.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollExchangeToken:Kc}=Fc.actions,Uc=Fc.reducer;function zc(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}import{Fragment as Wh}from"react";import{connect as Gh}from"react-redux";import jh from"classnames";import{Fragment as qh}from"react";import Hh from"classnames";var jc={root:"_root_838fd_1"};import{jsx as Fh}from"react/jsx-runtime";var Bh=({className:t,children:e})=>{let o=S("Unicode",jc);return Fh("span",{className:Hh(t,o.root),children:e})},qc=Bh;var Vc={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 Mr={};z(Mr,{enUS:()=>Kh,nlNL:()=>Uh});var Kh={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"}]},Uh={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 Je,jsxs as Dn}from"react/jsx-runtime";var Vh=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=S("Autoflow",Vc),a=T(Mr),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return Dn(M,{className:jh(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[Je(D,{children:Dn(D.Content,{children:[Dn(D.Title,{children:[e&&Je("span",{className:i.stateBadge,children:a(e)}),o]}),Je("span",{children:n})]})}),Je(M.Actions,{fixed:e==="Started",children:Je(M.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:Dn(qh,{children:[Je(qc,{children:c})," ",Je("span",{children:a(l)})]})})})]})},Wc=Vh;import{jsx as Gc}from"react/jsx-runtime";var $h=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Xh=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>Gc(Wh,{children:t.map(s=>Gc(Wc,{displayName:s.displayName,description:s.description,disabled:s.isBusy||$h(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),Qh=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},Zh={onStartAutoflow:Ir,onStopAutoflow:Pr},$c=Gh(Qh,Zh)(Xh);import{useEffect as Jh,useState as Yh}from"react";import{useDispatch as ey}from"react-redux";import Zc from"classnames";import{jsx as Xc}from"react/jsx-runtime";var Or=()=>Xc("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:Xc("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 Qc={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 Jc}from"react/jsx-runtime";var ty=({entities:t})=>{let e=S("EntitiesWidgetList",Qc),[o,n]=Yh(void 0),s=ey(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),no(a.text),s(Z({name:"entity copied",data:{entity:a,type:"copy"}})))};return Jh(()=>{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)=>Jc("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[Ot("span",{className:e.entityText,children:a.text}),Jc("span",{className:e.iconWrapper,children:[Ot("span",{className:Zc(e.icon),children:Ot(Or,{})}),Ot("span",{className:Zc(e.icon,o===l&&e.iconClicked),children:Ot(Or,{})})]})]},a.text))})},Yc=ty;import sy from"classnames";import{useCallback as ep}from"react";import{useDispatch as ry,useSelector as Hn}from"react-redux";var go={};z(go,{enUS:()=>oy,nlNL:()=>ny});var oy={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"}],answer:[{type:0,value:"Answer"}]},ny={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"}],answer:[{type:0,value:"Antwoord"}]};var ke={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 Be,jsxs as Bn}from"react/jsx-runtime";var iy=({suggestion:t})=>{let e=T(go),o=ry(),n=Hn(Pc(t.text)),s=Hn(Ac(t.text)),r=Hn(Lc(t.text)),i=Hn(Eo),{replyOptions:a}=t,l=ep(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(On({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(Nn({platformSessionId:i,reply:u,suggestion:t}))},[t,n,o,i]);return Bn(M,{onClick:l,className:sy(ke.root,{[ke.isUsed]:n,[ke.hasError]:r}),children:[Be(D,{children:Bn(D.Content,{children:[Bn(D.Title,{className:ke.title,children:[t.text," ",Be(ns,{className:ke.label,children:"analyse tool"})," ",r&&Be("span",{className:ke.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&Be("ul",{className:ke.quickReplies,children:a.map(p=>Be("li",{className:ke.quickReply,children:p.title},p.title))})]})}),Bn(M.Actions,{fixed:r||n,children:[a&&a.length>0&&Be(M.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>Be(M.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),Be(M.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},tp=iy;import{jsx as op}from"react/jsx-runtime";var np=()=>op("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:op("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 cy}from"react-redux";import{useCallback as ay}from"react";import{jsx as Ye,jsxs as Fn}from"react/jsx-runtime";var ly=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var u;let s=t.text||t.url||t.message,r=pn(s),i=T(go),a=b("showImages"),l=b("fallbackImage"),c=m=>{m.preventDefault(),m.stopPropagation(),n(s)},p=m=>{m.preventDefault(),m.stopPropagation(),o(t)},d=ay(m=>{window.open(r,"_blank"),m.stopPropagation(),m.preventDefault()},[r]);return Fn(M,{onClick:c,"data-testid":"edit-suggestion",children:[Fn(D,{children:[a&&t.image&&Ye(D.Image,{src:Ln(t,"small",l||void 0),title:t.title}),Fn(D.Content,{children:[t.title&&Ye(D.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&Ye(M.Labels,{labels:t.searchKeywords}),Ye(D.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),Fn(M.Actions,{children:[r&&Ye(M.ActionButton,{onClick:d,label:i("visitUrl")}),Ye(M.ActionButton,{primary:!0,onClick:p,label:i("preview")}),Ye(M.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},sp=ly;import{Fragment as dy,jsx as rp}from"react/jsx-runtime";var py=({contentType:t,lines:e,suggestions:o})=>{let n=ee(),s=cy(xt),r=a=>{n.send(Xs,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(be,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return rp(dy,{children:o.map(a=>rp(sp,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},ip=py;var Nr={};z(Nr,{enUS:()=>uy,nlNL:()=>gy});var uy={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"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},gy={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"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var ap={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 lp}from"react/jsx-runtime";var cp=()=>lp("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:lp("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 pp}from"react/jsx-runtime";var dp=()=>pp("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:pp("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 L,jsxs as Nt}from"react/jsx-runtime";var Kn=(t,e)=>{let o=Q(ie);fy(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},yy=()=>{let t=T(Nr),e=hy(),o=b("isEmbedded"),n=S("Widget",ap),s=b("showAutoflows"),r=b("showCustomMessages"),i=b("showPersonalCollectionLink"),a=b("showSummaryCommand"),l=b("showKnowledgeSearch"),c=b("showSearch"),p=Q(It),d=Q(vn),u=Q(wc),m=Q(hn),f=Q(Ic),g=Q(ko),x=Q(pt),w=Q(ie),h=Q(Eo),y=Q(zc),v=Q(xt),C=ee(),H=Q(Pa),O=Q(Bc("/admin/personal-collection")),le=b("adminUrl");if(Kn(()=>(e(po(h)),e(Oc(h)),()=>{e(Nc(h))}),[e,x,r,h]),Kn(()=>(e(Ee(h)),e(Tc(h)),()=>{e(Ec(h))}),[e,x,s,h]),Kn(()=>{d.forEach(({type:k})=>{e(k==="entities"?ae():_e(k))})},[e,x,g,p]),Kn(()=>(e(Lr()),()=>{e(Kc())}),[e,x,i,g]),x===!1)return L("div",{className:n.stateText,children:L("div",{children:L("p",{children:t("notSupported")})})},"supported");if(w===!1)return L("div",{className:n.loginText,children:L("div",{children:L(wn,{isEmbedded:o,loginUrl:le})})},"login");if(!p||!h||w===null||H||y)return L("div",{className:n.stateText,children:L("div",{children:L("p",{children:t("waiting")})})},"waiting");let N=c||a||l||O;return L("div",{className:my(n.root),"data-testid":"widget",children:Nt(rs,{className:n.sectionList,children:[N&&L(Ue,{title:t("actions"),type:"shortcuts",children:Nt("div",{className:n.shortcutList,children:[c&&Nt("button",{className:n.shortcut,"data-testid":"shortcut-search",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0}),children:[L(vt,{}),t("linkSearch")]}),a&&Nt("button",{className:n.shortcut,"data-testid":"shortcut-summary",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[L(dp,{}),t("linkSummary")]}),l&&Nt("button",{className:n.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[L(cp,{}),t("linkKnowledgeSearch")]}),O&&Nt("a",{className:n.shortcut,target:"_blank",href:O,"data-testid":"shortcut-personal-collection",rel:"noreferrer",children:[L(np,{}),t("linkPersonalcollection")]})]})}),r&&f.length>0&&L(Ue,{type:"custom-messages","data-testid":"custom-messages",children:L(ne,{withDivider:!0,children:f.map(k=>L(tp,{suggestion:k},k.text))})}),s&&u.length>0&&L(Ue,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:L(ne,{withDivider:!0,children:L($c,{})})}),d.map(({type:k,title:V,amount:te,lines:Qn})=>{var Ke;switch(k){case"entities":return m&&m.length>0&&L(Ue,{type:k,title:V,"data-testid":`type-${k}`,children:L(Yc,{entities:m})},k);default:return((Ke=v[k])==null?void 0:Ke.fetchState)==="done"&&v[k].suggestions.length>0&&L(Ue,{type:k,title:V,"data-testid":`type-${k}`,children:L(ne,{withDivider:!0,children:L(ip,{lines:Qn,contentType:k,suggestions:v[k].suggestions.slice(0,te)||[]})})},k)}})]})})},up=yy;function fo(t){let e=new Range;return e.selectNodeContents(t),e}function gp(t,e,o){try{return et(t,e,o),!0}catch{return!1}}function Un(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function zn(t){return"tagName"in t&&t.tagName==="BR"}var mo=/[\u200B-\u200D\uFEFF]/g;function et(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(mo,""),d=s+p.length,u=e>=s&&e<=d,m=o>=s&&o<=d;if(u){let f=i(c,e-s);f===0&&!m?n.setStartBefore(l):n.setStart(l,f)}m&&(n.setEnd(l,i(c,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(zn(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;Un(l)&&c&&!Un(c)&&!zn(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function jn(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,m=d===s;switch(d.nodeType){case Node.TEXT_NODE:{let f=d.textContent;u&&(a=c+f.substring(0,n).replace(mo,"").length),m&&(l=c+f.substring(0,r).replace(mo,"").length),c+=f.replace(mo,"").length;break}case Node.ELEMENT_NODE:{let f=d.nextSibling===null;zn(d)&&!f&&c++;for(let g=0;g<d.childNodes.length;g++){let x=u&&g===n,w=m&&g===r;if(x&&(a=c),w&&(l=c),l!==void 0||((!x||!i)&&p(d.childNodes[g]),m&&g===r-1&&(l=c),l!==void 0))break}!m&&Un(d)&&!f&&c++,m&&(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 qn(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,m=d?r:void 0,f=c.textContent.replace(mo,"");u===0&&m===void 0?a+=f:a+=f.substring(u,m);break}case Node.ELEMENT_NODE:{let u=c.nextSibling===null;i===0&&zn(c)&&!u&&(a+=`
4
- `);for(let m=p?n:0;m<(d?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[m]),i!==1);m++);!d&&i===0&&Un(c)&&!u&&(a+=`
5
- `);break}default:break}d&&i++}return l(t),a}function mp(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Dt=class extends Le{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),qn(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!mp(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!mp(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return jn(this.element,e);let o=this.lastKnownSelection;if(o&&gp(this.element,o.start,o.end))return o;let n=fo(this.element);return n.collapse(!1),jn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return qn(this.element,et(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()}};var Dr=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()}},Hr=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=this.createIframe(),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];createIframe(){let e=`deepdesk-iframe-${this.name}`,o=document.getElementById(e);if(o)return o;let n=document.createElement("iframe"),s=`${this.targetOrigin}/v2/widget/liveengage/channel.html`,r=new URLSearchParams({channel:this.name,host:window.location.origin});return this.options.debug&&r.set("debug","1"),n.style.position="absolute",n.style.left="-999em",n.style.width="0px",n.style.height="0px",n.tabIndex=-1,n.id=e,n.title=`iframe-${this.name}`,n.src=`${s}?${r.toString()}`,n}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()}},Br=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,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 Hr(e,this.deepdeskUrl,{debug:!0}):new Dr(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 s,r,i;if(!this.sessionId)return;E.info("broadcast event",{sessionId:this.sessionId,name:e,payload:o});let n={type:"event",name:e,payload:o};(r=(s=this.eventMap)[e])==null||r.call(s,o),(i=this.channel)==null||i.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)}},fp=Br;var Ht=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Fr=t=>new Promise(e=>{setTimeout(e,t)});var Bt=class extends Ht{name="ClientError"},Kr=class extends Ht{name="ServerError"},fe=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=v=>v instanceof TypeError,retryOnResponse:m=v=>v.status>=500,version:f="v1",...g}=o,x={credentials:"include",...g,headers:{"Content-Type":"application/json",...g.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(x.headers={...x.headers,"X-CSRFToken":this.csrfToken}),typeof f=="string"&&(x.headers={...x.headers,"X-Deepdesk-API-Version":f});let w=c,h=!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 y=async()=>(w--,a(i,x).then(async v=>m(v)&&!r.isAborted&&w>0?(await Fr(p),y()):v.status===401&&d===!0&&h===!1?(h=!0,await this.refreshToken(),y()):v).catch(async v=>{if(u(v)&&!r.isAborted&&w>0)return await Fr(p),y();throw v}));y().then(v=>v.json().catch(()=>null).then(C=>{v.status>=500?s(new Kr("Server Error",C)):v.status===401?s(new Bt("Unauthorized",C)):v.status===403?s(new Bt("Forbidden",C)):v.status===404?s(new Bt("Not Found",C)):v.status>=400&&s(new Bt("Bad Request",C)),delete this.latestRequestByUrl[i],n(C)})).catch(v=>{s(v)})})}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 Sy;(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||={})})(Sy||={});function Vn(t){return{...A(t),tags:t.tags}}var Fe=class t{constructor(e,o={}){this.options=o;this.client=new fe(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",{...B(e),tags:e.tags},{version:"v2"});return Vn(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${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 Vn(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=B(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return Vn(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...B(s),tags:s.tags})),{version:"v2"})).map(s=>Vn(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",B({...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:B({...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/",B(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}`,B(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`,B(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",B(e),{abortLatest:!0});return A(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,B(e),{version:"v2"});return A(o)}async knowledgeAssist(e,o,n){let s=await this.client.post("/api/knowledge-search/search",B({question:e.question,promptInstruction:e.promptInstruction,profile:n,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 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(ei);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 ho=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Ks(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 vy;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(vy||={});var yo=class{constructor(e,o={}){this.apiUrl=e;this.client=new fe(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`,B(o));return A(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,B(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",B(e));return A(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new ho(`${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 Ey,configureStore as ky}from"@reduxjs/toolkit";import{createSlice as _y}from"@reduxjs/toolkit";var hp={startTime:null,stopTime:null},yp=_y({name:"handlingTime",initialState:hp,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(R,()=>hp)}}),{handlingTimeStart:Sp,handlingTimeStop:Wn,handlingTimeReset:vp}=yp.actions,_p=yp.reducer;var xp=(t={})=>{let e={onAuthError:wt(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};import{createAsyncThunk as xy,createSlice as by}from"@reduxjs/toolkit";var Gn={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var tt=xy("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 Gn.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),Cy=by({name:"styleSuggestions",initialState:Gn,reducers:{},extraReducers:t=>{t.addCase(tt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(tt.rejected,e=>{e.fetchState="error"}).addCase(tt.fulfilled,(e,o)=>{e.fetchState="done",Ie(e.list,o.payload)||(e.list=o.payload)}).addCase(qe,e=>{e.list=Gn.list}).addCase(R,()=>Gn)}}),bp=Cy.reducer;var Cp=(t={})=>{let e,o=!0,n={getStyleSuggestions:tt,debounce:500,...t};return s=>r=>i=>{var m;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(!((m=c.conversation.current)==null?void 0:m.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 wy(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var wp=(t={})=>{let e={getTextSuggestions:_e,getAutocompleteSuggestions:Jt,debounce:200,check:At,...t},o;return n=>s=>r=>{var g;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=(g=l.conversation.current)==null?void 0:g.id,u=r.type===gn.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:m}}=l;return wy(m,i)&&!u||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let x=dt(l);x===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(x))},u?0:e.debounce)),a}};var Tp=tt.fulfilled.toString();function Ty(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 Ep=t=>e=>o=>n=>{var c;if(n.type!==Tp){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=Ty(s,i);n.type===Tp&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var Ry=Ey({activeSuggestion:Ka,answer:kl,auth:Ya,autoflows:kc,conversation:ii,contentTypes:pl,customMessages:Dc,exchangeToken:Uc,entities:gl,handlingTime:_p,info:ca,input:gs.reducer,overlayInput:W.reducer,settings:oi,profile:Ll,search:fa,summary:_l,styleSuggestions:bp,ui:qa,textSuggestions:Na});function kp(t){return ky({reducer:Ry,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),xp(),wp({debounce:200}),Cp({debounce:500}),Ep(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Iy=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Py=t=>e=>o=>n=>{var a;let s=e.getState(),r=cs("inlineSuggestions")(s);switch(n.type){case xe.toString():{let l=Ia(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 wt.toString():{!n.payload&&t.emit("logout",void 0);break}case se.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:Iy(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Oo.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 zt.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case Bo.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 ae.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case Ce.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary}});break;case Z.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 No.toString():t.handleKeyDown(n.payload);break;case qe.toString():t.logSendMessage(n.payload);break;case Do.toString():t.logSendEditSuggestionMessage(n.payload);break;case Ho.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case qe.toString():t.handleAfterSendMessage(n.payload);break;case Yt.toString():t.onUpdateShowTabHint(n.payload);break;case Wn.toString():t.logHandlingTime();break;case se.toString():{r&&(e.dispatch(pe([])),e.dispatch(Ae()));break}case pe.toString():{r&&n.payload.length>0&&e.dispatch(Ve(0));break}default:break}return i},Rp=Py;function Ur(t){return t.toISOString().replace("T"," ").replace("Z","")}function Ip(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:Ur(o),timeStop:Ur(n)}}function zr(t,e,o){var O,le,N;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:d,cuts:u,deletions:m,textSuggestions:f,offeredTextSuggestions:g}}=e[t],x=n.length,h=f.reduce((k,{text:V,searchTerm:te})=>k+V.length-(te?te.length:0),0),y=c??Date.now(),v=(Date.now()-y)/1e3+(p||0),C=s/v,H=f.reduce((k,{searchTerm:V})=>k+(V?V.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:d,cuts:u,deletions:m,lenTextTyped:s+H,lenTextTotal:x,lenTextAssisted:h,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:v,charsPerSecond:C,numPastes:l,textSuggestionsV2:f,suggestionsCounters:[{source:"gpt",countOffered:g.filter(k=>k.source==="gpt").length}],agentId:(O=e.info.agentInfo)==null?void 0:O.agentId,agentName:(le=e.info.agentInfo)==null?void 0:le.agentName,agentEmail:(N=e.info.agentInfo)==null?void 0:N.agentEmail}}function Pp(t,e){let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;return n instanceof HTMLElement?Pp(n,e):null}function Ap(t,e){return Pp(t,e)}function Lp(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Ay(t){return typeof t=="object"&&t!==null&&"tagName"in t}function jr(t){return Ay(t)&&(He(t)||en(t))}var Mp=(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 Ly(t){return t.offsetParent!==null}function Op(t){if(!Ly(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 qr(t,e,o=100){let n=Op(t);e({isVisible:n});let s=setInterval(()=>{let r=Op(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}import{jsx as q}from"react/jsx-runtime";var Np=Mp("showTabHint",!0),Xn=class t{static version="10.4.1-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 Fe(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Rp({emit:(d,u,m)=>this.emit(d,u,m),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=>Np.update(d),sendEvent:(d,u)=>this.deepdeskApi.sendEvent(d,u)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new yo(o)}),this.store=kp(p),this.broadcastEvents=new fp({debug:!0,deepdeskUrl:c,eventMap:el(this.store),createCustomChannel:l}),this.store.dispatch(Ut),this.store.dispatch(Yt(Np.value())),this.store.dispatch(Ut({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(wt(null)),this.store.dispatch(De()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ie(n)&&Ga(n)!=="loading"&&e()});this.unmountHandlers.push(()=>{o()})})}isLoggedIn(){return this.deepdeskApi.isLoggedIn()}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(ds({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Ro(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Io({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(us(e))).payload}async postMessages(e){return(await this.store.dispatch(Ao(e))).payload}async updateConversation(e){return(await this.store.dispatch(Po(e))).payload}resetConversation(){this.store.dispatch(R()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(Ce());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Ut(e))}setVisitorInfo(e){this.store.dispatch(la(e))}async setAgentInfo(e){await this.store.dispatch(Xt(e))}async setAgentSettings(e){await this.store.dispatch(zs(e))}async getAgentSettings(){return(await this.store.dispatch(js())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(gn()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Ho(e))}notifyKeyDown(e){this.store.dispatch(No(e))}notifyPaste(e,o){this.store.dispatch(yi({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(fi(e))}notifyExternalSuggestion(e){this.store.dispatch(se(e)),this.store.dispatch(Ae())}notifyEditSuggestion(e){this.store.dispatch(Ma(e.contentType,e.suggestions)),this.store.dispatch(xe({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(Ne({collapse:!1})),this.inputMediator&&this.store.dispatch(ci({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(pe([])))}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(hi(Mo(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(ui()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(mi());let{selectedSuggestionIndex:d}=this.state.input;e.preventDefault(),!i&&(d===-1?this.store.dispatch(zt()):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(Ve(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(Ve(-1)),this.store.dispatch(zt()),e.preventDefault()):o||(this.store.dispatch(Ne({collapse:!0})),this.store.dispatch(za(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:d}=this.state.input,u=d.text.substring(0,d.selection.end),{tabCompletionSuggestion:m}=this.state.input;this.store.dispatch(Yt(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&m&&m.text.startsWith(u)&&(this.store.dispatch(se({text:m.text,suggestion:m,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(Ae())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Si()),this.store.dispatch(pe([]))}handlingTimeStart(){this.state.handlingTime.startTime||(E.info("Start handling time"),this.store.dispatch(Sp()))}handlingTimeStop(){this.state.handlingTime.startTime&&(E.info("Stop handling time"),this.store.dispatch(Wn()))}logSendMessage(e){let o=zr("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=zr("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(di(this.state.overlayInput.metrics))}logHandlingTime(){let e=Ip(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(vp())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(Ae()),this.store.dispatch(qe(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(se({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]=ht(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{$n(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]=ht(r,{appendTo:document.body});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{$n(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Ge(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(()=>{$n(s),s.remove()}),s}mount(e,o={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!jr(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:m,inputMediator:f,closestScrollSelector:g,appendOverlayTo:x,inlineSuggestions:w}=o;if(this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:m,isEmbedded:d,inlineSuggestions:w}),o.automaticHandlingTime&&this.setupHandlingTime(e),Ge(e),this.inputMediator=f||(He(e)?new Me(e):new Dt(e)),this.inputMediator.on("change",({plainText:y})=>{this.notifyInputChanged(y)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(vi({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",y=>{this.notifyKeyDown(y)}),this.inputMediator.on("paste",({pastedText:y,selectionText:v})=>{this.notifyPaste(y,v)}),this.inputMediator.on("cut",({selectionText:y})=>{this.notifyCut(y)}),w){if(He(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let y=this.createInlineContainer(e,"deepdesk-caret");So(q(Lt,{store:this.store,customStyles:n,children:q(Ct,{broadcastEvents:this.broadcastEvents,children:q(Vl,{})})}),y),this.inputMediator.on("caret",v=>{this.store.dispatch(pe([])),v?(y.style.display="block",y.style.top=`${v.top}px`,y.style.left=`${v.left}px`):y.style.display="none"})}else{let y=g&&Ap(e,g)||void 0,v=this.overlayContainerFactory("deepdesk-tab-completion",y||e,{appendTo:x,closestScrollElement:y,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",y||e,{appendTo:x},n==null?void 0:n.suggestionsRootNode);So(q(Lt,{store:this.store,customStyles:n,children:q(Ct,{broadcastEvents:this.broadcastEvents,children:q(xc,{inputElement:e})})}),v),So(q(Lt,{store:this.store,customStyles:n,children:q(Ct,{broadcastEvents:this.broadcastEvents,children:q(ec,{})})}),C)}So(q(Lt,{store:this.store,customStyles:n,children:q(Ct,{broadcastEvents:this.broadcastEvents,children:q(Dl,{})})}),this.createContainer("deepdesk-overlays"));let h;this.inputMediator.on("selection",y=>{clearTimeout(h),y===null?h=setTimeout(()=>{y!==null&&this.store.dispatch(ms(y))},500):this.store.dispatch(ms(y))}),this.inputMediator.on("disabled",()=>{var y;(y=this.inputMediator)==null||y.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(bt(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(bt(!0))),this.store.dispatch(pi({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var y;this.refresh(),this.broadcastEvents.setSessionId((y=this.state.conversation.current)==null?void 0:y.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,showPersonalCollectionLink:r,isEmbedded:i}=o;this.widgetRoot=e,this.configure({showImages:s,showPersonalCollectionLink:r,isEmbedded:i}),So(q(Lt,{store:this.store,customStyles:n,children:q(Ct,{broadcastEvents:this.broadcastEvents,children:q(up,{})})}),e),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&$n(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=qr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Lp(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(so());let e=It(this.state);e&&this.store.dispatch(Ut({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:e.knowledgeAssistForAgents,recommendTextSuggestions:e.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}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=vn(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(ae()):this.store.dispatch(_e(n))})}catch(n){this.handleError(n)}}};async function My(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 Oy(t,e,o={}){let n=o.replace?et(t,o.replace.start,o.replace.end):fo(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(`
6
- `).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?et(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()}})}async function Ny(t,e){let o;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let n=()=>{let r=(t.ownerDocument.defaultView??window).getSelection();if(!r)return;let i=r.getRangeAt(0);i&&(i.deleteContents(),o=document.createElement("span"),i.insertNode(o),e.split(`
7
- `).reverse().forEach((a,l)=>{l>0&&i.insertNode(document.createElement("br")),i.insertNode(document.createTextNode(a))}),i.collapse(!1))};return Promise.resolve(n()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!o)try{o.scrollIntoView&&o.scrollIntoView({block:"nearest",inline:"nearest"})}finally{o&&o.remove()}})}function Dy(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function Hy(t,e,o){await new Fe(t).authenticateWithKey(e,o)}async function By(t){let o=await new fe(t).get("/platform/config/",{version:null});return A(o)}async function Fy(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 Ky(t,e){let o=await Fy(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{D as Card,Dt as ContentEditableInput,Fe as DeepdeskAPI,Xn as DeepdeskSDK,fe as HTTPClient,Le as InputMediator,ze as InputType,os as KeyboardHint,ns as Label,To as Locale,Ue as Section,rs as SectionList,ce as Sources,M as Suggestion,ne as SuggestionList,Me as TextAreaInput,at as ToggleButton,Ky as attachFile,Hy as authenticateWithKey,fo as createFullRange,ht as createOverlayContainer,et as createRangeFromOffsets,io as escapeHTML,By as fetchPlatformConfig,Dy as formatTextMarkup,jn as getRangeOffsets,qn as getRangeText,Ny as insertCKEditor,jr as isSupportedInputElement,Oy as updateContentEditable,My as updateTextArea,S as useStyles,qr as waitForElementVisibilityChange};
3
+ `,Ge.MISSING_INTL_API,i);var x=o.getPluralRules(e,{type:p.pluralType}).select(d-(p.offset||0));y=p.options[x]||p.options.other}if(!y)throw new Ts(p.value,d,Object.keys(p.options),i);a.push.apply(a,Gt(y.value,e,o,n,s,d-(p.offset||0)));continue}}return dd(a)}function md(t,e){return e?ee(ee(ee({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=ee(ee({},t[n]),e[n]||{}),o},{})):t}function fd(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=md(t[n],e[n]),o},ee({},t)):t}function Es(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function hd(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Zo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,Ko([void 0],o,!1)))},{cache:Es(t.number),strategy:Jo.variadic}),getDateTimeFormat:Zo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,Ko([void 0],o,!1)))},{cache:Es(t.dateTime),strategy:Jo.variadic}),getPluralRules:Zo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,Ko([void 0],o,!1)))},{cache:Es(t.pluralRules),strategy:Jo.variadic})}}var Fi=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 u=p.reduce(function(d,m){return!d.length||m.type!==j.literal||typeof d[d.length-1]!="string"?d.push(m.value):d[d.length-1]+=m.value,d},[]);return u.length<=1?u[0]||"":u},this.formatToParts=function(c){return Gt(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=Ai(i,["formatters"]);this.ast=t.__parse(e,ee(ee({},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=fd(t.formats,n),this.formatters=s&&s.formatters||hd(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=Oi,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 vd(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var _d="dummy",ks=yd(null);function T(t){let e=Sd(ks);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=vd(o,n);return r?new Fi(r).format(s):(e!==_d&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}import{jsx as Ki,jsxs as xd}from"react/jsx-runtime";var Yo=()=>xd("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[Ki("title",{id:"angleLeftTitle",children:"AngleLeft"}),Ki("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 Ui,jsxs as bd}from"react/jsx-runtime";var zi=()=>bd("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[Ui("title",{id:"angleRightTitle",children:"AngleRight"}),Ui("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 $t,useRef as Ds,useState as Kd}from"react";import{useDispatch as Ud}from"react-redux";import{Interweave as zd}from"interweave";import ra from"classnames";var Rs={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 Ed}from"interweave";import kd from"classnames";import{useEffect as Cd,useRef as wd,useState as Td}from"react";function ji(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function en(t){let e=wd(null),[o,n]=Td(!1);return Cd(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=ji((p,u)=>{let d=e.current;if(!d)return;let m=p/r,f=u/r,g=d.getBoundingClientRect(),v=m>g.x&&m<g.x+g.width&&f>g.y&&f<g.y+g.height;v&&!s?(s=!0,n(!0)):!v&&s&&(s=!1,n(!1))},({clientX:p,clientY:u})=>[p,u]),[l,c]=ji(()=>{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 ye={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 qi}from"react/jsx-runtime";var Rd=({inputElement:t,children:e})=>{let o=S("TabCompletion",ye),[n,s]=en(t);return qi("mark",{ref:n,className:kd(o.matchPlaceholder,{[o.hover]:s}),children:e})},ft=class extends Ed{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 qi(Rd,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import{useEffect as Id,useRef as Pd,useState as Ad}from"react";function tn(t){return t.contentEditable==="true"}function Ld(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 Vi(t){let{selectionStart:e,selectionEnd:o}=tn(t)?Ld(t):t;return[e,o]}function on(t){let[,e]=Ad(),o=Pd(null);return o.current=Vi(t),Id(()=>{let n=()=>{let[s,r]=o.current??[],i=Vi(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 nn(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(pt);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 Md}from"react";function ht(t){Md(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function $e(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var Wi,ue=new Map,Od=["bottom","height","left","right","top","width"],Nd=(t={},e={})=>Od.some(o=>t[o]!==e[o]);function Gi(t){var o,n;let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...Gi(e)]:[]}function $i(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var Is=!1,Xi=()=>{Is=!0;let t=[];ue.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),ue.delete(o);return}let n=o.getBoundingClientRect();Nd(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce($i,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),ue.size!==0&&(Wi=window.requestAnimationFrame(Xi))};function Ps(t,e){let o=Gi(t),n=[],s=o.map((r,i)=>Ps(r,a=>{n[i]=a;let l=ue.get(t);if(!l)return;let c=n.reduce($i,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),ue.has(t)){let i=ue.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else ue.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!Is&&Xi()},unobserve(){s.forEach(i=>i.unobserve());let r=ue.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||ue.delete(t),ue.size||(cancelAnimationFrame(Wi),Is=!1)}}}}var Qi,de=new Map,Zi=()=>{de.forEach((t,e)=>{if(!e.isConnected){de.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)))}),de.size!==0&&(Qi=window.requestAnimationFrame(Zi))};function Ji(t,e){return{observe(){let o=de.size===0;de.has(t)?de.get(t).callbacks.push(e):de.set(t,{visible:void 0,callbacks:[e]}),o&&Zi()},unobserve(){let o=de.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||de.delete(t),de.size||cancelAnimationFrame(Qi)}}}}var As=["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 Ls(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function yt(t){return parseFloat(t)}function sn(t){return Math.round(t*1e6)}function Yi(t){return t/1e6}function Ms(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=yt(t.width),r=yt(t.borderLeftWidth),i=yt(t.borderRightWidth),a=yt(t.paddingRight),l=Yi(sn(s)-sn(r)-sn(i)),c=Yi(sn(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function St(t,e={}){var l;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",$e(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Ls(n,o,As),Ms(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=Ji(t,()=>{Ls(n,o,As),Ms(n,t,o),r(),setTimeout(r,0)}),a=Ps(t,c=>{if(c===null){e.onRemove&&e.onRemove(),o.remove();return}if(c.height===0&&c.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Ls(n,o,As),Ms(n,t,o),r(),o.style.top=`${c.top}px`,o.style.left=`${c.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let p=e.closestScrollElement.getBoundingClientRect(),u=window.getComputedStyle(e.closestScrollElement),d=yt(u.borderTopWidth),m=yt(u.borderBottomWidth),f=p.top+d-c.top,g=c.top+c.height+-(p.top+p.height-m);o.style.clipPath=`inset(${f}px 0px ${g}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(l=t.parentElement)==null||l.appendChild(o),a.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),a.unobserve(),i.unobserve()}]}var Os={};q(Os,{enUS:()=>Dd,nlNL:()=>Hd});var Dd={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"}]},Hd={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 ea,jsxs as Bd}from"react/jsx-runtime";var ta=()=>Bd("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[ea("title",{id:"circleCheckTitle",children:"Check"}),ea("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 oa}from"react/jsx-runtime";var na=()=>oa("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:oa("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"})});function Fd(t){let e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!n}function rn(t){return t?t instanceof ShadowRoot?rn(t.host):t===t.ownerDocument.body?t.ownerDocument:Fd(t)?t:rn(t.parentNode):document.body}var sa=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(sa||{}),Me=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();Ie(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(sa).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",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),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",n=>this.handlePaste(n)),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()});let o=rn(this.element);if(o){let n=()=>{this.currentCaret!==null&&(this.currentCaret=null,this.emit("caret",null))};o.addEventListener("scroll",n),this.disposeHandlers.push(()=>{o.removeEventListener("scroll",n)})}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 Me{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())}};import{jsx as Se,jsxs as Ns}from"react/jsx-runtime";var jd=({value:t,onUse:e,...o})=>{var p;let n=T(Os),s=Ud(),r=S("EditSuggestionTextInput",Rs),[i,a]=Kd(null),l=Ds(null),c=((p=t.match(pt))==null?void 0:p.length)||0;return $t(()=>{let u;return l.current&&(a(l.current),u=new Oe(l.current),u.on("change",({plainText:d})=>{s($.actions.userInput({text:d,selection:u.getSelection()}))}),u.on("keydown",d=>{s($.actions.registerKeyDown(Oo(d))),d.code==="Enter"&&d.shiftKey&&e(u.getText())}),u.on("paste",({pastedText:d,selectionText:m})=>{s($.actions.registerPaste({text:d,selectionText:m}))}),u.on("cut",({selectionText:d})=>{s($.actions.registerCut(d))})),()=>{s($.actions.reset()),u.dispose(),u.deactivate()}},[l]),$t(()=>{t&&l.current&&(l.current.value=t)},[t,l]),$t(()=>{l.current&&setTimeout(()=>{if(!l.current)return;let u=l.current.value.length;l.current.setSelectionRange(u,u),l.current.focus()},0)},[l]),Ns("div",{className:r.textInputWrapper,children:[Se("textarea",{...o,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:r.textInput,defaultValue:t,onChange:()=>{}}),i&&Se(qd,{inputElement:l.current,value:t}),Ns("div",{className:ra(r.alert,c===0?r.success:r.warning),children:[Se("div",{className:r.alertText,children:n("placeholders",{placeholderSize:c})}),c===0?Se(ta,{}):Se(na,{})]})]})},qd=({inputElement:t,value:e})=>{let o=S("EditSuggestionTextInput",Rs),n=Ds(null),s=on(t);return $t(()=>{nn(t,s)},[s,t]),Se(Vd,{inputElement:t,children:Ns("div",{ref:n,className:ra(o.root,o.agentText),children:[Se(zd,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new ft("placeholders")],inputElement:t,boundaryRef:n}),Se("br",{})]})})},Vd=({inputElement:t,children:e})=>{let o=Ds(null);return $t(()=>{if(!o.current)return()=>{};let[n,s]=St(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),Se("div",{ref:o,children:e})},ia=jd;import{useEffect as Mg,useState as Og,useRef as Ng}from"react";import{useState as $d}from"react";import Hs from"classnames";var X={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 Xe={};q(Xe,{enUS:()=>Wd,nlNL:()=>Gd});var Wd={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},Gd={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 Xt,jsxs as Qd}from"react/jsx-runtime";var Xd=({src:t,title:e})=>{let o=S("CommandPalette",X),[n,s]=$d("loading"),r=T(Xe);return Qd("div",{className:o.image,children:[Xt("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:Hs(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&Xt("span",{className:Hs(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&Xt("span",{className:Hs(o.imageSrc,o.imageSrcStatus),children:Xt(bo,{})}),e&&Xt("span",{className:o.imageTitle,children:e})]})},aa=Xd;import Zd from"react";import Jd from"classnames";import{jsx as la,jsxs as Yd}from"react/jsx-runtime";function Bs({children:t,heading:e,orientation:o}){let n=S("CommandPalette",X);return Zd.Children.count(t)===0?null:Yd("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&la("h4",{className:n.listHeading,children:e}),la("div",{className:Jd(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}import cn from"classnames";import Fs from"react";import{jsx as eg}from"react/jsx-runtime";var ca=Fs.createContext(void 0);function Ne(){let t=Fs.useContext(ca);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var pa=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=Fs.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return eg(ca.Provider,{value:i,children:t})};import tg,{useState as ua,useEffect as da,useMemo as og,useRef as ga,useCallback as ng,useContext as sg}from"react";import rg from"classnames";var Ks={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 an,jsxs as cg}from"react/jsx-runtime";var ig=0,ma=tg.createContext(null),ag=()=>{let t=sg(ma);if(!t)throw new Error("Invalid DropdownContext");return t},fa=({trigger:t,children:e,position:o="bottom"})=>{let n=og(()=>++ig,[]),s=ga(null),r=ga(null),i=S("Dropdown",Ks),[a,l]=ua(!1),[c,p]=ua(o),u=m=>{m.preventDefault(),m.stopPropagation(),l(!a)},d=ng(([m])=>{!m.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return da(()=>{let m=f=>{s.current&&!s.current.contains(f.target)&&l(!1)};return document.addEventListener("click",m),()=>{document.removeEventListener("click",m)}},[]),da(()=>{if(!r.current&&!a)return()=>{};let m=new IntersectionObserver(d,{root:null,rootMargin:"0px",threshold:1});return r.current&&m.observe(r.current),()=>{r.current&&m.unobserve(r.current)}},[r,a]),an(ma.Provider,{value:{setIsOpen:l},children:cg("div",{ref:s,className:i.root,children:[an("button",{id:`dropdown-${n}`,"data-testid":"dropdown-trigger","aria-haspopup":"true","aria-expanded":a,"aria-label":"Dropdown trigger",type:"button",className:i.trigger,onClick:u,children:t}),an("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:rg(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=S("Dropdown",Ks),{setIsOpen:i}=ag(),a=l=>{i(!1),o(l),l.stopPropagation()};return an(s,{type:"button",className:r.item,onClick:a,...n,children:e})}fa.Item=lg;var Us=fa;import{jsx as ha}from"react/jsx-runtime";var ya=t=>ha("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:ha("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={};q(Qe,{enUS:()=>pg,nlNL:()=>ug});var pg={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"}]},ug={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 zs}from"react/jsx-runtime";var dg="%0d%0a%0d%0a%0d%0a",gg=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(dg)}`},mg=({suggestion:t,onFeedback:e})=>{let o=T(Qe),n=b("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:zs(Us,{trigger:zs(ya,{"data-testid":"feedback-dropdown-trigger"}),children:zs(Us.Item,{as:"a",href:gg(n,t),onClick:e,children:o("giveFeedback")})})},ln=mg;import{jsx as De,jsxs as js}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:u,setSelected:d,onChangeOpen:m}=Ne(),f=S("CommandPalette",X);function g(v){n(v),t&&m(!1)}return js("div",{className:cn(f.listItem,u===i&&f.listItemSelected),children:[De("button",{onMouseEnter:()=>d(i),type:"button",className:cn("command-palette-list-item",f.listItemAction,f.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:g,...p,children:js("div",{className:f.listItemContent,children:[typeof o=="string"?De("p",{className:cn(f.listItemText,f.truncate,c==null?void 0:c.title),children:o}):o,a&&De("p",{className:cn(f.listItemDescription,c==null?void 0:c.description,e?f.lineClamp:f.truncate),children:a})]})}),s&&u===i&&De("div",{className:f.listItemActions,children:De(ln,{suggestion:String(o),onFeedback:s})}),l&&js("div",{className:f.sources,children:[De("span",{className:f.sourcesTitle,children:"Sources"}),l.map(v=>v.url?De("a",{className:f.source,href:v.url,target:"_blank",title:v.url,rel:"noopener noreferrer",onClick:()=>r&&r(v),children:v.name},v.url):De("span",{className:f.source,children:v.name},v.name))]})]})}import{jsx as Sa,jsxs as Vs}from"react/jsx-runtime";function Ws({children:t,title:e,id:o,onDismiss:n}){let s=T(Xe),r=S("CommandPalette",X),{page:i}=Ne();return i!==o?null:Vs("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&Vs("div",{className:r.pageNav,children:[Vs("button",{className:r.pageBackButton,type:"button",onClick:n,children:[Sa(Yo,{}),s("back")]}),e&&Sa("h3",{className:r.pageTitle,children:e})]}),t]})}import{Fragment as Tg,useCallback as Eg,useEffect as kg,useRef as Rg}from"react";var pn=()=>/Mac/i.test(navigator.platform);import{createAsyncThunk as vg,createSlice as _g}from"@reduxjs/toolkit";var fg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},E=fg;import{createAsyncThunk as $s,createSlice as yg}from"@reduxjs/toolkit";function hg(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,[hg(o)]:A(t[o])}),{}):t}function Gs(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function B(t){return Array.isArray(t)?t.map(B):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Gs(o)]:B(t[o])}),{}):t}var Sg={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Zt=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)||""}},Qt=$s("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))}),Xs=$s("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}),Qs=$s("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),va=t=>t.info.agentInfo,_a=yg({name:"info",initialState:Sg,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Qt.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Qt.rejected,e=>{e.fetchState="error"}).addCase(Qt.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(Xs.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(Qs.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(R,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:xa}=_a.actions,ba=_a.reducer;var un={list:[],fetchState:"idle",isOpen:!1,page:"search"},Ca=t=>t.search.isOpen,wa=t=>t.search.page,Ta=t=>t.search.list;function Ea(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Ze=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:Zt(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),ka=_g({name:"search",initialState:un,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=un.fetchState,t.list=un.list}},extraReducers:t=>{t.addCase(Ze.pending,e=>{e.fetchState="loading"}).addCase(Ze.rejected,(e,o)=>{e.fetchState="error",E.error(o.error)}).addCase(Ze.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(R,()=>un)}}),{resetSearch:dn,setIsOpen:te,setPage:V}=ka.actions,Ra=ka.reducer;var xg=/(https?:\/\/[^\s]+)/,gn=t=>t.split(" ").find(e=>xg.test(e));import Ia from"classnames";import{jsx as Cg,jsxs as wg}from"react/jsx-runtime";var bg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=S("CommandPalette",X);return wg("button",{type:"button",...n,onClick:t,className:Ia(s.actionButton,n.className),children:[o,e&&e.map(r=>Cg("span",{className:Ia(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},vt=bg;import{jsx as mn,jsxs as Zs}from"react/jsx-runtime";var Ig=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=S("CommandPalette",X),a=T(Xe),{selected:l,setSelected:c}=Ne(),p=r[l],u=p&&typeof p.text=="string"&&gn(p.text),d=Rg(null);function m(y){if(!d.current)return;let x=d.current.querySelectorAll(".command-palette-list-item"),C=0,F=0;y==="down"?(x.forEach((Y,H)=>{H===l&&(C=H)}),F=C===x.length-1?0:C+1):y==="up"?(x.forEach((Y,H)=>{H===l&&(C=H)}),F=C?C-1:x.length-1):c(0);let D=x[F];D&&typeof F=="number"&&(c(F),D.scrollIntoView&&D.scrollIntoView({behavior:"smooth",block:F?"center":"end"}))}function f(){if(!d.current)return;let y=d.current.querySelectorAll(".command-palette-list-item"),x=0;y.forEach((F,D)=>{D===l&&(x=D)});let C=y[x];C&&C.click()}let g=()=>{u&&window.open(u,"_blank")},v=()=>{p&&n(p,l)},w=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},h=Eg(y=>{if(y.key==="Enter"&&y.altKey&&u){g();return}if(y.key==="Enter"&&y.shiftKey){w();return}if(y.key==="ArrowDown"){y.preventDefault(),y.stopPropagation(),m("down");return}if(y.key==="ArrowUp"){y.preventDefault(),y.stopPropagation(),m("up");return}y.key==="Enter"&&l!==-1&&(y.preventDefault(),y.stopPropagation(),f())},[l]);return kg(()=>(window.addEventListener("keyup",h),()=>{window.removeEventListener("keyup",h)}),[h]),Zs("div",{className:i.actions,children:[mn("div",{className:i.actionsWrapper,ref:d,children:t}),Zs("div",{className:i.actionsBar,children:[u&&mn(vt,{onClick:g,shortKeys:[pn()?8997:"ALT",8629],children:a("visitUrl")}),p&&Zs(Tg,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&mn(vt,{onClick:w,shortKeys:[8679,8629],children:o}),mn(vt,{onClick:v,shortKeys:[8629],children:e})]})]})]})},Aa=Ig;import{forwardRef as Ag}from"react";import{jsx as La,jsxs as Pg}from"react/jsx-runtime";var _t=()=>Pg("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[La("path",{d:"M0 0h24v24H0z",fill:"none"}),La("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 xt,jsxs as Js}from"react/jsx-runtime";function Lg({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=S("CommandPalette",X);return Js("div",{className:l.search,children:[xt("div",{className:l.searchIcon,children:xt(_t,{})}),Js("div",{className:l.searchInputWrapper,children:[xt("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&&xt("div",{className:l.selectWrapper,children:Js("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&&xt("option",{children:n}),s.map(c=>xt("option",{value:c.value,children:c.label},c.value))]})})]})]})}var Ma=Ag(Lg);import{jsx as Oa,jsxs as Dg}from"react/jsx-runtime";function Je({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:u,search:d}){let[m,f]=Og(0),g=Ng(null),v=()=>{s&&s(o),i(void 0),r(""),a(!1)},w=()=>{var h;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(h=g.current)==null||h.focus();return}if(d.length>0){r("");return}a(!1)};return Mg(()=>{f(0)},[d,n]),Oa(mt,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:w,onClose:v,children:Dg(pa,{selected:m,setSelected:f,isOpen:u,onChangeOpen:a,page:n,children:[n===o&&Oa(Ma,{ref:g,onChange:r,onChangeType:i,placeholder:t,value:d,selectedType:l,types:c,typePlaceholder:e}),p]})})}Je.Page=Ws;Je.List=Bs;Je.Image=aa;Je.ListItem=qs;Je.ActionsBar=Aa;Je.Button=vt;var I=Je;import{jsx as ve,jsxs as Jt}from"react/jsx-runtime";var Fg=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=S("EditSuggestionForm",Pi),l=Hg(),c=T(vs),p=Bg(f=>f.overlayInput.text);Na(()=>{t&&(l($.actions.reset()),l($.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l($.actions.commitSuggestion()))},[t]);let u=f=>{f.preventDefault(),d(p)},d=f=>{l(Ho(f)),e(f)},m=f=>g=>{p!==i?window.confirm(c("warning"))&&f(g):f(g)};return Na(()=>{n&&n(p!==i)},[n,t,p]),Jt("div",{className:a.root,children:[Jt("div",{className:a.content,children:[t.title&&ve("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&ve(us,{labels:t.searchKeywords}),ve(ia,{onUse:d,value:p})]}),Jt("form",{className:a.actions,onSubmit:u,children:[Jt("div",{children:[ve("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&m(r),children:ve(Yo,{})}),ve("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&m(s),children:ve(zi,{})})]}),Jt("div",{className:a.primaryButtons,children:[ve(I.Button,{onClick:m(o),shortKeys:["esc"],children:c("dismiss")}),ve(I.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},fn=Fg;import{createAction as zg,createAsyncThunk as Fa,createSlice as jg}from"@reduxjs/toolkit";var Kg=["{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}"],Ug=new RegExp(Kg.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Da(t,e){let o=t.split(Ug),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 u=a.charAt(0),d=0;do c=u?e.indexOf(u,c+1):-1,d+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&d>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 Ha(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Ka={suggestions:[],fetchState:"idle",isInitialRequest:null},Ba={default:Ka},Ua=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)||[]},za=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},ja=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")},bt=t=>t.textSuggestions,qa=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},hn=zg("textSuggestions/refresh"),_e=Fa("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=gt(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Zt(n),t);if(t==="default"){let p=i?l.filter(qa(a)):l;e.dispatch(pe(p.slice(0,r)))}return l}),Yt=Fa("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,{...Zt(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(qa(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?Da(p.text,t):p.text}))),l=Ha(l,r),e.dispatch(pe(l)),l}),Va=jg({name:"textSuggestions",initialState:Ba,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(_e.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||Ka;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(_e.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(_e.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Yt.pending,e=>{e.default.fetchState="loading"}).addCase(Yt.rejected,e=>{e.default.fetchState="error"}).addCase(Yt.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(R,()=>Ba)}}),{setTextSuggestions:Wa,setSuggestionState:Ga}=Va.actions,$a=Va.reducer;import{createSlice as qg}from"@reduxjs/toolkit";var Xa={contentType:null,suggestion:null},Qa=t=>t.activeSuggestion.suggestion,Za=t=>t.activeSuggestion.contentType,Ja=qg({name:"activeSuggestion",initialState:Xa,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(R,()=>Xa)}}),{setActiveSuggestion:xe,resetActiveSuggestion:Ys}=Ja.actions,Ya=Ja.reducer;var er={};q(er,{enUS:()=>Vg,nlNL:()=>Wg});var Vg={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"}]},Wg={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 Gg}from"@reduxjs/toolkit";var $g={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var yn=({ui:t})=>t.overlayCollapsed;var el=Gg({name:"ui",initialState:$g,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:eo,setInputHasFocus:Ct,setOverlayCollapsed:He,setOpenOverlayWhenTyping:tl,setOverlayCollapsedUserOverwrite:ol}=el.actions,nl=el.reducer;import sl,{useContext as Xg}from"react";import{jsx as Qg}from"react/jsx-runtime";var rl=sl.createContext(null),wt=({broadcastEvents:t,children:e})=>{let o=sl.useMemo(()=>t,[]);return Qg(rl.Provider,{value:o,children:e})},ne=()=>{let t=Xg(rl);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import{createAsyncThunk as tr,createSlice as Zg}from"@reduxjs/toolkit";var Jg={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ae=t=>t.auth.isLoggedIn,il=t=>t.auth.loginFetchState,al=t=>t.auth.verifyFetchState,ll=t=>t.auth.showLoginOverlay,Be=tr("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),cl=tr("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),to=tr("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),pl=Zg({name:"auth",initialState:Jg,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(Be.pending,e=>{e.loginFetchState="loading"}),t.addCase(Be.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(Be.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(to.pending,e=>{e.verifyFetchState="loading"}),t.addCase(to.rejected,e=>{e.verifyFetchState="error"}),t.addCase(to.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Tt,setShowLoginOverlay:ul}=pl.actions,dl=pl.reducer;var or="SetActiveSuggestion",Et="ShowLoginOverlay",nr="UserLoggedIn",Yg="UserLoggedOut",be="ApplySuggestion",sr="ApplyImageSuggestion",em="ShowCommandPalette",tm=t=>({[or]:e=>{t.dispatch(Ga(e.state)),t.dispatch(xe({contentType:e.contentType,suggestion:e.suggestion}))},[em]:e=>{t.dispatch(te(e.isOpen)),e.page&&t.dispatch(V(e.page))},[Et]:e=>{t.dispatch(ul(e))},[nr]:()=>{t.dispatch(Be())},[Yg]:()=>{t.dispatch(Be())},[sr]:e=>{t.dispatch(Fo({suggestion:e.suggestion}))},[be]:e=>{t.dispatch(re({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(Le())}}),gl=tm;import{jsx as ml}from"react/jsx-runtime";var sm=()=>{var f;let[t,e]=om(!1),o=rr(Qa),n=rr(Za),s=rr(bt),r=nm(),i=ne(),a=T(er),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(Ys()),r(Ct(!0)),r($.actions.reset())},p=(g,v)=>{r(Ys()),r(Ct(!0)),i.send(be,{text:g,suggestion:{...v,source:`${v.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let u=(f=s[n])==null?void 0:f.suggestions.indexOf(o),d=u===0||u===null?void 0:()=>r(xe({contentType:n,suggestion:s[n].suggestions[u-1]})),m=u===s[n].suggestions.length-1||u===null?void 0:()=>r(xe({contentType:n,suggestion:s[n].suggestions[u+1]}));return ml(mt,{autoFocus:!0,isOpen:u!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:ml(fn,{onTouched:e,onDismiss:c,onUse:g=>p(g,o),suggestion:o,onNext:m,onPrevious:d})})},fl=sm;import{useSelector as _l}from"react-redux";import ar from"classnames";import{useCallback as Sl,useEffect as pm,useMemo as um,useState as lr}from"react";import{useDispatch as dm,useSelector as gm}from"react-redux";import rm from"classnames";var hl={root:"_root_1ukx5_1"};import{jsx as am}from"react/jsx-runtime";var im=({className:t,value:e,...o})=>{let n=S("TextInput",hl);return am("input",{className:rm(t,n.root),type:"text",value:e,...o})},oo=im;var ir={};q(ir,{enUS:()=>lm,nlNL:()=>cm});var lm={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"}]},cm={back:[{type:0,value:"Terug"}],promptTitle:[{type:0,value:"Login bij "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Plak de code uit je email"}],verifyCodeBody:[{type:0,value:"Kopieer de code uit de email en plak deze hier."}],verifyCodeInputPlaceholder:[{type:0,value:"Plak hier de code"}],verifyCodeSubmitLabel:[{type:0,value:"Inloggen"}],verifyCodeError:[{type:0,value:"Inloggen is niet gelukt. De code is waarschijnlijk niet meer geldig. "},{type:8,value:"login",children:[{type:0,value:"Vraag een nieuwe code aan"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Verstuur een login code naar je email"}],requestCodeBody:[{type:0,value:"Voer je e-mailadres in en krijg een login code. Als je een bestaande "},{type:1,value:"productName"},{type:0,value:" gebruiker bent krijg je een email met een code. Als je een nieuwe gebruiker bent wordt er een email verstuurd met een toegangsverzoek voor "},{type:1,value:"productName"},{type:0,value:"."}],requestCodeInputPlaceholder:[{type:0,value:"Typ hier je e-mailadres"}],requestCodeSubmitLabel:[{type:0,value:"Code aanvragen"}]};var yl={root:"_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 Q,jsxs as Sn}from"react/jsx-runtime";var mm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},fm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=T(ir),i=S("LoginTokenDialog",yl),a=gm(al),l=dm(),c=b("productName"),[p,u]=lr(t||""),[d,m]=lr(0),[f,g]=lr(""),v=Sl(async x=>{x.preventDefault(),l(cl({email:p})),m(1)},[o,p]),w=()=>{g(""),m(0)},h=Sl(async x=>{x.preventDefault();let C=mm(x.target.elements.token.value);if(!C){g(r("verifyCodeError",{login:y}));return}l(to({token:C}))},[o]),y=um(()=>x=>Q("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:x},"back-button"),[]);return pm(()=>{a==="error"&&g(r("verifyCodeError",{login:y})),a==="done"&&n()},[a]),Q(mt,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:Sn("div",{className:i.root,children:[Q("h1",{className:i.title,children:r("promptTitle",{productName:c})}),d===0&&Sn("form",{onSubmit:v,children:[Q("h2",{className:i.subtitle,children:r("requestCodeTitle")}),Q("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),Q(oo,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:x=>u(x.target.value)}),Q("div",{className:i.actions,children:Q("button",{type:"submit",className:ar(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),d===1&&Sn("form",{onSubmit:h,children:[Q("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),Q("p",{className:i.text,children:r("verifyCodeBody")}),Q(oo,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&Q("div",{className:i.errorMessage,children:f}),Sn("div",{className:i.actions,children:[Q("button",{type:"button",className:ar(i.button),onClick:w,children:r("back")}),Q("button",{type:"submit",className:ar(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},vl=fm;import{jsx as ym}from"react/jsx-runtime";var hm=()=>{let t=_l(ll),e=_l(va),o=b("adminUrl"),n=ne(),s=()=>n.send(Et,!1),r=()=>{n.send(Et,!1),n.send(nr)};return ym(vl,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},xl=hm;import cf from"lodash.debounce";import{useCallback as Cn,useEffect as hr,useState as io}from"react";import{useDispatch as pf,useSelector as At}from"react-redux";import{createAsyncThunk as Sm,createSlice as vm}from"@reduxjs/toolkit";var _m={data:null,fetchState:"idle"},bl=t=>t.contentTypes.data,no=Sm("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),xm=vm({name:"contentTypes",initialState:_m,reducers:{},extraReducers:t=>{t.addCase(no.pending,e=>{e.fetchState="loading"}).addCase(no.rejected,e=>{e.fetchState="error"}).addCase(no.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Cl=xm.reducer;function so(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 bm}from"react";function wl(t,e){bm(()=>{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 Rl,useRef as Im}from"react";import{useSelector as Pm,useDispatch as Am}from"react-redux";import{createAsyncThunk as Cm,createSlice as wm}from"@reduxjs/toolkit";var Tl={data:null,fetchState:"idle"},vn=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},le=Cm("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)}),Tm=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Em=wm({name:"entities",initialState:Tl,reducers:{},extraReducers:t=>{t.addCase(le.pending,e=>{e.fetchState="loading"}).addCase(le.rejected,e=>{e.fetchState="error"}).addCase(le.fulfilled,(e,o)=>{e.fetchState="done",e.data=Tm(e.data?[...e.data,...o.payload]:o.payload)}).addCase(R,()=>Tl)}}),El=Em.reducer;var cr={};q(cr,{enUS:()=>km,nlNL:()=>Rm});var km={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Rm={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 _n,jsxs as Mm}from"react/jsx-runtime";var Lm=({onCopy:t,onUse:e})=>{let o=Im(null),n=S("EntitiesList",kl),s=T(cr),r=Pm(vn),i=Am();return Rl(()=>{i(le())},[]),Rl(()=>{o.current&&o.current.focus()},[o]),Mm("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&_n(I.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:_n(I.List,{children:r.map((a,l)=>_n(I.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&_n("p",{className:n.empty,children:s("noResults")})]})},Il=Lm;import{Fragment as Fm,useEffect as xn,useRef as Km,useState as Um}from"react";import{useSelector as Nl,useDispatch as zm}from"react-redux";import{createAsyncThunk as Om,createSlice as Nm}from"@reduxjs/toolkit";var Pl={data:null,fetchState:"idle"},Al=t=>t.summary.data,Ll=t=>t.summary.fetchState==="error",Ce=Om("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();return i.length===0?Promise.reject(new Error("No messages are included")):{summary:await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel})}}),Dm=Nm({name:"summary",initialState:Pl,reducers:{},extraReducers:t=>{t.addCase(Ce.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(Ce.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(Ce.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(R,()=>Pl)}}),Ml=Dm.reducer;var pr={};q(pr,{enUS:()=>Hm,nlNL:()=>Bm});var Hm={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."}]},Bm={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 Ol={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 kt,jsxs as qm}from"react/jsx-runtime";var jm=({onCopy:t})=>{let e=Km(null),o=S("SummaryForm",Ol),[n,s]=Um(""),r=T(pr),i=Nl(Al),a=Nl(Ll),l=zm(),c=()=>{l(z({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let u=document.getSelection();u&&l(z({name:"summary copied to clipboard",data:{originalText:i,finalText:u==null?void 0:u.toString()},options:{includeConversationData:!0}}))};return xn(()=>{l(Ce())},[]),xn(()=>{s(i||"")},[i]),xn(()=>{e.current&&i&&e.current.focus()},[e,i]),xn(()=>{let u=d=>{d.key==="Enter"&&d.shiftKey&&c()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[n]),kt("div",{className:o.root,tabIndex:-1,children:a?kt("p",{className:o.error,children:r("error")}):qm(Fm,{children:[kt("div",{className:o.main,children:kt("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:u=>s(u.target.value)})}),kt("div",{className:o.actions,children:kt(I.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},Dl=jm;var ur={};q(ur,{enUS:()=>Vm,nlNL:()=>Wm});var Vm={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?"}]},Wm={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 ef,{useEffect as mr,useRef as tf}from"react";import{useDispatch as of,useSelector as jl}from"react-redux";var dr={};q(dr,{enUS:()=>Gm,nlNL:()=>$m});var Gm={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"}]},$m={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 Hl={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 Xm,createAsyncThunk as Qm,createSlice as Zm}from"@reduxjs/toolkit";var gr={data:[],fetchState:"idle"},Bl=t=>{var e;return(e=t.answer)==null?void 0:e.data},Fl=t=>t.answer.fetchState,It=Xm("answer/resetKnowledgeSearch"),Rt=Qm("answer/getAnswer",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=(i=e.getState().conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile is not defined");let r=await o.knowledgeAssist({promptInstruction:t.promptInstruction,question:t.question},n,s);return{question:t.question,answer:r}}),Jm=Zm({name:"answer",initialState:gr,reducers:{},extraReducers:t=>{t.addCase(Rt.pending,e=>{e.fetchState="loading"}).addCase(Rt.rejected,e=>{e.fetchState="error"}).addCase(Rt.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(R,()=>gr).addCase(It,()=>gr)}}),Kl=Jm.reducer;import{jsx as Ul,jsxs as Ym}from"react/jsx-runtime";var zl=()=>Ym("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[Ul("title",{id:"paperPlaneTitle",children:"PaperPlane"}),Ul("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 we,jsxs as fr}from"react/jsx-runtime";var nf=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=ef.useState(""),{setSelected:i}=Ne(),a=tf(null),l=S("EntitiesList",Hl),c=T(dr),p=of(),u=jl(Bl),d=jl(Fl),m=async g=>{g.preventDefault(),g.stopPropagation(),s!==""&&p(Rt({question:s,promptInstruction:n}))},f=(g,v)=>{p(z({name:"knowledge assist source viewed",data:{question:v,sourceViewed:g.url||g.name},options:{includeConversationData:!0}}))};return mr(()=>{var g;o&&d==="idle"?p(Rt({question:o,promptInstruction:n})):(g=a.current)==null||g.focus()},[a,d]),mr(()=>{d==="done"&&(p(z({name:"knowledge assist question answered",data:{question:s||o,sources:u[u.length-1].answer.sources,answer:u[u.length-1].answer.answer,isFollowUpQuestion:u.length>1},options:{includeConversationData:!0}})),i(u.length-1),r(""))},[d,u]),mr(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,u]),fr("div",{className:l.root,children:[u.length>0&&we("div",{className:l.alignRight,children:we(I.Button,{onClick:e,children:c("reset")})}),fr(I.ActionsBar,{list:u.map(({answer:g})=>({text:g.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:g=>t(g.text),children:[u.map(({question:g,answer:v},w)=>we(I.List,{children:we(I.ListItem,{"data-testid":"knowledge-search-answer",index:w,description:v.answer,closeOnSelect:!0,onClick:()=>t(v.answer),onSourceClick:h=>f(h,g),sources:v.sources,styles:{title:l.question,description:l.answer},children:g})},`${v.answer}_${w}`)),d==="loading"&&we("p",{className:l.status,children:c("loading")}),d==="error"&&we("p",{className:l.status,children:c("error")}),fr("form",{className:l.form,onSubmit:m,children:[we("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:g=>{i(-1),r(g.target.value)}}),we("button",{type:"submit",className:l.submit,children:we(zl,{})})]})]})]})},ql=nf;import{createAsyncThunk as sf,createSlice as rf}from"@reduxjs/toolkit";var af={data:null,fetchState:"idle"},Pt=t=>t.profile.data,bn=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],ro=sf("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)}),lf=rf({name:"profile",initialState:af,reducers:{},extraReducers:t=>{t.addCase(ro.pending,e=>{e.fetchState="loading"}).addCase(ro.rejected,e=>{e.fetchState="error"}).addCase(ro.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Vl=lf.reducer;import{jsx as Z,jsxs as Gl}from"react/jsx-runtime";var uf=200,df=5,gf=4,mf=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Wl=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),ff=()=>{let t=pf(),e=ne(),o=T(ur),[n,s]=io(!1),[r,i]=io(""),a=At(wa),l=At(Pt),[c,p]=io(null),[u,d]=io([]),[m,f]=io(),g=At(ae),v=b("showSearch"),w=b("showEntitiesCommand"),h=b("showSummaryCommand"),y=b("showKnowledgeSearch"),x=b("showImageSearch"),C=b("searchTriggerKey"),F=At(bl),D=At(Ta),Y=At(Ca),H=_=>os(D.filter(P=>P.type===_.toUpperCase()),_),k=[{value:"PERSONAL",label:o("personalSuggestions"),list:H("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:H("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:H("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:H("IMAGE"),listOrientation:"horizontal",shouldShow:x}].filter(_=>_.shouldShow),O=[{label:o("entitiesClipboard"),onClick:()=>t(V("entities")),shouldShow:w&&Wl(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(V("summary")),shouldShow:h&&Wl(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(V("knowledgeAssist")),shouldShow:y}].filter(_=>_.shouldShow),G=(F==null?void 0:F.map(_=>({value:_.code.toUpperCase(),label:`${_.name}s`,list:H(_.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],es=Cn(cf((_,P)=>{t(Ze({query:_,type:P,tags:["search-overlay"]}))},uf),[]),ze=mf([...G,...k]),$p=Cn((_,P)=>{if(!P)return;let Re=[...k,...G].find(({value:rt})=>rt===P);Re&&(t(V("edit")),p({..._,searchTerm:void 0}),d(Re.list))},[t,c,G]),ts=Cn((_,P)=>{switch(P.type){case"IMAGE":e.send(sr,{suggestion:P});break;default:e.send(be,{text:_,suggestion:P})}t(te(!1))},[t]),Xp=_=>{so(_.text),t(z({name:"entity copied",data:{entity:_,type:"copy"}})),t(te(!1))},Qp=Cn(_=>{t(z({name:"suggestion feedback",data:{text:_.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),Zp=_=>{e.send(be,{text:_,suggestion:{source:"knowledge-assist",text:_}}),t(z({name:"answer used",data:{originalText:_},options:{includeConversationData:!0}})),i(""),t(V("search")),t(It()),t(te(!1))},Jp=_=>{so(_),t(te(!1))},Yp=_=>{e.send(be,{text:_.text,suggestion:{source:"entity",text:_.text}}),t(te(!1))},eu=c===null||u.indexOf(c)-1<0?void 0:()=>p(u[u.indexOf(c)-1]),tu=c===null||u.indexOf(c)===u.length-1?void 0:()=>p(u[u.indexOf(c)+1]);function os(_,P){return _.slice(0,m?10:P.toLowerCase()==="image"?gf:df)}function Zr(_,P,Re){return P.reduce((rt,_o)=>Re&&m===Re?_o.length+rt:os(_o,Re).length+rt,_)}function st(_){return P=>{n?window.confirm(o("warning"))&&(_(P),s(!1)):_(P)}}return hr(()=>{r?es(r,m):t(dn())},[r,m]),hr(()=>{a==="search"&&t(It())},[a]),hr(()=>{g&&t(no())},[g]),wl(C,()=>t(te(!0))),!v||!l?null:Gl(I,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:st(_=>t(te(_))),onChangeType:_=>f(_),onChangePage:st(_=>t(V(_))),selectedType:m,search:r,page:a,isOpen:Y,types:[...G,...k],children:[Z(I.Page,{id:"search",children:Gl(I.ActionsBar,{list:[...O.map(_=>({text:_.label,type:"command"})),...ze.map(_=>({text:_.text||_.url||_.message,type:_.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:_},P)=>ts(_,ze[P]),onSecondary:(_,P)=>{$p(ze[P-O.length],ze[P-O.length].type)},children:[O.length>0&&Z(I.List,{heading:o("commands"),children:O.map((_,P)=>Z(I.ListItem,{index:Zr(P,[],"commands"),closeOnSelect:!1,onClick:_.onClick,children:_.label},_.label))}),[...G,...k].map(({value:_,label:P,list:Re,lineClamp:rt,listOrientation:_o},ou)=>Z(I.List,{heading:P,orientation:_o==="horizontal"?"horizontal":"vertical",children:os(Re,_).map((oe,nu)=>Z(I.ListItem,{index:Zr(O.length+nu,[...G,...k].slice(0,ou).map(({list:su})=>su),_),closeOnSelect:!1,lineClamp:rt,onClick:()=>ts(oe.text,oe),description:_!=="IMAGE"?oe.title&&oe.text:void 0,onFeedback:_!=="IMAGE"?()=>Qp(oe):void 0,children:_==="IMAGE"?Z(I.Image,{title:oe.title||oe.text,src:oe.image}):oe.title||oe.text},`${oe.id}-${oe.text}`))},_))]})}),Z(I.Page,{id:"edit",onDismiss:st(()=>{t(V("search")),p(null)}),children:c&&Z(fn,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(V("search")),p(null),d([])},onNext:tu,onPrevious:eu,onUse:_=>{t(V("search")),ts(_,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(te(!1)),d([]),p(null)}})}),Z(I.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:st(()=>{t(V("search"))}),children:Z(Il,{onUse:Yp,onCopy:Xp})}),Z(I.Page,{id:"summary",title:o("summaryTitle"),onDismiss:st(()=>{t(V("search"))}),children:Z(Dl,{onCopy:Jp})}),Z(I.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:st(()=>{t(It()),t(V("search"))}),children:Z(ql,{promptInstruction:l.knowledgeAssistPromptInstruction,question:r,onUse:Zp,onResetQuestion:()=>{t(It()),i("")}})})]})},$l=ff;import{jsx as yr,jsxs as Sf}from"react/jsx-runtime";var yf=()=>{let t=b("showSearch"),e=b("isEmbedded");return Sf(hf,{children:[t&&yr($l,{}),yr(fl,{}),e&&yr(xl,{})]})},Xl=yf;import{connect as Uf,useDispatch as zf,useSelector as En}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 Bf,useMemo as Ff}from"react";import{Interweave as kf}from"interweave";import{useEffect as Rf,useMemo as If,useRef as Pf}from"react";import{useDispatch as Af,useSelector as Lf}from"react-redux";import{useEffect as vf}from"react";function Ql(t,e,o){vf(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var _f=/[.*+?^${}()|[\]\\]/g,xf=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function bf(t){return t.replace(_f,"\\$&")}function Cf(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function wf(t){return t.search(xf)}function Zl(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${bf(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function Jl(t){return t.replace(pt,'<mark data-type="placeholder">$1</mark>')}function ao(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Tf(t,e){return t.split("").map((i,a)=>({char:i,index:a})).filter(({char:i,index:a})=>/\s/.test(i)&&a<=e).map(({index:i})=>i).reverse()[0]}function Sr(t,e,o={}){if(e){let n=Cf(e.toLowerCase(),t.toLowerCase()),s=ao(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=wf(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(ri).length>3||e.length>30?Tf(e.trim(),n):0;return`${`${i>0?"\u2026":""}${ao(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var Yl={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};import{jsx as wn,jsxs as Hf}from"react/jsx-runtime";var Mf=["search","personal-collection-search","search-autocomplete"];function Of(t,e,o,n={}){let s="";return Mf.includes(e)?s=Zl(Sr(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=Sr(t,o,n),n.placeholders===!0&&(s=Jl(s)),s}var Nf=()=>{},Df=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=b("inlineSuggestions"),r=Lf(gt),i=Af(),a=S("TextSuggestion",Yl),l=Pf(null);Rf(()=>{let p=setTimeout(()=>{i(vi({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),Ql(l,"click",()=>{i(Ae(t)),i(re({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=If(()=>Of(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:Hf("div",{className:a.root,onMouseEnter:()=>i(Ae(t)),children:[wn(M,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:Nf,children:wn(kf,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&wn("div",{className:a.actions,children:wn(ln,{onFeedback:()=>n(o),suggestion:o.text})})]})},ec=Df;import{jsx as tc}from"react/jsx-runtime";var Kf=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=Ff(()=>{let r=e.map((i,a)=>tc(ec,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return tc(Bf,{children:s})},Tn=Kf;var oc={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};import{jsx as kn}from"react/jsx-runtime";var jf=({textSuggestions:t,selectedIndex:e})=>{let o=S("InlineSuggestionsOverlay",oc),n=En(Lt),s=zf(),r=En(ae),i=En(dt),a=En(yn),l=b("showTextSuggestions");return ht(()=>{s(He({collapse:!0,skipWhenInputFocus:!0}))}),a||!n||!l||t.length===0||r!==!0||i===!1?null:kn("div",{className:o.root,"data-variant":"inline",children:kn("div",{className:o.paper,children:kn(se,{children:kn(Tn,{suggestions:t,selectedIndex:e})})})})},qf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),nc=Uf(qf)(jf);import Cr from"classnames";import{useEffect as oh,useRef as nh,useState as sh}from"react";import{connect as rh,useDispatch as ih,useSelector as lo}from"react-redux";import{useState as Vf}from"react";function sc(t,e){let[o,n]=Vf(()=>{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 $f from"classnames";import{Fragment as Xf,useCallback as _r,useMemo as ic}from"react";var vr={};q(vr,{enUS:()=>Wf,nlNL:()=>Gf});var Wf={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"}]}]},Gf={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 rc={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};import{jsx as Rn,jsxs as ac}from"react/jsx-runtime";var xr=(t,e,o)=>n=>Rn("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),Qf=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n})=>{let s=T(vr),r=ne(),i=S("Login",rc),a=b("productName"),l=_r(g=>{g.preventDefault(),n&&n(parseInt(g.target.value,10))},[]),c=_r(g=>{g.preventDefault(),r.send(Et,!0)},[e]),p=ic(()=>g=>Rn("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[e]),u=_r(g=>Rn("button",{type:"button",className:i.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:d,hour:m,day:f}=ic(()=>({min:xr(i,60*10,l),hour:xr(i,60*60,l),day:xr(i,60*60*12,l)}),[]);return ac("div",{className:$f(t,i.root),children:[s("loginPlease",{login:o?u:p,productName:a}),n&&ac(Xf,{children:[Rn("br",{}),s("snooze",{min:d,hour:m,day:f})]})]})},In=Qf;import{useDispatch as Zf}from"react-redux";var lc={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};import{jsx as cc,jsxs as Yf}from"react/jsx-runtime";var Jf=({title:t})=>{let e=S("SearchTrigger",lc),o=Zf();return Yf("button",{type:"button",className:e.root,onClick:()=>o(te(!0)),children:[cc(_t,{}),cc("span",{className:e.text,children:t})]})},pc=Jf;var br={};q(br,{enUS:()=>eh,nlNL:()=>th});var eh={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"}]},th={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 uc={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 U,jsxs as co}from"react/jsx-runtime";var ah=({textSuggestions:t,selectedIndex:e})=>{let o=S("SuggestionsOverlay",uc),n=T(br),s=lo(Lt),r=mi(),i=ih(),a=nh(null),l=b("searchTriggerKey"),c=b("productName"),p=lo(yn),u=lo(ae),d=lo(dt),[m,f]=sh(null),g=b("showSearch"),v=b("showTextSuggestions"),w=b("adminUrl"),h=b("isEmbedded"),[y,x]=sc("dd-snooze-until-ms",0),C=p||y>Date.now(),F=lo(O=>O.input.text),D=t.filter(O=>O.source!=="gpt").length,Y=()=>{C&&x(0),i(ol(!C))},H=O=>{i(z({name:"suggestion feedback",data:{text:O.text,source:"overlay",context:F},options:{includeConversationData:!0}}))},k=O=>{let G=Date.now()+O*1e3;x(G),E.info(`Snooze until: ${new Date(G)}`),i(He({collapse:!0}))};return oh(()=>{D===0&&f(null)},[t,D]),ht(()=>{i(He({collapse:!0,skipWhenInputFocus:!0}))}),u===null||d===!1?null:u===!1?co("div",{ref:a,className:Cr(o.root,{[o.isCollapsed]:C}),children:[!C&&co("div",{className:o.triggers,children:[U("div",{style:{flex:1}}),U("div",{className:o.triggersRight,children:U(ct,{className:o.toggleButton,title:n("collapse"),onClick:Y,isCollapsed:!1})})]}),U("div",{className:o.toggleButtonWrapper,children:U(ct,{className:o.toggleButton,title:n("open",{productName:c}),onClick:Y,isCollapsed:!0})}),U("div",{className:o.collapsible,children:U(In,{loginUrl:w,isEmbedded:h,onSnooze:k})})]}):!r||!s?null:co("div",{ref:a,className:Cr(o.root,{[o.isCollapsed]:C}),children:[!C&&co("div",{className:o.triggers,children:[U("div",{style:{flex:1},children:g&&U("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(n(pn()?"searchHintMac":"searchHintWindows",{searchTriggerKey:l.toUpperCase()})),onMouseLeave:()=>f(null),children:U(pc,{title:n("search")})})}),co("div",{className:o.triggersRight,onFocus:()=>{},children:[U("div",{className:Cr(!m&&o.hintsHidden,o.hints),children:m}),U(ct,{className:o.toggleButton,title:n("collapse"),onClick:Y,isCollapsed:!1})]})]}),U("div",{className:o.toggleButtonWrapper,children:U(ct,{className:o.toggleButton,title:n("open",{productName:c}),onClick:Y,isCollapsed:!0})}),D>0&&v&&U("div",{className:o.collapsible,onFocus:()=>{},children:U(se,{children:U(Tn,{onFeedback:H,suggestions:t,selectedIndex:e,reverse:!0})})})]})},lh=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),dc=rh(lh)(ah);import{Provider as ch}from"react-redux";import{jsx as Pn}from"react/jsx-runtime";var ph=({children:t})=>{let o=b("locale").replace("-","");return Pn(ks.Provider,{value:o,children:t})},uh=({store:t,customStyles:e={},children:o})=>Pn(ch,{store:t,children:Pn(ph,{children:Pn(Kt.Provider,{value:e,children:o})})}),Mt=uh;import Or from"classnames";import{Interweave as Jh}from"interweave";import{useCallback as Yh,useEffect as ey,useMemo as Lc,useRef as ty}from"react";import{connect as oy}from"react-redux";import{cloneElement as dh}from"react";var gh=["div","span","mark","strong","b","i","u","em"];function wr(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(gh.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),dh(n,{children:wr(i,e,o+1)})]}return[...t,...e]}function Fe(t){return t.tagName.toLowerCase()==="textarea"}var gc={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 Ph from"classnames";import{Matcher as Ah}from"interweave";import{useEffect as Lh,useMemo as Mh}from"react";function mc(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function An(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function fc(t){return t!=null}import _c from"classnames";import{createRef as Ch,useCallback as Er,useMemo as wh,useRef as Th,useState as Eh}from"react";import{useState as mh,useLayoutEffect as fh}from"react";var hh=["bottom","height","left","right","top","width"],yh=(t={},e={})=>hh.some(o=>t[o]!==e[o]),Te=new Map,hc,yc=()=>{let t=[],e=[];Te.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();yh(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Te.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),hc=window.requestAnimationFrame(yc)};function Sh(t,e){return{observe(){let o=Te.size===0;if(Te.has(t)){let n=Te.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Te.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&yc()},unobserve(){let o=Te.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Te.delete(t),Te.size||cancelAnimationFrame(hc)}}}}function Tr(t){let[e,o]=mh(null);return fh(()=>{if(!t.current)return;let n=Sh(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}import{useContext as vh,useLayoutEffect as _h,useState as xh}from"react";import{createPortal as bh}from"react-dom";var Sc={root:"_root_1jq08_1"};var vc=({children:t})=>{let[e,o]=xh(null),n=vh(Kt);return _h(()=>{let s=document.createElement("div");return $e(s),s.classList.add(Sc.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?bh(t,e):null};var ge={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 kr}from"react/jsx-runtime";var Ln=(t=!1)=>{let[e,o]=Eh(t),n=Er(()=>o(!0),[]),s=Er(()=>o(!1),[]),r=Er(()=>o(a=>!a),[]),i=Th(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function Rr(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 Mn=({className:t,triggerRef:e,boundaryRef:o=Ch(),position:n="above",align:s="center",children:r,toStyle:i=Rr,...a})=>{let l=Tr(e),c=Tr(o),p=wh(()=>i(l,c,0),[l,c]);return kr(vc,{children:kr("div",{className:_c(ge.ref,{[ge.positionAbove]:n==="above",[ge.positionBelow]:n==="below",[ge.positionLeft]:n==="left",[ge.positionRight]:n==="right",[ge.alignStart]:s==="start",[ge.alignCenter]:s==="center",[ge.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:kr("div",{className:_c(t,ge.root),children:r})})})};import kh from"classnames";import{forwardRef as Rh,useRef as Ih}from"react";import{jsx as xc}from"react/jsx-runtime";var On=Rh(({className:t,children:e,...o},n)=>{let s=Ih(null),r=S("TabCompletion",ye);return xc("div",{ref:An([s,n]),className:kh(t,r.popoverContentContainer),...o,children:xc("div",{className:r.popoverContent,children:e})})});import{jsx as po,jsxs as Dh}from"react/jsx-runtime";var Oh=t=>e=>{let o=Rr(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Nh=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=S("TabCompletion",ye),i=Ln(),a=Mh(()=>Oh(t.getBoundingClientRect()),[t]),[l,c]=en(t);return Lh(()=>{c?i.open():i.close()},[c]),Dh("span",{children:[po("mark",{ref:An([l,i.triggerRef]),className:Ph(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&po(Mn,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:po(On,{style:o,children:po("div",{className:r.hintText,children:s})})})]})},Nn=class extends Ah{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${mc(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(fc);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 po(Nh,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import Mr from"classnames";import{Matcher as Vh}from"interweave";import{createRef as Wh,forwardRef as Gh,useCallback as $h,useEffect as Ic,useRef as Pc,useState as Ac}from"react";import{useDispatch as Xh}from"react-redux";import{jsx as bc}from"react/jsx-runtime";var Cc=()=>bc("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:bc("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 Hh,useEffect as Tc,useState as Ec}from"react";import{useDispatch as Bh,useSelector as kc}from"react-redux";import Fh from"lodash.debounce";var wc={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Dn(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 Ir(t){return t.replace("https://www.","").replace("https://","")}import{jsx as Ye,jsxs as Pr}from"react/jsx-runtime";var Kh=3,Uh=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),zh=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=Kh})=>{let r=S("LinkSearch",wc),[i,a]=Ec(""),l=Bh(),c=kc(Ua("url")),p=kc(Ea("URL",Uh)),[u,d]=Ec(p.length-1),m=b("fallbackImage"),f=h=>{let y=h.target;a(y.value)},g=(h,y)=>{h.stopPropagation(),h.preventDefault(),window.open(y,"_blank")},v=h=>{var C;let y=u-1<0?p.length-1:u-1,x=u+1===p.length?0:u+1;h.code==="Escape"&&(a(""),e()),h.code==="ArrowUp"&&d(y),h.code==="ArrowDown"&&d(x),h.code==="Enter"&&t(((C=p[u])==null?void 0:C.text)||i)},w=Hh(Fh(h=>{l(Ze({query:h,type:"URL",tags:["link-search"]}))},300),[]);return Tc(()=>{i&&w(i)},[i]),Tc(()=>()=>{l(dn())},[]),Pr("div",{className:r.root,children:[Ye(se,{withDivider:!0,children:(i?p:c).slice(0,s).map((h,y)=>Ye(M,{selected:u===y,onClick:()=>t(h.text),"data-testid":"linksearch-suggestion",children:Pr(N,{children:[Ye(N.Image,{src:Dn(h,"small",m||void 0),title:h.title||h.text}),Pr(N.Content,{className:r.content,cropText:!0,children:[Ye(N.Title,{children:h.title||Ir(h.text)}),h.title&&Ir(h.text)]}),Ye(M.Actions,{children:Ye(M.ActionButton,{label:n,onClick:x=>g(x,h.text)})})]})},h.text))}),Ye(oo,{value:i,onChange:f,autoFocus:!0,placeholder:o,onKeyUp:v})]})},Rc=zh;var Ar={};q(Ar,{enUS:()=>jh,nlNL:()=>qh});var jh={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},qh={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};import{jsx as me,jsxs as Lr}from"react/jsx-runtime";var Qh=Gh((t,e)=>{let o=S("TabCompletion",ye);return me("mark",{ref:e,className:Mr(o.matchSelection)},"selection-start")}),Zh=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=T(Ar),i=S("TabCompletion",ye),a=Pc(null),l=Pc(null),[c,p]=Ac(null),u=Xh(),d=Ln(document.activeElement===n),[m]=Ac(()=>document.createRange());d.triggerRef.current=m,Ic(()=>()=>m.detach(),[]),Ic(()=>{let g=t.current,v=a.current;!g||!v||(m.setStart(g,0),m.setEnd(v,0))},[t.current,a.current]),ht(()=>{d.close()});let f=$h(g=>{let v=m.toString(),w=/^http(s?):\/\//.test(g)?g:`https://${g}`;u(No({text:`[${v}](${w})`,replace:"selection"}))},[]);return Lr("span",{children:[me("mark",{ref:a,className:Mr(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:s}),d.opened&&me(Mn,{className:i.popoverRoot,triggerRef:d.triggerRef,boundaryRef:e,position:"above",align:"start",children:Lr(On,{style:o,ref:l,children:[me("div",{className:Mr(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:Lr("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[me(Cc,{}),me("span",{children:"\xA0"}),me("span",{children:r("insertLink")})]})}),c==="insertLink"&&me(Rc,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:f,onDismiss:()=>{p(null),d.close()}})]})})]},"selection-end")},Hn=class extends Vh{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=Wh(),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?me(Qh,{ref:this.startRef}):me(Zh,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};import{jsx as Ot,jsxs as ry}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=S("TabCompletion",gc),p=b("insertLink"),u=b("showMidSentenceSuggestions"),d=b("inlineSuggestions"),m=on(a),f=ty(null);ey(()=>{Fe(a)&&m&&nn(a,m)},[m]);let g=Yh(h=>{if(!s||!o)return h;let y=[Ot("span",{className:c.resetIndent,children:"\u200B"},"u200B"),Ot("span",{"data-testid":"tab-completion",className:Or(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&y.push(Ot("span",{className:Or(c.hint,c.resetIndent),children:Ot(is,{keyCode:"tab"},"tabHint")})),wr(h,y)},[s,o,n]),v=Lc(()=>{let h=[];return p&&h.push(new Hn("selection")),h.push(new ft("placeholders")),r&&h.push(new Nn("keywords")),h},[d,p,r]),w=Lc(()=>{let h=window.getComputedStyle(a);return{"--dd-color":h.color,"--dd-font-size":h.fontSize,"--dd-font-family":h.fontFamily,"--dd-font-variant":h.fontVariant}},[]);return t?ry("div",{ref:h=>{h!=null&&h.parentElement&&(f.current=h==null?void 0:h.parentElement)},className:c.root,style:w,children:[Ot(Jh,{tagName:"span",containerTagName:"div",className:Or(c.container,c.agentText),disableLineBreaks:Fe(a),content:e||"\u200B",onAfterParse:g,matchers:v,selection:m,keywordMatches:i,inputElement:a,inputStyle:w,boundaryRef:f,inlineSuggestionsOnlyAtEnd:!u}),Ot("br",{})]}):null},sy=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var g;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??ao(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:u}=s,{showTabCompletion:d,visible:m,showStyleSuggestions:f}=o;return{showTabHint:p,showStyleSuggestions:f,showTabCompletion:d,content:l,tabText:c,source:a,keywordMatches:((g=n.list)==null?void 0:g.keywordMatches)??[],enabled:m&&u!==!1}},Mc=oy(sy)(ny);import Ky from"classnames";import{useEffect as Uy}from"react";import{useDispatch as zy,useSelector as J}from"react-redux";import{createAsyncThunk as uo,createSlice as iy}from"@reduxjs/toolkit";var Oc={list:[],fetchState:"idle",isInitialRequest:null},Dc=t=>t.autoflows.list||[],Nc=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},Ee=uo("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Nr=uo("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(Ee(t.platformSessionId))}),Dr=uo("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(Ee(t.platformSessionId))}),ay=iy({name:"autoflows",initialState:Oc,reducers:{},extraReducers:t=>{t.addCase(Nr.pending,(e,o)=>{let n=Nc(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Dr.pending,(e,o)=>{let n=Nc(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(Ee.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(Ee.rejected,e=>{e.fetchState="error"}),t.addCase(Ee.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(R,()=>Oc)}}),Hc=uo("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(Ee(t))}),s.on("sessionCompleted",()=>{o(Ee(t))})}),Bc=uo("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Fc=ay.reducer;import{createAsyncThunk as mo,createSlice as ly}from"@reduxjs/toolkit";var Kc={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Uc=t=>t.customMessages.list,zc=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),jc=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),qc=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),go=mo("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),Bn=mo("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)}),Fn=mo("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)}),Vc=ly({name:"customMessages",initialState:Kc,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(go.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(go.rejected,e=>{e.fetchState="error"}).addCase(go.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(Bn.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(Bn.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(Fn.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(Fn.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(R,()=>Kc)}}),Wc=mo("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(Vc.actions.onCustomMessage(r))})}),Gc=mo("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),$c=Vc.reducer;import{createAsyncThunk as Xc,createSlice as cy}from"@reduxjs/toolkit";var py={jwt:null,accountUrl:null,interval:null},Qc=t=>e=>{let{exchangeToken:{jwt:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/jwt/?jwt=${o}&redirect=${t}`:null},Hr=Xc("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.getTemporaryExchangeToken();return{accountUrl:o.client.baseUrl,jwt:n}}),Br=Xc("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:o=1e3*60*30}=t,{dispatch:n}=e;return n(Hr()),setInterval(()=>n(Hr()),o)}),Zc=cy({name:"exchangeToken",initialState:py,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Hr.fulfilled,(e,o)=>{e.jwt=o.payload.jwt,e.accountUrl=o.payload.accountUrl}),t.addCase(Br.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollExchangeToken:Jc}=Zc.actions,Yc=Zc.reducer;function ep(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}import{Fragment as _y}from"react";import{connect as xy}from"react-redux";import yy from"classnames";import{Fragment as Sy}from"react";import uy from"classnames";var tp={root:"_root_838fd_1"};import{jsx as gy}from"react/jsx-runtime";var dy=({className:t,children:e})=>{let o=S("Unicode",tp);return gy("span",{className:uy(t,o.root),children:e})},op=dy;var np={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 Fr={};q(Fr,{enUS:()=>my,nlNL:()=>fy});var my={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"}]},fy={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 et,jsxs as Kn}from"react/jsx-runtime";var vy=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=S("Autoflow",np),a=T(Fr),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return Kn(M,{className:yy(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[et(N,{children:Kn(N.Content,{children:[Kn(N.Title,{children:[e&&et("span",{className:i.stateBadge,children:a(e)}),o]}),et("span",{children:n})]})}),et(M.Actions,{fixed:e==="Started",children:et(M.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:Kn(Sy,{children:[et(op,{children:c})," ",et("span",{children:a(l)})]})})})]})},sp=vy;import{jsx as rp}from"react/jsx-runtime";var by=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Cy=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>rp(_y,{children:t.map(s=>rp(sp,{displayName:s.displayName,description:s.description,disabled:s.isBusy||by(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),wy=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},Ty={onStartAutoflow:Nr,onStopAutoflow:Dr},ip=xy(wy,Ty)(Cy);import{useEffect as Ey,useState as ky}from"react";import{useDispatch as Ry}from"react-redux";import cp from"classnames";import{jsx as ap}from"react/jsx-runtime";var Kr=()=>ap("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:ap("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 lp={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 pp}from"react/jsx-runtime";var Iy=({entities:t})=>{let e=S("EntitiesWidgetList",lp),[o,n]=ky(void 0),s=Ry(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),so(a.text),s(z({name:"entity copied",data:{entity:a,type:"copy"}})))};return Ey(()=>{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)=>pp("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[Nt("span",{className:e.entityText,children:a.text}),pp("span",{className:e.iconWrapper,children:[Nt("span",{className:cp(e.icon),children:Nt(Kr,{})}),Nt("span",{className:cp(e.icon,o===l&&e.iconClicked),children:Nt(Kr,{})})]})]},a.text))})},up=Iy;import Py from"classnames";import{useCallback as dp}from"react";import{useDispatch as Ay,useSelector as Un}from"react-redux";var ke={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 Ke,jsxs as zn}from"react/jsx-runtime";var Ly=({suggestion:t})=>{let e=T(Qe),o=Ay(),n=Un(zc(t.text)),s=Un(jc(t.text)),r=Un(qc(t.text)),i=Un(ko),{replyOptions:a}=t,l=dp(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(Bn({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=dp(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let u=parseInt(p.target.dataset.index,10),d=a[u];o(Fn({platformSessionId:i,reply:d,suggestion:t}))},[t,n,o,i]);return zn(M,{onClick:l,className:Py(ke.root,{[ke.isUsed]:n,[ke.hasError]:r}),children:[Ke(N,{children:zn(N.Content,{children:[zn(N.Title,{className:ke.title,children:[t.text," ",Ke(as,{className:ke.label,children:"analyse tool"})," ",r&&Ke("span",{className:ke.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&Ke("ul",{className:ke.quickReplies,children:a.map(p=>Ke("li",{className:ke.quickReply,children:p.title},p.title))})]})}),zn(M.Actions,{fixed:r||n,children:[a&&a.length>0&&Ke(M.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,u)=>Ke(M.DropdownItem,{index:u,label:p.title,onClick:c},p.title))}),Ke(M.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},gp=Ly;import{jsx as mp}from"react/jsx-runtime";var fp=()=>mp("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:mp("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 Ny}from"react-redux";import{useCallback as My}from"react";import{jsx as tt,jsxs as jn}from"react/jsx-runtime";var Oy=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var d;let s=t.text||t.url||t.message,r=gn(s),i=T(Qe),a=b("showImages"),l=b("fallbackImage"),c=m=>{m.preventDefault(),m.stopPropagation(),n(s)},p=m=>{m.preventDefault(),m.stopPropagation(),o(t)},u=My(m=>{window.open(r,"_blank"),m.stopPropagation(),m.preventDefault()},[r]);return jn(M,{onClick:c,"data-testid":"edit-suggestion",children:[jn(N,{children:[a&&t.image&&tt(N.Image,{src:Dn(t,"small",l||void 0),title:t.title}),jn(N.Content,{children:[t.title&&tt(N.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((d=t.searchKeywords)==null?void 0:d.length)>0&&tt(M.Labels,{labels:t.searchKeywords}),tt(N.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),jn(M.Actions,{children:[r&&tt(M.ActionButton,{onClick:u,label:i("visitUrl")}),tt(M.ActionButton,{primary:!0,onClick:p,label:i("preview")}),tt(M.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},hp=Oy;import{Fragment as Hy,jsx as yp}from"react/jsx-runtime";var Dy=({contentType:t,lines:e,suggestions:o})=>{let n=ne(),s=Ny(bt),r=a=>{n.send(or,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(be,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return yp(Hy,{children:o.map(a=>yp(hp,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},Sp=Dy;var Ur={};q(Ur,{enUS:()=>By,nlNL:()=>Fy});var By={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"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},Fy={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"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var vp={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 _p}from"react/jsx-runtime";var xp=()=>_p("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:_p("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 bp}from"react/jsx-runtime";var Cp=()=>bp("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:bp("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 L,jsxs as Dt}from"react/jsx-runtime";var qn=(t,e)=>{let o=J(ae);Uy(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},jy=()=>{let t=T(Ur),e=zy(),o=b("isEmbedded"),n=S("Widget",vp),s=b("showAutoflows"),r=b("showCustomMessages"),i=b("showPersonalCollectionLink"),a=b("showSummaryCommand"),l=b("showKnowledgeSearch"),c=b("showSearch"),p=J(Pt),u=J(bn),d=J(Dc),m=J(vn),f=J(Uc),g=J(Ro),v=J(dt),w=J(ae),h=J(ko),y=J(ep),x=J(bt),C=ne(),F=J(ja),D=J(Qc("/admin/personal-collection")),Y=b("adminUrl");if(qn(()=>(e(go(h)),e(Wc(h)),()=>{e(Gc(h))}),[e,v,r,h]),qn(()=>(e(Ee(h)),e(Hc(h)),()=>{e(Bc(h))}),[e,v,s,h]),qn(()=>{u.forEach(({type:k})=>{e(k==="entities"?le():_e(k))})},[e,v,g,p]),qn(()=>(e(Br()),()=>{e(Jc())}),[e,v,i,g]),v===!1)return L("div",{className:n.stateText,children:L("div",{children:L("p",{children:t("notSupported")})})},"supported");if(w===!1)return L("div",{className:n.loginText,children:L("div",{children:L(In,{isEmbedded:o,loginUrl:Y})})},"login");if(!p||!h||w===null||F||y)return L("div",{className:n.stateText,children:L("div",{children:L("p",{children:t("waiting")})})},"waiting");let H=c||a||l||D;return L("div",{className:Ky(n.root),"data-testid":"widget",children:Dt(cs,{className:n.sectionList,children:[H&&L(je,{title:t("actions"),type:"shortcuts",children:Dt("div",{className:n.shortcutList,children:[c&&Dt("button",{className:n.shortcut,"data-testid":"shortcut-search",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0}),children:[L(_t,{}),t("linkSearch")]}),a&&Dt("button",{className:n.shortcut,"data-testid":"shortcut-summary",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[L(Cp,{}),t("linkSummary")]}),l&&Dt("button",{className:n.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[L(xp,{}),t("linkKnowledgeSearch")]}),D&&Dt("a",{className:n.shortcut,target:"_blank",href:D,"data-testid":"shortcut-personal-collection",rel:"noreferrer",children:[L(fp,{}),t("linkPersonalcollection")]})]})}),r&&f.length>0&&L(je,{type:"custom-messages","data-testid":"custom-messages",children:L(se,{withDivider:!0,children:f.map(k=>L(gp,{suggestion:k},k.text))})}),s&&d.length>0&&L(je,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:L(se,{withDivider:!0,children:L(ip,{})})}),u.map(({type:k,title:O,amount:G,lines:es})=>{var ze;switch(k){case"entities":return m&&m.length>0&&L(je,{type:k,title:O,"data-testid":`type-${k}`,children:L(up,{entities:m})},k);default:return((ze=x[k])==null?void 0:ze.fetchState)==="done"&&x[k].suggestions.length>0&&L(je,{type:k,title:O,"data-testid":`type-${k}`,children:L(se,{withDivider:!0,children:L(Sp,{lines:es,contentType:k,suggestions:x[k].suggestions.slice(0,G)||[]})})},k)}})]})})},wp=jy;function ho(t){let e=new Range;return e.selectNodeContents(t),e}function Tp(t,e,o){try{return ot(t,e,o),!0}catch{return!1}}function Vn(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function Wn(t){return"tagName"in t&&t.tagName==="BR"}var fo=/[\u200B-\u200D\uFEFF]/g;function ot(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,u=/[\u200B-\u200D\uFEFF]/;if(!u.test(l))return c;for(let d=0;d<=l.length;d++)if(u.test(l[d])||p++,p===c)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(fo,""),u=s+p.length,d=e>=s&&e<=u,m=o>=s&&o<=u;if(d){let f=i(c,e-s);f===0&&!m?n.setStartBefore(l):n.setStart(l,f)}m&&(n.setEnd(l,i(c,o-s)),r=!0),s=u;break}case Node.ELEMENT_NODE:{if(Wn(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;Vn(l)&&c&&!Vn(c)&&!Wn(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function Gn(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(u){let d=u===o,m=u===s;switch(u.nodeType){case Node.TEXT_NODE:{let f=u.textContent;d&&(a=c+f.substring(0,n).replace(fo,"").length),m&&(l=c+f.substring(0,r).replace(fo,"").length),c+=f.replace(fo,"").length;break}case Node.ELEMENT_NODE:{let f=u.nextSibling===null;Wn(u)&&!f&&c++;for(let g=0;g<u.childNodes.length;g++){let v=d&&g===n,w=m&&g===r;if(v&&(a=c),w&&(l=c),l!==void 0||((!v||!i)&&p(u.childNodes[g]),m&&g===r-1&&(l=c),l!==void 0))break}!m&&Vn(u)&&!f&&c++,m&&(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 $n(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,u=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let d=p?n:0,m=u?r:void 0,f=c.textContent.replace(fo,"");d===0&&m===void 0?a+=f:a+=f.substring(d,m);break}case Node.ELEMENT_NODE:{let d=c.nextSibling===null;i===0&&Wn(c)&&!d&&(a+=`
4
+ `);for(let m=p?n:0;m<(u?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[m]),i!==1);m++);!u&&i===0&&Vn(c)&&!d&&(a+=`
5
+ `);break}default:break}u&&i++}return l(t),a}function Ep(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Ht=class extends Me{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),$n(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!Ep(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!Ep(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return Gn(this.element,e);let o=this.lastKnownSelection;if(o&&Tp(this.element,o.start,o.end))return o;let n=ho(this.element);return n.collapse(!1),Gn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return $n(this.element,ot(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()}};var zr=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()}},jr=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=this.createIframe(),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];createIframe(){let e=`deepdesk-iframe-${this.name}`,o=document.getElementById(e);if(o)return o;let n=document.createElement("iframe"),s=`${this.targetOrigin}/v2/widget/liveengage/channel.html`,r=new URLSearchParams({channel:this.name,host:window.location.origin});return this.options.debug&&r.set("debug","1"),n.style.position="absolute",n.style.left="-999em",n.style.width="0px",n.style.height="0px",n.tabIndex=-1,n.id=e,n.title=`iframe-${this.name}`,n.src=`${s}?${r.toString()}`,n}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.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 jr(e,this.deepdeskUrl,{debug:!0}):new zr(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 s,r,i;if(!this.sessionId)return;E.info("broadcast event",{sessionId:this.sessionId,name:e,payload:o});let n={type:"event",name:e,payload:o};(r=(s=this.eventMap)[e])==null||r.call(s,o),(i=this.channel)==null||i.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)}},kp=qr;var Bt=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Vr=t=>new Promise(e=>{setTimeout(e,t)});var Ft=class extends Bt{name="ClientError"},Wr=class extends Bt{name="ServerError"},fe=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:u=!0,retryOnError:d=x=>x instanceof TypeError,retryOnResponse:m=x=>x.status>=500,version:f="v1",...g}=o,v={credentials:"include",...g,headers:{"Content-Type":"application/json",...g.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(v.headers={...v.headers,"X-CSRFToken":this.csrfToken}),typeof f=="string"&&(v.headers={...v.headers,"X-Deepdesk-API-Version":f});let w=c,h=!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 y=async()=>(w--,a(i,v).then(async x=>m(x)&&!r.isAborted&&w>0?(await Vr(p),y()):x.status===401&&u===!0&&h===!1?(h=!0,await this.refreshToken(),y()):x).catch(async x=>{if(d(x)&&!r.isAborted&&w>0)return await Vr(p),y();throw x}));y().then(x=>x.json().catch(()=>null).then(C=>{x.status>=500?s(new Wr("Server Error",C)):x.status===401?s(new Ft("Unauthorized",C)):x.status===403?s(new Ft("Forbidden",C)):x.status===404?s(new Ft("Not Found",C)):x.status>=400&&s(new Ft("Bad Request",C)),delete this.latestRequestByUrl[i],n(C)})).catch(x=>{s(x)})})}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 qy;(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||={})})(qy||={});function Xn(t){return{...A(t),tags:t.tags}}var Ue=class t{constructor(e,o={}){this.options=o;this.client=new fe(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",{...B(e),tags:e.tags},{version:"v2"});return Xn(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${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 Xn(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=B(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return Xn(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...B(s),tags:s.tags})),{version:"v2"})).map(s=>Xn(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",B({...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:B({...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/",B(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}`,B(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`,B(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",B(e),{abortLatest:!0});return A(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,B(e),{version:"v2"});return A(o)}async knowledgeAssist(e,o,n){let s=await this.client.post("/api/knowledge-search/search",B({question:e.question,promptInstruction:e.promptInstruction,profile:n,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 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(ii);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 yo=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Gs(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 Vy;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(Vy||={});var So=class{constructor(e,o={}){this.apiUrl=e;this.client=new fe(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`,B(o));return A(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,B(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",B(e));return A(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new yo(`${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 Jy,configureStore as Yy}from"@reduxjs/toolkit";import{createSlice as Wy}from"@reduxjs/toolkit";var Rp={startTime:null,stopTime:null},Ip=Wy({name:"handlingTime",initialState:Rp,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(R,()=>Rp)}}),{handlingTimeStart:Pp,handlingTimeStop:Qn,handlingTimeReset:Ap}=Ip.actions,Lp=Ip.reducer;var Mp=(t={})=>{let e={onAuthError:Tt(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};import{createAsyncThunk as Gy,createSlice as $y}from"@reduxjs/toolkit";var Zn={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var nt=Gy("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 Zn.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),Xy=$y({name:"styleSuggestions",initialState:Zn,reducers:{},extraReducers:t=>{t.addCase(nt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(nt.rejected,e=>{e.fetchState="error"}).addCase(nt.fulfilled,(e,o)=>{e.fetchState="done",Ie(e.list,o.payload)||(e.list=o.payload)}).addCase(We,e=>{e.list=Zn.list}).addCase(R,()=>Zn)}}),Op=Xy.reducer;var Np=(t={})=>{let e,o=!0,n={getStyleSuggestions:nt,debounce:500,...t};return s=>r=>i=>{var m;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(!((m=c.conversation.current)==null?void 0:m.id)||!p)return l;let{text:d}=c.input;return d===a&&!o||(clearTimeout(e),d==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:d}))},t.debounce)),l}};function Qy(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Dp=(t={})=>{let e={getTextSuggestions:_e,getAutocompleteSuggestions:Yt,debounce:200,check:Lt,...t},o;return n=>s=>r=>{var g;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,u=(g=l.conversation.current)==null?void 0:g.id,d=r.type===hn.toString();if(!u||!c&&!p)return a;let{input:{userCommitted:m}}=l;return Qy(m,i)&&!d||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let v=gt(l);v===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(v))},d?0:e.debounce)),a}};var Hp=nt.fulfilled.toString();function Zy(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 Bp=t=>e=>o=>n=>{var c;if(n.type!==Hp){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=Zy(s,i);n.type===Hp&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var eS=Jy({activeSuggestion:Ya,answer:Kl,auth:dl,autoflows:Fc,conversation:di,contentTypes:Cl,customMessages:$c,exchangeToken:Yc,entities:El,handlingTime:Lp,info:ba,input:ys.reducer,overlayInput:$.reducer,settings:li,profile:Vl,search:Ra,summary:Ml,styleSuggestions:Op,ui:nl,textSuggestions:$a});function Fp(t){return Yy({reducer:eS,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Mp(),Dp({debounce:200}),Np({debounce:500}),Bp(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var tS=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},oS=t=>e=>o=>n=>{var a;let s=e.getState(),r=gs("inlineSuggestions")(s);switch(n.type){case xe.toString():{let l=za(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 Tt.toString():{!n.payload&&t.emit("logout",void 0);break}case re.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:tS(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case No.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 jt.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case Fo.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 le.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case Ce.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary}});break;case z.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 Do.toString():t.handleKeyDown(n.payload);break;case We.toString():t.logSendMessage(n.payload);break;case Ho.toString():t.logSendEditSuggestionMessage(n.payload);break;case Bo.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case We.toString():t.handleAfterSendMessage(n.payload);break;case eo.toString():t.onUpdateShowTabHint(n.payload);break;case Qn.toString():t.logHandlingTime();break;case re.toString():{r&&(e.dispatch(pe([])),e.dispatch(Le()));break}case pe.toString():{r&&n.payload.length>0&&e.dispatch(Ae(0));break}default:break}return i},Kp=oS;function Gr(t){return t.toISOString().replace("T"," ").replace("Z","")}function Up(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:Gr(o),timeStop:Gr(n)}}function $r(t,e,o){var D,Y,H;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:u,cuts:d,deletions:m,textSuggestions:f,offeredTextSuggestions:g}}=e[t],v=n.length,h=f.reduce((k,{text:O,searchTerm:G})=>k+O.length-(G?G.length:0),0),y=c??Date.now(),x=(Date.now()-y)/1e3+(p||0),C=s/x,F=f.reduce((k,{searchTerm:O})=>k+(O?O.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:u,cuts:d,deletions:m,lenTextTyped:s+F,lenTextTotal:v,lenTextAssisted:h,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:x,charsPerSecond:C,numPastes:l,textSuggestionsV2:f,suggestionsCounters:[{source:"gpt",countOffered:g.filter(k=>k.source==="gpt").length}],agentId:(D=e.info.agentInfo)==null?void 0:D.agentId,agentName:(Y=e.info.agentInfo)==null?void 0:Y.agentName,agentEmail:(H=e.info.agentInfo)==null?void 0:H.agentEmail}}function zp(t,e){let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;return n instanceof HTMLElement?zp(n,e):null}function jp(t,e){return zp(t,e)}function qp(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function nS(t){return typeof t=="object"&&t!==null&&"tagName"in t}function Xr(t){return nS(t)&&(Fe(t)||tn(t))}var Vp=(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 sS(t){return t.offsetParent!==null}function Wp(t){if(!sS(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 Qr(t,e,o=100){let n=Wp(t);e({isVisible:n});let s=setInterval(()=>{let r=Wp(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}import{jsx as W}from"react/jsx-runtime";var Gp=Vp("showTabHint",!0),Yn=class t{static version="10.5.0";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 Ue(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Kp({emit:(u,d,m)=>this.emit(u,d,m),handleAfterSendMessage:u=>this.handleAfterSendMessage(u),handleInputChanged:u=>this.handleInputChanged(u),handleKeyDown:u=>this.handleKeyDown(u),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:u=>this.logSendMessage(u),logSendEditSuggestionMessage:u=>this.logSendEditMessage(u),onUpdateShowTabHint:u=>Gp.update(u),sendEvent:(u,d)=>this.deepdeskApi.sendEvent(u,d)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new So(o)}),this.store=Fp(p),this.broadcastEvents=new kp({debug:!0,deepdeskUrl:c,eventMap:gl(this.store),createCustomChannel:l}),this.store.dispatch(zt),this.store.dispatch(eo(Gp.value())),this.store.dispatch(zt({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(Tt(null)),this.store.dispatch(Be()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ae(n)&&il(n)!=="loading"&&e()});this.unmountHandlers.push(()=>{o()})})}isLoggedIn(){return this.deepdeskApi.isLoggedIn()}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(fs({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Io(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Po({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(hs(e))).payload}async postMessages(e){return(await this.store.dispatch(Lo(e))).payload}async updateConversation(e){return(await this.store.dispatch(Ao(e))).payload}resetConversation(){this.store.dispatch(R()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(Ce());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(zt(e))}setVisitorInfo(e){this.store.dispatch(xa(e))}async setAgentInfo(e){await this.store.dispatch(Qt(e))}async setAgentSettings(e){await this.store.dispatch(Xs(e))}async getAgentSettings(){return(await this.store.dispatch(Qs())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(hn()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Bo(e))}notifyKeyDown(e){this.store.dispatch(Do(e))}notifyPaste(e,o){this.store.dispatch(Ci({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(xi(e))}notifyExternalSuggestion(e){this.store.dispatch(re(e)),this.store.dispatch(Le())}notifyEditSuggestion(e){this.store.dispatch(Wa(e.contentType,e.suggestions)),this.store.dispatch(xe({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(He({collapse:!1})),this.inputMediator&&this.store.dispatch(fi({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(pe([])))}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(bi(Oo(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(Si()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(_i());let{selectedSuggestionIndex:u}=this.state.input;e.preventDefault(),!i&&(u===-1?this.store.dispatch(jt()):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(Ae(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(Ae(-1)),this.store.dispatch(jt()),e.preventDefault()):o||(this.store.dispatch(He({collapse:!0})),this.store.dispatch(tl(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:u}=this.state.input,d=u.text.substring(0,u.selection.end),{tabCompletionSuggestion:m}=this.state.input;this.store.dispatch(eo(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&m&&m.text.startsWith(d)&&(this.store.dispatch(re({text:m.text,suggestion:m,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(Le())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(wi()),this.store.dispatch(pe([]))}handlingTimeStart(){this.state.handlingTime.startTime||(E.info("Start handling time"),this.store.dispatch(Pp()))}handlingTimeStop(){this.state.handlingTime.startTime&&(E.info("Stop handling time"),this.store.dispatch(Qn()))}logSendMessage(e){let o=$r("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=$r("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(yi(this.state.overlayInput.metrics))}logHandlingTime(){let e=Up(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Ap())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(Le()),this.store.dispatch(We(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(re({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]=St(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{Jn(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]=St(r,{appendTo:document.body});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{Jn(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return $e(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(()=>{Jn(s),s.remove()}),s}mount(e,o={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Xr(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:u,detectSubmit:d,insertLink:m,inputMediator:f,closestScrollSelector:g,appendOverlayTo:v,inlineSuggestions:w}=o;if(this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:m,isEmbedded:u,inlineSuggestions:w}),o.automaticHandlingTime&&this.setupHandlingTime(e),$e(e),this.inputMediator=f||(Fe(e)?new Oe(e):new Ht(e)),this.inputMediator.on("change",({plainText:y})=>{this.notifyInputChanged(y)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Ti({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",y=>{this.notifyKeyDown(y)}),this.inputMediator.on("paste",({pastedText:y,selectionText:x})=>{this.notifyPaste(y,x)}),this.inputMediator.on("cut",({selectionText:y})=>{this.notifyCut(y)}),w){if(Fe(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let y=this.createInlineContainer(e,"deepdesk-caret");vo(W(Mt,{store:this.store,customStyles:n,children:W(wt,{broadcastEvents:this.broadcastEvents,children:W(nc,{})})}),y),this.inputMediator.on("caret",x=>{this.store.dispatch(pe([])),x?(y.style.display="block",y.style.top=`${x.top}px`,y.style.left=`${x.left}px`):y.style.display="none"})}else{let y=g&&jp(e,g)||void 0,x=this.overlayContainerFactory("deepdesk-tab-completion",y||e,{appendTo:v,closestScrollElement:y,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",y||e,{appendTo:v},n==null?void 0:n.suggestionsRootNode);vo(W(Mt,{store:this.store,customStyles:n,children:W(wt,{broadcastEvents:this.broadcastEvents,children:W(Mc,{inputElement:e})})}),x),vo(W(Mt,{store:this.store,customStyles:n,children:W(wt,{broadcastEvents:this.broadcastEvents,children:W(dc,{})})}),C)}vo(W(Mt,{store:this.store,customStyles:n,children:W(wt,{broadcastEvents:this.broadcastEvents,children:W(Xl,{})})}),this.createContainer("deepdesk-overlays"));let h;this.inputMediator.on("selection",y=>{clearTimeout(h),y===null?h=setTimeout(()=>{y!==null&&this.store.dispatch(Ss(y))},500):this.store.dispatch(Ss(y))}),this.inputMediator.on("disabled",()=>{var y;(y=this.inputMediator)==null||y.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(Ct(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(Ct(!0))),this.store.dispatch(hi({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var y;this.refresh(),this.broadcastEvents.setSessionId((y=this.state.conversation.current)==null?void 0:y.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,showPersonalCollectionLink:r,isEmbedded:i}=o;this.widgetRoot=e,this.configure({showImages:s,showPersonalCollectionLink:r,isEmbedded:i}),vo(W(Mt,{store:this.store,customStyles:n,children:W(wt,{broadcastEvents:this.broadcastEvents,children:W(wp,{})})}),e),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&Jn(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=Qr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){qp(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(ro());let e=Pt(this.state);e&&this.store.dispatch(zt({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:e.knowledgeAssistForAgents,recommendTextSuggestions:e.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}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=bn(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(le()):this.store.dispatch(_e(n))})}catch(n){this.handleError(n)}}};async function rS(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 iS(t,e,o={}){let n=o.replace?ot(t,o.replace.start,o.replace.end):ho(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(`
6
+ `).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?ot(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()}})}async function aS(t,e){let o;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let n=()=>{let r=(t.ownerDocument.defaultView??window).getSelection();if(!r)return;let i=r.getRangeAt(0);i&&(i.deleteContents(),o=document.createElement("span"),i.insertNode(o),e.split(`
7
+ `).reverse().forEach((a,l)=>{l>0&&i.insertNode(document.createElement("br")),i.insertNode(document.createTextNode(a))}),i.collapse(!1))};return Promise.resolve(n()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!o)try{o.scrollIntoView&&o.scrollIntoView({block:"nearest",inline:"nearest"})}finally{o&&o.remove()}})}function lS(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function cS(t,e,o){await new Ue(t).authenticateWithKey(e,o)}async function pS(t){let o=await new fe(t).get("/platform/config/",{version:null});return A(o)}async function uS(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 dS(t,e){let o=await uS(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{N as Card,Ht as ContentEditableInput,Ue as DeepdeskAPI,Yn as DeepdeskSDK,fe as HTTPClient,Me as InputMediator,qe as InputType,is as KeyboardHint,as as Label,Eo as Locale,je as Section,cs as SectionList,ce as Sources,M as Suggestion,se as SuggestionList,Oe as TextAreaInput,ct as ToggleButton,dS as attachFile,cS as authenticateWithKey,ho as createFullRange,St as createOverlayContainer,ot as createRangeFromOffsets,ao as escapeHTML,pS as fetchPlatformConfig,lS as formatTextMarkup,Gn as getRangeOffsets,$n as getRangeText,aS as insertCKEditor,Xr as isSupportedInputElement,iS as updateContentEditable,rS as updateTextArea,S as useStyles,Qr as waitForElementVisibilityChange};