@deepdesk/deepdesk-sdk 10.6.2-beta.0 → 10.6.2-beta.2

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,11 @@
1
- var cu=Object.defineProperty;var q=(t,e)=>{for(var o in e)cu(t,o,{get:e[o],enumerable:!0})};import as from"classnames";import mu,{createContext as fu,useContext as ls,useEffect as hu,useState as yu}from"react";import pu,{useContext as uu}from"react";import du from"classnames";var Kt=pu.createContext({});function S(t,e){let{debug:o,...n}=uu(Kt),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:du(a,l,o?`${t}__${i}`:!1)}},{}):e}var ei={root:"_root_vr71j_1"};import{jsx as bo,jsxs as gu}from"react/jsx-runtime";var Co=()=>gu("svg",{className:ei.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[bo("defs",{children:bo("style",{children:".cls-1 { fill: #b3b3b3; }"})}),bo("title",{children:"Failed loading image"}),bo("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 is={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 wo=fu(is),Su=({title:t,src:e})=>{let o=ls(wo),[n,s]=yu(!1);return hu(()=>{s(!1)},[e]),it("div",{className:o.imageWrapper,children:e&&!n?it("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):it(Co,{})})},vu=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=ls(wo);return it("div",{className:as(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},_u=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=ls(wo);return mu.createElement(t,{className:as(r.title,o,{[r.contentIsCropped]:e}),...s},n)},To=({children:t})=>{let e=S("Card",is);return it("div",{className:as(e.root),children:it(wo.Provider,{value:e,children:t})})};To.Image=Su;To.Content=vu;To.Title=_u;var N=To;import xu from"classnames";var ti={root:"_root_cq1yq_1"};import{jsx as wu}from"react/jsx-runtime";var bu={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Cu=({className:t,keyCode:e,...o})=>{let n=S("KeyboardHint",ti);return wu("span",{"data-key":bu[e],className:xu(t,n.root),...o})},cs=Cu;import Tu from"classnames";var oi={root:"_root_4a08n_1"};import{jsx as ku}from"react/jsx-runtime";var Eu=({className:t,children:e,...o})=>{let n=S("Label",oi);return ku("span",{...o,className:Tu(t,n.root),children:e})},ps=Eu;var ni={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};import{jsx as us,jsxs as Iu}from"react/jsx-runtime";var Ru=({title:t,children:e,type:o,...n})=>{let s=S("Section",ni);return Iu("section",{...n,className:s.root,"data-section-type":o,children:[t&&us("div",{className:s.subTitleContainer,children:us("span",{className:s.subtitle,children:t})}),us("div",{className:s.suggestions,children:e})]})},je=Ru;import Pu from"classnames";import Au from"react";var si={root:"_root_19wxp_1"};import{jsx as Mu}from"react/jsx-runtime";var Lu=Au.forwardRef(({className:t,children:e},o)=>{let n=S("SectionList",si);return Mu("div",{ref:o,className:Pu(n.root,t),children:e})}),ds=Lu;import Eo from"classnames";import Ou,{createContext as Nu,useCallback as Du,useContext as Ut}from"react";var gs={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 ye,jsxs as Uu}from"react/jsx-runtime";var at=Nu(gs),Hu=({fixed:t,children:e,...o})=>{let n=Ut(at);return ye("div",{...o,className:Eo(n.actions,{[n.actionsIsFixed]:t}),children:e})},Bu=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=Ut(at);return Uu("div",{className:Eo(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,ye("ul",{className:r.dropdownList,children:s})]})},Fu=({index:t,label:e,onClick:o})=>{let n=Ut(at);return ye("li",{className:n.dropdownItem,children:ye("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Ku=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=Ut(at);return ye("button",{type:"button",className:Eo(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},ms=({labels:t})=>{let e=Ut(at);return ye("div",{className:e.labels,children:t.map(o=>ye("span",{className:e.label,children:o},o))})},lt=Ou.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=S("Suggestion",gs),l=Du(c=>{c.preventDefault(),o&&o(c)},[o]);return ye(s,{...r,ref:i,className:Eo(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:ye(at.Provider,{value:a,children:n})})});lt.Labels=ms;lt.Actions=Hu;lt.ActionButton=Ku;lt.DropdownButton=Bu;lt.DropdownItem=Fu;var M=lt;import zu from"classnames";var ri={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};import{jsx as qu}from"react/jsx-runtime";var ju=({withDivider:t,children:e})=>{let o=S("SuggestionList",ri);return qu("div",{"data-testid":"suggestions-overlay-list",className:zu(o.root,{[o.isWithDivider]:t}),children:e})},se=ju;import Vu from"classnames";var ii={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};import{jsx as fs}from"react/jsx-runtime";var Wu=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=S("ToggleButton",ii);return fs("button",{type:"button",className:Vu(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:fs("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:fs("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},ct=Wu;var ai=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,pt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var li=/x-deepdesk-(([a-z0-9\-_])+-version)/,pe=(m=>(m.SEARCH="search",m.TEMPLATE="template",m.ELASTIC_SEARCH="search-autocomplete",m.GPT="gpt",m.TRIE="trie",m.TRIE_WITH_TYPOS="trie-with-typos",m.SEMANTIC="semantic",m.TEXT_RECOMMENDATION="text_recommendation",m.URL_RECOMMENDATION="url_recommendation",m.LINK_RECOMMENDATION="link_recommendation",m.PERSONAL_COLLECTION="personal-collection",m.PERSONAL_COLLECTION_SEARCH="personal-collection-search",m.SEARCH_OVERLAY="search-overlay",m.SEARCH_PREVIEW="search-preview",m.SEARCH_URL="search-url",m))(pe||{}),qe=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(qe||{});import{render as _o,unmountComponentAtNode as ts}from"react-dom";import{Fragment as Ef}from"react";import{createSlice as Gu}from"@reduxjs/toolkit";import{useSelector as $u}from"react-redux";var ko=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(ko||{});var Xu={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"},ci=Gu({name:"settings",initialState:Xu,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:zt}=ci.actions,hs=t=>e=>e.settings[t],b=t=>$u(hs(t)),pi=ci.reducer;import{useState as dm}from"react";import{useDispatch as gm,useSelector as lr}from"react-redux";import{createAction as Ve,createSlice as nd}from"@reduxjs/toolkit";import{diffChars as sd}from"diff";import{useSelector as rd}from"react-redux";function ui(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Pe(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)=>Pe(r,e[i],o-1)):ui(t)&&ui(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Pe(t[i],e[i],o-1)):!1}function Qu(t){return Math.max(...t.map(e=>e.length))}function Zu(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 di(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Qu(n);s++){let r=Zu(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 Ju=2;function ys(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=di(t,Ju);return o&&o.text!==e?o:t[0]}import{createAction as Yu,createAsyncThunk as ut,createSlice as ed}from"@reduxjs/toolkit";var gi={current:null,isSupported:null},R=Yu("resetConversation"),Ro=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Io=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},dt=t=>t.conversation.isSupported,Ss=ut("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Po=ut("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Ao=ut("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Lo=ut("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Io(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),vs=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})})}),Mo=ut("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Io(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),td=[Po.rejected,Ao.rejected,Lo.rejected,Mo.rejected].map(t=>t==null?void 0:t.toString()),od=ed({name:"conversation",initialState:gi,reducers:{},extraReducers:t=>{t.addCase(Ss.fulfilled,(e,o)=>{e.isSupported=o.payload}).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)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(vs.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)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Mo.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(R,()=>gi).addMatcher(e=>td.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),mi=od.reducer;var Ae={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 No(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 Do=Ve("input/replaceText"),Ho=Ve("input/keyDown"),We=Ve("input/sendMessage"),Bo=Ve("input/sendEditSuggestionMessage"),Fo=Ve("input/uiInputChange"),Ko=Ve("input/applyImageSuggestion"),z=Ve("input/sendEvent");function Oo(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 fi=t=>nd({name:t,initialState:Ae,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,{...Ae,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=ys(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(Pe(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Oo(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:g,altKey:f}=e.previousKeyDownEvent;switch(p){case"Enter":u&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:m}=e,{text:v}=o.payload,w=sd(m,v);m.length-v.length>1&&e.metrics.deletions.push(...w.filter(h=>h.removed).map(h=>h.value)),e.metrics.numCharsDeleted+=m.length-v.length;break}case"C":case"V":case"X":if(!d&&!g){e.metrics.numCharsTyped+=1;let m=((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;m&&m.length>0&&(e.metrics.numCharsDeleted+=m.length,e.metrics.deletions.push(m))}break;case"Shift":break;default:if(!d&&!g&&!f){e.metrics.numCharsTyped+=1;let m=((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;m&&m.length>0&&(e.metrics.numCharsDeleted+=m.length,e.metrics.deletions.push(m))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=Ae.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Oo(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"&&Oo(e)},commitSuggestion(e){Oo(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=ys(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=Ae.tabCompletionSuggestion,o.previousKeyDownEvent=Ae.previousKeyDownEvent,o.textSuggestions=Ae.textSuggestions,o.selectedSuggestionIndex=Ae.selectedSuggestionIndex,o.metrics=Ae.metrics})}}),_s=fi("input"),gt=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),id=t=>t.input.selection,hi=()=>rd(id),{userInput:yi,changeSelection:xs,initialInput:Si,mergeMetrics:vi,nextTextSuggestionIndex:_i,offeredTextSuggestion:xi,previousTextSuggestionIndex:bi,registerCut:Ci,registerKeyDown:wi,registerPaste:Ti,reset:Ei,resetToCommitted:jt,platformInput:ki,setSelectedTextSuggestionIndex:Le,setTextSuggestions:ue,stageSuggestion:re,commitSuggestion:Me}=_s.actions,$=fi("overlay");import{useEffect as Ii,useRef as Pi}from"react";var Ri={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};import{jsx as Ai}from"react/jsx-runtime";var ad=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=Pi(null),l=Pi(null),c=S("Dialog",Ri);return Ii(()=>{var d,g;let p=f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),s())},u=f=>{let m=window.getSelection();m!=null&&m.toString()||f.target===a.current&&t&&n()};return(d=a.current)==null||d.addEventListener("click",u),(g=a.current)==null||g.addEventListener("keyup",p),()=>{var f,m;(f=a.current)==null||f.removeEventListener("click",u),(m=a.current)==null||m.removeEventListener("keyup",p)}},[a,l,s,n]),Ii(()=>{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?Ai("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:Ai("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},mt=ad;import{useEffect as Ka}from"react";import{useDispatch as Gg,useSelector as $g}from"react-redux";var bs={};q(bs,{enUS:()=>ld,nlNL:()=>cd});var ld={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?"}]},cd={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 Li={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 xd,useContext as bd}from"react";var Cs=function(t,e){return Cs=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])},Cs(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");Cs(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 Mi(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 Uo(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 zo;(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"})(zo||(zo={}));var jo=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 qo;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(qo||(qo={}));function ws(t){return t.type===ie.literal}function Oi(t){return t.type===ie.argument}function Vo(t){return t.type===ie.number}function Wo(t){return t.type===ie.date}function Go(t){return t.type===ie.time}function $o(t){return t.type===ie.select}function Xo(t){return t.type===ie.plural}function Ni(t){return t.type===ie.pound}function Qo(t){return t.type===ie.tag}function Zo(t){return!!(t&&typeof t=="object"&&t.type===qo.number)}function Vt(t){return!!(t&&typeof t=="object"&&t.type===qo.dateTime)}function Ts(t){t.forEach(function(e){if(delete e.location,$o(e)||Xo(e))for(var o in e.options)delete e.options[o].location,Ts(e.options[o].value);else Vo(e)&&Zo(e.style)||(Wo(e)||Go(e))&&Vt(e.style)?delete e.style.location:Qo(e)&&Ts(e.children)})}function Di(t,e){e===void 0&&(e={}),e=ee({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new jo(t,e).parse();if(o.err){var n=SyntaxError(zo[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||Ts(o.val),o.val}function Jo(t,e){var o=e&&e.cache?e.cache:fd,n=e&&e.serializer?e.serializer:md,s=e&&e.strategy?e.strategy:ud;return s(t,{cache:o,serializer:n})}function pd(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Hi(t,e,o,n){var s=pd(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function Bi(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 Es(t,e,o,n,s){return o.bind(e,t,n,s)}function ud(t,e){var o=t.length===1?Hi:Bi;return Es(t,this,o,e.cache.create(),e.serializer)}function dd(t,e){return Es(t,this,Bi,e.cache.create(),e.serializer)}function gd(t,e){return Es(t,this,Hi,e.cache.create(),e.serializer)}var md=function(){return JSON.stringify(arguments)};function ks(){this.cache=Object.create(null)}ks.prototype.get=function(t){return this.cache[t]};ks.prototype.set=function(t,e){this.cache[t]=e};var fd={create:function(){return new ks}},Yo={variadic:dd,monadic:gd};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 Rs=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 Fi=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 Ki=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 hd(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 yd(t){return typeof t=="function"}function Gt(t,e,o,n,s,r,i){if(t.length===1&&ws(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(ws(p)){a.push({type:j.literal,value:p.value});continue}if(Ni(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 Ki(u,i);var d=s[u];if(Oi(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(Wo(p)){var g=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,g).format(d)});continue}if(Go(p)){var g=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,g).format(d)});continue}if(Vo(p)){var g=typeof p.style=="string"?n.number[p.style]:Zo(p.style)?p.style.parsedOptions:void 0;g&&g.scale&&(d=d*(g.scale||1)),a.push({type:j.literal,value:o.getNumberFormat(e,g).format(d)});continue}if(Qo(p)){var f=p.children,m=p.value,v=s[m];if(!yd(v))throw new Fi(m,"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($o(p)){var y=p.options[d]||p.options.other;if(!y)throw new Rs(p.value,d,Object.keys(p.options),i);a.push.apply(a,Gt(y.value,e,o,n,s));continue}if(Xo(p)){var y=p.options["=".concat(d)];if(!y){if(!Intl.PluralRules)throw new Wt(`Intl.PluralRules is not available in this environment.
1
+ var vu=Object.defineProperty;var j=(t,e)=>{for(var o in e)vu(t,o,{get:e[o],enumerable:!0})};import as from"classnames";import Cu,{createContext as wu,useContext as ls,useEffect as Tu,useState as Eu}from"react";import Su,{useContext as _u}from"react";import xu from"classnames";var Ut=Su.createContext({});function y(t,e){let{debug:o,...n}=_u(Ut),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:xu(a,l,o?`${t}__${i}`:!1)}},{}):e}var si={root:"_root_vr71j_1"};import{jsx as bo,jsxs as bu}from"react/jsx-runtime";var Co=()=>bu("svg",{className:si.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[bo("defs",{children:bo("style",{children:".cls-1 { fill: #b3b3b3; }"})}),bo("title",{children:"Failed loading image"}),bo("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 is={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 lt}from"react/jsx-runtime";var wo=wu(is),ku=({title:t,src:e})=>{let o=ls(wo),[n,s]=Eu(!1);return Tu(()=>{s(!1)},[e]),lt("div",{className:o.imageWrapper,children:e&&!n?lt("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):lt(Co,{})})},Ru=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=ls(wo);return lt("div",{className:as(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Iu=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=ls(wo);return Cu.createElement(t,{className:as(r.title,o,{[r.contentIsCropped]:e}),...s},n)},To=({children:t})=>{let e=y("Card",is);return lt("div",{className:as(e.root),children:lt(wo.Provider,{value:e,children:t})})};To.Image=ku;To.Content=Ru;To.Title=Iu;var B=To;import Pu from"classnames";var ri={root:"_root_cq1yq_1"};import{jsx as Mu}from"react/jsx-runtime";var Au={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Lu=({className:t,keyCode:e,...o})=>{let n=y("KeyboardHint",ri);return Mu("span",{"data-key":Au[e],className:Pu(t,n.root),...o})},cs=Lu;import Nu from"classnames";var ii={root:"_root_4a08n_1"};import{jsx as Du}from"react/jsx-runtime";var Ou=({className:t,children:e,...o})=>{let n=y("Label",ii);return Du("span",{...o,className:Nu(t,n.root),children:e})},ps=Ou;var ai={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};import{jsx as us,jsxs as Bu}from"react/jsx-runtime";var Hu=({title:t,children:e,type:o,...n})=>{let s=y("Section",ai);return Bu("section",{...n,className:s.root,"data-section-type":o,children:[t&&us("div",{className:s.subTitleContainer,children:us("span",{className:s.subtitle,children:t})}),us("div",{className:s.suggestions,children:e})]})},je=Hu;import Fu from"classnames";import Ku from"react";var li={root:"_root_19wxp_1"};import{jsx as zu}from"react/jsx-runtime";var Uu=Ku.forwardRef(({className:t,children:e},o)=>{let n=y("SectionList",li);return zu("div",{ref:o,className:Fu(n.root,t),children:e})}),ds=Uu;import Eo from"classnames";import ju,{createContext as qu,useCallback as Vu,useContext as zt}from"react";var gs={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 ye,jsxs as Qu}from"react/jsx-runtime";var ct=qu(gs),Wu=({fixed:t,children:e,...o})=>{let n=zt(ct);return ye("div",{...o,className:Eo(n.actions,{[n.actionsIsFixed]:t}),children:e})},Gu=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=zt(ct);return Qu("div",{className:Eo(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,ye("ul",{className:r.dropdownList,children:s})]})},$u=({index:t,label:e,onClick:o})=>{let n=zt(ct);return ye("li",{className:n.dropdownItem,children:ye("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Xu=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=zt(ct);return ye("button",{type:"button",className:Eo(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},ms=({labels:t})=>{let e=zt(ct);return ye("div",{className:e.labels,children:t.map(o=>ye("span",{className:e.label,children:o},o))})},pt=ju.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=y("Suggestion",gs),l=Vu(c=>{c.preventDefault(),o&&o(c)},[o]);return ye(s,{...r,ref:i,className:Eo(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:ye(ct.Provider,{value:a,children:n})})});pt.Labels=ms;pt.Actions=Wu;pt.ActionButton=Xu;pt.DropdownButton=Gu;pt.DropdownItem=$u;var N=pt;import Zu from"classnames";var ci={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};import{jsx as Yu}from"react/jsx-runtime";var Ju=({withDivider:t,children:e})=>{let o=y("SuggestionList",ci);return Yu("div",{"data-testid":"suggestions-overlay-list",className:Zu(o.root,{[o.isWithDivider]:t}),children:e})},re=Ju;import ed from"classnames";var pi={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};import{jsx as fs}from"react/jsx-runtime";var td=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",pi);return fs("button",{type:"button",className:ed(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:fs("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:fs("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},ut=td;var ui=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,dt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var di=/x-deepdesk-(([a-z0-9\-_])+-version)/,pe=(m=>(m.SEARCH="search",m.TEMPLATE="template",m.ELASTIC_SEARCH="search-autocomplete",m.GPT="gpt",m.TRIE="trie",m.TRIE_WITH_TYPOS="trie-with-typos",m.SEMANTIC="semantic",m.TEXT_RECOMMENDATION="text_recommendation",m.URL_RECOMMENDATION="url_recommendation",m.LINK_RECOMMENDATION="link_recommendation",m.PERSONAL_COLLECTION="personal-collection",m.PERSONAL_COLLECTION_SEARCH="personal-collection-search",m.SEARCH_OVERLAY="search-overlay",m.SEARCH_PREVIEW="search-preview",m.SEARCH_URL="search-url",m))(pe||{}),qe=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(qe||{});import{render as Kt,unmountComponentAtNode as ts}from"react-dom";import{Fragment as Of}from"react";import{createSlice as od}from"@reduxjs/toolkit";import{useSelector as nd}from"react-redux";var ko=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(ko||{});var sd={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,floatingMenu:!1,adminUrl:void 0,productName:"Deepdesk"},gi=od({name:"settings",initialState:sd,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:jt}=gi.actions,hs=t=>e=>e.settings[t],C=t=>nd(hs(t)),mi=gi.reducer;import{useState as xm}from"react";import{useDispatch as bm,useSelector as lr}from"react-redux";import{createAction as Ve,createSlice as dd}from"@reduxjs/toolkit";import{diffChars as gd}from"diff";import{useSelector as md}from"react-redux";function fi(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Pe(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)=>Pe(r,e[i],o-1)):fi(t)&&fi(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Pe(t[i],e[i],o-1)):!1}function rd(t){return Math.max(...t.map(e=>e.length))}function id(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 hi(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<rd(n);s++){let r=id(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 ad=2;function ys(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=hi(t,ad);return o&&o.text!==e?o:t[0]}import{createAction as ld,createAsyncThunk as gt,createSlice as cd}from"@reduxjs/toolkit";var yi={current:null,isSupported:null},R=ld("resetConversation"),Ro=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Io=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},mt=t=>t.conversation.isSupported,vs=gt("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Po=gt("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Ao=gt("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Lo=gt("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Io(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),Ss=gt("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})})}),Mo=gt("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Io(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),pd=[Po.rejected,Ao.rejected,Lo.rejected,Mo.rejected].map(t=>t==null?void 0:t.toString()),ud=cd({name:"conversation",initialState:yi,reducers:{},extraReducers:t=>{t.addCase(vs.fulfilled,(e,o)=>{e.isSupported=o.payload}).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)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Ss.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)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Mo.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(R,()=>yi).addMatcher(e=>pd.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),vi=ud.reducer;var Ae={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 Do=Ve("input/replaceText"),Ho=Ve("input/keyDown"),We=Ve("input/sendMessage"),Bo=Ve("input/sendEditSuggestionMessage"),Fo=Ve("input/uiInputChange"),Ko=Ve("input/applyImageSuggestion"),q=Ve("input/sendEvent");function No(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 Si=t=>dd({name:t,initialState:Ae,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,{...Ae,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=ys(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(Pe(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&No(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:g,altKey:f}=e.previousKeyDownEvent;switch(p){case"Enter":u&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:m}=e,{text:v}=o.payload,T=gd(m,v);m.length-v.length>1&&e.metrics.deletions.push(...T.filter(h=>h.removed).map(h=>h.value)),e.metrics.numCharsDeleted+=m.length-v.length;break}case"C":case"V":case"X":if(!d&&!g){e.metrics.numCharsTyped+=1;let m=((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;m&&m.length>0&&(e.metrics.numCharsDeleted+=m.length,e.metrics.deletions.push(m))}break;case"Shift":break;default:if(!d&&!g&&!f){e.metrics.numCharsTyped+=1;let m=((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;m&&m.length>0&&(e.metrics.numCharsDeleted+=m.length,e.metrics.deletions.push(m))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=Ae.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&No(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"&&No(e)},commitSuggestion(e){No(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=ys(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=Ae.tabCompletionSuggestion,o.previousKeyDownEvent=Ae.previousKeyDownEvent,o.textSuggestions=Ae.textSuggestions,o.selectedSuggestionIndex=Ae.selectedSuggestionIndex,o.metrics=Ae.metrics})}}),_s=Si("input"),ft=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),fd=t=>t.input.selection,_i=()=>md(fd),{userInput:xi,changeSelection:xs,initialInput:bi,mergeMetrics:Ci,nextTextSuggestionIndex:wi,offeredTextSuggestion:Ti,previousTextSuggestionIndex:Ei,registerCut:ki,registerKeyDown:Ri,registerPaste:Ii,reset:Pi,resetToCommitted:qt,platformInput:Ai,setSelectedTextSuggestionIndex:Le,setTextSuggestions:ue,stageSuggestion:ie,commitSuggestion:Me}=_s.actions,Q=Si("overlay");import{useEffect as Mi,useRef as Ni}from"react";var Li={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};import{jsx as Oi}from"react/jsx-runtime";var hd=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=Ni(null),l=Ni(null),c=y("Dialog",Li);return Mi(()=>{var d,g;let p=f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),s())},u=f=>{let m=window.getSelection();m!=null&&m.toString()||f.target===a.current&&t&&n()};return(d=a.current)==null||d.addEventListener("click",u),(g=a.current)==null||g.addEventListener("keyup",p),()=>{var f,m;(f=a.current)==null||f.removeEventListener("click",u),(m=a.current)==null||m.removeEventListener("keyup",p)}},[a,l,s,n]),Mi(()=>{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?Oi("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:Oi("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},ht=hd;import{useEffect as qa}from"react";import{useDispatch as om,useSelector as nm}from"react-redux";var bs={};j(bs,{enUS:()=>yd,nlNL:()=>vd});var yd={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?"}]},vd={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 Di={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 Pd,useContext as Ad}from"react";var Cs=function(t,e){return Cs=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])},Cs(t,e)};function Vt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Cs(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var te=function(){return te=Object.assign||function(e){for(var o,n=1,s=arguments.length;n<s;n++){o=arguments[n];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},te.apply(this,arguments)};function Hi(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 Uo(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 zo;(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"})(zo||(zo={}));var jo=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var ae;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(ae||(ae={}));var qo;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(qo||(qo={}));function ws(t){return t.type===ae.literal}function Bi(t){return t.type===ae.argument}function Vo(t){return t.type===ae.number}function Wo(t){return t.type===ae.date}function Go(t){return t.type===ae.time}function $o(t){return t.type===ae.select}function Xo(t){return t.type===ae.plural}function Fi(t){return t.type===ae.pound}function Qo(t){return t.type===ae.tag}function Zo(t){return!!(t&&typeof t=="object"&&t.type===qo.number)}function Wt(t){return!!(t&&typeof t=="object"&&t.type===qo.dateTime)}function Ts(t){t.forEach(function(e){if(delete e.location,$o(e)||Xo(e))for(var o in e.options)delete e.options[o].location,Ts(e.options[o].value);else Vo(e)&&Zo(e.style)||(Wo(e)||Go(e))&&Wt(e.style)?delete e.style.location:Qo(e)&&Ts(e.children)})}function Ki(t,e){e===void 0&&(e={}),e=te({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new jo(t,e).parse();if(o.err){var n=SyntaxError(zo[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||Ts(o.val),o.val}function Jo(t,e){var o=e&&e.cache?e.cache:wd,n=e&&e.serializer?e.serializer:Cd,s=e&&e.strategy?e.strategy:_d;return s(t,{cache:o,serializer:n})}function Sd(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Ui(t,e,o,n){var s=Sd(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function zi(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 Es(t,e,o,n,s){return o.bind(e,t,n,s)}function _d(t,e){var o=t.length===1?Ui:zi;return Es(t,this,o,e.cache.create(),e.serializer)}function xd(t,e){return Es(t,this,zi,e.cache.create(),e.serializer)}function bd(t,e){return Es(t,this,Ui,e.cache.create(),e.serializer)}var Cd=function(){return JSON.stringify(arguments)};function ks(){this.cache=Object.create(null)}ks.prototype.get=function(t){return this.cache[t]};ks.prototype.set=function(t,e){this.cache[t]=e};var wd={create:function(){return new ks}},Yo={variadic:xd,monadic:bd};var Ge;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Ge||(Ge={}));var Gt=function(t){Vt(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 Rs=function(t){Vt(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}(Gt);var ji=function(t){Vt(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}(Gt);var qi=function(t){Vt(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}(Gt);var V;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(V||(V={}));function Td(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==V.literal||o.type!==V.literal?e.push(o):n.value+=o.value,e},[])}function Ed(t){return typeof t=="function"}function $t(t,e,o,n,s,r,i){if(t.length===1&&ws(t[0]))return[{type:V.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(ws(p)){a.push({type:V.literal,value:p.value});continue}if(Fi(p)){typeof r=="number"&&a.push({type:V.literal,value:o.getNumberFormat(e).format(r)});continue}var u=p.value;if(!(s&&u in s))throw new qi(u,i);var d=s[u];if(Bi(p)){(!d||typeof d=="string"||typeof d=="number")&&(d=typeof d=="string"||typeof d=="number"?String(d):""),a.push({type:typeof d=="string"?V.literal:V.object,value:d});continue}if(Wo(p)){var g=typeof p.style=="string"?n.date[p.style]:Wt(p.style)?p.style.parsedOptions:void 0;a.push({type:V.literal,value:o.getDateTimeFormat(e,g).format(d)});continue}if(Go(p)){var g=typeof p.style=="string"?n.time[p.style]:Wt(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:V.literal,value:o.getDateTimeFormat(e,g).format(d)});continue}if(Vo(p)){var g=typeof p.style=="string"?n.number[p.style]:Zo(p.style)?p.style.parsedOptions:void 0;g&&g.scale&&(d=d*(g.scale||1)),a.push({type:V.literal,value:o.getNumberFormat(e,g).format(d)});continue}if(Qo(p)){var f=p.children,m=p.value,v=s[m];if(!Ed(v))throw new ji(m,"function",i);var T=$t(f,e,o,n,s,r),h=v(T.map(function(S){return S.value}));Array.isArray(h)||(h=[h]),a.push.apply(a,h.map(function(S){return{type:typeof S=="string"?V.literal:V.object,value:S}}))}if($o(p)){var x=p.options[d]||p.options.other;if(!x)throw new Rs(p.value,d,Object.keys(p.options),i);a.push.apply(a,$t(x.value,e,o,n,s));continue}if(Xo(p)){var x=p.options["=".concat(d)];if(!x){if(!Intl.PluralRules)throw new Gt(`Intl.PluralRules is not available in this environment.
2
2
  Try polyfilling it using "@formatjs/intl-pluralrules"
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 Rs(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 hd(a)}function Sd(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 vd(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Sd(t[n],e[n]),o},ee({},t)):t}function Is(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function _d(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Jo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,Uo([void 0],o,!1)))},{cache:Is(t.number),strategy:Yo.variadic}),getDateTimeFormat:Jo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,Uo([void 0],o,!1)))},{cache:Is(t.dateTime),strategy:Yo.variadic}),getPluralRules:Jo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,Uo([void 0],o,!1)))},{cache:Is(t.pluralRules),strategy:Yo.variadic})}}var Ui=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,g){return!d.length||g.type!==j.literal||typeof d[d.length-1]!="string"?d.push(g.value):d[d.length-1]+=g.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=Mi(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=vd(t.formats,n),this.formatters=s&&s.formatters||_d(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=Di,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 Cd(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var wd="dummy",Ps=xd(null);function T(t){let e=bd(Ps);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=Cd(o,n);return r?new Ui(r).format(s):(e!==wd&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}import{jsx as zi,jsxs as Td}from"react/jsx-runtime";var en=()=>Td("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[zi("title",{id:"angleLeftTitle",children:"AngleLeft"}),zi("path",{d:"M192 448c-8.188 0-16.38-3.125-22.62-9.375l-160-160c-12.5-12.5-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L77.25 256l137.4 137.4c12.5 12.5 12.5 32.75 0 45.25C208.4 444.9 200.2 448 192 448z"})]});import{jsx as ji,jsxs as Ed}from"react/jsx-runtime";var qi=()=>Ed("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[ji("title",{id:"angleRightTitle",children:"AngleRight"}),ji("path",{d:"M64 448c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L178.8 256L41.38 118.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l160 160c12.5 12.5 12.5 32.75 0 45.25l-160 160C80.38 444.9 72.19 448 64 448z"})]});import{useEffect as Xt,useRef as Ks,useState as Qd}from"react";import{useDispatch as Zd}from"react-redux";import{Interweave as ca}from"interweave";import pa from"classnames";var As={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 Pd}from"interweave";import Ad from"classnames";import{useEffect as kd,useRef as Rd,useState as Id}from"react";function Vi(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function tn(t){let e=Rd(null),[o,n]=Id(!1);return kd(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=Vi((p,u)=>{let d=e.current;if(!d)return;let g=p/r,f=u/r,m=d.getBoundingClientRect(),v=g>m.x&&g<m.x+m.width&&f>m.y&&f<m.y+m.height;v&&!s?(s=!0,n(!0)):!v&&s&&(s=!1,n(!1))},({clientX:p,clientY:u})=>[p,u]),[l,c]=Vi(()=>{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 Se={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 Wi}from"react/jsx-runtime";var Ld=({inputElement:t,children:e})=>{let o=S("TabCompletion",Se),[n,s]=tn(t);return Wi("mark",{ref:n,className:Ad(o.matchPlaceholder,{[o.hover]:s}),children:e})},ft=class extends Pd{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 Wi(Ld,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import{useEffect as Md,useRef as Od,useState as Nd}from"react";function on(t){return t.contentEditable==="true"}function Dd(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 Gi(t){let{selectionStart:e,selectionEnd:o}=on(t)?Dd(t):t;return[e,o]}function nn(t){let[,e]=Nd(),o=Od(null);return o.current=Gi(t),Md(()=>{let n=()=>{let[s,r]=o.current??[],i=Gi(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 sn(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 Hd}from"react";function ht(t){Hd(()=>{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 $i,de=new Map,Bd=["bottom","height","left","right","top","width"],Fd=(t={},e={})=>Bd.some(o=>t[o]!==e[o]);function Xi(t){var o,n;let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...Xi(e)]:[]}function Qi(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var rn=!1,Zi=()=>{rn=!0;let t=[];if(de.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),de.delete(o);return}let n=o.getBoundingClientRect();Fd(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(Qi,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),de.size===0){rn=!1;return}$i=window.requestAnimationFrame(Zi)};function Ls(t,e){let o=Xi(t),n=[],s=o.map((r,i)=>Ls(r,a=>{n[i]=a;let l=de.get(t);if(!l)return;let c=n.reduce(Qi,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&&!rn&&Zi()},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($i),rn=!1)}}}}var Ji,ge=new Map,Yi=()=>{ge.forEach((t,e)=>{if(!e.isConnected){ge.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)))}),ge.size!==0&&(Ji=window.requestAnimationFrame(Yi))};function ea(t,e){return{observe(){let o=ge.size===0;ge.has(t)?ge.get(t).callbacks.push(e):ge.set(t,{visible:void 0,callbacks:[e]}),o&&Yi()},unobserve(){let o=ge.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||ge.delete(t),ge.size||cancelAnimationFrame(Ji)}}}}var Ms=["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 Os(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function yt(t){return parseFloat(t)}function an(t){return Math.round(t*1e6)}function ta(t){return t/1e6}function Ns(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=ta(an(s)-an(r)-an(i)),c=ta(an(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};Os(n,o,Ms),Ns(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=ea(t,()=>{Os(n,o,Ms),Ns(n,t,o),r(),setTimeout(r,0)}),a=Ls(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(Os(n,o,Ms),Ns(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),g=yt(u.borderBottomWidth),f=p.top+d-c.top,m=c.top+c.height+-(p.top+p.height-g);o.style.clipPath=`inset(${f}px 0px ${m}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 Ds={};q(Ds,{enUS:()=>Kd,nlNL:()=>Ud});var Kd={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"}]},Ud={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 oa,jsxs as zd}from"react/jsx-runtime";var na=()=>zd("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[oa("title",{id:"circleCheckTitle",children:"Check"}),oa("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 sa}from"react/jsx-runtime";var ra=()=>sa("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:sa("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 jd(t){let e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!n}function ln(t){return t?t instanceof ShadowRoot?ln(t.host):t===t.ownerDocument.body?t.ownerDocument:jd(t)?t:ln(t.parentNode):document.body}var ia=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(ia||{}),Oe=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();Pe(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(ia).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=ln(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 Ne=class extends Oe{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){let e=this.getSelection();return e?this.getText().slice(e.start,e.end):""}getCaretPosition(){return null}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let o=this.element.disabled,n=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>n.disconnect())}};var qd=/[.*+?^${}()|[\]\\]/g,Vd=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function Wd(t){return t.replace(qd,"\\$&")}function Gd(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function $d(t){return t.search(Vd)}function aa(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${Wd(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function la(t){return t.replace(pt,'<mark data-type="placeholder">$1</mark>')}function $t(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Xd(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 Hs(t,e,o={}){if(e){let n=Gd(e.toLowerCase(),t.toLowerCase()),s=$t(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=$d(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(ai).length>3||e.length>30?Xd(e.trim(),n):0;return`${`${i>0?"\u2026":""}${$t(t.substring(i,n))}`}<strong>${s}</strong>`}return t}function Bs(t){return/<\/?[a-z][\s\S]*>/i.test(t)}function cn(t){if(Bs(t)){let o=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(t);return o?o[1]:""}return t}import{jsx as ae,jsxs as Fs}from"react/jsx-runtime";var Jd=({value:t,onUse:e,...o})=>{var u;let n=T(Ds),s=Zd(),r=Bs(t),i=S("EditSuggestionTextInput",As),[a,l]=Qd(null),c=Ks(null),p=((u=t.match(pt))==null?void 0:u.length)||0;return Xt(()=>{let d;return c.current&&(l(c.current),d=new Ne(c.current),d.on("change",({plainText:g})=>{s($.actions.userInput({text:g,selection:d.getSelection()}))}),d.on("keydown",g=>{s($.actions.registerKeyDown(No(g))),g.code==="Enter"&&g.shiftKey&&e(d.getText())}),d.on("paste",({pastedText:g,selectionText:f})=>{s($.actions.registerPaste({text:g,selectionText:f}))}),d.on("cut",({selectionText:g})=>{s($.actions.registerCut(g))})),()=>{s($.actions.reset()),d.dispose(),d.deactivate()}},[c]),Xt(()=>{t&&c.current&&(c.current.value=t)},[t,c]),Xt(()=>{c.current&&setTimeout(()=>{if(!c.current)return;let d=c.current.value.length;c.current.setSelectionRange(d,d),c.current.focus()},0)},[c]),r?ae("div",{className:i.textInputWrapper,children:ae(ca,{className:i.textInput,tagName:"div",content:t})}):Fs("div",{className:i.textInputWrapper,children:[ae("textarea",{...o,ref:c,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:t,onChange:()=>{}}),a&&ae(Yd,{inputElement:c.current,value:t}),Fs("div",{className:pa(i.alert,p===0?i.success:i.warning),children:[ae("div",{className:i.alertText,children:n("placeholders",{placeholderSize:p})}),p===0?ae(na,{}):ae(ra,{})]})]})},Yd=({inputElement:t,value:e})=>{let o=S("EditSuggestionTextInput",As),n=Ks(null),s=nn(t);return Xt(()=>{sn(t,s)},[s,t]),ae(eg,{inputElement:t,children:Fs("div",{ref:n,className:pa(o.root,o.agentText),children:[ae(ca,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new ft("placeholders")],inputElement:t,boundaryRef:n}),ae("br",{})]})})},eg=({inputElement:t,children:e})=>{let o=Ks(null);return Xt(()=>{if(!o.current)return()=>{};let[n,s]=St(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),ae("div",{ref:o,children:e})},ua=Jd;import{useEffect as jg,useState as qg,useRef as Vg}from"react";import{useState as ng}from"react";import Us 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:()=>tg,nlNL:()=>og});var tg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},og={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 Qt,jsxs as rg}from"react/jsx-runtime";var sg=({src:t,title:e})=>{let o=S("CommandPalette",X),[n,s]=ng("loading"),r=T(Xe);return rg("div",{className:o.image,children:[Qt("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:Us(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&Qt("span",{className:Us(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&Qt("span",{className:Us(o.imageSrc,o.imageSrcStatus),children:Qt(Co,{})}),e&&Qt("span",{className:o.imageTitle,children:e})]})},da=sg;import ig from"react";import ag from"classnames";import{jsx as ga,jsxs as lg}from"react/jsx-runtime";function zs({children:t,heading:e,orientation:o}){let n=S("CommandPalette",X);return ig.Children.count(t)===0?null:lg("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&ga("h4",{className:n.listHeading,children:e}),ga("div",{className:ag(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}import dn from"classnames";import js from"react";import{jsx as cg}from"react/jsx-runtime";var ma=js.createContext(void 0);function De(){let t=js.useContext(ma);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var fa=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=js.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return cg(ma.Provider,{value:i,children:t})};import pg,{useState as ha,useEffect as ya,useMemo as ug,useRef as Sa,useCallback as dg,useContext as gg}from"react";import mg from"classnames";var qs={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 pn,jsxs as Sg}from"react/jsx-runtime";var fg=0,va=pg.createContext(null),hg=()=>{let t=gg(va);if(!t)throw new Error("Invalid DropdownContext");return t},_a=({trigger:t,children:e,position:o="bottom"})=>{let n=ug(()=>++fg,[]),s=Sa(null),r=Sa(null),i=S("Dropdown",qs),[a,l]=ha(!1),[c,p]=ha(o),u=g=>{g.preventDefault(),g.stopPropagation(),l(!a)},d=dg(([g])=>{!g.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return ya(()=>{let g=f=>{s.current&&!s.current.contains(f.target)&&l(!1)};return document.addEventListener("click",g),()=>{document.removeEventListener("click",g)}},[]),ya(()=>{if(!r.current&&!a)return()=>{};let g=new IntersectionObserver(d,{root:null,rootMargin:"0px",threshold:1});return r.current&&g.observe(r.current),()=>{r.current&&g.unobserve(r.current)}},[r,a]),pn(va.Provider,{value:{setIsOpen:l},children:Sg("div",{ref:s,className:i.root,children:[pn("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}),pn("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:mg(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function yg({as:t,children:e,onClick:o,...n}){let s=t||"button",r=S("Dropdown",qs),{setIsOpen:i}=hg(),a=l=>{i(!1),o(l),l.stopPropagation()};return pn(s,{type:"button",className:r.item,onClick:a,...n,children:e})}_a.Item=yg;var Vs=_a;import{jsx as xa}from"react/jsx-runtime";var ba=t=>xa("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:xa("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:()=>vg,nlNL:()=>_g});var vg={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"}]},_g={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 Ws}from"react/jsx-runtime";var xg="%0d%0a%0d%0a%0d%0a",bg=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(xg)}`},Cg=({suggestion:t,onFeedback:e})=>{let o=T(Qe),n=b("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:Ws(Vs,{trigger:Ws(ba,{"data-testid":"feedback-dropdown-trigger"}),children:Ws(Vs.Item,{as:"a",href:bg(n,t),onClick:e,children:o("giveFeedback")})})},un=Cg;import{Interweave as wg}from"interweave";import{jsx as He,jsxs as Gs}from"react/jsx-runtime";function $s({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:g}=De(),f=S("CommandPalette",X);function m(v){n(v),t&&g(!1)}return Gs("div",{className:dn(f.listItem,u===i&&f.listItemSelected),children:[He("button",{onMouseEnter:()=>d(i),type:"button",className:dn("command-palette-list-item",f.listItemAction,f.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:m,...p,children:Gs("div",{className:f.listItemContent,children:[typeof o=="string"?He("p",{className:dn(f.listItemText,f.truncate,c==null?void 0:c.title),children:o}):o,a&&He(wg,{tagName:"p",allowList:[],content:cn(a),className:dn(f.listItemDescription,c==null?void 0:c.description,e?f.lineClamp:f.truncate)})]})}),s&&u===i&&He("div",{className:f.listItemActions,children:He(un,{suggestion:String(o),onFeedback:s})}),l&&Gs("div",{className:f.sources,children:[He("span",{className:f.sourcesTitle,children:"Sources"}),l.map(v=>v.url?He("a",{className:f.source,href:v.url,target:"_blank",title:v.url,rel:"noopener noreferrer",onClick:()=>r&&r(v),children:v.name},v.url):He("span",{className:f.source,children:v.name},v.name))]})]})}import{jsx as Ca,jsxs as Xs}from"react/jsx-runtime";function Qs({children:t,title:e,id:o,onDismiss:n}){let s=T(Xe),r=S("CommandPalette",X),{page:i}=De();return i!==o?null:Xs("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&Xs("div",{className:r.pageNav,children:[Xs("button",{className:r.pageBackButton,type:"button",onClick:n,children:[Ca(en,{}),s("back")]}),e&&Ca("h3",{className:r.pageTitle,children:e})]}),t]})}import{Fragment as Ng,useCallback as Dg,useEffect as Hg,useRef as Bg}from"react";var gn=()=>/Mac/i.test(navigator.platform);import{createAsyncThunk as Ig,createSlice as Pg}from"@reduxjs/toolkit";var Tg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},E=Tg;import{createAsyncThunk as Js,createSlice as kg}from"@reduxjs/toolkit";function Eg(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,[Eg(o)]:A(t[o])}),{}):t}function Zs(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,[Zs(o)]:B(t[o])}),{}):t}var Rg={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Jt=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)||""}},Zt=Js("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))}),Ys=Js("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}),er=Js("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),wa=t=>t.info.agentInfo,Ta=kg({name:"info",initialState:Rg,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Zt.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Zt.rejected,e=>{e.fetchState="error"}).addCase(Zt.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(Ys.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(er.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(R,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Ea}=Ta.actions,ka=Ta.reducer;var mn={list:[],fetchState:"idle",isOpen:!1,page:"search"},Ra=t=>t.search.isOpen,Ia=t=>t.search.page,Pa=t=>t.search.list;function Aa(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Ze=Ig("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:Jt(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),La=Pg({name:"search",initialState:mn,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=mn.fetchState,t.list=mn.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,()=>mn)}}),{resetSearch:fn,setIsOpen:te,setPage:V}=La.actions,Ma=La.reducer;var Ag=/(https?:\/\/[^\s]+)/,hn=t=>t.split(" ").find(e=>Ag.test(e));import Oa from"classnames";import{jsx as Mg,jsxs as Og}from"react/jsx-runtime";var Lg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=S("CommandPalette",X);return Og("button",{type:"button",...n,onClick:t,className:Oa(s.actionButton,n.className),children:[o,e&&e.map(r=>Mg("span",{className:Oa(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},vt=Lg;import{jsx as yn,jsxs as tr}from"react/jsx-runtime";var Fg=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=S("CommandPalette",X),a=T(Xe),{selected:l,setSelected:c}=De(),p=r[l],u=p&&typeof p.text=="string"&&hn(p.text),d=Bg(null);function g(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 m=()=>{u&&window.open(u,"_blank")},v=()=>{p&&n(p,l)},w=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},h=Dg(y=>{if(y.key==="Enter"&&y.altKey&&u){m();return}if(y.key==="Enter"&&y.shiftKey){w();return}if(y.key==="ArrowDown"){y.preventDefault(),y.stopPropagation(),g("down");return}if(y.key==="ArrowUp"){y.preventDefault(),y.stopPropagation(),g("up");return}y.key==="Enter"&&l!==-1&&(y.preventDefault(),y.stopPropagation(),f())},[l]);return Hg(()=>(window.addEventListener("keyup",h),()=>{window.removeEventListener("keyup",h)}),[h]),tr("div",{className:i.actions,children:[yn("div",{className:i.actionsWrapper,ref:d,children:t}),tr("div",{className:i.actionsBar,children:[u&&yn(vt,{onClick:m,shortKeys:[gn()?8997:"ALT",8629],children:a("visitUrl")}),p&&tr(Ng,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&yn(vt,{onClick:w,shortKeys:[8679,8629],children:o}),yn(vt,{onClick:v,shortKeys:[8629],children:e})]})]})]})},Da=Fg;import{forwardRef as Ug}from"react";import{jsx as Ha,jsxs as Kg}from"react/jsx-runtime";var _t=()=>Kg("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[Ha("path",{d:"M0 0h24v24H0z",fill:"none"}),Ha("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 or}from"react/jsx-runtime";function zg({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=S("CommandPalette",X);return or("div",{className:l.search,children:[xt("div",{className:l.searchIcon,children:xt(_t,{})}),or("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:or("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 Ba=Ug(zg);import{jsx as Fa,jsxs as Wg}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[g,f]=qg(0),m=Vg(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=m.current)==null||h.focus();return}if(d.length>0){r("");return}a(!1)};return jg(()=>{f(0)},[d,n]),Fa(mt,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:w,onClose:v,children:Wg(fa,{selected:g,setSelected:f,isOpen:u,onChangeOpen:a,page:n,children:[n===o&&Fa(Ba,{ref:m,onChange:r,onChangeType:i,placeholder:t,value:d,selectedType:l,types:c,typePlaceholder:e}),p]})})}Je.Page=Qs;Je.List=zs;Je.Image=da;Je.ListItem=$s;Je.ActionsBar=Da;Je.Button=vt;var I=Je;import{jsx as ve,jsxs as Yt}from"react/jsx-runtime";var Xg=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=S("EditSuggestionForm",Li),l=Gg(),c=T(bs),p=$g(f=>f.overlayInput.text);Ka(()=>{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(Bo(f)),e(f)},g=f=>m=>{p!==i?window.confirm(c("warning"))&&f(m):f(m)};return Ka(()=>{n&&n(p!==i)},[n,t,p]),Yt("div",{className:a.root,children:[Yt("div",{className:a.content,children:[t.title&&ve("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&ve(ms,{labels:t.searchKeywords}),ve(ua,{onUse:d,value:cn(p)})]}),Yt("form",{className:a.actions,onSubmit:u,children:[Yt("div",{children:[ve("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&g(r),children:ve(en,{})}),ve("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&g(s),children:ve(qi,{})})]}),Yt("div",{className:a.primaryButtons,children:[ve(I.Button,{onClick:g(o),shortKeys:["esc"],children:c("dismiss")}),ve(I.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},Sn=Xg;import{createAction as Jg,createAsyncThunk as qa,createSlice as Yg}from"@reduxjs/toolkit";var Qg=["{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}"],Zg=new RegExp(Qg.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Ua(t,e){let o=t.split(Zg),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 za(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Va={suggestions:[],fetchState:"idle",isInitialRequest:null},ja={default:Va},Wa=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)||[]},Ga=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},$a=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,Xa=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},vn=Jg("textSuggestions/refresh"),_e=qa("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,Jt(n),t);if(t==="default"){let p=i?l.filter(Xa(a)):l;e.dispatch(ue(p.slice(0,r)))}return l}),eo=qa("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,{...Jt(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(Xa(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?Ua(p.text,t):p.text}))),l=za(l,r),e.dispatch(ue(l)),l}),Qa=Yg({name:"textSuggestions",initialState:ja,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]||Va;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(eo.pending,e=>{e.default.fetchState="loading"}).addCase(eo.rejected,e=>{e.default.fetchState="error"}).addCase(eo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(R,()=>ja)}}),{setTextSuggestions:Za,setSuggestionState:Ja}=Qa.actions,Ya=Qa.reducer;import{createSlice as em}from"@reduxjs/toolkit";var el={contentType:null,suggestion:null},tl=t=>t.activeSuggestion.suggestion,ol=t=>t.activeSuggestion.contentType,nl=em({name:"activeSuggestion",initialState:el,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,()=>el)}}),{setActiveSuggestion:xe,resetActiveSuggestion:nr}=nl.actions,sl=nl.reducer;var sr={};q(sr,{enUS:()=>tm,nlNL:()=>om});var tm={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"}]},om={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 nm}from"@reduxjs/toolkit";var sm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var _n=({ui:t})=>t.overlayCollapsed;var rl=nm({name:"ui",initialState:sm,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputHasFocus(t,e){t.overlayCollapsedUserOverwrite!==!0&&(e.payload===!0&&(t.overlayCollapsed=!1),t.inputHasFocus=e.payload)},setOverlayCollapsed(t,e){e.payload.collapse===!1&&(t.openOverlayWhenTyping=!1),!(e.payload.skipWhenInputFocus&&t.inputHasFocus)&&(t.overlayCollapsed=e.payload.collapse)},setOpenOverlayWhenTyping(t,e){t.openOverlayWhenTyping=e.payload},setOverlayCollapsedUserOverwrite(t,e){t.overlayCollapsedUserOverwrite=e.payload,t.overlayCollapsed=e.payload}}}),{setShowTabHint:to,setInputHasFocus:Ct,setOverlayCollapsed:Be,setOpenOverlayWhenTyping:il,setOverlayCollapsedUserOverwrite:al}=rl.actions,ll=rl.reducer;import cl,{useContext as rm}from"react";import{jsx as im}from"react/jsx-runtime";var pl=cl.createContext(null),wt=({broadcastEvents:t,children:e})=>{let o=cl.useMemo(()=>t,[]);return im(pl.Provider,{value:o,children:e})},ne=()=>{let t=rm(pl);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import{createAsyncThunk as rr,createSlice as am}from"@reduxjs/toolkit";var lm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},le=t=>t.auth.isLoggedIn,ul=t=>t.auth.loginFetchState,dl=t=>t.auth.verifyFetchState,gl=t=>t.auth.showLoginOverlay,be=rr("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),ml=rr("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),oo=rr("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),fl=am({name:"auth",initialState:lm,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(oo.pending,e=>{e.verifyFetchState="loading"}),t.addCase(oo.rejected,e=>{e.verifyFetchState="error"}),t.addCase(oo.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Tt,setShowLoginOverlay:hl}=fl.actions,yl=fl.reducer;var ir="SetActiveSuggestion",Et="ShowLoginOverlay",no="UserLoggedIn",cm="UserLoggedOut",Ce="ApplySuggestion",ar="ApplyImageSuggestion",pm="ShowCommandPalette",um=t=>({[ir]:e=>{t.dispatch(Ja(e.state)),t.dispatch(xe({contentType:e.contentType,suggestion:e.suggestion}))},[pm]:e=>{t.dispatch(te(e.isOpen)),e.page&&t.dispatch(V(e.page))},[Et]:e=>{t.dispatch(hl(e))},[no]:()=>{t.dispatch(be())},[cm]:()=>{t.dispatch(be())},[ar]:e=>{t.dispatch(Ko({suggestion:e.suggestion}))},[Ce]:e=>{t.dispatch(re({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(Me())}}),Sl=um;import{jsx as vl}from"react/jsx-runtime";var mm=()=>{var f;let[t,e]=dm(!1),o=lr(tl),n=lr(ol),s=lr(bt),r=gm(),i=ne(),a=T(sr),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(nr()),r(Ct(!0)),r($.actions.reset())},p=(m,v)=>{r(nr()),r(Ct(!0)),i.send(Ce,{text:m,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]})),g=u===s[n].suggestions.length-1||u===null?void 0:()=>r(xe({contentType:n,suggestion:s[n].suggestions[u+1]}));return vl(mt,{autoFocus:!0,isOpen:u!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:vl(Sn,{onTouched:e,onDismiss:c,onUse:m=>p(m,o),suggestion:o,onNext:g,onPrevious:d})})},_l=mm;import{useSelector as Tl}from"react-redux";import pr from"classnames";import{useCallback as Cl,useEffect as _m,useMemo as xm,useState as ur}from"react";import{useDispatch as bm,useSelector as Cm}from"react-redux";import fm from"classnames";var xl={root:"_root_1ukx5_1"};import{jsx as ym}from"react/jsx-runtime";var hm=({className:t,value:e,...o})=>{let n=S("TextInput",xl);return ym("input",{className:fm(t,n.root),type:"text",value:e,...o})},so=hm;var cr={};q(cr,{enUS:()=>Sm,nlNL:()=>vm});var Sm={back:[{type:0,value:"Back"}],promptTitle:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Paste the code from your email"}],verifyCodeBody:[{type:0,value:"Copy the code from the email you just received and paste it here."}],verifyCodeInputPlaceholder:[{type:0,value:"Paste link or code here"}],verifyCodeSubmitLabel:[{type:0,value:"Sign in"}],verifyCodeError:[{type:0,value:"Sign in failed. The code is probably no longer valid. Please "},{type:8,value:"login",children:[{type:0,value:"request new code"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Have a code sent to your email"}],requestCodeBody:[{type:0,value:"Enter your email and request a code. If you are an existing "},{type:1,value:"productName"},{type:0,value:" user you will receive an email with a code. If you are a new user you will receive an email asking to request access to "},{type:1,value:"productName"},{type:0,value:" first."}],requestCodeInputPlaceholder:[{type:0,value:"Enter your email"}],requestCodeSubmitLabel:[{type:0,value:"Request code"}]},vm={back:[{type:0,value:"Terug"}],promptTitle:[{type:0,value:"Login bij "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Plak de code uit je email"}],verifyCodeBody:[{type:0,value:"Kopieer de code uit de email en plak deze hier."}],verifyCodeInputPlaceholder:[{type:0,value:"Plak hier de code"}],verifyCodeSubmitLabel:[{type:0,value:"Inloggen"}],verifyCodeError:[{type:0,value:"Inloggen is niet gelukt. De code is waarschijnlijk niet meer geldig. "},{type:8,value:"login",children:[{type:0,value:"Vraag een nieuwe code aan"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Verstuur een login code naar je email"}],requestCodeBody:[{type:0,value:"Voer je e-mailadres in en krijg een login code. Als je een bestaande "},{type:1,value:"productName"},{type:0,value:" gebruiker bent krijg je een email met een code. Als je een nieuwe gebruiker bent wordt er een email verstuurd met een toegangsverzoek voor "},{type:1,value:"productName"},{type:0,value:"."}],requestCodeInputPlaceholder:[{type:0,value:"Typ hier je e-mailadres"}],requestCodeSubmitLabel:[{type:0,value:"Code aanvragen"}]};var bl={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 xn}from"react/jsx-runtime";var wm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Tm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=T(cr),i=S("LoginTokenDialog",bl),a=Cm(dl),l=bm(),c=b("productName"),[p,u]=ur(t||""),[d,g]=ur(0),[f,m]=ur(""),v=Cl(async x=>{x.preventDefault(),l(ml({email:p})),g(1)},[o,p]),w=()=>{m(""),g(0)},h=Cl(async x=>{x.preventDefault();let C=wm(x.target.elements.token.value);if(!C){m(r("verifyCodeError",{login:y}));return}l(oo({token:C}))},[o]),y=xm(()=>x=>Q("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:x},"back-button"),[]);return _m(()=>{a==="error"&&m(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:xn("div",{className:i.root,children:[Q("h1",{className:i.title,children:r("promptTitle",{productName:c})}),d===0&&xn("form",{onSubmit:v,children:[Q("h2",{className:i.subtitle,children:r("requestCodeTitle")}),Q("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),Q(so,{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:pr(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),d===1&&xn("form",{onSubmit:h,children:[Q("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),Q("p",{className:i.text,children:r("verifyCodeBody")}),Q(so,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&Q("div",{className:i.errorMessage,children:f}),xn("div",{className:i.actions,children:[Q("button",{type:"button",className:pr(i.button),onClick:w,children:r("back")}),Q("button",{type:"submit",className:pr(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},wl=Tm;import{jsx as km}from"react/jsx-runtime";var Em=()=>{let t=Tl(gl),e=Tl(wa),o=b("adminUrl"),n=ne(),s=()=>n.send(Et,!1),r=()=>{n.send(Et,!1),n.send(no)};return km(wl,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},El=Em;import vf from"lodash.debounce";import{useCallback as En,useEffect as vr,useState as lo}from"react";import{useDispatch as _f,useSelector as At}from"react-redux";import{createAsyncThunk as Rm,createSlice as Im}from"@reduxjs/toolkit";var Pm={data:null,fetchState:"idle"},kl=t=>t.contentTypes.data,ro=Rm("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Am=Im({name:"contentTypes",initialState:Pm,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})}}),Rl=Am.reducer;function io(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 Lm}from"react";function Il(t,e){Lm(()=>{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 Ml,useRef as Fm}from"react";import{useSelector as Km,useDispatch as Um}from"react-redux";import{createAsyncThunk as Mm,createSlice as Om}from"@reduxjs/toolkit";var Pl={data:null,fetchState:"idle"},bn=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},ce=Mm("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)}),Nm=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Dm=Om({name:"entities",initialState:Pl,reducers:{},extraReducers:t=>{t.addCase(ce.pending,e=>{e.fetchState="loading"}).addCase(ce.rejected,e=>{e.fetchState="error"}).addCase(ce.fulfilled,(e,o)=>{e.fetchState="done",e.data=Nm(e.data?[...e.data,...o.payload]:o.payload)}).addCase(R,()=>Pl)}}),Al=Dm.reducer;var dr={};q(dr,{enUS:()=>Hm,nlNL:()=>Bm});var Hm={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Bm={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Ll={root:"_root_17kae_1",empty:"_empty_17kae_5"};import{jsx as Cn,jsxs as jm}from"react/jsx-runtime";var zm=({onCopy:t,onUse:e})=>{let o=Fm(null),n=S("EntitiesList",Ll),s=T(dr),r=Km(bn),i=Um();return Ml(()=>{i(ce())},[]),Ml(()=>{o.current&&o.current.focus()},[o]),jm("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&Cn(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:Cn(I.List,{children:r.map((a,l)=>Cn(I.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&Cn("p",{className:n.empty,children:s("noResults")})]})},Ol=zm;import{Fragment as Xm,useEffect as wn,useRef as Qm,useState as Zm}from"react";import{useSelector as Kl,useDispatch as Jm}from"react-redux";import{createAsyncThunk as qm,createSlice as Vm}from"@reduxjs/toolkit";var Nl={data:null,fetchState:"idle"},Dl=t=>t.summary.data,Hl=t=>t.summary.fetchState==="error",we=qm("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})}}),Wm=Vm({name:"summary",initialState:Nl,reducers:{},extraReducers:t=>{t.addCase(we.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(we.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(we.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(R,()=>Nl)}}),Bl=Wm.reducer;var gr={};q(gr,{enUS:()=>Gm,nlNL:()=>$m});var Gm={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."}]},$m={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 Fl={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 ef}from"react/jsx-runtime";var Ym=({onCopy:t})=>{let e=Qm(null),o=S("SummaryForm",Fl),[n,s]=Zm(""),r=T(gr),i=Kl(Dl),a=Kl(Hl),l=Jm(),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 wn(()=>{l(we())},[]),wn(()=>{s(i||"")},[i]),wn(()=>{e.current&&i&&e.current.focus()},[e,i]),wn(()=>{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")}):ef(Xm,{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")})})]})})},Ul=Ym;var mr={};q(mr,{enUS:()=>tf,nlNL:()=>of});var tf={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?"}]},of={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 uf,{useEffect as yr,useRef as df}from"react";import{useDispatch as gf,useSelector as $l}from"react-redux";var fr={};q(fr,{enUS:()=>nf,nlNL:()=>sf});var nf={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"}]},sf={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 zl={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 rf,createAsyncThunk as af,createSlice as lf}from"@reduxjs/toolkit";var hr={data:[],fetchState:"idle"},jl=t=>{var e;return(e=t.answer)==null?void 0:e.data},ql=t=>t.answer.fetchState,It=rf("answer/resetKnowledgeSearch"),Rt=af("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}}),cf=lf({name:"answer",initialState:hr,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,()=>hr).addCase(It,()=>hr)}}),Vl=cf.reducer;import{jsx as Wl,jsxs as pf}from"react/jsx-runtime";var Gl=()=>pf("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[Wl("title",{id:"paperPlaneTitle",children:"PaperPlane"}),Wl("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 Te,jsxs as Sr}from"react/jsx-runtime";var mf=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=uf.useState(""),{setSelected:i}=De(),a=df(null),l=S("EntitiesList",zl),c=T(fr),p=gf(),u=$l(jl),d=$l(ql),g=async m=>{m.preventDefault(),m.stopPropagation(),s!==""&&p(Rt({question:s,promptInstruction:n}))},f=(m,v)=>{p(z({name:"knowledge assist source viewed",data:{question:v,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return yr(()=>{var m;o&&d==="idle"?p(Rt({question:o,promptInstruction:n})):(m=a.current)==null||m.focus()},[a,d]),yr(()=>{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]),yr(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,u]),Sr("div",{className:l.root,children:[u.length>0&&Te("div",{className:l.alignRight,children:Te(I.Button,{onClick:e,children:c("reset")})}),Sr(I.ActionsBar,{list:u.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:m=>t(m.text),children:[u.map(({question:m,answer:v},w)=>Te(I.List,{children:Te(I.ListItem,{"data-testid":"knowledge-search-answer",index:w,description:v.answer,closeOnSelect:!0,onClick:()=>t(v.answer),onSourceClick:h=>f(h,m),sources:v.sources,styles:{title:l.question,description:l.answer},children:m})},`${v.answer}_${w}`)),d==="loading"&&Te("p",{className:l.status,children:c("loading")}),d==="error"&&Te("p",{className:l.status,children:c("error")}),Sr("form",{className:l.form,onSubmit:g,children:[Te("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:m=>{i(-1),r(m.target.value)}}),Te("button",{type:"submit",className:l.submit,children:Te(Gl,{})})]})]})]})},Xl=mf;import{createAsyncThunk as ff,createSlice as hf}from"@reduxjs/toolkit";var yf={data:null,fetchState:"idle"},Pt=t=>t.profile.data,Tn=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],ao=ff("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)}),Sf=hf({name:"profile",initialState:yf,reducers:{},extraReducers:t=>{t.addCase(ao.pending,e=>{e.fetchState="loading"}).addCase(ao.rejected,e=>{e.fetchState="error"}).addCase(ao.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Ql=Sf.reducer;import{jsx as Z,jsxs as Jl}from"react/jsx-runtime";var xf=200,bf=5,Cf=4,wf=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Zl=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Tf=()=>{let t=_f(),e=ne(),o=T(mr),[n,s]=lo(!1),[r,i]=lo(""),a=At(Ia),l=At(Pt),[c,p]=lo(null),[u,d]=lo([]),[g,f]=lo(),m=At(le),v=b("showSearch"),w=b("showEntitiesCommand"),h=b("showSummaryCommand"),y=b("showKnowledgeSearch"),x=b("showImageSearch"),C=b("searchTriggerKey"),F=At(kl),D=At(Pa),Y=At(Ra),H=_=>rs(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&&Zl(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(V("summary")),shouldShow:h&&Zl(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})))||[],ns=En(vf((_,P)=>{t(Ze({query:_,type:P,tags:["search-overlay"]}))},xf),[]),ze=wf([...G,...k]),Jp=En((_,P)=>{if(!P)return;let Ie=[...k,...G].find(({value:rt})=>rt===P);Ie&&(t(V("edit")),p({..._,searchTerm:void 0}),d(Ie.list))},[t,c,G]),ss=En((_,P)=>{switch(P.type){case"IMAGE":e.send(ar,{suggestion:P});break;default:e.send(Ce,{text:_,suggestion:P})}t(te(!1))},[t]),Yp=_=>{io(_.text),t(z({name:"entity copied",data:{entity:_,type:"copy"}})),t(te(!1))},eu=En(_=>{t(z({name:"suggestion feedback",data:{text:_.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),tu=_=>{e.send(Ce,{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))},ou=_=>{io(_),t(te(!1))},nu=_=>{e.send(Ce,{text:_.text,suggestion:{source:"entity",text:_.text}}),t(te(!1))},su=c===null||u.indexOf(c)-1<0?void 0:()=>p(u[u.indexOf(c)-1]),ru=c===null||u.indexOf(c)===u.length-1?void 0:()=>p(u[u.indexOf(c)+1]);function rs(_,P){return _.slice(0,g?10:P.toLowerCase()==="image"?Cf:bf)}function Yr(_,P,Ie){return P.reduce((rt,xo)=>Ie&&g===Ie?xo.length+rt:rs(xo,Ie).length+rt,_)}function st(_){return P=>{n?window.confirm(o("warning"))&&(_(P),s(!1)):_(P)}}return vr(()=>{r?ns(r,g):t(fn())},[r,g]),vr(()=>{a==="search"&&t(It())},[a]),vr(()=>{m&&t(ro())},[m]),Il(C,()=>t(te(!0))),!v||!l?null:Jl(I,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:st(_=>t(te(_))),onChangeType:_=>f(_),onChangePage:st(_=>t(V(_))),selectedType:g,search:r,page:a,isOpen:Y,types:[...G,...k],children:[Z(I.Page,{id:"search",children:Jl(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)=>ss(_,ze[P]),onSecondary:(_,P)=>{Jp(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:Yr(P,[],"commands"),closeOnSelect:!1,onClick:_.onClick,children:_.label},_.label))}),[...G,...k].map(({value:_,label:P,list:Ie,lineClamp:rt,listOrientation:xo},iu)=>Z(I.List,{heading:P,orientation:xo==="horizontal"?"horizontal":"vertical",children:rs(Ie,_).map((oe,au)=>Z(I.ListItem,{index:Yr(O.length+au,[...G,...k].slice(0,iu).map(({list:lu})=>lu),_),closeOnSelect:!1,lineClamp:rt,onClick:()=>ss(oe.text,oe),description:_!=="IMAGE"?oe.title&&oe.text:void 0,onFeedback:_!=="IMAGE"?()=>eu(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(Sn,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(V("search")),p(null),d([])},onNext:ru,onPrevious:su,onUse:_=>{t(V("search")),ss(_,{...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(Ol,{onUse:nu,onCopy:Yp})}),Z(I.Page,{id:"summary",title:o("summaryTitle"),onDismiss:st(()=>{t(V("search"))}),children:Z(Ul,{onCopy:ou})}),Z(I.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:st(()=>{t(It()),t(V("search"))}),children:Z(Xl,{promptInstruction:l.knowledgeAssistPromptInstruction,question:r,onUse:tu,onResetQuestion:()=>{t(It()),i("")}})})]})},Yl=Tf;import{jsx as _r,jsxs as Rf}from"react/jsx-runtime";var kf=()=>{let t=b("showSearch"),e=b("isEmbedded");return Rf(Ef,{children:[t&&_r(Yl,{}),_r(_l,{}),e&&_r(El,{})]})},ec=kf;import{connect as Vf,useDispatch as Wf,useSelector as In}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 zf,useMemo as jf}from"react";import{Interweave as Af}from"interweave";import{useEffect as Lf,useMemo as Mf,useRef as Of}from"react";import{useDispatch as Nf,useSelector as Df}from"react-redux";import{useEffect as If}from"react";function tc(t,e,o){If(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var oc={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};import{jsx as kn,jsxs as Uf}from"react/jsx-runtime";var Hf=["search","personal-collection-search","search-autocomplete"];function Bf(t,e,o,n={}){let s="";return Hf.includes(e)?s=aa(Hs(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=Hs(t,o,n),n.placeholders===!0&&(s=la(s)),s}var Ff=()=>{},Kf=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=b("inlineSuggestions"),r=Df(gt),i=Nf(),a=S("TextSuggestion",oc),l=Of(null);Lf(()=>{let p=setTimeout(()=>{i(xi({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),tc(l,"click",()=>{i(Le(t)),i(re({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=Mf(()=>Bf(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:Uf("div",{className:a.root,onMouseEnter:()=>i(Le(t)),children:[kn(M,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:Ff,children:kn(Af,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&kn("div",{className:a.actions,children:kn(un,{onFeedback:()=>n(o),suggestion:o.text})})]})},nc=Kf;import{jsx as sc}from"react/jsx-runtime";var qf=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=jf(()=>{let r=e.map((i,a)=>sc(nc,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return sc(zf,{children:s})},Rn=qf;var rc={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};import{jsx as Pn}from"react/jsx-runtime";var Gf=({textSuggestions:t,selectedIndex:e})=>{let o=S("InlineSuggestionsOverlay",rc),n=In(Lt),s=Wf(),r=In(le),i=In(dt),a=In(_n),l=b("showTextSuggestions");return ht(()=>{s(Be({collapse:!0,skipWhenInputFocus:!0}))}),a||!n||!l||t.length===0||r!==!0||i===!1?null:Pn("div",{className:o.root,"data-variant":"inline",children:Pn("div",{className:o.paper,children:Pn(se,{children:Pn(Rn,{suggestions:t,selectedIndex:e})})})})},$f=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),ic=Vf($f)(Gf);import Tr from"classnames";import{useEffect as ih,useRef as ah,useState as lh}from"react";import{connect as ch,useDispatch as ph,useSelector as co}from"react-redux";import{useState as Xf}from"react";function ac(t,e){let[o,n]=Xf(()=>{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 Jf from"classnames";import{Fragment as Yf,useCallback as br,useMemo as cc}from"react";var xr={};q(xr,{enUS:()=>Qf,nlNL:()=>Zf});var Qf={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"}]}]},Zf={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 lc={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};import{jsx as An,jsxs as pc}from"react/jsx-runtime";var Cr=(t,e,o)=>n=>An("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),eh=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n})=>{let s=T(xr),r=ne(),i=S("Login",lc),a=b("productName"),l=br(m=>{m.preventDefault(),n&&n(parseInt(m.target.value,10))},[]),c=br(m=>{m.preventDefault(),r.send(Et,!0)},[e]),p=cc(()=>m=>An("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:m},"login"),[e]),u=br(m=>An("button",{type:"button",className:i.anchorButton,onClick:c,children:m},"prompt"),[c]),{min:d,hour:g,day:f}=cc(()=>({min:Cr(i,60*10,l),hour:Cr(i,60*60,l),day:Cr(i,60*60*12,l)}),[]);return pc("div",{className:Jf(t,i.root),children:[s("loginPlease",{login:o?u:p,productName:a}),n&&pc(Yf,{children:[An("br",{}),s("snooze",{min:d,hour:g,day:f})]})]})},Ln=eh;import{useDispatch as th}from"react-redux";var uc={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};import{jsx as dc,jsxs as nh}from"react/jsx-runtime";var oh=({title:t})=>{let e=S("SearchTrigger",uc),o=th();return nh("button",{type:"button",className:e.root,onClick:()=>o(te(!0)),children:[dc(_t,{}),dc("span",{className:e.text,children:t})]})},gc=oh;var wr={};q(wr,{enUS:()=>sh,nlNL:()=>rh});var sh={arrowHint:[{type:0,value:"Tip: use arrow keys to navigate suggestions"}],searchHintWindows:[{type:0,value:"Press CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" to search"}],searchHintMac:[{type:0,value:"Press CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" to search"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Close"}],search:[{type:0,value:"Search"}]},rh={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 mc={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 po}from"react/jsx-runtime";var uh=({textSuggestions:t,selectedIndex:e})=>{let o=S("SuggestionsOverlay",mc),n=T(wr),s=co(Lt),r=hi(),i=ph(),a=ah(null),l=b("searchTriggerKey"),c=b("productName"),p=co(_n),u=co(le),d=co(dt),[g,f]=lh(null),m=b("showSearch"),v=b("showTextSuggestions"),w=b("adminUrl"),h=b("isEmbedded"),[y,x]=ac("dd-snooze-until-ms",0),C=p||y>Date.now(),F=co(O=>O.input.text),D=t.filter(O=>O.source!=="gpt").length,Y=()=>{C&&x(0),i(al(!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(Be({collapse:!0}))};return ih(()=>{D===0&&f(null)},[t,D]),ht(()=>{i(Be({collapse:!0,skipWhenInputFocus:!0}))}),u===null||d===!1?null:u===!1?po("div",{ref:a,className:Tr(o.root,{[o.isCollapsed]:C}),children:[!C&&po("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(Ln,{loginUrl:w,isEmbedded:h,onSnooze:k})})]}):!r||!s?null:po("div",{ref:a,className:Tr(o.root,{[o.isCollapsed]:C}),children:[!C&&po("div",{className:o.triggers,children:[U("div",{style:{flex:1},children:m&&U("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(n(gn()?"searchHintMac":"searchHintWindows",{searchTriggerKey:l.toUpperCase()})),onMouseLeave:()=>f(null),children:U(gc,{title:n("search")})})}),po("div",{className:o.triggersRight,onFocus:()=>{},children:[U("div",{className:Tr(!g&&o.hintsHidden,o.hints),children:g}),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(Rn,{onFeedback:H,suggestions:t,selectedIndex:e,reverse:!0})})})]})},dh=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),fc=ch(dh)(uh);import{Provider as gh}from"react-redux";import{jsx as Mn}from"react/jsx-runtime";var mh=({children:t})=>{let o=b("locale").replace("-","");return Mn(Ps.Provider,{value:o,children:t})},fh=({store:t,customStyles:e={},children:o})=>Mn(gh,{store:t,children:Mn(mh,{children:Mn(Kt.Provider,{value:e,children:o})})}),Mt=fh;import Dr from"classnames";import{Interweave as oy}from"interweave";import{useCallback as ny,useEffect as sy,useMemo as Nc,useRef as ry}from"react";import{connect as iy}from"react-redux";import{cloneElement as hh}from"react";var yh=["div","span","mark","strong","b","i","u","em"];function Er(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(yh.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),hh(n,{children:Er(i,e,o+1)})]}return[...t,...e]}function Fe(t){return t.tagName.toLowerCase()==="textarea"}var hc={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 Dh,useMemo as Hh}from"react";function yc(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function On(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function Sc(t){return t!=null}import Cc from"classnames";import{createRef as kh,useCallback as Rr,useMemo as Rh,useRef as Ih,useState as Ph}from"react";import{useState as Sh,useLayoutEffect as vh}from"react";var _h=["bottom","height","left","right","top","width"],xh=(t={},e={})=>_h.some(o=>t[o]!==e[o]),Ee=new Map,vc,_c=()=>{let t=[],e=[];Ee.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();xh(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Ee.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),vc=window.requestAnimationFrame(_c)};function bh(t,e){return{observe(){let o=Ee.size===0;if(Ee.has(t)){let n=Ee.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Ee.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&_c()},unobserve(){let o=Ee.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Ee.delete(t),Ee.size||cancelAnimationFrame(vc)}}}}function kr(t){let[e,o]=Sh(null);return vh(()=>{if(!t.current)return;let n=bh(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}import{useContext as Ch,useLayoutEffect as wh,useState as Th}from"react";import{createPortal as Eh}from"react-dom";var xc={root:"_root_1jq08_1"};var bc=({children:t})=>{let[e,o]=Th(null),n=Ch(Kt);return wh(()=>{let s=document.createElement("div");return $e(s),s.classList.add(xc.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?Eh(t,e):null};var me={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 Ir}from"react/jsx-runtime";var Nn=(t=!1)=>{let[e,o]=Ph(t),n=Rr(()=>o(!0),[]),s=Rr(()=>o(!1),[]),r=Rr(()=>o(a=>!a),[]),i=Ih(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function Pr(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 Dn=({className:t,triggerRef:e,boundaryRef:o=kh(),position:n="above",align:s="center",children:r,toStyle:i=Pr,...a})=>{let l=kr(e),c=kr(o),p=Rh(()=>i(l,c,0),[l,c]);return Ir(bc,{children:Ir("div",{className:Cc(me.ref,{[me.positionAbove]:n==="above",[me.positionBelow]:n==="below",[me.positionLeft]:n==="left",[me.positionRight]:n==="right",[me.alignStart]:s==="start",[me.alignCenter]:s==="center",[me.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:Ir("div",{className:Cc(t,me.root),children:r})})})};import Ah from"classnames";import{forwardRef as Lh,useRef as Mh}from"react";import{jsx as wc}from"react/jsx-runtime";var Hn=Lh(({className:t,children:e,...o},n)=>{let s=Mh(null),r=S("TabCompletion",Se);return wc("div",{ref:On([s,n]),className:Ah(t,r.popoverContentContainer),...o,children:wc("div",{className:r.popoverContent,children:e})})});import{jsx as uo,jsxs as Kh}from"react/jsx-runtime";var Bh=t=>e=>{let o=Pr(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Fh=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=S("TabCompletion",Se),i=Nn(),a=Hh(()=>Bh(t.getBoundingClientRect()),[t]),[l,c]=tn(t);return Dh(()=>{c?i.open():i.close()},[c]),Kh("span",{children:[uo("mark",{ref:On([l,i.triggerRef]),className:Oh(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&uo(Dn,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:uo(Hn,{style:o,children:uo("div",{className:r.hintText,children:s})})})]})},Bn=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${yc(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(Sc);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 uo(Fh,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import Nr from"classnames";import{Matcher as Xh}from"interweave";import{createRef as Qh,forwardRef as Zh,useCallback as Jh,useEffect as Lc,useRef as Mc,useState as Oc}from"react";import{useDispatch as Yh}from"react-redux";import{jsx as Tc}from"react/jsx-runtime";var Ec=()=>Tc("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:Tc("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 Uh,useEffect as Rc,useState as Ic}from"react";import{useDispatch as zh,useSelector as Pc}from"react-redux";import jh from"lodash.debounce";var kc={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Fn(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 Ar(t){return t.replace("https://www.","").replace("https://","")}import{jsx as Ye,jsxs as Lr}from"react/jsx-runtime";var qh=3,Vh=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Wh=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=qh})=>{let r=S("LinkSearch",kc),[i,a]=Ic(""),l=zh(),c=Pc(Wa("url")),p=Pc(Aa("URL",Vh)),[u,d]=Ic(p.length-1),g=b("fallbackImage"),f=h=>{let y=h.target;a(y.value)},m=(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=Uh(jh(h=>{l(Ze({query:h,type:"URL",tags:["link-search"]}))},300),[]);return Rc(()=>{i&&w(i)},[i]),Rc(()=>()=>{l(fn())},[]),Lr("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:Lr(N,{children:[Ye(N.Image,{src:Fn(h,"small",g||void 0),title:h.title||h.text}),Lr(N.Content,{className:r.content,cropText:!0,children:[Ye(N.Title,{children:h.title||Ar(h.text)}),h.title&&Ar(h.text)]}),Ye(M.Actions,{children:Ye(M.ActionButton,{label:n,onClick:x=>m(x,h.text)})})]})},h.text))}),Ye(so,{value:i,onChange:f,autoFocus:!0,placeholder:o,onKeyUp:v})]})},Ac=Wh;var Mr={};q(Mr,{enUS:()=>Gh,nlNL:()=>$h});var Gh={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},$h={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};import{jsx as fe,jsxs as Or}from"react/jsx-runtime";var ey=Zh((t,e)=>{let o=S("TabCompletion",Se);return fe("mark",{ref:e,className:Nr(o.matchSelection)},"selection-start")}),ty=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=T(Mr),i=S("TabCompletion",Se),a=Mc(null),l=Mc(null),[c,p]=Oc(null),u=Yh(),d=Nn(document.activeElement===n),[g]=Oc(()=>document.createRange());d.triggerRef.current=g,Lc(()=>()=>g.detach(),[]),Lc(()=>{let m=t.current,v=a.current;!m||!v||(g.setStart(m,0),g.setEnd(v,0))},[t.current,a.current]),ht(()=>{d.close()});let f=Jh(m=>{let v=g.toString(),w=/^http(s?):\/\//.test(m)?m:`https://${m}`;u(Do({text:`[${v}](${w})`,replace:"selection"}))},[]);return Or("span",{children:[fe("mark",{ref:a,className:Nr(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:s}),d.opened&&fe(Dn,{className:i.popoverRoot,triggerRef:d.triggerRef,boundaryRef:e,position:"above",align:"start",children:Or(Hn,{style:o,ref:l,children:[fe("div",{className:Nr(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:Or("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[fe(Ec,{}),fe("span",{children:"\xA0"}),fe("span",{children:r("insertLink")})]})}),c==="insertLink"&&fe(Ac,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:f,onDismiss:()=>{p(null),d.close()}})]})})]},"selection-end")},Kn=class extends Xh{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=Qh(),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?fe(ey,{ref:this.startRef}):fe(ty,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};import{jsx as Ot,jsxs as cy}from"react/jsx-runtime";var ay=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=S("TabCompletion",hc),p=b("insertLink"),u=b("showMidSentenceSuggestions"),d=b("inlineSuggestions"),g=nn(a),f=ry(null);sy(()=>{Fe(a)&&g&&sn(a,g)},[g]);let m=ny(h=>{if(!s||!o)return h;let y=[Ot("span",{className:c.resetIndent,children:"\u200B"},"u200B"),Ot("span",{"data-testid":"tab-completion",className:Dr(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&y.push(Ot("span",{className:Dr(c.hint,c.resetIndent),children:Ot(cs,{keyCode:"tab"},"tabHint")})),Er(h,y)},[s,o,n]),v=Nc(()=>{let h=[];return p&&h.push(new Kn("selection")),h.push(new ft("placeholders")),r&&h.push(new Bn("keywords")),h},[d,p,r]),w=Nc(()=>{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?cy("div",{ref:h=>{h!=null&&h.parentElement&&(f.current=h==null?void 0:h.parentElement)},className:c.root,style:w,children:[Ot(oy,{tagName:"span",containerTagName:"div",className:Dr(c.container,c.agentText),disableLineBreaks:Fe(a),content:e||"\u200B",onAfterParse:m,matchers:v,selection:g,keywordMatches:i,inputElement:a,inputStyle:w,boundaryRef:f,inlineSuggestionsOnlyAtEnd:!u}),Ot("br",{})]}):null},ly=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var m;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??$t(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:u}=s,{showTabCompletion:d,visible:g,showStyleSuggestions:f}=o;return{showTabHint:p,showStyleSuggestions:f,showTabCompletion:d,content:l,tabText:c,source:a,keywordMatches:((m=n.list)==null?void 0:m.keywordMatches)??[],enabled:g&&u!==!1}},Dc=iy(ly)(ay);import qy from"classnames";import{useEffect as Vy}from"react";import{useDispatch as Wy,useSelector as J}from"react-redux";import{createAsyncThunk as go,createSlice as py}from"@reduxjs/toolkit";var Hc={list:[],fetchState:"idle",isInitialRequest:null},Fc=t=>t.autoflows.list||[],Bc=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},ke=go("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Hr=go("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(ke(t.platformSessionId))}),Br=go("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(ke(t.platformSessionId))}),uy=py({name:"autoflows",initialState:Hc,reducers:{},extraReducers:t=>{t.addCase(Hr.pending,(e,o)=>{let n=Bc(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Br.pending,(e,o)=>{let n=Bc(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(ke.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(ke.rejected,e=>{e.fetchState="error"}),t.addCase(ke.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(R,()=>Hc)}}),Kc=go("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(ke(t))}),s.on("sessionCompleted",()=>{o(ke(t))})}),Uc=go("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),zc=uy.reducer;import{createAsyncThunk as fo,createSlice as dy}from"@reduxjs/toolkit";var jc={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},qc=t=>t.customMessages.list,Vc=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Wc=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Gc=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),mo=fo("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),Un=fo("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)}),zn=fo("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)}),$c=dy({name:"customMessages",initialState:jc,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(mo.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(mo.rejected,e=>{e.fetchState="error"}).addCase(mo.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(Un.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(Un.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(zn.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(zn.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,()=>jc)}}),Xc=fo("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($c.actions.onCustomMessage(r))})}),Qc=fo("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Zc=$c.reducer;import{createAsyncThunk as Jc,createSlice as gy}from"@reduxjs/toolkit";var my={jwt:null,accountUrl:null,interval:null},Yc=t=>e=>{let{exchangeToken:{jwt:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/jwt/?jwt=${o}&redirect=${t}`:null},Fr=Jc("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.getTemporaryExchangeToken();return{accountUrl:o.client.baseUrl,jwt:n}}),Kr=Jc("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:o=1e3*60*30}=t,{dispatch:n}=e;return n(Fr()),setInterval(()=>n(Fr()),o)}),ep=gy({name:"exchangeToken",initialState:my,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Fr.fulfilled,(e,o)=>{e.jwt=o.payload.jwt,e.accountUrl=o.payload.accountUrl}),t.addCase(Kr.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollExchangeToken:tp}=ep.actions,op=ep.reducer;function np(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}import{Fragment as wy}from"react";import{connect as Ty}from"react-redux";import xy from"classnames";import{Fragment as by}from"react";import fy from"classnames";var sp={root:"_root_838fd_1"};import{jsx as yy}from"react/jsx-runtime";var hy=({className:t,children:e})=>{let o=S("Unicode",sp);return yy("span",{className:fy(t,o.root),children:e})},rp=hy;var ip={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 Ur={};q(Ur,{enUS:()=>Sy,nlNL:()=>vy});var Sy={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]},vy={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]};import{jsx as et,jsxs as jn}from"react/jsx-runtime";var Cy=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=S("Autoflow",ip),a=T(Ur),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return jn(M,{className:xy(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[et(N,{children:jn(N.Content,{children:[jn(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:jn(by,{children:[et(rp,{children:c})," ",et("span",{children:a(l)})]})})})]})},ap=Cy;import{jsx as lp}from"react/jsx-runtime";var Ey=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},ky=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>lp(wy,{children:t.map(s=>lp(ap,{displayName:s.displayName,description:s.description,disabled:s.isBusy||Ey(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),Ry=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},Iy={onStartAutoflow:Hr,onStopAutoflow:Br},cp=Ty(Ry,Iy)(ky);import{useEffect as Py,useState as Ay}from"react";import{useDispatch as Ly}from"react-redux";import dp from"classnames";import{jsx as pp}from"react/jsx-runtime";var zr=()=>pp("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:pp("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 up={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 gp}from"react/jsx-runtime";var My=({entities:t})=>{let e=S("EntitiesWidgetList",up),[o,n]=Ay(void 0),s=Ly(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),io(a.text),s(z({name:"entity copied",data:{entity:a,type:"copy"}})))};return Py(()=>{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)=>gp("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[Nt("span",{className:e.entityText,children:a.text}),gp("span",{className:e.iconWrapper,children:[Nt("span",{className:dp(e.icon),children:Nt(zr,{})}),Nt("span",{className:dp(e.icon,o===l&&e.iconClicked),children:Nt(zr,{})})]})]},a.text))})},mp=My;import Oy from"classnames";import{useCallback as fp}from"react";import{useDispatch as Ny,useSelector as qn}from"react-redux";var Re={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 Vn}from"react/jsx-runtime";var Dy=({suggestion:t})=>{let e=T(Qe),o=Ny(),n=qn(Vc(t.text)),s=qn(Wc(t.text)),r=qn(Gc(t.text)),i=qn(Ro),{replyOptions:a}=t,l=fp(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(Un({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=fp(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let u=parseInt(p.target.dataset.index,10),d=a[u];o(zn({platformSessionId:i,reply:d,suggestion:t}))},[t,n,o,i]);return Vn(M,{onClick:l,className:Oy(Re.root,{[Re.isUsed]:n,[Re.hasError]:r}),children:[Ke(N,{children:Vn(N.Content,{children:[Vn(N.Title,{className:Re.title,children:[t.text," ",Ke(ps,{className:Re.label,children:"analyse tool"})," ",r&&Ke("span",{className:Re.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&Ke("ul",{className:Re.quickReplies,children:a.map(p=>Ke("li",{className:Re.quickReply,children:p.title},p.title))})]})}),Vn(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")})]})]})},hp=Dy;import{jsx as yp}from"react/jsx-runtime";var Sp=()=>yp("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:yp("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 Fy}from"react-redux";import{useCallback as Hy}from"react";import{jsx as tt,jsxs as Wn}from"react/jsx-runtime";var By=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var d;let s=t.text||t.url||t.message,r=hn(s),i=T(Qe),a=b("showImages"),l=b("fallbackImage"),c=g=>{g.preventDefault(),g.stopPropagation(),n(s)},p=g=>{g.preventDefault(),g.stopPropagation(),o(t)},u=Hy(g=>{window.open(r,"_blank"),g.stopPropagation(),g.preventDefault()},[r]);return Wn(M,{onClick:c,"data-testid":"edit-suggestion",children:[Wn(N,{children:[a&&t.image&&tt(N.Image,{src:Fn(t,"small",l||void 0),title:t.title}),Wn(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})]})]}),Wn(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")})]})]})},vp=By;import{Fragment as Uy,jsx as _p}from"react/jsx-runtime";var Ky=({contentType:t,lines:e,suggestions:o})=>{let n=ne(),s=Fy(bt),r=a=>{n.send(ir,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(Ce,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return _p(Uy,{children:o.map(a=>_p(vp,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},xp=Ky;var jr={};q(jr,{enUS:()=>zy,nlNL:()=>jy});var zy={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"}]},jy={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 bp={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 Cp}from"react/jsx-runtime";var wp=()=>Cp("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:Cp("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 Tp}from"react/jsx-runtime";var Ep=()=>Tp("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:Tp("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 Gn=(t,e)=>{let o=J(le);Vy(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},Gy=()=>{let t=T(jr),e=Wy(),o=b("isEmbedded"),n=S("Widget",bp),s=b("showAutoflows"),r=b("showCustomMessages"),i=b("showPersonalCollectionLink"),a=b("showSummaryCommand"),l=b("showKnowledgeSearch"),c=b("showSearch"),p=J(Pt),u=J(Tn),d=J(Fc),g=J(bn),f=J(qc),m=J(Io),v=J(dt),w=J(le),h=J(Ro),y=J(np),x=J(bt),C=ne(),F=J($a),D=J(Yc("/admin/personal-collection")),Y=b("adminUrl");if(Gn(()=>(e(mo(h)),e(Xc(h)),()=>{e(Qc(h))}),[e,v,r,h]),Gn(()=>(e(ke(h)),e(Kc(h)),()=>{e(Uc(h))}),[e,v,s,h]),Gn(()=>{u.forEach(({type:k})=>{e(k==="entities"?ce():_e(k))})},[e,v,m,p]),Gn(()=>(e(Kr()),()=>{e(tp())}),[e,v,i,m]),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(Ln,{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:qy(n.root),"data-testid":"widget",children:Dt(ds,{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(Ep,{}),t("linkSummary")]}),l&&Dt("button",{className:n.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[L(wp,{}),t("linkKnowledgeSearch")]}),D&&Dt("a",{className:n.shortcut,target:"_blank",href:D,"data-testid":"shortcut-personal-collection",rel:"noreferrer",children:[L(Sp,{}),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(hp,{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(cp,{})})}),u.map(({type:k,title:O,amount:G,lines:ns})=>{var ze;switch(k){case"entities":return g&&g.length>0&&L(je,{type:k,title:O,"data-testid":`type-${k}`,children:L(mp,{entities:g})},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(xp,{lines:ns,contentType:k,suggestions:x[k].suggestions.slice(0,G)||[]})})},k)}})]})})},kp=Gy;function yo(t){let e=new Range;return e.selectNodeContents(t),e}function Rp(t,e,o){try{return ot(t,e,o),!0}catch{return!1}}function $n(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function Xn(t){return"tagName"in t&&t.tagName==="BR"}var ho=/[\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(ho,""),u=s+p.length,d=e>=s&&e<=u,g=o>=s&&o<=u;if(d){let f=i(c,e-s);f===0&&!g?n.setStartBefore(l):n.setStart(l,f)}g&&(n.setEnd(l,i(c,o-s)),r=!0),s=u;break}case Node.ELEMENT_NODE:{if(Xn(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;$n(l)&&c&&!$n(c)&&!Xn(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}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,collapsed:i}=e,a,l,c=0;function p(u){let d=u===o,g=u===s;switch(u.nodeType){case Node.TEXT_NODE:{let f=u.textContent;d&&(a=c+f.substring(0,n).replace(ho,"").length),g&&(l=c+f.substring(0,r).replace(ho,"").length),c+=f.replace(ho,"").length;break}case Node.ELEMENT_NODE:{let f=u.nextSibling===null;Xn(u)&&!f&&c++;for(let m=0;m<u.childNodes.length;m++){let v=d&&m===n,w=g&&m===r;if(v&&(a=c),w&&(l=c),l!==void 0||((!v||!i)&&p(u.childNodes[m]),g&&m===r-1&&(l=c),l!==void 0))break}!g&&$n(u)&&!f&&c++,g&&(l=c);break}default:break}}if(p(t),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function Zn(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,g=u?r:void 0,f=c.textContent.replace(ho,"");d===0&&g===void 0?a+=f:a+=f.substring(d,g);break}case Node.ELEMENT_NODE:{let d=c.nextSibling===null;i===0&&Xn(c)&&!d&&(a+=`
3
+ `,Ge.MISSING_INTL_API,i);var b=o.getPluralRules(e,{type:p.pluralType}).select(d-(p.offset||0));x=p.options[b]||p.options.other}if(!x)throw new Rs(p.value,d,Object.keys(p.options),i);a.push.apply(a,$t(x.value,e,o,n,s,d-(p.offset||0)));continue}}return Td(a)}function kd(t,e){return e?te(te(te({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=te(te({},t[n]),e[n]||{}),o},{})):t}function Rd(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=kd(t[n],e[n]),o},te({},t)):t}function Is(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Id(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Jo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,Uo([void 0],o,!1)))},{cache:Is(t.number),strategy:Yo.variadic}),getDateTimeFormat:Jo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,Uo([void 0],o,!1)))},{cache:Is(t.dateTime),strategy:Yo.variadic}),getPluralRules:Jo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,Uo([void 0],o,!1)))},{cache:Is(t.pluralRules),strategy:Yo.variadic})}}var Vi=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,g){return!d.length||g.type!==V.literal||typeof d[d.length-1]!="string"?d.push(g.value):d[d.length-1]+=g.value,d},[]);return u.length<=1?u[0]||"":u},this.formatToParts=function(c){return $t(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=Hi(i,["formatters"]);this.ast=t.__parse(e,te(te({},l),{locale:this.resolvedLocale}))}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=Rd(t.formats,n),this.formatters=s&&s.formatters||Id(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=Ki,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 Ld(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var Md="dummy",Ps=Pd(null);function w(t){let e=Ad(Ps);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=Ld(o,n);return r?new Vi(r).format(s):(e!==Md&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}import{jsx as Wi,jsxs as Nd}from"react/jsx-runtime";var en=()=>Nd("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[Wi("title",{id:"angleLeftTitle",children:"AngleLeft"}),Wi("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 Gi,jsxs as Od}from"react/jsx-runtime";var $i=()=>Od("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[Gi("title",{id:"angleRightTitle",children:"AngleRight"}),Gi("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 Qt,useRef as Ks,useState as rg}from"react";import{useDispatch as ig}from"react-redux";import{Interweave as ga}from"interweave";import ma from"classnames";var As={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 Fd}from"interweave";import Kd from"classnames";import{useEffect as Dd,useRef as Hd,useState as Bd}from"react";function Xi(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function tn(t){let e=Hd(null),[o,n]=Bd(!1);return Dd(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=Xi((p,u)=>{let d=e.current;if(!d)return;let g=p/r,f=u/r,m=d.getBoundingClientRect(),v=g>m.x&&g<m.x+m.width&&f>m.y&&f<m.y+m.height;v&&!s?(s=!0,n(!0)):!v&&s&&(s=!1,n(!1))},({clientX:p,clientY:u})=>[p,u]),[l,c]=Xi(()=>{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 ve={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 Ud=({inputElement:t,children:e})=>{let o=y("TabCompletion",ve),[n,s]=tn(t);return Qi("mark",{ref:n,className:Kd(o.matchPlaceholder,{[o.hover]:s}),children:e})},yt=class extends Fd{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(Ud,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import{useEffect as zd,useRef as jd,useState as qd}from"react";function on(t){return t.contentEditable==="true"}function Vd(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 Zi(t){let{selectionStart:e,selectionEnd:o}=on(t)?Vd(t):t;return[e,o]}function nn(t){let[,e]=qd(),o=jd(null);return o.current=Zi(t),zd(()=>{let n=()=>{let[s,r]=o.current??[],i=Zi(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 sn(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(dt);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 Wd}from"react";function vt(t){Wd(()=>{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 Ji,de=new Map,Gd=["bottom","height","left","right","top","width"],$d=(t={},e={})=>Gd.some(o=>t[o]!==e[o]);function Yi(t){var o,n;let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...Yi(e)]:[]}function ea(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var rn=!1,ta=()=>{rn=!0;let t=[];if(de.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),de.delete(o);return}let n=o.getBoundingClientRect();$d(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(ea,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),de.size===0){rn=!1;return}Ji=window.requestAnimationFrame(ta)};function Ls(t,e){let o=Yi(t),n=[],s=o.map((r,i)=>Ls(r,a=>{n[i]=a;let l=de.get(t);if(!l)return;let c=n.reduce(ea,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&&!rn&&ta()},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(Ji),rn=!1)}}}}var oa,ge=new Map,na=()=>{ge.forEach((t,e)=>{if(!e.isConnected){ge.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)))}),ge.size!==0&&(oa=window.requestAnimationFrame(na))};function sa(t,e){return{observe(){let o=ge.size===0;ge.has(t)?ge.get(t).callbacks.push(e):ge.set(t,{visible:void 0,callbacks:[e]}),o&&na()},unobserve(){let o=ge.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||ge.delete(t),ge.size||cancelAnimationFrame(oa)}}}}var Ms=["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 Ns(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function St(t){return parseFloat(t)}function an(t){return Math.round(t*1e6)}function ra(t){return t/1e6}function Os(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=St(t.width),r=St(t.borderLeftWidth),i=St(t.borderRightWidth),a=St(t.paddingRight),l=ra(an(s)-an(r)-an(i)),c=ra(an(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function _t(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};Ns(n,o,Ms),Os(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=sa(t,()=>{Ns(n,o,Ms),Os(n,t,o),r(),setTimeout(r,0)}),a=Ls(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(Ns(n,o,Ms),Os(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=St(u.borderTopWidth),g=St(u.borderBottomWidth),f=p.top+d-c.top,m=c.top+c.height+-(p.top+p.height-g);o.style.clipPath=`inset(${f}px 0px ${m}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 Ds={};j(Ds,{enUS:()=>Xd,nlNL:()=>Qd});var Xd={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"}]},Qd={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 ia,jsxs as Zd}from"react/jsx-runtime";var aa=()=>Zd("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[ia("title",{id:"circleCheckTitle",children:"Check"}),ia("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 la}from"react/jsx-runtime";var ca=()=>la("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:la("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 Jd(t){let e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!n}function ln(t){return t?t instanceof ShadowRoot?ln(t.host):t===t.ownerDocument.body?t.ownerDocument:Jd(t)?t:ln(t.parentNode):document.body}var pa=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(pa||{}),Ne=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentCaret=null;currentSelection={start:0,end:0};currentHTML="";isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(e,o){let n=s=>{o(s)};this.element.addEventListener(e,n),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,n)})}removeEventListener(e,o){this.element.removeEventListener(e,o)}triggerChange(){let e=this.getText(),o=this.getHTML(),n=e!==this.currentText;this.isActive&&(e===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&n&&!this.isSubmitting&&this.emit("change",{plainText:e}),n&&(this.currentSelection=this.getSelection()),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==o||o===null&&n)&&(this.emit("updated",{plainText:e}),this.triggerCaretPosition(),this.currentHTML=o))}triggerSelection(){let e=this.getSelection();(e.start!==this.currentSelection.start||e.end!==this.currentSelection.end)&&(this.currentSelection=e,this.emit("selection",e),this.triggerCaretPosition())}triggerCaretPosition(){let e=this.getCaretPosition();Pe(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(pa).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=ln(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 Ne{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){let e=this.getSelection();return e?this.getText().slice(e.start,e.end):""}getCaretPosition(){return null}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let o=this.element.disabled,n=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>n.disconnect())}};var Yd=/[.*+?^${}()|[\]\\]/g,eg=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function tg(t){return t.replace(Yd,"\\$&")}function og(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function ng(t){return t.search(eg)}function ua(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${tg(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function da(t){return t.replace(dt,'<mark data-type="placeholder">$1</mark>')}function Xt(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function sg(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 Hs(t,e,o={}){if(e){let n=og(e.toLowerCase(),t.toLowerCase()),s=Xt(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=ng(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(ui).length>3||e.length>30?sg(e.trim(),n):0;return`${`${i>0?"\u2026":""}${Xt(t.substring(i,n))}`}<strong>${s}</strong>`}return t}function Bs(t){return/<\/?[a-z][\s\S]*>/i.test(t)}function cn(t){if(Bs(t)){let o=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(t);return o?o[1]:""}return t}import{jsx as le,jsxs as Fs}from"react/jsx-runtime";var ag=({value:t,onUse:e,...o})=>{var u;let n=w(Ds),s=ig(),r=Bs(t),i=y("EditSuggestionTextInput",As),[a,l]=rg(null),c=Ks(null),p=((u=t.match(dt))==null?void 0:u.length)||0;return Qt(()=>{let d;return c.current&&(l(c.current),d=new Oe(c.current),d.on("change",({plainText:g})=>{s(Q.actions.userInput({text:g,selection:d.getSelection()}))}),d.on("keydown",g=>{s(Q.actions.registerKeyDown(Oo(g))),g.code==="Enter"&&g.shiftKey&&e(d.getText())}),d.on("paste",({pastedText:g,selectionText:f})=>{s(Q.actions.registerPaste({text:g,selectionText:f}))}),d.on("cut",({selectionText:g})=>{s(Q.actions.registerCut(g))})),()=>{s(Q.actions.reset()),d.dispose(),d.deactivate()}},[c]),Qt(()=>{t&&c.current&&(c.current.value=t)},[t,c]),Qt(()=>{c.current&&setTimeout(()=>{if(!c.current)return;let d=c.current.value.length;c.current.setSelectionRange(d,d),c.current.focus()},0)},[c]),r?le("div",{className:i.textInputWrapper,children:le(ga,{className:i.textInput,tagName:"div",content:t})}):Fs("div",{className:i.textInputWrapper,children:[le("textarea",{...o,ref:c,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:t,onChange:()=>{}}),a&&le(lg,{inputElement:c.current,value:t}),Fs("div",{className:ma(i.alert,p===0?i.success:i.warning),children:[le("div",{className:i.alertText,children:n("placeholders",{placeholderSize:p})}),p===0?le(aa,{}):le(ca,{})]})]})},lg=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",As),n=Ks(null),s=nn(t);return Qt(()=>{sn(t,s)},[s,t]),le(cg,{inputElement:t,children:Fs("div",{ref:n,className:ma(o.root,o.agentText),children:[le(ga,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new yt("placeholders")],inputElement:t,boundaryRef:n}),le("br",{})]})})},cg=({inputElement:t,children:e})=>{let o=Ks(null);return Qt(()=>{if(!o.current)return()=>{};let[n,s]=_t(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),le("div",{ref:o,children:e})},fa=ag;import{useEffect as Jg,useState as Yg,useRef as em}from"react";import{useState as dg}from"react";import Us from"classnames";var Z={root:"_root_pc5uy_1",list:"_list_pc5uy_2",listWrapper:"_listWrapper_pc5uy_6",listHorizontal:"_listHorizontal_pc5uy_10",page:"_page_pc5uy_19",search:"_search_pc5uy_25",pageNav:"_pageNav_pc5uy_33",pageTitle:"_pageTitle_pc5uy_41",pageBackButton:"_pageBackButton_pc5uy_48",listHeading:"_listHeading_pc5uy_62",listItem:"_listItem_pc5uy_70",listItemContent:"_listItemContent_pc5uy_79",listItemText:"_listItemText_pc5uy_97",listItemDescription:"_listItemDescription_pc5uy_105",listItemActions:"_listItemActions_pc5uy_112",truncate:"_truncate_pc5uy_123",lineClamp:"_lineClamp_pc5uy_129",listItemTitle:"_listItemTitle_pc5uy_136",listItemAction:"_listItemAction_pc5uy_112",listItemPrimaryAction:"_listItemPrimaryAction_pc5uy_157",listItemSelected:"_listItemSelected_pc5uy_162",sources:"_sources_pc5uy_166",sourcesTitle:"_sourcesTitle_pc5uy_173",source:"_source_pc5uy_166",icon:"_icon_pc5uy_188",searchIcon:"_searchIcon_pc5uy_205",searchInputWrapper:"_searchInputWrapper_pc5uy_210",searchInput:"_searchInput_pc5uy_210",select:"_select_pc5uy_231",selectType:"_selectType_pc5uy_248",selectWrapper:"_selectWrapper_pc5uy_252",image:"_image_pc5uy_282",imageSrc:"_imageSrc_pc5uy_289",imageSrcHidden:"_imageSrcHidden_pc5uy_300",imageSrcStatus:"_imageSrcStatus_pc5uy_304",imageTitle:"_imageTitle_pc5uy_314",actions:"_actions_pc5uy_319",actionsWrapper:"_actionsWrapper_pc5uy_323",actionsBar:"_actionsBar_pc5uy_329",actionButton:"_actionButton_pc5uy_338",actionShortcut:"_actionShortcut_pc5uy_356",actionShortcutFixKerning:"_actionShortcutFixKerning_pc5uy_363"};var Xe={};j(Xe,{enUS:()=>pg,nlNL:()=>ug});var pg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},ug={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 Zt,jsxs as mg}from"react/jsx-runtime";var gg=({src:t,title:e})=>{let o=y("CommandPalette",Z),[n,s]=dg("loading"),r=w(Xe);return mg("div",{className:o.image,children:[Zt("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:Us(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&Zt("span",{className:Us(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&Zt("span",{className:Us(o.imageSrc,o.imageSrcStatus),children:Zt(Co,{})}),e&&Zt("span",{className:o.imageTitle,children:e})]})},ha=gg;import fg from"react";import hg from"classnames";import{jsx as ya,jsxs as yg}from"react/jsx-runtime";function zs({children:t,heading:e,orientation:o}){let n=y("CommandPalette",Z);return fg.Children.count(t)===0?null:yg("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&ya("h4",{className:n.listHeading,children:e}),ya("div",{className:hg(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}import dn from"classnames";import js from"react";import{jsx as vg}from"react/jsx-runtime";var va=js.createContext(void 0);function De(){let t=js.useContext(va);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=js.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return vg(va.Provider,{value:i,children:t})};import Sg,{useState as _a,useEffect as xa,useMemo as _g,useRef as ba,useCallback as xg,useContext as bg}from"react";import Cg from"classnames";var qs={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 pn,jsxs as kg}from"react/jsx-runtime";var wg=0,Ca=Sg.createContext(null),Tg=()=>{let t=bg(Ca);if(!t)throw new Error("Invalid DropdownContext");return t},wa=({trigger:t,children:e,position:o="bottom"})=>{let n=_g(()=>++wg,[]),s=ba(null),r=ba(null),i=y("Dropdown",qs),[a,l]=_a(!1),[c,p]=_a(o),u=g=>{g.preventDefault(),g.stopPropagation(),l(!a)},d=xg(([g])=>{!g.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return xa(()=>{let g=f=>{s.current&&!s.current.contains(f.target)&&l(!1)};return document.addEventListener("click",g),()=>{document.removeEventListener("click",g)}},[]),xa(()=>{if(!r.current&&!a)return()=>{};let g=new IntersectionObserver(d,{root:null,rootMargin:"0px",threshold:1});return r.current&&g.observe(r.current),()=>{r.current&&g.unobserve(r.current)}},[r,a]),pn(Ca.Provider,{value:{setIsOpen:l},children:kg("div",{ref:s,className:i.root,children:[pn("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}),pn("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:Cg(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function Eg({as:t,children:e,onClick:o,...n}){let s=t||"button",r=y("Dropdown",qs),{setIsOpen:i}=Tg(),a=l=>{i(!1),o(l),l.stopPropagation()};return pn(s,{type:"button",className:r.item,onClick:a,...n,children:e})}wa.Item=Eg;var Vs=wa;import{jsx as Ta}from"react/jsx-runtime";var Ea=t=>Ta("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:Ta("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={};j(Qe,{enUS:()=>Rg,nlNL:()=>Ig});var Rg={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"}]},Ig={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 Ws}from"react/jsx-runtime";var Pg="%0d%0a%0d%0a%0d%0a",Ag=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(Pg)}`},Lg=({suggestion:t,onFeedback:e})=>{let o=w(Qe),n=C("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:Ws(Vs,{trigger:Ws(Ea,{"data-testid":"feedback-dropdown-trigger"}),children:Ws(Vs.Item,{as:"a",href:Ag(n,t),onClick:e,children:o("giveFeedback")})})},un=Lg;import{Interweave as Mg}from"interweave";import{jsx as He,jsxs as Gs}from"react/jsx-runtime";function $s({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:g}=De(),f=y("CommandPalette",Z);function m(v){n(v),t&&g(!1)}return Gs("div",{className:dn(f.listItem,u===i&&f.listItemSelected),children:[He("button",{onMouseEnter:()=>d(i),type:"button",className:dn("command-palette-list-item",f.listItemAction,f.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:m,...p,children:Gs("div",{className:f.listItemContent,children:[typeof o=="string"?He("p",{className:dn(f.listItemText,f.truncate,c==null?void 0:c.title),children:o}):o,a&&He(Mg,{tagName:"p",allowList:[],content:cn(a),className:dn(f.listItemDescription,c==null?void 0:c.description,e?f.lineClamp:f.truncate)})]})}),s&&u===i&&He("div",{className:f.listItemActions,children:He(un,{suggestion:String(o),onFeedback:s})}),l&&Gs("div",{className:f.sources,children:[He("span",{className:f.sourcesTitle,children:"Sources"}),l.map(v=>v.url?He("a",{className:f.source,href:v.url,target:"_blank",title:v.url,rel:"noopener noreferrer",onClick:()=>r&&r(v),children:v.name},v.url):He("span",{className:f.source,children:v.name},v.name))]})]})}import{jsx as ka,jsxs as Xs}from"react/jsx-runtime";function Qs({children:t,title:e,id:o,onDismiss:n}){let s=w(Xe),r=y("CommandPalette",Z),{page:i}=De();return i!==o?null:Xs("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&Xs("div",{className:r.pageNav,children:[Xs("button",{className:r.pageBackButton,type:"button",onClick:n,children:[ka(en,{}),s("back")]}),e&&ka("h3",{className:r.pageTitle,children:e})]}),t]})}import{Fragment as qg,useCallback as Vg,useEffect as Wg,useRef as Gg}from"react";var gn=()=>/Mac/i.test(navigator.platform);import{createAsyncThunk as Bg,createSlice as Fg}from"@reduxjs/toolkit";var Ng={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},E=Ng;import{createAsyncThunk as Js,createSlice as Dg}from"@reduxjs/toolkit";function Og(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,[Og(o)]:A(t[o])}),{}):t}function Zs(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function F(t){return Array.isArray(t)?t.map(F):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Zs(o)]:F(t[o])}),{}):t}var Hg={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Yt=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)||""}},Jt=Js("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))}),Ys=Js("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}),er=Js("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),Ra=t=>t.info.agentInfo,Ia=Dg({name:"info",initialState:Hg,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Jt.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Jt.rejected,e=>{e.fetchState="error"}).addCase(Jt.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(Ys.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(er.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(R,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Pa}=Ia.actions,Aa=Ia.reducer;var mn={list:[],fetchState:"idle",isOpen:!1,page:"search"},La=t=>t.search.isOpen,Ma=t=>t.search.page,Na=t=>t.search.list;function Oa(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Ze=Bg("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:Yt(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),Da=Fg({name:"search",initialState:mn,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=mn.fetchState,t.list=mn.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,()=>mn)}}),{resetSearch:fn,setIsOpen:G,setPage:$}=Da.actions,Ha=Da.reducer;var Kg=/(https?:\/\/[^\s]+)/,hn=t=>t.split(" ").find(e=>Kg.test(e));import Ba from"classnames";import{jsx as zg,jsxs as jg}from"react/jsx-runtime";var Ug=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",Z);return jg("button",{type:"button",...n,onClick:t,className:Ba(s.actionButton,n.className),children:[o,e&&e.map(r=>zg("span",{className:Ba(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},xt=Ug;import{jsx as yn,jsxs as tr}from"react/jsx-runtime";var $g=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",Z),a=w(Xe),{selected:l,setSelected:c}=De(),p=r[l],u=p&&typeof p.text=="string"&&hn(p.text),d=Gg(null);function g(x){if(!d.current)return;let b=d.current.querySelectorAll(".command-palette-list-item"),S=0,O=0;x==="down"?(b.forEach((W,D)=>{D===l&&(S=D)}),O=S===b.length-1?0:S+1):x==="up"?(b.forEach((W,D)=>{D===l&&(S=D)}),O=S?S-1:b.length-1):c(0);let M=b[O];M&&typeof O=="number"&&(c(O),M.scrollIntoView&&M.scrollIntoView({behavior:"smooth",block:O?"center":"end"}))}function f(){if(!d.current)return;let x=d.current.querySelectorAll(".command-palette-list-item"),b=0;x.forEach((O,M)=>{M===l&&(b=M)});let S=x[b];S&&S.click()}let m=()=>{u&&window.open(u,"_blank")},v=()=>{p&&n(p,l)},T=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},h=Vg(x=>{if(x.key==="Enter"&&x.altKey&&u){m();return}if(x.key==="Enter"&&x.shiftKey){T();return}if(x.key==="ArrowDown"){x.preventDefault(),x.stopPropagation(),g("down");return}if(x.key==="ArrowUp"){x.preventDefault(),x.stopPropagation(),g("up");return}x.key==="Enter"&&l!==-1&&(x.preventDefault(),x.stopPropagation(),f())},[l]);return Wg(()=>(window.addEventListener("keyup",h),()=>{window.removeEventListener("keyup",h)}),[h]),tr("div",{className:i.actions,children:[yn("div",{className:i.actionsWrapper,ref:d,children:t}),tr("div",{className:i.actionsBar,children:[u&&yn(xt,{onClick:m,shortKeys:[gn()?8997:"ALT",8629],children:a("visitUrl")}),p&&tr(qg,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&yn(xt,{onClick:T,shortKeys:[8679,8629],children:o}),yn(xt,{onClick:v,shortKeys:[8629],children:e})]})]})]})},Ka=$g;import{forwardRef as Qg}from"react";import{jsx as Ua,jsxs as Xg}from"react/jsx-runtime";var bt=()=>Xg("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[Ua("path",{d:"M0 0h24v24H0z",fill:"none"}),Ua("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 Ct,jsxs as or}from"react/jsx-runtime";function Zg({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",Z);return or("div",{className:l.search,children:[Ct("div",{className:l.searchIcon,children:Ct(bt,{})}),or("div",{className:l.searchInputWrapper,children:[Ct("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&&Ct("div",{className:l.selectWrapper,children:or("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&&Ct("option",{children:n}),s.map(c=>Ct("option",{value:c.value,children:c.label},c.value))]})})]})]})}var za=Qg(Zg);import{jsx as ja,jsxs as tm}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[g,f]=Yg(0),m=em(null),v=()=>{s&&s(o),i(void 0),r(""),a(!1)},T=()=>{var h;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(h=m.current)==null||h.focus();return}if(d.length>0){r("");return}a(!1)};return Jg(()=>{f(0)},[d,n]),ja(ht,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:T,onClose:v,children:tm(Sa,{selected:g,setSelected:f,isOpen:u,onChangeOpen:a,page:n,children:[n===o&&ja(za,{ref:m,onChange:r,onChangeType:i,placeholder:t,value:d,selectedType:l,types:c,typePlaceholder:e}),p]})})}Je.Page=Qs;Je.List=zs;Je.Image=ha;Je.ListItem=$s;Je.ActionsBar=Ka;Je.Button=xt;var I=Je;import{jsx as Se,jsxs as eo}from"react/jsx-runtime";var sm=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",Di),l=om(),c=w(bs),p=nm(f=>f.overlayInput.text);qa(()=>{t&&(l(Q.actions.reset()),l(Q.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(Q.actions.commitSuggestion()))},[t]);let u=f=>{f.preventDefault(),d(p)},d=f=>{l(Bo(f)),e(f)},g=f=>m=>{p!==i?window.confirm(c("warning"))&&f(m):f(m)};return qa(()=>{n&&n(p!==i)},[n,t,p]),eo("div",{className:a.root,children:[eo("div",{className:a.content,children:[t.title&&Se("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&Se(ms,{labels:t.searchKeywords}),Se(fa,{onUse:d,value:cn(p)})]}),eo("form",{className:a.actions,onSubmit:u,children:[eo("div",{children:[Se("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&g(r),children:Se(en,{})}),Se("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&g(s),children:Se($i,{})})]}),eo("div",{className:a.primaryButtons,children:[Se(I.Button,{onClick:g(o),shortKeys:["esc"],children:c("dismiss")}),Se(I.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},vn=sm;import{createAction as am,createAsyncThunk as $a,createSlice as lm}from"@reduxjs/toolkit";var rm=["{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}"],im=new RegExp(rm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Va(t,e){let o=t.split(im),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 Wa(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Xa={suggestions:[],fetchState:"idle",isInitialRequest:null},Ga={default:Xa},Qa=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")},wt=t=>t.textSuggestions,Ya=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},Sn=am("textSuggestions/refresh"),_e=$a("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=ft(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Yt(n),t);if(t==="default"){let p=i?l.filter(Ya(a)):l;e.dispatch(ue(p.slice(0,r)))}return l}),to=$a("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,{...Yt(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(Ya(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?Va(p.text,t):p.text}))),l=Wa(l,r),e.dispatch(ue(l)),l}),el=lm({name:"textSuggestions",initialState:Ga,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]||Xa;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(to.pending,e=>{e.default.fetchState="loading"}).addCase(to.rejected,e=>{e.default.fetchState="error"}).addCase(to.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(R,()=>Ga)}}),{setTextSuggestions:tl,setSuggestionState:ol}=el.actions,nl=el.reducer;import{createSlice as cm}from"@reduxjs/toolkit";var sl={contentType:null,suggestion:null},rl=t=>t.activeSuggestion.suggestion,il=t=>t.activeSuggestion.contentType,al=cm({name:"activeSuggestion",initialState:sl,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,()=>sl)}}),{setActiveSuggestion:xe,resetActiveSuggestion:nr}=al.actions,ll=al.reducer;var sr={};j(sr,{enUS:()=>pm,nlNL:()=>um});var pm={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"}]},um={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 dm}from"@reduxjs/toolkit";var gm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var _n=({ui:t})=>t.overlayCollapsed;var cl=dm({name:"ui",initialState:gm,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:oo,setInputHasFocus:Tt,setOverlayCollapsed:Be,setOpenOverlayWhenTyping:pl,setOverlayCollapsedUserOverwrite:ul}=cl.actions,dl=cl.reducer;import gl,{useContext as mm}from"react";import{jsx as fm}from"react/jsx-runtime";var ml=gl.createContext(null),Ye=({broadcastEvents:t,children:e})=>{let o=gl.useMemo(()=>t,[]);return fm(ml.Provider,{value:o,children:e})},se=()=>{let t=mm(ml);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import{createAsyncThunk as rr,createSlice as hm}from"@reduxjs/toolkit";var ym={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},oe=t=>t.auth.isLoggedIn,fl=t=>t.auth.loginFetchState,hl=t=>t.auth.verifyFetchState,yl=t=>t.auth.showLoginOverlay,be=rr("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),vl=rr("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),no=rr("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),Sl=hm({name:"auth",initialState:ym,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(no.pending,e=>{e.verifyFetchState="loading"}),t.addCase(no.rejected,e=>{e.verifyFetchState="error"}),t.addCase(no.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Et,setShowLoginOverlay:_l}=Sl.actions,xl=Sl.reducer;var ir="SetActiveSuggestion",kt="ShowLoginOverlay",so="UserLoggedIn",vm="UserLoggedOut",Ce="ApplySuggestion",ar="ApplyImageSuggestion",Sm="ShowCommandPalette",_m=t=>({[ir]:e=>{t.dispatch(ol(e.state)),t.dispatch(xe({contentType:e.contentType,suggestion:e.suggestion}))},[Sm]:e=>{t.dispatch(G(e.isOpen)),e.page&&t.dispatch($(e.page))},[kt]:e=>{t.dispatch(_l(e))},[so]:()=>{t.dispatch(be())},[vm]:()=>{t.dispatch(be())},[ar]:e=>{t.dispatch(Ko({suggestion:e.suggestion}))},[Ce]:e=>{t.dispatch(ie({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(Me())}}),bl=_m;import{jsx as Cl}from"react/jsx-runtime";var Cm=()=>{var f;let[t,e]=xm(!1),o=lr(rl),n=lr(il),s=lr(wt),r=bm(),i=se(),a=w(sr),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(nr()),r(Tt(!0)),r(Q.actions.reset())},p=(m,v)=>{r(nr()),r(Tt(!0)),i.send(Ce,{text:m,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]})),g=u===s[n].suggestions.length-1||u===null?void 0:()=>r(xe({contentType:n,suggestion:s[n].suggestions[u+1]}));return Cl(ht,{autoFocus:!0,isOpen:u!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:Cl(vn,{onTouched:e,onDismiss:c,onUse:m=>p(m,o),suggestion:o,onNext:g,onPrevious:d})})},wl=Cm;import{useSelector as Il}from"react-redux";import pr from"classnames";import{useCallback as kl,useEffect as Im,useMemo as Pm,useState as ur}from"react";import{useDispatch as Am,useSelector as Lm}from"react-redux";import wm from"classnames";var Tl={root:"_root_1ukx5_1"};import{jsx as Em}from"react/jsx-runtime";var Tm=({className:t,value:e,...o})=>{let n=y("TextInput",Tl);return Em("input",{className:wm(t,n.root),type:"text",value:e,...o})},ro=Tm;var cr={};j(cr,{enUS:()=>km,nlNL:()=>Rm});var km={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"}]},Rm={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 El={root:"_root_1edpl_1",anchorButton:"_anchorButton_1edpl_5",errorMessage:"_errorMessage_1edpl_19",title:"_title_1edpl_25",subtitle:"_subtitle_1edpl_31",text:"_text_1edpl_38",input:"_input_1edpl_43",actions:"_actions_1edpl_48",button:"_button_1edpl_55",primaryButton:"_primaryButton_1edpl_70"};import{jsx as J,jsxs as xn}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}},Nm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=w(cr),i=y("LoginTokenDialog",El),a=Lm(hl),l=Am(),c=C("productName"),[p,u]=ur(t||""),[d,g]=ur(0),[f,m]=ur(""),v=kl(async b=>{b.preventDefault(),l(vl({email:p})),g(1)},[o,p]),T=()=>{m(""),g(0)},h=kl(async b=>{b.preventDefault();let S=Mm(b.target.elements.token.value);if(!S){m(r("verifyCodeError",{login:x}));return}l(no({token:S}))},[o]),x=Pm(()=>b=>J("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:T,children:b},"back-button"),[]);return Im(()=>{a==="error"&&m(r("verifyCodeError",{login:x})),a==="done"&&n()},[a]),J(ht,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:xn("div",{className:i.root,children:[J("h1",{className:i.title,children:r("promptTitle",{productName:c})}),d===0&&xn("form",{onSubmit:v,children:[J("h2",{className:i.subtitle,children:r("requestCodeTitle")}),J("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),J(ro,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:b=>u(b.target.value)}),J("div",{className:i.actions,children:J("button",{type:"submit",className:pr(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),d===1&&xn("form",{onSubmit:h,children:[J("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),J("p",{className:i.text,children:r("verifyCodeBody")}),J(ro,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&J("div",{className:i.errorMessage,children:f}),xn("div",{className:i.actions,children:[J("button",{type:"button",className:pr(i.button),onClick:T,children:r("back")}),J("button",{type:"submit",className:pr(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},Rl=Nm;import{jsx as Dm}from"react/jsx-runtime";var Om=()=>{let t=Il(yl),e=Il(Ra),o=C("adminUrl"),n=se(),s=()=>n.send(kt,!1),r=()=>{n.send(kt,!1),n.send(so)};return Dm(Rl,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},Pl=Om;import Rf from"lodash.debounce";import{useCallback as En,useEffect as Sr,useState as co}from"react";import{useDispatch as If,useSelector as Lt}from"react-redux";import{createAsyncThunk as Hm,createSlice as Bm}from"@reduxjs/toolkit";var Fm={data:null,fetchState:"idle"},Al=t=>t.contentTypes.data,io=Hm("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Km=Bm({name:"contentTypes",initialState:Fm,reducers:{},extraReducers:t=>{t.addCase(io.pending,e=>{e.fetchState="loading"}).addCase(io.rejected,e=>{e.fetchState="error"}).addCase(io.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Ll=Km.reducer;function ao(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 Um}from"react";function Ml(t,e){Um(()=>{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 Hl,useRef as $m}from"react";import{useSelector as Xm,useDispatch as Qm}from"react-redux";import{createAsyncThunk as zm,createSlice as jm}from"@reduxjs/toolkit";var Nl={data:null,fetchState:"idle"},bn=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},ce=zm("entities/getEntities",async(t,e)=>{let{deepdeskAPI:o,dynamicThunkObject:n}=e.extra;if(!n.conversationQuery)return Promise.resolve([]);let s=n.conversationQuery,r=await s();return r.length===0?Promise.resolve([]):o.getEntities(r)}),qm=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Vm=jm({name:"entities",initialState:Nl,reducers:{},extraReducers:t=>{t.addCase(ce.pending,e=>{e.fetchState="loading"}).addCase(ce.rejected,e=>{e.fetchState="error"}).addCase(ce.fulfilled,(e,o)=>{e.fetchState="done",e.data=qm(e.data?[...e.data,...o.payload]:o.payload)}).addCase(R,()=>Nl)}}),Ol=Vm.reducer;var dr={};j(dr,{enUS:()=>Wm,nlNL:()=>Gm});var Wm={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Gm={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Dl={root:"_root_17kae_1",empty:"_empty_17kae_5"};import{jsx as Cn,jsxs as Jm}from"react/jsx-runtime";var Zm=({onCopy:t,onUse:e})=>{let o=$m(null),n=y("EntitiesList",Dl),s=w(dr),r=Xm(bn),i=Qm();return Hl(()=>{i(ce())},[]),Hl(()=>{o.current&&o.current.focus()},[o]),Jm("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&Cn(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:Cn(I.List,{children:r.map((a,l)=>Cn(I.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&Cn("p",{className:n.empty,children:s("noResults")})]})},Bl=Zm;import{Fragment as sf,useEffect as wn,useRef as rf,useState as af}from"react";import{useSelector as ql,useDispatch as lf}from"react-redux";import{createAsyncThunk as Ym,createSlice as ef}from"@reduxjs/toolkit";var Fl={data:null,fetchState:"idle"},Kl=t=>t.summary.data,Ul=t=>t.summary.fetchState==="error",we=Ym("summary/getSummary",async(t,e)=>{let o=e.getState().profile.data;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:n,dynamicThunkObject:s}=e.extra;if(!s.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let r=s.conversationQuery,i=await r();if(i.length===0)return Promise.reject(new Error("No messages are included"));let a=await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return a?{summary:a}:Promise.reject(new Error("Summary is not provided"))}),tf=ef({name:"summary",initialState:Fl,reducers:{},extraReducers:t=>{t.addCase(we.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(we.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(we.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(R,()=>Fl)}}),zl=tf.reducer;var gr={};j(gr,{enUS:()=>of,nlNL:()=>nf});var of={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."}]},nf={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 jl={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};import{jsx as Rt,jsxs as pf}from"react/jsx-runtime";var cf=({onCopy:t})=>{let e=rf(null),o=y("SummaryForm",jl),[n,s]=af(""),r=w(gr),i=ql(Kl),a=ql(Ul),l=lf(),c=()=>{l(q({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let u=document.getSelection();u&&l(q({name:"summary copied to clipboard",data:{originalText:i,finalText:u==null?void 0:u.toString()},options:{includeConversationData:!0}}))};return wn(()=>{l(we())},[]),wn(()=>{s(i||"")},[i]),wn(()=>{e.current&&i&&e.current.focus()},[e,i]),wn(()=>{let u=d=>{d.key==="Enter"&&d.shiftKey&&c()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[n]),Rt("div",{className:o.root,tabIndex:-1,children:a?Rt("p",{className:o.error,children:r("error")}):pf(sf,{children:[Rt("div",{className:o.main,children:Rt("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:u=>s(u.target.value)})}),Rt("div",{className:o.actions,children:Rt(I.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},Vl=cf;var mr={};j(mr,{enUS:()=>uf,nlNL:()=>df});var uf={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?"}]},df={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"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 _f,{useEffect as yr,useRef as xf}from"react";import{useDispatch as bf,useSelector as Jl}from"react-redux";var fr={};j(fr,{enUS:()=>gf,nlNL:()=>mf});var gf={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"}]},mf={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 ff,createAsyncThunk as hf,createSlice as yf}from"@reduxjs/toolkit";var hr={data:[],fetchState:"idle"},Gl=t=>{var e;return(e=t.answer)==null?void 0:e.data},$l=t=>t.answer.fetchState,Pt=ff("answer/resetKnowledgeSearch"),It=hf("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}}),vf=yf({name:"answer",initialState:hr,reducers:{},extraReducers:t=>{t.addCase(It.pending,e=>{e.fetchState="loading"}).addCase(It.rejected,e=>{e.fetchState="error"}).addCase(It.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(R,()=>hr).addCase(Pt,()=>hr)}}),Xl=vf.reducer;import{jsx as Ql,jsxs as Sf}from"react/jsx-runtime";var Zl=()=>Sf("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[Ql("title",{id:"paperPlaneTitle",children:"PaperPlane"}),Ql("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 Te,jsxs as vr}from"react/jsx-runtime";var Cf=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=_f.useState(""),{setSelected:i}=De(),a=xf(null),l=y("EntitiesList",Wl),c=w(fr),p=bf(),u=Jl(Gl),d=Jl($l),g=async m=>{m.preventDefault(),m.stopPropagation(),s!==""&&p(It({question:s,promptInstruction:n}))},f=(m,v)=>{p(q({name:"knowledge assist source viewed",data:{question:v,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return yr(()=>{var m;o&&d==="idle"?p(It({question:o,promptInstruction:n})):(m=a.current)==null||m.focus()},[a,d]),yr(()=>{d==="done"&&(p(q({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]),yr(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,u]),vr("div",{className:l.root,children:[u.length>0&&Te("div",{className:l.alignRight,children:Te(I.Button,{onClick:e,children:c("reset")})}),vr(I.ActionsBar,{list:u.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:m=>t(m.text),children:[u.map(({question:m,answer:v},T)=>Te(I.List,{children:Te(I.ListItem,{"data-testid":"knowledge-search-answer",index:T,description:v.answer,closeOnSelect:!0,onClick:()=>t(v.answer),onSourceClick:h=>f(h,m),sources:v.sources,styles:{title:l.question,description:l.answer},children:m})},`${v.answer}_${T}`)),d==="loading"&&Te("p",{className:l.status,children:c("loading")}),d==="error"&&Te("p",{className:l.status,children:c("error")}),vr("form",{className:l.form,onSubmit:g,children:[Te("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:m=>{i(-1),r(m.target.value)}}),Te("button",{type:"submit",className:l.submit,children:Te(Zl,{})})]})]})]})},Yl=Cf;import{createAsyncThunk as wf,createSlice as Tf}from"@reduxjs/toolkit";var Ef={data:null,fetchState:"idle"},At=t=>t.profile.data,Tn=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],lo=wf("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)}),kf=Tf({name:"profile",initialState:Ef,reducers:{},extraReducers:t=>{t.addCase(lo.pending,e=>{e.fetchState="loading"}).addCase(lo.rejected,e=>{e.fetchState="error"}).addCase(lo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),ec=kf.reducer;import{jsx as Y,jsxs as oc}from"react/jsx-runtime";var Pf=200,Af=5,Lf=4,Mf=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),tc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Nf=()=>{let t=If(),e=se(),o=w(mr),[n,s]=co(!1),[r,i]=co(""),a=Lt(Ma),l=Lt(At),[c,p]=co(null),[u,d]=co([]),[g,f]=co(),m=Lt(oe),v=C("showSearch"),T=C("showEntitiesCommand"),h=C("showSummaryCommand"),x=C("showKnowledgeSearch"),b=C("showImageSearch"),S=C("searchTriggerKey"),O=Lt(Al),M=Lt(Na),W=Lt(La),D=_=>rs(M.filter(P=>P.type===_.toUpperCase()),_),k=[{value:"PERSONAL",label:o("personalSuggestions"),list:D("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:D("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:D("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:D("IMAGE"),listOrientation:"horizontal",shouldShow:b}].filter(_=>_.shouldShow),H=[{label:o("entitiesClipboard"),onClick:()=>t($("entities")),shouldShow:T&&tc(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t($("summary")),shouldShow:h&&tc(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t($("knowledgeAssist")),shouldShow:x}].filter(_=>_.shouldShow),X=(O==null?void 0:O.map(_=>({value:_.code.toUpperCase(),label:`${_.name}s`,list:D(_.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],ns=En(Rf((_,P)=>{t(Ze({query:_,type:P,tags:["search-overlay"]}))},Pf),[]),ze=Mf([...X,...k]),au=En((_,P)=>{if(!P)return;let Ie=[...k,...X].find(({value:at})=>at===P);Ie&&(t($("edit")),p({..._,searchTerm:void 0}),d(Ie.list))},[t,c,X]),ss=En((_,P)=>{switch(P.type){case"IMAGE":e.send(ar,{suggestion:P});break;default:e.send(Ce,{text:_,suggestion:P})}t(G(!1))},[t]),lu=_=>{ao(_.text),t(q({name:"entity copied",data:{entity:_,type:"copy"}})),t(G(!1))},cu=En(_=>{t(q({name:"suggestion feedback",data:{text:_.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),pu=_=>{e.send(Ce,{text:_,suggestion:{source:"knowledge-assist",text:_}}),t(q({name:"answer used",data:{originalText:_},options:{includeConversationData:!0}})),i(""),t($("search")),t(Pt()),t(G(!1))},uu=_=>{ao(_),t(G(!1))},du=_=>{e.send(Ce,{text:_.text,suggestion:{source:"entity",text:_.text}}),t(G(!1))},gu=c===null||u.indexOf(c)-1<0?void 0:()=>p(u[u.indexOf(c)-1]),mu=c===null||u.indexOf(c)===u.length-1?void 0:()=>p(u[u.indexOf(c)+1]);function rs(_,P){return _.slice(0,g?10:P.toLowerCase()==="image"?Lf:Af)}function ni(_,P,Ie){return P.reduce((at,xo)=>Ie&&g===Ie?xo.length+at:rs(xo,Ie).length+at,_)}function it(_){return P=>{n?window.confirm(o("warning"))&&(_(P),s(!1)):_(P)}}return Sr(()=>{r?ns(r,g):t(fn())},[r,g]),Sr(()=>{a==="search"&&t(Pt())},[a]),Sr(()=>{m&&t(io())},[m]),Ml(S,()=>t(G(!0))),!v||!l?null:oc(I,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:it(_=>t(G(_))),onChangeType:_=>f(_),onChangePage:it(_=>t($(_))),selectedType:g,search:r,page:a,isOpen:W,types:[...X,...k],children:[Y(I.Page,{id:"search",children:oc(I.ActionsBar,{list:[...H.map(_=>({text:_.label,type:"command"})),...ze.map(_=>({text:_.text||_.url||_.message,type:_.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:_},P)=>ss(_,ze[P]),onSecondary:(_,P)=>{au(ze[P-H.length],ze[P-H.length].type)},children:[H.length>0&&Y(I.List,{heading:o("commands"),children:H.map((_,P)=>Y(I.ListItem,{index:ni(P,[],"commands"),closeOnSelect:!1,onClick:_.onClick,children:_.label},_.label))}),[...X,...k].map(({value:_,label:P,list:Ie,lineClamp:at,listOrientation:xo},fu)=>Y(I.List,{heading:P,orientation:xo==="horizontal"?"horizontal":"vertical",children:rs(Ie,_).map((ne,hu)=>Y(I.ListItem,{index:ni(H.length+hu,[...X,...k].slice(0,fu).map(({list:yu})=>yu),_),closeOnSelect:!1,lineClamp:at,onClick:()=>ss(ne.text,ne),description:_!=="IMAGE"?ne.title&&ne.text:void 0,onFeedback:_!=="IMAGE"?()=>cu(ne):void 0,children:_==="IMAGE"?Y(I.Image,{title:ne.title||ne.text,src:ne.image}):ne.title||ne.text},`${ne.id}-${ne.text}`))},_))]})}),Y(I.Page,{id:"edit",onDismiss:it(()=>{t($("search")),p(null)}),children:c&&Y(vn,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t($("search")),p(null),d([])},onNext:mu,onPrevious:gu,onUse:_=>{t($("search")),ss(_,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(G(!1)),d([]),p(null)}})}),Y(I.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:it(()=>{t($("search"))}),children:Y(Bl,{onUse:du,onCopy:lu})}),Y(I.Page,{id:"summary",title:o("summaryTitle"),onDismiss:it(()=>{t($("search"))}),children:Y(Vl,{onCopy:uu})}),Y(I.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:it(()=>{t(Pt()),t($("search"))}),children:Y(Yl,{promptInstruction:l.knowledgeAssistPromptInstruction,question:r,onUse:pu,onResetQuestion:()=>{t(Pt()),i("")}})})]})},nc=Nf;import{jsx as _r,jsxs as Hf}from"react/jsx-runtime";var Df=()=>{let t=C("showSearch"),e=C("isEmbedded");return Hf(Of,{children:[t&&_r(nc,{}),_r(wl,{}),e&&_r(Pl,{})]})},sc=Df;import{connect as eh,useDispatch as th,useSelector as In}from"react-redux";function Mt(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:o,showSuggestionsAfterPattern:n}=t.settings,{text:s,selection:r}=t.input.userCommitted;return r.start!==r.end?!1:r.end>=s.length?!0:e?o&&new RegExp(o).test(s.substring(r.end))||n&&new RegExp(n).test(s.substring(0,r.end))?!0:o===!1&&n===!1:!1}import{Fragment as Zf,useMemo as Jf}from"react";import{Interweave as Kf}from"interweave";import{useEffect as Uf,useMemo as zf,useRef as jf}from"react";import{useDispatch as qf,useSelector as Vf}from"react-redux";import{useEffect as Bf}from"react";function rc(t,e,o){Bf(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var ic={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};import{jsx as kn,jsxs as Qf}from"react/jsx-runtime";var Wf=["search","personal-collection-search","search-autocomplete"];function Gf(t,e,o,n={}){let s="";return Wf.includes(e)?s=ua(Hs(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=Hs(t,o,n),n.placeholders===!0&&(s=da(s)),s}var $f=()=>{},Xf=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=C("inlineSuggestions"),r=Vf(ft),i=qf(),a=y("TextSuggestion",ic),l=jf(null);Uf(()=>{let p=setTimeout(()=>{i(Ti({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),rc(l,"click",()=>{i(Le(t)),i(ie({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=zf(()=>Gf(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:Qf("div",{className:a.root,onMouseEnter:()=>i(Le(t)),children:[kn(N,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:$f,children:kn(Kf,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&kn("div",{className:a.actions,children:kn(un,{onFeedback:()=>n(o),suggestion:o.text})})]})},ac=Xf;import{jsx as lc}from"react/jsx-runtime";var Yf=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=Jf(()=>{let r=e.map((i,a)=>lc(ac,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return lc(Zf,{children:s})},Rn=Yf;var cc={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};import{jsx as Pn}from"react/jsx-runtime";var oh=({textSuggestions:t,selectedIndex:e})=>{let o=y("InlineSuggestionsOverlay",cc),n=In(Mt),s=th(),r=In(oe),i=In(mt),a=In(_n),l=C("showTextSuggestions");return vt(()=>{s(Be({collapse:!0,skipWhenInputFocus:!0}))}),a||!n||!l||t.length===0||r!==!0||i===!1?null:Pn("div",{className:o.root,"data-variant":"inline",children:Pn("div",{className:o.paper,children:Pn(re,{children:Pn(Rn,{suggestions:t,selectedIndex:e})})})})},nh=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),pc=eh(nh)(oh);import Tr from"classnames";import{useEffect as fh,useRef as hh,useState as yh}from"react";import{connect as vh,useDispatch as Sh,useSelector as po}from"react-redux";import{useState as sh}from"react";function uc(t,e){let[o,n]=sh(()=>{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 ah from"classnames";import{Fragment as lh,useCallback as br,useMemo as gc}from"react";var xr={};j(xr,{enUS:()=>rh,nlNL:()=>ih});var rh={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"}]}]},ih={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 dc={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};import{jsx as An,jsxs as mc}from"react/jsx-runtime";var Cr=(t,e,o)=>n=>An("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),ch=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n})=>{let s=w(xr),r=se(),i=y("Login",dc),a=C("productName"),l=br(m=>{m.preventDefault(),n&&n(parseInt(m.target.value,10))},[]),c=br(m=>{m.preventDefault(),r.send(kt,!0)},[e]),p=gc(()=>m=>An("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:m},"login"),[e]),u=br(m=>An("button",{type:"button",className:i.anchorButton,onClick:c,children:m},"prompt"),[c]),{min:d,hour:g,day:f}=gc(()=>({min:Cr(i,60*10,l),hour:Cr(i,60*60,l),day:Cr(i,60*60*12,l)}),[]);return mc("div",{className:ah(t,i.root),children:[s("loginPlease",{login:o?u:p,productName:a}),n&&mc(lh,{children:[An("br",{}),s("snooze",{min:d,hour:g,day:f})]})]})},Ln=ch;import{useDispatch as ph}from"react-redux";var fc={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};import{jsx as hc,jsxs as dh}from"react/jsx-runtime";var uh=({title:t})=>{let e=y("SearchTrigger",fc),o=ph();return dh("button",{type:"button",className:e.root,onClick:()=>o(G(!0)),children:[hc(bt,{}),hc("span",{className:e.text,children:t})]})},yc=uh;var wr={};j(wr,{enUS:()=>gh,nlNL:()=>mh});var gh={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"}]},mh={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 vc={root:"_root_onpov_1",isInline:"_isInline_onpov_14",toggleButton:"_toggleButton_onpov_21",toggleButtonWrapper:"_toggleButtonWrapper_onpov_25",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_onpov_32",isCollapsed:"_isCollapsed_onpov_36",collapsible:"_collapsible_onpov_36",hints:"_hints_onpov_44",hintsHidden:"_hintsHidden_onpov_51",triggers:"_triggers_onpov_56",triggersRight:"_triggersRight_onpov_71"};import{jsx as z,jsxs as uo}from"react/jsx-runtime";var _h=({textSuggestions:t,selectedIndex:e})=>{let o=y("SuggestionsOverlay",vc),n=w(wr),s=po(Mt),r=_i(),i=Sh(),a=hh(null),l=C("searchTriggerKey"),c=C("productName"),p=po(_n),u=po(oe),d=po(mt),[g,f]=yh(null),m=C("showSearch"),v=C("showTextSuggestions"),T=C("adminUrl"),h=C("isEmbedded"),[x,b]=uc("dd-snooze-until-ms",0),S=p||x>Date.now(),O=po(H=>H.input.text),M=t.filter(H=>H.source!=="gpt").length,W=()=>{S&&b(0),i(ul(!S))},D=H=>{i(q({name:"suggestion feedback",data:{text:H.text,source:"overlay",context:O},options:{includeConversationData:!0}}))},k=H=>{let X=Date.now()+H*1e3;b(X),E.info(`Snooze until: ${new Date(X)}`),i(Be({collapse:!0}))};return fh(()=>{M===0&&f(null)},[t,M]),vt(()=>{i(Be({collapse:!0,skipWhenInputFocus:!0}))}),u===null||d===!1?null:u===!1?uo("div",{ref:a,className:Tr(o.root,{[o.isCollapsed]:S}),children:[!S&&uo("div",{className:o.triggers,children:[z("div",{style:{flex:1}}),z("div",{className:o.triggersRight,children:z(ut,{className:o.toggleButton,title:n("collapse"),onClick:W,isCollapsed:!1})})]}),z("div",{className:o.toggleButtonWrapper,children:z(ut,{className:o.toggleButton,title:n("open",{productName:c}),onClick:W,isCollapsed:!0})}),z("div",{className:o.collapsible,children:z(Ln,{loginUrl:T,isEmbedded:h,onSnooze:k})})]}):!r||!s?null:uo("div",{ref:a,className:Tr(o.root,{[o.isCollapsed]:S}),children:[!S&&uo("div",{className:o.triggers,children:[z("div",{style:{flex:1},children:m&&z("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(n(gn()?"searchHintMac":"searchHintWindows",{searchTriggerKey:l.toUpperCase()})),onMouseLeave:()=>f(null),children:z(yc,{title:n("search")})})}),uo("div",{className:o.triggersRight,onFocus:()=>{},children:[z("div",{className:Tr(!g&&o.hintsHidden,o.hints),children:g}),z(ut,{className:o.toggleButton,title:n("collapse"),onClick:W,isCollapsed:!1})]})]}),z("div",{className:o.toggleButtonWrapper,children:z(ut,{className:o.toggleButton,title:n("open",{productName:c}),onClick:W,isCollapsed:!0})}),M>0&&v&&z("div",{className:o.collapsible,onFocus:()=>{},children:z(re,{children:z(Rn,{onFeedback:D,suggestions:t,selectedIndex:e,reverse:!0})})})]})},xh=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Sc=vh(xh)(_h);import{Provider as bh}from"react-redux";import{jsx as Mn}from"react/jsx-runtime";var Ch=({children:t})=>{let o=C("locale").replace("-","");return Mn(Ps.Provider,{value:o,children:t})},wh=({store:t,customStyles:e={},children:o})=>Mn(bh,{store:t,children:Mn(Ch,{children:Mn(Ut.Provider,{value:e,children:o})})}),et=wh;import Dr from"classnames";import{Interweave as uy}from"interweave";import{useCallback as dy,useEffect as gy,useMemo as Fc,useRef as my}from"react";import{connect as fy}from"react-redux";import{cloneElement as Th}from"react";var Eh=["div","span","mark","strong","b","i","u","em"];function Er(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(Eh.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),Th(n,{children:Er(i,e,o+1)})]}return[...t,...e]}function Fe(t){return t.tagName.toLowerCase()==="textarea"}var _c={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 jh from"classnames";import{Matcher as qh}from"interweave";import{useEffect as Vh,useMemo as Wh}from"react";function xc(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Nn(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function bc(t){return t!=null}import kc from"classnames";import{createRef as Dh,useCallback as Rr,useMemo as Hh,useRef as Bh,useState as Fh}from"react";import{useState as kh,useLayoutEffect as Rh}from"react";var Ih=["bottom","height","left","right","top","width"],Ph=(t={},e={})=>Ih.some(o=>t[o]!==e[o]),Ee=new Map,Cc,wc=()=>{let t=[],e=[];Ee.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Ph(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Ee.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),Cc=window.requestAnimationFrame(wc)};function Ah(t,e){return{observe(){let o=Ee.size===0;if(Ee.has(t)){let n=Ee.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Ee.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&wc()},unobserve(){let o=Ee.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Ee.delete(t),Ee.size||cancelAnimationFrame(Cc)}}}}function kr(t){let[e,o]=kh(null);return Rh(()=>{if(!t.current)return;let n=Ah(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}import{useContext as Lh,useLayoutEffect as Mh,useState as Nh}from"react";import{createPortal as Oh}from"react-dom";var Tc={root:"_root_1jq08_1"};var Ec=({children:t})=>{let[e,o]=Nh(null),n=Lh(Ut);return Mh(()=>{let s=document.createElement("div");return $e(s),s.classList.add(Tc.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?Oh(t,e):null};var me={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 Ir}from"react/jsx-runtime";var On=(t=!1)=>{let[e,o]=Fh(t),n=Rr(()=>o(!0),[]),s=Rr(()=>o(!1),[]),r=Rr(()=>o(a=>!a),[]),i=Bh(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function Pr(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 Dn=({className:t,triggerRef:e,boundaryRef:o=Dh(),position:n="above",align:s="center",children:r,toStyle:i=Pr,...a})=>{let l=kr(e),c=kr(o),p=Hh(()=>i(l,c,0),[l,c]);return Ir(Ec,{children:Ir("div",{className:kc(me.ref,{[me.positionAbove]:n==="above",[me.positionBelow]:n==="below",[me.positionLeft]:n==="left",[me.positionRight]:n==="right",[me.alignStart]:s==="start",[me.alignCenter]:s==="center",[me.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:Ir("div",{className:kc(t,me.root),children:r})})})};import Kh from"classnames";import{forwardRef as Uh,useRef as zh}from"react";import{jsx as Rc}from"react/jsx-runtime";var Hn=Uh(({className:t,children:e,...o},n)=>{let s=zh(null),r=y("TabCompletion",ve);return Rc("div",{ref:Nn([s,n]),className:Kh(t,r.popoverContentContainer),...o,children:Rc("div",{className:r.popoverContent,children:e})})});import{jsx as go,jsxs as Xh}from"react/jsx-runtime";var Gh=t=>e=>{let o=Pr(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},$h=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",ve),i=On(),a=Wh(()=>Gh(t.getBoundingClientRect()),[t]),[l,c]=tn(t);return Vh(()=>{c?i.open():i.close()},[c]),Xh("span",{children:[go("mark",{ref:Nn([l,i.triggerRef]),className:jh(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&go(Dn,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:go(Hn,{style:o,children:go("div",{className:r.hintText,children:s})})})]})},Bn=class extends qh{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${xc(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(bc);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 go($h,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import Or from"classnames";import{Matcher as sy}from"interweave";import{createRef as ry,forwardRef as iy,useCallback as ay,useEffect as Dc,useRef as Hc,useState as Bc}from"react";import{useDispatch as ly}from"react-redux";import{jsx as Ic}from"react/jsx-runtime";var Pc=()=>Ic("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:Ic("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 Qh,useEffect as Lc,useState as Mc}from"react";import{useDispatch as Zh,useSelector as Nc}from"react-redux";import Jh from"lodash.debounce";var Ac={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Fn(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 Ar(t){return t.replace("https://www.","").replace("https://","")}import{jsx as tt,jsxs as Lr}from"react/jsx-runtime";var Yh=3,ey=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),ty=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=Yh})=>{let r=y("LinkSearch",Ac),[i,a]=Mc(""),l=Zh(),c=Nc(Qa("url")),p=Nc(Oa("URL",ey)),[u,d]=Mc(p.length-1),g=C("fallbackImage"),f=h=>{let x=h.target;a(x.value)},m=(h,x)=>{h.stopPropagation(),h.preventDefault(),window.open(x,"_blank")},v=h=>{var S;let x=u-1<0?p.length-1:u-1,b=u+1===p.length?0:u+1;h.code==="Escape"&&(a(""),e()),h.code==="ArrowUp"&&d(x),h.code==="ArrowDown"&&d(b),h.code==="Enter"&&t(((S=p[u])==null?void 0:S.text)||i)},T=Qh(Jh(h=>{l(Ze({query:h,type:"URL",tags:["link-search"]}))},300),[]);return Lc(()=>{i&&T(i)},[i]),Lc(()=>()=>{l(fn())},[]),Lr("div",{className:r.root,children:[tt(re,{withDivider:!0,children:(i?p:c).slice(0,s).map((h,x)=>tt(N,{selected:u===x,onClick:()=>t(h.text),"data-testid":"linksearch-suggestion",children:Lr(B,{children:[tt(B.Image,{src:Fn(h,"small",g||void 0),title:h.title||h.text}),Lr(B.Content,{className:r.content,cropText:!0,children:[tt(B.Title,{children:h.title||Ar(h.text)}),h.title&&Ar(h.text)]}),tt(N.Actions,{children:tt(N.ActionButton,{label:n,onClick:b=>m(b,h.text)})})]})},h.text))}),tt(ro,{value:i,onChange:f,autoFocus:!0,placeholder:o,onKeyUp:v})]})},Oc=ty;var Mr={};j(Mr,{enUS:()=>oy,nlNL:()=>ny});var oy={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},ny={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};import{jsx as fe,jsxs as Nr}from"react/jsx-runtime";var cy=iy((t,e)=>{let o=y("TabCompletion",ve);return fe("mark",{ref:e,className:Or(o.matchSelection)},"selection-start")}),py=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=w(Mr),i=y("TabCompletion",ve),a=Hc(null),l=Hc(null),[c,p]=Bc(null),u=ly(),d=On(document.activeElement===n),[g]=Bc(()=>document.createRange());d.triggerRef.current=g,Dc(()=>()=>g.detach(),[]),Dc(()=>{let m=t.current,v=a.current;!m||!v||(g.setStart(m,0),g.setEnd(v,0))},[t.current,a.current]),vt(()=>{d.close()});let f=ay(m=>{let v=g.toString(),T=/^http(s?):\/\//.test(m)?m:`https://${m}`;u(Do({text:`[${v}](${T})`,replace:"selection"}))},[]);return Nr("span",{children:[fe("mark",{ref:a,className:Or(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:s}),d.opened&&fe(Dn,{className:i.popoverRoot,triggerRef:d.triggerRef,boundaryRef:e,position:"above",align:"start",children:Nr(Hn,{style:o,ref:l,children:[fe("div",{className:Or(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:Nr("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[fe(Pc,{}),fe("span",{children:"\xA0"}),fe("span",{children:r("insertLink")})]})}),c==="insertLink"&&fe(Oc,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:f,onDismiss:()=>{p(null),d.close()}})]})})]},"selection-end")},Kn=class extends sy{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=ry(),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?fe(cy,{ref:this.startRef}):fe(py,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};import{jsx as Nt,jsxs as vy}from"react/jsx-runtime";var hy=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",_c),p=C("insertLink"),u=C("showMidSentenceSuggestions"),d=C("inlineSuggestions"),g=nn(a),f=my(null);gy(()=>{Fe(a)&&g&&sn(a,g)},[g]);let m=dy(h=>{if(!s||!o)return h;let x=[Nt("span",{className:c.resetIndent,children:"\u200B"},"u200B"),Nt("span",{"data-testid":"tab-completion",className:Dr(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&x.push(Nt("span",{className:Dr(c.hint,c.resetIndent),children:Nt(cs,{keyCode:"tab"},"tabHint")})),Er(h,x)},[s,o,n]),v=Fc(()=>{let h=[];return p&&h.push(new Kn("selection")),h.push(new yt("placeholders")),r&&h.push(new Bn("keywords")),h},[d,p,r]),T=Fc(()=>{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?vy("div",{ref:h=>{h!=null&&h.parentElement&&(f.current=h==null?void 0:h.parentElement)},className:c.root,style:T,children:[Nt(uy,{tagName:"span",containerTagName:"div",className:Dr(c.container,c.agentText),disableLineBreaks:Fe(a),content:e||"\u200B",onAfterParse:m,matchers:v,selection:g,keywordMatches:i,inputElement:a,inputStyle:T,boundaryRef:f,inlineSuggestionsOnlyAtEnd:!u}),Nt("br",{})]}):null},yy=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var m;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??Xt(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:u}=s,{showTabCompletion:d,visible:g,showStyleSuggestions:f}=o;return{showTabHint:p,showStyleSuggestions:f,showTabCompletion:d,content:l,tabText:c,source:a,keywordMatches:((m=n.list)==null?void 0:m.keywordMatches)??[],enabled:g&&u!==!1}},Kc=fy(yy)(hy);import Yy from"classnames";import{useEffect as ev}from"react";import{useDispatch as tv,useSelector as ee}from"react-redux";import{createAsyncThunk as mo,createSlice as Sy}from"@reduxjs/toolkit";var Uc={list:[],fetchState:"idle",isInitialRequest:null},jc=t=>t.autoflows.list||[],zc=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},ke=mo("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Hr=mo("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(ke(t.platformSessionId))}),Br=mo("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(ke(t.platformSessionId))}),_y=Sy({name:"autoflows",initialState:Uc,reducers:{},extraReducers:t=>{t.addCase(Hr.pending,(e,o)=>{let n=zc(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Br.pending,(e,o)=>{let n=zc(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(ke.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(ke.rejected,e=>{e.fetchState="error"}),t.addCase(ke.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(R,()=>Uc)}}),qc=mo("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(ke(t))}),s.on("sessionCompleted",()=>{o(ke(t))})}),Vc=mo("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Wc=_y.reducer;import{createAsyncThunk as ho,createSlice as xy}from"@reduxjs/toolkit";var Gc={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},$c=t=>t.customMessages.list,Xc=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Qc=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Zc=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),fo=ho("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),Un=ho("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)}),zn=ho("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)}),Jc=xy({name:"customMessages",initialState:Gc,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(fo.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(fo.rejected,e=>{e.fetchState="error"}).addCase(fo.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(Un.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(Un.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(zn.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(zn.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,()=>Gc)}}),Yc=ho("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(Jc.actions.onCustomMessage(r))})}),ep=ho("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),tp=Jc.reducer;import{createAsyncThunk as op,createSlice as by}from"@reduxjs/toolkit";var Cy={jwt:null,accountUrl:null,interval:null},np=t=>e=>{let{exchangeToken:{jwt:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/jwt/?jwt=${o}&redirect=${t}`:null},Fr=op("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.getTemporaryExchangeToken();return{accountUrl:o.client.baseUrl,jwt:n}}),Kr=op("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:o=1e3*60*30}=t,{dispatch:n}=e;return n(Fr()),setInterval(()=>n(Fr()),o)}),sp=by({name:"exchangeToken",initialState:Cy,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Fr.fulfilled,(e,o)=>{e.jwt=o.payload.jwt,e.accountUrl=o.payload.accountUrl}),t.addCase(Kr.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollExchangeToken:rp}=sp.actions,ip=sp.reducer;function ap(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}import{Fragment as My}from"react";import{connect as Ny}from"react-redux";import Py from"classnames";import{Fragment as Ay}from"react";import wy from"classnames";var lp={root:"_root_838fd_1"};import{jsx as Ey}from"react/jsx-runtime";var Ty=({className:t,children:e})=>{let o=y("Unicode",lp);return Ey("span",{className:wy(t,o.root),children:e})},cp=Ty;var pp={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 Ur={};j(Ur,{enUS:()=>ky,nlNL:()=>Ry});var ky={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"}]},Ry={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 ot,jsxs as jn}from"react/jsx-runtime";var Ly=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",pp),a=w(Ur),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return jn(N,{className:Py(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[ot(B,{children:jn(B.Content,{children:[jn(B.Title,{children:[e&&ot("span",{className:i.stateBadge,children:a(e)}),o]}),ot("span",{children:n})]})}),ot(N.Actions,{fixed:e==="Started",children:ot(N.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:jn(Ay,{children:[ot(cp,{children:c})," ",ot("span",{children:a(l)})]})})})]})},up=Ly;import{jsx as dp}from"react/jsx-runtime";var Oy=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Dy=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>dp(My,{children:t.map(s=>dp(up,{displayName:s.displayName,description:s.description,disabled:s.isBusy||Oy(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),Hy=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},By={onStartAutoflow:Hr,onStopAutoflow:Br},gp=Ny(Hy,By)(Dy);import{useEffect as Fy,useState as Ky}from"react";import{useDispatch as Uy}from"react-redux";import hp from"classnames";import{jsx as mp}from"react/jsx-runtime";var zr=()=>mp("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:mp("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 fp={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 yp}from"react/jsx-runtime";var zy=({entities:t})=>{let e=y("EntitiesWidgetList",fp),[o,n]=Ky(void 0),s=Uy(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),ao(a.text),s(q({name:"entity copied",data:{entity:a,type:"copy"}})))};return Fy(()=>{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)=>yp("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[Ot("span",{className:e.entityText,children:a.text}),yp("span",{className:e.iconWrapper,children:[Ot("span",{className:hp(e.icon),children:Ot(zr,{})}),Ot("span",{className:hp(e.icon,o===l&&e.iconClicked),children:Ot(zr,{})})]})]},a.text))})},vp=zy;import jy from"classnames";import{useCallback as Sp}from"react";import{useDispatch as qy,useSelector as qn}from"react-redux";var Re={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 Vn}from"react/jsx-runtime";var Vy=({suggestion:t})=>{let e=w(Qe),o=qy(),n=qn(Xc(t.text)),s=qn(Qc(t.text)),r=qn(Zc(t.text)),i=qn(Ro),{replyOptions:a}=t,l=Sp(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(Un({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=Sp(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let u=parseInt(p.target.dataset.index,10),d=a[u];o(zn({platformSessionId:i,reply:d,suggestion:t}))},[t,n,o,i]);return Vn(N,{onClick:l,className:jy(Re.root,{[Re.isUsed]:n,[Re.hasError]:r}),children:[Ke(B,{children:Vn(B.Content,{children:[Vn(B.Title,{className:Re.title,children:[t.text," ",Ke(ps,{className:Re.label,children:"analyse tool"})," ",r&&Ke("span",{className:Re.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&Ke("ul",{className:Re.quickReplies,children:a.map(p=>Ke("li",{className:Re.quickReply,children:p.title},p.title))})]})}),Vn(N.Actions,{fixed:r||n,children:[a&&a.length>0&&Ke(N.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,u)=>Ke(N.DropdownItem,{index:u,label:p.title,onClick:c},p.title))}),Ke(N.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},_p=Vy;import{jsx as xp}from"react/jsx-runtime";var bp=()=>xp("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:xp("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 $y}from"react-redux";import{useCallback as Wy}from"react";import{jsx as nt,jsxs as Wn}from"react/jsx-runtime";var Gy=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var d;let s=t.text||t.url||t.message,r=hn(s),i=w(Qe),a=C("showImages"),l=C("fallbackImage"),c=g=>{g.preventDefault(),g.stopPropagation(),n(s)},p=g=>{g.preventDefault(),g.stopPropagation(),o(t)},u=Wy(g=>{window.open(r,"_blank"),g.stopPropagation(),g.preventDefault()},[r]);return Wn(N,{onClick:c,"data-testid":"edit-suggestion",children:[Wn(B,{children:[a&&t.image&&nt(B.Image,{src:Fn(t,"small",l||void 0),title:t.title}),Wn(B.Content,{children:[t.title&&nt(B.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((d=t.searchKeywords)==null?void 0:d.length)>0&&nt(N.Labels,{labels:t.searchKeywords}),nt(B.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),Wn(N.Actions,{children:[r&&nt(N.ActionButton,{onClick:u,label:i("visitUrl")}),nt(N.ActionButton,{primary:!0,onClick:p,label:i("preview")}),nt(N.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},Cp=Gy;import{Fragment as Qy,jsx as wp}from"react/jsx-runtime";var Xy=({contentType:t,lines:e,suggestions:o})=>{let n=se(),s=$y(wt),r=a=>{n.send(ir,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(Ce,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return wp(Qy,{children:o.map(a=>wp(Cp,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},Tp=Xy;var jr={};j(jr,{enUS:()=>Zy,nlNL:()=>Jy});var Zy={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"}]},Jy={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 Ep={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 kp}from"react/jsx-runtime";var Rp=()=>kp("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:kp("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 Ip}from"react/jsx-runtime";var Pp=()=>Ip("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:Ip("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 Gn=(t,e)=>{let o=ee(oe);ev(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},ov=()=>{let t=w(jr),e=tv(),o=C("isEmbedded"),n=y("Widget",Ep),s=C("showAutoflows"),r=C("showCustomMessages"),i=C("showPersonalCollectionLink"),a=C("showSummaryCommand"),l=C("showKnowledgeSearch"),c=C("showSearch"),p=ee(At),u=ee(Tn),d=ee(jc),g=ee(bn),f=ee($c),m=ee(Io),v=ee(mt),T=ee(oe),h=ee(Ro),x=ee(ap),b=ee(wt),S=se(),O=ee(Ja),M=ee(np("/admin/personal-collection")),W=C("adminUrl");if(Gn(()=>(e(fo(h)),e(Yc(h)),()=>{e(ep(h))}),[e,v,r,h]),Gn(()=>(e(ke(h)),e(qc(h)),()=>{e(Vc(h))}),[e,v,s,h]),Gn(()=>{u.forEach(({type:k})=>{e(k==="entities"?ce():_e(k))})},[e,v,m,p]),Gn(()=>(e(Kr()),()=>{e(rp())}),[e,v,i,m]),v===!1)return L("div",{className:n.stateText,children:L("div",{children:L("p",{children:t("notSupported")})})},"supported");if(T===!1)return L("div",{className:n.loginText,children:L("div",{children:L(Ln,{isEmbedded:o,loginUrl:W})})},"login");if(!p||!h||T===null||O||x)return L("div",{className:n.stateText,children:L("div",{children:L("p",{children:t("waiting")})})},"waiting");let D=c||a||l||M;return L("div",{className:Yy(n.root),"data-testid":"widget",children:Dt(ds,{className:n.sectionList,children:[D&&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:()=>S.send("ShowCommandPalette",{isOpen:!0}),children:[L(bt,{}),t("linkSearch")]}),a&&Dt("button",{className:n.shortcut,"data-testid":"shortcut-summary",onClick:()=>S.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[L(Pp,{}),t("linkSummary")]}),l&&Dt("button",{className:n.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>S.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[L(Rp,{}),t("linkKnowledgeSearch")]}),M&&Dt("a",{className:n.shortcut,target:"_blank",href:M,"data-testid":"shortcut-personal-collection",rel:"noreferrer",children:[L(bp,{}),t("linkPersonalcollection")]})]})}),r&&f.length>0&&L(je,{type:"custom-messages","data-testid":"custom-messages",children:L(re,{withDivider:!0,children:f.map(k=>L(_p,{suggestion:k},k.text))})}),s&&d.length>0&&L(je,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:L(re,{withDivider:!0,children:L(gp,{})})}),u.map(({type:k,title:H,amount:X,lines:ns})=>{var ze;switch(k){case"entities":return g&&g.length>0&&L(je,{type:k,title:H,"data-testid":`type-${k}`,children:L(vp,{entities:g})},k);default:return((ze=b[k])==null?void 0:ze.fetchState)==="done"&&b[k].suggestions.length>0&&L(je,{type:k,title:H,"data-testid":`type-${k}`,children:L(re,{withDivider:!0,children:L(Tp,{lines:ns,contentType:k,suggestions:b[k].suggestions.slice(0,X)||[]})})},k)}})]})})},Ap=ov;function vo(t){let e=new Range;return e.selectNodeContents(t),e}function Lp(t,e,o){try{return st(t,e,o),!0}catch{return!1}}function $n(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function Xn(t){return"tagName"in t&&t.tagName==="BR"}var yo=/[\u200B-\u200D\uFEFF]/g;function st(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(yo,""),u=s+p.length,d=e>=s&&e<=u,g=o>=s&&o<=u;if(d){let f=i(c,e-s);f===0&&!g?n.setStartBefore(l):n.setStart(l,f)}g&&(n.setEnd(l,i(c,o-s)),r=!0),s=u;break}case Node.ELEMENT_NODE:{if(Xn(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;$n(l)&&c&&!$n(c)&&!Xn(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}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,collapsed:i}=e,a,l,c=0;function p(u){let d=u===o,g=u===s;switch(u.nodeType){case Node.TEXT_NODE:{let f=u.textContent;d&&(a=c+f.substring(0,n).replace(yo,"").length),g&&(l=c+f.substring(0,r).replace(yo,"").length),c+=f.replace(yo,"").length;break}case Node.ELEMENT_NODE:{let f=u.nextSibling===null;Xn(u)&&!f&&c++;for(let m=0;m<u.childNodes.length;m++){let v=d&&m===n,T=g&&m===r;if(v&&(a=c),T&&(l=c),l!==void 0||((!v||!i)&&p(u.childNodes[m]),g&&m===r-1&&(l=c),l!==void 0))break}!g&&$n(u)&&!f&&c++,g&&(l=c);break}default:break}}if(p(t),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function Zn(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,g=u?r:void 0,f=c.textContent.replace(yo,"");d===0&&g===void 0?a+=f:a+=f.substring(d,g);break}case Node.ELEMENT_NODE:{let d=c.nextSibling===null;i===0&&Xn(c)&&!d&&(a+=`
4
4
  `);for(let g=p?n:0;g<(u?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[g]),i!==1);g++);!u&&i===0&&$n(c)&&!d&&(a+=`
5
- `);break}default:break}u&&i++}return l(t),a}function Ip(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Ht=class extends Oe{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),Zn(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!Ip(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!Ip(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return Qn(this.element,e);let o=this.lastKnownSelection;if(o&&Rp(this.element,o.start,o.end))return o;let n=yo(this.element);return n.collapse(!1),Qn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return Zn(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()}};function Pp(t,e,o){let n=`deepdesk-iframe-${t}`,s=document.getElementById(n);if(s)return s;let r=document.createElement("iframe"),i=new URL(e);return Object.entries(o).forEach(([a,l])=>{i.searchParams.append(a,l)}),r.style.position="absolute",r.style.left="-999em",r.style.width="0px",r.style.height="0px",r.tabIndex=-1,r.id=n,r.title=`iframe-${t}`,r.src=i.toString(),window.document.body.appendChild(r),r}var qr=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()}},Vr=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=Pp(e,`${this.targetOrigin}/v2/widget/liveengage/channel.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(e,this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},Wr=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 Vr(e,this.deepdeskUrl,{debug:!0}):new qr(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)}},Ap=Wr;var Bt=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Gr=t=>new Promise(e=>{setTimeout(e,t)});var Ft=class extends Bt{name="ClientError"},$r=class extends Bt{name="ServerError"},he=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:g=x=>x.status>=500,version:f="v1",...m}=o,v={credentials:"include",...m,headers:{"Content-Type":"application/json",...m.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=>g(x)&&!r.isAborted&&w>0?(await Gr(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 Gr(p),y();throw x}));y().then(x=>x.json().catch(()=>null).then(C=>{x.status>=500?s(new $r("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 $y;(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||={})})($y||={});function Jn(t){return{...A(t),tags:t.tags}}var Ue=class t{constructor(e,o={}){this.options=o;this.client=new he(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 Jn(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 Jn(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 Jn(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=>Jn(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(li);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 So=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Zs(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 Xy;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(Xy||={});var vo=class{constructor(e,o={}){this.apiUrl=e;this.client=new he(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 So(`${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 oS,configureStore as nS}from"@reduxjs/toolkit";import{createSlice as Qy}from"@reduxjs/toolkit";var Lp={startTime:null,stopTime:null},Mp=Qy({name:"handlingTime",initialState:Lp,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,()=>Lp)}}),{handlingTimeStart:Op,handlingTimeStop:Yn,handlingTimeReset:Np}=Mp.actions,Dp=Mp.reducer;var Hp=(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 Zy,createSlice as Jy}from"@reduxjs/toolkit";var es={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var nt=Zy("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 es.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),Yy=Jy({name:"styleSuggestions",initialState:es,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",Pe(e.list,o.payload)||(e.list=o.payload)}).addCase(We,e=>{e.list=es.list}).addCase(R,()=>es)}}),Bp=Yy.reducer;var Fp=(t={})=>{let e,o=!0,n={getStyleSuggestions:nt,debounce:500,...t};return s=>r=>i=>{var g;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:p}=c.settings;if(!((g=c.conversation.current)==null?void 0:g.id)||!p)return l;let{text:d}=c.input;return d===a&&!o||(clearTimeout(e),d==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:d}))},t.debounce)),l}};function eS(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Kp=(t={})=>{let e={getTextSuggestions:_e,getAutocompleteSuggestions:eo,debounce:200,check:Lt,...t},o;return n=>s=>r=>{var m;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=(m=l.conversation.current)==null?void 0:m.id,d=r.type===vn.toString();if(!u||!c&&!p)return a;let{input:{userCommitted:g}}=l;return eS(g,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 Up=nt.fulfilled.toString();function tS(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 zp=t=>e=>o=>n=>{var c;if(n.type!==Up){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=tS(s,i);n.type===Up&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var sS=oS({activeSuggestion:sl,answer:Vl,auth:yl,autoflows:zc,conversation:mi,contentTypes:Rl,customMessages:Zc,exchangeToken:op,entities:Al,handlingTime:Dp,info:ka,input:_s.reducer,overlayInput:$.reducer,settings:pi,profile:Ql,search:Ma,summary:Bl,styleSuggestions:Bp,ui:ll,textSuggestions:Ya});function jp(t){return nS({reducer:sS,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Hp(),Kp({debounce:200}),Fp({debounce:500}),zp(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var rS=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},iS=t=>e=>o=>n=>{var a;let s=e.getState(),r=hs("inlineSuggestions")(s);switch(n.type){case xe.toString():{let l=Ga(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:rS(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Do.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 Ko.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 ce.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case we.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 Ho.toString():t.handleKeyDown(n.payload);break;case We.toString():t.logSendMessage(n.payload);break;case Bo.toString():t.logSendEditSuggestionMessage(n.payload);break;case Fo.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case We.toString():t.handleAfterSendMessage(n.payload);break;case to.toString():t.onUpdateShowTabHint(n.payload);break;case Yn.toString():t.logHandlingTime();break;case re.toString():{r&&(e.dispatch(ue([])),e.dispatch(Me()));break}case ue.toString():{r&&n.payload.length>0&&e.dispatch(Le(0));break}default:break}return i},qp=iS;function Xr(t){return t.toISOString().replace("T"," ").replace("Z","")}function Vp(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:Xr(o),timeStop:Xr(n)}}function Qr(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:g,textSuggestions:f,offeredTextSuggestions:m}}=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:g,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:m.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 Wp(t,e){let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;return n instanceof HTMLElement?Wp(n,e):null}function Gp(t,e){return Wp(t,e)}function $p(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function aS(t){return typeof t=="object"&&t!==null&&"tagName"in t}function Zr(t){return aS(t)&&(Fe(t)||on(t))}var Xp=(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 lS(t){return t.offsetParent!==null}function Qp(t){if(!lS(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 Jr(t,e,o=100){let n=Qp(t);e({isVisible:n});let s=setInterval(()=>{let r=Qp(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}import{jsx as W}from"react/jsx-runtime";var Zp=Xp("showTabHint",!0),os=class t{static version="10.6.2-beta.0";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;authIframe=null;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:[qp({emit:(u,d,g)=>this.emit(u,d,g),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=>Zp.update(u),sendEvent:(u,d)=>this.deepdeskApi.sendEvent(u,d)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new vo(o)}),this.store=jp(p),this.broadcastEvents=new Ap({debug:!0,deepdeskUrl:c,eventMap:Sl(this.store),createCustomChannel:l}),this.store.dispatch(zt),this.store.dispatch(to(Zp.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();le(n)&&ul(n)!=="loading"&&e()});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(be())).payload}async setPlatformAgentId(e){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:e}),version:null})}catch(o){E.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(Ss({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Po(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Ao({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(vs(e))).payload}async postMessages(e){return(await this.store.dispatch(Mo(e))).payload}async updateConversation(e){return(await this.store.dispatch(Lo(e))).payload}resetConversation(){this.store.dispatch(R()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(we());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(Ea(e))}async setAgentInfo(e){await this.store.dispatch(Zt(e))}async setAgentSettings(e){await this.store.dispatch(Ys(e))}async getAgentSettings(){return(await this.store.dispatch(er())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(vn()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Fo(e))}notifyKeyDown(e){this.store.dispatch(Ho(e))}notifyPaste(e,o){this.store.dispatch(Ti({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Ci(e))}notifyExternalSuggestion(e){this.store.dispatch(re(e)),this.store.dispatch(Me())}notifyEditSuggestion(e){this.store.dispatch(Za(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(Be({collapse:!1})),this.inputMediator&&this.store.dispatch(yi({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(ue([])))}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(wi(No(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(_i()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(bi());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(Le(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(Le(-1)),this.store.dispatch(jt()),e.preventDefault()):o||(this.store.dispatch(Be({collapse:!0})),this.store.dispatch(il(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:u}=this.state.input,d=u.text.substring(0,u.selection.end),{tabCompletionSuggestion:g}=this.state.input;this.store.dispatch(to(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&g&&g.text.startsWith(d)&&(this.store.dispatch(re({text:g.text,suggestion:g,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(Me())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ei()),this.store.dispatch(ue([]))}handlingTimeStart(){this.state.handlingTime.startTime||(E.info("Start handling time"),this.store.dispatch(Op()))}handlingTimeStop(){this.state.handlingTime.startTime&&(E.info("Stop handling time"),this.store.dispatch(Yn()))}logSendMessage(e){let o=Qr("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=Qr("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(vi(this.state.overlayInput.metrics))}logHandlingTime(){let e=Vp(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Np())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(Me()),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(()=>{ts(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(()=>{ts(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(()=>{ts(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(!Zr(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:g,inputMediator:f,closestScrollSelector:m,appendOverlayTo:v,inlineSuggestions:w}=o;if(this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:g,isEmbedded:u,inlineSuggestions:w}),o.automaticHandlingTime&&this.setupHandlingTime(e),$e(e),this.inputMediator=f||(Fe(e)?new Ne(e):new Ht(e)),this.inputMediator.on("change",({plainText:y})=>{this.notifyInputChanged(y)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(ki({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");_o(W(Mt,{store:this.store,customStyles:n,children:W(wt,{broadcastEvents:this.broadcastEvents,children:W(ic,{})})}),y),this.inputMediator.on("caret",x=>{this.store.dispatch(ue([])),x?(y.style.display="block",y.style.top=`${x.top}px`,y.style.left=`${x.left}px`):y.style.display="none"})}else{let y=m&&Gp(e,m)||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);_o(W(Mt,{store:this.store,customStyles:n,children:W(wt,{broadcastEvents:this.broadcastEvents,children:W(Dc,{inputElement:e})})}),x),_o(W(Mt,{store:this.store,customStyles:n,children:W(wt,{broadcastEvents:this.broadcastEvents,children:W(fc,{})})}),C)}_o(W(Mt,{store:this.store,customStyles:n,children:W(wt,{broadcastEvents:this.broadcastEvents,children:W(ec,{})})}),this.createContainer("deepdesk-overlays"));let h;this.inputMediator.on("selection",y=>{clearTimeout(h),y===null?h=setTimeout(()=>{y!==null&&this.store.dispatch(xs(y))},500):this.store.dispatch(xs(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(Si({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}),_o(W(Mt,{store:this.store,customStyles:n,children:W(wt,{broadcastEvents:this.broadcastEvents,children:W(kp,{})})}),e),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&ts(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=Jr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){$p(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(ao());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 loginViaPopup(){return new Promise((e,o)=>{let n=this.state.settings.adminUrl,s=new MessageChannel,r=s.port1,i=new URL(`${n}/platform/sso/`);i.searchParams.append("redirect","/sdk/popup/close.html");let a=!1,l=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",p),clearInterval(u)};r.onmessage=async d=>{var g,f;if((g=d.data)!=null&&g.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((f=d.data)==null?void 0:f.jwt),this.broadcastEvents.send(no),l(),a=!0,s.port1.close(),e()}catch(m){o(m)}};let c=window.open(i.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&o(new Error("Popup blocked by browser"));let p=async d=>{var g;if(d.origin===i.origin)switch((g=d.data)==null?void 0:g.type){case"deepdesk-popup-loaded":{c==null||c.postMessage({type:"deepdesk-popup-create-channel"},i.origin,[s.port2]);break}case"deepdesk-popup-error":{l(),d.data.message==="Timeout"&&E.warn("Popup timed out. Check if the account's platform url is configured correctly."),o(new Error(d.data.message));break}}};window.addEventListener("message",p);let u=setInterval(()=>{c&&!c.closed||(l(),a||o(new Error("Popup closed by user")))},200);this.unmountHandlers.push(l)})}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=Tn(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(ce()):this.store.dispatch(_e(n))})}catch(n){this.handleError(n)}}};async function cS(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 pS(t,e,o={}){let n=o.replace?ot(t,o.replace.start,o.replace.end):yo(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 uS(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 dS(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function gS(t,e,o){await new Ue(t).authenticateWithKey(e,o)}async function mS(t){let o=await new he(t).get("/platform/config/",{version:null});return A(o)}async function fS(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 hS(t,e){let o=await fS(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,os as DeepdeskSDK,he as HTTPClient,Oe as InputMediator,qe as InputType,cs as KeyboardHint,ps as Label,ko as Locale,je as Section,ds as SectionList,pe as Sources,M as Suggestion,se as SuggestionList,Ne as TextAreaInput,ct as ToggleButton,hS as attachFile,gS as authenticateWithKey,yo as createFullRange,St as createOverlayContainer,ot as createRangeFromOffsets,$t as escapeHTML,mS as fetchPlatformConfig,dS as formatTextMarkup,Qn as getRangeOffsets,Zn as getRangeText,uS as insertCKEditor,Zr as isSupportedInputElement,pS as updateContentEditable,cS as updateTextArea,S as useStyles,Jr as waitForElementVisibilityChange};
5
+ `);break}default:break}u&&i++}return l(t),a}function Mp(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Ht=class extends Ne{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),Zn(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 Qn(this.element,e);let o=this.lastKnownSelection;if(o&&Lp(this.element,o.start,o.end))return o;let n=vo(this.element);return n.collapse(!1),Qn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return Zn(this.element,st(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return(s=this.observer)==null||s.takeRecords(),Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};function Np(t,e,o){let n=`deepdesk-iframe-${t}`,s=document.getElementById(n);if(s)return s;let r=document.createElement("iframe"),i=new URL(e);return Object.entries(o).forEach(([a,l])=>{i.searchParams.append(a,l)}),r.style.position="absolute",r.style.left="-999em",r.style.width="0px",r.style.height="0px",r.tabIndex=-1,r.id=n,r.title=`iframe-${t}`,r.src=i.toString(),window.document.body.appendChild(r),r}var qr=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()}},Vr=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=Np(e,`${this.targetOrigin}/v2/widget/liveengage/channel.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(e,this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},Wr=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 Vr(e,this.deepdeskUrl,{debug:!0}):new qr(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)}},Op=Wr;var Bt=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Gr=t=>new Promise(e=>{setTimeout(e,t)});var Ft=class extends Bt{name="ClientError"},$r=class extends Bt{name="ServerError"},he=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=b=>b instanceof TypeError,retryOnResponse:g=b=>b.status>=500,version:f="v1",...m}=o,v={credentials:"include",...m,headers:{"Content-Type":"application/json",...m.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 T=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 x=async()=>(T--,a(i,v).then(async b=>g(b)&&!r.isAborted&&T>0?(await Gr(p),x()):b.status===401&&u===!0&&h===!1?(h=!0,await this.refreshToken(),x()):b).catch(async b=>{if(d(b)&&!r.isAborted&&T>0)return await Gr(p),x();throw b}));x().then(b=>b.json().catch(()=>null).then(S=>{b.status>=500?s(new $r("Server Error",S)):b.status===401?s(new Ft("Unauthorized",S)):b.status===403?s(new Ft("Forbidden",S)):b.status===404?s(new Ft("Not Found",S)):b.status>=400&&s(new Ft("Bad Request",S)),delete this.latestRequestByUrl[i],n(S)})).catch(b=>{s(b)})})}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var nv;(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||={})})(nv||={});function Jn(t){return{...A(t),tags:t.tags}}var Ue=class t{constructor(e,o={}){this.options=o;this.client=new he(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",{...F(e),tags:e.tags},{version:"v2"});return Jn(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 Jn(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=F(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return Jn(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...F(s),tags:s.tags})),{version:"v2"})).map(s=>Jn(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",F({...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:F({...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/",F(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}`,F(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`,F(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",F(e),{abortLatest:!0});return A(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,F(e),{version:"v2"});return A(o)}async knowledgeAssist(e,o,n){let s=await this.client.post("/api/knowledge-search/search",F({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(di);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 So=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Zs(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 sv;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(sv||={});var _o=class{constructor(e,o={}){this.apiUrl=e;this.client=new he(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`,F(o));return A(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,F(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",F(e));return A(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new So(`${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 uv,configureStore as dv}from"@reduxjs/toolkit";import{createSlice as rv}from"@reduxjs/toolkit";var Dp={startTime:null,stopTime:null},Hp=rv({name:"handlingTime",initialState:Dp,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,()=>Dp)}}),{handlingTimeStart:Bp,handlingTimeStop:Yn,handlingTimeReset:Fp}=Hp.actions,Kp=Hp.reducer;var Up=(t={})=>{let e={onAuthError:Et(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};import{createAsyncThunk as iv,createSlice as av}from"@reduxjs/toolkit";var es={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var rt=iv("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 es.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),lv=av({name:"styleSuggestions",initialState:es,reducers:{},extraReducers:t=>{t.addCase(rt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(rt.rejected,e=>{e.fetchState="error"}).addCase(rt.fulfilled,(e,o)=>{e.fetchState="done",Pe(e.list,o.payload)||(e.list=o.payload)}).addCase(We,e=>{e.list=es.list}).addCase(R,()=>es)}}),zp=lv.reducer;var jp=(t={})=>{let e,o=!0,n={getStyleSuggestions:rt,debounce:500,...t};return s=>r=>i=>{var g;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:p}=c.settings;if(!((g=c.conversation.current)==null?void 0:g.id)||!p)return l;let{text:d}=c.input;return d===a&&!o||(clearTimeout(e),d==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:d}))},t.debounce)),l}};function cv(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var qp=(t={})=>{let e={getTextSuggestions:_e,getAutocompleteSuggestions:to,debounce:200,check:Mt,...t},o;return n=>s=>r=>{var m;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=(m=l.conversation.current)==null?void 0:m.id,d=r.type===Sn.toString();if(!u||!c&&!p)return a;let{input:{userCommitted:g}}=l;return cv(g,i)&&!d||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let v=ft(l);v===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(v))},d?0:e.debounce)),a}};var Vp=rt.fulfilled.toString();function pv(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 Wp=t=>e=>o=>n=>{var c;if(n.type!==Vp){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=pv(s,i);n.type===Vp&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var gv=uv({activeSuggestion:ll,answer:Xl,auth:xl,autoflows:Wc,conversation:vi,contentTypes:Ll,customMessages:tp,exchangeToken:ip,entities:Ol,handlingTime:Kp,info:Aa,input:_s.reducer,overlayInput:Q.reducer,settings:mi,profile:ec,search:Ha,summary:zl,styleSuggestions:zp,ui:dl,textSuggestions:nl});function Gp(t){return dv({reducer:gv,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Up(),qp({debounce:200}),jp({debounce:500}),Wp(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var mv=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},fv=t=>e=>o=>n=>{var a;let s=e.getState(),r=hs("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 Et.toString():{!n.payload&&t.emit("logout",void 0);break}case ie.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:mv(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Do.toString():{let{start:l,end:c}=s.input.selection;t.emit("replace",{...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case qt.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case Ko.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 ce.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case we.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary}});break;case q.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 Ho.toString():t.handleKeyDown(n.payload);break;case We.toString():t.logSendMessage(n.payload);break;case Bo.toString():t.logSendEditSuggestionMessage(n.payload);break;case Fo.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case We.toString():t.handleAfterSendMessage(n.payload);break;case oo.toString():t.onUpdateShowTabHint(n.payload);break;case Yn.toString():t.logHandlingTime();break;case ie.toString():{r&&(e.dispatch(ue([])),e.dispatch(Me()));break}case ue.toString():{r&&n.payload.length>0&&e.dispatch(Le(0));break}default:break}return i},$p=fv;function Xr(t){return t.toISOString().replace("T"," ").replace("Z","")}function Xp(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:Xr(o),timeStop:Xr(n)}}function Qr(t,e,o){var M,W,D;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:u,cuts:d,deletions:g,textSuggestions:f,offeredTextSuggestions:m}}=e[t],v=n.length,h=f.reduce((k,{text:H,searchTerm:X})=>k+H.length-(X?X.length:0),0),x=c??Date.now(),b=(Date.now()-x)/1e3+(p||0),S=s/b,O=f.reduce((k,{searchTerm:H})=>k+(H?H.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:u,cuts:d,deletions:g,lenTextTyped:s+O,lenTextTotal:v,lenTextAssisted:h,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:b,charsPerSecond:S,numPastes:l,textSuggestionsV2:f,suggestionsCounters:[{source:"gpt",countOffered:m.filter(k=>k.source==="gpt").length}],agentId:(M=e.info.agentInfo)==null?void 0:M.agentId,agentName:(W=e.info.agentInfo)==null?void 0:W.agentName,agentEmail:(D=e.info.agentInfo)==null?void 0:D.agentEmail}}function Zr(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return Zr(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?Zr(s,e):null}function Qp(t,e){return Zr(t,e)}function Zp(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function hv(t){return typeof t=="object"&&t!==null&&"tagName"in t}function Jr(t){return hv(t)&&(Fe(t)||on(t))}var Jp=(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 yv(t){return t.offsetParent!==null}function Yp(t){if(!yv(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 Yr(t,e,o=100){let n=Yp(t);e({isVisible:n});let s=setInterval(()=>{let r=Yp(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}import{useSelector as xv}from"react-redux";import{jsx as ei}from"react/jsx-runtime";var eu=({className:t})=>ei("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 512 512",xmlSpace:"preserve",className:t,children:ei("g",{children:ei("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
6
+ c-17.9,17.9-27.3,40.1-27.3,65.7C163.4,163,163.4,233,163.4,233z M465.5,267.9V477c0,9.4-3.4,17.9-10.2,24.7
7
+ c-6.8,6.8-15.4,10.2-24.7,10.2h-349c-9.4,0-17.9-3.4-24.7-10.2c-6.8-6.8-10.2-15.4-10.2-24.7V267.9c0-9.4,3.4-17.9,10.2-24.7
8
+ c6.8-6.8,15.4-10.2,24.7-10.2h11.9v-70c0-44.4,16.2-82.8,47.8-115.2S212.1,0,256.4,0s82.8,16.2,115.2,47.8
9
+ c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});import{jsx as tu}from"react/jsx-runtime";var vv={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},ou=({className:t,color:e})=>tu("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:tu("path",{d:"M172.03 0.0199966H0V86.03C47.5 86.03 86 124.54 86 172.04C86 124.54 124.51 86.03 172.01 86.03C219.51 86.03 258.03 124.54 258.03 172.04C258.03 219.54 219.52 258.05 172.01 258.05C124.5 258.05 86 219.54 86 172.04C86 219.54 47.5 258.05 0 258.05V344.06H172.03C267.04 344.06 344.06 267.04 344.06 172.03C344.06 77.02 267.04 0 172.03 0V0.0199966Z",fill:vv[e||"pink"]})});var nu={root:"_root_bgd7a_1",text:"_text_bgd7a_18",icon:"_icon_bgd7a_33",logo:"_logo_bgd7a_38",lock:"_lock_bgd7a_43"};var ti={};j(ti,{enUS:()=>Sv,nlNL:()=>_v});var Sv={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:0,value:"Search"}]},_v={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:0,value:"Zoek"}]};import{useDispatch as bv}from"react-redux";import{jsx as oi,jsxs as su}from"react/jsx-runtime";var ru=()=>{let t=w(ti),e=C("productName"),o=C("adminUrl"),n=bv(),s=xv(oe),r=y("FloatingMenu",nu);if(s===null)return null;let i=()=>{s===!0?n(G(!0)):window.open(o,"_blank")};return su("button",{className:r.root,onClick:i,children:[oi("div",{className:r.text,children:s?t("search"):t("signin",{productName:e})}),su("div",{className:r.icon,children:[oi(ou,{className:r.logo,color:"pink"}),s===!1&&oi(eu,{className:r.lock})]})]})};import{jsx as K}from"react/jsx-runtime";var iu=Jp("showTabHint",!0),os=class t{static version="10.6.2-beta.2";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;authIframe=null;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:[$p({emit:(u,d,g)=>this.emit(u,d,g),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=>iu.update(u),sendEvent:(u,d)=>this.deepdeskApi.sendEvent(u,d)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new _o(o)}),this.store=Gp(p),this.broadcastEvents=new Op({debug:!0,deepdeskUrl:c,eventMap:bl(this.store),createCustomChannel:l}),this.store.dispatch(jt),this.store.dispatch(oo(iu.value())),this.store.dispatch(jt({locale:s,adminUrl:c,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(E.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(E.warn("Profile has not been loaded (yet)"),!0):(E.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Et(null)),this.store.dispatch(be()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();oe(n)&&fl(n)!=="loading"&&e()});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(be())).payload}async setPlatformAgentId(e){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:e}),version:null})}catch(o){E.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(vs({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Po(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Ao({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Ss(e))).payload}async postMessages(e){return(await this.store.dispatch(Mo(e))).payload}async updateConversation(e){return(await this.store.dispatch(Lo(e))).payload}resetConversation(){this.store.dispatch(R()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(we());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(jt(e))}setVisitorInfo(e){this.store.dispatch(Pa(e))}async setAgentInfo(e){await this.store.dispatch(Jt(e))}async setAgentSettings(e){await this.store.dispatch(Ys(e))}async getAgentSettings(){return(await this.store.dispatch(er())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(Sn()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Fo(e))}notifyKeyDown(e){this.store.dispatch(Ho(e))}notifyPaste(e,o){this.store.dispatch(Ii({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(ki(e))}notifyExternalSuggestion(e){this.store.dispatch(ie(e)),this.store.dispatch(Me())}notifyEditSuggestion(e){this.store.dispatch(tl(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(Be({collapse:!1})),this.inputMediator&&this.store.dispatch(xi({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(ue([])))}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(Ri(Oo(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(wi()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Ei());let{selectedSuggestionIndex:u}=this.state.input;e.preventDefault(),!i&&(u===-1?this.store.dispatch(qt()):this.stageSelectedSuggestion({inputType:"arrow"}))};switch(e.key){case"Up":case"ArrowUp":i?p():c();return;case"Down":case"ArrowDown":{i?c():p();return}case"Esc":case"Escape":{i&&l&&this.store.dispatch(Le(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(Le(-1)),this.store.dispatch(qt()),e.preventDefault()):o||(this.store.dispatch(Be({collapse:!0})),this.store.dispatch(pl(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:u}=this.state.input,d=u.text.substring(0,u.selection.end),{tabCompletionSuggestion:g}=this.state.input;this.store.dispatch(oo(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&g&&g.text.startsWith(d)&&(this.store.dispatch(ie({text:g.text,suggestion:g,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(Me())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Pi()),this.store.dispatch(ue([]))}handlingTimeStart(){this.state.handlingTime.startTime||(E.info("Start handling time"),this.store.dispatch(Bp()))}handlingTimeStop(){this.state.handlingTime.startTime&&(E.info("Stop handling time"),this.store.dispatch(Yn()))}logSendMessage(e){let o=Qr("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=Qr("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(Ci(this.state.overlayInput.metrics))}logHandlingTime(){let e=Xp(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Fp())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(Me()),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(ie({text:n[o].text,suggestion:n[o],eventMetrics:e,replace:"until-selection-end"}))}emit(e,o,n={}){let s=()=>{this.eventListeners[e]&&this.eventListeners[e].forEach(r=>{try{r(o)}catch(i){E.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),E.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=_t(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{ts(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]=_t(r,{appendTo:document.body});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{ts(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(()=>{ts(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:u,detectSubmit:d,insertLink:g,inputMediator:f,closestScrollSelector:m,appendOverlayTo:v,inlineSuggestions:T,floatingMenu:h}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:g,isEmbedded:u,inlineSuggestions:T,floatingMenu:h}),o.automaticHandlingTime&&this.setupHandlingTime(e),$e(e),this.inputMediator=f||(Fe(e)?new Oe(e):new Ht(e)),this.inputMediator.on("change",({plainText:S})=>{this.notifyInputChanged(S)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Ai({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",S=>{this.notifyKeyDown(S)}),this.inputMediator.on("paste",({pastedText:S,selectionText:O})=>{this.notifyPaste(S,O)}),this.inputMediator.on("cut",({selectionText:S})=>{this.notifyCut(S)});let x=m&&Qp(e,m)||void 0;if(T){let{customStyles:S,appendOverlayTo:O}=o;if(Fe(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let M=this.createInlineContainer(e,"deepdesk-caret");Kt(K(et,{store:this.store,customStyles:S,children:K(Ye,{broadcastEvents:this.broadcastEvents,children:K(pc,{})})}),M),this.inputMediator.on("caret",D=>{this.store.dispatch(ue([])),D?(M.style.display="block",M.style.top=`${D.top}px`,M.style.left=`${D.left}px`):M.style.display="none"});let W=this.overlayContainerFactory("floating-menu",x||e,{appendTo:O});Kt(K(et,{store:this.store,customStyles:S,children:K(Ye,{broadcastEvents:this.broadcastEvents,children:K(ru,{})})}),W)}else{let S=this.overlayContainerFactory("deepdesk-tab-completion",x||e,{appendTo:v,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),O=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||e,{appendTo:v},n==null?void 0:n.suggestionsRootNode);Kt(K(et,{store:this.store,customStyles:n,children:K(Ye,{broadcastEvents:this.broadcastEvents,children:K(Kc,{inputElement:e})})}),S),Kt(K(et,{store:this.store,customStyles:n,children:K(Ye,{broadcastEvents:this.broadcastEvents,children:K(Sc,{})})}),O)}Kt(K(et,{store:this.store,customStyles:n,children:K(Ye,{broadcastEvents:this.broadcastEvents,children:K(sc,{})})}),this.createContainer("deepdesk-overlays"));let b;this.inputMediator.on("selection",S=>{clearTimeout(b),S===null?b=setTimeout(()=>{S!==null&&this.store.dispatch(xs(S))},500):this.store.dispatch(xs(S))}),this.inputMediator.on("disabled",()=>{var S;(S=this.inputMediator)==null||S.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(Tt(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(Tt(!0))),this.store.dispatch(bi({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var S;this.refresh(),this.broadcastEvents.setSessionId((S=this.state.conversation.current)==null?void 0:S.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}),Kt(K(et,{store:this.store,customStyles:n,children:K(Ye,{broadcastEvents:this.broadcastEvents,children:K(Ap,{})})}),e),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&ts(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=Yr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Zp(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(lo());let e=At(this.state);e&&this.store.dispatch(jt({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 loginViaPopup(){return new Promise((e,o)=>{let n=this.state.settings.adminUrl,s=new MessageChannel,r=s.port1,i=new URL(`${n}/platform/sso/`);i.searchParams.append("redirect","/sdk/popup/close.html");let a=!1,l=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",p),clearInterval(u)};r.onmessage=async d=>{var g,f;if((g=d.data)!=null&&g.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((f=d.data)==null?void 0:f.jwt),this.broadcastEvents.send(so),l(),a=!0,s.port1.close(),e()}catch(m){o(m)}};let c=window.open(i.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&o(new Error("Popup blocked by browser"));let p=async d=>{var g;if(d.origin===i.origin)switch((g=d.data)==null?void 0:g.type){case"deepdesk-popup-loaded":{c==null||c.postMessage({type:"deepdesk-popup-create-channel"},i.origin,[s.port2]);break}case"deepdesk-popup-error":{l(),d.data.message==="Timeout"&&E.warn("Popup timed out. Check if the account's platform url is configured correctly."),o(new Error(d.data.message));break}}};window.addEventListener("message",p);let u=setInterval(()=>{c&&!c.closed||(l(),a||o(new Error("Popup closed by user")))},200);this.unmountHandlers.push(l)})}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=Tn(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(ce()):this.store.dispatch(_e(n))})}catch(n){this.handleError(n)}}};async function Cv(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 wv(t,e,o={}){let n=o.replace?st(t,o.replace.start,o.replace.end):vo(t),s,r=()=>{if(o.setRange)return o.setRange(n.cloneRange());n.deleteContents(),s=document.createElement("span"),n.insertNode(s),o.insertBRs!==!1?e.split(`
10
+ `).reverse().forEach((i,a)=>{a>0&&n.insertNode(document.createElement("br")),n.insertNode(document.createTextNode(i))}):n.insertNode(document.createTextNode(e))};return Promise.resolve(r()).then(()=>{try{if(o.selectionAfter!==!1){t.focus();let i=o.selectionAfter?st(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 Tv(t,e){let o;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let n=()=>{let s=t.ownerDocument.defaultView??window,r=s.getSelection();if((!r||r.rangeCount===0)&&(t.focus(),r=s.getSelection()),!r||r.rangeCount===0)return;let i=r.getRangeAt(0);i&&(i.deleteContents(),o=document.createElement("span"),i.insertNode(o),e.split(`
11
+ `).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 Ev(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function kv(t,e,o){await new Ue(t).authenticateWithKey(e,o)}async function Rv(t){let o=await new he(t).get("/platform/config/",{version:null});return A(o)}async function Iv(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 Pv(t,e){let o=await Iv(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{B as Card,Ht as ContentEditableInput,Ue as DeepdeskAPI,os as DeepdeskSDK,he as HTTPClient,Ne as InputMediator,qe as InputType,cs as KeyboardHint,ps as Label,ko as Locale,je as Section,ds as SectionList,pe as Sources,N as Suggestion,re as SuggestionList,Oe as TextAreaInput,ut as ToggleButton,Pv as attachFile,kv as authenticateWithKey,vo as createFullRange,_t as createOverlayContainer,st as createRangeFromOffsets,Xt as escapeHTML,Rv as fetchPlatformConfig,Ev as formatTextMarkup,Qn as getRangeOffsets,Zn as getRangeText,Tv as insertCKEditor,Jr as isSupportedInputElement,wv as updateContentEditable,Cv as updateTextArea,y as useStyles,Yr as waitForElementVisibilityChange};