@deepdesk/deepdesk-sdk 10.9.3-beta.2 → 10.9.3-beta.4
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.cjs.js +7 -7
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +7 -7
- package/dist/index.iife.js +11 -11
- package/package.json +1 -1
- package/styles/index.js +1 -1
- package/styles.css +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var xd=Object.defineProperty;var j=(t,e)=>{for(var o in e)xd(t,o,{get:e[o],enumerable:!0})};import ls from"classnames";import Ed,{createContext as kd,useContext as cs,useEffect as Rd,useState as Id}from"react";import bd,{useContext as Cd}from"react";import wd from"classnames";var zt=bd.createContext({});function y(t,e){let{debug:o,...n}=Cd(zt),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:wd(a,l,o?`${t}__${i}`:!1)}},{}):e}var ii={root:"_root_vr71j_1"};import{jsx as wo,jsxs as Td}from"react/jsx-runtime";var To=()=>Td("svg",{className:ii.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[wo("defs",{children:wo("style",{children:".cls-1 { fill: #b3b3b3; }"})}),wo("title",{children:"Failed loading image"}),wo("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 as={root:"_root_4e7lf_1",imageWrapper:"_imageWrapper_4e7lf_7",image:"_image_4e7lf_7",content:"_content_4e7lf_24",title:"_title_4e7lf_35",contentIsCropped:"_contentIsCropped_4e7lf_45",lineClamp:"_lineClamp_4e7lf_51"};import{jsx as ct}from"react/jsx-runtime";var Eo=kd(as),Pd=({title:t,src:e})=>{let o=cs(Eo),[n,s]=Id(!1);return Rd(()=>{s(!1)},[e]),ct("div",{className:o.imageWrapper,children:e&&!n?ct("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):ct(To,{})})},Ad=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=cs(Eo);return ct("div",{className:ls(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Ld=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=cs(Eo);return Ed.createElement(t,{className:ls(r.title,o,{[r.contentIsCropped]:e}),...s},n)},ko=({children:t})=>{let e=y("Card",as);return ct("div",{className:ls(e.root),children:ct(Eo.Provider,{value:e,children:t})})};ko.Image=Pd;ko.Content=Ad;ko.Title=Ld;var B=ko;import Md from"classnames";var ai={root:"_root_cq1yq_1"};import{jsx as Dd}from"react/jsx-runtime";var Nd={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Od=({className:t,keyCode:e,...o})=>{let n=y("KeyboardHint",ai);return Dd("span",{"data-key":Nd[e],className:Md(t,n.root),...o})},ps=Od;import Hd from"classnames";var li={root:"_root_4a08n_1"};import{jsx as Fd}from"react/jsx-runtime";var Bd=({className:t,children:e,...o})=>{let n=y("Label",li);return Fd("span",{...o,className:Hd(t,n.root),children:e})},ds=Bd;var ci={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};import{jsx as us,jsxs as Ud}from"react/jsx-runtime";var Kd=({title:t,children:e,type:o,...n})=>{let s=y("Section",ci);return Ud("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})]})},ze=Kd;import zd from"classnames";import jd from"react";var pi={root:"_root_19wxp_1"};import{jsx as Vd}from"react/jsx-runtime";var qd=jd.forwardRef(({className:t,children:e},o)=>{let n=y("SectionList",pi);return Vd("div",{ref:o,className:zd(n.root,t),children:e})}),gs=qd;import Ro from"classnames";import Wd,{createContext as Gd,useCallback as $d,useContext as jt}from"react";var ms={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 Yd}from"react/jsx-runtime";var pt=Gd(ms),Xd=({fixed:t,children:e,...o})=>{let n=jt(pt);return ye("div",{...o,className:Ro(n.actions,{[n.actionsIsFixed]:t}),children:e})},Qd=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=jt(pt);return Yd("div",{className:Ro(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})]})},Zd=({index:t,label:e,onClick:o})=>{let n=jt(pt);return ye("li",{className:n.dropdownItem,children:ye("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Jd=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=jt(pt);return ye("button",{type:"button",className:Ro(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},fs=({labels:t})=>{let e=jt(pt);return ye("div",{className:e.labels,children:t.map(o=>ye("span",{className:e.label,children:o},o))})},dt=Wd.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=y("Suggestion",ms),l=$d(c=>{c.preventDefault(),o&&o(c)},[o]);return ye(s,{...r,ref:i,className:Ro(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:ye(pt.Provider,{value:a,children:n})})});dt.Labels=fs;dt.Actions=Xd;dt.ActionButton=Jd;dt.DropdownButton=Qd;dt.DropdownItem=Zd;var D=dt;import eu from"classnames";var di={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};import{jsx as ou}from"react/jsx-runtime";var tu=({withDivider:t,children:e})=>{let o=y("SuggestionList",di);return ou("div",{"data-testid":"suggestions-overlay-list",className:eu(o.root,{[o.isWithDivider]:t}),children:e})},re=tu;import nu from"classnames";var ui={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};import{jsx as hs}from"react/jsx-runtime";var su=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",ui);return hs("button",{type:"button",className:nu(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:hs("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:hs("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},ut=su;var gi=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,gt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var mi=/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||{}),je=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(je||{});import{render as Ut,unmountComponentAtNode as ns}from"react-dom";import{Fragment as Bf}from"react";import{createSlice as ru}from"@reduxjs/toolkit";import{useSelector as iu}from"react-redux";var Io=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Io||{});var au={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,inlineSuggestions:!1,floatingMenu:!1,adminUrl:void 0,productName:"Deepdesk"},fi=ru({name:"settings",initialState:au,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:qt}=fi.actions,ys=t=>e=>e.settings[t],C=t=>iu(ys(t)),hi=fi.reducer;import{useState as wm}from"react";import{useDispatch as Tm,useSelector as cr}from"react-redux";import{createAction as qe,createSlice as fu}from"@reduxjs/toolkit";import{diffChars as hu}from"diff";import{useSelector as yu}from"react-redux";function yi(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Ae(t,e,o=10){let n=typeof t,s=typeof e;if(o===0)throw new Error("Max depth deepEqual, possible circular references?");return n!==s?!1:t==null||n==="string"||n==="number"||n==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>Ae(r,e[i],o-1)):yi(t)&&yi(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Ae(t[i],e[i],o-1)):!1}function lu(t){return Math.max(...t.map(e=>e.length))}function cu(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 vi(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<lu(n);s++){let r=cu(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 pu=2;function vs(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=vi(t,pu);return o&&o.text!==e?o:t[0]}import{createAction as du,createAsyncThunk as mt,createSlice as uu}from"@reduxjs/toolkit";var Si={current:null,isSupported:null},P=du("resetConversation"),Po=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Ao=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},ft=t=>t.conversation.isSupported,Ss=mt("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Lo=mt("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Mo=mt("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),No=mt("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Ao(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),_s=mt("conversation/upsert",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId).catch(()=>null).then(n=>{if(!n)return o.createConversation(t);let{agentId:s,agentName:r,agentEmail:i,agentNickname:a,tags:l}=t;return o.updateConversation(n.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,tags:l})})}),Oo=mt("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Ao(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),gu=[Lo.rejected,Mo.rejected,No.rejected,Oo.rejected].map(t=>t==null?void 0:t.toString()),mu=uu({name:"conversation",initialState:Si,reducers:{},extraReducers:t=>{t.addCase(Ss.fulfilled,(e,o)=>{e.isSupported=o.payload}).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)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(_s.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(No.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Oo.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(P,()=>Si).addMatcher(e=>gu.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),_i=mu.reducer;var Le={text:"",html:null,selection:{start:0,end:0},stagedSuggestion:null,userCommitted:{text:"",selection:{start:0,end:0}},tabCompletionSuggestion:void 0,previousKeyDownEvent:null,textSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Ho(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 Bo=qe("input/replaceText"),Fo=qe("input/keyDown"),Ve=qe("input/sendMessage"),Ko=qe("input/sendEditSuggestionMessage"),Uo=qe("input/uiInputChange"),zo=qe("input/applyImageSuggestion"),q=qe("input/sendEvent");function Do(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:l},eventMetrics:{inputType:c},replace:p}=t.stagedSuggestion,d=o==="search"||o==="personal-collection-search",u=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(d||p==="selection")&&(u=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(u=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:u,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:d?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var xi=t=>fu({name:t,initialState:Le,reducers:{initialInput(e,o){let{text:n,selection:s,html:r}=o.payload;e.text=n,e.selection.start=(s==null?void 0:s.start)??n.length,e.selection.end=(s==null?void 0:s.end)??n.length,e.userCommitted.text=n,e.userCommitted.selection.start=(s==null?void 0:s.start)??n.length,e.userCommitted.selection.end=(s==null?void 0:s.end)??n.length,e.html=r||null},reset(e){Object.assign(e,{...Le,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=vs(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(Ae(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Do(e)))},platformInput(e,o){let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end),e.text=n,e.html=s||null},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:d,ctrlKey:u,metaKey:g,altKey:f}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:m}=e,{text:v}=o.payload,w=hu(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(!u&&!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(!u&&!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=Le.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Do(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"&&Do(e)},commitSuggestion(e){Do(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=vs(o.payload,n);e.tabCompletionSuggestion=s!=null&&s.text.includes(n)?s:void 0},setSelectedTextSuggestionIndex(e,o){e.selectedSuggestionIndex=o.payload},mergeMetrics(e,{payload:o}){let n=o.agentStartedTypingTimestamp!=null?o.agentStartedTypingTimestamp:Date.now(),s=(Date.now()-n)/1e3;e.metrics.externalTimeTotalSeconds=s,e.metrics.numCharsTyped+=o.numCharsTyped,e.metrics.numCharsPasted+=o.numCharsPasted,e.metrics.numCharsCut+=o.numCharsCut,e.metrics.numCharsDeleted+=o.numCharsDeleted,e.metrics.numPaste+=o.numPaste,e.metrics.pastes.push(...o.pastes),e.metrics.deletions.push(...o.deletions)},setMetrics(e,{payload:o}){e.metrics=o}},extraReducers:e=>{e.addCase(P,o=>{o.tabCompletionSuggestion=Le.tabCompletionSuggestion,o.previousKeyDownEvent=Le.previousKeyDownEvent,o.textSuggestions=Le.textSuggestions,o.selectedSuggestionIndex=Le.selectedSuggestionIndex,o.metrics=Le.metrics})}}),xs=xi("input"),ht=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),vu=t=>t.input.selection,bi=()=>yu(vu),{userInput:Ci,changeSelection:bs,initialInput:wi,mergeMetrics:Ti,nextTextSuggestionIndex:Ei,offeredTextSuggestion:ki,previousTextSuggestionIndex:Ri,registerCut:Ii,registerKeyDown:Pi,registerPaste:Ai,reset:Li,resetToCommitted:Vt,platformInput:Mi,setSelectedTextSuggestionIndex:Me,setTextSuggestions:de,stageSuggestion:ie,commitSuggestion:ve,setMetrics:Ni}=xs.actions,Q=xi("overlay");import{useEffect as Di,useRef as Hi}from"react";var Oi={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};import{jsx as Bi}from"react/jsx-runtime";var Su=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=Hi(null),l=Hi(null),c=y("Dialog",Oi);return Di(()=>{var u,g;let p=f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),s())},d=f=>{let m=window.getSelection();m!=null&&m.toString()||f.target===a.current&&t&&n()};return(u=a.current)==null||u.addEventListener("click",d),(g=a.current)==null||g.addEventListener("keyup",p),()=>{var f,m;(f=a.current)==null||f.removeEventListener("click",d),(m=a.current)==null||m.removeEventListener("keyup",p)}},[a,l,s,n]),Di(()=>{var p,d;!a.current||!t||!e||(d=(p=a.current)==null?void 0:p.querySelector("input, textarea"))==null||d.focus()},[t,e,a]),t?Bi("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:Bi("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},yt=Su;import{useEffect as Ga}from"react";import{useDispatch as rm,useSelector as im}from"react-redux";var Cs={};j(Cs,{enUS:()=>_u,nlNL:()=>xu});var _u={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?"}]},xu={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 Fi={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 Mu,useContext as Nu}from"react";var ws=function(t,e){return ws=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])},ws(t,e)};function Wt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ws(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 Ki(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 jo(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 qo;(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"})(qo||(qo={}));var Vo=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 Wo;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Wo||(Wo={}));function Ts(t){return t.type===ae.literal}function Ui(t){return t.type===ae.argument}function Go(t){return t.type===ae.number}function $o(t){return t.type===ae.date}function Xo(t){return t.type===ae.time}function Qo(t){return t.type===ae.select}function Zo(t){return t.type===ae.plural}function zi(t){return t.type===ae.pound}function Jo(t){return t.type===ae.tag}function Yo(t){return!!(t&&typeof t=="object"&&t.type===Wo.number)}function Gt(t){return!!(t&&typeof t=="object"&&t.type===Wo.dateTime)}function Es(t){t.forEach(function(e){if(delete e.location,Qo(e)||Zo(e))for(var o in e.options)delete e.options[o].location,Es(e.options[o].value);else Go(e)&&Yo(e.style)||($o(e)||Xo(e))&&Gt(e.style)?delete e.style.location:Jo(e)&&Es(e.children)})}function ji(t,e){e===void 0&&(e={}),e=te({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new Vo(t,e).parse();if(o.err){var n=SyntaxError(qo[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||Es(o.val),o.val}function en(t,e){var o=e&&e.cache?e.cache:ku,n=e&&e.serializer?e.serializer:Eu,s=e&&e.strategy?e.strategy:Cu;return s(t,{cache:o,serializer:n})}function bu(t){return t==null||typeof t=="number"||typeof t=="boolean"}function qi(t,e,o,n){var s=bu(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function Vi(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 ks(t,e,o,n,s){return o.bind(e,t,n,s)}function Cu(t,e){var o=t.length===1?qi:Vi;return ks(t,this,o,e.cache.create(),e.serializer)}function wu(t,e){return ks(t,this,Vi,e.cache.create(),e.serializer)}function Tu(t,e){return ks(t,this,qi,e.cache.create(),e.serializer)}var Eu=function(){return JSON.stringify(arguments)};function Rs(){this.cache=Object.create(null)}Rs.prototype.get=function(t){return this.cache[t]};Rs.prototype.set=function(t,e){this.cache[t]=e};var ku={create:function(){return new Rs}},tn={variadic:wu,monadic:Tu};var We;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(We||(We={}));var $t=function(t){Wt(e,t);function e(o,n,s){var r=t.call(this,o)||this;return r.code=n,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e}(Error);var Is=function(t){Wt(e,t);function e(o,n,s,r){return t.call(this,'Invalid values for "'.concat(o,'": "').concat(n,'". Options are "').concat(Object.keys(s).join('", "'),'"'),We.INVALID_VALUE,r)||this}return e}($t);var Wi=function(t){Wt(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),We.INVALID_VALUE,s)||this}return e}($t);var Gi=function(t){Wt(e,t);function e(o,n){return t.call(this,'The intl string context variable "'.concat(o,'" was not provided to the string "').concat(n,'"'),We.MISSING_VALUE,n)||this}return e}($t);var V;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(V||(V={}));function Ru(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 Iu(t){return typeof t=="function"}function Xt(t,e,o,n,s,r,i){if(t.length===1&&Ts(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(Ts(p)){a.push({type:V.literal,value:p.value});continue}if(zi(p)){typeof r=="number"&&a.push({type:V.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new Gi(d,i);var u=s[d];if(Ui(p)){(!u||typeof u=="string"||typeof u=="number")&&(u=typeof u=="string"||typeof u=="number"?String(u):""),a.push({type:typeof u=="string"?V.literal:V.object,value:u});continue}if($o(p)){var g=typeof p.style=="string"?n.date[p.style]:Gt(p.style)?p.style.parsedOptions:void 0;a.push({type:V.literal,value:o.getDateTimeFormat(e,g).format(u)});continue}if(Xo(p)){var g=typeof p.style=="string"?n.time[p.style]:Gt(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:V.literal,value:o.getDateTimeFormat(e,g).format(u)});continue}if(Go(p)){var g=typeof p.style=="string"?n.number[p.style]:Yo(p.style)?p.style.parsedOptions:void 0;g&&g.scale&&(u=u*(g.scale||1)),a.push({type:V.literal,value:o.getNumberFormat(e,g).format(u)});continue}if(Jo(p)){var f=p.children,m=p.value,v=s[m];if(!Iu(v))throw new Wi(m,"function",i);var w=Xt(f,e,o,n,s,r),h=v(w.map(function(_){return _.value}));Array.isArray(h)||(h=[h]),a.push.apply(a,h.map(function(_){return{type:typeof _=="string"?V.literal:V.object,value:_}}))}if(Qo(p)){var x=p.options[u]||p.options.other;if(!x)throw new Is(p.value,u,Object.keys(p.options),i);a.push.apply(a,Xt(x.value,e,o,n,s));continue}if(Zo(p)){var x=p.options["=".concat(u)];if(!x){if(!Intl.PluralRules)throw new $t(`Intl.PluralRules is not available in this environment.
|
|
1
|
+
var xu=Object.defineProperty;var j=(t,e)=>{for(var o in e)xu(t,o,{get:e[o],enumerable:!0})};import ls from"classnames";import Eu,{createContext as ku,useContext as cs,useEffect as Ru,useState as Iu}from"react";import bu,{useContext as Cu}from"react";import wu from"classnames";var zt=bu.createContext({});function y(t,e){let{debug:o,...n}=Cu(zt),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:wu(a,l,o?`${t}__${i}`:!1)}},{}):e}var ii={root:"_root_vr71j_1"};import{jsx as wo,jsxs as Tu}from"react/jsx-runtime";var To=()=>Tu("svg",{className:ii.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[wo("defs",{children:wo("style",{children:".cls-1 { fill: #b3b3b3; }"})}),wo("title",{children:"Failed loading image"}),wo("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 as={root:"_root_4e7lf_1",imageWrapper:"_imageWrapper_4e7lf_7",image:"_image_4e7lf_7",content:"_content_4e7lf_24",title:"_title_4e7lf_35",contentIsCropped:"_contentIsCropped_4e7lf_45",lineClamp:"_lineClamp_4e7lf_51"};import{jsx as ct}from"react/jsx-runtime";var Eo=ku(as),Pu=({title:t,src:e})=>{let o=cs(Eo),[n,s]=Iu(!1);return Ru(()=>{s(!1)},[e]),ct("div",{className:o.imageWrapper,children:e&&!n?ct("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):ct(To,{})})},Au=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=cs(Eo);return ct("div",{className:ls(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Lu=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=cs(Eo);return Eu.createElement(t,{className:ls(r.title,o,{[r.contentIsCropped]:e}),...s},n)},ko=({children:t})=>{let e=y("Card",as);return ct("div",{className:ls(e.root),children:ct(Eo.Provider,{value:e,children:t})})};ko.Image=Pu;ko.Content=Au;ko.Title=Lu;var B=ko;import Mu from"classnames";var ai={root:"_root_cq1yq_1"};import{jsx as Du}from"react/jsx-runtime";var Nu={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Ou=({className:t,keyCode:e,...o})=>{let n=y("KeyboardHint",ai);return Du("span",{"data-key":Nu[e],className:Mu(t,n.root),...o})},ps=Ou;import Hu from"classnames";var li={root:"_root_4a08n_1"};import{jsx as Fu}from"react/jsx-runtime";var Bu=({className:t,children:e,...o})=>{let n=y("Label",li);return Fu("span",{...o,className:Hu(t,n.root),children:e})},us=Bu;var ci={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};import{jsx as ds,jsxs as Uu}from"react/jsx-runtime";var Ku=({title:t,children:e,type:o,...n})=>{let s=y("Section",ci);return Uu("section",{...n,className:s.root,"data-section-type":o,children:[t&&ds("div",{className:s.subTitleContainer,children:ds("span",{className:s.subtitle,children:t})}),ds("div",{className:s.suggestions,children:e})]})},ze=Ku;import zu from"classnames";import ju from"react";var pi={root:"_root_19wxp_1"};import{jsx as Vu}from"react/jsx-runtime";var qu=ju.forwardRef(({className:t,children:e},o)=>{let n=y("SectionList",pi);return Vu("div",{ref:o,className:zu(n.root,t),children:e})}),gs=qu;import Ro from"classnames";import Wu,{createContext as Gu,useCallback as $u,useContext as jt}from"react";var ms={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 Yu}from"react/jsx-runtime";var pt=Gu(ms),Xu=({fixed:t,children:e,...o})=>{let n=jt(pt);return ye("div",{...o,className:Ro(n.actions,{[n.actionsIsFixed]:t}),children:e})},Qu=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=jt(pt);return Yu("div",{className:Ro(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})]})},Zu=({index:t,label:e,onClick:o})=>{let n=jt(pt);return ye("li",{className:n.dropdownItem,children:ye("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Ju=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=jt(pt);return ye("button",{type:"button",className:Ro(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},fs=({labels:t})=>{let e=jt(pt);return ye("div",{className:e.labels,children:t.map(o=>ye("span",{className:e.label,children:o},o))})},ut=Wu.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=y("Suggestion",ms),l=$u(c=>{c.preventDefault(),o&&o(c)},[o]);return ye(s,{...r,ref:i,className:Ro(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:ye(pt.Provider,{value:a,children:n})})});ut.Labels=fs;ut.Actions=Xu;ut.ActionButton=Ju;ut.DropdownButton=Qu;ut.DropdownItem=Zu;var D=ut;import ed from"classnames";var ui={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};import{jsx as od}from"react/jsx-runtime";var td=({withDivider:t,children:e})=>{let o=y("SuggestionList",ui);return od("div",{"data-testid":"suggestions-overlay-list",className:ed(o.root,{[o.isWithDivider]:t}),children:e})},re=td;import nd from"classnames";var di={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};import{jsx as hs}from"react/jsx-runtime";var sd=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",di);return hs("button",{type:"button",className:nd(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:hs("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:hs("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},dt=sd;var gi=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,gt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var mi=/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||{}),je=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(je||{});import{render as Ut,unmountComponentAtNode as ns}from"react-dom";import{Fragment as Bf}from"react";import{createSlice as rd}from"@reduxjs/toolkit";import{useSelector as id}from"react-redux";var Io=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Io||{});var ad={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,inlineSuggestions:!1,floatingMenu:!1,adminUrl:void 0,productName:"Deepdesk"},fi=rd({name:"settings",initialState:ad,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:qt}=fi.actions,ys=t=>e=>e.settings[t],C=t=>id(ys(t)),hi=fi.reducer;import{useState as wm}from"react";import{useDispatch as Tm,useSelector as cr}from"react-redux";import{createAction as qe,createSlice as fd}from"@reduxjs/toolkit";import{diffChars as hd}from"diff";import{useSelector as yd}from"react-redux";function yi(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Ae(t,e,o=10){let n=typeof t,s=typeof e;if(o===0)throw new Error("Max depth deepEqual, possible circular references?");return n!==s?!1:t==null||n==="string"||n==="number"||n==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>Ae(r,e[i],o-1)):yi(t)&&yi(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Ae(t[i],e[i],o-1)):!1}function ld(t){return Math.max(...t.map(e=>e.length))}function cd(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 vi(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<ld(n);s++){let r=cd(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 pd=2;function vs(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=vi(t,pd);return o&&o.text!==e?o:t[0]}import{createAction as ud,createAsyncThunk as mt,createSlice as dd}from"@reduxjs/toolkit";var Si={current:null,isSupported:null},P=ud("resetConversation"),Po=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Ao=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},ft=t=>t.conversation.isSupported,Ss=mt("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Lo=mt("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Mo=mt("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),No=mt("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Ao(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),_s=mt("conversation/upsert",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId).catch(()=>null).then(n=>{if(!n)return o.createConversation(t);let{agentId:s,agentName:r,agentEmail:i,agentNickname:a,tags:l}=t;return o.updateConversation(n.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,tags:l})})}),Oo=mt("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Ao(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),gd=[Lo.rejected,Mo.rejected,No.rejected,Oo.rejected].map(t=>t==null?void 0:t.toString()),md=dd({name:"conversation",initialState:Si,reducers:{},extraReducers:t=>{t.addCase(Ss.fulfilled,(e,o)=>{e.isSupported=o.payload}).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)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(_s.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(No.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Oo.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(P,()=>Si).addMatcher(e=>gd.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),_i=md.reducer;var Le={text:"",html:null,selection:{start:0,end:0},stagedSuggestion:null,userCommitted:{text:"",selection:{start:0,end:0}},tabCompletionSuggestion:void 0,previousKeyDownEvent:null,textSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Ho(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 Bo=qe("input/replaceText"),Fo=qe("input/keyDown"),Ve=qe("input/sendMessage"),Ko=qe("input/sendEditSuggestionMessage"),Uo=qe("input/uiInputChange"),zo=qe("input/applyImageSuggestion"),q=qe("input/sendEvent");function Do(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 xi=t=>fd({name:t,initialState:Le,reducers:{initialInput(e,o){let{text:n,selection:s,html:r}=o.payload;e.text=n,e.selection.start=(s==null?void 0:s.start)??n.length,e.selection.end=(s==null?void 0:s.end)??n.length,e.userCommitted.text=n,e.userCommitted.selection.start=(s==null?void 0:s.start)??n.length,e.userCommitted.selection.end=(s==null?void 0:s.end)??n.length,e.html=r||null},reset(e){Object.assign(e,{...Le,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=vs(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(Ae(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Do(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=hd(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=Le.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Do(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"&&Do(e)},commitSuggestion(e){Do(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=vs(o.payload,n);e.tabCompletionSuggestion=s!=null&&s.text.includes(n)?s:void 0},setSelectedTextSuggestionIndex(e,o){e.selectedSuggestionIndex=o.payload},mergeMetrics(e,{payload:o}){let n=o.agentStartedTypingTimestamp!=null?o.agentStartedTypingTimestamp:Date.now(),s=(Date.now()-n)/1e3;e.metrics.externalTimeTotalSeconds=s,e.metrics.numCharsTyped+=o.numCharsTyped,e.metrics.numCharsPasted+=o.numCharsPasted,e.metrics.numCharsCut+=o.numCharsCut,e.metrics.numCharsDeleted+=o.numCharsDeleted,e.metrics.numPaste+=o.numPaste,e.metrics.pastes.push(...o.pastes),e.metrics.deletions.push(...o.deletions)},setMetrics(e,{payload:o}){e.metrics=o}},extraReducers:e=>{e.addCase(P,o=>{o.tabCompletionSuggestion=Le.tabCompletionSuggestion,o.previousKeyDownEvent=Le.previousKeyDownEvent,o.textSuggestions=Le.textSuggestions,o.selectedSuggestionIndex=Le.selectedSuggestionIndex,o.metrics=Le.metrics})}}),xs=xi("input"),ht=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),vd=t=>t.input.selection,bi=()=>yd(vd),{userInput:Ci,changeSelection:bs,initialInput:wi,mergeMetrics:Ti,nextTextSuggestionIndex:Ei,offeredTextSuggestion:ki,previousTextSuggestionIndex:Ri,registerCut:Ii,registerKeyDown:Pi,registerPaste:Ai,reset:Li,resetToCommitted:Vt,platformInput:Mi,setSelectedTextSuggestionIndex:Me,setTextSuggestions:ue,stageSuggestion:ie,commitSuggestion:ve,setMetrics:Ni}=xs.actions,Q=xi("overlay");import{useEffect as Di,useRef as Hi}from"react";var Oi={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};import{jsx as Bi}from"react/jsx-runtime";var Sd=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=Hi(null),l=Hi(null),c=y("Dialog",Oi);return Di(()=>{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]),Di(()=>{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?Bi("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:Bi("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},yt=Sd;import{useEffect as Ga}from"react";import{useDispatch as rm,useSelector as im}from"react-redux";var Cs={};j(Cs,{enUS:()=>_d,nlNL:()=>xd});var _d={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?"}]},xd={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 Fi={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 Md,useContext as Nd}from"react";var ws=function(t,e){return ws=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])},ws(t,e)};function Wt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ws(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 Ki(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 jo(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 qo;(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"})(qo||(qo={}));var Vo=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 Wo;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Wo||(Wo={}));function Ts(t){return t.type===ae.literal}function Ui(t){return t.type===ae.argument}function Go(t){return t.type===ae.number}function $o(t){return t.type===ae.date}function Xo(t){return t.type===ae.time}function Qo(t){return t.type===ae.select}function Zo(t){return t.type===ae.plural}function zi(t){return t.type===ae.pound}function Jo(t){return t.type===ae.tag}function Yo(t){return!!(t&&typeof t=="object"&&t.type===Wo.number)}function Gt(t){return!!(t&&typeof t=="object"&&t.type===Wo.dateTime)}function Es(t){t.forEach(function(e){if(delete e.location,Qo(e)||Zo(e))for(var o in e.options)delete e.options[o].location,Es(e.options[o].value);else Go(e)&&Yo(e.style)||($o(e)||Xo(e))&&Gt(e.style)?delete e.style.location:Jo(e)&&Es(e.children)})}function ji(t,e){e===void 0&&(e={}),e=te({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new Vo(t,e).parse();if(o.err){var n=SyntaxError(qo[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||Es(o.val),o.val}function en(t,e){var o=e&&e.cache?e.cache:kd,n=e&&e.serializer?e.serializer:Ed,s=e&&e.strategy?e.strategy:Cd;return s(t,{cache:o,serializer:n})}function bd(t){return t==null||typeof t=="number"||typeof t=="boolean"}function qi(t,e,o,n){var s=bd(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function Vi(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 ks(t,e,o,n,s){return o.bind(e,t,n,s)}function Cd(t,e){var o=t.length===1?qi:Vi;return ks(t,this,o,e.cache.create(),e.serializer)}function wd(t,e){return ks(t,this,Vi,e.cache.create(),e.serializer)}function Td(t,e){return ks(t,this,qi,e.cache.create(),e.serializer)}var Ed=function(){return JSON.stringify(arguments)};function Rs(){this.cache=Object.create(null)}Rs.prototype.get=function(t){return this.cache[t]};Rs.prototype.set=function(t,e){this.cache[t]=e};var kd={create:function(){return new Rs}},tn={variadic:wd,monadic:Td};var We;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(We||(We={}));var $t=function(t){Wt(e,t);function e(o,n,s){var r=t.call(this,o)||this;return r.code=n,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e}(Error);var Is=function(t){Wt(e,t);function e(o,n,s,r){return t.call(this,'Invalid values for "'.concat(o,'": "').concat(n,'". Options are "').concat(Object.keys(s).join('", "'),'"'),We.INVALID_VALUE,r)||this}return e}($t);var Wi=function(t){Wt(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),We.INVALID_VALUE,s)||this}return e}($t);var Gi=function(t){Wt(e,t);function e(o,n){return t.call(this,'The intl string context variable "'.concat(o,'" was not provided to the string "').concat(n,'"'),We.MISSING_VALUE,n)||this}return e}($t);var V;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(V||(V={}));function Rd(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 Id(t){return typeof t=="function"}function Xt(t,e,o,n,s,r,i){if(t.length===1&&Ts(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(Ts(p)){a.push({type:V.literal,value:p.value});continue}if(zi(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 Gi(u,i);var d=s[u];if(Ui(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($o(p)){var g=typeof p.style=="string"?n.date[p.style]:Gt(p.style)?p.style.parsedOptions:void 0;a.push({type:V.literal,value:o.getDateTimeFormat(e,g).format(d)});continue}if(Xo(p)){var g=typeof p.style=="string"?n.time[p.style]:Gt(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:V.literal,value:o.getDateTimeFormat(e,g).format(d)});continue}if(Go(p)){var g=typeof p.style=="string"?n.number[p.style]:Yo(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(Jo(p)){var f=p.children,m=p.value,v=s[m];if(!Id(v))throw new Wi(m,"function",i);var w=Xt(f,e,o,n,s,r),h=v(w.map(function(_){return _.value}));Array.isArray(h)||(h=[h]),a.push.apply(a,h.map(function(_){return{type:typeof _=="string"?V.literal:V.object,value:_}}))}if(Qo(p)){var x=p.options[d]||p.options.other;if(!x)throw new Is(p.value,d,Object.keys(p.options),i);a.push.apply(a,Xt(x.value,e,o,n,s));continue}if(Zo(p)){var x=p.options["=".concat(d)];if(!x){if(!Intl.PluralRules)throw new $t(`Intl.PluralRules is not available in this environment.
|
|
2
2
|
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
3
|
-
`,We.MISSING_INTL_API,i);var b=o.getPluralRules(e,{type:p.pluralType}).select(u-(p.offset||0));x=p.options[b]||p.options.other}if(!x)throw new Is(p.value,u,Object.keys(p.options),i);a.push.apply(a,Xt(x.value,e,o,n,s,u-(p.offset||0)));continue}}return Ru(a)}function Pu(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 Au(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Pu(t[n],e[n]),o},te({},t)):t}function Ps(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Lu(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:en(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,jo([void 0],o,!1)))},{cache:Ps(t.number),strategy:tn.variadic}),getDateTimeFormat:en(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,jo([void 0],o,!1)))},{cache:Ps(t.dateTime),strategy:tn.variadic}),getPluralRules:en(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,jo([void 0],o,!1)))},{cache:Ps(t.pluralRules),strategy:tn.variadic})}}var $i=function(){function t(e,o,n,s){o===void 0&&(o=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var p=r.formatToParts(c);if(p.length===1)return p[0].value;var d=p.reduce(function(u,g){return!u.length||g.type!==V.literal||typeof u[u.length-1]!="string"?u.push(g.value):u[u.length-1]+=g.value,u},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return Xt(r.ast,r.locales,r.formatters,r.formats,c,void 0,r.message)},this.resolvedOptions=function(){var c;return{locale:((c=r.resolvedLocale)===null||c===void 0?void 0:c.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=o,this.resolvedLocale=t.resolveLocale(o),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=s||{},a=i.formatters,l=Ki(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=Au(t.formats,n),this.formatters=s&&s.formatters||Lu(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=ji,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 Ou(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var Du="dummy",As=Mu(null);function E(t){let e=Nu(As);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=Ou(o,n);return r?new $i(r).format(s):(e!==Du&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}import{jsx as Xi,jsxs as Hu}from"react/jsx-runtime";var on=()=>Hu("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[Xi("title",{id:"angleLeftTitle",children:"AngleLeft"}),Xi("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 Qi,jsxs as Bu}from"react/jsx-runtime";var Zi=()=>Bu("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[Qi("title",{id:"angleRightTitle",children:"AngleRight"}),Qi("path",{d:"M64 448c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L178.8 256L41.38 118.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l160 160c12.5 12.5 12.5 32.75 0 45.25l-160 160C80.38 444.9 72.19 448 64 448z"})]});import{useEffect as Zt,useRef as Us,useState as lg}from"react";import{useDispatch as cg}from"react-redux";import{Interweave as ha}from"interweave";import ya from"classnames";var Ls={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 zu}from"interweave";import ju from"classnames";import{useEffect as Fu,useRef as Ku,useState as Uu}from"react";function Ji(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function nn(t){let e=Ku(null),[o,n]=Uu(!1);return Fu(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=Ji((p,d)=>{let u=e.current;if(!u)return;let g=p/r,f=d/r,m=u.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:d})=>[p,d]),[l,c]=Ji(()=>{s=!1,n(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",l),()=>{a(),c(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",l)}},[e]),[e,o]}var 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 Yi}from"react/jsx-runtime";var qu=({inputElement:t,children:e})=>{let o=y("TabCompletion",Se),[n,s]=nn(t);return Yi("mark",{ref:n,className:ju(o.matchPlaceholder,{[o.hover]:s}),children:e})},vt=class extends zu{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 Yi(qu,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import{useEffect as Vu,useRef as Wu,useState as Gu}from"react";function sn(t){return t.contentEditable==="true"}function $u(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 ea(t){let{selectionStart:e,selectionEnd:o}=sn(t)?$u(t):t;return[e,o]}function rn(t){let[,e]=Gu(),o=Wu(null);return o.current=ea(t),Vu(()=>{let n=()=>{let[s,r]=o.current??[],i=ea(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 an(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(gt);if(!i||i.length===0)return;let a=0;i.find(l=>{let c=n.indexOf(l,a);return s>c&&r<c+l.length?(o.selectionStart=c,o.selectionEnd=c+l.length,!0):(a=c+l.length,!1)})}import{useEffect as Xu}from"react";function St(t){Xu(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Ge(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var ta,ue=new Map,Qu=["bottom","height","left","right","top","width"],Zu=(t={},e={})=>Qu.some(o=>t[o]!==e[o]);function oa(t){var o,n;if(t.ownerDocument===document)return[];let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...oa(e)]:[]}function na(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var ln=!1,sa=()=>{ln=!0;let t=[];if(ue.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),ue.delete(o);return}let n=o.getBoundingClientRect();Zu(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(na,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),ue.size===0){ln=!1;return}ta=window.requestAnimationFrame(sa)};function Ms(t,e){let o=oa(t),n=[],s=o.map((r,i)=>Ms(r,a=>{n[i]=a;let l=ue.get(t);if(!l)return;let c=n.reduce(na,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),ue.has(t)){let i=ue.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else ue.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!ln&&sa()},unobserve(){s.forEach(i=>i.unobserve());let r=ue.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||ue.delete(t),ue.size||(cancelAnimationFrame(ta),ln=!1)}}}}var ra,ge=new Map,ia=()=>{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&&(ra=window.requestAnimationFrame(ia))};function aa(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&&ia()},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(ra)}}}}var Ns=["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 _t(t){return parseFloat(t)}function cn(t){return Math.round(t*1e6)}function la(t){return t/1e6}function Ds(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=_t(t.width),r=_t(t.borderLeftWidth),i=_t(t.borderRightWidth),a=_t(t.paddingRight),l=la(cn(s)-cn(r)-cn(i)),c=la(cn(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function xt(t,e={}){var l;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",Ge(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Os(n,o,Ns),Ds(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=aa(t,()=>{Os(n,o,Ns),Ds(n,t,o),r(),setTimeout(r,0)}),a=Ms(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,Ns),Ds(n,t,o),r(),o.style.top=`${c.top}px`,o.style.left=`${c.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let p=e.closestScrollElement.getBoundingClientRect(),d=window.getComputedStyle(e.closestScrollElement),u=_t(d.borderTopWidth),g=_t(d.borderBottomWidth),f=p.top+u-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 Hs={};j(Hs,{enUS:()=>Ju,nlNL:()=>Yu});var Ju={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"}]},Yu={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 ca,jsxs as eg}from"react/jsx-runtime";var pa=()=>eg("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[ca("title",{id:"circleCheckTitle",children:"Check"}),ca("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 da}from"react/jsx-runtime";var ua=()=>da("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:da("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 tg(t){let e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!n}function pn(t){return t?t instanceof ShadowRoot?pn(t.host):t===t.ownerDocument.body?t.ownerDocument:tg(t)?t:pn(t.parentNode):document.body}var ga=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(ga||{}),Ne=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentCaret=null;currentSelection={start:0,end:0};currentHTML="";isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(e,o){let n=s=>{o(s)};this.element.addEventListener(e,n),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,n)})}removeEventListener(e,o){this.element.removeEventListener(e,o)}triggerChange(){let e=this.getText(),o=this.getHTML(),n=e!==this.currentText;this.isActive&&(e===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&n&&!this.isSubmitting&&this.emit("change",{plainText:e}),n&&(this.currentSelection=this.getSelection()),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==o||o===null&&n)&&(this.emit("updated",{plainText:e}),this.triggerCaretPosition(),this.currentHTML=o))}triggerSelection(){let e=this.getSelection();(e.start!==this.currentSelection.start||e.end!==this.currentSelection.end)&&(this.currentSelection=e,this.emit("selection",e),this.triggerCaretPosition())}triggerCaretPosition(){let e=this.getCaretPosition();Ae(e,this.currentCaret)||(this.currentCaret=e,this.emit("caret",e))}handleKeyUp(e){let{key:o,shiftKey:n}=e;(o==="Enter"&&n===!0||o==="Backspace")&&this.triggerChange(),this.triggerSelection()}handleClick(){this.triggerSelection()}handleFocus(){this.isFocused||this.emit("focus"),this.triggerSelection(),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(e){let{key:o,ctrlKey:n,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(ga).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=pn(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 og=/[.*+?^${}()|[\]\\]/g,ng=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function sg(t){return t.replace(og,"\\$&")}function rg(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function ig(t){return t.search(ng)}function ma(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${sg(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function fa(t){return t.replace(gt,'<mark data-type="placeholder">$1</mark>')}function Qt(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ag(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 Bs(t,e,o={}){if(e){let n=rg(e.toLowerCase(),t.toLowerCase()),s=Qt(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=ig(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(gi).length>3||e.length>30?ag(e.trim(),n):0;return`${`${i>0?"\u2026":""}${Qt(t.substring(i,n))}`}<strong>${s}</strong>`}return t}function Fs(t){return/<\/?[a-z][\s\S]*>/i.test(t)}function dn(t){if(Fs(t)){let o=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(t);return o?o[1]:""}return t}import{jsx as le,jsxs as Ks}from"react/jsx-runtime";var pg=({value:t,onUse:e,...o})=>{var d;let n=E(Hs),s=cg(),r=Fs(t),i=y("EditSuggestionTextInput",Ls),[a,l]=lg(null),c=Us(null),p=((d=t.match(gt))==null?void 0:d.length)||0;return Zt(()=>{let u;return c.current&&(l(c.current),u=new Oe(c.current),u.on("change",({plainText:g})=>{s(Q.actions.userInput({text:g,selection:u.getSelection()}))}),u.on("keydown",g=>{s(Q.actions.registerKeyDown(Ho(g))),g.code==="Enter"&&g.shiftKey&&e(u.getText())}),u.on("paste",({pastedText:g,selectionText:f})=>{s(Q.actions.registerPaste({text:g,selectionText:f}))}),u.on("cut",({selectionText:g})=>{s(Q.actions.registerCut(g))})),()=>{s(Q.actions.reset()),u.dispose(),u.deactivate()}},[c]),Zt(()=>{t&&c.current&&(c.current.value=t)},[t,c]),Zt(()=>{c.current&&setTimeout(()=>{if(!c.current)return;let u=c.current.value.length;c.current.setSelectionRange(u,u),c.current.focus()},0)},[c]),r?le("div",{className:i.textInputWrapper,children:le(ha,{className:i.textInput,tagName:"div",content:t})}):Ks("div",{className:i.textInputWrapper,children:[le("textarea",{...o,ref:c,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:t,onChange:()=>{}}),a&&le(dg,{inputElement:c.current,value:t}),Ks("div",{className:ya(i.alert,p===0?i.success:i.warning),children:[le("div",{className:i.alertText,children:n("placeholders",{placeholderSize:p})}),p===0?le(pa,{}):le(ua,{})]})]})},dg=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",Ls),n=Us(null),s=rn(t);return Zt(()=>{an(t,s)},[s,t]),le(ug,{inputElement:t,children:Ks("div",{ref:n,className:ya(o.root,o.agentText),children:[le(ha,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new vt("placeholders")],inputElement:t,boundaryRef:n}),le("br",{})]})})},ug=({inputElement:t,children:e})=>{let o=Us(null);return Zt(()=>{if(!o.current)return()=>{};let[n,s]=xt(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),le("div",{ref:o,children:e})},va=pg;import{useEffect as tm,useState as om,useRef as nm}from"react";import{useState as fg}from"react";import zs 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 $e={};j($e,{enUS:()=>gg,nlNL:()=>mg});var gg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},mg={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};import{jsx as Jt,jsxs as yg}from"react/jsx-runtime";var hg=({src:t,title:e})=>{let o=y("CommandPalette",Z),[n,s]=fg("loading"),r=E($e);return yg("div",{className:o.image,children:[Jt("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:zs(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&Jt("span",{className:zs(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&Jt("span",{className:zs(o.imageSrc,o.imageSrcStatus),children:Jt(To,{})}),e&&Jt("span",{className:o.imageTitle,children:e})]})},Sa=hg;import vg from"react";import Sg from"classnames";import{jsx as _a,jsxs as _g}from"react/jsx-runtime";function js({children:t,heading:e,orientation:o}){let n=y("CommandPalette",Z);return vg.Children.count(t)===0?null:_g("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&_a("h4",{className:n.listHeading,children:e}),_a("div",{className:Sg(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}import mn from"classnames";import qs from"react";import{jsx as xg}from"react/jsx-runtime";var xa=qs.createContext(void 0);function De(){let t=qs.useContext(xa);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var ba=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=qs.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return xg(xa.Provider,{value:i,children:t})};import bg,{useState as Ca,useEffect as wa,useMemo as Cg,useRef as Ta,useCallback as wg,useContext as Tg}from"react";import Eg from"classnames";var Vs={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 un,jsxs as Pg}from"react/jsx-runtime";var kg=0,Ea=bg.createContext(null),Rg=()=>{let t=Tg(Ea);if(!t)throw new Error("Invalid DropdownContext");return t},ka=({trigger:t,children:e,position:o="bottom"})=>{let n=Cg(()=>++kg,[]),s=Ta(null),r=Ta(null),i=y("Dropdown",Vs),[a,l]=Ca(!1),[c,p]=Ca(o),d=g=>{g.preventDefault(),g.stopPropagation(),l(!a)},u=wg(([g])=>{!g.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return wa(()=>{let g=f=>{s.current&&!s.current.contains(f.target)&&l(!1)};return document.addEventListener("click",g),()=>{document.removeEventListener("click",g)}},[]),wa(()=>{if(!r.current&&!a)return()=>{};let g=new IntersectionObserver(u,{root:null,rootMargin:"0px",threshold:1});return r.current&&g.observe(r.current),()=>{r.current&&g.unobserve(r.current)}},[r,a]),un(Ea.Provider,{value:{setIsOpen:l},children:Pg("div",{ref:s,className:i.root,children:[un("button",{id:`dropdown-${n}`,"data-testid":"dropdown-trigger","aria-haspopup":"true","aria-expanded":a,"aria-label":"Dropdown trigger",type:"button",className:i.trigger,onClick:d,children:t}),un("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:Eg(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function Ig({as:t,children:e,onClick:o,...n}){let s=t||"button",r=y("Dropdown",Vs),{setIsOpen:i}=Rg(),a=l=>{i(!1),o(l),l.stopPropagation()};return un(s,{type:"button",className:r.item,onClick:a,...n,children:e})}ka.Item=Ig;var Ws=ka;import{jsx as Ra}from"react/jsx-runtime";var Ia=t=>Ra("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:Ra("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 Xe={};j(Xe,{enUS:()=>Ag,nlNL:()=>Lg});var Ag={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"}]},Lg={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 Gs}from"react/jsx-runtime";var Mg="%0d%0a%0d%0a%0d%0a",Ng=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(Mg)}`},Og=({suggestion:t,onFeedback:e})=>{let o=E(Xe),n=C("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:Gs(Ws,{trigger:Gs(Ia,{"data-testid":"feedback-dropdown-trigger"}),children:Gs(Ws.Item,{as:"a",href:Ng(n,t),onClick:e,children:o("giveFeedback")})})},gn=Og;import{Interweave as Dg}from"interweave";import{jsx as He,jsxs as $s}from"react/jsx-runtime";function Xs({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onFeedback:s,onSourceClick:r,index:i,description:a,sources:l,styles:c,...p}){let{selected:d,setSelected:u,onChangeOpen:g}=De(),f=y("CommandPalette",Z);function m(v){n(v),t&&g(!1)}return $s("div",{className:mn(f.listItem,d===i&&f.listItemSelected),children:[He("button",{onMouseEnter:()=>u(i),type:"button",className:mn("command-palette-list-item",f.listItemAction,f.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:m,...p,children:$s("div",{className:f.listItemContent,children:[typeof o=="string"?He("p",{className:mn(f.listItemText,f.truncate,c==null?void 0:c.title),children:o}):o,a&&He(Dg,{tagName:"p",allowList:[],content:dn(a),className:mn(f.listItemDescription,c==null?void 0:c.description,e?f.lineClamp:f.truncate)})]})}),s&&d===i&&He("div",{className:f.listItemActions,children:He(gn,{suggestion:String(o),onFeedback:s})}),l&&$s("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 Pa,jsxs as Qs}from"react/jsx-runtime";function Zs({children:t,title:e,id:o,onDismiss:n}){let s=E($e),r=y("CommandPalette",Z),{page:i}=De();return i!==o?null:Qs("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&Qs("div",{className:r.pageNav,children:[Qs("button",{className:r.pageBackButton,type:"button",onClick:n,children:[Pa(on,{}),s("back")]}),e&&Pa("h3",{className:r.pageTitle,children:e})]}),t]})}import{Fragment as Gg,useCallback as $g,useEffect as Xg,useRef as Qg}from"react";var fn=()=>/Mac/i.test(navigator.platform);import{createAsyncThunk as Ug,createSlice as zg}from"@reduxjs/toolkit";var Hg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},T=Hg;import{createAsyncThunk as Ys,createSlice as Fg}from"@reduxjs/toolkit";function Bg(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,[Bg(o)]:A(t[o])}),{}):t}function Js(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,[Js(o)]:F(t[o])}),{}):t}var Kg={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},eo=t=>{var e,o,n;return{timezone:((e=t.info.visitorInfo)==null?void 0:e.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((o=t.info.agentInfo)==null?void 0:o.agentNickname)||"",visitorName:((n=t.info.visitorInfo)==null?void 0:n.visitorName)||""}},Yt=Ys("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))}),er=Ys("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}),tr=Ys("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),Aa=t=>t.info.agentInfo,La=Fg({name:"info",initialState:Kg,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Yt.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Yt.rejected,e=>{e.fetchState="error"}).addCase(Yt.fulfilled,(e,o)=>{e.fetchState="done",e.agentInfo={...e.agentInfo,...o.meta.arg,agentId:o.payload.externalId||o.meta.arg.agentId||"",agentNickname:o.payload.nickname||o.meta.arg.agentNickname||""}}).addCase(er.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(tr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(P,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Ma}=La.actions,Na=La.reducer;var hn={list:[],fetchState:"idle",isOpen:!1,page:"search"},Oa=t=>t.search.isOpen,Da=t=>t.search.page,Ha=t=>t.search.list;function Ba(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Qe=Ug("search/getAll",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r}=await o.search({profile:s,query:t.query,filters:{type:t.type},params:eo(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),Fa=zg({name:"search",initialState:hn,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=hn.fetchState,t.list=hn.list}},extraReducers:t=>{t.addCase(Qe.pending,e=>{e.fetchState="loading"}).addCase(Qe.rejected,(e,o)=>{e.fetchState="error",T.error(o.error)}).addCase(Qe.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(P,()=>hn)}}),{resetSearch:yn,setIsOpen:G,setPage:$}=Fa.actions,Ka=Fa.reducer;var jg=/(https?:\/\/[^\s]+)/,vn=t=>t.split(" ").find(e=>jg.test(e));import Ua from"classnames";import{jsx as Vg,jsxs as Wg}from"react/jsx-runtime";var qg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",Z);return Wg("button",{type:"button",...n,onClick:t,className:Ua(s.actionButton,n.className),children:[o,e&&e.map(r=>Vg("span",{className:Ua(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},bt=qg;import{jsx as Sn,jsxs as or}from"react/jsx-runtime";var Zg=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",Z),a=E($e),{selected:l,setSelected:c}=De(),p=r[l],d=p&&typeof p.text=="string"&&vn(p.text),u=Qg(null);function g(x){if(!u.current)return;let b=u.current.querySelectorAll(".command-palette-list-item"),_=0,R=0;x==="down"?(b.forEach((X,I)=>{I===l&&(_=I)}),R=_===b.length-1?0:_+1):x==="up"?(b.forEach((X,I)=>{I===l&&(_=I)}),R=_?_-1:b.length-1):c(0);let O=b[R];O&&typeof R=="number"&&(c(R),O.scrollIntoView&&O.scrollIntoView({behavior:"smooth",block:R?"center":"end"}))}function f(){if(!u.current)return;let x=u.current.querySelectorAll(".command-palette-list-item"),b=0;x.forEach((R,O)=>{O===l&&(b=O)});let _=x[b];_&&_.click()}let m=()=>{d&&window.open(d,"_blank")},v=()=>{p&&n(p,l)},w=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},h=$g(x=>{if(x.key==="Enter"&&x.altKey&&d){m();return}if(x.key==="Enter"&&x.shiftKey){w();return}if(x.key==="ArrowDown"){x.preventDefault(),x.stopPropagation(),g("down");return}if(x.key==="ArrowUp"){x.preventDefault(),x.stopPropagation(),g("up");return}x.key==="Enter"&&l!==-1&&(x.preventDefault(),x.stopPropagation(),f())},[l]);return Xg(()=>(window.addEventListener("keyup",h),()=>{window.removeEventListener("keyup",h)}),[h]),or("div",{className:i.actions,children:[Sn("div",{className:i.actionsWrapper,ref:u,children:t}),or("div",{className:i.actionsBar,children:[d&&Sn(bt,{onClick:m,shortKeys:[fn()?8997:"ALT",8629],children:a("visitUrl")}),p&&or(Gg,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&Sn(bt,{onClick:w,shortKeys:[8679,8629],children:o}),Sn(bt,{onClick:v,shortKeys:[8629],children:e})]})]})]})},ja=Zg;import{forwardRef as Yg}from"react";import{jsx as qa,jsxs as Jg}from"react/jsx-runtime";var Ct=()=>Jg("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[qa("path",{d:"M0 0h24v24H0z",fill:"none"}),qa("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});import{jsx as wt,jsxs as nr}from"react/jsx-runtime";function em({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",Z);return nr("div",{className:l.search,children:[wt("div",{className:l.searchIcon,children:wt(Ct,{})}),nr("div",{className:l.searchInputWrapper,children:[wt("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:c=>{t(c.currentTarget.value)},onFocus:c=>{c.currentTarget.select()},className:l.searchInput,placeholder:o,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&wt("div",{className:l.selectWrapper,children:nr("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:c=>e(c.target.value===n?void 0:c.target.value),value:i||n,children:[n&&wt("option",{children:n}),s.map(c=>wt("option",{value:c.value,children:c.label},c.value))]})})]})]})}var Va=Yg(em);import{jsx as Wa,jsxs as sm}from"react/jsx-runtime";function Ze({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:o="search",page:n,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:l,types:c,children:p,isOpen:d,search:u}){let[g,f]=om(0),m=nm(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(u.length>0){r("");return}a(!1)};return tm(()=>{f(0)},[u,n]),Wa(yt,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:w,onClose:v,children:sm(ba,{selected:g,setSelected:f,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&Wa(Va,{ref:m,onChange:r,onChangeType:i,placeholder:t,value:u,selectedType:l,types:c,typePlaceholder:e}),p]})})}Ze.Page=Zs;Ze.List=js;Ze.Image=Sa;Ze.ListItem=Xs;Ze.ActionsBar=ja;Ze.Button=bt;var L=Ze;import{jsx as _e,jsxs as to}from"react/jsx-runtime";var am=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",Fi),l=rm(),c=E(Cs),p=im(f=>f.overlayInput.text);Ga(()=>{t&&(l(Q.actions.reset()),l(Q.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(Q.actions.commitSuggestion()))},[t]);let d=f=>{f.preventDefault(),u(p)},u=f=>{l(Ko(f)),e(f)},g=f=>m=>{p!==i?window.confirm(c("warning"))&&f(m):f(m)};return Ga(()=>{n&&n(p!==i)},[n,t,p]),to("div",{className:a.root,children:[to("div",{className:a.content,children:[t.title&&_e("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&_e(fs,{labels:t.searchKeywords}),_e(va,{onUse:u,value:dn(p)})]}),to("form",{className:a.actions,onSubmit:d,children:[to("div",{children:[_e("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&g(r),children:_e(on,{})}),_e("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&g(s),children:_e(Zi,{})})]}),to("div",{className:a.primaryButtons,children:[_e(L.Button,{onClick:g(o),shortKeys:["esc"],children:c("dismiss")}),_e(L.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},_n=am;import{createAction as pm,createAsyncThunk as Za,createSlice as dm}from"@reduxjs/toolkit";var lm=["{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}"],cm=new RegExp(lm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function $a(t,e){let o=t.split(cm),n=0,s=[];for(let r=0;r<o.length;r++){let i=o[r];if(s.push(i),r===o.length-1)break;if(e.indexOf(i)===-1)return t;let a=o[r+1],l=r===o.length-2;n+=i.length;let c=n;if(l){let d=a.charAt(0),u=0;do c=d?e.indexOf(d,c+1):-1,u+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&u>2)return t}else c=a&&a!==""?e.indexOf(a,n):-1;let p=c===-1?e.slice(n):e.slice(n,c);s.push(p),n=c}return s.join("")}function Xa(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Ja={suggestions:[],fetchState:"idle",isInitialRequest:null},Qa={default:Ja},Ya=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)||[]},el=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},tl=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")},Tt=t=>t.textSuggestions,ol=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},xn=pm("textSuggestions/refresh"),xe=Za("textSuggestions/recommendations",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,inlineSuggestions:i}=n.settings,a=ht(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,eo(n),t);if(t==="default"){let p=i?l.filter(ol(a)):l;e.dispatch(de(p.slice(0,r)))}return l}),oo=Za("textSuggestions/autocompletions",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,deanonymize:i,inlineSuggestions:a}=n.settings;if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getAutocompleteSuggestions(s,{...eo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(ol(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?$a(p.text,t):p.text}))),l=Xa(l,r),e.dispatch(de(l)),l}),nl=dm({name:"textSuggestions",initialState:Qa,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(xe.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||Ja;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(xe.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(xe.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(oo.pending,e=>{e.default.fetchState="loading"}).addCase(oo.rejected,e=>{e.default.fetchState="error"}).addCase(oo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(P,()=>Qa)}}),{setTextSuggestions:sl,setSuggestionState:rl}=nl.actions,il=nl.reducer;import{createSlice as um}from"@reduxjs/toolkit";var al={contentType:null,suggestion:null},ll=t=>t.activeSuggestion.suggestion,cl=t=>t.activeSuggestion.contentType,pl=um({name:"activeSuggestion",initialState:al,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(P,()=>al)}}),{setActiveSuggestion:be,resetActiveSuggestion:sr}=pl.actions,dl=pl.reducer;var rr={};j(rr,{enUS:()=>gm,nlNL:()=>mm});var gm={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"}]},mm={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 fm}from"@reduxjs/toolkit";var hm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var bn=({ui:t})=>t.overlayCollapsed;var ul=fm({name:"ui",initialState:hm,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputHasFocus(t,e){t.overlayCollapsedUserOverwrite!==!0&&(e.payload===!0&&(t.overlayCollapsed=!1),t.inputHasFocus=e.payload)},setOverlayCollapsed(t,e){e.payload.collapse===!1&&(t.openOverlayWhenTyping=!1),!(e.payload.skipWhenInputFocus&&t.inputHasFocus)&&(t.overlayCollapsed=e.payload.collapse)},setOpenOverlayWhenTyping(t,e){t.openOverlayWhenTyping=e.payload},setOverlayCollapsedUserOverwrite(t,e){t.overlayCollapsedUserOverwrite=e.payload,t.overlayCollapsed=e.payload}}}),{setShowTabHint:no,setInputHasFocus:Et,setOverlayCollapsed:Be,setOpenOverlayWhenTyping:gl,setOverlayCollapsedUserOverwrite:ml}=ul.actions,fl=ul.reducer;import hl,{useContext as ym}from"react";import{jsx as vm}from"react/jsx-runtime";var yl=hl.createContext(null),Je=({broadcastEvents:t,children:e})=>{let o=hl.useMemo(()=>t,[]);return vm(yl.Provider,{value:o,children:e})},se=()=>{let t=ym(yl);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import{createAsyncThunk as ir,createSlice as Sm}from"@reduxjs/toolkit";var _m={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},oe=t=>t.auth.isLoggedIn,vl=t=>t.auth.loginFetchState,Sl=t=>t.auth.verifyFetchState,_l=t=>t.auth.showLoginOverlay,Ce=ir("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),xl=ir("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),so=ir("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),bl=Sm({name:"auth",initialState:_m,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(Ce.pending,e=>{e.loginFetchState="loading"}),t.addCase(Ce.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(Ce.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(so.pending,e=>{e.verifyFetchState="loading"}),t.addCase(so.rejected,e=>{e.verifyFetchState="error"}),t.addCase(so.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:kt,setShowLoginOverlay:Cl}=bl.actions,wl=bl.reducer;var ar="SetActiveSuggestion",Rt="ShowLoginOverlay",ro="UserLoggedIn",xm="UserLoggedOut",we="ApplySuggestion",lr="ApplyImageSuggestion",bm="ShowCommandPalette",Cm=t=>({[ar]:e=>{t.dispatch(rl(e.state)),t.dispatch(be({contentType:e.contentType,suggestion:e.suggestion}))},[bm]:e=>{t.dispatch(G(e.isOpen)),e.page&&t.dispatch($(e.page))},[Rt]:e=>{t.dispatch(Cl(e))},[ro]:()=>{t.dispatch(Ce())},[xm]:()=>{t.dispatch(Ce())},[lr]:e=>{t.dispatch(zo({suggestion:e.suggestion}))},[we]:e=>{t.dispatch(ie({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(ve())}}),Tl=Cm;import{jsx as El}from"react/jsx-runtime";var Em=()=>{var f;let[t,e]=wm(!1),o=cr(ll),n=cr(cl),s=cr(Tt),r=Tm(),i=se(),a=E(rr),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(sr()),r(Et(!0)),r(Q.actions.reset())},p=(m,v)=>{r(sr()),r(Et(!0)),i.send(we,{text:m,suggestion:{...v,source:`${v.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let d=(f=s[n])==null?void 0:f.suggestions.indexOf(o),u=d===0||d===null?void 0:()=>r(be({contentType:n,suggestion:s[n].suggestions[d-1]})),g=d===s[n].suggestions.length-1||d===null?void 0:()=>r(be({contentType:n,suggestion:s[n].suggestions[d+1]}));return El(yt,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:El(_n,{onTouched:e,onDismiss:c,onUse:m=>p(m,o),suggestion:o,onNext:g,onPrevious:u})})},kl=Em;import{useSelector as Ll}from"react-redux";import dr from"classnames";import{useCallback as Pl,useEffect as Lm,useMemo as Mm,useState as ur}from"react";import{useDispatch as Nm,useSelector as Om}from"react-redux";import km from"classnames";var Rl={root:"_root_1ukx5_1"};import{jsx as Im}from"react/jsx-runtime";var Rm=({className:t,value:e,...o})=>{let n=y("TextInput",Rl);return Im("input",{className:km(t,n.root),type:"text",value:e,...o})},io=Rm;var pr={};j(pr,{enUS:()=>Pm,nlNL:()=>Am});var Pm={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"}]},Am={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 Il={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 Cn}from"react/jsx-runtime";var Dm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Hm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=E(pr),i=y("LoginTokenDialog",Il),a=Om(Sl),l=Nm(),c=C("productName"),[p,d]=ur(t||""),[u,g]=ur(0),[f,m]=ur(""),v=Pl(async b=>{b.preventDefault(),l(xl({email:p})),g(1)},[o,p]),w=()=>{m(""),g(0)},h=Pl(async b=>{b.preventDefault();let _=Dm(b.target.elements.token.value);if(!_){m(r("verifyCodeError",{login:x}));return}l(so({token:_}))},[o]),x=Mm(()=>b=>J("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:b},"back-button"),[]);return Lm(()=>{a==="error"&&m(r("verifyCodeError",{login:x})),a==="done"&&n()},[a]),J(yt,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:Cn("div",{className:i.root,children:[J("h1",{className:i.title,children:r("promptTitle",{productName:c})}),u===0&&Cn("form",{onSubmit:v,children:[J("h2",{className:i.subtitle,children:r("requestCodeTitle")}),J("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),J(io,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:b=>d(b.target.value)}),J("div",{className:i.actions,children:J("button",{type:"submit",className:dr(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),u===1&&Cn("form",{onSubmit:h,children:[J("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),J("p",{className:i.text,children:r("verifyCodeBody")}),J(io,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&J("div",{className:i.errorMessage,children:f}),Cn("div",{className:i.actions,children:[J("button",{type:"button",className:dr(i.button),onClick:w,children:r("back")}),J("button",{type:"submit",className:dr(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},Al=Hm;import{jsx as Fm}from"react/jsx-runtime";var Bm=()=>{let t=Ll(_l),e=Ll(Aa),o=C("adminUrl"),n=se(),s=()=>n.send(Rt,!1),r=()=>{n.send(Rt,!1),n.send(ro)};return Fm(Al,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},Ml=Bm;import Af from"lodash.debounce";import{useCallback as Rn,useEffect as _r,useState as po}from"react";import{useDispatch as Lf,useSelector as Mt}from"react-redux";import{createAsyncThunk as Km,createSlice as Um}from"@reduxjs/toolkit";var zm={data:null,fetchState:"idle"},Nl=t=>t.contentTypes.data,ao=Km("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),jm=Um({name:"contentTypes",initialState:zm,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})}}),Ol=jm.reducer;function lo(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}import{useEffect as qm}from"react";function Dl(t,e){qm(()=>{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 Kl,useRef as Zm}from"react";import{useSelector as Jm,useDispatch as Ym}from"react-redux";import{createAsyncThunk as Vm,createSlice as Wm}from"@reduxjs/toolkit";var Hl={data:null,fetchState:"idle"},wn=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=Vm("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)}),Gm=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),$m=Wm({name:"entities",initialState:Hl,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=Gm(e.data?[...e.data,...o.payload]:o.payload)}).addCase(P,()=>Hl)}}),Bl=$m.reducer;var gr={};j(gr,{enUS:()=>Xm,nlNL:()=>Qm});var Xm={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Qm={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Fl={root:"_root_17kae_1",empty:"_empty_17kae_5"};import{jsx as Tn,jsxs as tf}from"react/jsx-runtime";var ef=({onCopy:t,onUse:e})=>{let o=Zm(null),n=y("EntitiesList",Fl),s=E(gr),r=Jm(wn),i=Ym();return Kl(()=>{i(ce())},[]),Kl(()=>{o.current&&o.current.focus()},[o]),tf("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&Tn(L.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:Tn(L.List,{children:r.map((a,l)=>Tn(L.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&Tn("p",{className:n.empty,children:s("noResults")})]})},Ul=ef;import{Fragment as lf,useEffect as En,useRef as cf,useState as pf}from"react";import{useSelector as Gl,useDispatch as df}from"react-redux";import{createAsyncThunk as of,createSlice as nf}from"@reduxjs/toolkit";var zl={data:null,fetchState:"idle"},jl=t=>t.summary.data,ql=t=>t.summary.fetchState==="error",Te=of("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"))}),sf=nf({name:"summary",initialState:zl,reducers:{},extraReducers:t=>{t.addCase(Te.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(Te.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(Te.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(P,()=>zl)}}),Vl=sf.reducer;var mr={};j(mr,{enUS:()=>rf,nlNL:()=>af});var rf={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."}]},af={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 Wl={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};import{jsx as It,jsxs as gf}from"react/jsx-runtime";var uf=({onCopy:t})=>{let e=cf(null),o=y("SummaryForm",Wl),[n,s]=pf(""),r=E(mr),i=Gl(jl),a=Gl(ql),l=df(),c=()=>{l(q({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let d=document.getSelection();d&&l(q({name:"summary copied to clipboard",data:{originalText:i,finalText:d==null?void 0:d.toString()},options:{includeConversationData:!0}}))};return En(()=>{l(Te())},[]),En(()=>{s(i||"")},[i]),En(()=>{e.current&&i&&e.current.focus()},[e,i]),En(()=>{let d=u=>{u.key==="Enter"&&u.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[n]),It("div",{className:o.root,tabIndex:-1,children:a?It("p",{className:o.error,children:r("error")}):gf(lf,{children:[It("div",{className:o.main,children:It("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:d=>s(d.target.value)})}),It("div",{className:o.actions,children:It(L.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},$l=uf;var fr={};j(fr,{enUS:()=>mf,nlNL:()=>ff});var mf={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?"}]},ff={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 Cf,{useEffect as vr,useRef as wf}from"react";import{useDispatch as Tf,useSelector as tc}from"react-redux";var hr={};j(hr,{enUS:()=>hf,nlNL:()=>yf});var hf={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"}]},yf={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 Xl={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 vf,createAsyncThunk as Sf,createSlice as _f}from"@reduxjs/toolkit";var yr={data:[],fetchState:"idle"},Ql=t=>{var e;return(e=t.answer)==null?void 0:e.data},Zl=t=>t.answer.fetchState,At=vf("answer/resetKnowledgeSearch"),Pt=Sf("answer/getAnswer",async(t,e)=>{var i,a;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=(a=(i=e.getState().profile)==null?void 0:i.data)==null?void 0:a.knowledgeAssistant;if(!s)throw new Error("KnowledgeAssistant is not defined");let r=await o.knowledgeAssist({promptInstruction:t.promptInstruction,question:t.question},n,s);return{question:t.question,answer:r}}),xf=_f({name:"answer",initialState:yr,reducers:{},extraReducers:t=>{t.addCase(Pt.pending,e=>{e.fetchState="loading"}).addCase(Pt.rejected,e=>{e.fetchState="error"}).addCase(Pt.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(P,()=>yr).addCase(At,()=>yr)}}),Jl=xf.reducer;import{jsx as Yl,jsxs as bf}from"react/jsx-runtime";var ec=()=>bf("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[Yl("title",{id:"paperPlaneTitle",children:"PaperPlane"}),Yl("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 Ee,jsxs as Sr}from"react/jsx-runtime";var Ef=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=Cf.useState(""),{setSelected:i}=De(),a=wf(null),l=y("EntitiesList",Xl),c=E(hr),p=Tf(),d=tc(Ql),u=tc(Zl),g=async m=>{m.preventDefault(),m.stopPropagation(),s!==""&&p(Pt({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 vr(()=>{var m;o&&u==="idle"?p(Pt({question:o,promptInstruction:n})):(m=a.current)==null||m.focus()},[a,u]),vr(()=>{u==="done"&&(p(q({name:"knowledge assist question answered",data:{question:s||o,sources:d[d.length-1].answer.sources,answer:d[d.length-1].answer.answer,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),i(d.length-1),r(""))},[u,d]),vr(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,d]),Sr("div",{className:l.root,children:[d.length>0&&Ee("div",{className:l.alignRight,children:Ee(L.Button,{onClick:e,children:c("reset")})}),Sr(L.ActionsBar,{list:d.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:m=>t(m.text),children:[d.map(({question:m,answer:v},w)=>Ee(L.List,{children:Ee(L.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}`)),u==="loading"&&Ee("p",{className:l.status,children:c("loading")}),u==="error"&&Ee("p",{className:l.status,children:c("error")}),Sr("form",{className:l.form,onSubmit:g,children:[Ee("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:m=>{i(-1),r(m.target.value)}}),Ee("button",{type:"submit",className:l.submit,children:Ee(ec,{})})]})]})]})},oc=Ef;import{createAsyncThunk as kf,createSlice as Rf}from"@reduxjs/toolkit";var If={data:null,fetchState:"idle"},Lt=t=>t.profile.data,kn=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],co=kf("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)}),Pf=Rf({name:"profile",initialState:If,reducers:{},extraReducers:t=>{t.addCase(co.pending,e=>{e.fetchState="loading"}).addCase(co.rejected,e=>{e.fetchState="error"}).addCase(co.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),nc=Pf.reducer;import{jsx as Y,jsxs as rc}from"react/jsx-runtime";var Mf=200,Nf=5,Of=4,Df=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),sc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Hf=()=>{let t=Lf(),e=se(),o=E(fr),[n,s]=po(!1),[r,i]=po(""),a=Mt(Da),l=Mt(Lt),[c,p]=po(null),[d,u]=po([]),[g,f]=po(),m=Mt(oe),v=C("showSearch"),w=C("showEntitiesCommand"),h=C("showSummaryCommand"),x=C("showKnowledgeSearch"),b=C("showImageSearch"),_=C("searchTriggerKey"),R=Mt(Nl),O=Mt(Ha),X=Mt(Oa),I=S=>is(O.filter(M=>M.type===S.toUpperCase()),S),W=[{value:"PERSONAL",label:o("personalSuggestions"),list:I("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:I("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:I("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:I("IMAGE"),listOrientation:"horizontal",shouldShow:b}].filter(S=>S.shouldShow),k=[{label:o("entitiesClipboard"),onClick:()=>t($("entities")),shouldShow:w&&sc(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t($("summary")),shouldShow:h&&sc(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t($("knowledgeAssist")),shouldShow:x}].filter(S=>S.shouldShow),H=(R==null?void 0:R.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:I(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],rt=Rn(Af((S,M)=>{t(Qe({query:S,type:M,tags:["search-overlay"]}))},Mf),[]),it=Df([...H,...W]),bo=Rn((S,M)=>{if(!M)return;let Pe=[...W,...H].find(({value:lt})=>lt===M);Pe&&(t($("edit")),p({...S,searchTerm:void 0}),u(Pe.list))},[t,c,H]),rs=Rn((S,M)=>{switch(M.type){case"IMAGE":e.send(lr,{suggestion:M});break;default:e.send(we,{text:S,suggestion:M})}t(G(!1))},[t]),dd=S=>{lo(S.text),t(q({name:"entity copied",data:{entity:S,type:"copy"}})),t(G(!1))},ud=Rn(S=>{t(q({name:"suggestion feedback",data:{text:S.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),gd=S=>{e.send(we,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(q({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t($("search")),t(At()),t(G(!1))},md=S=>{lo(S),t(G(!1))},fd=S=>{e.send(we,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(G(!1))},hd=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),yd=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function is(S,M){return S.slice(0,g?10:M.toLowerCase()==="image"?Of:Nf)}function ri(S,M,Pe){return M.reduce((lt,Co)=>Pe&&g===Pe?Co.length+lt:is(Co,Pe).length+lt,S)}function at(S){return M=>{n?window.confirm(o("warning"))&&(S(M),s(!1)):S(M)}}return _r(()=>{r?rt(r,g):t(yn())},[r,g]),_r(()=>{a==="search"&&t(At())},[a]),_r(()=>{m&&t(ao())},[m]),Dl(_,()=>t(G(!0))),!v||!l?null:rc(L,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:at(S=>t(G(S))),onChangeType:S=>f(S),onChangePage:at(S=>t($(S))),selectedType:g,search:r,page:a,isOpen:X,types:[...H,...W],children:[Y(L.Page,{id:"search",children:rc(L.ActionsBar,{list:[...k.map(S=>({text:S.label,type:"command"})),...it.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},M)=>rs(S,it[M]),onSecondary:(S,M)=>{bo(it[M-k.length],it[M-k.length].type)},children:[k.length>0&&Y(L.List,{heading:o("commands"),children:k.map((S,M)=>Y(L.ListItem,{index:ri(M,[],"commands"),closeOnSelect:!1,onClick:S.onClick,children:S.label},S.label))}),[...H,...W].map(({value:S,label:M,list:Pe,lineClamp:lt,listOrientation:Co},vd)=>Y(L.List,{heading:M,orientation:Co==="horizontal"?"horizontal":"vertical",children:is(Pe,S).map((ne,Sd)=>Y(L.ListItem,{index:ri(k.length+Sd,[...H,...W].slice(0,vd).map(({list:_d})=>_d),S),closeOnSelect:!1,lineClamp:lt,onClick:()=>rs(ne.text,ne),description:S!=="IMAGE"?ne.title&&ne.text:void 0,onFeedback:S!=="IMAGE"?()=>ud(ne):void 0,children:S==="IMAGE"?Y(L.Image,{title:ne.title||ne.text,src:ne.image}):ne.title||ne.text},`${ne.id}-${ne.text}`))},S))]})}),Y(L.Page,{id:"edit",onDismiss:at(()=>{t($("search")),p(null)}),children:c&&Y(_n,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t($("search")),p(null),u([])},onNext:yd,onPrevious:hd,onUse:S=>{t($("search")),rs(S,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(G(!1)),u([]),p(null)}})}),Y(L.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:at(()=>{t($("search"))}),children:Y(Ul,{onUse:fd,onCopy:dd})}),Y(L.Page,{id:"summary",title:o("summaryTitle"),onDismiss:at(()=>{t($("search"))}),children:Y($l,{onCopy:md})}),Y(L.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:at(()=>{t(At()),t($("search"))}),children:Y(oc,{promptInstruction:l.knowledgeAssistPromptInstruction,question:r,onUse:gd,onResetQuestion:()=>{t(At()),i("")}})})]})},ic=Hf;import{jsx as xr,jsxs as Kf}from"react/jsx-runtime";var Ff=()=>{let t=C("showSearch"),e=C("isEmbedded");return Kf(Bf,{children:[t&&xr(ic,{}),xr(kl,{}),e&&xr(Ml,{})]})},ac=Ff;import{useEffect as nh,useRef as sh}from"react";import{connect as rh,useDispatch as ih,useSelector as An}from"react-redux";function Nt(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 eh,useMemo as th}from"react";import{Interweave as jf}from"interweave";import{useEffect as qf,useMemo as Vf,useRef as Wf}from"react";import{useDispatch as Gf,useSelector as $f}from"react-redux";import{useEffect as Uf}from"react";function lc(t,e,o){Uf(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var cc={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};import{jsx as In,jsxs as Yf}from"react/jsx-runtime";var Xf=["search","personal-collection-search","search-autocomplete"];function Qf(t,e,o,n={}){let s="";return Xf.includes(e)?s=ma(Bs(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=Bs(t,o,n),n.placeholders===!0&&(s=fa(s)),s}var Zf=()=>{},Jf=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=C("inlineSuggestions"),r=$f(ht),i=Gf(),a=y("TextSuggestion",cc),l=Wf(null);qf(()=>{let p=setTimeout(()=>{i(ki({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),lc(l,"click",()=>{i(Me(t)),i(ie({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=Vf(()=>Qf(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:Yf("div",{className:a.root,onMouseEnter:()=>i(Me(t)),children:[In(D,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:Zf,children:In(jf,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&In("div",{className:a.actions,children:In(gn,{onFeedback:()=>n(o),suggestion:o.text})})]})},pc=Jf;import{jsx as dc}from"react/jsx-runtime";var oh=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=th(()=>{let r=e.map((i,a)=>dc(pc,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return dc(eh,{children:s})},Pn=oh;var uc={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};import{jsx as Ln}from"react/jsx-runtime";var ah=({textSuggestions:t,selectedIndex:e})=>{let o=sh(null),n=y("InlineSuggestionsOverlay",uc),s=An(Nt),r=ih(),i=An(oe),a=An(ft),l=An(bn),c=C("showTextSuggestions");return St(()=>{r(Be({collapse:!0,skipWhenInputFocus:!0}))}),nh(()=>{let p=o.current;if(!p||!p.parentElement)return;p.parentElement.style.left="0px";let d=p.getBoundingClientRect();p.parentElement.style.left=`${Math.min(window.innerWidth-4-d.right,0)}px`}),l||!s||!c||t.length===0||i!==!0||a===!1?null:Ln("div",{className:n.root,"data-variant":"inline",children:Ln("div",{ref:o,className:n.paper,children:Ln(re,{children:Ln(Pn,{suggestions:t,selectedIndex:e})})})})},lh=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),gc=rh(lh)(ah);import Er from"classnames";import{useEffect as _h,useRef as xh,useState as bh}from"react";import{connect as Ch,useDispatch as wh,useSelector as uo}from"react-redux";import{useState as ch}from"react";function mc(t,e){let[o,n]=ch(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return T.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){T.error(i)}}]}import uh from"classnames";import{Fragment as gh,useCallback as Cr,useMemo as hc}from"react";var br={};j(br,{enUS:()=>ph,nlNL:()=>dh});var ph={loginPlease:[{type:8,value:"login",children:[{type:0,value:"Sign in"}]},{type:0,value:" to enable "},{type:1,value:"productName"},{type:0,value:"."}],snooze:[{type:0,value:"Snooze for "},{type:8,value:"min",children:[{type:0,value:"10 minutes"}]},{type:0,value:", "},{type:8,value:"hour",children:[{type:0,value:"1 hour"}]},{type:0,value:" or "},{type:8,value:"day",children:[{type:0,value:"1 day"}]}]},dh={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 fc={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};import{jsx as Mn,jsxs as yc}from"react/jsx-runtime";var wr=(t,e,o)=>n=>Mn("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),mh=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=E(br),i=se(),a=y("Login",fc),l=C("productName"),c=Cr(v=>{v.preventDefault(),n&&n(parseInt(v.target.value,10))},[]),p=Cr(v=>{v.preventDefault(),i.send(Rt,!0)},[e]),d=hc(()=>v=>Mn("a",{onClick:h=>{h.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:v},"login"),[e]),u=Cr(v=>Mn("button",{type:"button",className:a.anchorButton,onClick:p,children:v},"prompt"),[p]),{min:g,hour:f,day:m}=hc(()=>({min:wr(a,60*10,c),hour:wr(a,60*60,c),day:wr(a,60*60*12,c)}),[]);return yc("div",{className:uh(t,a.root),children:[r("loginPlease",{login:o?u:d,productName:l}),n&&yc(gh,{children:[Mn("br",{}),r("snooze",{min:g,hour:f,day:m})]})]})},Nn=mh;import{useDispatch as fh}from"react-redux";var vc={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};import{jsx as Sc,jsxs as yh}from"react/jsx-runtime";var hh=({title:t})=>{let e=y("SearchTrigger",vc),o=fh();return yh("button",{type:"button",className:e.root,onClick:()=>o(G(!0)),children:[Sc(Ct,{}),Sc("span",{className:e.text,children:t})]})},_c=hh;var Tr={};j(Tr,{enUS:()=>vh,nlNL:()=>Sh});var vh={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"}]},Sh={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 xc={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 go}from"react/jsx-runtime";var Th=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=y("SuggestionsOverlay",xc),s=E(Tr),r=uo(Nt),i=bi(),a=wh(),l=xh(null),c=C("searchTriggerKey"),p=C("productName"),d=uo(bn),u=uo(oe),g=uo(ft),[f,m]=bh(null),v=C("showSearch"),w=C("showTextSuggestions"),h=C("adminUrl"),x=C("isEmbedded"),[b,_]=mc("dd-snooze-until-ms",0),R=d||b>Date.now(),O=uo(H=>H.input.text),X=t.filter(H=>H.source!=="gpt").length,I=()=>{R&&_(0),a(ml(!R))},W=H=>{a(q({name:"suggestion feedback",data:{text:H.text,source:"overlay",context:O},options:{includeConversationData:!0}}))},k=H=>{let rt=Date.now()+H*1e3;_(rt),T.info(`Snooze until: ${new Date(rt)}`),a(Be({collapse:!0}))};return _h(()=>{X===0&&m(null)},[t,X]),St(()=>{a(Be({collapse:!0,skipWhenInputFocus:!0}))}),u===null||g===!1?null:u===!1?go("div",{ref:l,className:Er(n.root,{[n.isCollapsed]:R}),children:[!R&&go("div",{className:n.triggers,children:[z("div",{style:{flex:1}}),z("div",{className:n.triggersRight,children:z(ut,{className:n.toggleButton,title:s("collapse"),onClick:I,isCollapsed:!1})})]}),z("div",{className:n.toggleButtonWrapper,children:z(ut,{className:n.toggleButton,title:s("open",{productName:p}),onClick:I,isCollapsed:!0})}),z("div",{className:n.collapsible,children:z(Nn,{loginUrl:h,isEmbedded:x,onLogIn:o,onSnooze:k})})]}):!i||!r?null:go("div",{ref:l,className:Er(n.root,{[n.isCollapsed]:R}),children:[!R&&go("div",{className:n.triggers,children:[z("div",{style:{flex:1},children:v&&z("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>m(s(fn()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>m(null),children:z(_c,{title:s("search")})})}),go("div",{className:n.triggersRight,onFocus:()=>{},children:[z("div",{className:Er(!f&&n.hintsHidden,n.hints),children:f}),z(ut,{className:n.toggleButton,title:s("collapse"),onClick:I,isCollapsed:!1})]})]}),z("div",{className:n.toggleButtonWrapper,children:z(ut,{className:n.toggleButton,title:s("open",{productName:p}),onClick:I,isCollapsed:!0})}),X>0&&w&&z("div",{className:n.collapsible,onFocus:()=>{},children:z(re,{children:z(Pn,{onFeedback:W,suggestions:t,selectedIndex:e,reverse:!0})})})]})},Eh=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),bc=Ch(Eh)(Th);import{Provider as kh}from"react-redux";import{jsx as On}from"react/jsx-runtime";var Rh=({children:t})=>{let o=C("locale").replace("-","");return On(As.Provider,{value:o,children:t})},Ih=({store:t,customStyles:e={},children:o})=>On(kh,{store:t,children:On(Rh,{children:On(zt.Provider,{value:e,children:o})})}),Ye=Ih;import Hr from"classnames";import{Interweave as hy}from"interweave";import{useCallback as yy,useEffect as vy,useMemo as zc,useRef as Sy}from"react";import{connect as _y}from"react-redux";import{cloneElement as Ph}from"react";var Ah=["div","span","mark","strong","b","i","u","em"];function kr(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(Ah.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),Ph(n,{children:kr(i,e,o+1)})]}return[...t,...e]}function Fe(t){return t.tagName.toLowerCase()==="textarea"}var Cc={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 $h from"classnames";import{Matcher as Xh}from"interweave";import{useEffect as Qh,useMemo as Zh}from"react";function wc(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Dn(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function Tc(t){return t!=null}import Pc from"classnames";import{createRef as Uh,useCallback as Ir,useMemo as zh,useRef as jh,useState as qh}from"react";import{useState as Lh,useLayoutEffect as Mh}from"react";var Nh=["bottom","height","left","right","top","width"],Oh=(t={},e={})=>Nh.some(o=>t[o]!==e[o]),ke=new Map,Ec,kc=()=>{let t=[],e=[];ke.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Oh(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{ke.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),Ec=window.requestAnimationFrame(kc)};function Dh(t,e){return{observe(){let o=ke.size===0;if(ke.has(t)){let n=ke.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else ke.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&kc()},unobserve(){let o=ke.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||ke.delete(t),ke.size||cancelAnimationFrame(Ec)}}}}function Rr(t){let[e,o]=Lh(null);return Mh(()=>{if(!t.current)return;let n=Dh(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}import{useContext as Hh,useLayoutEffect as Bh,useState as Fh}from"react";import{createPortal as Kh}from"react-dom";var Rc={root:"_root_1jq08_1"};var Ic=({children:t})=>{let[e,o]=Fh(null),n=Hh(zt);return Bh(()=>{let s=document.createElement("div");return Ge(s),s.classList.add(Rc.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?Kh(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 Pr}from"react/jsx-runtime";var Hn=(t=!1)=>{let[e,o]=qh(t),n=Ir(()=>o(!0),[]),s=Ir(()=>o(!1),[]),r=Ir(()=>o(a=>!a),[]),i=jh(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function Ar(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 Bn=({className:t,triggerRef:e,boundaryRef:o=Uh(),position:n="above",align:s="center",children:r,toStyle:i=Ar,...a})=>{let l=Rr(e),c=Rr(o),p=zh(()=>i(l,c,0),[l,c]);return Pr(Ic,{children:Pr("div",{className:Pc(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:Pr("div",{className:Pc(t,me.root),children:r})})})};import Vh from"classnames";import{forwardRef as Wh,useRef as Gh}from"react";import{jsx as Ac}from"react/jsx-runtime";var Fn=Wh(({className:t,children:e,...o},n)=>{let s=Gh(null),r=y("TabCompletion",Se);return Ac("div",{ref:Dn([s,n]),className:Vh(t,r.popoverContentContainer),...o,children:Ac("div",{className:r.popoverContent,children:e})})});import{jsx as mo,jsxs as ey}from"react/jsx-runtime";var Jh=t=>e=>{let o=Ar(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Yh=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",Se),i=Hn(),a=Zh(()=>Jh(t.getBoundingClientRect()),[t]),[l,c]=nn(t);return Qh(()=>{c?i.open():i.close()},[c]),ey("span",{children:[mo("mark",{ref:Dn([l,i.triggerRef]),className:$h(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&mo(Bn,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:mo(Fn,{style:o,children:mo("div",{className:r.hintText,children:s})})})]})},Kn=class extends Xh{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${wc(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(Tc);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 mo(Yh,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import Dr from"classnames";import{Matcher as cy}from"interweave";import{createRef as py,forwardRef as dy,useCallback as uy,useEffect as Fc,useRef as Kc,useState as Uc}from"react";import{useDispatch as gy}from"react-redux";import{jsx as Lc}from"react/jsx-runtime";var Mc=()=>Lc("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:Lc("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 ty,useEffect as Oc,useState as Dc}from"react";import{useDispatch as oy,useSelector as Hc}from"react-redux";import ny from"lodash.debounce";var Nc={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Un(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 Lr(t){return t.replace("https://www.","").replace("https://","")}import{jsx as et,jsxs as Mr}from"react/jsx-runtime";var sy=3,ry=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),iy=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=sy})=>{let r=y("LinkSearch",Nc),[i,a]=Dc(""),l=oy(),c=Hc(Ya("url")),p=Hc(Ba("URL",ry)),[d,u]=Dc(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 _;let x=d-1<0?p.length-1:d-1,b=d+1===p.length?0:d+1;h.code==="Escape"&&(a(""),e()),h.code==="ArrowUp"&&u(x),h.code==="ArrowDown"&&u(b),h.code==="Enter"&&t(((_=p[d])==null?void 0:_.text)||i)},w=ty(ny(h=>{l(Qe({query:h,type:"URL",tags:["link-search"]}))},300),[]);return Oc(()=>{i&&w(i)},[i]),Oc(()=>()=>{l(yn())},[]),Mr("div",{className:r.root,children:[et(re,{withDivider:!0,children:(i?p:c).slice(0,s).map((h,x)=>et(D,{selected:d===x,onClick:()=>t(h.text),"data-testid":"linksearch-suggestion",children:Mr(B,{children:[et(B.Image,{src:Un(h,"small",g||void 0),title:h.title||h.text}),Mr(B.Content,{className:r.content,cropText:!0,children:[et(B.Title,{children:h.title||Lr(h.text)}),h.title&&Lr(h.text)]}),et(D.Actions,{children:et(D.ActionButton,{label:n,onClick:b=>m(b,h.text)})})]})},h.text))}),et(io,{value:i,onChange:f,autoFocus:!0,placeholder:o,onKeyUp:v})]})},Bc=iy;var Nr={};j(Nr,{enUS:()=>ay,nlNL:()=>ly});var ay={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},ly={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 my=dy((t,e)=>{let o=y("TabCompletion",Se);return fe("mark",{ref:e,className:Dr(o.matchSelection)},"selection-start")}),fy=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=E(Nr),i=y("TabCompletion",Se),a=Kc(null),l=Kc(null),[c,p]=Uc(null),d=gy(),u=Hn(document.activeElement===n),[g]=Uc(()=>document.createRange());u.triggerRef.current=g,Fc(()=>()=>g.detach(),[]),Fc(()=>{let m=t.current,v=a.current;!m||!v||(g.setStart(m,0),g.setEnd(v,0))},[t.current,a.current]),St(()=>{u.close()});let f=uy(m=>{let v=g.toString(),w=/^http(s?):\/\//.test(m)?m:`https://${m}`;d(Bo({text:`[${v}](${w})`,replace:"selection"}))},[]);return Or("span",{children:[fe("mark",{ref:a,className:Dr(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":u.opened?"true":"false",children:s}),u.opened&&fe(Bn,{className:i.popoverRoot,triggerRef:u.triggerRef,boundaryRef:e,position:"above",align:"start",children:Or(Fn,{style:o,ref:l,children:[fe("div",{className:Dr(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(Mc,{}),fe("span",{children:"\xA0"}),fe("span",{children:r("insertLink")})]})}),c==="insertLink"&&fe(Bc,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:f,onDismiss:()=>{p(null),u.close()}})]})})]},"selection-end")},zn=class extends cy{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=py(),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(my,{ref:this.startRef}):fe(fy,{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 xy=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",Cc),p=C("insertLink"),d=C("showMidSentenceSuggestions"),u=C("inlineSuggestions"),g=rn(a),f=Sy(null);vy(()=>{Fe(a)&&g&&an(a,g)},[g]);let m=yy(h=>{if(!s||!o)return h;let x=[Ot("span",{className:c.resetIndent,children:"\u200B"},"u200B"),Ot("span",{"data-testid":"tab-completion",className:Hr(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&x.push(Ot("span",{className:Hr(c.hint,c.resetIndent),children:Ot(ps,{keyCode:"tab"},"tabHint")})),kr(h,x)},[s,o,n]),v=zc(()=>{let h=[];return p&&h.push(new zn("selection")),h.push(new vt("placeholders")),r&&h.push(new Kn("keywords")),h},[u,p,r]),w=zc(()=>{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(hy,{tagName:"span",containerTagName:"div",className:Hr(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:!d}),Ot("br",{})]}):null},by=({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??Qt(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:u,visible:g,showStyleSuggestions:f}=o;return{showTabHint:p,showStyleSuggestions:f,showTabCompletion:u,content:l,tabText:c,source:a,keywordMatches:((m=n.list)==null?void 0:m.keywordMatches)??[],enabled:g&&d!==!1}},jc=_y(by)(xy);import sv from"classnames";import{useEffect as rv}from"react";import{useDispatch as iv,useSelector as ee}from"react-redux";import{createAsyncThunk as fo,createSlice as wy}from"@reduxjs/toolkit";var qc={list:[],fetchState:"idle",isInitialRequest:null},Wc=t=>t.autoflows.list||[],Vc=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},Re=fo("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Br=fo("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(Re(t.platformSessionId))}),Fr=fo("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(Re(t.platformSessionId))}),Ty=wy({name:"autoflows",initialState:qc,reducers:{},extraReducers:t=>{t.addCase(Br.pending,(e,o)=>{let n=Vc(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Fr.pending,(e,o)=>{let n=Vc(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(Re.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(Re.rejected,e=>{e.fetchState="error"}),t.addCase(Re.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(P,()=>qc)}}),Gc=fo("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(Re(t))}),s.on("sessionCompleted",()=>{o(Re(t))})}),$c=fo("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Xc=Ty.reducer;import{createAsyncThunk as yo,createSlice as Ey}from"@reduxjs/toolkit";var Qc={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Zc=t=>t.customMessages.list,Jc=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Yc=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),ep=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),ho=yo("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),jn=yo("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)}),qn=yo("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)}),tp=Ey({name:"customMessages",initialState:Qc,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(ho.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(ho.rejected,e=>{e.fetchState="error"}).addCase(ho.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(jn.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(jn.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(qn.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(qn.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(P,()=>Qc)}}),op=yo("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(tp.actions.onCustomMessage(r))})}),np=yo("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),sp=tp.reducer;import{createAsyncThunk as rp,createSlice as ky}from"@reduxjs/toolkit";var Ry={token:null,accountUrl:null,interval:null},ip=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},Kr=rp("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),Ur=rp("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(Kr()),setInterval(()=>n(Kr()),o)}),ap=ky({name:"passwordlessToken",initialState:Ry,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Kr.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(Ur.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:lp}=ap.actions,cp=ap.reducer;function pp(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}import{Fragment as By}from"react";import{connect as Fy}from"react-redux";import Oy from"classnames";import{Fragment as Dy}from"react";import Iy from"classnames";var dp={root:"_root_838fd_1"};import{jsx as Ay}from"react/jsx-runtime";var Py=({className:t,children:e})=>{let o=y("Unicode",dp);return Ay("span",{className:Iy(t,o.root),children:e})},up=Py;var gp={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 zr={};j(zr,{enUS:()=>Ly,nlNL:()=>My});var Ly={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"}]},My={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]};import{jsx as tt,jsxs as Vn}from"react/jsx-runtime";var Hy=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",gp),a=E(zr),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return Vn(D,{className:Oy(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[tt(B,{children:Vn(B.Content,{children:[Vn(B.Title,{children:[e&&tt("span",{className:i.stateBadge,children:a(e)}),o]}),tt("span",{children:n})]})}),tt(D.Actions,{fixed:e==="Started",children:tt(D.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:Vn(Dy,{children:[tt(up,{children:c})," ",tt("span",{children:a(l)})]})})})]})},mp=Hy;import{jsx as fp}from"react/jsx-runtime";var Ky=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Uy=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>fp(By,{children:t.map(s=>fp(mp,{displayName:s.displayName,description:s.description,disabled:s.isBusy||Ky(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),zy=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},jy={onStartAutoflow:Br,onStopAutoflow:Fr},hp=Fy(zy,jy)(Uy);import{useEffect as qy,useState as Vy}from"react";import{useDispatch as Wy}from"react-redux";import Sp from"classnames";import{jsx as yp}from"react/jsx-runtime";var jr=()=>yp("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:yp("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 vp={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 Dt,jsxs as _p}from"react/jsx-runtime";var Gy=({entities:t})=>{let e=y("EntitiesWidgetList",vp),[o,n]=Vy(void 0),s=Wy(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),lo(a.text),s(q({name:"entity copied",data:{entity:a,type:"copy"}})))};return qy(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:Dt("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>_p("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[Dt("span",{className:e.entityText,children:a.text}),_p("span",{className:e.iconWrapper,children:[Dt("span",{className:Sp(e.icon),children:Dt(jr,{})}),Dt("span",{className:Sp(e.icon,o===l&&e.iconClicked),children:Dt(jr,{})})]})]},a.text))})},xp=Gy;import $y from"classnames";import{useCallback as bp}from"react";import{useDispatch as Xy,useSelector as Wn}from"react-redux";var Ie={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 Gn}from"react/jsx-runtime";var Qy=({suggestion:t})=>{let e=E(Xe),o=Xy(),n=Wn(Jc(t.text)),s=Wn(Yc(t.text)),r=Wn(ep(t.text)),i=Wn(Po),{replyOptions:a}=t,l=bp(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(jn({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=bp(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),u=a[d];o(qn({platformSessionId:i,reply:u,suggestion:t}))},[t,n,o,i]);return Gn(D,{onClick:l,className:$y(Ie.root,{[Ie.isUsed]:n,[Ie.hasError]:r}),children:[Ke(B,{children:Gn(B.Content,{children:[Gn(B.Title,{className:Ie.title,children:[t.text," ",Ke(ds,{className:Ie.label,children:"analyse tool"})," ",r&&Ke("span",{className:Ie.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&Ke("ul",{className:Ie.quickReplies,children:a.map(p=>Ke("li",{className:Ie.quickReply,children:p.title},p.title))})]})}),Gn(D.Actions,{fixed:r||n,children:[a&&a.length>0&&Ke(D.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>Ke(D.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),Ke(D.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},Cp=Qy;import{jsx as wp}from"react/jsx-runtime";var Tp=()=>wp("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:wp("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 Yy}from"react-redux";import{useCallback as Zy}from"react";import{jsx as ot,jsxs as $n}from"react/jsx-runtime";var Jy=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var u;let s=t.text||t.url||t.message,r=vn(s),i=E(Xe),a=C("showImages"),l=C("fallbackImage"),c=g=>{g.preventDefault(),g.stopPropagation(),n(s)},p=g=>{g.preventDefault(),g.stopPropagation(),o(t)},d=Zy(g=>{window.open(r,"_blank"),g.stopPropagation(),g.preventDefault()},[r]);return $n(D,{onClick:c,"data-testid":"edit-suggestion",children:[$n(B,{children:[a&&t.image&&ot(B.Image,{src:Un(t,"small",l||void 0),title:t.title}),$n(B.Content,{children:[t.title&&ot(B.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&ot(D.Labels,{labels:t.searchKeywords}),ot(B.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),$n(D.Actions,{children:[r&&ot(D.ActionButton,{onClick:d,label:i("visitUrl")}),ot(D.ActionButton,{primary:!0,onClick:p,label:i("preview")}),ot(D.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},Ep=Jy;import{Fragment as tv,jsx as kp}from"react/jsx-runtime";var ev=({contentType:t,lines:e,suggestions:o})=>{let n=se(),s=Yy(Tt),r=a=>{n.send(ar,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(we,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return kp(tv,{children:o.map(a=>kp(Ep,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},Rp=ev;var qr={};j(qr,{enUS:()=>ov,nlNL:()=>nv});var ov={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},nv={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Ip={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 Pp}from"react/jsx-runtime";var Ap=()=>Pp("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:Pp("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 Lp}from"react/jsx-runtime";var Mp=()=>Lp("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:Lp("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 N,jsxs as Ht}from"react/jsx-runtime";var Xn=(t,e)=>{let o=ee(oe);rv(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},av=({onLogIn:t})=>{let e=E(qr),o=iv(),n=C("isEmbedded"),s=y("Widget",Ip),r=C("showAutoflows"),i=C("showCustomMessages"),a=C("showSummaryCommand"),l=C("showKnowledgeSearch"),c=C("showSearch"),p=ee(Lt),d=ee(kn),u=ee(Wc),g=ee(wn),f=ee(Zc),m=ee(Ao),v=ee(ft),w=ee(oe),h=ee(Po),x=ee(pp),b=ee(Tt),_=se(),R=ee(tl),O=ee(ip("/admin/")),X=C("adminUrl"),I=C("productName");if(Xn(()=>(o(ho(h)),o(op(h)),()=>{o(np(h))}),[o,v,i,h]),Xn(()=>(o(Re(h)),o(Gc(h)),()=>{o($c(h))}),[o,v,r,h]),Xn(()=>{d.forEach(({type:k})=>{o(k==="entities"?ce():xe(k))})},[o,v,m,p]),Xn(()=>(o(Ur()),()=>{o(lp())}),[o]),v===!1)return N("div",{className:s.stateText,children:N("div",{children:N("p",{children:e("notSupported")})})},"supported");if(w===!1)return N("div",{className:s.loginText,children:N("div",{children:N(Nn,{isEmbedded:n,loginUrl:X,onLogIn:t})})},"login");if(!p||!h||w===null||R||x)return N("div",{className:s.stateText,children:N("div",{children:N("p",{children:e("waiting")})})},"waiting");let W=c||a||l||O;return N("div",{className:sv(s.root),"data-testid":"widget",children:Ht(gs,{className:s.sectionList,children:[W&&N(ze,{title:e("actions"),type:"shortcuts",children:Ht("div",{className:s.shortcutList,children:[c&&Ht("button",{className:s.shortcut,"data-testid":"shortcut-search",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0}),children:[N(Ct,{}),e("linkSearch")]}),a&&Ht("button",{className:s.shortcut,"data-testid":"shortcut-summary",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[N(Mp,{}),e("linkSummary")]}),l&&Ht("button",{className:s.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[N(Ap,{}),e("linkKnowledgeSearch")]}),O&&Ht("a",{className:s.shortcut,target:"_blank",href:O,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[N(Tp,{}),e("linkStudioLogin",{productName:I})]})]})}),i&&f.length>0&&N(ze,{type:"custom-messages","data-testid":"custom-messages",children:N(re,{withDivider:!0,children:f.map(k=>N(Cp,{suggestion:k},k.text))})}),r&&u.length>0&&N(ze,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:N(re,{withDivider:!0,children:N(hp,{})})}),d.map(({type:k,title:H,amount:rt,lines:it})=>{var bo;switch(k){case"entities":return g&&g.length>0&&N(ze,{type:k,title:H,"data-testid":`type-${k}`,children:N(xp,{entities:g})},k);default:return((bo=b[k])==null?void 0:bo.fetchState)==="done"&&b[k].suggestions.length>0&&N(ze,{type:k,title:H,"data-testid":`type-${k}`,children:N(re,{withDivider:!0,children:N(Rp,{lines:it,contentType:k,suggestions:b[k].suggestions.slice(0,rt)||[]})})},k)}})]})})},Np=av;function So(t){let e=new Range;return e.selectNodeContents(t),e}function Op(t,e,o){try{return nt(t,e,o),!0}catch{return!1}}function Qn(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function Zn(t){return"tagName"in t&&t.tagName==="BR"}var vo=/[\u200B-\u200D\uFEFF]/g;function nt(t,e,o){let n=new Range;if(t.firstChild===null&&e===0&&o===0)return n.selectNodeContents(t),n;let s=0,r=!1;function i(l,c){let p=-1,d=/[\u200B-\u200D\uFEFF]/;if(!d.test(l))return c;for(let u=0;u<=l.length;u++)if(d.test(l[u])||p++,p===c)return u;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(vo,""),d=s+p.length,u=e>=s&&e<=d,g=o>=s&&o<=d;if(u){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=d;break}case Node.ELEMENT_NODE:{if(Zn(l)&&(s===e&&n.setStartBefore(l),s++,s===o)){n.setEndAfter(l),r=!0;return}for(let p=0;p<l.childNodes.length&&(a(l.childNodes[p]),!r);p++);let c=l.lastChild;Qn(l)&&c&&!Qn(c)&&!Zn(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function Jn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r,collapsed:i}=e,a,l,c=0;function p(d){let u=d===o,g=d===s;switch(d.nodeType){case Node.TEXT_NODE:{let f=d.textContent;u&&(a=c+f.substring(0,n).replace(vo,"").length),g&&(l=c+f.substring(0,r).replace(vo,"").length),c+=f.replace(vo,"").length;break}case Node.ELEMENT_NODE:{let f=d.nextSibling===null;Zn(d)&&!f&&c++;for(let m=0;m<d.childNodes.length;m++){let v=u&&m===n,w=g&&m===r;if(v&&(a=c),w&&(l=c),l!==void 0||((!v||!i)&&p(d.childNodes[m]),g&&m===r-1&&(l=c),l!==void 0))break}!g&&Qn(d)&&!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 Yn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let p=c===o,d=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let u=p?n:0,g=d?r:void 0,f=c.textContent.replace(vo,"");u===0&&g===void 0?a+=f:a+=f.substring(u,g);break}case Node.ELEMENT_NODE:{let u=c.nextSibling===null;i===0&&Zn(c)&&!u&&(a+=`
|
|
4
|
-
`);for(let g=p?n:0;g<(
|
|
5
|
-
`);break}default:break}d&&i++}return l(t),a}function Dp(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Bt=class extends Ne{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),Yn(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!Dp(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!Dp(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return Jn(this.element,e);let o=this.lastKnownSelection;if(o&&Op(this.element,o.start,o.end))return o;let n=So(this.element);return n.collapse(!1),Jn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return Yn(this.element,nt(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 Hp(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 Vr=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()}},Wr=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=Hp(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()}},Gr=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),T.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 Wr(e,this.deepdeskUrl,{debug:!0}):new Vr(e),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&s.data.channel===e&&(T.info("Received broadcast event",this.sessionId,s),(i=(r=this.eventMap)[s.data.name])==null||i.call(r,s.data.payload))};return o.onMessage(n),o}send(e,o){var r,i;T.info("broadcast event",{sessionId:this.sessionId,name:e,payload:o});let n={type:"event",name:e,payload:o};(i=(r=this.eventMap)[e])==null||i.call(r,o);let s=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage({...n,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},Bp=Gr;var Ft=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var $r=t=>new Promise(e=>{setTimeout(e,t)});var Kt=class extends Ft{name="ClientError"},Xr=class extends Ft{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:d=!0,retryOnError:u=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 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 x=async()=>(w--,a(i,v).then(async b=>g(b)&&!r.isAborted&&w>0?(await $r(p),x()):b.status===401&&d===!0&&h===!1?(h=!0,await this.refreshToken(),x()):b).catch(async b=>{if(u(b)&&!r.isAborted&&w>0)return await $r(p),x();throw b}));x().then(b=>b.json().catch(()=>null).then(_=>{b.status>=500?s(new Xr("Server Error",_)):b.status===401?s(new Kt("Unauthorized",_)):b.status===403?s(new Kt("Forbidden",_)):b.status===404?s(new Kt("Not Found",_)):b.status>=400&&s(new Kt("Bad Request",_)),delete this.latestRequestByUrl[i],n(_)})).catch(b=>{s(b)})})}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var lv;(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||={})})(lv||={});function es(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(),T.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 es(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(),T.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 es(r)}async isConversationSupported(e,o={}){T.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 es(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=>es(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 T.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-assist/assistants/${n}/search`,F({question:e.question,promptInstruction:e.promptInstruction,chatHistory:o.map(r=>({question:r.question,answer:r.answer.answer}))}),{version:"v2"});return A(s)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return A(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return A(e.token)}async getCsrfToken(){let{token:e}=await this.client.get("/apis/admin/session/csrf/",{version:null});return e}async verifyLoginToken(e){let o=await this.client.post("/apis/admin/session/passwordless/login/",{token:e},{version:null});return A(o)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(mi);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&T.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var _o=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Js(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,A(s))}catch{T.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 cv;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(cv||={});var xo=class{constructor(e,o={}){this.apiUrl=e;this.client=new he(e,o)}client;streams={};logger=T;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 _o(`${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 hv,configureStore as yv}from"@reduxjs/toolkit";import{createSlice as pv}from"@reduxjs/toolkit";var Fp={startTime:null,stopTime:null},Kp=pv({name:"handlingTime",initialState:Fp,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(P,()=>Fp)}}),{handlingTimeStart:Up,handlingTimeStop:ts,handlingTimeReset:zp}=Kp.actions,jp=Kp.reducer;var qp=(t={})=>{let e={onAuthError:kt(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};import{createAsyncThunk as dv,createSlice as uv}from"@reduxjs/toolkit";var os={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var st=dv("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 os.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),gv=uv({name:"styleSuggestions",initialState:os,reducers:{},extraReducers:t=>{t.addCase(st.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(st.rejected,e=>{e.fetchState="error"}).addCase(st.fulfilled,(e,o)=>{e.fetchState="done",Ae(e.list,o.payload)||(e.list=o.payload)}).addCase(Ve,e=>{e.list=os.list}).addCase(P,()=>os)}}),Vp=gv.reducer;var Wp=(t={})=>{let e,o=!0,n={getStyleSuggestions:st,debounce:500,...t};return s=>r=>i=>{var g;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:p}=c.settings;if(!((g=c.conversation.current)==null?void 0:g.id)||!p)return l;let{text:u}=c.input;return u===a&&!o||(clearTimeout(e),u==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:u}))},t.debounce)),l}};function mv(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Gp=(t={})=>{let e={getTextSuggestions:xe,getAutocompleteSuggestions:oo,debounce:200,check:Nt,...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,d=(m=l.conversation.current)==null?void 0:m.id,u=r.type===xn.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:g}}=l;return mv(g,i)&&!u||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let v=ht(l);v===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(v))},u?0:e.debounce)),a}};var $p=st.fulfilled.toString();function fv(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 Xp=t=>e=>o=>n=>{var c;if(n.type!==$p){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=fv(s,i);n.type===$p&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var vv=hv({activeSuggestion:dl,answer:Jl,auth:wl,autoflows:Xc,conversation:_i,contentTypes:Ol,customMessages:sp,passwordlessToken:cp,entities:Bl,handlingTime:jp,info:Na,input:xs.reducer,overlayInput:Q.reducer,settings:hi,profile:nc,search:Ka,summary:Vl,styleSuggestions:Vp,ui:fl,textSuggestions:il});function Qp(t){return yv({reducer:vv,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),qp(),Gp({debounce:200}),Wp({debounce:500}),Xp(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Sv=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},_v=t=>e=>o=>n=>{var a;let s=e.getState(),r=ys("inlineSuggestions")(s);switch(n.type){case be.toString():{let l=el(n.payload.contentType)(e.getState()),c=l.indexOf(n.payload.suggestion);t.emit("edit-suggestion",{contentType:n.payload.contentType,index:c,suggestions:l});break}case kt.toString():{!n.payload&&t.emit("logout",void 0);break}case ie.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:Sv(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Bo.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 Vt.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case zo.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 Te.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 Fo.toString():t.handleKeyDown(n.payload);break;case Ve.toString():t.logSendMessage(n.payload);break;case Ko.toString():t.logSendEditSuggestionMessage(n.payload);break;case Uo.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case Ve.toString():t.handleAfterSendMessage(n.payload);break;case no.toString():t.onUpdateShowTabHint(n.payload);break;case ts.toString():t.logHandlingTime();break;case ie.toString():{r&&(e.dispatch(de([])),e.dispatch(ve()));break}case de.toString():{r&&n.payload.length>0&&e.dispatch(Me(0));break}default:break}return i},Zp=_v;function Qr(t){return t.toISOString().replace("T"," ").replace("Z","")}function Jp(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:Qr(o),timeStop:Qr(n)}}function Zr(t,e,o){var O,X,I;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:d,cuts:u,deletions:g,textSuggestions:f,offeredTextSuggestions:m}}=e[t],v=n.length,h=f.reduce((W,{text:k,searchTerm:H})=>W+k.length-(H?H.length:0),0),x=c??Date.now(),b=(Date.now()-x)/1e3+(p||0),_=s/b,R=f.reduce((W,{searchTerm:k})=>W+(k?k.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:d,cuts:u,deletions:g,lenTextTyped:s+R,lenTextTotal:v,lenTextAssisted:h,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:b,charsPerSecond:_,numPastes:l,textSuggestionsV2:f,suggestionsCounters:[{source:"gpt",countOffered:m.filter(W=>W.source==="gpt").length}],agentId:(O=e.info.agentInfo)==null?void 0:O.agentId,agentName:(X=e.info.agentInfo)==null?void 0:X.agentName,agentEmail:(I=e.info.agentInfo)==null?void 0:I.agentEmail}}function Jr(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return Jr(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?Jr(s,e):null}function Yp(t,e){return Jr(t,e)}function ed(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function xv(t){return typeof t=="object"&&t!==null&&"tagName"in t}function Yr(t){return xv(t)&&(Fe(t)||sn(t))}var td=(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{T.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function bv(t){return t.offsetParent!==null}function od(t){if(!bv(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 ei(t,e,o=100){let n=od(t);e({isVisible:n});let s=setInterval(()=>{let r=od(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}import{useSelector as Ev}from"react-redux";import{jsx as ti}from"react/jsx-runtime";var nd=({className:t})=>ti("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:ti("g",{children:ti("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
|
|
3
|
+
`,We.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 Is(p.value,d,Object.keys(p.options),i);a.push.apply(a,Xt(x.value,e,o,n,s,d-(p.offset||0)));continue}}return Rd(a)}function Pd(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 Ad(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Pd(t[n],e[n]),o},te({},t)):t}function Ps(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Ld(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:en(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,jo([void 0],o,!1)))},{cache:Ps(t.number),strategy:tn.variadic}),getDateTimeFormat:en(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,jo([void 0],o,!1)))},{cache:Ps(t.dateTime),strategy:tn.variadic}),getPluralRules:en(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,jo([void 0],o,!1)))},{cache:Ps(t.pluralRules),strategy:tn.variadic})}}var $i=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 Xt(r.ast,r.locales,r.formatters,r.formats,c,void 0,r.message)},this.resolvedOptions=function(){var c;return{locale:((c=r.resolvedLocale)===null||c===void 0?void 0:c.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=o,this.resolvedLocale=t.resolveLocale(o),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=s||{},a=i.formatters,l=Ki(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=Ad(t.formats,n),this.formatters=s&&s.formatters||Ld(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=ji,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 Od(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var Dd="dummy",As=Md(null);function E(t){let e=Nd(As);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=Od(o,n);return r?new $i(r).format(s):(e!==Dd&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}import{jsx as Xi,jsxs as Hd}from"react/jsx-runtime";var on=()=>Hd("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[Xi("title",{id:"angleLeftTitle",children:"AngleLeft"}),Xi("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 Qi,jsxs as Bd}from"react/jsx-runtime";var Zi=()=>Bd("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[Qi("title",{id:"angleRightTitle",children:"AngleRight"}),Qi("path",{d:"M64 448c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L178.8 256L41.38 118.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l160 160c12.5 12.5 12.5 32.75 0 45.25l-160 160C80.38 444.9 72.19 448 64 448z"})]});import{useEffect as Zt,useRef as Us,useState as lg}from"react";import{useDispatch as cg}from"react-redux";import{Interweave as ha}from"interweave";import ya from"classnames";var Ls={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 zd}from"interweave";import jd from"classnames";import{useEffect as Fd,useRef as Kd,useState as Ud}from"react";function Ji(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function nn(t){let e=Kd(null),[o,n]=Ud(!1);return Fd(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=Ji((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]=Ji(()=>{s=!1,n(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",l),()=>{a(),c(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",l)}},[e]),[e,o]}var 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 Yi}from"react/jsx-runtime";var qd=({inputElement:t,children:e})=>{let o=y("TabCompletion",Se),[n,s]=nn(t);return Yi("mark",{ref:n,className:jd(o.matchPlaceholder,{[o.hover]:s}),children:e})},vt=class extends zd{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 Yi(qd,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import{useEffect as Vd,useRef as Wd,useState as Gd}from"react";function sn(t){return t.contentEditable==="true"}function $d(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 ea(t){let{selectionStart:e,selectionEnd:o}=sn(t)?$d(t):t;return[e,o]}function rn(t){let[,e]=Gd(),o=Wd(null);return o.current=ea(t),Vd(()=>{let n=()=>{let[s,r]=o.current??[],i=ea(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 an(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(gt);if(!i||i.length===0)return;let a=0;i.find(l=>{let c=n.indexOf(l,a);return s>c&&r<c+l.length?(o.selectionStart=c,o.selectionEnd=c+l.length,!0):(a=c+l.length,!1)})}import{useEffect as Xd}from"react";function St(t){Xd(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Ge(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var ta,de=new Map,Qd=["bottom","height","left","right","top","width"],Zd=(t={},e={})=>Qd.some(o=>t[o]!==e[o]);function oa(t){var o,n;if(t.ownerDocument===document)return[];let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...oa(e)]:[]}function na(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var ln=!1,sa=()=>{ln=!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();Zd(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(na,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),de.size===0){ln=!1;return}ta=window.requestAnimationFrame(sa)};function Ms(t,e){let o=oa(t),n=[],s=o.map((r,i)=>Ms(r,a=>{n[i]=a;let l=de.get(t);if(!l)return;let c=n.reduce(na,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&&!ln&&sa()},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(ta),ln=!1)}}}}var ra,ge=new Map,ia=()=>{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&&(ra=window.requestAnimationFrame(ia))};function aa(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&&ia()},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(ra)}}}}var Ns=["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 _t(t){return parseFloat(t)}function cn(t){return Math.round(t*1e6)}function la(t){return t/1e6}function Ds(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=_t(t.width),r=_t(t.borderLeftWidth),i=_t(t.borderRightWidth),a=_t(t.paddingRight),l=la(cn(s)-cn(r)-cn(i)),c=la(cn(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function xt(t,e={}){var l;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",Ge(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Os(n,o,Ns),Ds(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=aa(t,()=>{Os(n,o,Ns),Ds(n,t,o),r(),setTimeout(r,0)}),a=Ms(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,Ns),Ds(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=_t(u.borderTopWidth),g=_t(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 Hs={};j(Hs,{enUS:()=>Jd,nlNL:()=>Yd});var Jd={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"}]},Yd={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 ca,jsxs as eg}from"react/jsx-runtime";var pa=()=>eg("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[ca("title",{id:"circleCheckTitle",children:"Check"}),ca("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 ua}from"react/jsx-runtime";var da=()=>ua("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:ua("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 tg(t){let e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!n}function pn(t){return t?t instanceof ShadowRoot?pn(t.host):t===t.ownerDocument.body?t.ownerDocument:tg(t)?t:pn(t.parentNode):document.body}var ga=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(ga||{}),Ne=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentCaret=null;currentSelection={start:0,end:0};currentHTML="";isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(e,o){let n=s=>{o(s)};this.element.addEventListener(e,n),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,n)})}removeEventListener(e,o){this.element.removeEventListener(e,o)}triggerChange(){let e=this.getText(),o=this.getHTML(),n=e!==this.currentText;this.isActive&&(e===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&n&&!this.isSubmitting&&this.emit("change",{plainText:e}),n&&(this.currentSelection=this.getSelection()),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==o||o===null&&n)&&(this.emit("updated",{plainText:e}),this.triggerCaretPosition(),this.currentHTML=o))}triggerSelection(){let e=this.getSelection();(e.start!==this.currentSelection.start||e.end!==this.currentSelection.end)&&(this.currentSelection=e,this.emit("selection",e),this.triggerCaretPosition())}triggerCaretPosition(){let e=this.getCaretPosition();Ae(e,this.currentCaret)||(this.currentCaret=e,this.emit("caret",e))}handleKeyUp(e){let{key:o,shiftKey:n}=e;(o==="Enter"&&n===!0||o==="Backspace")&&this.triggerChange(),this.triggerSelection()}handleClick(){this.triggerSelection()}handleFocus(){this.isFocused||this.emit("focus"),this.triggerSelection(),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(e){let{key:o,ctrlKey:n,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(ga).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=pn(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 og=/[.*+?^${}()|[\]\\]/g,ng=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function sg(t){return t.replace(og,"\\$&")}function rg(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function ig(t){return t.search(ng)}function ma(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${sg(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function fa(t){return t.replace(gt,'<mark data-type="placeholder">$1</mark>')}function Qt(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ag(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 Bs(t,e,o={}){if(e){let n=rg(e.toLowerCase(),t.toLowerCase()),s=Qt(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=ig(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(gi).length>3||e.length>30?ag(e.trim(),n):0;return`${`${i>0?"\u2026":""}${Qt(t.substring(i,n))}`}<strong>${s}</strong>`}return t}function Fs(t){return/<\/?[a-z][\s\S]*>/i.test(t)}function un(t){if(Fs(t)){let o=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(t);return o?o[1]:""}return t}import{jsx as le,jsxs as Ks}from"react/jsx-runtime";var pg=({value:t,onUse:e,...o})=>{var u;let n=E(Hs),s=cg(),r=Fs(t),i=y("EditSuggestionTextInput",Ls),[a,l]=lg(null),c=Us(null),p=((u=t.match(gt))==null?void 0:u.length)||0;return Zt(()=>{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(Ho(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]),Zt(()=>{t&&c.current&&(c.current.value=t)},[t,c]),Zt(()=>{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(ha,{className:i.textInput,tagName:"div",content:t})}):Ks("div",{className:i.textInputWrapper,children:[le("textarea",{...o,ref:c,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:t,onChange:()=>{}}),a&&le(ug,{inputElement:c.current,value:t}),Ks("div",{className:ya(i.alert,p===0?i.success:i.warning),children:[le("div",{className:i.alertText,children:n("placeholders",{placeholderSize:p})}),p===0?le(pa,{}):le(da,{})]})]})},ug=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",Ls),n=Us(null),s=rn(t);return Zt(()=>{an(t,s)},[s,t]),le(dg,{inputElement:t,children:Ks("div",{ref:n,className:ya(o.root,o.agentText),children:[le(ha,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new vt("placeholders")],inputElement:t,boundaryRef:n}),le("br",{})]})})},dg=({inputElement:t,children:e})=>{let o=Us(null);return Zt(()=>{if(!o.current)return()=>{};let[n,s]=xt(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),le("div",{ref:o,children:e})},va=pg;import{useEffect as tm,useState as om,useRef as nm}from"react";import{useState as fg}from"react";import zs 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 $e={};j($e,{enUS:()=>gg,nlNL:()=>mg});var gg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},mg={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};import{jsx as Jt,jsxs as yg}from"react/jsx-runtime";var hg=({src:t,title:e})=>{let o=y("CommandPalette",Z),[n,s]=fg("loading"),r=E($e);return yg("div",{className:o.image,children:[Jt("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:zs(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&Jt("span",{className:zs(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&Jt("span",{className:zs(o.imageSrc,o.imageSrcStatus),children:Jt(To,{})}),e&&Jt("span",{className:o.imageTitle,children:e})]})},Sa=hg;import vg from"react";import Sg from"classnames";import{jsx as _a,jsxs as _g}from"react/jsx-runtime";function js({children:t,heading:e,orientation:o}){let n=y("CommandPalette",Z);return vg.Children.count(t)===0?null:_g("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&_a("h4",{className:n.listHeading,children:e}),_a("div",{className:Sg(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}import mn from"classnames";import qs from"react";import{jsx as xg}from"react/jsx-runtime";var xa=qs.createContext(void 0);function De(){let t=qs.useContext(xa);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var ba=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=qs.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return xg(xa.Provider,{value:i,children:t})};import bg,{useState as Ca,useEffect as wa,useMemo as Cg,useRef as Ta,useCallback as wg,useContext as Tg}from"react";import Eg from"classnames";var Vs={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 dn,jsxs as Pg}from"react/jsx-runtime";var kg=0,Ea=bg.createContext(null),Rg=()=>{let t=Tg(Ea);if(!t)throw new Error("Invalid DropdownContext");return t},ka=({trigger:t,children:e,position:o="bottom"})=>{let n=Cg(()=>++kg,[]),s=Ta(null),r=Ta(null),i=y("Dropdown",Vs),[a,l]=Ca(!1),[c,p]=Ca(o),u=g=>{g.preventDefault(),g.stopPropagation(),l(!a)},d=wg(([g])=>{!g.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return wa(()=>{let g=f=>{s.current&&!s.current.contains(f.target)&&l(!1)};return document.addEventListener("click",g),()=>{document.removeEventListener("click",g)}},[]),wa(()=>{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]),dn(Ea.Provider,{value:{setIsOpen:l},children:Pg("div",{ref:s,className:i.root,children:[dn("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}),dn("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:Eg(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function Ig({as:t,children:e,onClick:o,...n}){let s=t||"button",r=y("Dropdown",Vs),{setIsOpen:i}=Rg(),a=l=>{i(!1),o(l),l.stopPropagation()};return dn(s,{type:"button",className:r.item,onClick:a,...n,children:e})}ka.Item=Ig;var Ws=ka;import{jsx as Ra}from"react/jsx-runtime";var Ia=t=>Ra("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:Ra("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 Xe={};j(Xe,{enUS:()=>Ag,nlNL:()=>Lg});var Ag={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"}]},Lg={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 Gs}from"react/jsx-runtime";var Mg="%0d%0a%0d%0a%0d%0a",Ng=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(Mg)}`},Og=({suggestion:t,onFeedback:e})=>{let o=E(Xe),n=C("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:Gs(Ws,{trigger:Gs(Ia,{"data-testid":"feedback-dropdown-trigger"}),children:Gs(Ws.Item,{as:"a",href:Ng(n,t),onClick:e,children:o("giveFeedback")})})},gn=Og;import{Interweave as Dg}from"interweave";import{jsx as He,jsxs as $s}from"react/jsx-runtime";function Xs({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 $s("div",{className:mn(f.listItem,u===i&&f.listItemSelected),children:[He("button",{onMouseEnter:()=>d(i),type:"button",className:mn("command-palette-list-item",f.listItemAction,f.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:m,...p,children:$s("div",{className:f.listItemContent,children:[typeof o=="string"?He("p",{className:mn(f.listItemText,f.truncate,c==null?void 0:c.title),children:o}):o,a&&He(Dg,{tagName:"p",allowList:[],content:un(a),className:mn(f.listItemDescription,c==null?void 0:c.description,e?f.lineClamp:f.truncate)})]})}),s&&u===i&&He("div",{className:f.listItemActions,children:He(gn,{suggestion:String(o),onFeedback:s})}),l&&$s("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 Pa,jsxs as Qs}from"react/jsx-runtime";function Zs({children:t,title:e,id:o,onDismiss:n}){let s=E($e),r=y("CommandPalette",Z),{page:i}=De();return i!==o?null:Qs("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&Qs("div",{className:r.pageNav,children:[Qs("button",{className:r.pageBackButton,type:"button",onClick:n,children:[Pa(on,{}),s("back")]}),e&&Pa("h3",{className:r.pageTitle,children:e})]}),t]})}import{Fragment as Gg,useCallback as $g,useEffect as Xg,useRef as Qg}from"react";var fn=()=>/Mac/i.test(navigator.platform);import{createAsyncThunk as Ug,createSlice as zg}from"@reduxjs/toolkit";var Hg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},T=Hg;import{createAsyncThunk as Ys,createSlice as Fg}from"@reduxjs/toolkit";function Bg(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,[Bg(o)]:A(t[o])}),{}):t}function Js(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,[Js(o)]:F(t[o])}),{}):t}var Kg={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},eo=t=>{var e,o,n;return{timezone:((e=t.info.visitorInfo)==null?void 0:e.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((o=t.info.agentInfo)==null?void 0:o.agentNickname)||"",visitorName:((n=t.info.visitorInfo)==null?void 0:n.visitorName)||""}},Yt=Ys("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))}),er=Ys("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}),tr=Ys("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),Aa=t=>t.info.agentInfo,La=Fg({name:"info",initialState:Kg,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Yt.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Yt.rejected,e=>{e.fetchState="error"}).addCase(Yt.fulfilled,(e,o)=>{e.fetchState="done",e.agentInfo={...e.agentInfo,...o.meta.arg,agentId:o.payload.externalId||o.meta.arg.agentId||"",agentNickname:o.payload.nickname||o.meta.arg.agentNickname||""}}).addCase(er.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(tr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(P,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Ma}=La.actions,Na=La.reducer;var hn={list:[],fetchState:"idle",isOpen:!1,page:"search"},Oa=t=>t.search.isOpen,Da=t=>t.search.page,Ha=t=>t.search.list;function Ba(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Qe=Ug("search/getAll",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r}=await o.search({profile:s,query:t.query,filters:{type:t.type},params:eo(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),Fa=zg({name:"search",initialState:hn,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=hn.fetchState,t.list=hn.list}},extraReducers:t=>{t.addCase(Qe.pending,e=>{e.fetchState="loading"}).addCase(Qe.rejected,(e,o)=>{e.fetchState="error",T.error(o.error)}).addCase(Qe.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(P,()=>hn)}}),{resetSearch:yn,setIsOpen:G,setPage:$}=Fa.actions,Ka=Fa.reducer;var jg=/(https?:\/\/[^\s]+)/,vn=t=>t.split(" ").find(e=>jg.test(e));import Ua from"classnames";import{jsx as Vg,jsxs as Wg}from"react/jsx-runtime";var qg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",Z);return Wg("button",{type:"button",...n,onClick:t,className:Ua(s.actionButton,n.className),children:[o,e&&e.map(r=>Vg("span",{className:Ua(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},bt=qg;import{jsx as Sn,jsxs as or}from"react/jsx-runtime";var Zg=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",Z),a=E($e),{selected:l,setSelected:c}=De(),p=r[l],u=p&&typeof p.text=="string"&&vn(p.text),d=Qg(null);function g(x){if(!d.current)return;let b=d.current.querySelectorAll(".command-palette-list-item"),_=0,R=0;x==="down"?(b.forEach((X,I)=>{I===l&&(_=I)}),R=_===b.length-1?0:_+1):x==="up"?(b.forEach((X,I)=>{I===l&&(_=I)}),R=_?_-1:b.length-1):c(0);let O=b[R];O&&typeof R=="number"&&(c(R),O.scrollIntoView&&O.scrollIntoView({behavior:"smooth",block:R?"center":"end"}))}function f(){if(!d.current)return;let x=d.current.querySelectorAll(".command-palette-list-item"),b=0;x.forEach((R,O)=>{O===l&&(b=O)});let _=x[b];_&&_.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=$g(x=>{if(x.key==="Enter"&&x.altKey&&u){m();return}if(x.key==="Enter"&&x.shiftKey){w();return}if(x.key==="ArrowDown"){x.preventDefault(),x.stopPropagation(),g("down");return}if(x.key==="ArrowUp"){x.preventDefault(),x.stopPropagation(),g("up");return}x.key==="Enter"&&l!==-1&&(x.preventDefault(),x.stopPropagation(),f())},[l]);return Xg(()=>(window.addEventListener("keyup",h),()=>{window.removeEventListener("keyup",h)}),[h]),or("div",{className:i.actions,children:[Sn("div",{className:i.actionsWrapper,ref:d,children:t}),or("div",{className:i.actionsBar,children:[u&&Sn(bt,{onClick:m,shortKeys:[fn()?8997:"ALT",8629],children:a("visitUrl")}),p&&or(Gg,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&Sn(bt,{onClick:w,shortKeys:[8679,8629],children:o}),Sn(bt,{onClick:v,shortKeys:[8629],children:e})]})]})]})},ja=Zg;import{forwardRef as Yg}from"react";import{jsx as qa,jsxs as Jg}from"react/jsx-runtime";var Ct=()=>Jg("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[qa("path",{d:"M0 0h24v24H0z",fill:"none"}),qa("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});import{jsx as wt,jsxs as nr}from"react/jsx-runtime";function em({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",Z);return nr("div",{className:l.search,children:[wt("div",{className:l.searchIcon,children:wt(Ct,{})}),nr("div",{className:l.searchInputWrapper,children:[wt("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:c=>{t(c.currentTarget.value)},onFocus:c=>{c.currentTarget.select()},className:l.searchInput,placeholder:o,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&wt("div",{className:l.selectWrapper,children:nr("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:c=>e(c.target.value===n?void 0:c.target.value),value:i||n,children:[n&&wt("option",{children:n}),s.map(c=>wt("option",{value:c.value,children:c.label},c.value))]})})]})]})}var Va=Yg(em);import{jsx as Wa,jsxs as sm}from"react/jsx-runtime";function Ze({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]=om(0),m=nm(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 tm(()=>{f(0)},[d,n]),Wa(yt,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:w,onClose:v,children:sm(ba,{selected:g,setSelected:f,isOpen:u,onChangeOpen:a,page:n,children:[n===o&&Wa(Va,{ref:m,onChange:r,onChangeType:i,placeholder:t,value:d,selectedType:l,types:c,typePlaceholder:e}),p]})})}Ze.Page=Zs;Ze.List=js;Ze.Image=Sa;Ze.ListItem=Xs;Ze.ActionsBar=ja;Ze.Button=bt;var L=Ze;import{jsx as _e,jsxs as to}from"react/jsx-runtime";var am=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",Fi),l=rm(),c=E(Cs),p=im(f=>f.overlayInput.text);Ga(()=>{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(Ko(f)),e(f)},g=f=>m=>{p!==i?window.confirm(c("warning"))&&f(m):f(m)};return Ga(()=>{n&&n(p!==i)},[n,t,p]),to("div",{className:a.root,children:[to("div",{className:a.content,children:[t.title&&_e("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&_e(fs,{labels:t.searchKeywords}),_e(va,{onUse:d,value:un(p)})]}),to("form",{className:a.actions,onSubmit:u,children:[to("div",{children:[_e("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&g(r),children:_e(on,{})}),_e("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&g(s),children:_e(Zi,{})})]}),to("div",{className:a.primaryButtons,children:[_e(L.Button,{onClick:g(o),shortKeys:["esc"],children:c("dismiss")}),_e(L.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},_n=am;import{createAction as pm,createAsyncThunk as Za,createSlice as um}from"@reduxjs/toolkit";var lm=["{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}"],cm=new RegExp(lm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function $a(t,e){let o=t.split(cm),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 Xa(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Ja={suggestions:[],fetchState:"idle",isInitialRequest:null},Qa={default:Ja},Ya=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)||[]},el=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},tl=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")},Tt=t=>t.textSuggestions,ol=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},xn=pm("textSuggestions/refresh"),xe=Za("textSuggestions/recommendations",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,inlineSuggestions:i}=n.settings,a=ht(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,eo(n),t);if(t==="default"){let p=i?l.filter(ol(a)):l;e.dispatch(ue(p.slice(0,r)))}return l}),oo=Za("textSuggestions/autocompletions",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,deanonymize:i,inlineSuggestions:a}=n.settings;if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getAutocompleteSuggestions(s,{...eo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(ol(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?$a(p.text,t):p.text}))),l=Xa(l,r),e.dispatch(ue(l)),l}),nl=um({name:"textSuggestions",initialState:Qa,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(xe.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||Ja;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(xe.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(xe.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(oo.pending,e=>{e.default.fetchState="loading"}).addCase(oo.rejected,e=>{e.default.fetchState="error"}).addCase(oo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(P,()=>Qa)}}),{setTextSuggestions:sl,setSuggestionState:rl}=nl.actions,il=nl.reducer;import{createSlice as dm}from"@reduxjs/toolkit";var al={contentType:null,suggestion:null},ll=t=>t.activeSuggestion.suggestion,cl=t=>t.activeSuggestion.contentType,pl=dm({name:"activeSuggestion",initialState:al,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(P,()=>al)}}),{setActiveSuggestion:be,resetActiveSuggestion:sr}=pl.actions,ul=pl.reducer;var rr={};j(rr,{enUS:()=>gm,nlNL:()=>mm});var gm={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"}]},mm={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 fm}from"@reduxjs/toolkit";var hm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var bn=({ui:t})=>t.overlayCollapsed;var dl=fm({name:"ui",initialState:hm,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputHasFocus(t,e){t.overlayCollapsedUserOverwrite!==!0&&(e.payload===!0&&(t.overlayCollapsed=!1),t.inputHasFocus=e.payload)},setOverlayCollapsed(t,e){e.payload.collapse===!1&&(t.openOverlayWhenTyping=!1),!(e.payload.skipWhenInputFocus&&t.inputHasFocus)&&(t.overlayCollapsed=e.payload.collapse)},setOpenOverlayWhenTyping(t,e){t.openOverlayWhenTyping=e.payload},setOverlayCollapsedUserOverwrite(t,e){t.overlayCollapsedUserOverwrite=e.payload,t.overlayCollapsed=e.payload}}}),{setShowTabHint:no,setInputHasFocus:Et,setOverlayCollapsed:Be,setOpenOverlayWhenTyping:gl,setOverlayCollapsedUserOverwrite:ml}=dl.actions,fl=dl.reducer;import hl,{useContext as ym}from"react";import{jsx as vm}from"react/jsx-runtime";var yl=hl.createContext(null),Je=({broadcastEvents:t,children:e})=>{let o=hl.useMemo(()=>t,[]);return vm(yl.Provider,{value:o,children:e})},se=()=>{let t=ym(yl);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import{createAsyncThunk as ir,createSlice as Sm}from"@reduxjs/toolkit";var _m={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},oe=t=>t.auth.isLoggedIn,vl=t=>t.auth.loginFetchState,Sl=t=>t.auth.verifyFetchState,_l=t=>t.auth.showLoginOverlay,Ce=ir("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),xl=ir("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),so=ir("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),bl=Sm({name:"auth",initialState:_m,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(Ce.pending,e=>{e.loginFetchState="loading"}),t.addCase(Ce.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(Ce.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(so.pending,e=>{e.verifyFetchState="loading"}),t.addCase(so.rejected,e=>{e.verifyFetchState="error"}),t.addCase(so.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:kt,setShowLoginOverlay:Cl}=bl.actions,wl=bl.reducer;var ar="SetActiveSuggestion",Rt="ShowLoginOverlay",ro="UserLoggedIn",xm="UserLoggedOut",we="ApplySuggestion",lr="ApplyImageSuggestion",bm="ShowCommandPalette",Cm=t=>({[ar]:e=>{t.dispatch(rl(e.state)),t.dispatch(be({contentType:e.contentType,suggestion:e.suggestion}))},[bm]:e=>{t.dispatch(G(e.isOpen)),e.page&&t.dispatch($(e.page))},[Rt]:e=>{t.dispatch(Cl(e))},[ro]:()=>{t.dispatch(Ce())},[xm]:()=>{t.dispatch(Ce())},[lr]:e=>{t.dispatch(zo({suggestion:e.suggestion}))},[we]:e=>{t.dispatch(ie({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(ve())}}),Tl=Cm;import{jsx as El}from"react/jsx-runtime";var Em=()=>{var f;let[t,e]=wm(!1),o=cr(ll),n=cr(cl),s=cr(Tt),r=Tm(),i=se(),a=E(rr),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(sr()),r(Et(!0)),r(Q.actions.reset())},p=(m,v)=>{r(sr()),r(Et(!0)),i.send(we,{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(be({contentType:n,suggestion:s[n].suggestions[u-1]})),g=u===s[n].suggestions.length-1||u===null?void 0:()=>r(be({contentType:n,suggestion:s[n].suggestions[u+1]}));return El(yt,{autoFocus:!0,isOpen:u!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:El(_n,{onTouched:e,onDismiss:c,onUse:m=>p(m,o),suggestion:o,onNext:g,onPrevious:d})})},kl=Em;import{useSelector as Ll}from"react-redux";import ur from"classnames";import{useCallback as Pl,useEffect as Lm,useMemo as Mm,useState as dr}from"react";import{useDispatch as Nm,useSelector as Om}from"react-redux";import km from"classnames";var Rl={root:"_root_1ukx5_1"};import{jsx as Im}from"react/jsx-runtime";var Rm=({className:t,value:e,...o})=>{let n=y("TextInput",Rl);return Im("input",{className:km(t,n.root),type:"text",value:e,...o})},io=Rm;var pr={};j(pr,{enUS:()=>Pm,nlNL:()=>Am});var Pm={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"}]},Am={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 Il={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 Cn}from"react/jsx-runtime";var Dm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Hm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=E(pr),i=y("LoginTokenDialog",Il),a=Om(Sl),l=Nm(),c=C("productName"),[p,u]=dr(t||""),[d,g]=dr(0),[f,m]=dr(""),v=Pl(async b=>{b.preventDefault(),l(xl({email:p})),g(1)},[o,p]),w=()=>{m(""),g(0)},h=Pl(async b=>{b.preventDefault();let _=Dm(b.target.elements.token.value);if(!_){m(r("verifyCodeError",{login:x}));return}l(so({token:_}))},[o]),x=Mm(()=>b=>J("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:b},"back-button"),[]);return Lm(()=>{a==="error"&&m(r("verifyCodeError",{login:x})),a==="done"&&n()},[a]),J(yt,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:Cn("div",{className:i.root,children:[J("h1",{className:i.title,children:r("promptTitle",{productName:c})}),d===0&&Cn("form",{onSubmit:v,children:[J("h2",{className:i.subtitle,children:r("requestCodeTitle")}),J("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),J(io,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:b=>u(b.target.value)}),J("div",{className:i.actions,children:J("button",{type:"submit",className:ur(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),d===1&&Cn("form",{onSubmit:h,children:[J("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),J("p",{className:i.text,children:r("verifyCodeBody")}),J(io,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&J("div",{className:i.errorMessage,children:f}),Cn("div",{className:i.actions,children:[J("button",{type:"button",className:ur(i.button),onClick:w,children:r("back")}),J("button",{type:"submit",className:ur(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},Al=Hm;import{jsx as Fm}from"react/jsx-runtime";var Bm=()=>{let t=Ll(_l),e=Ll(Aa),o=C("adminUrl"),n=se(),s=()=>n.send(Rt,!1),r=()=>{n.send(Rt,!1),n.send(ro)};return Fm(Al,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},Ml=Bm;import Af from"lodash.debounce";import{useCallback as Rn,useEffect as _r,useState as po}from"react";import{useDispatch as Lf,useSelector as Mt}from"react-redux";import{createAsyncThunk as Km,createSlice as Um}from"@reduxjs/toolkit";var zm={data:null,fetchState:"idle"},Nl=t=>t.contentTypes.data,ao=Km("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),jm=Um({name:"contentTypes",initialState:zm,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})}}),Ol=jm.reducer;function lo(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}import{useEffect as qm}from"react";function Dl(t,e){qm(()=>{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 Kl,useRef as Zm}from"react";import{useSelector as Jm,useDispatch as Ym}from"react-redux";import{createAsyncThunk as Vm,createSlice as Wm}from"@reduxjs/toolkit";var Hl={data:null,fetchState:"idle"},wn=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=Vm("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)}),Gm=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),$m=Wm({name:"entities",initialState:Hl,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=Gm(e.data?[...e.data,...o.payload]:o.payload)}).addCase(P,()=>Hl)}}),Bl=$m.reducer;var gr={};j(gr,{enUS:()=>Xm,nlNL:()=>Qm});var Xm={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Qm={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Fl={root:"_root_17kae_1",empty:"_empty_17kae_5"};import{jsx as Tn,jsxs as tf}from"react/jsx-runtime";var ef=({onCopy:t,onUse:e})=>{let o=Zm(null),n=y("EntitiesList",Fl),s=E(gr),r=Jm(wn),i=Ym();return Kl(()=>{i(ce())},[]),Kl(()=>{o.current&&o.current.focus()},[o]),tf("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&Tn(L.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:Tn(L.List,{children:r.map((a,l)=>Tn(L.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&Tn("p",{className:n.empty,children:s("noResults")})]})},Ul=ef;import{Fragment as lf,useEffect as En,useRef as cf,useState as pf}from"react";import{useSelector as Gl,useDispatch as uf}from"react-redux";import{createAsyncThunk as of,createSlice as nf}from"@reduxjs/toolkit";var zl={data:null,fetchState:"idle"},jl=t=>t.summary.data,ql=t=>t.summary.fetchState==="error",Te=of("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"))}),sf=nf({name:"summary",initialState:zl,reducers:{},extraReducers:t=>{t.addCase(Te.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(Te.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(Te.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(P,()=>zl)}}),Vl=sf.reducer;var mr={};j(mr,{enUS:()=>rf,nlNL:()=>af});var rf={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."}]},af={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 Wl={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};import{jsx as It,jsxs as gf}from"react/jsx-runtime";var df=({onCopy:t})=>{let e=cf(null),o=y("SummaryForm",Wl),[n,s]=pf(""),r=E(mr),i=Gl(jl),a=Gl(ql),l=uf(),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 En(()=>{l(Te())},[]),En(()=>{s(i||"")},[i]),En(()=>{e.current&&i&&e.current.focus()},[e,i]),En(()=>{let u=d=>{d.key==="Enter"&&d.shiftKey&&c()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[n]),It("div",{className:o.root,tabIndex:-1,children:a?It("p",{className:o.error,children:r("error")}):gf(lf,{children:[It("div",{className:o.main,children:It("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:u=>s(u.target.value)})}),It("div",{className:o.actions,children:It(L.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},$l=df;var fr={};j(fr,{enUS:()=>mf,nlNL:()=>ff});var mf={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?"}]},ff={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 Cf,{useEffect as vr,useRef as wf}from"react";import{useDispatch as Tf,useSelector as tc}from"react-redux";var hr={};j(hr,{enUS:()=>hf,nlNL:()=>yf});var hf={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"}]},yf={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 Xl={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 vf,createAsyncThunk as Sf,createSlice as _f}from"@reduxjs/toolkit";var yr={data:[],fetchState:"idle"},Ql=t=>{var e;return(e=t.answer)==null?void 0:e.data},Zl=t=>t.answer.fetchState,At=vf("answer/resetKnowledgeSearch"),Pt=Sf("answer/getAnswer",async(t,e)=>{var i,a;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=(a=(i=e.getState().profile)==null?void 0:i.data)==null?void 0:a.knowledgeAssistant;if(!s)throw new Error("KnowledgeAssistant is not defined");let r=await o.knowledgeAssist({promptInstruction:t.promptInstruction,question:t.question},n,s);return{question:t.question,answer:r}}),xf=_f({name:"answer",initialState:yr,reducers:{},extraReducers:t=>{t.addCase(Pt.pending,e=>{e.fetchState="loading"}).addCase(Pt.rejected,e=>{e.fetchState="error"}).addCase(Pt.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(P,()=>yr).addCase(At,()=>yr)}}),Jl=xf.reducer;import{jsx as Yl,jsxs as bf}from"react/jsx-runtime";var ec=()=>bf("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[Yl("title",{id:"paperPlaneTitle",children:"PaperPlane"}),Yl("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 Ee,jsxs as Sr}from"react/jsx-runtime";var Ef=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=Cf.useState(""),{setSelected:i}=De(),a=wf(null),l=y("EntitiesList",Xl),c=E(hr),p=Tf(),u=tc(Ql),d=tc(Zl),g=async m=>{m.preventDefault(),m.stopPropagation(),s!==""&&p(Pt({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 vr(()=>{var m;o&&d==="idle"?p(Pt({question:o,promptInstruction:n})):(m=a.current)==null||m.focus()},[a,d]),vr(()=>{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]),vr(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,u]),Sr("div",{className:l.root,children:[u.length>0&&Ee("div",{className:l.alignRight,children:Ee(L.Button,{onClick:e,children:c("reset")})}),Sr(L.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)=>Ee(L.List,{children:Ee(L.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"&&Ee("p",{className:l.status,children:c("loading")}),d==="error"&&Ee("p",{className:l.status,children:c("error")}),Sr("form",{className:l.form,onSubmit:g,children:[Ee("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:m=>{i(-1),r(m.target.value)}}),Ee("button",{type:"submit",className:l.submit,children:Ee(ec,{})})]})]})]})},oc=Ef;import{createAsyncThunk as kf,createSlice as Rf}from"@reduxjs/toolkit";var If={data:null,fetchState:"idle"},Lt=t=>t.profile.data,kn=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],co=kf("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)}),Pf=Rf({name:"profile",initialState:If,reducers:{},extraReducers:t=>{t.addCase(co.pending,e=>{e.fetchState="loading"}).addCase(co.rejected,e=>{e.fetchState="error"}).addCase(co.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),nc=Pf.reducer;import{jsx as Y,jsxs as rc}from"react/jsx-runtime";var Mf=200,Nf=5,Of=4,Df=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),sc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Hf=()=>{let t=Lf(),e=se(),o=E(fr),[n,s]=po(!1),[r,i]=po(""),a=Mt(Da),l=Mt(Lt),[c,p]=po(null),[u,d]=po([]),[g,f]=po(),m=Mt(oe),v=C("showSearch"),w=C("showEntitiesCommand"),h=C("showSummaryCommand"),x=C("showKnowledgeSearch"),b=C("showImageSearch"),_=C("searchTriggerKey"),R=Mt(Nl),O=Mt(Ha),X=Mt(Oa),I=S=>is(O.filter(M=>M.type===S.toUpperCase()),S),W=[{value:"PERSONAL",label:o("personalSuggestions"),list:I("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:I("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:I("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:I("IMAGE"),listOrientation:"horizontal",shouldShow:b}].filter(S=>S.shouldShow),k=[{label:o("entitiesClipboard"),onClick:()=>t($("entities")),shouldShow:w&&sc(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t($("summary")),shouldShow:h&&sc(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t($("knowledgeAssist")),shouldShow:x}].filter(S=>S.shouldShow),H=(R==null?void 0:R.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:I(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],rt=Rn(Af((S,M)=>{t(Qe({query:S,type:M,tags:["search-overlay"]}))},Mf),[]),it=Df([...H,...W]),bo=Rn((S,M)=>{if(!M)return;let Pe=[...W,...H].find(({value:lt})=>lt===M);Pe&&(t($("edit")),p({...S,searchTerm:void 0}),d(Pe.list))},[t,c,H]),rs=Rn((S,M)=>{switch(M.type){case"IMAGE":e.send(lr,{suggestion:M});break;default:e.send(we,{text:S,suggestion:M})}t(G(!1))},[t]),uu=S=>{lo(S.text),t(q({name:"entity copied",data:{entity:S,type:"copy"}})),t(G(!1))},du=Rn(S=>{t(q({name:"suggestion feedback",data:{text:S.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),gu=S=>{e.send(we,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(q({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t($("search")),t(At()),t(G(!1))},mu=S=>{lo(S),t(G(!1))},fu=S=>{e.send(we,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(G(!1))},hu=c===null||u.indexOf(c)-1<0?void 0:()=>p(u[u.indexOf(c)-1]),yu=c===null||u.indexOf(c)===u.length-1?void 0:()=>p(u[u.indexOf(c)+1]);function is(S,M){return S.slice(0,g?10:M.toLowerCase()==="image"?Of:Nf)}function ri(S,M,Pe){return M.reduce((lt,Co)=>Pe&&g===Pe?Co.length+lt:is(Co,Pe).length+lt,S)}function at(S){return M=>{n?window.confirm(o("warning"))&&(S(M),s(!1)):S(M)}}return _r(()=>{r?rt(r,g):t(yn())},[r,g]),_r(()=>{a==="search"&&t(At())},[a]),_r(()=>{m&&t(ao())},[m]),Dl(_,()=>t(G(!0))),!v||!l?null:rc(L,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:at(S=>t(G(S))),onChangeType:S=>f(S),onChangePage:at(S=>t($(S))),selectedType:g,search:r,page:a,isOpen:X,types:[...H,...W],children:[Y(L.Page,{id:"search",children:rc(L.ActionsBar,{list:[...k.map(S=>({text:S.label,type:"command"})),...it.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},M)=>rs(S,it[M]),onSecondary:(S,M)=>{bo(it[M-k.length],it[M-k.length].type)},children:[k.length>0&&Y(L.List,{heading:o("commands"),children:k.map((S,M)=>Y(L.ListItem,{index:ri(M,[],"commands"),closeOnSelect:!1,onClick:S.onClick,children:S.label},S.label))}),[...H,...W].map(({value:S,label:M,list:Pe,lineClamp:lt,listOrientation:Co},vu)=>Y(L.List,{heading:M,orientation:Co==="horizontal"?"horizontal":"vertical",children:is(Pe,S).map((ne,Su)=>Y(L.ListItem,{index:ri(k.length+Su,[...H,...W].slice(0,vu).map(({list:_u})=>_u),S),closeOnSelect:!1,lineClamp:lt,onClick:()=>rs(ne.text,ne),description:S!=="IMAGE"?ne.title&&ne.text:void 0,onFeedback:S!=="IMAGE"?()=>du(ne):void 0,children:S==="IMAGE"?Y(L.Image,{title:ne.title||ne.text,src:ne.image}):ne.title||ne.text},`${ne.id}-${ne.text}`))},S))]})}),Y(L.Page,{id:"edit",onDismiss:at(()=>{t($("search")),p(null)}),children:c&&Y(_n,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t($("search")),p(null),d([])},onNext:yu,onPrevious:hu,onUse:S=>{t($("search")),rs(S,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(G(!1)),d([]),p(null)}})}),Y(L.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:at(()=>{t($("search"))}),children:Y(Ul,{onUse:fu,onCopy:uu})}),Y(L.Page,{id:"summary",title:o("summaryTitle"),onDismiss:at(()=>{t($("search"))}),children:Y($l,{onCopy:mu})}),Y(L.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:at(()=>{t(At()),t($("search"))}),children:Y(oc,{promptInstruction:l.knowledgeAssistPromptInstruction,question:r,onUse:gu,onResetQuestion:()=>{t(At()),i("")}})})]})},ic=Hf;import{jsx as xr,jsxs as Kf}from"react/jsx-runtime";var Ff=()=>{let t=C("showSearch"),e=C("isEmbedded");return Kf(Bf,{children:[t&&xr(ic,{}),xr(kl,{}),e&&xr(Ml,{})]})},ac=Ff;import{useEffect as nh,useRef as sh}from"react";import{connect as rh,useDispatch as ih,useSelector as An}from"react-redux";function Nt(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 eh,useMemo as th}from"react";import{Interweave as jf}from"interweave";import{useEffect as qf,useMemo as Vf,useRef as Wf}from"react";import{useDispatch as Gf,useSelector as $f}from"react-redux";import{useEffect as Uf}from"react";function lc(t,e,o){Uf(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var cc={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};import{jsx as In,jsxs as Yf}from"react/jsx-runtime";var Xf=["search","personal-collection-search","search-autocomplete"];function Qf(t,e,o,n={}){let s="";return Xf.includes(e)?s=ma(Bs(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=Bs(t,o,n),n.placeholders===!0&&(s=fa(s)),s}var Zf=()=>{},Jf=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=C("inlineSuggestions"),r=$f(ht),i=Gf(),a=y("TextSuggestion",cc),l=Wf(null);qf(()=>{let p=setTimeout(()=>{i(ki({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),lc(l,"click",()=>{i(Me(t)),i(ie({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=Vf(()=>Qf(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:Yf("div",{className:a.root,onMouseEnter:()=>i(Me(t)),children:[In(D,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:Zf,children:In(jf,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&In("div",{className:a.actions,children:In(gn,{onFeedback:()=>n(o),suggestion:o.text})})]})},pc=Jf;import{jsx as uc}from"react/jsx-runtime";var oh=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=th(()=>{let r=e.map((i,a)=>uc(pc,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return uc(eh,{children:s})},Pn=oh;var dc={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};import{jsx as Ln}from"react/jsx-runtime";var ah=({textSuggestions:t,selectedIndex:e})=>{let o=sh(null),n=y("InlineSuggestionsOverlay",dc),s=An(Nt),r=ih(),i=An(oe),a=An(ft),l=An(bn),c=C("showTextSuggestions");return St(()=>{r(Be({collapse:!0,skipWhenInputFocus:!0}))}),nh(()=>{let p=o.current;if(!p||!p.parentElement)return;p.parentElement.style.left="0px";let u=p.getBoundingClientRect();p.parentElement.style.left=`${Math.min(window.innerWidth-4-u.right,0)}px`}),l||!s||!c||t.length===0||i!==!0||a===!1?null:Ln("div",{className:n.root,"data-variant":"inline",children:Ln("div",{ref:o,className:n.paper,children:Ln(re,{children:Ln(Pn,{suggestions:t,selectedIndex:e})})})})},lh=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),gc=rh(lh)(ah);import Er from"classnames";import{useEffect as _h,useRef as xh,useState as bh}from"react";import{connect as Ch,useDispatch as wh,useSelector as uo}from"react-redux";import{useState as ch}from"react";function mc(t,e){let[o,n]=ch(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return T.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){T.error(i)}}]}import dh from"classnames";import{Fragment as gh,useCallback as Cr,useMemo as hc}from"react";var br={};j(br,{enUS:()=>ph,nlNL:()=>uh});var ph={loginPlease:[{type:8,value:"login",children:[{type:0,value:"Sign in"}]},{type:0,value:" to enable "},{type:1,value:"productName"},{type:0,value:"."}],snooze:[{type:0,value:"Snooze for "},{type:8,value:"min",children:[{type:0,value:"10 minutes"}]},{type:0,value:", "},{type:8,value:"hour",children:[{type:0,value:"1 hour"}]},{type:0,value:" or "},{type:8,value:"day",children:[{type:0,value:"1 day"}]}]},uh={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 fc={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};import{jsx as Mn,jsxs as yc}from"react/jsx-runtime";var wr=(t,e,o)=>n=>Mn("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),mh=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=E(br),i=se(),a=y("Login",fc),l=C("productName"),c=Cr(v=>{v.preventDefault(),n&&n(parseInt(v.target.value,10))},[]),p=Cr(v=>{v.preventDefault(),i.send(Rt,!0)},[e]),u=hc(()=>v=>Mn("a",{onClick:h=>{h.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:v},"login"),[e]),d=Cr(v=>Mn("button",{type:"button",className:a.anchorButton,onClick:p,children:v},"prompt"),[p]),{min:g,hour:f,day:m}=hc(()=>({min:wr(a,60*10,c),hour:wr(a,60*60,c),day:wr(a,60*60*12,c)}),[]);return yc("div",{className:dh(t,a.root),children:[r("loginPlease",{login:o?d:u,productName:l}),n&&yc(gh,{children:[Mn("br",{}),r("snooze",{min:g,hour:f,day:m})]})]})},Nn=mh;import{useDispatch as fh}from"react-redux";var vc={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};import{jsx as Sc,jsxs as yh}from"react/jsx-runtime";var hh=({title:t})=>{let e=y("SearchTrigger",vc),o=fh();return yh("button",{type:"button",className:e.root,onClick:()=>o(G(!0)),children:[Sc(Ct,{}),Sc("span",{className:e.text,children:t})]})},_c=hh;var Tr={};j(Tr,{enUS:()=>vh,nlNL:()=>Sh});var vh={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"}]},Sh={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 xc={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 go}from"react/jsx-runtime";var Th=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=y("SuggestionsOverlay",xc),s=E(Tr),r=uo(Nt),i=bi(),a=wh(),l=xh(null),c=C("searchTriggerKey"),p=C("productName"),u=uo(bn),d=uo(oe),g=uo(ft),[f,m]=bh(null),v=C("showSearch"),w=C("showTextSuggestions"),h=C("adminUrl"),x=C("isEmbedded"),[b,_]=mc("dd-snooze-until-ms",0),R=u||b>Date.now(),O=uo(H=>H.input.text),X=t.filter(H=>H.source!=="gpt").length,I=()=>{R&&_(0),a(ml(!R))},W=H=>{a(q({name:"suggestion feedback",data:{text:H.text,source:"overlay",context:O},options:{includeConversationData:!0}}))},k=H=>{let rt=Date.now()+H*1e3;_(rt),T.info(`Snooze until: ${new Date(rt)}`),a(Be({collapse:!0}))};return _h(()=>{X===0&&m(null)},[t,X]),St(()=>{a(Be({collapse:!0,skipWhenInputFocus:!0}))}),d===null||g===!1?null:d===!1?go("div",{ref:l,className:Er(n.root,{[n.isCollapsed]:R}),children:[!R&&go("div",{className:n.triggers,children:[z("div",{style:{flex:1}}),z("div",{className:n.triggersRight,children:z(dt,{className:n.toggleButton,title:s("collapse"),onClick:I,isCollapsed:!1})})]}),z("div",{className:n.toggleButtonWrapper,children:z(dt,{className:n.toggleButton,title:s("open",{productName:p}),onClick:I,isCollapsed:!0})}),z("div",{className:n.collapsible,children:z(Nn,{loginUrl:h,isEmbedded:x,onLogIn:o,onSnooze:k})})]}):!i||!r?null:go("div",{ref:l,className:Er(n.root,{[n.isCollapsed]:R}),children:[!R&&go("div",{className:n.triggers,children:[z("div",{style:{flex:1},children:v&&z("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>m(s(fn()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>m(null),children:z(_c,{title:s("search")})})}),go("div",{className:n.triggersRight,onFocus:()=>{},children:[z("div",{className:Er(!f&&n.hintsHidden,n.hints),children:f}),z(dt,{className:n.toggleButton,title:s("collapse"),onClick:I,isCollapsed:!1})]})]}),z("div",{className:n.toggleButtonWrapper,children:z(dt,{className:n.toggleButton,title:s("open",{productName:p}),onClick:I,isCollapsed:!0})}),X>0&&w&&z("div",{className:n.collapsible,onFocus:()=>{},children:z(re,{children:z(Pn,{onFeedback:W,suggestions:t,selectedIndex:e,reverse:!0})})})]})},Eh=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),bc=Ch(Eh)(Th);import{Provider as kh}from"react-redux";import{jsx as On}from"react/jsx-runtime";var Rh=({children:t})=>{let o=C("locale").replace("-","");return On(As.Provider,{value:o,children:t})},Ih=({store:t,customStyles:e={},children:o})=>On(kh,{store:t,children:On(Rh,{children:On(zt.Provider,{value:e,children:o})})}),Ye=Ih;import Hr from"classnames";import{Interweave as hy}from"interweave";import{useCallback as yy,useEffect as vy,useMemo as zc,useRef as Sy}from"react";import{connect as _y}from"react-redux";import{cloneElement as Ph}from"react";var Ah=["div","span","mark","strong","b","i","u","em"];function kr(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(Ah.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),Ph(n,{children:kr(i,e,o+1)})]}return[...t,...e]}function Fe(t){return t.tagName.toLowerCase()==="textarea"}var Cc={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 $h from"classnames";import{Matcher as Xh}from"interweave";import{useEffect as Qh,useMemo as Zh}from"react";function wc(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Dn(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function Tc(t){return t!=null}import Pc from"classnames";import{createRef as Uh,useCallback as Ir,useMemo as zh,useRef as jh,useState as qh}from"react";import{useState as Lh,useLayoutEffect as Mh}from"react";var Nh=["bottom","height","left","right","top","width"],Oh=(t={},e={})=>Nh.some(o=>t[o]!==e[o]),ke=new Map,Ec,kc=()=>{let t=[],e=[];ke.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Oh(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{ke.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),Ec=window.requestAnimationFrame(kc)};function Dh(t,e){return{observe(){let o=ke.size===0;if(ke.has(t)){let n=ke.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else ke.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&kc()},unobserve(){let o=ke.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||ke.delete(t),ke.size||cancelAnimationFrame(Ec)}}}}function Rr(t){let[e,o]=Lh(null);return Mh(()=>{if(!t.current)return;let n=Dh(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}import{useContext as Hh,useLayoutEffect as Bh,useState as Fh}from"react";import{createPortal as Kh}from"react-dom";var Rc={root:"_root_1jq08_1"};var Ic=({children:t})=>{let[e,o]=Fh(null),n=Hh(zt);return Bh(()=>{let s=document.createElement("div");return Ge(s),s.classList.add(Rc.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?Kh(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 Pr}from"react/jsx-runtime";var Hn=(t=!1)=>{let[e,o]=qh(t),n=Ir(()=>o(!0),[]),s=Ir(()=>o(!1),[]),r=Ir(()=>o(a=>!a),[]),i=jh(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function Ar(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 Bn=({className:t,triggerRef:e,boundaryRef:o=Uh(),position:n="above",align:s="center",children:r,toStyle:i=Ar,...a})=>{let l=Rr(e),c=Rr(o),p=zh(()=>i(l,c,0),[l,c]);return Pr(Ic,{children:Pr("div",{className:Pc(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:Pr("div",{className:Pc(t,me.root),children:r})})})};import Vh from"classnames";import{forwardRef as Wh,useRef as Gh}from"react";import{jsx as Ac}from"react/jsx-runtime";var Fn=Wh(({className:t,children:e,...o},n)=>{let s=Gh(null),r=y("TabCompletion",Se);return Ac("div",{ref:Dn([s,n]),className:Vh(t,r.popoverContentContainer),...o,children:Ac("div",{className:r.popoverContent,children:e})})});import{jsx as mo,jsxs as ey}from"react/jsx-runtime";var Jh=t=>e=>{let o=Ar(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Yh=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",Se),i=Hn(),a=Zh(()=>Jh(t.getBoundingClientRect()),[t]),[l,c]=nn(t);return Qh(()=>{c?i.open():i.close()},[c]),ey("span",{children:[mo("mark",{ref:Dn([l,i.triggerRef]),className:$h(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&mo(Bn,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:mo(Fn,{style:o,children:mo("div",{className:r.hintText,children:s})})})]})},Kn=class extends Xh{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${wc(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(Tc);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 mo(Yh,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import Dr from"classnames";import{Matcher as cy}from"interweave";import{createRef as py,forwardRef as uy,useCallback as dy,useEffect as Fc,useRef as Kc,useState as Uc}from"react";import{useDispatch as gy}from"react-redux";import{jsx as Lc}from"react/jsx-runtime";var Mc=()=>Lc("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:Lc("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 ty,useEffect as Oc,useState as Dc}from"react";import{useDispatch as oy,useSelector as Hc}from"react-redux";import ny from"lodash.debounce";var Nc={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Un(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 Lr(t){return t.replace("https://www.","").replace("https://","")}import{jsx as et,jsxs as Mr}from"react/jsx-runtime";var sy=3,ry=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),iy=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=sy})=>{let r=y("LinkSearch",Nc),[i,a]=Dc(""),l=oy(),c=Hc(Ya("url")),p=Hc(Ba("URL",ry)),[u,d]=Dc(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 _;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(((_=p[u])==null?void 0:_.text)||i)},w=ty(ny(h=>{l(Qe({query:h,type:"URL",tags:["link-search"]}))},300),[]);return Oc(()=>{i&&w(i)},[i]),Oc(()=>()=>{l(yn())},[]),Mr("div",{className:r.root,children:[et(re,{withDivider:!0,children:(i?p:c).slice(0,s).map((h,x)=>et(D,{selected:u===x,onClick:()=>t(h.text),"data-testid":"linksearch-suggestion",children:Mr(B,{children:[et(B.Image,{src:Un(h,"small",g||void 0),title:h.title||h.text}),Mr(B.Content,{className:r.content,cropText:!0,children:[et(B.Title,{children:h.title||Lr(h.text)}),h.title&&Lr(h.text)]}),et(D.Actions,{children:et(D.ActionButton,{label:n,onClick:b=>m(b,h.text)})})]})},h.text))}),et(io,{value:i,onChange:f,autoFocus:!0,placeholder:o,onKeyUp:v})]})},Bc=iy;var Nr={};j(Nr,{enUS:()=>ay,nlNL:()=>ly});var ay={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},ly={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 my=uy((t,e)=>{let o=y("TabCompletion",Se);return fe("mark",{ref:e,className:Dr(o.matchSelection)},"selection-start")}),fy=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=E(Nr),i=y("TabCompletion",Se),a=Kc(null),l=Kc(null),[c,p]=Uc(null),u=gy(),d=Hn(document.activeElement===n),[g]=Uc(()=>document.createRange());d.triggerRef.current=g,Fc(()=>()=>g.detach(),[]),Fc(()=>{let m=t.current,v=a.current;!m||!v||(g.setStart(m,0),g.setEnd(v,0))},[t.current,a.current]),St(()=>{d.close()});let f=dy(m=>{let v=g.toString(),w=/^http(s?):\/\//.test(m)?m:`https://${m}`;u(Bo({text:`[${v}](${w})`,replace:"selection"}))},[]);return Or("span",{children:[fe("mark",{ref:a,className:Dr(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:s}),d.opened&&fe(Bn,{className:i.popoverRoot,triggerRef:d.triggerRef,boundaryRef:e,position:"above",align:"start",children:Or(Fn,{style:o,ref:l,children:[fe("div",{className:Dr(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(Mc,{}),fe("span",{children:"\xA0"}),fe("span",{children:r("insertLink")})]})}),c==="insertLink"&&fe(Bc,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:f,onDismiss:()=>{p(null),d.close()}})]})})]},"selection-end")},zn=class extends cy{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=py(),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(my,{ref:this.startRef}):fe(fy,{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 xy=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",Cc),p=C("insertLink"),u=C("showMidSentenceSuggestions"),d=C("inlineSuggestions"),g=rn(a),f=Sy(null);vy(()=>{Fe(a)&&g&&an(a,g)},[g]);let m=yy(h=>{if(!s||!o)return h;let x=[Ot("span",{className:c.resetIndent,children:"\u200B"},"u200B"),Ot("span",{"data-testid":"tab-completion",className:Hr(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&x.push(Ot("span",{className:Hr(c.hint,c.resetIndent),children:Ot(ps,{keyCode:"tab"},"tabHint")})),kr(h,x)},[s,o,n]),v=zc(()=>{let h=[];return p&&h.push(new zn("selection")),h.push(new vt("placeholders")),r&&h.push(new Kn("keywords")),h},[d,p,r]),w=zc(()=>{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(hy,{tagName:"span",containerTagName:"div",className:Hr(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},by=({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??Qt(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}},jc=_y(by)(xy);import sv from"classnames";import{useEffect as rv}from"react";import{useDispatch as iv,useSelector as ee}from"react-redux";import{createAsyncThunk as fo,createSlice as wy}from"@reduxjs/toolkit";var qc={list:[],fetchState:"idle",isInitialRequest:null},Wc=t=>t.autoflows.list||[],Vc=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},Re=fo("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Br=fo("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(Re(t.platformSessionId))}),Fr=fo("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(Re(t.platformSessionId))}),Ty=wy({name:"autoflows",initialState:qc,reducers:{},extraReducers:t=>{t.addCase(Br.pending,(e,o)=>{let n=Vc(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Fr.pending,(e,o)=>{let n=Vc(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(Re.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(Re.rejected,e=>{e.fetchState="error"}),t.addCase(Re.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(P,()=>qc)}}),Gc=fo("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(Re(t))}),s.on("sessionCompleted",()=>{o(Re(t))})}),$c=fo("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Xc=Ty.reducer;import{createAsyncThunk as yo,createSlice as Ey}from"@reduxjs/toolkit";var Qc={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Zc=t=>t.customMessages.list,Jc=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Yc=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),ep=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),ho=yo("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),jn=yo("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)}),qn=yo("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)}),tp=Ey({name:"customMessages",initialState:Qc,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(ho.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(ho.rejected,e=>{e.fetchState="error"}).addCase(ho.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(jn.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(jn.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(qn.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(qn.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(P,()=>Qc)}}),op=yo("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(tp.actions.onCustomMessage(r))})}),np=yo("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),sp=tp.reducer;import{createAsyncThunk as rp,createSlice as ky}from"@reduxjs/toolkit";var Ry={token:null,accountUrl:null,interval:null},ip=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},Kr=rp("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),Ur=rp("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(Kr()),setInterval(()=>n(Kr()),o)}),ap=ky({name:"passwordlessToken",initialState:Ry,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Kr.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(Ur.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:lp}=ap.actions,cp=ap.reducer;function pp(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}import{Fragment as By}from"react";import{connect as Fy}from"react-redux";import Oy from"classnames";import{Fragment as Dy}from"react";import Iy from"classnames";var up={root:"_root_838fd_1"};import{jsx as Ay}from"react/jsx-runtime";var Py=({className:t,children:e})=>{let o=y("Unicode",up);return Ay("span",{className:Iy(t,o.root),children:e})},dp=Py;var gp={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 zr={};j(zr,{enUS:()=>Ly,nlNL:()=>My});var Ly={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"}]},My={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]};import{jsx as tt,jsxs as Vn}from"react/jsx-runtime";var Hy=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",gp),a=E(zr),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return Vn(D,{className:Oy(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[tt(B,{children:Vn(B.Content,{children:[Vn(B.Title,{children:[e&&tt("span",{className:i.stateBadge,children:a(e)}),o]}),tt("span",{children:n})]})}),tt(D.Actions,{fixed:e==="Started",children:tt(D.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:Vn(Dy,{children:[tt(dp,{children:c})," ",tt("span",{children:a(l)})]})})})]})},mp=Hy;import{jsx as fp}from"react/jsx-runtime";var Ky=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Uy=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>fp(By,{children:t.map(s=>fp(mp,{displayName:s.displayName,description:s.description,disabled:s.isBusy||Ky(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),zy=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},jy={onStartAutoflow:Br,onStopAutoflow:Fr},hp=Fy(zy,jy)(Uy);import{useEffect as qy,useState as Vy}from"react";import{useDispatch as Wy}from"react-redux";import Sp from"classnames";import{jsx as yp}from"react/jsx-runtime";var jr=()=>yp("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:yp("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 vp={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 Dt,jsxs as _p}from"react/jsx-runtime";var Gy=({entities:t})=>{let e=y("EntitiesWidgetList",vp),[o,n]=Vy(void 0),s=Wy(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),lo(a.text),s(q({name:"entity copied",data:{entity:a,type:"copy"}})))};return qy(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:Dt("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>_p("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[Dt("span",{className:e.entityText,children:a.text}),_p("span",{className:e.iconWrapper,children:[Dt("span",{className:Sp(e.icon),children:Dt(jr,{})}),Dt("span",{className:Sp(e.icon,o===l&&e.iconClicked),children:Dt(jr,{})})]})]},a.text))})},xp=Gy;import $y from"classnames";import{useCallback as bp}from"react";import{useDispatch as Xy,useSelector as Wn}from"react-redux";var Ie={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 Gn}from"react/jsx-runtime";var Qy=({suggestion:t})=>{let e=E(Xe),o=Xy(),n=Wn(Jc(t.text)),s=Wn(Yc(t.text)),r=Wn(ep(t.text)),i=Wn(Po),{replyOptions:a}=t,l=bp(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(jn({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=bp(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let u=parseInt(p.target.dataset.index,10),d=a[u];o(qn({platformSessionId:i,reply:d,suggestion:t}))},[t,n,o,i]);return Gn(D,{onClick:l,className:$y(Ie.root,{[Ie.isUsed]:n,[Ie.hasError]:r}),children:[Ke(B,{children:Gn(B.Content,{children:[Gn(B.Title,{className:Ie.title,children:[t.text," ",Ke(us,{className:Ie.label,children:"analyse tool"})," ",r&&Ke("span",{className:Ie.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&Ke("ul",{className:Ie.quickReplies,children:a.map(p=>Ke("li",{className:Ie.quickReply,children:p.title},p.title))})]})}),Gn(D.Actions,{fixed:r||n,children:[a&&a.length>0&&Ke(D.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,u)=>Ke(D.DropdownItem,{index:u,label:p.title,onClick:c},p.title))}),Ke(D.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},Cp=Qy;import{jsx as wp}from"react/jsx-runtime";var Tp=()=>wp("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:wp("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 Yy}from"react-redux";import{useCallback as Zy}from"react";import{jsx as ot,jsxs as $n}from"react/jsx-runtime";var Jy=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var d;let s=t.text||t.url||t.message,r=vn(s),i=E(Xe),a=C("showImages"),l=C("fallbackImage"),c=g=>{g.preventDefault(),g.stopPropagation(),n(s)},p=g=>{g.preventDefault(),g.stopPropagation(),o(t)},u=Zy(g=>{window.open(r,"_blank"),g.stopPropagation(),g.preventDefault()},[r]);return $n(D,{onClick:c,"data-testid":"edit-suggestion",children:[$n(B,{children:[a&&t.image&&ot(B.Image,{src:Un(t,"small",l||void 0),title:t.title}),$n(B.Content,{children:[t.title&&ot(B.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((d=t.searchKeywords)==null?void 0:d.length)>0&&ot(D.Labels,{labels:t.searchKeywords}),ot(B.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),$n(D.Actions,{children:[r&&ot(D.ActionButton,{onClick:u,label:i("visitUrl")}),ot(D.ActionButton,{primary:!0,onClick:p,label:i("preview")}),ot(D.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},Ep=Jy;import{Fragment as tv,jsx as kp}from"react/jsx-runtime";var ev=({contentType:t,lines:e,suggestions:o})=>{let n=se(),s=Yy(Tt),r=a=>{n.send(ar,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(we,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return kp(tv,{children:o.map(a=>kp(Ep,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},Rp=ev;var qr={};j(qr,{enUS:()=>ov,nlNL:()=>nv});var ov={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},nv={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Ip={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 Pp}from"react/jsx-runtime";var Ap=()=>Pp("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:Pp("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 Lp}from"react/jsx-runtime";var Mp=()=>Lp("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:Lp("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 N,jsxs as Ht}from"react/jsx-runtime";var Xn=(t,e)=>{let o=ee(oe);rv(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},av=({onLogIn:t})=>{let e=E(qr),o=iv(),n=C("isEmbedded"),s=y("Widget",Ip),r=C("showAutoflows"),i=C("showCustomMessages"),a=C("showSummaryCommand"),l=C("showKnowledgeSearch"),c=C("showSearch"),p=ee(Lt),u=ee(kn),d=ee(Wc),g=ee(wn),f=ee(Zc),m=ee(Ao),v=ee(ft),w=ee(oe),h=ee(Po),x=ee(pp),b=ee(Tt),_=se(),R=ee(tl),O=ee(ip("/admin/")),X=C("adminUrl"),I=C("productName");if(Xn(()=>(o(ho(h)),o(op(h)),()=>{o(np(h))}),[o,v,i,h]),Xn(()=>(o(Re(h)),o(Gc(h)),()=>{o($c(h))}),[o,v,r,h]),Xn(()=>{u.forEach(({type:k})=>{o(k==="entities"?ce():xe(k))})},[o,v,m,p]),Xn(()=>(o(Ur()),()=>{o(lp())}),[o]),v===!1)return N("div",{className:s.stateText,children:N("div",{children:N("p",{children:e("notSupported")})})},"supported");if(w===!1)return N("div",{className:s.loginText,children:N("div",{children:N(Nn,{isEmbedded:n,loginUrl:X,onLogIn:t})})},"login");if(!p||!h||w===null||R||x)return N("div",{className:s.stateText,children:N("div",{children:N("p",{children:e("waiting")})})},"waiting");let W=c||a||l||O;return N("div",{className:sv(s.root),"data-testid":"widget",children:Ht(gs,{className:s.sectionList,children:[W&&N(ze,{title:e("actions"),type:"shortcuts",children:Ht("div",{className:s.shortcutList,children:[c&&Ht("button",{className:s.shortcut,"data-testid":"shortcut-search",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0}),children:[N(Ct,{}),e("linkSearch")]}),a&&Ht("button",{className:s.shortcut,"data-testid":"shortcut-summary",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[N(Mp,{}),e("linkSummary")]}),l&&Ht("button",{className:s.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[N(Ap,{}),e("linkKnowledgeSearch")]}),O&&Ht("a",{className:s.shortcut,target:"_blank",href:O,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[N(Tp,{}),e("linkStudioLogin",{productName:I})]})]})}),i&&f.length>0&&N(ze,{type:"custom-messages","data-testid":"custom-messages",children:N(re,{withDivider:!0,children:f.map(k=>N(Cp,{suggestion:k},k.text))})}),r&&d.length>0&&N(ze,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:N(re,{withDivider:!0,children:N(hp,{})})}),u.map(({type:k,title:H,amount:rt,lines:it})=>{var bo;switch(k){case"entities":return g&&g.length>0&&N(ze,{type:k,title:H,"data-testid":`type-${k}`,children:N(xp,{entities:g})},k);default:return((bo=b[k])==null?void 0:bo.fetchState)==="done"&&b[k].suggestions.length>0&&N(ze,{type:k,title:H,"data-testid":`type-${k}`,children:N(re,{withDivider:!0,children:N(Rp,{lines:it,contentType:k,suggestions:b[k].suggestions.slice(0,rt)||[]})})},k)}})]})})},Np=av;function So(t){let e=new Range;return e.selectNodeContents(t),e}function Op(t,e,o){try{return nt(t,e,o),!0}catch{return!1}}function Qn(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function Zn(t){return"tagName"in t&&t.tagName==="BR"}var vo=/[\u200B-\u200D\uFEFF]/g;function nt(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(vo,""),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(Zn(l)&&(s===e&&n.setStartBefore(l),s++,s===o)){n.setEndAfter(l),r=!0;return}for(let p=0;p<l.childNodes.length&&(a(l.childNodes[p]),!r);p++);let c=l.lastChild;Qn(l)&&c&&!Qn(c)&&!Zn(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function Jn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r,collapsed:i}=e,a,l,c=0;function p(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(vo,"").length),g&&(l=c+f.substring(0,r).replace(vo,"").length),c+=f.replace(vo,"").length;break}case Node.ELEMENT_NODE:{let f=u.nextSibling===null;Zn(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&&Qn(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 Yn(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(vo,"");d===0&&g===void 0?a+=f:a+=f.substring(d,g);break}case Node.ELEMENT_NODE:{let d=c.nextSibling===null;i===0&&Zn(c)&&!d&&(a+=`
|
|
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&&Qn(c)&&!d&&(a+=`
|
|
5
|
+
`);break}default:break}u&&i++}return l(t),a}function Dp(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Bt=class extends Ne{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),Yn(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!Dp(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!Dp(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return Jn(this.element,e);let o=this.lastKnownSelection;if(o&&Op(this.element,o.start,o.end))return o;let n=So(this.element);return n.collapse(!1),Jn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return Yn(this.element,nt(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 Hp(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 Vr=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()}},Wr=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=Hp(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()}},Gr=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),T.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 Wr(e,this.deepdeskUrl,{debug:!0}):new Vr(e),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&s.data.channel===e&&(T.info("Received broadcast event",this.sessionId,s),(i=(r=this.eventMap)[s.data.name])==null||i.call(r,s.data.payload))};return o.onMessage(n),o}send(e,o){var r,i;T.info("broadcast event",{sessionId:this.sessionId,name:e,payload:o});let n={type:"event",name:e,payload:o};(i=(r=this.eventMap)[e])==null||i.call(r,o);let s=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage({...n,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},Bp=Gr;var Ft=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var $r=t=>new Promise(e=>{setTimeout(e,t)});var Kt=class extends Ft{name="ClientError"},Xr=class extends Ft{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 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 x=async()=>(w--,a(i,v).then(async b=>g(b)&&!r.isAborted&&w>0?(await $r(p),x()):b.status===401&&u===!0&&h===!1?(h=!0,await this.refreshToken(),x()):b).catch(async b=>{if(d(b)&&!r.isAborted&&w>0)return await $r(p),x();throw b}));x().then(b=>b.json().catch(()=>null).then(_=>{b.status>=500?s(new Xr("Server Error",_)):b.status===401?s(new Kt("Unauthorized",_)):b.status===403?s(new Kt("Forbidden",_)):b.status===404?s(new Kt("Not Found",_)):b.status>=400&&s(new Kt("Bad Request",_)),delete this.latestRequestByUrl[i],n(_)})).catch(b=>{s(b)})})}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var lv;(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||={})})(lv||={});function es(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(),T.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 es(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(),T.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 es(r)}async isConversationSupported(e,o={}){T.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 es(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=>es(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 T.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-assist/assistants/${n}/search`,F({question:e.question,promptInstruction:e.promptInstruction,chatHistory:o.map(r=>({question:r.question,answer:r.answer.answer}))}),{version:"v2"});return A(s)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return A(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return A(e.token)}async getCsrfToken(){let{token:e}=await this.client.get("/apis/admin/session/csrf/",{version:null});return e}async verifyLoginToken(e){let o=await this.client.post("/apis/admin/session/passwordless/login/",{token:e},{version:null});return A(o)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(mi);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&T.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var _o=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Js(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,A(s))}catch{T.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 cv;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(cv||={});var xo=class{constructor(e,o={}){this.apiUrl=e;this.client=new he(e,o)}client;streams={};logger=T;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 _o(`${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 hv,configureStore as yv}from"@reduxjs/toolkit";import{createSlice as pv}from"@reduxjs/toolkit";var Fp={startTime:null,stopTime:null},Kp=pv({name:"handlingTime",initialState:Fp,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(P,()=>Fp)}}),{handlingTimeStart:Up,handlingTimeStop:ts,handlingTimeReset:zp}=Kp.actions,jp=Kp.reducer;var qp=(t={})=>{let e={onAuthError:kt(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};import{createAsyncThunk as uv,createSlice as dv}from"@reduxjs/toolkit";var os={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var st=uv("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 os.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),gv=dv({name:"styleSuggestions",initialState:os,reducers:{},extraReducers:t=>{t.addCase(st.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(st.rejected,e=>{e.fetchState="error"}).addCase(st.fulfilled,(e,o)=>{e.fetchState="done",Ae(e.list,o.payload)||(e.list=o.payload)}).addCase(Ve,e=>{e.list=os.list}).addCase(P,()=>os)}}),Vp=gv.reducer;var Wp=(t={})=>{let e,o=!0,n={getStyleSuggestions:st,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 mv(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Gp=(t={})=>{let e={getTextSuggestions:xe,getAutocompleteSuggestions:oo,debounce:200,check:Nt,...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===xn.toString();if(!u||!c&&!p)return a;let{input:{userCommitted:g}}=l;return mv(g,i)&&!d||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let v=ht(l);v===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(v))},d?0:e.debounce)),a}};var $p=st.fulfilled.toString();function fv(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 Xp=t=>e=>o=>n=>{var c;if(n.type!==$p){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=fv(s,i);n.type===$p&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var vv=hv({activeSuggestion:ul,answer:Jl,auth:wl,autoflows:Xc,conversation:_i,contentTypes:Ol,customMessages:sp,passwordlessToken:cp,entities:Bl,handlingTime:jp,info:Na,input:xs.reducer,overlayInput:Q.reducer,settings:hi,profile:nc,search:Ka,summary:Vl,styleSuggestions:Vp,ui:fl,textSuggestions:il});function Qp(t){return yv({reducer:vv,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),qp(),Gp({debounce:200}),Wp({debounce:500}),Xp(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Sv=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},_v=t=>e=>o=>n=>{var a;let s=e.getState(),r=ys("inlineSuggestions")(s);switch(n.type){case be.toString():{let l=el(n.payload.contentType)(e.getState()),c=l.indexOf(n.payload.suggestion);t.emit("edit-suggestion",{contentType:n.payload.contentType,index:c,suggestions:l});break}case kt.toString():{!n.payload&&t.emit("logout",void 0);break}case ie.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:Sv(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Bo.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 Vt.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case zo.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 Te.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 Fo.toString():t.handleKeyDown(n.payload);break;case Ve.toString():t.logSendMessage(n.payload);break;case Ko.toString():t.logSendEditSuggestionMessage(n.payload);break;case Uo.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case Ve.toString():t.handleAfterSendMessage(n.payload);break;case no.toString():t.onUpdateShowTabHint(n.payload);break;case ts.toString():t.logHandlingTime();break;case ie.toString():{r&&(e.dispatch(ue([])),e.dispatch(ve()));break}case ue.toString():{r&&n.payload.length>0&&e.dispatch(Me(0));break}default:break}return i},Zp=_v;function Qr(t){return t.toISOString().replace("T"," ").replace("Z","")}function Jp(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:Qr(o),timeStop:Qr(n)}}function Zr(t,e,o){var O,X,I;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((W,{text:k,searchTerm:H})=>W+k.length-(H?H.length:0),0),x=c??Date.now(),b=(Date.now()-x)/1e3+(p||0),_=s/b,R=f.reduce((W,{searchTerm:k})=>W+(k?k.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:u,cuts:d,deletions:g,lenTextTyped:s+R,lenTextTotal:v,lenTextAssisted:h,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:b,charsPerSecond:_,numPastes:l,textSuggestionsV2:f,suggestionsCounters:[{source:"gpt",countOffered:m.filter(W=>W.source==="gpt").length}],agentId:(O=e.info.agentInfo)==null?void 0:O.agentId,agentName:(X=e.info.agentInfo)==null?void 0:X.agentName,agentEmail:(I=e.info.agentInfo)==null?void 0:I.agentEmail}}function Jr(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return Jr(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?Jr(s,e):null}function Yp(t,e){return Jr(t,e)}function eu(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function xv(t){return typeof t=="object"&&t!==null&&"tagName"in t}function Yr(t){return xv(t)&&(Fe(t)||sn(t))}var tu=(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{T.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function bv(t){return t.offsetParent!==null}function ou(t){if(!bv(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 ei(t,e,o=100){let n=ou(t);e({isVisible:n});let s=setInterval(()=>{let r=ou(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}import Ev from"classnames";import{useSelector as kv}from"react-redux";import{jsx as ti}from"react/jsx-runtime";var nu=({className:t})=>ti("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:ti("g",{children:ti("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
|
|
6
6
|
c-17.9,17.9-27.3,40.1-27.3,65.7C163.4,163,163.4,233,163.4,233z M465.5,267.9V477c0,9.4-3.4,17.9-10.2,24.7
|
|
7
7
|
c-6.8,6.8-15.4,10.2-24.7,10.2h-349c-9.4,0-17.9-3.4-24.7-10.2c-6.8-6.8-10.2-15.4-10.2-24.7V267.9c0-9.4,3.4-17.9,10.2-24.7
|
|
8
8
|
c6.8-6.8,15.4-10.2,24.7-10.2h11.9v-70c0-44.4,16.2-82.8,47.8-115.2S212.1,0,256.4,0s82.8,16.2,115.2,47.8
|
|
9
|
-
c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});import{jsx as sd}from"react/jsx-runtime";var Cv={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},rd=({className:t,color:e})=>sd("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:sd("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:Cv[e||"pink"]})});var id={root:"_root_bgd7a_1",text:"_text_bgd7a_18",icon:"_icon_bgd7a_33",logo:"_logo_bgd7a_38",lock:"_lock_bgd7a_43"};var oi={};j(oi,{enUS:()=>wv,nlNL:()=>Tv});var wv={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"}]},Tv={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"}]};import{useDispatch as kv}from"react-redux";import{jsx as ni,jsxs as ad}from"react/jsx-runtime";var ld=({onLogIn:t})=>{let e=E(oi),o=C("productName"),n=kv(),s=Ev(oe),r=y("FloatingMenu",id);if(s===null)return null;let i=()=>{s===!0?n(G(!0)):t()};return ad("button",{className:r.root,onClick:i,children:[ni("div",{className:r.text,children:e(s?"search":"signin",{productName:o})}),ad("div",{className:r.icon,children:[ni(rd,{className:r.logo,color:"pink"}),s===!1&&ni(nd,{className:r.lock})]})]})};async function si(t){let o=await new he(t).get("/platform/config/",{version:null});return A(o)}import{jsx as K}from"react/jsx-runtime";var cd=td("showTabHint",!0),ss=class t{static version="10.9.3-beta.2";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new Ue(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Zp({emit:(d,u,g)=>this.emit(d,u,g),handleAfterSendMessage:d=>this.handleAfterSendMessage(d),handleInputChanged:d=>this.handleInputChanged(d),handleKeyDown:d=>this.handleKeyDown(d),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:d=>this.logSendMessage(d),logSendEditSuggestionMessage:d=>this.logSendEditMessage(d),onUpdateShowTabHint:d=>cd.update(d),sendEvent:(d,u)=>this.deepdeskApi.sendEvent(d,u)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new xo(o)}),this.store=Qp(p),this.broadcastEvents=new Bp({debug:!0,deepdeskUrl:c,eventMap:Tl(this.store),createCustomChannel:l}),this.store.dispatch(qt),this.store.dispatch(no(cd.value())),this.store.dispatch(qt({locale:s,adminUrl:c,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(T.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(T.warn("Profile has not been loaded (yet)"),!0):(T.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(kt(null)),this.store.dispatch(Ce()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();oe(n)&&vl(n)!=="loading"&&(o(),e())});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(Ce())).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){T.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(Lo(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Mo({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(_s(e))).payload}async postMessages(e){return(await this.store.dispatch(Oo(e))).payload}async updateConversation(e){return(await this.store.dispatch(No(e))).payload}resetConversation(){this.store.dispatch(P()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(Te());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(qt(e))}setVisitorInfo(e){this.store.dispatch(Ma(e))}async setAgentInfo(e){await this.store.dispatch(Yt(e))}async setAgentSettings(e){await this.store.dispatch(er(e))}async getAgentSettings(){return(await this.store.dispatch(tr())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(xn()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Uo(e))}notifyKeyDown(e){this.store.dispatch(Fo(e))}notifyPaste(e,o){this.store.dispatch(Ai({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Ii(e))}notifyExternalSuggestion(e){this.store.dispatch(ie(e)),this.store.dispatch(ve())}notifyEditSuggestion(e){this.store.dispatch(sl(e.contentType,e.suggestions)),this.store.dispatch(be({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(Ci({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(de([])))}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(Pi(Ho(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(Ei()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Ri());let{selectedSuggestionIndex:d}=this.state.input;e.preventDefault(),!i&&(d===-1?this.store.dispatch(Vt()):this.stageSelectedSuggestion({inputType:"arrow"}))};switch(e.key){case"Up":case"ArrowUp":i?p():c();return;case"Down":case"ArrowDown":{i?c():p();return}case"Esc":case"Escape":{i&&l&&this.store.dispatch(Me(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(Me(-1)),this.store.dispatch(Vt()),e.preventDefault()):o||(this.store.dispatch(Be({collapse:!0})),this.store.dispatch(gl(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:d}=this.state.input,u=d.text.substring(0,d.selection.end),{tabCompletionSuggestion:g}=this.state.input;this.store.dispatch(no(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&g&&g.text.startsWith(u)&&(this.store.dispatch(ie({text:g.text,suggestion:g,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(ve())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Li()),this.store.dispatch(de([]))}handlingTimeStart(){this.state.handlingTime.startTime||(T.info("Start handling time"),this.store.dispatch(Up()))}handlingTimeStop(){this.state.handlingTime.startTime&&(T.info("Stop handling time"),this.store.dispatch(ts()))}logSendMessage(e){let o=Zr("input",this.state,{version:this.version});e&&(Object.assign(o,{text:e}),Object.assign(o,{lenTextTotal:e.length})),this.deepdeskApi.sendEventV1("Send Message",o),this.emit("send-message-event",o)}logSendEditMessage(e){let o=Zr("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(Ti(this.state.overlayInput.metrics))}logHandlingTime(){let e=Jp(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(zp())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(ve()),this.store.dispatch(Ve(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){T.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),T.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=xt(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{ns(r),i(),r.remove()}),r}createInlineContainer(e,o){var i;let n=document.createElement("div");n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.style.height="0px",n.style.width="0px";let s=document.createElement("div");s.style.display="none",s.style.position="absolute",s.style.height="0px",s.style.width="0px",s.style.backgroundColor="red",n.appendChild(s);let r=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;if(r){let[a,l]=xt(r,{appendTo:document.body});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{ns(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Ge(s),s.dataset.testid=e,s.style.color=n.color,s.style.fontSize=n.fontSize,s.style.fontFamily=n.fontFamily,s.style.fontVariant=n.fontVariant,s.setAttribute("translate","no"),o.appendChild(s),this.unmountHandlers.push(()=>{ns(s),s.remove()}),s}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,o),T.info(`Stored analytics for ${this.conversationId()}`)}catch{}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=window.sessionStorage.getItem(e);if(!o)return;let n=JSON.parse(o);n.text.trim()===this.state.input.text.trim()?(T.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(Ni(n.metrics))):T.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch{}}mount(e,o={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Yr(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:n={},showStyleSuggestions:s,showTabCompletion:r,showTextSuggestions:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,isEmbedded:d,detectSubmit:u,insertLink:g,inputMediator:f,closestScrollSelector:m,appendOverlayTo:v,inlineSuggestions:w,floatingMenu:h}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:g,isEmbedded:d,inlineSuggestions:w,floatingMenu:!!h}),o.automaticHandlingTime&&this.setupHandlingTime(e),Ge(e),this.inputMediator=f||(Fe(e)?new Oe(e):new Bt(e)),this.inputMediator.on("change",({plainText:_})=>{this.notifyInputChanged(_)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Mi({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",_=>{this.notifyKeyDown(_)}),this.inputMediator.on("paste",({pastedText:_,selectionText:R})=>{this.notifyPaste(_,R)}),this.inputMediator.on("cut",({selectionText:_})=>{this.notifyCut(_)});let x=m&&Yp(e,m)||void 0;if(w){let{customStyles:_,appendOverlayTo:R}=o;if(Fe(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let O=this.createInlineContainer(e,"deepdesk-caret");Ut(K(Ye,{store:this.store,customStyles:_,children:K(Je,{broadcastEvents:this.broadcastEvents,children:K(gc,{})})}),O),this.inputMediator.on("caret",I=>{this.store.dispatch(de([])),I?(O.style.display="block",O.style.top=`${I.top}px`,O.style.left=`${I.left}px`):O.style.display="none"});let X=this.overlayContainerFactory("floating-menu",x||e,{appendTo:typeof h=="object"&&"appendOverlayTo"in h?h.appendOverlayTo:R},_==null?void 0:_.floatingMenuRootNode);Ut(K(Ye,{store:this.store,customStyles:_,children:K(Je,{broadcastEvents:this.broadcastEvents,children:K(ld,{onLogIn:()=>this.loginViaPopup().catch(I=>T.warn(I.message))})})}),X)}else{let _=this.overlayContainerFactory("deepdesk-tab-completion",x||e,{appendTo:v,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),R=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||e,{appendTo:v},n==null?void 0:n.suggestionsRootNode);Ut(K(Ye,{store:this.store,customStyles:n,children:K(Je,{broadcastEvents:this.broadcastEvents,children:K(jc,{inputElement:e})})}),_),Ut(K(Ye,{store:this.store,customStyles:n,children:K(Je,{broadcastEvents:this.broadcastEvents,children:K(bc,{onLogIn:()=>this.loginViaPopup().catch(O=>T.warn(O.message))})})}),R)}Ut(K(Ye,{store:this.store,customStyles:n,children:K(Je,{broadcastEvents:this.broadcastEvents,children:K(ac,{})})}),this.createContainer("deepdesk-overlays"));let b;this.inputMediator.on("selection",_=>{clearTimeout(b),_===null?b=setTimeout(()=>{_!==null&&this.store.dispatch(bs(_))},500):this.store.dispatch(bs(_))}),this.inputMediator.on("disabled",()=>{var _;(_=this.inputMediator)==null||_.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{u&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(Et(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(Et(!0))),this.store.dispatch(wi({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(ve()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var _;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((_=this.state.conversation.current)==null?void 0:_.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&T.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:n,showImages:s,isEmbedded:r}=o;this.widgetRoot=e,this.configure({showImages:s,isEmbedded:r}),Ut(K(Ye,{store:this.store,customStyles:n,children:K(Je,{broadcastEvents:this.broadcastEvents,children:K(Np,{onLogIn:()=>this.loginViaPopup().catch(i=>T.warn(i.message))})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setSessionId((i=this.state.conversation.current)==null?void 0:i.sessionId)})}unmountWidget(){this.widgetRoot&&ns(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=ei(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){ed(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(co());let e=Lt(this.state);e&&this.store.dispatch(qt({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(){let e=this.state.settings.adminUrl,o=new URL(e),n=await si(o.origin);return new Promise((s,r)=>{let i=new MessageChannel,a=i.port1,l=new URL(n.config.platform.hasSso?`${e}/platform/sso/`:`${e}/admin/`);l.searchParams.append("redirect","/sdk/popup/close.html");let c=!1,p=()=>{d&&!d.closed&&d.close(),window.removeEventListener("message",u),clearInterval(g)};a.onmessage=async f=>{var m,v;if((m=f.data)!=null&&m.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((v=f.data)==null?void 0:v.jwt),await this.isLoggedIn(),this.broadcastEvents.send(ro),p(),c=!0,i.port1.close(),s()}catch(w){r(w)}};let d=window.open(l.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");d===null&&r(new Error("Popup blocked by browser"));let u=async f=>{var m;if(f.origin===l.origin)switch((m=f.data)==null?void 0:m.type){case"deepdesk-popup-loaded":{d==null||d.postMessage({type:"deepdesk-popup-create-channel"},l.origin,[i.port2]);break}case"deepdesk-popup-error":{p(),f.data.message==="Timeout"&&T.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(f.data.message));break}}};window.addEventListener("message",u);let g=setInterval(()=>{d&&!d.closed||(p(),c||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(p)})}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(T.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;T.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=kn(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(ce()):this.store.dispatch(xe(n))})}catch(n){this.handleError(n)}}};async function Rv(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 Iv(t,e,o={}){let n=o.replace?nt(t,o.replace.start,o.replace.end):So(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?nt(t,o.selectionAfter.start,o.selectionAfter.end):(n.collapse(!1),n),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(i)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function
|
|
11
|
-
`).
|
|
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 su}from"react/jsx-runtime";var Cv={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},ru=({className:t,color:e})=>su("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:su("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:Cv[e||"pink"]})});var iu={root:"_root_1tvv4_1",text:"_text_1tvv4_18",isLoggedIn:"_isLoggedIn_1tvv4_25",isLoggedOut:"_isLoggedOut_1tvv4_29",icon:"_icon_1tvv4_39",logo:"_logo_1tvv4_44",lock:"_lock_1tvv4_49"};var oi={};j(oi,{enUS:()=>wv,nlNL:()=>Tv});var wv={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},Tv={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};import{useDispatch as Rv}from"react-redux";import{jsx as ni,jsxs as au}from"react/jsx-runtime";var lu=({onLogIn:t})=>{let e=E(oi),o=C("productName"),n=Rv(),s=kv(oe),r=y("FloatingMenu",iu);if(s===null)return null;let i=()=>{s===!0?n(G(!0)):t()};return au("button",{className:Ev(r.root,{[r.isLoggedIn]:s,[r.isLoggedOut]:!s}),onClick:i,children:[ni("div",{className:r.text,children:e(s?"search":"signin",{productName:o})}),au("div",{className:r.icon,children:[ni(ru,{className:r.logo,color:"pink"}),s===!1&&ni(nu,{className:r.lock})]})]})};async function si(t){let o=await new he(t).get("/platform/config/",{version:null});return A(o)}import{jsx as K}from"react/jsx-runtime";var cu=tu("showTabHint",!0),ss=class t{static version="10.9.3-beta.4";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new Ue(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Zp({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=>cu.update(u),sendEvent:(u,d)=>this.deepdeskApi.sendEvent(u,d)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new xo(o)}),this.store=Qp(p),this.broadcastEvents=new Bp({debug:!0,deepdeskUrl:c,eventMap:Tl(this.store),createCustomChannel:l}),this.store.dispatch(qt),this.store.dispatch(no(cu.value())),this.store.dispatch(qt({locale:s,adminUrl:c,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(T.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(T.warn("Profile has not been loaded (yet)"),!0):(T.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(kt(null)),this.store.dispatch(Ce()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();oe(n)&&vl(n)!=="loading"&&(o(),e())});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(Ce())).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){T.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(Lo(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Mo({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(_s(e))).payload}async postMessages(e){return(await this.store.dispatch(Oo(e))).payload}async updateConversation(e){return(await this.store.dispatch(No(e))).payload}resetConversation(){this.store.dispatch(P()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(Te());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(qt(e))}setVisitorInfo(e){this.store.dispatch(Ma(e))}async setAgentInfo(e){await this.store.dispatch(Yt(e))}async setAgentSettings(e){await this.store.dispatch(er(e))}async getAgentSettings(){return(await this.store.dispatch(tr())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(xn()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Uo(e))}notifyKeyDown(e){this.store.dispatch(Fo(e))}notifyPaste(e,o){this.store.dispatch(Ai({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Ii(e))}notifyExternalSuggestion(e){this.store.dispatch(ie(e)),this.store.dispatch(ve())}notifyEditSuggestion(e){this.store.dispatch(sl(e.contentType,e.suggestions)),this.store.dispatch(be({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(Ci({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(Pi(Ho(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(Ei()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Ri());let{selectedSuggestionIndex:u}=this.state.input;e.preventDefault(),!i&&(u===-1?this.store.dispatch(Vt()):this.stageSelectedSuggestion({inputType:"arrow"}))};switch(e.key){case"Up":case"ArrowUp":i?p():c();return;case"Down":case"ArrowDown":{i?c():p();return}case"Esc":case"Escape":{i&&l&&this.store.dispatch(Me(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(Me(-1)),this.store.dispatch(Vt()),e.preventDefault()):o||(this.store.dispatch(Be({collapse:!0})),this.store.dispatch(gl(!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(no(!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(ve())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Li()),this.store.dispatch(ue([]))}handlingTimeStart(){this.state.handlingTime.startTime||(T.info("Start handling time"),this.store.dispatch(Up()))}handlingTimeStop(){this.state.handlingTime.startTime&&(T.info("Stop handling time"),this.store.dispatch(ts()))}logSendMessage(e){let o=Zr("input",this.state,{version:this.version});e&&(Object.assign(o,{text:e}),Object.assign(o,{lenTextTotal:e.length})),this.deepdeskApi.sendEventV1("Send Message",o),this.emit("send-message-event",o)}logSendEditMessage(e){let o=Zr("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(Ti(this.state.overlayInput.metrics))}logHandlingTime(){let e=Jp(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(zp())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(ve()),this.store.dispatch(Ve(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){T.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),T.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=xt(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{ns(r),i(),r.remove()}),r}createInlineContainer(e,o){var i;let n=document.createElement("div");n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.style.height="0px",n.style.width="0px";let s=document.createElement("div");s.style.display="none",s.style.position="absolute",s.style.height="0px",s.style.width="0px",s.style.backgroundColor="red",n.appendChild(s);let r=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;if(r){let[a,l]=xt(r,{appendTo:document.body});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{ns(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Ge(s),s.dataset.testid=e,s.style.color=n.color,s.style.fontSize=n.fontSize,s.style.fontFamily=n.fontFamily,s.style.fontVariant=n.fontVariant,s.setAttribute("translate","no"),o.appendChild(s),this.unmountHandlers.push(()=>{ns(s),s.remove()}),s}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,o),T.info(`Stored analytics for ${this.conversationId()}`)}catch{}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=window.sessionStorage.getItem(e);if(!o)return;let n=JSON.parse(o);n.text.trim()===this.state.input.text.trim()?(T.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(Ni(n.metrics))):T.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch{}}mount(e,o={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Yr(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,floatingMenu:h}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:g,isEmbedded:u,inlineSuggestions:w,floatingMenu:!!h}),o.automaticHandlingTime&&this.setupHandlingTime(e),Ge(e),this.inputMediator=f||(Fe(e)?new Oe(e):new Bt(e)),this.inputMediator.on("change",({plainText:_})=>{this.notifyInputChanged(_)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Mi({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",_=>{this.notifyKeyDown(_)}),this.inputMediator.on("paste",({pastedText:_,selectionText:R})=>{this.notifyPaste(_,R)}),this.inputMediator.on("cut",({selectionText:_})=>{this.notifyCut(_)});let x=m&&Yp(e,m)||void 0;if(w){let{customStyles:_,appendOverlayTo:R}=o;if(Fe(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let O=this.createInlineContainer(e,"deepdesk-caret");Ut(K(Ye,{store:this.store,customStyles:_,children:K(Je,{broadcastEvents:this.broadcastEvents,children:K(gc,{})})}),O),this.inputMediator.on("caret",I=>{this.store.dispatch(ue([])),I?(O.style.display="block",O.style.top=`${I.top}px`,O.style.left=`${I.left}px`):O.style.display="none"});let X=this.overlayContainerFactory("floating-menu",x||e,{appendTo:typeof h=="object"&&"appendOverlayTo"in h?h.appendOverlayTo:R},_==null?void 0:_.floatingMenuRootNode);Ut(K(Ye,{store:this.store,customStyles:_,children:K(Je,{broadcastEvents:this.broadcastEvents,children:K(lu,{onLogIn:()=>this.loginViaPopup().catch(I=>T.warn(I.message))})})}),X)}else{let _=this.overlayContainerFactory("deepdesk-tab-completion",x||e,{appendTo:v,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),R=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||e,{appendTo:v},n==null?void 0:n.suggestionsRootNode);Ut(K(Ye,{store:this.store,customStyles:n,children:K(Je,{broadcastEvents:this.broadcastEvents,children:K(jc,{inputElement:e})})}),_),Ut(K(Ye,{store:this.store,customStyles:n,children:K(Je,{broadcastEvents:this.broadcastEvents,children:K(bc,{onLogIn:()=>this.loginViaPopup().catch(O=>T.warn(O.message))})})}),R)}Ut(K(Ye,{store:this.store,customStyles:n,children:K(Je,{broadcastEvents:this.broadcastEvents,children:K(ac,{})})}),this.createContainer("deepdesk-overlays"));let b;this.inputMediator.on("selection",_=>{clearTimeout(b),_===null?b=setTimeout(()=>{_!==null&&this.store.dispatch(bs(_))},500):this.store.dispatch(bs(_))}),this.inputMediator.on("disabled",()=>{var _;(_=this.inputMediator)==null||_.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(Et(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(Et(!0))),this.store.dispatch(wi({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(ve()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var _;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((_=this.state.conversation.current)==null?void 0:_.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&T.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:n,showImages:s,isEmbedded:r}=o;this.widgetRoot=e,this.configure({showImages:s,isEmbedded:r}),Ut(K(Ye,{store:this.store,customStyles:n,children:K(Je,{broadcastEvents:this.broadcastEvents,children:K(Np,{onLogIn:()=>this.loginViaPopup().catch(i=>T.warn(i.message))})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setSessionId((i=this.state.conversation.current)==null?void 0:i.sessionId)})}unmountWidget(){this.widgetRoot&&ns(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=ei(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){eu(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(co());let e=Lt(this.state);e&&this.store.dispatch(qt({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(){let e=this.state.settings.adminUrl,o=new URL(e),n=await si(o.origin);return new Promise((s,r)=>{let i=new MessageChannel,a=i.port1,l=new URL(n.config.platform.hasSso?`${e}/platform/sso/`:`${e}/admin/`);l.searchParams.append("redirect","/sdk/popup/close.html");let c=!1,p=()=>{u&&!u.closed&&u.close(),window.removeEventListener("message",d),clearInterval(g)};a.onmessage=async f=>{var m,v;if((m=f.data)!=null&&m.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((v=f.data)==null?void 0:v.jwt),await this.isLoggedIn(),this.broadcastEvents.send(ro),p(),c=!0,i.port1.close(),s()}catch(w){r(w)}};let u=window.open(l.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");u===null&&r(new Error("Popup blocked by browser"));let d=async f=>{var m;if(f.origin===l.origin)switch((m=f.data)==null?void 0:m.type){case"deepdesk-popup-loaded":{u==null||u.postMessage({type:"deepdesk-popup-create-channel"},l.origin,[i.port2]);break}case"deepdesk-popup-error":{p(),f.data.message==="Timeout"&&T.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(f.data.message));break}}};window.addEventListener("message",d);let g=setInterval(()=>{u&&!u.closed||(p(),c||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(p)})}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(T.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;T.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=kn(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(ce()):this.store.dispatch(xe(n))})}catch(n){this.handleError(n)}}};async function Iv(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 Pv(t,e,o={}){let n=o.replace?nt(t,o.replace.start,o.replace.end):So(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?nt(t,o.selectionAfter.start,o.selectionAfter.end):(n.collapse(!1),n),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(i)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function Av(t){let e=document.createElement("template");return e.innerHTML=t,e.content}function Lv(t){let e=document.createDocumentFragment();return t.split(`
|
|
11
|
+
`).forEach((o,n)=>{n>0&&e.appendChild(document.createElement("br")),e.appendChild(document.createTextNode(o))}),e}function pu(t,e){return!t.contains(e)||e===t?null:e.parentNode===t?e:pu(t,e.parentNode)}async function Mv(t,e,{isBlock:o,isHTML:n}={}){let s;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let r=()=>{let i=t.ownerDocument.defaultView??window,a=i.getSelection();if((!a||a.rangeCount===0)&&(t.focus(),a=i.getSelection()),!a||a.rangeCount===0)return;let l=a.getRangeAt(0);if(!l)return;s=document.createElement("span"),l.insertNode(s);let c=n?Av(e):Lv(e);if(o){let p=pu(t,l.startContainer)??t.firstChild;t.insertBefore(c,(p==null?void 0:p.nextSibling)??null)}else l.insertNode(c),l.collapse(!1)};return Promise.resolve(r()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!s)try{s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function Nv(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function Ov(t,e,o){await new Ue(t).authenticateWithKey(e,o)}async function Dv(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 Hv(t,e){let o=await Dv(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,Bt as ContentEditableInput,Ue as DeepdeskAPI,ss as DeepdeskSDK,he as HTTPClient,Ne as InputMediator,je as InputType,ps as KeyboardHint,us as Label,Io as Locale,ze as Section,gs as SectionList,pe as Sources,D as Suggestion,re as SuggestionList,Oe as TextAreaInput,dt as ToggleButton,Hv as attachFile,Ov as authenticateWithKey,So as createFullRange,xt as createOverlayContainer,nt as createRangeFromOffsets,Qt as escapeHTML,si as fetchPlatformConfig,Nv as formatTextMarkup,Jn as getRangeOffsets,Yn as getRangeText,Mv as insertCKEditor,Yr as isSupportedInputElement,Pv as updateContentEditable,Iv as updateTextArea,y as useStyles,ei as waitForElementVisibilityChange};
|