@deepdesk/deepdesk-sdk 10.12.1-beta.1 → 10.12.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,11 +1,11 @@
1
- "use strict";var Ju=Object.create;var Ln=Object.defineProperty;var Yu=Object.getOwnPropertyDescriptor;var eg=Object.getOwnPropertyNames;var tg=Object.getPrototypeOf,og=Object.prototype.hasOwnProperty;var G=(t,e)=>{for(var o in e)Ln(t,o,{get:e[o],enumerable:!0})},pa=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of eg(e))!og.call(t,s)&&s!==o&&Ln(t,s,{get:()=>e[s],enumerable:!(n=Yu(e,s))||n.enumerable});return t};var E=(t,e,o)=>(o=t!=null?Ju(tg(t)):{},pa(e||!t||!t.__esModule?Ln(o,"default",{value:t,enumerable:!0}):o,t)),ng=t=>pa(Ln({},"__esModule",{value:!0}),t);var Ih={};G(Ih,{Card:()=>F,ContentEditableInput:()=>Qt,DeepdeskAPI:()=>ct,DeepdeskSDK:()=>kn,HTTPClient:()=>Oe,InputMediator:()=>$e,InputType:()=>dt,KeyboardHint:()=>Bn,Label:()=>Fn,Locale:()=>Bo,Section:()=>pt,SectionList:()=>Kn,Sources:()=>Ee,Suggestion:()=>O,SuggestionList:()=>Se,TextAreaInput:()=>Ge,ToggleButton:()=>At,attachFile:()=>Uu,authenticateWithKey:()=>Fu,createFullRange:()=>Mo,createOverlayContainer:()=>Ot,createRangeFromOffsets:()=>It,escapeHTML:()=>fo,fetchPlatformConfig:()=>Ku,formatTextMarkup:()=>Bu,getRangeOffsets:()=>Cn,getRangeText:()=>wn,insertCKEditor:()=>Hu,isHTML:()=>Dt,isSupportedInputElement:()=>wr,updateContentEditable:()=>Ou,updateTextArea:()=>Nu,useStyles:()=>y,waitForElementVisibilityChange:()=>Tr});module.exports=ng(Ih);var On=E(require("classnames")),he=E(require("react"));var Mn=E(require("react")),da=E(require("classnames")),Do=Mn.default.createContext({});function y(t,e){let{debug:o,...n}=(0,Mn.useContext)(Do),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,da.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var ua={root:"_root_vr71j_1"};var Rt=require("react/jsx-runtime"),Nn=()=>(0,Rt.jsxs)("svg",{className:ua.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,Rt.jsx)("defs",{children:(0,Rt.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,Rt.jsx)("title",{children:"Failed loading image"}),(0,Rt.jsx)("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 kr={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"};var Pt=require("react/jsx-runtime"),Dn=(0,he.createContext)(kr),sg=({title:t,src:e})=>{let o=(0,he.useContext)(Dn),[n,s]=(0,he.useState)(!1);return(0,he.useEffect)(()=>{s(!1)},[e]),(0,Pt.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,Pt.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,Pt.jsx)(Nn,{})})},rg=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,he.useContext)(Dn);return(0,Pt.jsx)("div",{className:(0,On.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},ig=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,he.useContext)(Dn);return he.default.createElement(t,{className:(0,On.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Hn=({children:t})=>{let e=y("Card",kr);return(0,Pt.jsx)("div",{className:(0,On.default)(e.root),children:(0,Pt.jsx)(Dn.Provider,{value:e,children:t})})};Hn.Image=sg;Hn.Content=rg;Hn.Title=ig;var F=Hn;var ma=E(require("classnames"));var ga={root:"_root_cq1yq_1"};var fa=require("react/jsx-runtime");var ag={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},lg=({className:t,keyCode:e,...o})=>{let n=y("KeyboardHint",ga);return(0,fa.jsx)("span",{"data-key":ag[e],className:(0,ma.default)(t,n.root),...o})},Bn=lg;var ya=E(require("classnames"));var ha={root:"_root_4a08n_1"};var va=require("react/jsx-runtime"),cg=({className:t,children:e,...o})=>{let n=y("Label",ha);return(0,va.jsx)("span",{...o,className:(0,ya.default)(t,n.root),children:e})},Fn=cg;var Sa={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var to=require("react/jsx-runtime"),pg=({title:t,children:e,type:o,...n})=>{let s=y("Section",Sa);return(0,to.jsxs)("section",{...n,className:s.root,"data-section-type":o,children:[t&&(0,to.jsx)("div",{className:s.subTitleContainer,children:(0,to.jsx)("span",{className:s.subtitle,children:t})}),(0,to.jsx)("div",{className:s.suggestions,children:e})]})},pt=pg;var xa=E(require("classnames")),ba=E(require("react"));var _a={root:"_root_19wxp_1"};var Ca=require("react/jsx-runtime"),dg=ba.default.forwardRef(({className:t,children:e},o)=>{let n=y("SectionList",_a);return(0,Ca.jsx)("div",{ref:o,className:(0,xa.default)(n.root,t),children:e})}),Kn=dg;var Ho=E(require("classnames")),ve=E(require("react"));var Ir={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"};var ye=require("react/jsx-runtime"),oo=(0,ve.createContext)(Ir),ug=({fixed:t,children:e,...o})=>{let n=(0,ve.useContext)(oo);return(0,ye.jsx)("div",{...o,className:(0,Ho.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},gg=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,ve.useContext)(oo);return(0,ye.jsxs)("div",{className:(0,Ho.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,(0,ye.jsx)("ul",{className:r.dropdownList,children:s})]})},mg=({index:t,label:e,onClick:o})=>{let n=(0,ve.useContext)(oo);return(0,ye.jsx)("li",{className:n.dropdownItem,children:(0,ye.jsx)("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},fg=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,ve.useContext)(oo);return(0,ye.jsx)("button",{type:"button",className:(0,Ho.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},Rr=({labels:t})=>{let e=(0,ve.useContext)(oo);return(0,ye.jsx)("div",{className:e.labels,children:t.map(o=>(0,ye.jsx)("span",{className:e.label,children:o},o))})},no=ve.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=y("Suggestion",Ir),l=(0,ve.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,ye.jsx)(s,{...r,ref:i,className:(0,Ho.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,ye.jsx)(oo.Provider,{value:a,children:n})})});no.Labels=Rr;no.Actions=ug;no.ActionButton=fg;no.DropdownButton=gg;no.DropdownItem=mg;var O=no;var Ta=E(require("classnames"));var wa={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var Ea=require("react/jsx-runtime"),hg=({withDivider:t,children:e})=>{let o=y("SuggestionList",wa);return(0,Ea.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,Ta.default)(o.root,{[o.isWithDivider]:t}),children:e})},Se=hg;var Ia=E(require("classnames"));var ka={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var Un=require("react/jsx-runtime"),yg=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",ka);return(0,Un.jsx)("button",{type:"button",className:(0,Ia.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,Un.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,Un.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},At=yg;var Ra=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,so=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Pa=/x-deepdesk-(([a-z0-9\-_])+-version)/,Ee=(f=>(f.SEARCH="search",f.TEMPLATE="template",f.ELASTIC_SEARCH="search-autocomplete",f.GPT="gpt",f.TRIE="trie",f.TRIE_WITH_TYPOS="trie-with-typos",f.SEMANTIC="semantic",f.TEXT_RECOMMENDATION="text_recommendation",f.URL_RECOMMENDATION="url_recommendation",f.LINK_RECOMMENDATION="link_recommendation",f.PERSONAL_COLLECTION="personal-collection",f.PERSONAL_COLLECTION_SEARCH="personal-collection-search",f.SEARCH_OVERLAY="search-overlay",f.SEARCH_PREVIEW="search-preview",f.SEARCH_URL="search-url",f))(Ee||{}),dt=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(dt||{});var we=require("react-dom");var Cp=require("react");var Aa=require("@reduxjs/toolkit"),La=require("react-redux");var Bo=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Bo||{});var vg={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"},Ma=(0,Aa.createSlice)({name:"settings",initialState:vg,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:Fo}=Ma.actions,Pr=t=>e=>e.settings[t],C=t=>(0,La.useSelector)(Pr(t)),Na=Ma.reducer;var Fc=require("react"),wo=require("react-redux");var He=require("@reduxjs/toolkit"),Fa=require("diff"),Ka=require("react-redux");function Oa(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function ut(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)=>ut(r,e[i],o-1)):Oa(t)&&Oa(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>ut(t[i],e[i],o-1)):!1}function Sg(t){return Math.max(...t.map(e=>e.length))}function _g(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 Da(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Sg(n);s++){let r=_g(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 xg=2;function Ar(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=Da(t,xg);return o&&o.text!==e?o:t[0]}var ke=require("@reduxjs/toolkit");var bg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},w=bg;var Ha={current:null,isSupported:null},N=(0,ke.createAction)("resetConversation"),zn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},jn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},ro=t=>t.conversation.isSupported,Lr=(0,ke.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Vn=(0,ke.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),qn=(0,ke.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Wn=(0,ke.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=jn(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),Mr=(0,ke.createAsyncThunk)("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})})}),$n=(0,ke.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=jn(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Cg=[Vn.rejected,qn.rejected,Wn.rejected,$n.rejected].map(t=>t==null?void 0:t.toString()),wg=(0,ke.createSlice)({name:"conversation",initialState:Ha,reducers:{},extraReducers:t=>{t.addCase(Lr.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Vn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(qn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Mr.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Wn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase($n.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(N,()=>Ha).addMatcher(e=>Cg.includes(e.type),(e,o)=>{var n;throw w.info("Conversation action rejected",o.type,((n=o.error)==null?void 0:n.message)||"No message"),new Error(o.error.message)})}}),Ba=wg.reducer;var gt={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 Xn(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 Zn=(0,He.createAction)("input/replaceText"),Qn=(0,He.createAction)("input/keyDown"),Lt=(0,He.createAction)("input/sendMessage"),Jn=(0,He.createAction)("input/sendEditSuggestionMessage"),Yn=(0,He.createAction)("input/uiInputChange"),es=(0,He.createAction)("input/applyImageSuggestion"),Q=(0,He.createAction)("input/sendEvent");function Gn(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",g=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(d||p==="selection")&&(g=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(g=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:g,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 Ua=t=>(0,He.createSlice)({name:t,initialState:gt,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,{...gt,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=Ar(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(ut(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Gn(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:g,metaKey:u,altKey:m}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:f}=e,{text:h}=o.payload,k=(0,Fa.diffChars)(f,h);f.length-h.length>1&&e.metrics.deletions.push(...k.filter(_=>_.removed).map(_=>_.value)),e.metrics.numCharsDeleted+=f.length-h.length;break}case"C":case"V":case"X":if(!g&&!u){e.metrics.numCharsTyped+=1;let f=((i=e.selection)==null?void 0:i.start)!==void 0&&((a=e.selection)==null?void 0:a.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}break;case"Shift":break;default:if(!g&&!u&&!m){e.metrics.numCharsTyped+=1;let f=((l=e.selection)==null?void 0:l.start)!==void 0&&((c=e.selection)==null?void 0:c.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=gt.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Gn(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"&&Gn(e)},commitSuggestion(e){Gn(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=Ar(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(N,o=>{o.tabCompletionSuggestion=gt.tabCompletionSuggestion,o.previousKeyDownEvent=gt.previousKeyDownEvent,o.textSuggestions=gt.textSuggestions,o.selectedSuggestionIndex=gt.selectedSuggestionIndex,o.metrics=gt.metrics})}}),Nr=Ua("input"),io=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),Tg=t=>t.input.selection,za=()=>(0,Ka.useSelector)(Tg),{userInput:ja,changeSelection:Or,initialInput:Va,mergeMetrics:qa,nextTextSuggestionIndex:Wa,offeredTextSuggestion:$a,previousTextSuggestionIndex:Ga,registerCut:Xa,registerKeyDown:Za,registerPaste:Qa,reset:Ja,resetToCommitted:Ko,platformInput:Ya,setSelectedTextSuggestionIndex:mt,setTextSuggestions:Be,stageSuggestion:Ie,commitSuggestion:qe,setMetrics:el}=Nr.actions,ae=Ua("overlay");var ao=require("react");var tl={root:"_root_1h19b_1",content:"_content_1h19b_24"};var Dr=require("react/jsx-runtime"),Eg=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=(0,ao.useRef)(null),l=(0,ao.useRef)(null),c=y("Dialog",tl);return(0,ao.useEffect)(()=>{var g,u;let p=m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),s())},d=m=>{let f=window.getSelection();f!=null&&f.toString()||m.target===a.current&&t&&n()};return(g=a.current)==null||g.addEventListener("click",d),(u=a.current)==null||u.addEventListener("keyup",p),()=>{var m,f;(m=a.current)==null||m.removeEventListener("click",d),(f=a.current)==null||f.removeEventListener("keyup",p)}},[a,l,s,n]),(0,ao.useEffect)(()=>{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?(0,Dr.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,Dr.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},lo=Eg;var gi=require("react"),Ls=require("react-redux");var Hr={};G(Hr,{enUS:()=>kg,nlNL:()=>Ig});var kg={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?"}]},Ig={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 ol={root:"_root_jcr8j_1",content:"_content_jcr8j_3",title:"_title_jcr8j_7",actions:"_actions_jcr8j_15",pagination:"_pagination_jcr8j_19",primaryButton:"_primaryButton_jcr8j_50",primaryButtons:"_primaryButtons_jcr8j_54"};var ms=require("react");var Br=function(t,e){return Br=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])},Br(t,e)};function Uo(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Br(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var de=function(){return de=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},de.apply(this,arguments)};function nl(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 ts(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 os;(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"})(os||(os={}));var ns=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Re;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(Re||(Re={}));var ss;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(ss||(ss={}));function Fr(t){return t.type===Re.literal}function sl(t){return t.type===Re.argument}function rs(t){return t.type===Re.number}function is(t){return t.type===Re.date}function as(t){return t.type===Re.time}function ls(t){return t.type===Re.select}function cs(t){return t.type===Re.plural}function rl(t){return t.type===Re.pound}function ps(t){return t.type===Re.tag}function ds(t){return!!(t&&typeof t=="object"&&t.type===ss.number)}function zo(t){return!!(t&&typeof t=="object"&&t.type===ss.dateTime)}function Kr(t){t.forEach(function(e){if(delete e.location,ls(e)||cs(e))for(var o in e.options)delete e.options[o].location,Kr(e.options[o].value);else rs(e)&&ds(e.style)||(is(e)||as(e))&&zo(e.style)?delete e.style.location:ps(e)&&Kr(e.children)})}function il(t,e){e===void 0&&(e={}),e=de({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new ns(t,e).parse();if(o.err){var n=SyntaxError(os[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||Kr(o.val),o.val}function us(t,e){var o=e&&e.cache?e.cache:Ng,n=e&&e.serializer?e.serializer:Mg,s=e&&e.strategy?e.strategy:Pg;return s(t,{cache:o,serializer:n})}function Rg(t){return t==null||typeof t=="number"||typeof t=="boolean"}function al(t,e,o,n){var s=Rg(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function ll(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 Ur(t,e,o,n,s){return o.bind(e,t,n,s)}function Pg(t,e){var o=t.length===1?al:ll;return Ur(t,this,o,e.cache.create(),e.serializer)}function Ag(t,e){return Ur(t,this,ll,e.cache.create(),e.serializer)}function Lg(t,e){return Ur(t,this,al,e.cache.create(),e.serializer)}var Mg=function(){return JSON.stringify(arguments)};function zr(){this.cache=Object.create(null)}zr.prototype.get=function(t){return this.cache[t]};zr.prototype.set=function(t,e){this.cache[t]=e};var Ng={create:function(){return new zr}},gs={variadic:Ag,monadic:Lg};var Mt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Mt||(Mt={}));var jo=function(t){Uo(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 jr=function(t){Uo(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('", "'),'"'),Mt.INVALID_VALUE,r)||this}return e}(jo);var cl=function(t){Uo(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),Mt.INVALID_VALUE,s)||this}return e}(jo);var pl=function(t){Uo(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,'"'),Mt.MISSING_VALUE,n)||this}return e}(jo);var J;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(J||(J={}));function Og(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==J.literal||o.type!==J.literal?e.push(o):n.value+=o.value,e},[])}function Dg(t){return typeof t=="function"}function Vo(t,e,o,n,s,r,i){if(t.length===1&&Fr(t[0]))return[{type:J.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(Fr(p)){a.push({type:J.literal,value:p.value});continue}if(rl(p)){typeof r=="number"&&a.push({type:J.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new pl(d,i);var g=s[d];if(sl(p)){(!g||typeof g=="string"||typeof g=="number")&&(g=typeof g=="string"||typeof g=="number"?String(g):""),a.push({type:typeof g=="string"?J.literal:J.object,value:g});continue}if(is(p)){var u=typeof p.style=="string"?n.date[p.style]:zo(p.style)?p.style.parsedOptions:void 0;a.push({type:J.literal,value:o.getDateTimeFormat(e,u).format(g)});continue}if(as(p)){var u=typeof p.style=="string"?n.time[p.style]:zo(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:J.literal,value:o.getDateTimeFormat(e,u).format(g)});continue}if(rs(p)){var u=typeof p.style=="string"?n.number[p.style]:ds(p.style)?p.style.parsedOptions:void 0;u&&u.scale&&(g=g*(u.scale||1)),a.push({type:J.literal,value:o.getNumberFormat(e,u).format(g)});continue}if(ps(p)){var m=p.children,f=p.value,h=s[f];if(!Dg(h))throw new cl(f,"function",i);var k=Vo(m,e,o,n,s,r),_=h(k.map(function(v){return v.value}));Array.isArray(_)||(_=[_]),a.push.apply(a,_.map(function(v){return{type:typeof v=="string"?J.literal:J.object,value:v}}))}if(ls(p)){var x=p.options[g]||p.options.other;if(!x)throw new jr(p.value,g,Object.keys(p.options),i);a.push.apply(a,Vo(x.value,e,o,n,s));continue}if(cs(p)){var x=p.options["=".concat(g)];if(!x){if(!Intl.PluralRules)throw new jo(`Intl.PluralRules is not available in this environment.
1
+ "use strict";var dg=Object.create;var Hn=Object.defineProperty;var ug=Object.getOwnPropertyDescriptor;var gg=Object.getOwnPropertyNames;var mg=Object.getPrototypeOf,fg=Object.prototype.hasOwnProperty;var $=(t,e)=>{for(var o in e)Hn(t,o,{get:e[o],enumerable:!0})},va=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of gg(e))!fg.call(t,s)&&s!==o&&Hn(t,s,{get:()=>e[s],enumerable:!(n=ug(e,s))||n.enumerable});return t};var k=(t,e,o)=>(o=t!=null?dg(mg(t)):{},va(e||!t||!t.__esModule?Hn(o,"default",{value:t,enumerable:!0}):o,t)),hg=t=>va(Hn({},"__esModule",{value:!0}),t);var Wh={};$(Wh,{Card:()=>D,ContentEditableInput:()=>eo,DeepdeskAPI:()=>ut,DeepdeskSDK:()=>Mn,HTTPClient:()=>De,InputMediator:()=>Ge,InputType:()=>gt,KeyboardHint:()=>jn,Label:()=>Vn,Locale:()=>Vo,Section:()=>qe,SectionList:()=>qn,Sources:()=>ke,Suggestion:()=>L,SuggestionList:()=>de,TextAreaInput:()=>Xe,ToggleButton:()=>Mt,attachFile:()=>eg,authenticateWithKey:()=>Ju,createFullRange:()=>Ho,createOverlayContainer:()=>Ht,createRangeFromOffsets:()=>Pt,escapeHTML:()=>vo,fetchPlatformConfig:()=>Yu,formatTextMarkup:()=>Qu,getRangeOffsets:()=>In,getRangeText:()=>Pn,insertCKEditor:()=>Zu,isHTML:()=>Bt,isSupportedInputElement:()=>Pr,updateContentEditable:()=>Gu,updateTextArea:()=>$u,useStyles:()=>y,waitForElementVisibilityChange:()=>Ar});module.exports=hg(Wh);var Kn=k(require("classnames")),ve=k(require("react"));var Bn=k(require("react")),Sa=k(require("classnames")),zo=Bn.default.createContext({});function y(t,e){let{debug:o,...n}=(0,Bn.useContext)(zo),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,Sa.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var _a={root:"_root_vr71j_1"};var At=require("react/jsx-runtime"),Fn=()=>(0,At.jsxs)("svg",{className:_a.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,At.jsx)("defs",{children:(0,At.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,At.jsx)("title",{children:"Failed loading image"}),(0,At.jsx)("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 Mr={root:"_root_1yiwn_1",imageWrapper:"_imageWrapper_1yiwn_7",image:"_image_1yiwn_7",content:"_content_1yiwn_24",title:"_title_1yiwn_35",contentIsCropped:"_contentIsCropped_1yiwn_45",lineClamp:"_lineClamp_1yiwn_51",expandOnHover:"_expandOnHover_1yiwn_58"};var Lt=require("react/jsx-runtime"),Un=(0,ve.createContext)(Mr),yg=({title:t,src:e})=>{let o=(0,ve.useContext)(Un),[n,s]=(0,ve.useState)(!1);return(0,ve.useEffect)(()=>{s(!1)},[e]),(0,Lt.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,Lt.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,Lt.jsx)(Fn,{})})},vg=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,ve.useContext)(Un);return(0,Lt.jsx)("div",{className:(0,Kn.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Sg=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,ve.useContext)(Un);return ve.default.createElement(t,{className:(0,Kn.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},zn=({expandOnHover:t,children:e})=>{let o=y("Card",Mr);return(0,Lt.jsx)("div",{className:(0,Kn.default)(o.root,{[o.expandOnHover]:t}),children:(0,Lt.jsx)(Un.Provider,{value:o,children:e})})};zn.Image=yg;zn.Content=vg;zn.Title=Sg;var D=zn;var ba=k(require("classnames"));var xa={root:"_root_cq1yq_1"};var Ca=require("react/jsx-runtime");var _g={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},xg=({className:t,keyCode:e,...o})=>{let n=y("KeyboardHint",xa);return(0,Ca.jsx)("span",{"data-key":_g[e],className:(0,ba.default)(t,n.root),...o})},jn=xg;var Ta=k(require("classnames"));var wa={root:"_root_4a08n_1"};var Ea=require("react/jsx-runtime"),bg=({className:t,children:e,...o})=>{let n=y("Label",wa);return(0,Ea.jsx)("span",{...o,className:(0,Ta.default)(t,n.root),children:e})},Vn=bg;var ka={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var so=require("react/jsx-runtime"),Cg=({title:t,children:e,type:o,...n})=>{let s=y("Section",ka);return(0,so.jsxs)("section",{...n,className:s.root,"data-section-type":o,children:[t&&(0,so.jsx)("div",{className:s.subTitleContainer,children:(0,so.jsx)("span",{className:s.subtitle,children:t})}),(0,so.jsx)("div",{className:s.suggestions,children:e})]})},qe=Cg;var Ia=k(require("classnames")),Pa=k(require("react"));var Ra={root:"_root_19wxp_1"};var Aa=require("react/jsx-runtime"),wg=Pa.default.forwardRef(({className:t,children:e},o)=>{let n=y("SectionList",Ra);return(0,Aa.jsx)("div",{ref:o,className:(0,Ia.default)(n.root,t),children:e})}),qn=wg;var jo=k(require("classnames")),_e=k(require("react"));var Nr={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"};var Se=require("react/jsx-runtime"),ro=(0,_e.createContext)(Nr),Tg=({fixed:t,children:e,...o})=>{let n=(0,_e.useContext)(ro);return(0,Se.jsx)("div",{...o,className:(0,jo.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},Eg=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,_e.useContext)(ro);return(0,Se.jsxs)("div",{className:(0,jo.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,(0,Se.jsx)("ul",{className:r.dropdownList,children:s})]})},kg=({index:t,label:e,onClick:o})=>{let n=(0,_e.useContext)(ro);return(0,Se.jsx)("li",{className:n.dropdownItem,children:(0,Se.jsx)("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Rg=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,_e.useContext)(ro);return(0,Se.jsx)("button",{type:"button",className:(0,jo.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},Or=({labels:t})=>{let e=(0,_e.useContext)(ro);return(0,Se.jsx)("div",{className:e.labels,children:t.map(o=>(0,Se.jsx)("span",{className:e.label,children:o},o))})},io=_e.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=y("Suggestion",Nr),l=(0,_e.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,Se.jsx)(s,{...r,ref:i,className:(0,jo.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,Se.jsx)(ro.Provider,{value:a,children:n})})});io.Labels=Or;io.Actions=Tg;io.ActionButton=Rg;io.DropdownButton=Eg;io.DropdownItem=kg;var L=io;var Ma=k(require("classnames"));var La={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var Na=require("react/jsx-runtime"),Ig=({withDivider:t,children:e})=>{let o=y("SuggestionList",La);return(0,Na.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,Ma.default)(o.root,{[o.isWithDivider]:t}),children:e})},de=Ig;var Da=k(require("classnames"));var Oa={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var Wn=require("react/jsx-runtime"),Pg=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",Oa);return(0,Wn.jsx)("button",{type:"button",className:(0,Da.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,Wn.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,Wn.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Mt=Pg;var Ha=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,ao=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Ba=/x-deepdesk-(([a-z0-9\-_])+-version)/,ke=(f=>(f.SEARCH="search",f.TEMPLATE="template",f.ELASTIC_SEARCH="search-autocomplete",f.GPT="gpt",f.TRIE="trie",f.TRIE_WITH_TYPOS="trie-with-typos",f.SEMANTIC="semantic",f.TEXT_RECOMMENDATION="text_recommendation",f.URL_RECOMMENDATION="url_recommendation",f.LINK_RECOMMENDATION="link_recommendation",f.PERSONAL_COLLECTION="personal-collection",f.PERSONAL_COLLECTION_SEARCH="personal-collection-search",f.SEARCH_OVERLAY="search-overlay",f.SEARCH_PREVIEW="search-preview",f.SEARCH_URL="search-url",f))(ke||{}),gt=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(gt||{});var Te=require("react-dom");var Np=require("react");var Fa=require("@reduxjs/toolkit"),Ka=require("react-redux");var Vo=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Vo||{});var Ag={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"},Ua=(0,Fa.createSlice)({name:"settings",initialState:Ag,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:qo}=Ua.actions,Dr=t=>e=>e.settings[t],C=t=>(0,Ka.useSelector)(Dr(t)),za=Ua.reducer;var Zc=require("react"),Ro=require("react-redux");var He=require("@reduxjs/toolkit"),$a=require("diff"),Ga=require("react-redux");function ja(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function mt(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)=>mt(r,e[i],o-1)):ja(t)&&ja(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>mt(t[i],e[i],o-1)):!1}function Lg(t){return Math.max(...t.map(e=>e.length))}function Mg(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 Va(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Lg(n);s++){let r=Mg(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 Ng=2;function Hr(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=Va(t,Ng);return o&&o.text!==e?o:t[0]}var Re=require("@reduxjs/toolkit");var Og={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},w=Og;var qa={current:null,isSupported:null},M=(0,Re.createAction)("resetConversation"),$n=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Gn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},lo=t=>t.conversation.isSupported,Br=(0,Re.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Xn=(0,Re.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Zn=(0,Re.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Qn=(0,Re.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Gn(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),Fr=(0,Re.createAsyncThunk)("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})})}),Jn=(0,Re.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Gn(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Dg=[Xn.rejected,Zn.rejected,Qn.rejected,Jn.rejected].map(t=>t==null?void 0:t.toString()),Hg=(0,Re.createSlice)({name:"conversation",initialState:qa,reducers:{},extraReducers:t=>{t.addCase(Br.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Xn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Zn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Fr.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Qn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Jn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(M,()=>qa).addMatcher(e=>Dg.includes(e.type),(e,o)=>{var n;throw w.info("Conversation action rejected",o.type,((n=o.error)==null?void 0:n.message)||"No message"),new Error(o.error.message)})}}),Wa=Hg.reducer;var ft={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 es(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 ts=(0,He.createAction)("input/replaceText"),os=(0,He.createAction)("input/keyDown"),Nt=(0,He.createAction)("input/sendMessage"),ns=(0,He.createAction)("input/sendEditSuggestionMessage"),ss=(0,He.createAction)("input/uiInputChange"),rs=(0,He.createAction)("input/applyImageSuggestion"),Q=(0,He.createAction)("input/sendEvent");function Yn(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",g=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(d||p==="selection")&&(g=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(g=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:g,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 Xa=t=>(0,He.createSlice)({name:t,initialState:ft,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,{...ft,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=Hr(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(mt(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Yn(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:g,metaKey:u,altKey:m}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:f}=e,{text:h}=o.payload,E=(0,$a.diffChars)(f,h);f.length-h.length>1&&e.metrics.deletions.push(...E.filter(x=>x.removed).map(x=>x.value)),e.metrics.numCharsDeleted+=f.length-h.length;break}case"C":case"V":case"X":if(!g&&!u){e.metrics.numCharsTyped+=1;let f=((i=e.selection)==null?void 0:i.start)!==void 0&&((a=e.selection)==null?void 0:a.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}break;case"Shift":break;default:if(!g&&!u&&!m){e.metrics.numCharsTyped+=1;let f=((l=e.selection)==null?void 0:l.start)!==void 0&&((c=e.selection)==null?void 0:c.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=ft.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Yn(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"&&Yn(e)},commitSuggestion(e){Yn(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=Hr(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(M,o=>{o.tabCompletionSuggestion=ft.tabCompletionSuggestion,o.previousKeyDownEvent=ft.previousKeyDownEvent,o.textSuggestions=ft.textSuggestions,o.selectedSuggestionIndex=ft.selectedSuggestionIndex,o.metrics=ft.metrics})}}),Kr=Xa("input"),co=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),Bg=t=>t.input.selection,Za=()=>(0,Ga.useSelector)(Bg),{userInput:Qa,changeSelection:Ur,initialInput:Ja,mergeMetrics:Ya,nextTextSuggestionIndex:el,offeredTextSuggestion:tl,previousTextSuggestionIndex:ol,registerCut:nl,registerKeyDown:sl,registerPaste:rl,reset:il,resetToCommitted:Wo,platformInput:al,setSelectedTextSuggestionIndex:ht,setTextSuggestions:Be,stageSuggestion:Ie,commitSuggestion:We,setMetrics:ll}=Kr.actions,ae=Xa("overlay");var po=require("react");var cl={root:"_root_1h19b_1",content:"_content_1h19b_24"};var zr=require("react/jsx-runtime"),Fg=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=(0,po.useRef)(null),l=(0,po.useRef)(null),c=y("Dialog",cl);return(0,po.useEffect)(()=>{var g,u;let p=m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),s())},d=m=>{let f=window.getSelection();f!=null&&f.toString()||m.target===a.current&&t&&n()};return(g=a.current)==null||g.addEventListener("click",d),(u=a.current)==null||u.addEventListener("keyup",p),()=>{var m,f;(m=a.current)==null||m.removeEventListener("click",d),(f=a.current)==null||f.removeEventListener("keyup",p)}},[a,l,s,n]),(0,po.useEffect)(()=>{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?(0,zr.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,zr.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},uo=Fg;var Si=require("react"),Hs=require("react-redux");var jr={};$(jr,{enUS:()=>Kg,nlNL:()=>Ug});var Kg={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?"}]},Ug={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 pl={root:"_root_jcr8j_1",content:"_content_jcr8j_3",title:"_title_jcr8j_7",actions:"_actions_jcr8j_15",pagination:"_pagination_jcr8j_19",primaryButton:"_primaryButton_jcr8j_50",primaryButtons:"_primaryButtons_jcr8j_54"};var Ss=require("react");var Vr=function(t,e){return Vr=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])},Vr(t,e)};function $o(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Vr(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var ue=function(){return ue=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},ue.apply(this,arguments)};function dl(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 is(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 as;(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"})(as||(as={}));var ls=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Pe;(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"})(Pe||(Pe={}));var cs;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(cs||(cs={}));function qr(t){return t.type===Pe.literal}function ul(t){return t.type===Pe.argument}function ps(t){return t.type===Pe.number}function ds(t){return t.type===Pe.date}function us(t){return t.type===Pe.time}function gs(t){return t.type===Pe.select}function ms(t){return t.type===Pe.plural}function gl(t){return t.type===Pe.pound}function fs(t){return t.type===Pe.tag}function hs(t){return!!(t&&typeof t=="object"&&t.type===cs.number)}function Go(t){return!!(t&&typeof t=="object"&&t.type===cs.dateTime)}function Wr(t){t.forEach(function(e){if(delete e.location,gs(e)||ms(e))for(var o in e.options)delete e.options[o].location,Wr(e.options[o].value);else ps(e)&&hs(e.style)||(ds(e)||us(e))&&Go(e.style)?delete e.style.location:fs(e)&&Wr(e.children)})}function ml(t,e){e===void 0&&(e={}),e=ue({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new ls(t,e).parse();if(o.err){var n=SyntaxError(as[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||Wr(o.val),o.val}function ys(t,e){var o=e&&e.cache?e.cache:$g,n=e&&e.serializer?e.serializer:Wg,s=e&&e.strategy?e.strategy:jg;return s(t,{cache:o,serializer:n})}function zg(t){return t==null||typeof t=="number"||typeof t=="boolean"}function fl(t,e,o,n){var s=zg(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function hl(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 $r(t,e,o,n,s){return o.bind(e,t,n,s)}function jg(t,e){var o=t.length===1?fl:hl;return $r(t,this,o,e.cache.create(),e.serializer)}function Vg(t,e){return $r(t,this,hl,e.cache.create(),e.serializer)}function qg(t,e){return $r(t,this,fl,e.cache.create(),e.serializer)}var Wg=function(){return JSON.stringify(arguments)};function Gr(){this.cache=Object.create(null)}Gr.prototype.get=function(t){return this.cache[t]};Gr.prototype.set=function(t,e){this.cache[t]=e};var $g={create:function(){return new Gr}},vs={variadic:Vg,monadic:qg};var Ot;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Ot||(Ot={}));var Xo=function(t){$o(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 Xr=function(t){$o(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('", "'),'"'),Ot.INVALID_VALUE,r)||this}return e}(Xo);var yl=function(t){$o(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),Ot.INVALID_VALUE,s)||this}return e}(Xo);var vl=function(t){$o(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,'"'),Ot.MISSING_VALUE,n)||this}return e}(Xo);var J;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(J||(J={}));function Gg(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==J.literal||o.type!==J.literal?e.push(o):n.value+=o.value,e},[])}function Xg(t){return typeof t=="function"}function Zo(t,e,o,n,s,r,i){if(t.length===1&&qr(t[0]))return[{type:J.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(qr(p)){a.push({type:J.literal,value:p.value});continue}if(gl(p)){typeof r=="number"&&a.push({type:J.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new vl(d,i);var g=s[d];if(ul(p)){(!g||typeof g=="string"||typeof g=="number")&&(g=typeof g=="string"||typeof g=="number"?String(g):""),a.push({type:typeof g=="string"?J.literal:J.object,value:g});continue}if(ds(p)){var u=typeof p.style=="string"?n.date[p.style]:Go(p.style)?p.style.parsedOptions:void 0;a.push({type:J.literal,value:o.getDateTimeFormat(e,u).format(g)});continue}if(us(p)){var u=typeof p.style=="string"?n.time[p.style]:Go(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:J.literal,value:o.getDateTimeFormat(e,u).format(g)});continue}if(ps(p)){var u=typeof p.style=="string"?n.number[p.style]:hs(p.style)?p.style.parsedOptions:void 0;u&&u.scale&&(g=g*(u.scale||1)),a.push({type:J.literal,value:o.getNumberFormat(e,u).format(g)});continue}if(fs(p)){var m=p.children,f=p.value,h=s[f];if(!Xg(h))throw new yl(f,"function",i);var E=Zo(m,e,o,n,s,r),x=h(E.map(function(v){return v.value}));Array.isArray(x)||(x=[x]),a.push.apply(a,x.map(function(v){return{type:typeof v=="string"?J.literal:J.object,value:v}}))}if(gs(p)){var _=p.options[g]||p.options.other;if(!_)throw new Xr(p.value,g,Object.keys(p.options),i);a.push.apply(a,Zo(_.value,e,o,n,s));continue}if(ms(p)){var _=p.options["=".concat(g)];if(!_){if(!Intl.PluralRules)throw new Xo(`Intl.PluralRules is not available in this environment.
2
2
  Try polyfilling it using "@formatjs/intl-pluralrules"
3
- `,Mt.MISSING_INTL_API,i);var b=o.getPluralRules(e,{type:p.pluralType}).select(g-(p.offset||0));x=p.options[b]||p.options.other}if(!x)throw new jr(p.value,g,Object.keys(p.options),i);a.push.apply(a,Vo(x.value,e,o,n,s,g-(p.offset||0)));continue}}return Og(a)}function Hg(t,e){return e?de(de(de({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=de(de({},t[n]),e[n]||{}),o},{})):t}function Bg(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Hg(t[n],e[n]),o},de({},t)):t}function Vr(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Fg(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:us(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,ts([void 0],o,!1)))},{cache:Vr(t.number),strategy:gs.variadic}),getDateTimeFormat:us(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,ts([void 0],o,!1)))},{cache:Vr(t.dateTime),strategy:gs.variadic}),getPluralRules:us(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,ts([void 0],o,!1)))},{cache:Vr(t.pluralRules),strategy:gs.variadic})}}var dl=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(g,u){return!g.length||u.type!==J.literal||typeof g[g.length-1]!="string"?g.push(u.value):g[g.length-1]+=u.value,g},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return Vo(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=nl(i,["formatters"]);this.ast=t.__parse(e,de(de({},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=Bg(t.formats,n),this.formatters=s&&s.formatters||Fg(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=il,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 Kg(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var Ug="dummy",qr=(0,ms.createContext)(null);function T(t){let e=(0,ms.useContext)(qr);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=Kg(o,n);return r?new dl(r).format(s):(e!==Ug&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var qo=require("react/jsx-runtime"),fs=()=>(0,qo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,qo.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,qo.jsx)("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"})]});var Wo=require("react/jsx-runtime"),ul=()=>(0,Wo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,Wo.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,Wo.jsx)("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"})]});var _e=require("react"),Ml=require("react-redux"),ti=require("interweave"),oi=E(require("classnames"));var Wr={root:"_root_smoda_1",agentText:"_agentText_smoda_3",textInput:"_textInput_smoda_8",textInputWrapper:"_textInputWrapper_smoda_27",alert:"_alert_smoda_31",alertText:"_alertText_smoda_50",warning:"_warning_smoda_60",success:"_success_smoda_69"};var ml=require("interweave"),fl=E(require("classnames"));var co=require("react");function gl(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function hs(t){let e=(0,co.useRef)(null),[o,n]=(0,co.useState)(!1);return(0,co.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=gl((p,d)=>{let g=e.current;if(!g)return;let u=p/r,m=d/r,f=g.getBoundingClientRect(),h=u>f.x&&u<f.x+f.width&&m>f.y&&m<f.y+f.height;h&&!s?(s=!0,n(!0)):!h&&s&&(s=!1,n(!1))},({clientX:p,clientY:d})=>[p,d]),[l,c]=gl(()=>{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 We={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"};var $r=require("react/jsx-runtime"),zg=({inputElement:t,children:e})=>{let o=y("TabCompletion",We),[n,s]=hs(t);return(0,$r.jsx)("mark",{ref:n,className:(0,fl.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},po=class extends ml.Matcher{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(0,$r.jsx)(zg,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var uo=require("react");function ys(t){return t.contentEditable==="true"}function jg(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 hl(t){let{selectionStart:e,selectionEnd:o}=ys(t)?jg(t):t;return[e,o]}function vs(t){let[,e]=(0,uo.useState)(),o=(0,uo.useRef)(null);return o.current=hl(t),(0,uo.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=hl(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 Ss(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(so);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)})}var yl=require("react");function go(t){(0,yl.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Nt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var vl,Fe=new Map,Vg=["bottom","height","left","right","top","width"],qg=(t={},e={})=>Vg.some(o=>t[o]!==e[o]);function Sl(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,...Sl(e)]:[]}function _l(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var _s=!1,xl=()=>{_s=!0;let t=[];if(Fe.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),Fe.delete(o);return}let n=o.getBoundingClientRect();qg(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(_l,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),Fe.size===0){_s=!1;return}vl=window.requestAnimationFrame(xl)};function Gr(t,e){let o=Sl(t),n=[],s=o.map((r,i)=>Gr(r,a=>{n[i]=a;let l=Fe.get(t);if(!l)return;let c=n.reduce(_l,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),Fe.has(t)){let i=Fe.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Fe.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!_s&&xl()},unobserve(){s.forEach(i=>i.unobserve());let r=Fe.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||Fe.delete(t),Fe.size||(cancelAnimationFrame(vl),_s=!1)}}}}var bl,Ke=new Map,Cl=()=>{Ke.forEach((t,e)=>{if(!e.isConnected){Ke.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)))}),Ke.size!==0&&(bl=window.requestAnimationFrame(Cl))};function wl(t,e){return{observe(){let o=Ke.size===0;Ke.has(t)?Ke.get(t).callbacks.push(e):Ke.set(t,{visible:void 0,callbacks:[e]}),o&&Cl()},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(bl)}}}}var Xr=["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 Zr(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function mo(t){return parseFloat(t)}function xs(t){return Math.round(t*1e6)}function Tl(t){return t/1e6}function Qr(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=mo(t.width),r=mo(t.borderLeftWidth),i=mo(t.borderRightWidth),a=mo(t.paddingRight),l=Tl(xs(s)-xs(r)-xs(i)),c=Tl(xs(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function Ot(t,e={}){var p;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",Nt(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Zr(n,o,Xr),Qr(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=wl(t,()=>{Zr(n,o,Xr),Qr(n,t,o),r(),setTimeout(r,0)}),a,l=!0,c=Gr(t,d=>{if(d===null){e.onRemove&&e.onRemove(),o.remove();return}if(!l&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Zr(n,o,Xr),Qr(n,t,o),r(),o.style.top=`${d.top}px`,o.style.left=`${d.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let g=e.closestScrollElement.getBoundingClientRect(),u=window.getComputedStyle(e.closestScrollElement),m=mo(u.borderTopWidth),f=mo(u.borderBottomWidth),h=g.top+m-d.top,k=d.top+d.height+-(g.top+g.height-f);o.style.clipPath=`inset(${h}px 0px ${k}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(p=t.parentElement)==null||p.appendChild(o),c.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),c.unobserve(),i.unobserve()}]}var Jr={};G(Jr,{enUS:()=>Wg,nlNL:()=>$g});var Wg={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"}]},$g={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"}]};var $o=require("react/jsx-runtime"),El=()=>(0,$o.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,$o.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,$o.jsx)("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"})]});var Yr=require("react/jsx-runtime"),kl=()=>(0,Yr.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Yr.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var Il=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(Il||{}),$e=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();ut(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(Il).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var n,s;let o=((n=e.clipboardData)==null?void 0:n.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",o=>this.handleKeyDown(o)),this.addEventListener("keyup",o=>this.handleKeyUp(o)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",o=>this.handlePaste(o)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()}),this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};var Ge=class extends $e{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 Gg=/[.*+?^${}()|[\]\\]/g,Xg=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function Zg(t){return t.replace(Gg,"\\$&")}function Qg(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function Jg(t){return t.search(Xg)}function Rl(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${Zg(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function Pl(t){return t.replace(so,'<mark data-type="placeholder">$1</mark>')}function fo(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Yg(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 ei(t,e,o={}){if(e){let n=Qg(e.toLowerCase(),t.toLowerCase()),s=fo(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=Jg(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(Ra).length>3||e.length>30?Yg(e.trim(),n):0;return`${`${i>0?"\u2026":""}${fo(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var em=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function Dt(t){return em.test(t)}function Al(t){if(Dt(t)){let o=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(t);return o?o[1]:""}return t}function Ll(t){let e=document.createElement("template");return e.innerHTML=t,e.content.textContent??""}var Y=require("react/jsx-runtime"),tm=({value:t,onUse:e,...o})=>{var d;let n=T(Jr),s=(0,Ml.useDispatch)(),r=Dt(t),i=y("EditSuggestionTextInput",Wr),[a,l]=(0,_e.useState)(null),c=(0,_e.useRef)(null),p=((d=t.match(so))==null?void 0:d.length)||0;return(0,_e.useEffect)(()=>{let g;return c.current&&(l(c.current),g=new Ge(c.current),g.on("change",({plainText:u})=>{s(ae.actions.userInput({text:u,selection:g.getSelection()}))}),g.on("keydown",u=>{s(ae.actions.registerKeyDown(Xn(u))),u.code==="Enter"&&u.shiftKey&&e(g.getText())}),g.on("paste",({pastedText:u,selectionText:m})=>{s(ae.actions.registerPaste({text:u,selectionText:m}))}),g.on("cut",({selectionText:u})=>{s(ae.actions.registerCut(u))})),()=>{s(ae.actions.reset()),g.dispose(),g.deactivate()}},[c]),(0,_e.useEffect)(()=>{t&&c.current&&(c.current.value=t)},[t,c]),(0,_e.useEffect)(()=>{c.current&&setTimeout(()=>{if(!c.current)return;let g=c.current.value.length;c.current.setSelectionRange(g,g),c.current.focus()},0)},[c]),r?(0,Y.jsx)("div",{className:i.textInputWrapper,children:(0,Y.jsx)(ti.Interweave,{className:i.textInput,tagName:"div",content:t})}):(0,Y.jsxs)("div",{className:i.textInputWrapper,children:[(0,Y.jsx)("textarea",{...o,ref:c,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:t,onChange:()=>{}}),a&&(0,Y.jsx)(om,{inputElement:c.current,value:t}),(0,Y.jsxs)("div",{className:(0,oi.default)(i.alert,p===0?i.success:i.warning),children:[(0,Y.jsx)("div",{className:i.alertText,children:n("placeholders",{placeholderSize:p})}),p===0?(0,Y.jsx)(El,{}):(0,Y.jsx)(kl,{})]})]})},om=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",Wr),n=(0,_e.useRef)(null),s=vs(t);return(0,_e.useEffect)(()=>{Ss(t,s)},[s,t]),(0,Y.jsx)(nm,{inputElement:t,children:(0,Y.jsxs)("div",{ref:n,className:(0,oi.default)(o.root,o.agentText),children:[(0,Y.jsx)(ti.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new po("placeholders")],inputElement:t,boundaryRef:n}),(0,Y.jsx)("br",{})]})})},nm=({inputElement:t,children:e})=>{let o=(0,_e.useRef)(null);return(0,_e.useEffect)(()=>{if(!o.current)return()=>{};let[n,s]=Ot(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),(0,Y.jsx)("div",{ref:o,children:e})},Nl=tm;var So=require("react");var Ol=require("react"),bs=E(require("classnames"));var le={root:"_root_1xflk_1",list:"_list_1xflk_2",listWrapper:"_listWrapper_1xflk_6",listHorizontal:"_listHorizontal_1xflk_10",page:"_page_1xflk_19",search:"_search_1xflk_25",pageNav:"_pageNav_1xflk_33",pageTitle:"_pageTitle_1xflk_41",pageBackButton:"_pageBackButton_1xflk_48",listHeader:"_listHeader_1xflk_62",listHeading:"_listHeading_1xflk_68",listMoreButton:"_listMoreButton_1xflk_76",listItem:"_listItem_1xflk_87",listItemContent:"_listItemContent_1xflk_96",listItemText:"_listItemText_1xflk_114",listItemDescription:"_listItemDescription_1xflk_122",listItemActions:"_listItemActions_1xflk_129",truncate:"_truncate_1xflk_140",lineClamp:"_lineClamp_1xflk_146",listItemTitle:"_listItemTitle_1xflk_153",listItemAction:"_listItemAction_1xflk_129",listItemPrimaryAction:"_listItemPrimaryAction_1xflk_174",listItemSelected:"_listItemSelected_1xflk_179",sources:"_sources_1xflk_183",sourcesTitle:"_sourcesTitle_1xflk_190",source:"_source_1xflk_183",icon:"_icon_1xflk_205",searchIcon:"_searchIcon_1xflk_222",searchInputWrapper:"_searchInputWrapper_1xflk_227",searchInput:"_searchInput_1xflk_227",select:"_select_1xflk_248",selectType:"_selectType_1xflk_265",selectWrapper:"_selectWrapper_1xflk_269",image:"_image_1xflk_299",imageSrc:"_imageSrc_1xflk_306",imageSrcHidden:"_imageSrcHidden_1xflk_317",imageSrcStatus:"_imageSrcStatus_1xflk_321",imageTitle:"_imageTitle_1xflk_331",actions:"_actions_1xflk_336",actionsWrapper:"_actionsWrapper_1xflk_340",actionsBar:"_actionsBar_1xflk_346",actionButton:"_actionButton_1xflk_355",hasShortKeys:"_hasShortKeys_1xflk_368",actionShortcut:"_actionShortcut_1xflk_377",actionShortcutFixKerning:"_actionShortcutFixKerning_1xflk_384"};var Xe={};G(Xe,{enUS:()=>sm,nlNL:()=>rm});var sm={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}],showAll:[{type:0,value:"Show more"}]},rm={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}],showAll:[{type:0,value:"Toon meer"}]};var ft=require("react/jsx-runtime"),im=({src:t,title:e})=>{let o=y("CommandPalette",le),[n,s]=(0,Ol.useState)("loading"),r=T(Xe);return(0,ft.jsxs)("div",{className:o.image,children:[(0,ft.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,bs.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,ft.jsx)("span",{className:(0,bs.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,ft.jsx)("span",{className:(0,bs.default)(o.imageSrc,o.imageSrcStatus),children:(0,ft.jsx)(Nn,{})}),e&&(0,ft.jsx)("span",{className:o.imageTitle,children:e})]})},Dl=im;var Hl=E(require("react")),Bl=E(require("classnames"));var Ht=require("react/jsx-runtime");function ni({children:t,heading:e,orientation:o,hasMore:n,onShowAll:s}){let r=T(Xe),i=y("CommandPalette",le);return Hl.default.Children.count(t)===0?null:(0,Ht.jsxs)("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||n)&&(0,Ht.jsxs)("div",{className:i.listHeader,children:[e&&(0,Ht.jsx)("h4",{className:i.listHeading,children:e}),n&&s&&(0,Ht.jsx)("button",{onClick:s,className:i.listMoreButton,type:"button",children:r("showAll")})]}),(0,Ht.jsx)("div",{className:(0,Bl.default)(i.listWrapper,o==="horizontal"&&i.listHorizontal),children:t})]})}var Go=E(require("classnames")),Wl=require("interweave");var X=E(require("react")),Fl=E(require("classnames"));var si={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"};var Bt=require("react/jsx-runtime"),am=0,Kl=X.default.createContext(null),lm=()=>{let t=(0,X.useContext)(Kl);if(!t)throw new Error("Invalid DropdownContext");return t},Ul=({trigger:t,children:e,position:o="bottom"})=>{let n=(0,X.useMemo)(()=>++am,[]),s=(0,X.useRef)(null),r=(0,X.useRef)(null),i=y("Dropdown",si),[a,l]=(0,X.useState)(!1),[c,p]=(0,X.useState)(o),d=u=>{u.preventDefault(),u.stopPropagation(),l(!a)},g=(0,X.useCallback)(([u])=>{!u.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return(0,X.useEffect)(()=>{let u=m=>{s.current&&!s.current.contains(m.target)&&l(!1)};return document.addEventListener("click",u),()=>{document.removeEventListener("click",u)}},[]),(0,X.useEffect)(()=>{if(!r.current&&!a)return()=>{};let u=new IntersectionObserver(g,{root:null,rootMargin:"0px",threshold:1});return r.current&&u.observe(r.current),()=>{r.current&&u.unobserve(r.current)}},[r,a]),(0,Bt.jsx)(Kl.Provider,{value:{setIsOpen:l},children:(0,Bt.jsxs)("div",{ref:s,className:i.root,children:[(0,Bt.jsx)("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}),(0,Bt.jsx)("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:(0,Fl.default)(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function cm({as:t,children:e,onClick:o,...n}){let s=t||"button",r=y("Dropdown",si),{setIsOpen:i}=lm(),a=l=>{i(!1),o(l),l.stopPropagation()};return(0,Bt.jsx)(s,{type:"button",className:r.item,onClick:a,...n,children:e})}Ul.Item=cm;var ri=Ul;var ii=require("react/jsx-runtime"),zl=t=>(0,ii.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:(0,ii.jsx)("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 Ft={};G(Ft,{enUS:()=>pm,nlNL:()=>dm});var pm={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"}]},dm={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],giveFeedback:[{type:0,value:"Geef feedback"}],answer:[{type:0,value:"Antwoord"}]};var Cs=require("react/jsx-runtime"),um="%0d%0a%0d%0a%0d%0a",gm=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(um)}`},mm=({suggestion:t,onFeedback:e})=>{let o=T(Ft),n=C("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:(0,Cs.jsx)(ri,{trigger:(0,Cs.jsx)(zl,{"data-testid":"feedback-dropdown-trigger"}),children:(0,Cs.jsx)(ri.Item,{as:"a",href:gm(n,t),onClick:e,children:o("giveFeedback")})})},ws=mm;var Ts=E(require("react")),ql=require("react/jsx-runtime"),jl=Ts.default.createContext(void 0);function ht(){let t=Ts.default.useContext(jl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Vl=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=Ts.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,ql.jsx)(jl.Provider,{value:i,children:t})};var ue=require("react/jsx-runtime");function ai({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:g,onChangeOpen:u}=ht(),m=y("CommandPalette",le);function f(h){n(h),t&&u(!1)}return(0,ue.jsxs)("div",{className:(0,Go.default)(m.listItem,d===i&&m.listItemSelected),children:[(0,ue.jsx)("button",{onMouseEnter:()=>g(i),type:"button",className:(0,Go.default)("command-palette-list-item",m.listItemAction,m.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:f,...p,children:(0,ue.jsxs)("div",{className:m.listItemContent,children:[typeof o=="string"?(0,ue.jsx)("p",{className:(0,Go.default)(m.listItemText,m.truncate,c==null?void 0:c.title),children:o}):o,a&&(0,ue.jsx)(Wl.Interweave,{tagName:"p",allowList:[],content:Dt(a)?Ll(a):a,className:(0,Go.default)(m.listItemDescription,c==null?void 0:c.description,e?m.lineClamp:m.truncate)})]})}),s&&d===i&&(0,ue.jsx)("div",{className:m.listItemActions,children:(0,ue.jsx)(ws,{suggestion:String(o),onFeedback:s})}),l&&(0,ue.jsxs)("div",{className:m.sources,children:[(0,ue.jsx)("span",{className:m.sourcesTitle,children:"Sources"}),l.map(h=>h.url?(0,ue.jsx)("a",{className:m.source,href:h.url,target:"_blank",title:h.url,rel:"noopener noreferrer",onClick:()=>r&&r(h),children:h.name},h.url):(0,ue.jsx)("span",{className:m.source,children:h.name},h.name))]})]})}var Kt=require("react/jsx-runtime");function li({children:t,title:e,id:o,onDismiss:n}){let s=T(Xe),r=y("CommandPalette",le),{page:i}=ht();return i!==o?null:(0,Kt.jsxs)("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,Kt.jsxs)("div",{className:r.pageNav,children:[(0,Kt.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:n,children:[(0,Kt.jsx)(fs,{}),s("back")]}),e&&(0,Kt.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var yt=require("react");var ks=require("@reduxjs/toolkit");var ho=require("@reduxjs/toolkit");function fm(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function L(t){return Array.isArray(t)?t.map(L):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[fm(o)]:L(t[o])}),{}):t}function ci(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function $(t){return Array.isArray(t)?t.map($):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[ci(o)]:$(t[o])}),{}):t}var hm={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Zo=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)||""}},Xo=(0,ho.createAsyncThunk)("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?L(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),L(n))}),pi=(0,ho.createAsyncThunk)("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}),di=(0,ho.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),$l=t=>t.info.agentInfo,Gl=(0,ho.createSlice)({name:"info",initialState:hm,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Xo.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Xo.rejected,e=>{e.fetchState="error"}).addCase(Xo.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(pi.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(di.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(N,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Xl}=Gl.actions,Zl=Gl.reducer;var Es={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},Ql=t=>t.search.isOpen,Jl=t=>t.search.page,Yl=t=>t.search.list,ec=t=>t.search.aggregates;function tc(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Ut=(0,ks.createAsyncThunk)("search/getAll",async(t,e)=>{var a;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(a=n.conversation.current)==null?void 0:a.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r,aggregates:i}=await o.search({profile:s,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:Zo(n)});return{results:r.map(l=>({...l,source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:i}}),oc=(0,ks.createSlice)({name:"search",initialState:Es,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=Es.fetchState,t.list=Es.list}},extraReducers:t=>{t.addCase(Ut.pending,e=>{e.fetchState="loading"}).addCase(Ut.rejected,(e,o)=>{e.fetchState="error",w.error(o.error)}).addCase(Ut.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload.results,e.aggregates=o.payload.aggregates||{}}).addCase(N,()=>Es)}}),{resetSearch:Is,setIsOpen:te,setPage:oe}=oc.actions,nc=oc.reducer;var ym=/(https?:\/\/[^\s]+)/,Rs=t=>t.split(" ").find(e=>ym.test(e));var Ps=()=>/Mac/i.test(navigator.platform);var ui=E(require("classnames"));var As=require("react/jsx-runtime"),vm=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",le);return(0,As.jsxs)("button",{type:"button",...n,onClick:t,className:(0,ui.default)(s.actionButton,n.className,{[s.hasShortKeys]:e&&e.length>0}),children:[o,e&&e.map(r=>(0,As.jsx)("span",{className:(0,ui.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},yo=vm;var Ze=require("react/jsx-runtime"),Sm=["url","URL"],_m=["default","pinned-message","DEFAULT","STICKYMESSAGE"],xm=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",le),a=T(Xe),{selected:l,setSelected:c}=ht(),p=r[l],d=p&&p.type&&Sm.includes(p.type),g=p&&p.type&&_m.includes(p.type)||p&&"secondaryAction"in p,u=d?Rs(p.text):null,m=(0,yt.useRef)(null);function f(v){if(!m.current)return;let A=m.current.querySelectorAll(".command-palette-list-item"),M=0,K=0;v==="down"?(A.forEach((q,I)=>{I===l&&(M=I)}),K=M===A.length-1?0:M+1):v==="up"?(A.forEach((q,I)=>{I===l&&(M=I)}),K=M?M-1:A.length-1):c(0);let D=A[K];D&&typeof K=="number"&&(c(K),D.scrollIntoView&&D.scrollIntoView({behavior:"smooth",block:K?"center":"end"}))}function h(){if(!m.current)return;let v=m.current.querySelectorAll(".command-palette-list-item"),A=0;v.forEach((K,D)=>{D===l&&(A=D)});let M=v[A];M&&M.click()}let k=()=>{u&&window.open(u,"_blank")},_=()=>{p&&n(p,l)},x=()=>{!s||!g||s(p,l)},b=(0,yt.useCallback)(v=>{if(v.key==="Enter"&&v.altKey&&u){k();return}if(v.key==="Enter"&&v.shiftKey){x();return}if(v.key==="ArrowDown"){v.preventDefault(),v.stopPropagation(),f("down");return}if(v.key==="ArrowUp"){v.preventDefault(),v.stopPropagation(),f("up");return}v.key==="Enter"&&l!==-1&&(v.preventDefault(),v.stopPropagation(),h())},[l]);return(0,yt.useEffect)(()=>(window.addEventListener("keyup",b),()=>{window.removeEventListener("keyup",b)}),[b]),(0,Ze.jsxs)("div",{className:i.actions,children:[(0,Ze.jsx)("div",{className:i.actionsWrapper,ref:m,children:t}),(0,Ze.jsxs)("div",{className:i.actionsBar,children:[u&&(0,Ze.jsx)(yo,{onClick:k,shortKeys:[Ps()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,Ze.jsxs)(yt.Fragment,{children:[s&&g&&(0,Ze.jsx)(yo,{onClick:x,shortKeys:[8679,8629],children:o}),(0,Ze.jsx)(yo,{onClick:_,shortKeys:[8629],children:e})]})]})]})},rc=xm;var ic=require("react");var Qo=require("react/jsx-runtime"),vo=()=>(0,Qo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Qo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Qo.jsx)("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"})]});var Pe=require("react/jsx-runtime");function bm({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",le);return(0,Pe.jsxs)("div",{className:l.search,children:[(0,Pe.jsx)("div",{className:l.searchIcon,children:(0,Pe.jsx)(vo,{})}),(0,Pe.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Pe.jsx)("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&&(0,Pe.jsx)("div",{className:l.selectWrapper,children:(0,Pe.jsxs)("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&&(0,Pe.jsx)("option",{children:n}),s.map(c=>(0,Pe.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var ac=(0,ic.forwardRef)(bm);var Jo=require("react/jsx-runtime");function zt({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:g}){let[u,m]=(0,So.useState)(0),f=(0,So.useRef)(null),h=()=>{s&&s(o),i(void 0),r(""),a(!1)},k=()=>{var _;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(_=f.current)==null||_.focus();return}if(g.length>0){r("");return}a(!1)};return(0,So.useEffect)(()=>{m(0)},[g,n]),(0,Jo.jsx)(lo,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:k,onClose:h,children:(0,Jo.jsxs)(Vl,{selected:u,setSelected:m,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&(0,Jo.jsx)(ac,{ref:f,onChange:r,onChangeType:i,placeholder:t,value:g,selectedType:l,types:c,typePlaceholder:e}),p]})})}zt.Page=li;zt.List=ni;zt.Image=Dl;zt.ListItem=ai;zt.ActionsBar=rc;zt.Button=yo;var P=zt;var ee=require("react/jsx-runtime"),Cm=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",ol),l=(0,Ls.useDispatch)(),c=T(Hr),p=(0,Ls.useSelector)(m=>m.overlayInput.text);(0,gi.useEffect)(()=>{t&&(l(ae.actions.reset()),l(ae.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(ae.actions.commitSuggestion()))},[t]);let d=m=>{m.preventDefault(),g(p)},g=m=>{l(Jn(m)),e(m)},u=m=>f=>{p!==i?window.confirm(c("warning"))&&m(f):m(f)};return(0,gi.useEffect)(()=>{n&&n(p!==i)},[n,t,p]),(0,ee.jsxs)("div",{className:a.root,children:[(0,ee.jsxs)("div",{className:a.content,children:[t.title&&(0,ee.jsx)("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&(0,ee.jsx)(Rr,{labels:t.searchKeywords}),(0,ee.jsx)(Nl,{onUse:g,value:Al(p)})]}),(0,ee.jsxs)("form",{className:a.actions,onSubmit:d,children:[(0,ee.jsxs)("div",{children:[(0,ee.jsx)("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&u(r),children:(0,ee.jsx)(fs,{})}),(0,ee.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&u(s),children:(0,ee.jsx)(ul,{})})]}),(0,ee.jsxs)("div",{className:a.primaryButtons,children:[(0,ee.jsx)(P.Button,{onClick:u(o),shortKeys:["esc"],children:c("dismiss")}),(0,ee.jsx)(P.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},Ms=Cm;var jt=require("@reduxjs/toolkit");var wm=["{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}"],Tm=new RegExp(wm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function lc(t,e){let o=t.split(Tm),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),g=0;do c=d?e.indexOf(d,c+1):-1,g+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&g>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 cc(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var dc={suggestions:[],fetchState:"idle",isInitialRequest:null},pc={default:dc},Ns=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},uc=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")},vt=t=>t.textSuggestions,gc=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},Os=(0,jt.createAction)("textSuggestions/refresh"),Ae=(0,jt.createAsyncThunk)("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=io(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Zo(n),t);if(t==="default"){let p=i?l.filter(gc(a)):l;e.dispatch(Be(p.slice(0,r)))}return l}),Yo=(0,jt.createAsyncThunk)("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,{...Zo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(gc(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?lc(p.text,t):p.text}))),l=cc(l,r),e.dispatch(Be(l)),l}),mc=(0,jt.createSlice)({name:"textSuggestions",initialState:pc,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(Ae.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||dc;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(Ae.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(Ae.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Yo.pending,e=>{e.default.fetchState="loading"}).addCase(Yo.rejected,e=>{e.default.fetchState="error"}).addCase(Yo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(N,()=>pc)}}),{setTextSuggestions:fc,setSuggestionState:hc}=mc.actions,yc=mc.reducer;var Sc=require("@reduxjs/toolkit");var vc={contentType:null,suggestion:null},_c=t=>t.activeSuggestion.suggestion,xc=t=>t.activeSuggestion.contentType,bc=(0,Sc.createSlice)({name:"activeSuggestion",initialState:vc,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(N,()=>vc)}}),{setActiveSuggestion:Qe,resetActiveSuggestion:mi}=bc.actions,Cc=bc.reducer;var fi={};G(fi,{enUS:()=>Em,nlNL:()=>km});var Em={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"}]},km={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"}]};var wc=require("@reduxjs/toolkit"),Im={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Ds=({ui:t})=>t.overlayCollapsed;var Tc=(0,wc.createSlice)({name:"ui",initialState:Im,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:en,setInputHasFocus:_o,setOverlayCollapsed:St,setOpenOverlayWhenTyping:Ec,setOverlayCollapsedUserOverwrite:kc}=Tc.actions,Ic=Tc.reducer;var tn=E(require("react")),Pc=require("react/jsx-runtime"),Rc=tn.default.createContext(null),Vt=({broadcastEvents:t,children:e})=>{let o=tn.default.useMemo(()=>t,[]);return(0,Pc.jsx)(Rc.Provider,{value:o,children:e})},xe=()=>{let t=(0,tn.useContext)(Rc);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var xo=require("@reduxjs/toolkit");var Rm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ne=t=>t.auth.isLoggedIn,Ac=t=>t.auth.loginFetchState,Lc=t=>t.auth.verifyFetchState,Mc=t=>t.auth.showLoginOverlay,Je=(0,xo.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),Nc=(0,xo.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),on=(0,xo.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),Oc=(0,xo.createSlice)({name:"auth",initialState:Rm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(Je.pending,e=>{e.loginFetchState="loading"}),t.addCase(Je.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(Je.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(on.pending,e=>{e.verifyFetchState="loading"}),t.addCase(on.rejected,e=>{e.verifyFetchState="error"}),t.addCase(on.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:bo,setShowLoginOverlay:Dc}=Oc.actions,Hc=Oc.reducer;var hi="SetActiveSuggestion",Co="ShowLoginOverlay",nn="UserLoggedIn",Pm="UserLoggedOut",Ye="ApplySuggestion",yi="ApplyImageSuggestion",Am="ShowCommandPalette",Lm=t=>({[hi]:e=>{t.dispatch(hc(e.state)),t.dispatch(Qe({contentType:e.contentType,suggestion:e.suggestion}))},[Am]:e=>{t.dispatch(te(e.isOpen)),e.page&&t.dispatch(oe(e.page))},[Co]:e=>{t.dispatch(Dc(e))},[nn]:()=>{t.dispatch(Je())},[Pm]:()=>{t.dispatch(Je())},[yi]:e=>{t.dispatch(es({suggestion:e.suggestion}))},[Ye]:e=>{t.dispatch(Ie({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(qe())}}),Bc=Lm;var vi=require("react/jsx-runtime"),Mm=()=>{var m;let[t,e]=(0,Fc.useState)(!1),o=(0,wo.useSelector)(_c),n=(0,wo.useSelector)(xc),s=(0,wo.useSelector)(vt),r=(0,wo.useDispatch)(),i=xe(),a=T(fi),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(mi()),r(_o(!0)),r(ae.actions.reset())},p=(f,h)=>{r(mi()),r(_o(!0)),i.send(Ye,{text:f,suggestion:{...h,source:`${h.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let d=(m=s[n])==null?void 0:m.suggestions.indexOf(o),g=d===0||d===null?void 0:()=>r(Qe({contentType:n,suggestion:s[n].suggestions[d-1]})),u=d===s[n].suggestions.length-1||d===null?void 0:()=>r(Qe({contentType:n,suggestion:s[n].suggestions[d+1]}));return(0,vi.jsx)(lo,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,vi.jsx)(Ms,{onTouched:e,onDismiss:c,onUse:f=>p(f,o),suggestion:o,onNext:u,onPrevious:g})})},Kc=Mm;var _i=require("react-redux");var Hs=E(require("classnames")),Le=require("react"),Bs=require("react-redux");var zc=E(require("classnames"));var Uc={root:"_root_1ukx5_1"};var jc=require("react/jsx-runtime"),Nm=({className:t,value:e,...o})=>{let n=y("TextInput",Uc);return(0,jc.jsx)("input",{className:(0,zc.default)(t,n.root),type:"text",value:e,...o})},sn=Nm;var Si={};G(Si,{enUS:()=>Om,nlNL:()=>Dm});var Om={back:[{type:0,value:"Back"}],promptTitle:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Paste the code from your email"}],verifyCodeBody:[{type:0,value:"Copy the code from the email you just received and paste it here."}],verifyCodeInputPlaceholder:[{type:0,value:"Paste link or code here"}],verifyCodeSubmitLabel:[{type:0,value:"Sign in"}],verifyCodeError:[{type:0,value:"Sign in failed. The code is probably no longer valid. Please "},{type:8,value:"login",children:[{type:0,value:"request new code"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Have a code sent to your email"}],requestCodeBody:[{type:0,value:"Enter your email and request a code. If you are an existing "},{type:1,value:"productName"},{type:0,value:" user you will receive an email with a code. If you are a new user you will receive an email asking to request access to "},{type:1,value:"productName"},{type:0,value:" first."}],requestCodeInputPlaceholder:[{type:0,value:"Enter your email"}],requestCodeSubmitLabel:[{type:0,value:"Request code"}]},Dm={back:[{type:0,value:"Terug"}],promptTitle:[{type:0,value:"Login bij "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Plak de code uit je email"}],verifyCodeBody:[{type:0,value:"Kopieer de code uit de email en plak deze hier."}],verifyCodeInputPlaceholder:[{type:0,value:"Plak hier de code"}],verifyCodeSubmitLabel:[{type:0,value:"Inloggen"}],verifyCodeError:[{type:0,value:"Inloggen is niet gelukt. De code is waarschijnlijk niet meer geldig. "},{type:8,value:"login",children:[{type:0,value:"Vraag een nieuwe code aan"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Verstuur een login code naar je email"}],requestCodeBody:[{type:0,value:"Voer je e-mailadres in en krijg een login code. Als je een bestaande "},{type:1,value:"productName"},{type:0,value:" gebruiker bent krijg je een email met een code. Als je een nieuwe gebruiker bent wordt er een email verstuurd met een toegangsverzoek voor "},{type:1,value:"productName"},{type:0,value:"."}],requestCodeInputPlaceholder:[{type:0,value:"Typ hier je e-mailadres"}],requestCodeSubmitLabel:[{type:0,value:"Code aanvragen"}]};var Vc={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"};var z=require("react/jsx-runtime");var Hm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Bm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=T(Si),i=y("LoginTokenDialog",Vc),a=(0,Bs.useSelector)(Lc),l=(0,Bs.useDispatch)(),c=C("productName"),[p,d]=(0,Le.useState)(t||""),[g,u]=(0,Le.useState)(0),[m,f]=(0,Le.useState)(""),h=(0,Le.useCallback)(async b=>{b.preventDefault(),l(Nc({email:p})),u(1)},[o,p]),k=()=>{f(""),u(0)},_=(0,Le.useCallback)(async b=>{b.preventDefault();let v=Hm(b.target.elements.token.value);if(!v){f(r("verifyCodeError",{login:x}));return}l(on({token:v}))},[o]),x=(0,Le.useMemo)(()=>b=>(0,z.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:k,children:b},"back-button"),[]);return(0,Le.useEffect)(()=>{a==="error"&&f(r("verifyCodeError",{login:x})),a==="done"&&n()},[a]),(0,z.jsx)(lo,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:(0,z.jsxs)("div",{className:i.root,children:[(0,z.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:c})}),g===0&&(0,z.jsxs)("form",{onSubmit:h,children:[(0,z.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,z.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),(0,z.jsx)(sn,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:b=>d(b.target.value)}),(0,z.jsx)("div",{className:i.actions,children:(0,z.jsx)("button",{type:"submit",className:(0,Hs.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),g===1&&(0,z.jsxs)("form",{onSubmit:_,children:[(0,z.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,z.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,z.jsx)(sn,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),m&&(0,z.jsx)("div",{className:i.errorMessage,children:m}),(0,z.jsxs)("div",{className:i.actions,children:[(0,z.jsx)("button",{type:"button",className:(0,Hs.default)(i.button),onClick:k,children:r("back")}),(0,z.jsx)("button",{type:"submit",className:(0,Hs.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},qc=Bm;var $c=require("react/jsx-runtime"),Fm=()=>{let t=(0,_i.useSelector)(Mc),e=(0,_i.useSelector)($l),o=C("adminUrl"),n=xe(),s=()=>n.send(Co,!1),r=()=>{n.send(Co,!1),n.send(nn)};return(0,$c.jsx)(qc,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},Wc=Fm;var xp=E(require("lodash.debounce")),se=require("react"),Ue=require("react-redux");var Fs=require("@reduxjs/toolkit");var Km={data:null,fetchState:"idle"},Gc=t=>t.contentTypes.data,rn=(0,Fs.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Um=(0,Fs.createSlice)({name:"contentTypes",initialState:Km,reducers:{},extraReducers:t=>{t.addCase(rn.pending,e=>{e.fetchState="loading"}).addCase(rn.rejected,e=>{e.fetchState="error"}).addCase(rn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Xc=Um.reducer;function an(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()}var Zc=require("react");function Qc(t,e){(0,Zc.useEffect)(()=>{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)}},[])}var ln=require("react"),zs=require("react-redux");var Ks=require("@reduxjs/toolkit");var Jc={data:null,fetchState:"idle"},Us=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},Me=(0,Ks.createAsyncThunk)("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)}),zm=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),jm=(0,Ks.createSlice)({name:"entities",initialState:Jc,reducers:{},extraReducers:t=>{t.addCase(Me.pending,e=>{e.fetchState="loading"}).addCase(Me.rejected,e=>{e.fetchState="error"}).addCase(Me.fulfilled,(e,o)=>{e.fetchState="done",e.data=zm(e.data?[...e.data,...o.payload]:o.payload)}).addCase(N,()=>Jc)}}),Yc=jm.reducer;var xi={};G(xi,{enUS:()=>Vm,nlNL:()=>qm});var Vm={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 ep={root:"_root_17kae_1",empty:"_empty_17kae_5"};var qt=require("react/jsx-runtime"),Wm=({onCopy:t,onUse:e})=>{let o=(0,ln.useRef)(null),n=y("EntitiesList",ep),s=T(xi),r=(0,zs.useSelector)(Us),i=(0,zs.useDispatch)();return(0,ln.useEffect)(()=>{i(Me())},[]),(0,ln.useEffect)(()=>{o.current&&o.current.focus()},[o]),(0,qt.jsxs)("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&(0,qt.jsx)(P.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:(0,qt.jsx)(P.List,{children:r.map((a,l)=>(0,qt.jsx)(P.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&(0,qt.jsx)("p",{className:n.empty,children:s("noResults")})]})},tp=Wm;var Ne=require("react"),cn=require("react-redux");var js=require("@reduxjs/toolkit");var op={data:null,fetchState:"idle"},np=t=>t.summary.data,sp=t=>t.summary.fetchState==="error",et=(0,js.createAsyncThunk)("summary/getSummary",async(t,e)=>{var p,d,g;let o=e.getState().profile.data,n=(p=e.getState().conversation.current)==null?void 0:p.sessionId,s=(g=(d=e.getState().info)==null?void 0:d.agentInfo)==null?void 0:g.agentId;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:r,dynamicThunkObject:i}=e.extra;if(!i.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let a=i.conversationQuery,l=await a();if(l.length===0)return Promise.reject(new Error("No messages are included"));let c=await r.getSummary(l,{externalConversationId:n,agentId:s,promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return c?{summary:c}:Promise.reject(new Error("Summary is not provided"))}),$m=(0,js.createSlice)({name:"summary",initialState:op,reducers:{},extraReducers:t=>{t.addCase(et.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(et.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(et.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(N,()=>op)}}),rp=$m.reducer;var bi={};G(bi,{enUS:()=>Gm,nlNL:()=>Xm});var Gm={copy:[{type:0,value:"Copy"}],error:[{type:0,value:"Could not generate a summary"}],loading:[{type:0,value:"Generating summary, this may take a few moments."}]},Xm={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 ip={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};var tt=require("react/jsx-runtime"),Zm=({onCopy:t})=>{let e=(0,Ne.useRef)(null),o=y("SummaryForm",ip),[n,s]=(0,Ne.useState)(""),r=T(bi),i=(0,cn.useSelector)(np),a=(0,cn.useSelector)(sp),l=(0,cn.useDispatch)(),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(0,Ne.useEffect)(()=>{l(et())},[]),(0,Ne.useEffect)(()=>{s(i||"")},[i]),(0,Ne.useEffect)(()=>{e.current&&i&&e.current.focus()},[e,i]),(0,Ne.useEffect)(()=>{let d=g=>{g.key==="Enter"&&g.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[n]),(0,tt.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,tt.jsx)("p",{className:o.error,children:r("error")}):(0,tt.jsxs)(Ne.Fragment,{children:[(0,tt.jsx)("div",{className:o.main,children:(0,tt.jsx)("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:d=>s(d.target.value)})}),(0,tt.jsx)("div",{className:o.actions,children:(0,tt.jsx)(P.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},ap=Zm;var pn={};G(pn,{enUS:()=>Qm,nlNL:()=>Jm});var Qm={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?"}]},Jm={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?"}]};var _t=E(require("react")),gn=require("react-redux");var Ci={};G(Ci,{enUS:()=>Ym,nlNL:()=>ef});var Ym={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"}]},ef={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 lp={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"};var Eo=require("@reduxjs/toolkit");var Vs=require("@reduxjs/toolkit");var tf={data:null,fetchState:"idle"},cp=t=>{var e;return(e=t.knowledgeAssistant)==null?void 0:e.data},dn=(0,Vs.createAsyncThunk)("knowledgeAssistant/getKnowledgeAssistant",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");let r=(i=n.profile.data)==null?void 0:i.knowledgeAssistant;return r?o.getKnowledgeAssistant(r):null}),of=(0,Vs.createSlice)({name:"knowledgeAssistant",initialState:tf,reducers:{},extraReducers:t=>{t.addCase(dn.pending,e=>{e.fetchState="loading"}).addCase(dn.rejected,e=>{e.fetchState="error"}).addCase(dn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),pp=of.reducer;var wi={data:[],fetchState:"idle"},dp=t=>{var e;return(e=t.answer)==null?void 0:e.data},up=t=>t.answer.fetchState,ko=(0,Eo.createAction)("answer/resetKnowledgeSearch"),To=(0,Eo.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var l,c,p;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=cp(e.getState()),r=(l=e.getState().conversation.current)==null?void 0:l.sessionId,i=(p=(c=e.getState().info)==null?void 0:c.agentInfo)==null?void 0:p.agentId;if(!s)throw new Error("KnowledgeAssistant is not defined");let a=await o.knowledgeAssist({promptInstruction:s.prompt,question:t},n,s.code,{agentId:i,conversationId:r});return{question:t,answer:a}}),nf=(0,Eo.createSlice)({name:"answer",initialState:wi,reducers:{},extraReducers:t=>{t.addCase(To.pending,e=>{e.fetchState="loading"}).addCase(To.rejected,e=>{e.fetchState="error"}).addCase(To.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(N,()=>wi).addCase(ko,()=>wi)}}),gp=nf.reducer;var un=require("react/jsx-runtime"),mp=()=>(0,un.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,un.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,un.jsx)("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"})]});var ce=require("react/jsx-runtime"),sf=({onUse:t,onResetQuestion:e,question:o})=>{let[n,s]=_t.default.useState(""),{setSelected:r}=ht(),i=(0,_t.useRef)(null),a=y("EntitiesList",lp),l=T(Ci),c=(0,gn.useDispatch)(),p=(0,gn.useSelector)(dp),d=(0,gn.useSelector)(up),g=async m=>{m.preventDefault(),m.stopPropagation(),n!==""&&c(To(n))},u=(m,f)=>{c(Q({name:"knowledge assist source viewed",data:{question:f,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return(0,_t.useEffect)(()=>{var m;o&&d==="idle"?c(To(o)):(m=i.current)==null||m.focus()},[i,d]),(0,_t.useEffect)(()=>{d==="done"&&(c(Q({name:"knowledge assist question answered",data:{question:n||o,sources:p[p.length-1].answer.sources,answer:p[p.length-1].answer.answer,isFollowUpQuestion:p.length>1},options:{includeConversationData:!0}})),r(p.length-1),s(""))},[d,p]),(0,_t.useEffect)(()=>{i.current&&i.current.scrollIntoView({behavior:"smooth"})},[i,p]),(0,ce.jsxs)("div",{className:a.root,children:[p.length>0&&(0,ce.jsx)("div",{className:a.alignRight,children:(0,ce.jsx)(P.Button,{onClick:e,children:l("reset")})}),(0,ce.jsxs)(P.ActionsBar,{list:p.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:l("use"),onPrimary:m=>t(m.text),children:[p.map(({question:m,answer:f},h)=>(0,ce.jsx)(P.List,{children:(0,ce.jsx)(P.ListItem,{"data-testid":"knowledge-search-answer",index:h,description:f.answer,closeOnSelect:!0,onClick:()=>t(f.answer),onSourceClick:k=>u(k,m),sources:f.sources,styles:{title:a.question,description:a.answer},children:m})},`${f.answer}_${h}`)),d==="loading"&&(0,ce.jsx)("p",{className:a.status,children:l("loading")}),d==="error"&&(0,ce.jsx)("p",{className:a.status,children:l("error")}),(0,ce.jsxs)("form",{className:a.form,onSubmit:g,children:[(0,ce.jsx)("input",{ref:i,placeholder:l("anotherQuestion"),className:a.input,type:"text",value:n,onFocus:()=>{r(-1)},onChange:m=>{r(-1),s(m.target.value)}}),(0,ce.jsx)("button",{type:"submit",className:a.submit,children:(0,ce.jsx)(mp,{})})]})]})]})},fp=sf;var qs=require("@reduxjs/toolkit");var rf={data:null,fetchState:"idle"},xt=t=>t.profile.data,Ws=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],mn=(0,qs.createAsyncThunk)("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)}),af=(0,qs.createSlice)({name:"profile",initialState:rf,reducers:{},extraReducers:t=>{t.addCase(mn.pending,e=>{e.fetchState="loading"}).addCase(mn.rejected,e=>{e.fetchState="error"}).addCase(mn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),hp=af.reducer;var yp=require("react");var vp=require("react-redux");var Ti=require("react-redux");var Wt=require("react/jsx-runtime"),lf=({commands:t,onClick:e,onEdit:o})=>{var p,d,g;let n=(0,vp.useDispatch)(),s=T(pn),r=(0,Ti.useSelector)(xt),i=(0,Ti.useSelector)(vt),a=((g=(d=(p=r==null?void 0:r.uiConfig)==null?void 0:p.search)==null?void 0:d.initialTypes)==null?void 0:g.filter(({isActive:u})=>u))||[],l=0,c=a.map(({type:u})=>{var m;return(m=i[u])==null?void 0:m.suggestions.map(f=>({text:f.text||f.url||f.message,type:u}))}).flat(1);return(0,yp.useEffect)(()=>{a.forEach(({type:u})=>{(!i[u]||i[u].suggestions.length===0)&&n(Ae(u))})},[]),(0,Wt.jsxs)(P.ActionsBar,{list:[...t.map(u=>({text:u.label,type:"command"})),...c],primaryLabel:s("use"),secondaryLabel:s("preview"),onPrimary:({text:u},m)=>e(u,c[m]),onSecondary:(u,m)=>{let f=m-t.length;o(c[f],i[c[f].type].suggestions)},children:[t.length>0&&(0,Wt.jsx)(P.List,{heading:s("commands"),children:t.map((u,m)=>(0,Wt.jsx)(P.ListItem,{index:m,closeOnSelect:!1,onClick:u.onClick,children:u.label},u.label))}),a.map(({type:u,title:m})=>{var f;return(0,Wt.jsx)(P.List,{heading:m,orientation:"vertical",children:(f=i[u])==null?void 0:f.suggestions.map(h=>(l++,(0,Wt.jsx)(P.ListItem,{index:l+t.length-1,closeOnSelect:!1,description:h.text,onClick:()=>e(h.text,h),"data-testid":"search-overlay-suggestion",children:h.title},`${h.id}-${h.text}`)))},u)})]})},Sp=lf;var j=require("react/jsx-runtime"),cf=200,pf=5,df=4,uf=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),_p=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),gf=()=>{let t=(0,Ue.useDispatch)(),e=xe(),o=T(pn),[n,s]=(0,se.useState)(!1),[r,i]=(0,se.useState)(""),a=(0,Ue.useSelector)(Jl),l=(0,Ue.useSelector)(xt),[c,p]=(0,se.useState)(null),[d,g]=(0,se.useState)([]),[u,m]=(0,se.useState)(),f=(0,Ue.useSelector)(ne),h=C("showSearch"),k=C("showEntitiesCommand"),_=C("showSummaryCommand"),x=C("showKnowledgeSearch"),b=C("showImageSearch"),v=C("searchTriggerKey"),A=(0,Ue.useSelector)(Gc),M=(0,Ue.useSelector)(Yl),K=(0,Ue.useSelector)(ec),D=(0,Ue.useSelector)(Ql),q=S=>Rn(M.filter(H=>H.type===S.toUpperCase()),S),I=[{value:"PERSONAL",label:o("personalSuggestions"),list:q("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:q("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:q("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:q("IMAGE"),listOrientation:"horizontal",shouldShow:b}].filter(S=>S.shouldShow),U=[{label:o("entitiesClipboard"),onClick:()=>t(oe("entities")),shouldShow:k&&_p(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(oe("summary")),shouldShow:_&&_p(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(oe("knowledgeAssist")),shouldShow:x}].filter(S=>S.shouldShow),De=(A==null?void 0:A.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:q(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],Er=(0,se.useCallback)((0,xp.default)((S,H)=>{t(Ut({query:S,type:H,tags:["search-overlay"],size:u?50:20}))},cf),[u]),Yt=uf([...De,...I]),la=(0,se.useCallback)((S,H)=>{t(oe("edit")),p({...S,searchTerm:void 0}),g(H)},[t,c,De]),In=(0,se.useCallback)((S,H)=>{switch(H.type){case"IMAGE":e.send(yi,{suggestion:H});break;default:e.send(Ye,{text:S,suggestion:H})}t(te(!1))},[t]),zu=S=>{an(S.text),t(Q({name:"entity copied",data:{entity:S,type:"copy"}})),t(te(!1))},ju=(0,se.useCallback)(S=>{t(Q({name:"suggestion feedback",data:{text:S.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),Vu=S=>{e.send(Ye,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(Q({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(oe("search")),t(ko()),t(te(!1))},qu=S=>{an(S),t(te(!1))},Wu=S=>{e.send(Ye,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(te(!1))},$u=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),Gu=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function Rn(S,H){return S.slice(0,u?10:H.toLowerCase()==="image"?df:pf)}function ca(S,H,Te){return H.reduce((Pn,An)=>Te&&u===Te?An.length+Pn:Rn(An,Te).length+Pn,S)}function eo(S){return H=>{n?window.confirm(o("warning"))&&(S(H),s(!1)):S(H)}}return(0,se.useEffect)(()=>{r?Er(r,u):t(Is())},[r,u]),(0,se.useEffect)(()=>{a==="search"&&t(ko())},[a]),(0,se.useEffect)(()=>{f&&t(rn())},[f]),Qc(v,()=>t(te(!0))),!h||!l?null:(0,j.jsxs)(P,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:eo(S=>t(te(S))),onChangeType:S=>m(S),onChangePage:eo(S=>t(oe(S))),selectedType:u,search:r,page:a,isOpen:D,types:[...De,...I],children:[(0,j.jsxs)(P.Page,{id:"search",children:[r.length===0&&(0,j.jsx)(Sp,{commands:U,onClick:In,onEdit:la}),r.length>0&&(0,j.jsxs)(P.ActionsBar,{list:[...U.map(S=>({text:S.label,type:"command"})),...Yt.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},H)=>In(S,Yt[H]),onSecondary:(S,H)=>{let Te=Yt[H-U.length];!Te||!Te.type||la(Te,q(Te.type))},children:[U.length>0&&(0,j.jsx)(P.List,{heading:o("commands"),children:U.map((S,H)=>(0,j.jsx)(P.ListItem,{index:ca(H,[],"commands"),closeOnSelect:!1,onClick:S.onClick,children:S.label},S.label))}),[...De,...I].map(({value:S,label:H,list:Te,lineClamp:Pn,listOrientation:An},Xu)=>(0,j.jsx)(P.List,{heading:H,orientation:An==="horizontal"?"horizontal":"vertical",onShowAll:()=>m(S),hasMore:!u&&K[S.toLowerCase()]>Rn(Te,S).length,children:Rn(Te,S).map((fe,Zu)=>(0,j.jsx)(P.ListItem,{index:ca(U.length+Zu,[...De,...I].slice(0,Xu).map(({list:Qu})=>Qu),S),closeOnSelect:!1,lineClamp:Pn,onClick:()=>In(fe.text,fe),description:S!=="IMAGE"?fe.title&&fe.text:void 0,onFeedback:S!=="IMAGE"?()=>ju(fe):void 0,children:S==="IMAGE"?(0,j.jsx)(P.Image,{title:fe.title||fe.text,src:fe.image}):fe.title||fe.text},`${fe.id}-${fe.text}`))},S))]})]}),(0,j.jsx)(P.Page,{id:"edit",onDismiss:eo(()=>{t(oe("search")),p(null)}),children:c&&(0,j.jsx)(Ms,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(oe("search")),p(null),g([])},onNext:Gu,onPrevious:$u,onUse:S=>{t(oe("search")),In(S,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(te(!1)),g([]),p(null)}})}),(0,j.jsx)(P.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:eo(()=>{t(oe("search"))}),children:(0,j.jsx)(tp,{onUse:Wu,onCopy:zu})}),(0,j.jsx)(P.Page,{id:"summary",title:o("summaryTitle"),onDismiss:eo(()=>{t(oe("search"))}),children:(0,j.jsx)(ap,{onCopy:qu})}),(0,j.jsx)(P.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:eo(()=>{t(ko()),t(oe("search"))}),children:(0,j.jsx)(fp,{question:r,onUse:Vu,onResetQuestion:()=>{t(ko()),i("")}})})]})},bp=gf;var Io=require("react/jsx-runtime"),mf=()=>{let t=C("showSearch"),e=C("isEmbedded");return(0,Io.jsxs)(Cp.Fragment,{children:[t&&(0,Io.jsx)(bp,{}),(0,Io.jsx)(Kc,{}),e&&(0,Io.jsx)(Wc,{})]})},wp=mf;var Ip=E(require("classnames")),Rp=require("react-redux");var $s=require("react/jsx-runtime"),Tp=({className:t})=>(0,$s.jsx)("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:(0,$s.jsx)("g",{children:(0,$s.jsx)("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
+ `,Ot.MISSING_INTL_API,i);var b=o.getPluralRules(e,{type:p.pluralType}).select(g-(p.offset||0));_=p.options[b]||p.options.other}if(!_)throw new Xr(p.value,g,Object.keys(p.options),i);a.push.apply(a,Zo(_.value,e,o,n,s,g-(p.offset||0)));continue}}return Gg(a)}function Zg(t,e){return e?ue(ue(ue({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=ue(ue({},t[n]),e[n]||{}),o},{})):t}function Qg(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Zg(t[n],e[n]),o},ue({},t)):t}function Zr(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Jg(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:ys(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,is([void 0],o,!1)))},{cache:Zr(t.number),strategy:vs.variadic}),getDateTimeFormat:ys(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,is([void 0],o,!1)))},{cache:Zr(t.dateTime),strategy:vs.variadic}),getPluralRules:ys(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,is([void 0],o,!1)))},{cache:Zr(t.pluralRules),strategy:vs.variadic})}}var Sl=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(g,u){return!g.length||u.type!==J.literal||typeof g[g.length-1]!="string"?g.push(u.value):g[g.length-1]+=u.value,g},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return Zo(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=dl(i,["formatters"]);this.ast=t.__parse(e,ue(ue({},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=Qg(t.formats,n),this.formatters=s&&s.formatters||Jg(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=ml,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 Yg(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var em="dummy",Qr=(0,Ss.createContext)(null);function T(t){let e=(0,Ss.useContext)(Qr);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=Yg(o,n);return r?new Sl(r).format(s):(e!==em&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var Qo=require("react/jsx-runtime"),_s=()=>(0,Qo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Qo.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Qo.jsx)("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"})]});var Jo=require("react/jsx-runtime"),_l=()=>(0,Jo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,Jo.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,Jo.jsx)("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"})]});var xe=require("react"),Ul=require("react-redux"),ai=require("interweave"),li=k(require("classnames"));var Jr={root:"_root_smoda_1",agentText:"_agentText_smoda_3",textInput:"_textInput_smoda_8",textInputWrapper:"_textInputWrapper_smoda_27",alert:"_alert_smoda_31",alertText:"_alertText_smoda_50",warning:"_warning_smoda_60",success:"_success_smoda_69"};var bl=require("interweave"),Cl=k(require("classnames"));var go=require("react");function xl(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function xs(t){let e=(0,go.useRef)(null),[o,n]=(0,go.useState)(!1);return(0,go.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=xl((p,d)=>{let g=e.current;if(!g)return;let u=p/r,m=d/r,f=g.getBoundingClientRect(),h=u>f.x&&u<f.x+f.width&&m>f.y&&m<f.y+f.height;h&&!s?(s=!0,n(!0)):!h&&s&&(s=!1,n(!1))},({clientX:p,clientY:d})=>[p,d]),[l,c]=xl(()=>{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 $e={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"};var Yr=require("react/jsx-runtime"),tm=({inputElement:t,children:e})=>{let o=y("TabCompletion",$e),[n,s]=xs(t);return(0,Yr.jsx)("mark",{ref:n,className:(0,Cl.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},mo=class extends bl.Matcher{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(0,Yr.jsx)(tm,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var fo=require("react");function bs(t){return t.contentEditable==="true"}function om(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 wl(t){let{selectionStart:e,selectionEnd:o}=bs(t)?om(t):t;return[e,o]}function Cs(t){let[,e]=(0,fo.useState)(),o=(0,fo.useRef)(null);return o.current=wl(t),(0,fo.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=wl(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 ws(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(ao);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)})}var Tl=require("react");function ho(t){(0,Tl.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Dt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var El,Fe=new Map,nm=["bottom","height","left","right","top","width"],sm=(t={},e={})=>nm.some(o=>t[o]!==e[o]);function kl(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,...kl(e)]:[]}function Rl(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var Ts=!1,Il=()=>{Ts=!0;let t=[];if(Fe.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),Fe.delete(o);return}let n=o.getBoundingClientRect();sm(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(Rl,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),Fe.size===0){Ts=!1;return}El=window.requestAnimationFrame(Il)};function ei(t,e){let o=kl(t),n=[],s=o.map((r,i)=>ei(r,a=>{n[i]=a;let l=Fe.get(t);if(!l)return;let c=n.reduce(Rl,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),Fe.has(t)){let i=Fe.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Fe.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!Ts&&Il()},unobserve(){s.forEach(i=>i.unobserve());let r=Fe.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||Fe.delete(t),Fe.size||(cancelAnimationFrame(El),Ts=!1)}}}}var Pl,Ke=new Map,Al=()=>{Ke.forEach((t,e)=>{if(!e.isConnected){Ke.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)))}),Ke.size!==0&&(Pl=window.requestAnimationFrame(Al))};function Ll(t,e){return{observe(){let o=Ke.size===0;Ke.has(t)?Ke.get(t).callbacks.push(e):Ke.set(t,{visible:void 0,callbacks:[e]}),o&&Al()},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(Pl)}}}}var ti=["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 oi(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function yo(t){return parseFloat(t)}function Es(t){return Math.round(t*1e6)}function Ml(t){return t/1e6}function ni(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=yo(t.width),r=yo(t.borderLeftWidth),i=yo(t.borderRightWidth),a=yo(t.paddingRight),l=Ml(Es(s)-Es(r)-Es(i)),c=Ml(Es(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function Ht(t,e={}){var p;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",Dt(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};oi(n,o,ti),ni(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=Ll(t,()=>{oi(n,o,ti),ni(n,t,o),r(),setTimeout(r,0)}),a,l=!0,c=ei(t,d=>{if(d===null){e.onRemove&&e.onRemove(),o.remove();return}if(!l&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(oi(n,o,ti),ni(n,t,o),r(),o.style.top=`${d.top}px`,o.style.left=`${d.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let g=e.closestScrollElement.getBoundingClientRect(),u=window.getComputedStyle(e.closestScrollElement),m=yo(u.borderTopWidth),f=yo(u.borderBottomWidth),h=g.top+m-d.top,E=d.top+d.height+-(g.top+g.height-f);o.style.clipPath=`inset(${h}px 0px ${E}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(p=t.parentElement)==null||p.appendChild(o),c.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),c.unobserve(),i.unobserve()}]}var si={};$(si,{enUS:()=>rm,nlNL:()=>im});var rm={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"}]},im={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"}]};var Yo=require("react/jsx-runtime"),Nl=()=>(0,Yo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,Yo.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,Yo.jsx)("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"})]});var ri=require("react/jsx-runtime"),Ol=()=>(0,ri.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,ri.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var Dl=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(Dl||{}),Ge=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();mt(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(Dl).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var n,s;let o=((n=e.clipboardData)==null?void 0:n.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",o=>this.handleKeyDown(o)),this.addEventListener("keyup",o=>this.handleKeyUp(o)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",o=>this.handlePaste(o)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()}),this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};var Xe=class extends Ge{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 am=/[.*+?^${}()|[\]\\]/g,lm=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function cm(t){return t.replace(am,"\\$&")}function pm(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function dm(t){return t.search(lm)}function Hl(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${cm(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function Bl(t){return t.replace(ao,'<mark data-type="placeholder">$1</mark>')}function vo(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function um(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 ii(t,e,o={}){if(e){let n=pm(e.toLowerCase(),t.toLowerCase()),s=vo(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=dm(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(Ha).length>3||e.length>30?um(e.trim(),n):0;return`${`${i>0?"\u2026":""}${vo(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var gm=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function Bt(t){return gm.test(t)}function Fl(t){if(Bt(t)){let o=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(t);return o?o[1]:""}return t}function Kl(t){let e=document.createElement("template");return e.innerHTML=t,e.content.textContent??""}var Y=require("react/jsx-runtime"),mm=({value:t,onUse:e,...o})=>{var d;let n=T(si),s=(0,Ul.useDispatch)(),r=Bt(t),i=y("EditSuggestionTextInput",Jr),[a,l]=(0,xe.useState)(null),c=(0,xe.useRef)(null),p=((d=t.match(ao))==null?void 0:d.length)||0;return(0,xe.useEffect)(()=>{let g;return c.current&&(l(c.current),g=new Xe(c.current),g.on("change",({plainText:u})=>{s(ae.actions.userInput({text:u,selection:g.getSelection()}))}),g.on("keydown",u=>{s(ae.actions.registerKeyDown(es(u))),u.code==="Enter"&&u.shiftKey&&e(g.getText())}),g.on("paste",({pastedText:u,selectionText:m})=>{s(ae.actions.registerPaste({text:u,selectionText:m}))}),g.on("cut",({selectionText:u})=>{s(ae.actions.registerCut(u))})),()=>{s(ae.actions.reset()),g.dispose(),g.deactivate()}},[c]),(0,xe.useEffect)(()=>{t&&c.current&&(c.current.value=t)},[t,c]),(0,xe.useEffect)(()=>{c.current&&setTimeout(()=>{if(!c.current)return;let g=c.current.value.length;c.current.setSelectionRange(g,g),c.current.focus()},0)},[c]),r?(0,Y.jsx)("div",{className:i.textInputWrapper,children:(0,Y.jsx)(ai.Interweave,{className:i.textInput,tagName:"div",content:t})}):(0,Y.jsxs)("div",{className:i.textInputWrapper,children:[(0,Y.jsx)("textarea",{...o,ref:c,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:t,onChange:()=>{}}),a&&(0,Y.jsx)(fm,{inputElement:c.current,value:t}),(0,Y.jsxs)("div",{className:(0,li.default)(i.alert,p===0?i.success:i.warning),children:[(0,Y.jsx)("div",{className:i.alertText,children:n("placeholders",{placeholderSize:p})}),p===0?(0,Y.jsx)(Nl,{}):(0,Y.jsx)(Ol,{})]})]})},fm=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",Jr),n=(0,xe.useRef)(null),s=Cs(t);return(0,xe.useEffect)(()=>{ws(t,s)},[s,t]),(0,Y.jsx)(hm,{inputElement:t,children:(0,Y.jsxs)("div",{ref:n,className:(0,li.default)(o.root,o.agentText),children:[(0,Y.jsx)(ai.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new mo("placeholders")],inputElement:t,boundaryRef:n}),(0,Y.jsx)("br",{})]})})},hm=({inputElement:t,children:e})=>{let o=(0,xe.useRef)(null);return(0,xe.useEffect)(()=>{if(!o.current)return()=>{};let[n,s]=Ht(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),(0,Y.jsx)("div",{ref:o,children:e})},zl=mm;var bo=require("react");var jl=require("react"),ks=k(require("classnames"));var le={root:"_root_1xflk_1",list:"_list_1xflk_2",listWrapper:"_listWrapper_1xflk_6",listHorizontal:"_listHorizontal_1xflk_10",page:"_page_1xflk_19",search:"_search_1xflk_25",pageNav:"_pageNav_1xflk_33",pageTitle:"_pageTitle_1xflk_41",pageBackButton:"_pageBackButton_1xflk_48",listHeader:"_listHeader_1xflk_62",listHeading:"_listHeading_1xflk_68",listMoreButton:"_listMoreButton_1xflk_76",listItem:"_listItem_1xflk_87",listItemContent:"_listItemContent_1xflk_96",listItemText:"_listItemText_1xflk_114",listItemDescription:"_listItemDescription_1xflk_122",listItemActions:"_listItemActions_1xflk_129",truncate:"_truncate_1xflk_140",lineClamp:"_lineClamp_1xflk_146",listItemTitle:"_listItemTitle_1xflk_153",listItemAction:"_listItemAction_1xflk_129",listItemPrimaryAction:"_listItemPrimaryAction_1xflk_174",listItemSelected:"_listItemSelected_1xflk_179",sources:"_sources_1xflk_183",sourcesTitle:"_sourcesTitle_1xflk_190",source:"_source_1xflk_183",icon:"_icon_1xflk_205",searchIcon:"_searchIcon_1xflk_222",searchInputWrapper:"_searchInputWrapper_1xflk_227",searchInput:"_searchInput_1xflk_227",select:"_select_1xflk_248",selectType:"_selectType_1xflk_265",selectWrapper:"_selectWrapper_1xflk_269",image:"_image_1xflk_299",imageSrc:"_imageSrc_1xflk_306",imageSrcHidden:"_imageSrcHidden_1xflk_317",imageSrcStatus:"_imageSrcStatus_1xflk_321",imageTitle:"_imageTitle_1xflk_331",actions:"_actions_1xflk_336",actionsWrapper:"_actionsWrapper_1xflk_340",actionsBar:"_actionsBar_1xflk_346",actionButton:"_actionButton_1xflk_355",hasShortKeys:"_hasShortKeys_1xflk_368",actionShortcut:"_actionShortcut_1xflk_377",actionShortcutFixKerning:"_actionShortcutFixKerning_1xflk_384"};var Ze={};$(Ze,{enUS:()=>ym,nlNL:()=>vm});var ym={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}],showAll:[{type:0,value:"Show more"}]},vm={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}],showAll:[{type:0,value:"Toon meer"}]};var yt=require("react/jsx-runtime"),Sm=({src:t,title:e})=>{let o=y("CommandPalette",le),[n,s]=(0,jl.useState)("loading"),r=T(Ze);return(0,yt.jsxs)("div",{className:o.image,children:[(0,yt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,ks.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,yt.jsx)("span",{className:(0,ks.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,yt.jsx)("span",{className:(0,ks.default)(o.imageSrc,o.imageSrcStatus),children:(0,yt.jsx)(Fn,{})}),e&&(0,yt.jsx)("span",{className:o.imageTitle,children:e})]})},Vl=Sm;var ql=k(require("react")),Wl=k(require("classnames"));var Ft=require("react/jsx-runtime");function ci({children:t,heading:e,orientation:o,hasMore:n,onShowAll:s}){let r=T(Ze),i=y("CommandPalette",le);return ql.default.Children.count(t)===0?null:(0,Ft.jsxs)("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||n)&&(0,Ft.jsxs)("div",{className:i.listHeader,children:[e&&(0,Ft.jsx)("h4",{className:i.listHeading,children:e}),n&&s&&(0,Ft.jsx)("button",{onClick:s,className:i.listMoreButton,type:"button",children:r("showAll")})]}),(0,Ft.jsx)("div",{className:(0,Wl.default)(i.listWrapper,o==="horizontal"&&i.listHorizontal),children:t})]})}var en=k(require("classnames")),ec=require("interweave");var Z=k(require("react")),$l=k(require("classnames"));var pi={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"};var Kt=require("react/jsx-runtime"),_m=0,Gl=Z.default.createContext(null),xm=()=>{let t=(0,Z.useContext)(Gl);if(!t)throw new Error("Invalid DropdownContext");return t},Xl=({trigger:t,children:e,position:o="bottom"})=>{let n=(0,Z.useMemo)(()=>++_m,[]),s=(0,Z.useRef)(null),r=(0,Z.useRef)(null),i=y("Dropdown",pi),[a,l]=(0,Z.useState)(!1),[c,p]=(0,Z.useState)(o),d=u=>{u.preventDefault(),u.stopPropagation(),l(!a)},g=(0,Z.useCallback)(([u])=>{!u.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return(0,Z.useEffect)(()=>{let u=m=>{s.current&&!s.current.contains(m.target)&&l(!1)};return document.addEventListener("click",u),()=>{document.removeEventListener("click",u)}},[]),(0,Z.useEffect)(()=>{if(!r.current&&!a)return()=>{};let u=new IntersectionObserver(g,{root:null,rootMargin:"0px",threshold:1});return r.current&&u.observe(r.current),()=>{r.current&&u.unobserve(r.current)}},[r,a]),(0,Kt.jsx)(Gl.Provider,{value:{setIsOpen:l},children:(0,Kt.jsxs)("div",{ref:s,className:i.root,children:[(0,Kt.jsx)("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}),(0,Kt.jsx)("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:(0,$l.default)(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function bm({as:t,children:e,onClick:o,...n}){let s=t||"button",r=y("Dropdown",pi),{setIsOpen:i}=xm(),a=l=>{i(!1),o(l),l.stopPropagation()};return(0,Kt.jsx)(s,{type:"button",className:r.item,onClick:a,...n,children:e})}Xl.Item=bm;var di=Xl;var ui=require("react/jsx-runtime"),Zl=t=>(0,ui.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:(0,ui.jsx)("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 Ut={};$(Ut,{enUS:()=>Cm,nlNL:()=>wm});var Cm={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"}]},wm={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],giveFeedback:[{type:0,value:"Geef feedback"}],answer:[{type:0,value:"Antwoord"}]};var Rs=require("react/jsx-runtime"),Tm="%0d%0a%0d%0a%0d%0a",Em=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(Tm)}`},km=({suggestion:t,onFeedback:e})=>{let o=T(Ut),n=C("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:(0,Rs.jsx)(di,{trigger:(0,Rs.jsx)(Zl,{"data-testid":"feedback-dropdown-trigger"}),children:(0,Rs.jsx)(di.Item,{as:"a",href:Em(n,t),onClick:e,children:o("giveFeedback")})})},Is=km;var Ps=k(require("react")),Yl=require("react/jsx-runtime"),Ql=Ps.default.createContext(void 0);function vt(){let t=Ps.default.useContext(Ql);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Jl=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=Ps.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,Yl.jsx)(Ql.Provider,{value:i,children:t})};var ge=require("react/jsx-runtime");function gi({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:g,onChangeOpen:u}=vt(),m=y("CommandPalette",le);function f(h){n(h),t&&u(!1)}return(0,ge.jsxs)("div",{className:(0,en.default)(m.listItem,d===i&&m.listItemSelected),children:[(0,ge.jsx)("button",{onMouseEnter:()=>g(i),type:"button",className:(0,en.default)("command-palette-list-item",m.listItemAction,m.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:f,...p,children:(0,ge.jsxs)("div",{className:m.listItemContent,children:[typeof o=="string"?(0,ge.jsx)("p",{className:(0,en.default)(m.listItemText,m.truncate,c==null?void 0:c.title),children:o}):o,a&&(0,ge.jsx)(ec.Interweave,{tagName:"p",allowList:[],content:Bt(a)?Kl(a):a,className:(0,en.default)(m.listItemDescription,c==null?void 0:c.description,e?m.lineClamp:m.truncate)})]})}),s&&d===i&&(0,ge.jsx)("div",{className:m.listItemActions,children:(0,ge.jsx)(Is,{suggestion:String(o),onFeedback:s})}),l&&(0,ge.jsxs)("div",{className:m.sources,children:[(0,ge.jsx)("span",{className:m.sourcesTitle,children:"Sources"}),l.map(h=>h.url?(0,ge.jsx)("a",{className:m.source,href:h.url,target:"_blank",title:h.url,rel:"noopener noreferrer",onClick:()=>r&&r(h),children:h.name},h.url):(0,ge.jsx)("span",{className:m.source,children:h.name},h.name))]})]})}var zt=require("react/jsx-runtime");function mi({children:t,title:e,id:o,onDismiss:n}){let s=T(Ze),r=y("CommandPalette",le),{page:i}=vt();return i!==o?null:(0,zt.jsxs)("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,zt.jsxs)("div",{className:r.pageNav,children:[(0,zt.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:n,children:[(0,zt.jsx)(_s,{}),s("back")]}),e&&(0,zt.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var St=require("react");var Ls=require("@reduxjs/toolkit");var So=require("@reduxjs/toolkit");function Rm(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function N(t){return Array.isArray(t)?t.map(N):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Rm(o)]:N(t[o])}),{}):t}function fi(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function G(t){return Array.isArray(t)?t.map(G):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[fi(o)]:G(t[o])}),{}):t}var Im={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},on=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)||""}},tn=(0,So.createAsyncThunk)("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?N(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),N(n))}),hi=(0,So.createAsyncThunk)("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}),yi=(0,So.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),tc=t=>t.info.agentInfo,oc=(0,So.createSlice)({name:"info",initialState:Im,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(tn.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(tn.rejected,e=>{e.fetchState="error"}).addCase(tn.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(hi.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(yi.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(M,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:nc}=oc.actions,sc=oc.reducer;var As={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},rc=t=>t.search.isOpen,ic=t=>t.search.page,ac=t=>t.search.list,lc=t=>t.search.aggregates;function cc(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var jt=(0,Ls.createAsyncThunk)("search/getAll",async(t,e)=>{var a;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(a=n.conversation.current)==null?void 0:a.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r,aggregates:i}=await o.search({profile:s,query:t.query,tags:t.tags,size:t.size,current:t.current,filters:{type:t.type},params:on(n)});return{results:r.map(l=>({...l,source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:i}}),pc=(0,Ls.createSlice)({name:"search",initialState:As,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=As.fetchState,t.list=As.list}},extraReducers:t=>{t.addCase(jt.pending,e=>{e.fetchState="loading"}).addCase(jt.rejected,(e,o)=>{e.fetchState="error",w.error(o.error)}).addCase(jt.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload.results,e.aggregates=o.payload.aggregates||{}}).addCase(M,()=>As)}}),{resetSearch:Ms,setIsOpen:te,setPage:oe}=pc.actions,dc=pc.reducer;var Pm=/(https?:\/\/[^\s]+)/,Ns=t=>t.split(" ").find(e=>Pm.test(e));var Os=()=>/Mac/i.test(navigator.platform);var vi=k(require("classnames"));var Ds=require("react/jsx-runtime"),Am=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",le);return(0,Ds.jsxs)("button",{type:"button",...n,onClick:t,className:(0,vi.default)(s.actionButton,n.className,{[s.hasShortKeys]:e&&e.length>0}),children:[o,e&&e.map(r=>(0,Ds.jsx)("span",{className:(0,vi.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},_o=Am;var Qe=require("react/jsx-runtime"),Lm=["url","URL"],Mm=["default","pinned-message","DEFAULT","STICKYMESSAGE"],Nm=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",le),a=T(Ze),{selected:l,setSelected:c}=vt(),p=r[l],d=p&&p.type&&Lm.includes(p.type),g=p&&p.type&&Mm.includes(p.type)||p&&"secondaryAction"in p,u=d?Ns(p.text):null,m=(0,St.useRef)(null);function f(v){if(!m.current)return;let A=m.current.querySelectorAll(".command-palette-list-item"),O=0,K=0;v==="down"?(A.forEach((W,z)=>{z===l&&(O=z)}),K=O===A.length-1?0:O+1):v==="up"?(A.forEach((W,z)=>{z===l&&(O=z)}),K=O?O-1:A.length-1):c(0);let H=A[K];H&&typeof K=="number"&&(c(K),H.scrollIntoView&&H.scrollIntoView({behavior:"smooth",block:K?"center":"end"}))}function h(){if(!m.current)return;let v=m.current.querySelectorAll(".command-palette-list-item"),A=0;v.forEach((K,H)=>{H===l&&(A=H)});let O=v[A];O&&O.click()}let E=()=>{u&&window.open(u,"_blank")},x=()=>{p&&n(p,l)},_=()=>{!s||!g||s(p,l)},b=(0,St.useCallback)(v=>{if(v.key==="Enter"&&v.altKey&&u){E();return}if(v.key==="Enter"&&v.shiftKey){_();return}if(v.key==="ArrowDown"){v.preventDefault(),v.stopPropagation(),f("down");return}if(v.key==="ArrowUp"){v.preventDefault(),v.stopPropagation(),f("up");return}v.key==="Enter"&&l!==-1&&(v.preventDefault(),v.stopPropagation(),h())},[l]);return(0,St.useEffect)(()=>(window.addEventListener("keyup",b),()=>{window.removeEventListener("keyup",b)}),[b]),(0,Qe.jsxs)("div",{className:i.actions,children:[(0,Qe.jsx)("div",{className:i.actionsWrapper,ref:m,children:t}),(0,Qe.jsxs)("div",{className:i.actionsBar,children:[u&&(0,Qe.jsx)(_o,{onClick:E,shortKeys:[Os()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,Qe.jsxs)(St.Fragment,{children:[s&&g&&(0,Qe.jsx)(_o,{onClick:_,shortKeys:[8679,8629],children:o}),(0,Qe.jsx)(_o,{onClick:x,shortKeys:[8629],children:e})]})]})]})},gc=Nm;var mc=require("react");var nn=require("react/jsx-runtime"),xo=()=>(0,nn.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,nn.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,nn.jsx)("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"})]});var Ae=require("react/jsx-runtime");function Om({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",le);return(0,Ae.jsxs)("div",{className:l.search,children:[(0,Ae.jsx)("div",{className:l.searchIcon,children:(0,Ae.jsx)(xo,{})}),(0,Ae.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Ae.jsx)("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&&(0,Ae.jsx)("div",{className:l.selectWrapper,children:(0,Ae.jsxs)("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&&(0,Ae.jsx)("option",{children:n}),s.map(c=>(0,Ae.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var fc=(0,mc.forwardRef)(Om);var sn=require("react/jsx-runtime");function Vt({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:g}){let[u,m]=(0,bo.useState)(0),f=(0,bo.useRef)(null),h=()=>{s&&s(o),i(void 0),r(""),a(!1)},E=()=>{var x;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(x=f.current)==null||x.focus();return}if(g.length>0){r("");return}a(!1)};return(0,bo.useEffect)(()=>{m(0)},[g,n]),(0,sn.jsx)(uo,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:E,onClose:h,children:(0,sn.jsxs)(Jl,{selected:u,setSelected:m,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&(0,sn.jsx)(fc,{ref:f,onChange:r,onChangeType:i,placeholder:t,value:g,selectedType:l,types:c,typePlaceholder:e}),p]})})}Vt.Page=mi;Vt.List=ci;Vt.Image=Vl;Vt.ListItem=gi;Vt.ActionsBar=gc;Vt.Button=_o;var P=Vt;var ee=require("react/jsx-runtime"),Dm=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",pl),l=(0,Hs.useDispatch)(),c=T(jr),p=(0,Hs.useSelector)(m=>m.overlayInput.text);(0,Si.useEffect)(()=>{t&&(l(ae.actions.reset()),l(ae.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(ae.actions.commitSuggestion()))},[t]);let d=m=>{m.preventDefault(),g(p)},g=m=>{l(ns(m)),e(m)},u=m=>f=>{p!==i?window.confirm(c("warning"))&&m(f):m(f)};return(0,Si.useEffect)(()=>{n&&n(p!==i)},[n,t,p]),(0,ee.jsxs)("div",{className:a.root,children:[(0,ee.jsxs)("div",{className:a.content,children:[t.title&&(0,ee.jsx)("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&(0,ee.jsx)(Or,{labels:t.searchKeywords}),(0,ee.jsx)(zl,{onUse:g,value:Fl(p)})]}),(0,ee.jsxs)("form",{className:a.actions,onSubmit:d,children:[(0,ee.jsxs)("div",{children:[(0,ee.jsx)("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&u(r),children:(0,ee.jsx)(_s,{})}),(0,ee.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&u(s),children:(0,ee.jsx)(_l,{})})]}),(0,ee.jsxs)("div",{className:a.primaryButtons,children:[(0,ee.jsx)(P.Button,{onClick:u(o),shortKeys:["esc"],children:c("dismiss")}),(0,ee.jsx)(P.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},Bs=Dm;var qt=require("@reduxjs/toolkit");var Hm=["{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}"],Bm=new RegExp(Hm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function hc(t,e){let o=t.split(Bm),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),g=0;do c=d?e.indexOf(d,c+1):-1,g+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&g>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 yc(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Sc={suggestions:[],fetchState:"idle",isInitialRequest:null},vc={default:Sc},Fs=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},_c=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")},_t=t=>t.textSuggestions,xc=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},Ks=(0,qt.createAction)("textSuggestions/refresh"),Le=(0,qt.createAsyncThunk)("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=co(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,on(n),t);if(t==="default"){let p=i?l.filter(xc(a)):l;e.dispatch(Be(p.slice(0,r)))}return l}),rn=(0,qt.createAsyncThunk)("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,{...on(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(xc(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?hc(p.text,t):p.text}))),l=yc(l,r),e.dispatch(Be(l)),l}),bc=(0,qt.createSlice)({name:"textSuggestions",initialState:vc,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(Le.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||Sc;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(Le.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(Le.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(rn.pending,e=>{e.default.fetchState="loading"}).addCase(rn.rejected,e=>{e.default.fetchState="error"}).addCase(rn.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(M,()=>vc)}}),{setTextSuggestions:Cc,setSuggestionState:wc}=bc.actions,Tc=bc.reducer;var kc=require("@reduxjs/toolkit");var Ec={contentType:null,suggestion:null},Rc=t=>t.activeSuggestion.suggestion,Ic=t=>t.activeSuggestion.contentType,Pc=(0,kc.createSlice)({name:"activeSuggestion",initialState:Ec,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(M,()=>Ec)}}),{setActiveSuggestion:Je,resetActiveSuggestion:_i}=Pc.actions,Ac=Pc.reducer;var xi={};$(xi,{enUS:()=>Fm,nlNL:()=>Km});var Fm={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"}]},Km={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"}]};var Lc=require("@reduxjs/toolkit"),Um={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Us=({ui:t})=>t.overlayCollapsed;var Mc=(0,Lc.createSlice)({name:"ui",initialState:Um,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:an,setInputHasFocus:Co,setOverlayCollapsed:xt,setOpenOverlayWhenTyping:Nc,setOverlayCollapsedUserOverwrite:Oc}=Mc.actions,Dc=Mc.reducer;var ln=k(require("react")),Bc=require("react/jsx-runtime"),Hc=ln.default.createContext(null),Wt=({broadcastEvents:t,children:e})=>{let o=ln.default.useMemo(()=>t,[]);return(0,Bc.jsx)(Hc.Provider,{value:o,children:e})},be=()=>{let t=(0,ln.useContext)(Hc);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var wo=require("@reduxjs/toolkit");var zm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ne=t=>t.auth.isLoggedIn,Fc=t=>t.auth.loginFetchState,Kc=t=>t.auth.verifyFetchState,Uc=t=>t.auth.showLoginOverlay,Ye=(0,wo.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),zc=(0,wo.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),cn=(0,wo.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),jc=(0,wo.createSlice)({name:"auth",initialState:zm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(Ye.pending,e=>{e.loginFetchState="loading"}),t.addCase(Ye.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(Ye.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(cn.pending,e=>{e.verifyFetchState="loading"}),t.addCase(cn.rejected,e=>{e.verifyFetchState="error"}),t.addCase(cn.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:To,setShowLoginOverlay:Vc}=jc.actions,qc=jc.reducer;var Eo=require("@reduxjs/toolkit");var bi={cues:[],fetchState:"idle"},Wc=t=>{var e;return(e=t.rules)==null?void 0:e.cues},jm=(0,Eo.createAction)("rules/resetCues"),et=(0,Eo.createAsyncThunk)("rules/evaluate",async(t,e)=>{var r;let{deepdeskAPI:o}=e.extra,n=(r=e.getState().conversation.current)==null?void 0:r.id;if(!n)throw new Error("No current conversation to evaulate rules");return await o.evaluateRule(t.label,n,t.params)}),$c=(0,Eo.createSlice)({name:"answer",initialState:bi,reducers:{removeCue(t,e){t.cues=t.cues.filter(o=>o.id!==e.payload.id)}},extraReducers:t=>{t.addCase(et.pending,e=>{e.fetchState="loading"}).addCase(et.rejected,e=>{e.fetchState="error"}).addCase(et.fulfilled,(e,o)=>{let n=Date.now(),s=o.payload.map(a=>({id:a.id||a.text,timestamp:n,...a})),r=s.map(a=>a.id),i=e.cues.filter(a=>!r.includes(a.id));e.fetchState="done",e.cues=[...s,...i]}).addCase(M,()=>bi).addCase(jm.toString(),()=>bi)}}),{removeCue:Nb}=$c.actions,Gc=$c.reducer;var Ci="SetActiveSuggestion",wi="SetCues",ko="ShowLoginOverlay",pn="UserLoggedIn",Vm="UserLoggedOut",tt="ApplySuggestion",Ti="ApplyImageSuggestion",qm="ShowCommandPalette",Wm=t=>({[Ci]:e=>{t.dispatch(wc(e.state)),t.dispatch(Je({contentType:e.contentType,suggestion:e.suggestion}))},[wi]:e=>{t.dispatch({type:et.fulfilled,payload:e})},[qm]:e=>{t.dispatch(te(e.isOpen)),e.page&&t.dispatch(oe(e.page))},[ko]:e=>{t.dispatch(Vc(e))},[pn]:()=>{t.dispatch(Ye())},[Vm]:()=>{t.dispatch(Ye())},[Ti]:e=>{t.dispatch(rs({suggestion:e.suggestion}))},[tt]:e=>{t.dispatch(Ie({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(We())}}),Xc=Wm;var Ei=require("react/jsx-runtime"),$m=()=>{var m;let[t,e]=(0,Zc.useState)(!1),o=(0,Ro.useSelector)(Rc),n=(0,Ro.useSelector)(Ic),s=(0,Ro.useSelector)(_t),r=(0,Ro.useDispatch)(),i=be(),a=T(xi),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(_i()),r(Co(!0)),r(ae.actions.reset())},p=(f,h)=>{r(_i()),r(Co(!0)),i.send(tt,{text:f,suggestion:{...h,source:`${h.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let d=(m=s[n])==null?void 0:m.suggestions.indexOf(o),g=d===0||d===null?void 0:()=>r(Je({contentType:n,suggestion:s[n].suggestions[d-1]})),u=d===s[n].suggestions.length-1||d===null?void 0:()=>r(Je({contentType:n,suggestion:s[n].suggestions[d+1]}));return(0,Ei.jsx)(uo,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,Ei.jsx)(Bs,{onTouched:e,onDismiss:c,onUse:f=>p(f,o),suggestion:o,onNext:u,onPrevious:g})})},Qc=$m;var Ri=require("react-redux");var zs=k(require("classnames")),Me=require("react"),js=require("react-redux");var Yc=k(require("classnames"));var Jc={root:"_root_1ukx5_1"};var ep=require("react/jsx-runtime"),Gm=({className:t,value:e,...o})=>{let n=y("TextInput",Jc);return(0,ep.jsx)("input",{className:(0,Yc.default)(t,n.root),type:"text",value:e,...o})},dn=Gm;var ki={};$(ki,{enUS:()=>Xm,nlNL:()=>Zm});var Xm={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"}]},Zm={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 tp={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"};var U=require("react/jsx-runtime");var Qm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Jm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=T(ki),i=y("LoginTokenDialog",tp),a=(0,js.useSelector)(Kc),l=(0,js.useDispatch)(),c=C("productName"),[p,d]=(0,Me.useState)(t||""),[g,u]=(0,Me.useState)(0),[m,f]=(0,Me.useState)(""),h=(0,Me.useCallback)(async b=>{b.preventDefault(),l(zc({email:p})),u(1)},[o,p]),E=()=>{f(""),u(0)},x=(0,Me.useCallback)(async b=>{b.preventDefault();let v=Qm(b.target.elements.token.value);if(!v){f(r("verifyCodeError",{login:_}));return}l(cn({token:v}))},[o]),_=(0,Me.useMemo)(()=>b=>(0,U.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:E,children:b},"back-button"),[]);return(0,Me.useEffect)(()=>{a==="error"&&f(r("verifyCodeError",{login:_})),a==="done"&&n()},[a]),(0,U.jsx)(uo,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:(0,U.jsxs)("div",{className:i.root,children:[(0,U.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:c})}),g===0&&(0,U.jsxs)("form",{onSubmit:h,children:[(0,U.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,U.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),(0,U.jsx)(dn,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:b=>d(b.target.value)}),(0,U.jsx)("div",{className:i.actions,children:(0,U.jsx)("button",{type:"submit",className:(0,zs.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),g===1&&(0,U.jsxs)("form",{onSubmit:x,children:[(0,U.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,U.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,U.jsx)(dn,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),m&&(0,U.jsx)("div",{className:i.errorMessage,children:m}),(0,U.jsxs)("div",{className:i.actions,children:[(0,U.jsx)("button",{type:"button",className:(0,zs.default)(i.button),onClick:E,children:r("back")}),(0,U.jsx)("button",{type:"submit",className:(0,zs.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},op=Jm;var sp=require("react/jsx-runtime"),Ym=()=>{let t=(0,Ri.useSelector)(Uc),e=(0,Ri.useSelector)(tc),o=C("adminUrl"),n=be(),s=()=>n.send(ko,!1),r=()=>{n.send(ko,!1),n.send(pn)};return(0,sp.jsx)(op,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},np=Ym;var Lp=k(require("lodash.debounce")),se=require("react"),Ue=require("react-redux");var Vs=require("@reduxjs/toolkit");var ef={data:null,fetchState:"idle"},rp=t=>t.contentTypes.data,un=(0,Vs.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),tf=(0,Vs.createSlice)({name:"contentTypes",initialState:ef,reducers:{},extraReducers:t=>{t.addCase(un.pending,e=>{e.fetchState="loading"}).addCase(un.rejected,e=>{e.fetchState="error"}).addCase(un.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),ip=tf.reducer;function $t(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()}var ap=require("react");function lp(t,e){(0,ap.useEffect)(()=>{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)}},[])}var gn=require("react"),$s=require("react-redux");var qs=require("@reduxjs/toolkit");var cp={data:null,fetchState:"idle"},Ws=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},Ne=(0,qs.createAsyncThunk)("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)}),of=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),nf=(0,qs.createSlice)({name:"entities",initialState:cp,reducers:{},extraReducers:t=>{t.addCase(Ne.pending,e=>{e.fetchState="loading"}).addCase(Ne.rejected,e=>{e.fetchState="error"}).addCase(Ne.fulfilled,(e,o)=>{e.fetchState="done",e.data=of(e.data?[...e.data,...o.payload]:o.payload)}).addCase(M,()=>cp)}}),pp=nf.reducer;var Ii={};$(Ii,{enUS:()=>sf,nlNL:()=>rf});var sf={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},rf={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var dp={root:"_root_17kae_1",empty:"_empty_17kae_5"};var Gt=require("react/jsx-runtime"),af=({onCopy:t,onUse:e})=>{let o=(0,gn.useRef)(null),n=y("EntitiesList",dp),s=T(Ii),r=(0,$s.useSelector)(Ws),i=(0,$s.useDispatch)();return(0,gn.useEffect)(()=>{i(Ne())},[]),(0,gn.useEffect)(()=>{o.current&&o.current.focus()},[o]),(0,Gt.jsxs)("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&(0,Gt.jsx)(P.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:(0,Gt.jsx)(P.List,{children:r.map((a,l)=>(0,Gt.jsx)(P.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&(0,Gt.jsx)("p",{className:n.empty,children:s("noResults")})]})},up=af;var Oe=require("react"),mn=require("react-redux");var Gs=require("@reduxjs/toolkit");var gp={data:null,fetchState:"idle"},mp=t=>t.summary.data,fp=t=>t.summary.fetchState==="error",ot=(0,Gs.createAsyncThunk)("summary/getSummary",async(t,e)=>{var p,d,g;let o=e.getState().profile.data,n=(p=e.getState().conversation.current)==null?void 0:p.sessionId,s=(g=(d=e.getState().info)==null?void 0:d.agentInfo)==null?void 0:g.agentId;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:r,dynamicThunkObject:i}=e.extra;if(!i.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let a=i.conversationQuery,l=await a();if(l.length===0)return Promise.reject(new Error("No messages are included"));let c=await r.getSummary(l,{externalConversationId:n,agentId:s,promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return c?{summary:c}:Promise.reject(new Error("Summary is not provided"))}),lf=(0,Gs.createSlice)({name:"summary",initialState:gp,reducers:{},extraReducers:t=>{t.addCase(ot.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(ot.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(ot.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(M,()=>gp)}}),hp=lf.reducer;var Pi={};$(Pi,{enUS:()=>cf,nlNL:()=>pf});var cf={copy:[{type:0,value:"Copy"}],error:[{type:0,value:"Could not generate a summary"}],loading:[{type:0,value:"Generating summary, this may take a few moments."}]},pf={copy:[{type:0,value:"Kopieer"}],error:[{type:0,value:"Kon helaas geen samenvatting genereren."}],loading:[{type:0,value:"Samenvatting wordt gemaakt, dit kan even duren."}]};var yp={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};var nt=require("react/jsx-runtime"),df=({onCopy:t})=>{let e=(0,Oe.useRef)(null),o=y("SummaryForm",yp),[n,s]=(0,Oe.useState)(""),r=T(Pi),i=(0,mn.useSelector)(mp),a=(0,mn.useSelector)(fp),l=(0,mn.useDispatch)(),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(0,Oe.useEffect)(()=>{l(ot())},[]),(0,Oe.useEffect)(()=>{s(i||"")},[i]),(0,Oe.useEffect)(()=>{e.current&&i&&e.current.focus()},[e,i]),(0,Oe.useEffect)(()=>{let d=g=>{g.key==="Enter"&&g.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[n]),(0,nt.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,nt.jsx)("p",{className:o.error,children:r("error")}):(0,nt.jsxs)(Oe.Fragment,{children:[(0,nt.jsx)("div",{className:o.main,children:(0,nt.jsx)("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:d=>s(d.target.value)})}),(0,nt.jsx)("div",{className:o.actions,children:(0,nt.jsx)(P.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},vp=df;var fn={};$(fn,{enUS:()=>uf,nlNL:()=>gf});var uf={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},gf={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?"}]};var bt=k(require("react")),vn=require("react-redux");var Ai={};$(Ai,{enUS:()=>mf,nlNL:()=>ff});var mf={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"}]},ff={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 Sp={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"};var Po=require("@reduxjs/toolkit");var Xs=require("@reduxjs/toolkit");var hf={data:null,fetchState:"idle"},_p=t=>{var e;return(e=t.knowledgeAssistant)==null?void 0:e.data},hn=(0,Xs.createAsyncThunk)("knowledgeAssistant/getKnowledgeAssistant",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");let r=(i=n.profile.data)==null?void 0:i.knowledgeAssistant;return r?o.getKnowledgeAssistant(r):null}),yf=(0,Xs.createSlice)({name:"knowledgeAssistant",initialState:hf,reducers:{},extraReducers:t=>{t.addCase(hn.pending,e=>{e.fetchState="loading"}).addCase(hn.rejected,e=>{e.fetchState="error"}).addCase(hn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),xp=yf.reducer;var Li={data:[],fetchState:"idle"},bp=t=>{var e;return(e=t.answer)==null?void 0:e.data},Cp=t=>t.answer.fetchState,Ao=(0,Po.createAction)("answer/resetKnowledgeSearch"),Io=(0,Po.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var l,c,p;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=_p(e.getState()),r=(l=e.getState().conversation.current)==null?void 0:l.sessionId,i=(p=(c=e.getState().info)==null?void 0:c.agentInfo)==null?void 0:p.agentId;if(!s)throw new Error("KnowledgeAssistant is not defined");let a=await o.knowledgeAssist({promptInstruction:s.prompt,question:t},n,s.code,{agentId:i,conversationId:r});return{question:t,answer:a}}),vf=(0,Po.createSlice)({name:"answer",initialState:Li,reducers:{},extraReducers:t=>{t.addCase(Io.pending,e=>{e.fetchState="loading"}).addCase(Io.rejected,e=>{e.fetchState="error"}).addCase(Io.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(M,()=>Li).addCase(Ao,()=>Li)}}),wp=vf.reducer;var yn=require("react/jsx-runtime"),Tp=()=>(0,yn.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,yn.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,yn.jsx)("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"})]});var ce=require("react/jsx-runtime"),Sf=({onUse:t,onResetQuestion:e,question:o})=>{let[n,s]=bt.default.useState(""),{setSelected:r}=vt(),i=(0,bt.useRef)(null),a=y("EntitiesList",Sp),l=T(Ai),c=(0,vn.useDispatch)(),p=(0,vn.useSelector)(bp),d=(0,vn.useSelector)(Cp),g=async m=>{m.preventDefault(),m.stopPropagation(),n!==""&&c(Io(n))},u=(m,f)=>{c(Q({name:"knowledge assist source viewed",data:{question:f,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return(0,bt.useEffect)(()=>{var m;o&&d==="idle"?c(Io(o)):(m=i.current)==null||m.focus()},[i,d]),(0,bt.useEffect)(()=>{d==="done"&&(c(Q({name:"knowledge assist question answered",data:{question:n||o,sources:p[p.length-1].answer.sources,answer:p[p.length-1].answer.answer,isFollowUpQuestion:p.length>1},options:{includeConversationData:!0}})),r(p.length-1),s(""))},[d,p]),(0,bt.useEffect)(()=>{i.current&&i.current.scrollIntoView({behavior:"smooth"})},[i,p]),(0,ce.jsxs)("div",{className:a.root,children:[p.length>0&&(0,ce.jsx)("div",{className:a.alignRight,children:(0,ce.jsx)(P.Button,{onClick:e,children:l("reset")})}),(0,ce.jsxs)(P.ActionsBar,{list:p.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:l("use"),onPrimary:m=>t(m.text),children:[p.map(({question:m,answer:f},h)=>(0,ce.jsx)(P.List,{children:(0,ce.jsx)(P.ListItem,{"data-testid":"knowledge-search-answer",index:h,description:f.answer,closeOnSelect:!0,onClick:()=>t(f.answer),onSourceClick:E=>u(E,m),sources:f.sources,styles:{title:a.question,description:a.answer},children:m})},`${f.answer}_${h}`)),d==="loading"&&(0,ce.jsx)("p",{className:a.status,children:l("loading")}),d==="error"&&(0,ce.jsx)("p",{className:a.status,children:l("error")}),(0,ce.jsxs)("form",{className:a.form,onSubmit:g,children:[(0,ce.jsx)("input",{ref:i,placeholder:l("anotherQuestion"),className:a.input,type:"text",value:n,onFocus:()=>{r(-1)},onChange:m=>{r(-1),s(m.target.value)}}),(0,ce.jsx)("button",{type:"submit",className:a.submit,children:(0,ce.jsx)(Tp,{})})]})]})]})},Ep=Sf;var Zs=require("@reduxjs/toolkit");var _f={data:null,fetchState:"idle"},Ct=t=>t.profile.data,Qs=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],Sn=(0,Zs.createAsyncThunk)("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)}),xf=(0,Zs.createSlice)({name:"profile",initialState:_f,reducers:{},extraReducers:t=>{t.addCase(Sn.pending,e=>{e.fetchState="loading"}).addCase(Sn.rejected,e=>{e.fetchState="error"}).addCase(Sn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),kp=xf.reducer;var Rp=require("react");var Ip=require("react-redux");var Mi=require("react-redux");var Xt=require("react/jsx-runtime"),bf=({commands:t,onClick:e,onEdit:o})=>{var p,d,g;let n=(0,Ip.useDispatch)(),s=T(fn),r=(0,Mi.useSelector)(Ct),i=(0,Mi.useSelector)(_t),a=((g=(d=(p=r==null?void 0:r.uiConfig)==null?void 0:p.search)==null?void 0:d.initialTypes)==null?void 0:g.filter(({isActive:u})=>u))||[],l=0,c=a.map(({type:u})=>{var m;return(m=i[u])==null?void 0:m.suggestions.map(f=>({text:f.text||f.url||f.message,type:u}))}).flat(1);return(0,Rp.useEffect)(()=>{a.forEach(({type:u})=>{(!i[u]||i[u].suggestions.length===0)&&n(Le(u))})},[]),(0,Xt.jsxs)(P.ActionsBar,{list:[...t.map(u=>({text:u.label,type:"command"})),...c],primaryLabel:s("use"),secondaryLabel:s("preview"),onPrimary:({text:u},m)=>e(u,c[m]),onSecondary:(u,m)=>{let f=m-t.length;o(c[f],i[c[f].type].suggestions)},children:[t.length>0&&(0,Xt.jsx)(P.List,{heading:s("commands"),children:t.map((u,m)=>(0,Xt.jsx)(P.ListItem,{index:m,closeOnSelect:!1,onClick:u.onClick,children:u.label},u.label))}),a.map(({type:u,title:m})=>{var f;return(0,Xt.jsx)(P.List,{heading:m,orientation:"vertical",children:(f=i[u])==null?void 0:f.suggestions.map(h=>(l++,(0,Xt.jsx)(P.ListItem,{index:l+t.length-1,closeOnSelect:!1,description:h.text,onClick:()=>e(h.text,h),"data-testid":"search-overlay-suggestion",children:h.title},`${h.id}-${h.text}`)))},u)})]})},Pp=bf;var V=require("react/jsx-runtime"),Cf=200,wf=5,Tf=4,Ef=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Ap=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),kf=()=>{let t=(0,Ue.useDispatch)(),e=be(),o=T(fn),[n,s]=(0,se.useState)(!1),[r,i]=(0,se.useState)(""),a=(0,Ue.useSelector)(ic),l=(0,Ue.useSelector)(Ct),[c,p]=(0,se.useState)(null),[d,g]=(0,se.useState)([]),[u,m]=(0,se.useState)(),f=(0,Ue.useSelector)(ne),h=C("showSearch"),E=C("showEntitiesCommand"),x=C("showSummaryCommand"),_=C("showKnowledgeSearch"),b=C("showImageSearch"),v=C("searchTriggerKey"),A=(0,Ue.useSelector)(rp),O=(0,Ue.useSelector)(ac),K=(0,Ue.useSelector)(lc),H=(0,Ue.useSelector)(rc),W=S=>Nn(O.filter(B=>B.type===S.toUpperCase()),S),z=[{value:"PERSONAL",label:o("personalSuggestions"),list:W("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:W("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:W("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:W("IMAGE"),listOrientation:"horizontal",shouldShow:b}].filter(S=>S.shouldShow),R=[{label:o("entitiesClipboard"),onClick:()=>t(oe("entities")),shouldShow:E&&Ap(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(oe("summary")),shouldShow:x&&Ap(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(oe("knowledgeAssist")),shouldShow:_}].filter(S=>S.shouldShow),he=(A==null?void 0:A.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:W(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],Lr=(0,se.useCallback)((0,Lp.default)((S,B)=>{t(jt({query:S,type:B,tags:["search-overlay"],size:u?50:20}))},Cf),[u]),Ko=Ef([...he,...z]),Uo=(0,se.useCallback)((S,B)=>{t(oe("edit")),p({...S,searchTerm:void 0}),g(B)},[t,c,he]),oo=(0,se.useCallback)((S,B)=>{switch(B.type){case"IMAGE":e.send(Ti,{suggestion:B});break;default:e.send(tt,{text:S,suggestion:B})}t(te(!1))},[t]),tg=S=>{$t(S.text),t(Q({name:"entity copied",data:{entity:S,type:"copy"}})),t(te(!1))},og=(0,se.useCallback)(S=>{t(Q({name:"suggestion feedback",data:{text:S.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),ng=S=>{e.send(tt,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(Q({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(oe("search")),t(Ao()),t(te(!1))},sg=S=>{$t(S),t(te(!1))},rg=S=>{e.send(tt,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(te(!1))},ig=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),ag=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function Nn(S,B){return S.slice(0,u?10:B.toLowerCase()==="image"?Tf:wf)}function ya(S,B,Ee){return B.reduce((On,Dn)=>Ee&&u===Ee?Dn.length+On:Nn(Dn,Ee).length+On,S)}function no(S){return B=>{n?window.confirm(o("warning"))&&(S(B),s(!1)):S(B)}}return(0,se.useEffect)(()=>{r?Lr(r,u):t(Ms())},[r,u]),(0,se.useEffect)(()=>{a==="search"&&t(Ao())},[a]),(0,se.useEffect)(()=>{f&&t(un())},[f]),lp(v,()=>t(te(!0))),!h||!l?null:(0,V.jsxs)(P,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:no(S=>t(te(S))),onChangeType:S=>m(S),onChangePage:no(S=>t(oe(S))),selectedType:u,search:r,page:a,isOpen:H,types:[...he,...z],children:[(0,V.jsxs)(P.Page,{id:"search",children:[r.length===0&&(0,V.jsx)(Pp,{commands:R,onClick:oo,onEdit:Uo}),r.length>0&&(0,V.jsxs)(P.ActionsBar,{list:[...R.map(S=>({text:S.label,type:"command"})),...Ko.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},B)=>oo(S,Ko[B]),onSecondary:(S,B)=>{let Ee=Ko[B-R.length];!Ee||!Ee.type||Uo(Ee,W(Ee.type))},children:[R.length>0&&(0,V.jsx)(P.List,{heading:o("commands"),children:R.map((S,B)=>(0,V.jsx)(P.ListItem,{index:ya(B,[],"commands"),closeOnSelect:!1,onClick:S.onClick,children:S.label},S.label))}),[...he,...z].map(({value:S,label:B,list:Ee,lineClamp:On,listOrientation:Dn},lg)=>(0,V.jsx)(P.List,{heading:B,orientation:Dn==="horizontal"?"horizontal":"vertical",onShowAll:()=>m(S),hasMore:!u&&K[S.toLowerCase()]>Nn(Ee,S).length,children:Nn(Ee,S).map((ye,cg)=>(0,V.jsx)(P.ListItem,{index:ya(R.length+cg,[...he,...z].slice(0,lg).map(({list:pg})=>pg),S),closeOnSelect:!1,lineClamp:On,onClick:()=>oo(ye.text,ye),description:S!=="IMAGE"?ye.title&&ye.text:void 0,onFeedback:S!=="IMAGE"?()=>og(ye):void 0,children:S==="IMAGE"?(0,V.jsx)(P.Image,{title:ye.title||ye.text,src:ye.image}):ye.title||ye.text},`${ye.id}-${ye.text}`))},S))]})]}),(0,V.jsx)(P.Page,{id:"edit",onDismiss:no(()=>{t(oe("search")),p(null)}),children:c&&(0,V.jsx)(Bs,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(oe("search")),p(null),g([])},onNext:ag,onPrevious:ig,onUse:S=>{t(oe("search")),oo(S,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(te(!1)),g([]),p(null)}})}),(0,V.jsx)(P.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:no(()=>{t(oe("search"))}),children:(0,V.jsx)(up,{onUse:rg,onCopy:tg})}),(0,V.jsx)(P.Page,{id:"summary",title:o("summaryTitle"),onDismiss:no(()=>{t(oe("search"))}),children:(0,V.jsx)(vp,{onCopy:sg})}),(0,V.jsx)(P.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:no(()=>{t(Ao()),t(oe("search"))}),children:(0,V.jsx)(Ep,{question:r,onUse:ng,onResetQuestion:()=>{t(Ao()),i("")}})})]})},Mp=kf;var Lo=require("react/jsx-runtime"),Rf=()=>{let t=C("showSearch"),e=C("isEmbedded");return(0,Lo.jsxs)(Np.Fragment,{children:[t&&(0,Lo.jsx)(Mp,{}),(0,Lo.jsx)(Qc,{}),e&&(0,Lo.jsx)(np,{})]})},Op=Rf;var Fp=k(require("classnames")),Kp=require("react-redux");var Js=require("react/jsx-runtime"),Dp=({className:t})=>(0,Js.jsx)("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:(0,Js.jsx)("g",{children:(0,Js.jsx)("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
4
4
  c-17.9,17.9-27.3,40.1-27.3,65.7C163.4,163,163.4,233,163.4,233z M465.5,267.9V477c0,9.4-3.4,17.9-10.2,24.7
5
5
  c-6.8,6.8-15.4,10.2-24.7,10.2h-349c-9.4,0-17.9-3.4-24.7-10.2c-6.8-6.8-10.2-15.4-10.2-24.7V267.9c0-9.4,3.4-17.9,10.2-24.7
6
6
  c6.8-6.8,15.4-10.2,24.7-10.2h11.9v-70c0-44.4,16.2-82.8,47.8-115.2S212.1,0,256.4,0s82.8,16.2,115.2,47.8
7
- c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var Ei=require("react/jsx-runtime"),ff={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Ep=({className:t,color:e})=>(0,Ei.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ei.jsx)("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:ff[e||"pink"]})});var kp={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 ki={};G(ki,{enUS:()=>hf,nlNL:()=>yf});var hf={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},yf={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Pp=require("react-redux"),$t=require("react/jsx-runtime"),Ap=({onLogIn:t})=>{let e=T(ki),o=C("floatingMenu"),n=C("productName"),s=(0,Pp.useDispatch)(),r=(0,Rp.useSelector)(ne),i=y("FloatingMenu",kp);if(r===null||o===!1)return null;let a=()=>{r===!0?s(te(!0)):t()};return(0,$t.jsxs)("button",{className:(0,Ip.default)(i.root,{[i.isLoggedIn]:r,[i.isLoggedOut]:!r}),onClick:a,children:[(0,$t.jsx)("div",{className:i.text,children:e(r?"search":"signin",{productName:n})}),(0,$t.jsxs)("div",{className:i.icon,children:[(0,$t.jsx)(Ep,{className:i.logo,color:"pink"}),r===!1&&(0,$t.jsx)(Tp,{className:i.lock})]})]})};var Qs=require("react"),ot=require("react-redux");function Ro(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}var Xs=require("react");var Op=require("interweave"),Po=require("react"),Gs=require("react-redux");var Lp=require("react");function Mp(t,e,o){(0,Lp.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var Np={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};var Gt=require("react/jsx-runtime"),Sf=["search","personal-collection-search","search-autocomplete"];function _f(t,e,o,n={}){let s="";return Sf.includes(e)?s=Rl(ei(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=ei(t,o,n),n.placeholders===!0&&(s=Pl(s)),s}var xf=()=>{},bf=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=C("inlineSuggestions"),r=(0,Gs.useSelector)(io),i=(0,Gs.useDispatch)(),a=y("TextSuggestion",Np),l=(0,Po.useRef)(null);(0,Po.useEffect)(()=>{let p=setTimeout(()=>{i($a({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),Mp(l,"click",()=>{i(mt(t)),i(Ie({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=(0,Po.useMemo)(()=>_f(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:(0,Gt.jsxs)("div",{className:a.root,onMouseEnter:()=>i(mt(t)),children:[(0,Gt.jsx)(O,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:xf,children:(0,Gt.jsx)(Op.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&(0,Gt.jsx)("div",{className:a.actions,children:(0,Gt.jsx)(ws,{onFeedback:()=>n(o),suggestion:o.text})})]})},Dp=bf;var Ii=require("react/jsx-runtime"),Cf=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=(0,Xs.useMemo)(()=>{let r=e.map((i,a)=>(0,Ii.jsx)(Dp,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return(0,Ii.jsx)(Xs.Fragment,{children:s})},Zs=Cf;var Hp={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var fn=require("react/jsx-runtime"),wf=({textSuggestions:t,selectedIndex:e})=>{let o=(0,Qs.useRef)(null),n=y("InlineSuggestionsOverlay",Hp),s=(0,ot.useSelector)(Ro),r=(0,ot.useDispatch)(),i=(0,ot.useSelector)(ne),a=(0,ot.useSelector)(ro),l=(0,ot.useSelector)(Ds),c=C("showTextSuggestions");return go(()=>{r(St({collapse:!0,skipWhenInputFocus:!0}))}),(0,Qs.useEffect)(()=>{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:(0,fn.jsx)("div",{className:n.root,"data-variant":"inline",children:(0,fn.jsx)("div",{ref:o,className:n.paper,children:(0,fn.jsx)(Se,{children:(0,fn.jsx)(Zs,{suggestions:t,selectedIndex:e})})})})},Tf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Bp=(0,ot.connect)(Tf)(wf);var Fp=require("react-redux");var hn=require("react/jsx-runtime"),Ef=({children:t})=>{let o=C("locale").replace("-","");return(0,hn.jsx)(qr.Provider,{value:o,children:t})},kf=({store:t,customStyles:e={},children:o})=>(0,hn.jsx)(Fp.Provider,{store:t,children:(0,hn.jsx)(Ef,{children:(0,hn.jsx)(Do.Provider,{value:e,children:o})})}),Xt=kf;var Ys=E(require("classnames")),Ao=require("react"),ze=require("react-redux");var Kp=require("react");function Up(t,e){let[o,n]=(0,Kp.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return w.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){w.error(i)}}]}var jp=E(require("classnames")),nt=require("react");var Ri={};G(Ri,{enUS:()=>If,nlNL:()=>Rf});var If={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"}]}]},Rf={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 zp={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var bt=require("react/jsx-runtime"),Pi=(t,e,o)=>n=>(0,bt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),Pf=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=T(Ri),i=xe(),a=y("Login",zp),l=C("productName"),c=(0,nt.useCallback)(h=>{h.preventDefault(),n&&n(parseInt(h.target.value,10))},[]),p=(0,nt.useCallback)(h=>{h.preventDefault(),i.send(Co,!0)},[e]),d=(0,nt.useMemo)(()=>h=>(0,bt.jsx)("a",{onClick:_=>{_.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[e]),g=(0,nt.useCallback)(h=>(0,bt.jsx)("button",{type:"button",className:a.anchorButton,onClick:p,children:h},"prompt"),[p]),{min:u,hour:m,day:f}=(0,nt.useMemo)(()=>({min:Pi(a,60*10,c),hour:Pi(a,60*60,c),day:Pi(a,60*60*12,c)}),[]);return(0,bt.jsxs)("div",{className:(0,jp.default)(t,a.root),children:[r("loginPlease",{login:o?g:d,productName:l}),n&&(0,bt.jsxs)(nt.Fragment,{children:[(0,bt.jsx)("br",{}),r("snooze",{min:u,hour:m,day:f})]})]})},Js=Pf;var qp=require("react-redux");var Vp={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var yn=require("react/jsx-runtime"),Af=({title:t})=>{let e=y("SearchTrigger",Vp),o=(0,qp.useDispatch)();return(0,yn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(te(!0)),children:[(0,yn.jsx)(vo,{}),(0,yn.jsx)("span",{className:e.text,children:t})]})},Wp=Af;var Ai={};G(Ai,{enUS:()=>Lf,nlNL:()=>Mf});var Lf={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"}]},Mf={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 $p={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"};var B=require("react/jsx-runtime"),Nf=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=y("SuggestionsOverlay",$p),s=T(Ai),r=(0,ze.useSelector)(Ro),i=za(),a=(0,ze.useDispatch)(),l=(0,Ao.useRef)(null),c=C("searchTriggerKey"),p=C("productName"),d=(0,ze.useSelector)(Ds),g=(0,ze.useSelector)(ne),u=(0,ze.useSelector)(ro),[m,f]=(0,Ao.useState)(null),h=C("showSearch"),k=C("showTextSuggestions"),_=C("adminUrl"),x=C("isEmbedded"),[b,v]=Up("dd-snooze-until-ms",0),A=d||b>Date.now(),M=(0,ze.useSelector)(U=>U.input.text),K=t.filter(U=>U.source!=="gpt").length,D=()=>{A&&v(0),a(kc(!A))},q=U=>{a(Q({name:"suggestion feedback",data:{text:U.text,source:"overlay",context:M},options:{includeConversationData:!0}}))},I=U=>{let De=Date.now()+U*1e3;v(De),w.info(`Snooze until: ${new Date(De)}`),a(St({collapse:!0}))};return(0,Ao.useEffect)(()=>{K===0&&f(null)},[t,K]),go(()=>{a(St({collapse:!0,skipWhenInputFocus:!0}))}),g===null||u===!1?null:g===!1?(0,B.jsxs)("div",{ref:l,className:(0,Ys.default)(n.root,{[n.isCollapsed]:A}),children:[!A&&(0,B.jsxs)("div",{className:n.triggers,children:[(0,B.jsx)("div",{style:{flex:1}}),(0,B.jsx)("div",{className:n.triggersRight,children:(0,B.jsx)(At,{className:n.toggleButton,title:s("collapse"),onClick:D,isCollapsed:!1})})]}),(0,B.jsx)("div",{className:n.toggleButtonWrapper,children:(0,B.jsx)(At,{className:n.toggleButton,title:s("open",{productName:p}),onClick:D,isCollapsed:!0})}),(0,B.jsx)("div",{className:n.collapsible,children:(0,B.jsx)(Js,{loginUrl:_,isEmbedded:x,onLogIn:o,onSnooze:I})})]}):!i||!r?null:(0,B.jsxs)("div",{ref:l,className:(0,Ys.default)(n.root,{[n.isCollapsed]:A}),children:[!A&&(0,B.jsxs)("div",{className:n.triggers,children:[(0,B.jsx)("div",{style:{flex:1},children:h&&(0,B.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(s(Ps()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>f(null),children:(0,B.jsx)(Wp,{title:s("search")})})}),(0,B.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,B.jsx)("div",{className:(0,Ys.default)(!m&&n.hintsHidden,n.hints),children:m}),(0,B.jsx)(At,{className:n.toggleButton,title:s("collapse"),onClick:D,isCollapsed:!1})]})]}),(0,B.jsx)("div",{className:n.toggleButtonWrapper,children:(0,B.jsx)(At,{className:n.toggleButton,title:s("open",{productName:p}),onClick:D,isCollapsed:!0})}),K>0&&k&&(0,B.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,B.jsx)(Se,{children:(0,B.jsx)(Zs,{onFeedback:q,suggestions:t,selectedIndex:e,reverse:!0})})})]})},Of=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Gp=(0,ze.connect)(Of)(Nf);var ur=E(require("classnames")),gd=require("interweave"),it=require("react"),md=require("react-redux");var Xp=require("react"),Df=["div","span","mark","strong","b","i","u","em"];function Li(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(Df.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,Xp.cloneElement)(n,{children:Li(i,e,o+1)})]}return[...t,...e]}function Ct(t){return t.tagName.toLowerCase()==="textarea"}var Zp={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"};var rd=E(require("classnames")),id=require("interweave"),lr=require("react");function Qp(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function er(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function Jp(t){return t!=null}var Ni=E(require("classnames")),be=require("react");var tr=require("react"),Hf=["bottom","height","left","right","top","width"],Bf=(t={},e={})=>Hf.some(o=>t[o]!==e[o]),st=new Map,Yp,ed=()=>{let t=[],e=[];st.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Bf(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{st.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),Yp=window.requestAnimationFrame(ed)};function Ff(t,e){return{observe(){let o=st.size===0;if(st.has(t)){let n=st.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else st.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&ed()},unobserve(){let o=st.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||st.delete(t),st.size||cancelAnimationFrame(Yp)}}}}function Mi(t){let[e,o]=(0,tr.useState)(null);return(0,tr.useLayoutEffect)(()=>{if(!t.current)return;let n=Ff(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var Lo=require("react"),od=require("react-dom");var td={root:"_root_1jq08_1"};var nd=({children:t})=>{let[e,o]=(0,Lo.useState)(null),n=(0,Lo.useContext)(Do);return(0,Lo.useLayoutEffect)(()=>{let s=document.createElement("div");return Nt(s),s.classList.add(td.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?(0,od.createPortal)(t,e):null};var je={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"};var or=require("react/jsx-runtime"),nr=(t=!1)=>{let[e,o]=(0,be.useState)(t),n=(0,be.useCallback)(()=>o(!0),[]),s=(0,be.useCallback)(()=>o(!1),[]),r=(0,be.useCallback)(()=>o(a=>!a),[]),i=(0,be.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function Oi(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 sr=({className:t,triggerRef:e,boundaryRef:o=(0,be.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=Oi,...a})=>{let l=Mi(e),c=Mi(o),p=(0,be.useMemo)(()=>i(l,c,0),[l,c]);return(0,or.jsx)(nd,{children:(0,or.jsx)("div",{className:(0,Ni.default)(je.ref,{[je.positionAbove]:n==="above",[je.positionBelow]:n==="below",[je.positionLeft]:n==="left",[je.positionRight]:n==="right",[je.alignStart]:s==="start",[je.alignCenter]:s==="center",[je.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:(0,or.jsx)("div",{className:(0,Ni.default)(t,je.root),children:r})})})};var sd=E(require("classnames")),rr=require("react");var Di=require("react/jsx-runtime"),ir=(0,rr.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,rr.useRef)(null),r=y("TabCompletion",We);return(0,Di.jsx)("div",{ref:er([s,n]),className:(0,sd.default)(t,r.popoverContentContainer),...o,children:(0,Di.jsx)("div",{className:r.popoverContent,children:e})})});var wt=require("react/jsx-runtime"),Kf=t=>e=>{let o=Oi(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Uf=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",We),i=nr(),a=(0,lr.useMemo)(()=>Kf(t.getBoundingClientRect()),[t]),[l,c]=hs(t);return(0,lr.useEffect)(()=>{c?i.open():i.close()},[c]),(0,wt.jsxs)("span",{children:[(0,wt.jsx)("mark",{ref:er([l,i.triggerRef]),className:(0,rd.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,wt.jsx)(sr,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,wt.jsx)(ir,{style:o,children:(0,wt.jsx)("div",{className:r.hintText,children:s})})})]})},ar=class extends id.Matcher{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${Qp(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(Jp);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(0,wt.jsx)(Uf,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var pr=E(require("classnames")),dd=require("interweave"),ie=require("react"),ud=require("react-redux");var Hi=require("react/jsx-runtime"),ad=()=>(0,Hi.jsx)("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:(0,Hi.jsx)("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"})});var Tt=require("react"),vn=require("react-redux"),cd=E(require("lodash.debounce"));var ld={root:"_root_1muu8_1",content:"_content_1muu8_7"};function cr(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 Bi(t){return t.replace("https://www.","").replace("https://","")}var Ce=require("react/jsx-runtime"),zf=3,jf=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Vf=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=zf})=>{let r=y("LinkSearch",ld),[i,a]=(0,Tt.useState)(""),l=(0,vn.useDispatch)(),c=(0,vn.useSelector)(Ns("url")),p=(0,vn.useSelector)(tc("URL",jf)),[d,g]=(0,Tt.useState)(p.length-1),u=C("fallbackImage"),m=_=>{let x=_.target;a(x.value)},f=(_,x)=>{_.stopPropagation(),_.preventDefault(),window.open(x,"_blank")},h=_=>{var v;let x=d-1<0?p.length-1:d-1,b=d+1===p.length?0:d+1;_.code==="Escape"&&(a(""),e()),_.code==="ArrowUp"&&g(x),_.code==="ArrowDown"&&g(b),_.code==="Enter"&&t(((v=p[d])==null?void 0:v.text)||i)},k=(0,Tt.useCallback)((0,cd.default)(_=>{l(Ut({query:_,type:"URL",tags:["link-search"]}))},300),[]);return(0,Tt.useEffect)(()=>{i&&k(i)},[i]),(0,Tt.useEffect)(()=>()=>{l(Is())},[]),(0,Ce.jsxs)("div",{className:r.root,children:[(0,Ce.jsx)(Se,{withDivider:!0,children:(i?p:c).slice(0,s).map((_,x)=>(0,Ce.jsx)(O,{selected:d===x,onClick:()=>t(_.text),"data-testid":"linksearch-suggestion",children:(0,Ce.jsxs)(F,{children:[(0,Ce.jsx)(F.Image,{src:cr(_,"small",u||void 0),title:_.title||_.text}),(0,Ce.jsxs)(F.Content,{className:r.content,cropText:!0,children:[(0,Ce.jsx)(F.Title,{children:_.title||Bi(_.text)}),_.title&&Bi(_.text)]}),(0,Ce.jsx)(O.Actions,{children:(0,Ce.jsx)(O.ActionButton,{label:n,onClick:b=>f(b,_.text)})})]})},_.text))}),(0,Ce.jsx)(sn,{value:i,onChange:m,autoFocus:!0,placeholder:o,onKeyUp:h})]})},pd=Vf;var Fi={};G(Fi,{enUS:()=>qf,nlNL:()=>Wf});var qf={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Wf={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var re=require("react/jsx-runtime"),$f=(0,ie.forwardRef)((t,e)=>{let o=y("TabCompletion",We);return(0,re.jsx)("mark",{ref:e,className:(0,pr.default)(o.matchSelection)},"selection-start")}),Gf=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=T(Fi),i=y("TabCompletion",We),a=(0,ie.useRef)(null),l=(0,ie.useRef)(null),[c,p]=(0,ie.useState)(null),d=(0,ud.useDispatch)(),g=nr(document.activeElement===n),[u]=(0,ie.useState)(()=>document.createRange());g.triggerRef.current=u,(0,ie.useEffect)(()=>()=>u.detach(),[]),(0,ie.useEffect)(()=>{let f=t.current,h=a.current;!f||!h||(u.setStart(f,0),u.setEnd(h,0))},[t.current,a.current]),go(()=>{g.close()});let m=(0,ie.useCallback)(f=>{let h=u.toString(),k=/^http(s?):\/\//.test(f)?f:`https://${f}`;d(Zn({text:`[${h}](${k})`,replace:"selection"}))},[]);return(0,re.jsxs)("span",{children:[(0,re.jsx)("mark",{ref:a,className:(0,pr.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":g.opened?"true":"false",children:s}),g.opened&&(0,re.jsx)(sr,{className:i.popoverRoot,triggerRef:g.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,re.jsxs)(ir,{style:o,ref:l,children:[(0,re.jsx)("div",{className:(0,pr.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,re.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,re.jsx)(ad,{}),(0,re.jsx)("span",{children:"\xA0"}),(0,re.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,re.jsx)(pd,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:m,onDismiss:()=>{p(null),g.close()}})]})})]},"selection-end")},dr=class extends dd.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,ie.createRef)(),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?(0,re.jsx)($f,{ref:this.startRef}):(0,re.jsx)(Gf,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var fd=require("react-redux");var rt=require("react/jsx-runtime"),Xf=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",Zp),p=C("insertLink"),d=C("showMidSentenceSuggestions"),g=C("inlineSuggestions"),u=vs(a),m=(0,it.useRef)(null),f=(0,fd.useSelector)(ne);(0,it.useEffect)(()=>{Ct(a)&&u&&Ss(a,u)},[u]);let h=(0,it.useCallback)(x=>{if(!s||!o)return x;let b=[(0,rt.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,rt.jsx)("span",{"data-testid":"tab-completion",className:(0,ur.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&b.push((0,rt.jsx)("span",{className:(0,ur.default)(c.hint,c.resetIndent),children:(0,rt.jsx)(Bn,{keyCode:"tab"},"tabHint")})),Li(x,b)},[s,o,n]),k=(0,it.useMemo)(()=>{let x=[];return p&&x.push(new dr("selection")),x.push(new po("placeholders")),r&&x.push(new ar("keywords")),x},[g,p,r]),_=(0,it.useMemo)(()=>{let x=window.getComputedStyle(a);return{"--dd-color":x.color,"--dd-font-size":x.fontSize,"--dd-font-family":x.fontFamily,"--dd-font-variant":x.fontVariant}},[]);return!t||!f?null:(0,rt.jsxs)("div",{ref:x=>{x!=null&&x.parentElement&&(m.current=x==null?void 0:x.parentElement)},className:c.root,style:_,children:[(0,rt.jsx)(gd.Interweave,{tagName:"span",containerTagName:"div",className:(0,ur.default)(c.container,c.agentText),disableLineBreaks:Ct(a),content:e||"\u200B",onAfterParse:h,matchers:k,selection:u,keywordMatches:i,inputElement:a,inputStyle:_,boundaryRef:m,inlineSuggestionsOnlyAtEnd:!d}),(0,rt.jsx)("br",{})]})},Zf=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var f;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??fo(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:g,visible:u,showStyleSuggestions:m}=o;return{showTabHint:p,showStyleSuggestions:m,showTabCompletion:g,content:l,tabText:c,source:a,keywordMatches:((f=n.list)==null?void 0:f.keywordMatches)??[],enabled:u&&d!==!1}},hd=(0,md.connect)(Zf)(Xf);var au=E(require("classnames")),lu=require("react"),Z=require("react-redux");var Et=require("@reduxjs/toolkit");var yd={list:[],fetchState:"idle",isInitialRequest:null},Sd=t=>t.autoflows.list||[],vd=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},at=(0,Et.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Ki=(0,Et.createAsyncThunk)("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(at(t.platformSessionId))}),Ui=(0,Et.createAsyncThunk)("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(at(t.platformSessionId))}),Qf=(0,Et.createSlice)({name:"autoflows",initialState:yd,reducers:{},extraReducers:t=>{t.addCase(Ki.pending,(e,o)=>{let n=vd(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Ui.pending,(e,o)=>{let n=vd(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(at.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(at.rejected,e=>{e.fetchState="error"}),t.addCase(at.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(N,()=>yd)}}),_d=(0,Et.createAsyncThunk)("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(at(t))}),s.on("sessionCompleted",()=>{o(at(t))})}),xd=(0,Et.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),bd=Qf.reducer;var kt=require("@reduxjs/toolkit");var Cd={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},wd=t=>t.customMessages.list,Td=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Ed=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),kd=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),Sn=(0,kt.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),gr=(0,kt.createAsyncThunk)("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)}),mr=(0,kt.createAsyncThunk)("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)}),Id=(0,kt.createSlice)({name:"customMessages",initialState:Cd,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(Sn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(Sn.rejected,e=>{e.fetchState="error"}).addCase(Sn.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(gr.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(gr.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(mr.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(mr.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(N,()=>Cd)}}),Rd=(0,kt.createAsyncThunk)("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(Id.actions.onCustomMessage(r))})}),Pd=(0,kt.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Ad=Id.reducer;var _n=require("@reduxjs/toolkit"),Jf={token:null,accountUrl:null,interval:null},Ld=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},zi=(0,_n.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),ji=(0,_n.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(zi()),setInterval(()=>n(zi()),o)}),Md=(0,_n.createSlice)({name:"passwordlessToken",initialState:Jf,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(zi.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(ji.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:Nd}=Md.actions,Od=Md.reducer;function Dd(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var qd=require("react"),Wd=require("react-redux");var zd=E(require("classnames")),jd=require("react");var Bd=E(require("classnames"));var Hd={root:"_root_838fd_1"};var Kd=require("react/jsx-runtime"),Yf=({className:t,children:e})=>{let o=y("Unicode",Hd);return(0,Kd.jsx)("span",{className:(0,Bd.default)(t,o.root),children:e})},Fd=Yf;var Ud={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 Vi={};G(Vi,{enUS:()=>eh,nlNL:()=>th});var eh={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"}]},th={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"}]};var ge=require("react/jsx-runtime"),nh=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",Ud),a=T(Vi),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,ge.jsxs)(O,{className:(0,zd.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,ge.jsx)(F,{children:(0,ge.jsxs)(F.Content,{children:[(0,ge.jsxs)(F.Title,{children:[e&&(0,ge.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,ge.jsx)("span",{children:n})]})}),(0,ge.jsx)(O.Actions,{fixed:e==="Started",children:(0,ge.jsx)(O.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,ge.jsxs)(jd.Fragment,{children:[(0,ge.jsx)(Fd,{children:c})," ",(0,ge.jsx)("span",{children:a(l)})]})})})]})},Vd=nh;var qi=require("react/jsx-runtime"),sh=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},rh=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,qi.jsx)(qd.Fragment,{children:t.map(s=>(0,qi.jsx)(Vd,{displayName:s.displayName,description:s.description,disabled:s.isBusy||sh(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),ih=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},ah={onStartAutoflow:Ki,onStopAutoflow:Ui},$d=(0,Wd.connect)(ih,ah)(rh);var fr=require("react"),Xd=require("react-redux"),Gi=E(require("classnames"));var Wi=require("react/jsx-runtime"),$i=()=>(0,Wi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,Wi.jsx)("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 Gd={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};var Ve=require("react/jsx-runtime"),lh=({entities:t})=>{let e=y("EntitiesWidgetList",Gd),[o,n]=(0,fr.useState)(void 0),s=(0,Xd.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),an(a.text),s(Q({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,fr.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,Ve.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,Ve.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Ve.jsx)("span",{className:e.entityText,children:a.text}),(0,Ve.jsxs)("span",{className:e.iconWrapper,children:[(0,Ve.jsx)("span",{className:(0,Gi.default)(e.icon),children:(0,Ve.jsx)($i,{})}),(0,Ve.jsx)("span",{className:(0,Gi.default)(e.icon,o===l&&e.iconClicked),children:(0,Ve.jsx)($i,{})})]})]},a.text))})},Zd=lh;var Qd=E(require("classnames")),Xi=require("react"),Zt=require("react-redux");var lt={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"};var pe=require("react/jsx-runtime"),ch=({suggestion:t})=>{let e=T(Ft),o=(0,Zt.useDispatch)(),n=(0,Zt.useSelector)(Td(t.text)),s=(0,Zt.useSelector)(Ed(t.text)),r=(0,Zt.useSelector)(kd(t.text)),i=(0,Zt.useSelector)(zn),{replyOptions:a}=t,l=(0,Xi.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(gr({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,Xi.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),g=a[d];o(mr({platformSessionId:i,reply:g,suggestion:t}))},[t,n,o,i]);return(0,pe.jsxs)(O,{onClick:l,className:(0,Qd.default)(lt.root,{[lt.isUsed]:n,[lt.hasError]:r}),children:[(0,pe.jsx)(F,{children:(0,pe.jsxs)(F.Content,{children:[(0,pe.jsxs)(F.Title,{className:lt.title,children:[t.text," ",(0,pe.jsx)(Fn,{className:lt.label,children:"analyse tool"})," ",r&&(0,pe.jsx)("span",{className:lt.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,pe.jsx)("ul",{className:lt.quickReplies,children:a.map(p=>(0,pe.jsx)("li",{className:lt.quickReply,children:p.title},p.title))})]})}),(0,pe.jsxs)(O.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,pe.jsx)(O.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>(0,pe.jsx)(O.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),(0,pe.jsx)(O.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},Jd=ch;var Zi=require("react/jsx-runtime"),Yd=()=>(0,Zi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Zi.jsx)("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});var ou=require("react-redux");var eu=require("react");var me=require("react/jsx-runtime"),ph=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var g;let s=t.text||t.url||t.message,r=Rs(s),i=T(Ft),a=C("showImages"),l=C("fallbackImage"),c=u=>{u.preventDefault(),u.stopPropagation(),n(s)},p=u=>{u.preventDefault(),u.stopPropagation(),o(t)},d=(0,eu.useCallback)(u=>{window.open(r,"_blank"),u.stopPropagation(),u.preventDefault()},[r]);return(0,me.jsxs)(O,{onClick:c,"data-testid":"edit-suggestion",children:[(0,me.jsxs)(F,{children:[a&&t.image&&(0,me.jsx)(F.Image,{src:cr(t,"small",l||void 0),title:t.title}),(0,me.jsxs)(F.Content,{children:[t.title&&(0,me.jsx)(F.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((g=t.searchKeywords)==null?void 0:g.length)>0&&(0,me.jsx)(O.Labels,{labels:t.searchKeywords}),(0,me.jsx)(F.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),(0,me.jsxs)(O.Actions,{children:[r&&(0,me.jsx)(O.ActionButton,{onClick:d,label:i("visitUrl")}),(0,me.jsx)(O.ActionButton,{primary:!0,onClick:p,label:i("preview")}),(0,me.jsx)(O.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},tu=ph;var xn=require("react/jsx-runtime"),dh=({contentType:t,lines:e,suggestions:o})=>{let n=xe(),s=(0,ou.useSelector)(vt),r=a=>{n.send(hi,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(Ye,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,xn.jsx)(xn.Fragment,{children:o.map(a=>(0,xn.jsx)(tu,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},nu=dh;var Qi={};G(Qi,{enUS:()=>uh,nlNL:()=>gh});var uh={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"}]},gh={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 su={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"};var Ji=require("react/jsx-runtime"),ru=()=>(0,Ji.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Ji.jsx)("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"})});var Yi=require("react/jsx-runtime"),iu=()=>(0,Yi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Yi.jsx)("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"})});var R=require("react/jsx-runtime"),hr=(t,e)=>{let o=(0,Z.useSelector)(ne);(0,lu.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},mh=({onLogIn:t})=>{let e=T(Qi),o=(0,Z.useDispatch)(),n=C("isEmbedded"),s=y("Widget",su),r=C("showAutoflows"),i=C("showCustomMessages"),a=C("showSummaryCommand"),l=C("showKnowledgeSearch"),c=C("showSearch"),p=(0,Z.useSelector)(xt),d=(0,Z.useSelector)(Ws),g=(0,Z.useSelector)(Sd),u=(0,Z.useSelector)(Us),m=(0,Z.useSelector)(wd),f=(0,Z.useSelector)(jn),h=(0,Z.useSelector)(ro),k=(0,Z.useSelector)(ne),_=(0,Z.useSelector)(zn),x=(0,Z.useSelector)(Dd),b=(0,Z.useSelector)(vt),v=xe(),A=(0,Z.useSelector)(uc),M=(0,Z.useSelector)(Ld("/admin/")),K=C("adminUrl"),D=C("productName");if(hr(()=>(o(Sn(_)),o(Rd(_)),()=>{o(Pd(_))}),[o,h,i,_]),hr(()=>(o(at(_)),o(_d(_)),()=>{o(xd(_))}),[o,h,r,_]),hr(()=>{d.forEach(({type:I})=>{o(I==="entities"?Me():Ae(I))})},[o,h,f,p]),hr(()=>(o(ji()),()=>{o(Nd())}),[o]),h===!1)return(0,R.jsx)("div",{className:s.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:e("notSupported")})})},"supported");if(k===!1)return(0,R.jsx)("div",{className:s.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(Js,{isEmbedded:n,loginUrl:K,onLogIn:t})})},"login");if(!p||!_||k===null||A||x)return(0,R.jsx)("div",{className:s.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:e("waiting")})})},"waiting");let q=c||a||l||M;return(0,R.jsx)("div",{className:(0,au.default)(s.root),"data-testid":"widget",children:(0,R.jsxs)(Kn,{className:s.sectionList,children:[q&&(0,R.jsx)(pt,{title:e("actions"),type:"shortcuts",children:(0,R.jsxs)("div",{className:s.shortcutList,children:[c&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-search",onClick:()=>v.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(vo,{}),e("linkSearch")]}),a&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-summary",onClick:()=>v.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(iu,{}),e("linkSummary")]}),l&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>v.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,R.jsx)(ru,{}),e("linkKnowledgeSearch")]}),M&&(0,R.jsxs)("a",{className:s.shortcut,target:"_blank",href:M,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[(0,R.jsx)(Yd,{}),e("linkStudioLogin",{productName:D})]})]})}),i&&m.length>0&&(0,R.jsx)(pt,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(Se,{withDivider:!0,children:m.map(I=>(0,R.jsx)(Jd,{suggestion:I},I.text))})}),r&&g.length>0&&(0,R.jsx)(pt,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(Se,{withDivider:!0,children:(0,R.jsx)($d,{})})}),d.map(({type:I,title:U,amount:De,lines:Er})=>{var Yt;switch(I){case"entities":return u&&u.length>0&&(0,R.jsx)(pt,{type:I,title:U,"data-testid":`type-${I}`,children:(0,R.jsx)(Zd,{entities:u})},I);default:return((Yt=b[I])==null?void 0:Yt.fetchState)==="done"&&b[I].suggestions.length>0&&(0,R.jsx)(pt,{type:I,title:U,"data-testid":`type-${I}`,children:(0,R.jsx)(Se,{withDivider:!0,children:(0,R.jsx)(nu,{lines:Er,contentType:I,suggestions:b[I].suggestions.slice(0,De)||[]})})},I)}})]})})},cu=mh;function Mo(t){let e=new Range;return e.selectNodeContents(t),e}function pu(t,e,o){try{return It(t,e,o),!0}catch{return!1}}function yr(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function vr(t){return"tagName"in t&&t.tagName==="BR"}var bn=/[\u200B-\u200D\uFEFF]/g;function It(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 g=0;g<=l.length;g++)if(d.test(l[g])||p++,p===c)return g;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(bn,""),d=s+p.length,g=e>=s&&e<=d,u=o>=s&&o<=d;if(g){let m=i(c,e-s);m===0&&!u?n.setStartBefore(l):n.setStart(l,m)}u&&(n.setEnd(l,i(c,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(vr(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;yr(l)&&c&&!yr(c)&&!vr(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function Cn(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 g=d===o,u=d===s;switch(d.nodeType){case Node.TEXT_NODE:{let m=d.textContent;g&&(a=c+m.substring(0,n).replace(bn,"").length),u&&(l=c+m.substring(0,r).replace(bn,"").length),c+=m.replace(bn,"").length;break}case Node.ELEMENT_NODE:{let m=d.nextSibling===null;vr(d)&&!m&&c++;for(let f=0;f<d.childNodes.length;f++){let h=g&&f===n,k=u&&f===r;if(h&&(a=c),k&&(l=c),l!==void 0||((!h||!i)&&p(d.childNodes[f]),u&&f===r-1&&(l=c),l!==void 0))break}!u&&yr(d)&&!m&&c++,u&&(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 wn(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 g=p?n:0,u=d?r:void 0,m=c.textContent.replace(bn,"");g===0&&u===void 0?a+=m:a+=m.substring(g,u);break}case Node.ELEMENT_NODE:{let g=c.nextSibling===null;i===0&&vr(c)&&!g&&(a+=`
8
- `);for(let u=p?n:0;u<(d?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[u]),i!==1);u++);!d&&i===0&&yr(c)&&!g&&(a+=`
9
- `);break}default:break}d&&i++}return l(t),a}function du(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Qt=class extends $e{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),wn(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!du(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!du(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return Cn(this.element,e);let o=this.lastKnownSelection;if(o&&pu(this.element,o.start,o.end))return o;let n=Mo(this.element);return n.collapse(!1),Cn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return wn(this.element,It(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 uu(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 ea=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(JSON.stringify(e))}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},ta=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=uu(e,`${this.targetOrigin}/sdk/proxy/proxy.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(JSON.stringify(e),this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},oa=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(),w.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 ta(e,this.deepdeskUrl,{debug:!0}):new ea(e),n=s=>{var i,a;if(s.origin!==this.deepdeskUrl)return;let r=typeof s.data=="string"?JSON.parse(s.data):s.data;r.type==="event"&&r.channel===e&&(w.info("Received broadcast event",this.sessionId,s),(a=(i=this.eventMap)[r.name])==null||a.call(i,r.payload))};return o.onMessage(n),o}send(e,o){var r,i;w.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)}},gu=oa;var No=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var na=t=>new Promise(e=>{setTimeout(e,t)});var Oo=class extends No{name="ClientError"},sa=class extends No{name="ServerError"},Oe=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:g=b=>b instanceof TypeError,retryOnResponse:u=b=>b.status>=500,version:m="v1",...f}=o,h={credentials:"include",...f,headers:{"Content-Type":"application/json",...f.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(h.headers={...h.headers,"X-CSRFToken":this.csrfToken}),typeof m=="string"&&(h.headers={...h.headers,"X-Deepdesk-API-Version":m});let k=c,_=!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()=>(k--,a(i,h).then(async b=>u(b)&&!r.isAborted&&k>0?(await na(p),x()):b.status===401&&d===!0&&_===!1?(_=!0,await this.refreshToken(),x()):b).catch(async b=>{if(g(b)&&!r.isAborted&&k>0)return await na(p),x();throw b}));x().then(b=>b.json().catch(()=>null).then(v=>{b.status>=500?s(new sa("Server Error",v)):b.status===401?s(new Oo("Unauthorized",v)):b.status===403?s(new Oo("Forbidden",v)):b.status===404?s(new Oo("Not Found",v)):b.status>=400&&s(new Oo("Bad Request",v)),delete this.latestRequestByUrl[i],n(v)})).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 fh;(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||={})})(fh||={});function Sr(t){return{...L(t),tags:t.tags}}var ct=class t{constructor(e,o={}){this.options=o;this.client=new Oe(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(),w.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...$(e),tags:e.tags},{version:"v2"});return Sr(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return L(o)}async getKnowledgeAssistant(e){let o=await this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{version:null});return L(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return L(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return L(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(),w.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 w.info(`Successfully retrieved conversation ${r.id} for session ${e}`),Sr(r)}async isConversationSupported(e,o={}){w.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=$(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return Sr(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...$(s),tags:s.tags})),{version:"v2"})).map(s=>Sr(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",$({...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:$({...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),agent_id:o.agentId,id:o.externalConversationId},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 w.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",$(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}`,$(o),{abortLatest:!0})).map(r=>({...L(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`,$(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 L(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",$(e),{abortLatest:!0});return L(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,$(e),{version:"v2"});return L(o)}async knowledgeAssist(e,o,n,s={}){let r=await this.client.post(`/api/knowledge-assist/assistants/${n}/search`,$({question:e.question,promptInstruction:e.promptInstruction,chatHistory:o.map(i=>({question:i.question,answer:i.answer.answer})),agentId:s.agentId,conversationId:s.conversationId}),{version:"v2"});return L(r)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return L(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return L(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 L(o)}async evaluateRule(e,o,n,s={}){let r=new URLSearchParams;s.raiseForFailingConditions&&r.set("raise_for_failing_conditions","true");let i=await this.client.post(`/api/conversations/${o}/rules/${e}/evaluate?${r.toString()}`,n,{version:"v2"});return L(i.cues)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(Pa);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&w.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var Tn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(ci(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,L(s))}catch{w.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 hh;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(hh||={});var En=class{constructor(e,o={}){this.apiUrl=e;this.client=new Oe(e,o)}client;streams={};logger=w;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return L(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,$(o));return L(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,$(o))}async getAutoflows(e){let o=await this.client.get(`/sessions/${e}/autoflows`);return L(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",$(e));return L(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new Tn(`${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])}};var Cr=require("@reduxjs/toolkit");var fu=require("@reduxjs/toolkit");var mu={startTime:null,stopTime:null},hu=(0,fu.createSlice)({name:"handlingTime",initialState:mu,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(N,()=>mu)}}),{handlingTimeStart:yu,handlingTimeStop:_r,handlingTimeReset:vu}=hu.actions,Su=hu.reducer;var _u=(t={})=>{let e={onAuthError:bo(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var br=require("@reduxjs/toolkit");var xr={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var Jt=(0,br.createAsyncThunk)("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 xr.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),yh=(0,br.createSlice)({name:"styleSuggestions",initialState:xr,reducers:{},extraReducers:t=>{t.addCase(Jt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(Jt.rejected,e=>{e.fetchState="error"}).addCase(Jt.fulfilled,(e,o)=>{e.fetchState="done",ut(e.list,o.payload)||(e.list=o.payload)}).addCase(Lt,e=>{e.list=xr.list}).addCase(N,()=>xr)}}),xu=yh.reducer;var bu=(t={})=>{let e,o=!0,n={getStyleSuggestions:Jt,debounce:500,...t};return s=>r=>i=>{var u;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(!((u=c.conversation.current)==null?void 0:u.id)||!p)return l;let{text:g}=c.input;return g===a&&!o||(clearTimeout(e),g==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:g}))},t.debounce)),l}};function vh(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Cu=(t={})=>{let e={getTextSuggestions:Ae,getAutocompleteSuggestions:Yo,debounce:200,check:Ro,...t},o;return n=>s=>r=>{var f;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:p}=l.settings,d=(f=l.conversation.current)==null?void 0:f.id,g=r.type===Os.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:u}}=l;return vh(u,i)&&!g||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let h=io(l);h===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(h))},g?0:e.debounce)),a}};var wu=Jt.fulfilled.toString();function Sh(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 Tu=t=>e=>o=>n=>{var c;if(n.type!==wu){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=Sh(s,i);n.type===wu&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var _h=(0,Cr.combineReducers)({activeSuggestion:Cc,answer:gp,auth:Hc,autoflows:bd,conversation:Ba,contentTypes:Xc,customMessages:Ad,passwordlessToken:Od,entities:Yc,knowledgeAssistant:pp,handlingTime:Su,info:Zl,input:Nr.reducer,overlayInput:ae.reducer,settings:Na,profile:hp,search:nc,summary:rp,styleSuggestions:xu,ui:Ic,textSuggestions:yc});function Eu(t){return(0,Cr.configureStore)({reducer:_h,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),_u(),Cu({debounce:200}),bu({debounce:500}),Tu(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var xh=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},bh=t=>e=>o=>n=>{var a;let s=e.getState(),r=Pr("inlineSuggestions")(s);switch(n.type){case Qe.toString():{let l=Ns(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 bo.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:xh(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Zn.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 Ko.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case es.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 Me.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case et.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 Qn.toString():t.handleKeyDown(n.payload);break;case Lt.toString():t.logSendMessage(n.payload);break;case Jn.toString():t.logSendEditSuggestionMessage(n.payload);break;case Yn.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case Lt.toString():t.handleAfterSendMessage(n.payload);break;case en.toString():t.onUpdateShowTabHint(n.payload);break;case _r.toString():t.logHandlingTime();break;case Ie.toString():{r&&(e.dispatch(Be([])),e.dispatch(qe()));break}case Be.toString():{r&&n.payload.length>0&&e.dispatch(mt(0));break}default:break}return i},ku=bh;function ra(t){return t.toISOString().replace("T"," ").replace("Z","")}function Iu(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:ra(o),timeStop:ra(n)}}function ia(t,e,o){var M,K,D;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:d,cuts:g,deletions:u,textSuggestions:m,offeredTextSuggestions:f}}=e[t],h=n.length,_=m.reduce((q,{text:I,searchTerm:U})=>q+I.length-(U?U.length:0),0),x=c??Date.now(),b=(Date.now()-x)/1e3+(p||0),v=s/b,A=m.reduce((q,{searchTerm:I})=>q+(I?I.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:d,cuts:g,deletions:u,lenTextTyped:s+A,lenTextTotal:h,lenTextAssisted:_,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:b,charsPerSecond:v,numPastes:l,textSuggestionsV2:m,suggestionsCounters:[{source:"gpt",countOffered:f.filter(q=>q.source==="gpt").length}],agentId:(M=e.info.agentInfo)==null?void 0:M.agentId,agentName:(K=e.info.agentInfo)==null?void 0:K.agentName,agentEmail:(D=e.info.agentInfo)==null?void 0:D.agentEmail}}function aa(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return aa(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?aa(s,e):null}function Ru(t,e){return aa(t,e)}function Pu(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Ch(t){return typeof t=="object"&&t!==null&&"tagName"in t}function wr(t){return Ch(t)&&(Ct(t)||ys(t))}var Au=(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{w.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function wh(t){return t.offsetParent!==null}function Lu(t){if(!wh(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 Tr(t,e,o=100){let n=Lu(t);e({isVisible:n});let s=setInterval(()=>{let r=Lu(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var V=require("react/jsx-runtime");var Mu=Au("showTabHint",!0),kn=class t{static version="10.12.1-beta.1";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new ct(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[ku({emit:(d,g,u)=>this.emit(d,g,u),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=>Mu.update(d),sendEvent:(d,g)=>this.deepdeskApi.sendEvent(d,g)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new En(o)}),this.store=Eu(p),this.broadcastEvents=new gu({debug:!0,deepdeskUrl:c,eventMap:Bc(this.store),createCustomChannel:l}),this.store.dispatch(Fo),this.store.dispatch(en(Mu.value())),this.store.dispatch(Fo({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?(w.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(w.warn("Profile has not been loaded (yet)"),!0):(w.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(bo(null)),this.store.dispatch(Je()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ne(n)&&Ac(n)!=="loading"&&(o(),e())});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(Je())).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){w.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(Lr({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Vn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(qn({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Mr(e))).payload}async postMessages(e){return(await this.store.dispatch($n(e))).payload}async updateConversation(e){return(await this.store.dispatch(Wn(e))).payload}resetConversation(){this.store.dispatch(N()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(et());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Fo(e))}setVisitorInfo(e){this.store.dispatch(Xl(e))}async setAgentInfo(e){await this.store.dispatch(Xo(e))}async setAgentSettings(e){await this.store.dispatch(pi(e))}async getAgentSettings(){return(await this.store.dispatch(di())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(Os()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Yn(e))}notifyKeyDown(e){this.store.dispatch(Qn(e))}notifyPaste(e,o){this.store.dispatch(Qa({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Xa(e))}notifyExternalSuggestion(e){this.store.dispatch(Ie(e)),this.store.dispatch(qe())}notifyEditSuggestion(e){this.store.dispatch(fc(e.contentType,e.suggestions)),this.store.dispatch(Qe({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(St({collapse:!1})),this.inputMediator&&this.store.dispatch(ja({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Be([])))}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(Za(Xn(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(Wa()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{o||!a||i&&s<=0||r&&(e.shiftKey||(this.store.dispatch(Ga()),e.preventDefault(),!i&&(this.state.input.selectedSuggestionIndex===-1?this.store.dispatch(Ko()):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(mt(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(mt(-1)),this.store.dispatch(Ko()),e.preventDefault()):o||(this.store.dispatch(St({collapse:!0})),this.store.dispatch(Ec(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:d}=this.state.input,g=d.text.substring(0,d.selection.end),{tabCompletionSuggestion:u}=this.state.input;this.store.dispatch(en(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&u&&u.text.startsWith(g)&&(this.store.dispatch(Ie({text:u.text,suggestion:u,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(qe())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ja()),this.store.dispatch(Be([]))}handlingTimeStart(){this.state.handlingTime.startTime||(w.info("Start handling time"),this.store.dispatch(yu()))}handlingTimeStop(){this.state.handlingTime.startTime&&(w.info("Stop handling time"),this.store.dispatch(_r()))}logSendMessage(e){let o=ia("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=ia("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(qa(this.state.overlayInput.metrics))}logHandlingTime(){let e=Iu(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(vu())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(qe()),this.store.dispatch(Lt(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){w.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),w.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]=Ot(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,we.unmountComponentAtNode)(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]=Ot(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{(0,we.unmountComponentAtNode)(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Nt(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(()=>{(0,we.unmountComponentAtNode)(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),w.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()?(w.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(el(n.metrics))):w.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(!wr(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:g,insertLink:u,inputMediator:m,closestScrollSelector:f,appendOverlayTo:h,inlineSuggestions:k,floatingMenu:_}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:u,isEmbedded:d,inlineSuggestions:k,floatingMenu:!!_}),o.automaticHandlingTime&&this.setupHandlingTime(e),Nt(e),this.inputMediator=m||(Ct(e)?new Ge(e):new Qt(e)),this.inputMediator.on("change",({plainText:v})=>{this.notifyInputChanged(v)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Ya({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",v=>{this.notifyKeyDown(v)}),this.inputMediator.on("paste",({pastedText:v,selectionText:A})=>{this.notifyPaste(v,A)}),this.inputMediator.on("cut",({selectionText:v})=>{this.notifyCut(v)});let x=f&&Ru(e,f)||void 0;if(k){let{customStyles:v,appendOverlayTo:A}=o;if(Ct(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let M=this.createInlineContainer(e,"deepdesk-caret");(0,we.render)((0,V.jsx)(Xt,{store:this.store,customStyles:v,children:(0,V.jsx)(Vt,{broadcastEvents:this.broadcastEvents,children:(0,V.jsx)(Bp,{})})}),M),this.inputMediator.on("caret",D=>{this.store.dispatch(Be([])),D?(M.style.display="block",M.style.top=`${D.top}px`,M.style.left=`${D.left}px`):M.style.display="none"});let K=this.overlayContainerFactory("floating-menu",x||e,{appendTo:typeof _=="object"&&"appendOverlayTo"in _?_.appendOverlayTo:A},v==null?void 0:v.floatingMenuRootNode);(0,we.render)((0,V.jsx)(Xt,{store:this.store,customStyles:v,children:(0,V.jsx)(Vt,{broadcastEvents:this.broadcastEvents,children:(0,V.jsx)(Ap,{onLogIn:()=>this.loginViaPopup().catch(D=>w.warn(D.message))})})}),K)}else{let v=this.overlayContainerFactory("deepdesk-tab-completion",x||e,{appendTo:h,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),A=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||e,{appendTo:h},n==null?void 0:n.suggestionsRootNode);(0,we.render)((0,V.jsx)(Xt,{store:this.store,customStyles:n,children:(0,V.jsx)(Vt,{broadcastEvents:this.broadcastEvents,children:(0,V.jsx)(hd,{inputElement:e})})}),v),(0,we.render)((0,V.jsx)(Xt,{store:this.store,customStyles:n,children:(0,V.jsx)(Vt,{broadcastEvents:this.broadcastEvents,children:(0,V.jsx)(Gp,{onLogIn:()=>this.loginViaPopup().catch(M=>w.warn(M.message))})})}),A)}(0,we.render)((0,V.jsx)(Xt,{store:this.store,customStyles:n,children:(0,V.jsx)(Vt,{broadcastEvents:this.broadcastEvents,children:(0,V.jsx)(wp,{})})}),this.createContainer("deepdesk-overlays"));let b;this.inputMediator.on("selection",v=>{clearTimeout(b),v===null?b=setTimeout(()=>{v!==null&&this.store.dispatch(Or(v))},500):this.store.dispatch(Or(v))}),this.inputMediator.on("disabled",()=>{var v;(v=this.inputMediator)==null||v.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{g&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(_o(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(_o(!0))),this.store.dispatch(Va({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(qe()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var v;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((v=this.state.conversation.current)==null?void 0:v.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&&w.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}),(0,we.render)((0,V.jsx)(Xt,{store:this.store,customStyles:n,children:(0,V.jsx)(Vt,{broadcastEvents:this.broadcastEvents,children:(0,V.jsx)(cu,{onLogIn:()=>this.loginViaPopup().catch(i=>w.warn(i.message))})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setSessionId((i=this.state.conversation.current)==null?void 0:i.sessionId)})}unmountWidget(){this.widgetRoot&&(0,we.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=Tr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Pu(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(mn());let e=xt(this.state);e&&(await this.store.dispatch(dn()),this.store.dispatch(Fo({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions})))}),this.loadProfileConfigPromise)}async loginViaPopup(e){return new Promise((o,n)=>{let s=new MessageChannel,r=s.port1,i=this.state.settings.adminUrl,a=new URL(e!=null&&e.url?e==null?void 0:e.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,c=()=>{p&&!p.closed&&p.close(),window.removeEventListener("message",d),clearInterval(g)};r.onmessage=async u=>{var m,f;if((m=u.data)!=null&&m.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((f=u.data)==null?void 0:f.jwt),await this.isLoggedIn(),this.broadcastEvents.send(nn),l=!0,s.port1.close(),o()}catch(h){console.error(h),n(h)}finally{l=!0,c()}};let p=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");p===null&&n(new Error("Popup blocked by browser"));let d=async u=>{var m;if(u.origin===a.origin)switch((m=u.data)==null?void 0:m.type){case"deepdesk-popup-loaded":{try{let f=JSON.stringify({type:"deepdesk-popup-create-channel"});p==null||p.postMessage(f,a.origin,[s.port2])}catch(f){w.error("Error posting message to popup",f),n(f)}break}case"deepdesk-popup-error":{c(),u.data.message==="Timeout"&&w.warn("Popup timed out. Check if the account's platform url is configured correctly."),n(new Error(u.data.message));break}}};window.addEventListener("message",d);let g=setInterval(()=>{p&&!p.closed||(c(),l||n(new Error("Popup closed by user")))},200);this.unmountHandlers.push(c)})}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(w.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;w.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=Ws(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Me()):this.store.dispatch(Ae(n))})}catch(n){this.handleError(n)}}};async function Nu(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 Ou(t,e,o={}){let n=o.replace?It(t,o.replace.start,o.replace.end):Mo(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?It(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 Th(t){let e=document.createElement("template");return e.innerHTML=t.replace(/(\[([^\]]+)])\(([^)]+)\)/g,'<a href="$3" target="_blank" rel="noopener noreferrer">$2</a>'),e.content}function Eh(t){let e=document.createDocumentFragment();return t.split(`
11
- `).forEach((o,n)=>{n>0&&e.appendChild(document.createElement("br"));let s={index:0},r=0;for(;s=o.slice(r).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=s[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(s[2])),e.appendChild(document.createTextNode(o.slice(r,r+s.index))),e.appendChild(i),r=r+s.index+s[0].length}e.appendChild(document.createTextNode(o.slice(r)))}),e}function Du(t,e){return!t.contains(e)||e===t?null:e.parentNode===t?e:Du(t,e.parentNode)}async function Hu(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?Th(e):Eh(e);if(o){let p=l.startContainer===t?t.childNodes[l.startOffset]:l.startContainer,d=Du(t,p)??t.firstChild;t.insertBefore(c,(d==null?void 0:d.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 Bu(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function Fu(t,e,o){await new ct(t).authenticateWithKey(e,o)}async function Ku(t){let o=await new Oe(t).get("/platform/config/",{version:null});return L(o)}async function kh(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 Uu(t,e){let o=await kh(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}}0&&(module.exports={Card,ContentEditableInput,DeepdeskAPI,DeepdeskSDK,HTTPClient,InputMediator,InputType,KeyboardHint,Label,Locale,Section,SectionList,Sources,Suggestion,SuggestionList,TextAreaInput,ToggleButton,attachFile,authenticateWithKey,createFullRange,createOverlayContainer,createRangeFromOffsets,escapeHTML,fetchPlatformConfig,formatTextMarkup,getRangeOffsets,getRangeText,insertCKEditor,isHTML,isSupportedInputElement,updateContentEditable,updateTextArea,useStyles,waitForElementVisibilityChange});
7
+ c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var Ni=require("react/jsx-runtime"),If={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Hp=({className:t,color:e})=>(0,Ni.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ni.jsx)("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:If[e||"pink"]})});var Bp={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={};$(Oi,{enUS:()=>Pf,nlNL:()=>Af});var Pf={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},Af={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Up=require("react-redux"),Zt=require("react/jsx-runtime"),zp=({onLogIn:t})=>{let e=T(Oi),o=C("floatingMenu"),n=C("productName"),s=(0,Up.useDispatch)(),r=(0,Kp.useSelector)(ne),i=y("FloatingMenu",Bp);if(r===null||o===!1)return null;let a=()=>{r===!0?s(te(!0)):t()};return(0,Zt.jsxs)("button",{className:(0,Fp.default)(i.root,{[i.isLoggedIn]:r,[i.isLoggedOut]:!r}),onClick:a,children:[(0,Zt.jsx)("div",{className:i.text,children:e(r?"search":"signin",{productName:n})}),(0,Zt.jsxs)("div",{className:i.icon,children:[(0,Zt.jsx)(Hp,{className:i.logo,color:"pink"}),r===!1&&(0,Zt.jsx)(Dp,{className:i.lock})]})]})};var or=require("react"),st=require("react-redux");function Mo(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}var er=require("react");var Wp=require("interweave"),No=require("react"),Ys=require("react-redux");var jp=require("react");function Vp(t,e,o){(0,jp.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var qp={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};var Qt=require("react/jsx-runtime"),Mf=["search","personal-collection-search","search-autocomplete"];function Nf(t,e,o,n={}){let s="";return Mf.includes(e)?s=Hl(ii(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=ii(t,o,n),n.placeholders===!0&&(s=Bl(s)),s}var Of=()=>{},Df=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=C("inlineSuggestions"),r=(0,Ys.useSelector)(co),i=(0,Ys.useDispatch)(),a=y("TextSuggestion",qp),l=(0,No.useRef)(null);(0,No.useEffect)(()=>{let p=setTimeout(()=>{i(tl({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),Vp(l,"click",()=>{i(ht(t)),i(Ie({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=(0,No.useMemo)(()=>Nf(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:(0,Qt.jsxs)("div",{className:a.root,onMouseEnter:()=>i(ht(t)),children:[(0,Qt.jsx)(L,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:Of,children:(0,Qt.jsx)(Wp.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&(0,Qt.jsx)("div",{className:a.actions,children:(0,Qt.jsx)(Is,{onFeedback:()=>n(o),suggestion:o.text})})]})},$p=Df;var Di=require("react/jsx-runtime"),Hf=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=(0,er.useMemo)(()=>{let r=e.map((i,a)=>(0,Di.jsx)($p,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return(0,Di.jsx)(er.Fragment,{children:s})},tr=Hf;var Gp={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var _n=require("react/jsx-runtime"),Bf=({textSuggestions:t,selectedIndex:e})=>{let o=(0,or.useRef)(null),n=y("InlineSuggestionsOverlay",Gp),s=(0,st.useSelector)(Mo),r=(0,st.useDispatch)(),i=(0,st.useSelector)(ne),a=(0,st.useSelector)(lo),l=(0,st.useSelector)(Us),c=C("showTextSuggestions");return ho(()=>{r(xt({collapse:!0,skipWhenInputFocus:!0}))}),(0,or.useEffect)(()=>{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:(0,_n.jsx)("div",{className:n.root,"data-variant":"inline",children:(0,_n.jsx)("div",{ref:o,className:n.paper,children:(0,_n.jsx)(de,{children:(0,_n.jsx)(tr,{suggestions:t,selectedIndex:e})})})})},Ff=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Xp=(0,st.connect)(Ff)(Bf);var Zp=require("react-redux");var xn=require("react/jsx-runtime"),Kf=({children:t})=>{let o=C("locale").replace("-","");return(0,xn.jsx)(Qr.Provider,{value:o,children:t})},Uf=({store:t,customStyles:e={},children:o})=>(0,xn.jsx)(Zp.Provider,{store:t,children:(0,xn.jsx)(Kf,{children:(0,xn.jsx)(zo.Provider,{value:e,children:o})})}),Jt=Uf;var sr=k(require("classnames")),Oo=require("react"),ze=require("react-redux");var Qp=require("react");function Jp(t,e){let[o,n]=(0,Qp.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return w.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){w.error(i)}}]}var ed=k(require("classnames")),rt=require("react");var Hi={};$(Hi,{enUS:()=>zf,nlNL:()=>jf});var zf={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"}]}]},jf={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 Yp={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var wt=require("react/jsx-runtime"),Bi=(t,e,o)=>n=>(0,wt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),Vf=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=T(Hi),i=be(),a=y("Login",Yp),l=C("productName"),c=(0,rt.useCallback)(h=>{h.preventDefault(),n&&n(parseInt(h.target.value,10))},[]),p=(0,rt.useCallback)(h=>{h.preventDefault(),i.send(ko,!0)},[e]),d=(0,rt.useMemo)(()=>h=>(0,wt.jsx)("a",{onClick:x=>{x.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[e]),g=(0,rt.useCallback)(h=>(0,wt.jsx)("button",{type:"button",className:a.anchorButton,onClick:p,children:h},"prompt"),[p]),{min:u,hour:m,day:f}=(0,rt.useMemo)(()=>({min:Bi(a,60*10,c),hour:Bi(a,60*60,c),day:Bi(a,60*60*12,c)}),[]);return(0,wt.jsxs)("div",{className:(0,ed.default)(t,a.root),children:[r("loginPlease",{login:o?g:d,productName:l}),n&&(0,wt.jsxs)(rt.Fragment,{children:[(0,wt.jsx)("br",{}),r("snooze",{min:u,hour:m,day:f})]})]})},nr=Vf;var od=require("react-redux");var td={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var bn=require("react/jsx-runtime"),qf=({title:t})=>{let e=y("SearchTrigger",td),o=(0,od.useDispatch)();return(0,bn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(te(!0)),children:[(0,bn.jsx)(xo,{}),(0,bn.jsx)("span",{className:e.text,children:t})]})},nd=qf;var Fi={};$(Fi,{enUS:()=>Wf,nlNL:()=>$f});var Wf={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"}]},$f={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 sd={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"};var F=require("react/jsx-runtime"),Gf=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=y("SuggestionsOverlay",sd),s=T(Fi),r=(0,ze.useSelector)(Mo),i=Za(),a=(0,ze.useDispatch)(),l=(0,Oo.useRef)(null),c=C("searchTriggerKey"),p=C("productName"),d=(0,ze.useSelector)(Us),g=(0,ze.useSelector)(ne),u=(0,ze.useSelector)(lo),[m,f]=(0,Oo.useState)(null),h=C("showSearch"),E=C("showTextSuggestions"),x=C("adminUrl"),_=C("isEmbedded"),[b,v]=Jp("dd-snooze-until-ms",0),A=d||b>Date.now(),O=(0,ze.useSelector)(R=>R.input.text),K=t.filter(R=>R.source!=="gpt").length,H=()=>{A&&v(0),a(Oc(!A))},W=R=>{a(Q({name:"suggestion feedback",data:{text:R.text,source:"overlay",context:O},options:{includeConversationData:!0}}))},z=R=>{let he=Date.now()+R*1e3;v(he),w.info(`Snooze until: ${new Date(he)}`),a(xt({collapse:!0}))};return(0,Oo.useEffect)(()=>{K===0&&f(null)},[t,K]),ho(()=>{a(xt({collapse:!0,skipWhenInputFocus:!0}))}),g===null||u===!1?null:g===!1?(0,F.jsxs)("div",{ref:l,className:(0,sr.default)(n.root,{[n.isCollapsed]:A}),children:[!A&&(0,F.jsxs)("div",{className:n.triggers,children:[(0,F.jsx)("div",{style:{flex:1}}),(0,F.jsx)("div",{className:n.triggersRight,children:(0,F.jsx)(Mt,{className:n.toggleButton,title:s("collapse"),onClick:H,isCollapsed:!1})})]}),(0,F.jsx)("div",{className:n.toggleButtonWrapper,children:(0,F.jsx)(Mt,{className:n.toggleButton,title:s("open",{productName:p}),onClick:H,isCollapsed:!0})}),(0,F.jsx)("div",{className:n.collapsible,children:(0,F.jsx)(nr,{loginUrl:x,isEmbedded:_,onLogIn:o,onSnooze:z})})]}):!i||!r?null:(0,F.jsxs)("div",{ref:l,className:(0,sr.default)(n.root,{[n.isCollapsed]:A}),children:[!A&&(0,F.jsxs)("div",{className:n.triggers,children:[(0,F.jsx)("div",{style:{flex:1},children:h&&(0,F.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(s(Os()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>f(null),children:(0,F.jsx)(nd,{title:s("search")})})}),(0,F.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,F.jsx)("div",{className:(0,sr.default)(!m&&n.hintsHidden,n.hints),children:m}),(0,F.jsx)(Mt,{className:n.toggleButton,title:s("collapse"),onClick:H,isCollapsed:!1})]})]}),(0,F.jsx)("div",{className:n.toggleButtonWrapper,children:(0,F.jsx)(Mt,{className:n.toggleButton,title:s("open",{productName:p}),onClick:H,isCollapsed:!0})}),K>0&&E&&(0,F.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,F.jsx)(de,{children:(0,F.jsx)(tr,{onFeedback:W,suggestions:t,selectedIndex:e,reverse:!0})})})]})},Xf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),rd=(0,ze.connect)(Xf)(Gf);var yr=k(require("classnames")),wd=require("interweave"),lt=require("react"),Td=require("react-redux");var id=require("react"),Zf=["div","span","mark","strong","b","i","u","em"];function Ki(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(Zf.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,id.cloneElement)(n,{children:Ki(i,e,o+1)})]}return[...t,...e]}function Tt(t){return t.tagName.toLowerCase()==="textarea"}var ad={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"};var hd=k(require("classnames")),yd=require("interweave"),gr=require("react");function ld(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function rr(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function cd(t){return t!=null}var zi=k(require("classnames")),Ce=require("react");var ir=require("react"),Qf=["bottom","height","left","right","top","width"],Jf=(t={},e={})=>Qf.some(o=>t[o]!==e[o]),it=new Map,pd,dd=()=>{let t=[],e=[];it.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Jf(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{it.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),pd=window.requestAnimationFrame(dd)};function Yf(t,e){return{observe(){let o=it.size===0;if(it.has(t)){let n=it.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else it.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&dd()},unobserve(){let o=it.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||it.delete(t),it.size||cancelAnimationFrame(pd)}}}}function Ui(t){let[e,o]=(0,ir.useState)(null);return(0,ir.useLayoutEffect)(()=>{if(!t.current)return;let n=Yf(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var Do=require("react"),gd=require("react-dom");var ud={root:"_root_1jq08_1"};var md=({children:t})=>{let[e,o]=(0,Do.useState)(null),n=(0,Do.useContext)(zo);return(0,Do.useLayoutEffect)(()=>{let s=document.createElement("div");return Dt(s),s.classList.add(ud.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?(0,gd.createPortal)(t,e):null};var je={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"};var ar=require("react/jsx-runtime"),lr=(t=!1)=>{let[e,o]=(0,Ce.useState)(t),n=(0,Ce.useCallback)(()=>o(!0),[]),s=(0,Ce.useCallback)(()=>o(!1),[]),r=(0,Ce.useCallback)(()=>o(a=>!a),[]),i=(0,Ce.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function ji(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 cr=({className:t,triggerRef:e,boundaryRef:o=(0,Ce.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=ji,...a})=>{let l=Ui(e),c=Ui(o),p=(0,Ce.useMemo)(()=>i(l,c,0),[l,c]);return(0,ar.jsx)(md,{children:(0,ar.jsx)("div",{className:(0,zi.default)(je.ref,{[je.positionAbove]:n==="above",[je.positionBelow]:n==="below",[je.positionLeft]:n==="left",[je.positionRight]:n==="right",[je.alignStart]:s==="start",[je.alignCenter]:s==="center",[je.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:(0,ar.jsx)("div",{className:(0,zi.default)(t,je.root),children:r})})})};var fd=k(require("classnames")),pr=require("react");var Vi=require("react/jsx-runtime"),dr=(0,pr.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,pr.useRef)(null),r=y("TabCompletion",$e);return(0,Vi.jsx)("div",{ref:rr([s,n]),className:(0,fd.default)(t,r.popoverContentContainer),...o,children:(0,Vi.jsx)("div",{className:r.popoverContent,children:e})})});var Et=require("react/jsx-runtime"),eh=t=>e=>{let o=ji(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},th=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",$e),i=lr(),a=(0,gr.useMemo)(()=>eh(t.getBoundingClientRect()),[t]),[l,c]=xs(t);return(0,gr.useEffect)(()=>{c?i.open():i.close()},[c]),(0,Et.jsxs)("span",{children:[(0,Et.jsx)("mark",{ref:rr([l,i.triggerRef]),className:(0,hd.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,Et.jsx)(cr,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,Et.jsx)(dr,{style:o,children:(0,Et.jsx)("div",{className:r.hintText,children:s})})})]})},ur=class extends yd.Matcher{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${ld(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(cd);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(0,Et.jsx)(th,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var fr=k(require("classnames")),bd=require("interweave"),ie=require("react"),Cd=require("react-redux");var qi=require("react/jsx-runtime"),vd=()=>(0,qi.jsx)("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:(0,qi.jsx)("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"})});var kt=require("react"),Cn=require("react-redux"),_d=k(require("lodash.debounce"));var Sd={root:"_root_1muu8_1",content:"_content_1muu8_7"};function mr(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 Wi(t){return t.replace("https://www.","").replace("https://","")}var we=require("react/jsx-runtime"),oh=3,nh=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),sh=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=oh})=>{let r=y("LinkSearch",Sd),[i,a]=(0,kt.useState)(""),l=(0,Cn.useDispatch)(),c=(0,Cn.useSelector)(Fs("url")),p=(0,Cn.useSelector)(cc("URL",nh)),[d,g]=(0,kt.useState)(p.length-1),u=C("fallbackImage"),m=x=>{let _=x.target;a(_.value)},f=(x,_)=>{x.stopPropagation(),x.preventDefault(),window.open(_,"_blank")},h=x=>{var v;let _=d-1<0?p.length-1:d-1,b=d+1===p.length?0:d+1;x.code==="Escape"&&(a(""),e()),x.code==="ArrowUp"&&g(_),x.code==="ArrowDown"&&g(b),x.code==="Enter"&&t(((v=p[d])==null?void 0:v.text)||i)},E=(0,kt.useCallback)((0,_d.default)(x=>{l(jt({query:x,type:"URL",tags:["link-search"]}))},300),[]);return(0,kt.useEffect)(()=>{i&&E(i)},[i]),(0,kt.useEffect)(()=>()=>{l(Ms())},[]),(0,we.jsxs)("div",{className:r.root,children:[(0,we.jsx)(de,{withDivider:!0,children:(i?p:c).slice(0,s).map((x,_)=>(0,we.jsx)(L,{selected:d===_,onClick:()=>t(x.text),"data-testid":"linksearch-suggestion",children:(0,we.jsxs)(D,{children:[(0,we.jsx)(D.Image,{src:mr(x,"small",u||void 0),title:x.title||x.text}),(0,we.jsxs)(D.Content,{className:r.content,cropText:!0,children:[(0,we.jsx)(D.Title,{children:x.title||Wi(x.text)}),x.title&&Wi(x.text)]}),(0,we.jsx)(L.Actions,{children:(0,we.jsx)(L.ActionButton,{label:n,onClick:b=>f(b,x.text)})})]})},x.text))}),(0,we.jsx)(dn,{value:i,onChange:m,autoFocus:!0,placeholder:o,onKeyUp:h})]})},xd=sh;var $i={};$($i,{enUS:()=>rh,nlNL:()=>ih});var rh={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},ih={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var re=require("react/jsx-runtime"),ah=(0,ie.forwardRef)((t,e)=>{let o=y("TabCompletion",$e);return(0,re.jsx)("mark",{ref:e,className:(0,fr.default)(o.matchSelection)},"selection-start")}),lh=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=T($i),i=y("TabCompletion",$e),a=(0,ie.useRef)(null),l=(0,ie.useRef)(null),[c,p]=(0,ie.useState)(null),d=(0,Cd.useDispatch)(),g=lr(document.activeElement===n),[u]=(0,ie.useState)(()=>document.createRange());g.triggerRef.current=u,(0,ie.useEffect)(()=>()=>u.detach(),[]),(0,ie.useEffect)(()=>{let f=t.current,h=a.current;!f||!h||(u.setStart(f,0),u.setEnd(h,0))},[t.current,a.current]),ho(()=>{g.close()});let m=(0,ie.useCallback)(f=>{let h=u.toString(),E=/^http(s?):\/\//.test(f)?f:`https://${f}`;d(ts({text:`[${h}](${E})`,replace:"selection"}))},[]);return(0,re.jsxs)("span",{children:[(0,re.jsx)("mark",{ref:a,className:(0,fr.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":g.opened?"true":"false",children:s}),g.opened&&(0,re.jsx)(cr,{className:i.popoverRoot,triggerRef:g.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,re.jsxs)(dr,{style:o,ref:l,children:[(0,re.jsx)("div",{className:(0,fr.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,re.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,re.jsx)(vd,{}),(0,re.jsx)("span",{children:"\xA0"}),(0,re.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,re.jsx)(xd,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:m,onDismiss:()=>{p(null),g.close()}})]})})]},"selection-end")},hr=class extends bd.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,ie.createRef)(),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?(0,re.jsx)(ah,{ref:this.startRef}):(0,re.jsx)(lh,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var Ed=require("react-redux");var at=require("react/jsx-runtime"),ch=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",ad),p=C("insertLink"),d=C("showMidSentenceSuggestions"),g=C("inlineSuggestions"),u=Cs(a),m=(0,lt.useRef)(null),f=(0,Ed.useSelector)(ne);(0,lt.useEffect)(()=>{Tt(a)&&u&&ws(a,u)},[u]);let h=(0,lt.useCallback)(_=>{if(!s||!o)return _;let b=[(0,at.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,at.jsx)("span",{"data-testid":"tab-completion",className:(0,yr.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&b.push((0,at.jsx)("span",{className:(0,yr.default)(c.hint,c.resetIndent),children:(0,at.jsx)(jn,{keyCode:"tab"},"tabHint")})),Ki(_,b)},[s,o,n]),E=(0,lt.useMemo)(()=>{let _=[];return p&&_.push(new hr("selection")),_.push(new mo("placeholders")),r&&_.push(new ur("keywords")),_},[g,p,r]),x=(0,lt.useMemo)(()=>{let _=window.getComputedStyle(a);return{"--dd-color":_.color,"--dd-font-size":_.fontSize,"--dd-font-family":_.fontFamily,"--dd-font-variant":_.fontVariant}},[]);return!t||!f?null:(0,at.jsxs)("div",{ref:_=>{_!=null&&_.parentElement&&(m.current=_==null?void 0:_.parentElement)},className:c.root,style:x,children:[(0,at.jsx)(wd.Interweave,{tagName:"span",containerTagName:"div",className:(0,yr.default)(c.container,c.agentText),disableLineBreaks:Tt(a),content:e||"\u200B",onAfterParse:h,matchers:E,selection:u,keywordMatches:i,inputElement:a,inputStyle:x,boundaryRef:m,inlineSuggestionsOnlyAtEnd:!d}),(0,at.jsx)("br",{})]})},ph=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var f;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??vo(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:g,visible:u,showStyleSuggestions:m}=o;return{showTabHint:p,showStyleSuggestions:m,showTabCompletion:g,content:l,tabText:c,source:a,keywordMatches:((f=n.list)==null?void 0:f.keywordMatches)??[],enabled:u&&d!==!1}},kd=(0,Td.connect)(ph)(ch);var _u=k(require("classnames")),xu=require("react"),X=require("react-redux");var Rt=require("@reduxjs/toolkit");var Rd={list:[],fetchState:"idle",isInitialRequest:null},Pd=t=>t.autoflows.list||[],Id=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},ct=(0,Rt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Gi=(0,Rt.createAsyncThunk)("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(ct(t.platformSessionId))}),Xi=(0,Rt.createAsyncThunk)("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(ct(t.platformSessionId))}),dh=(0,Rt.createSlice)({name:"autoflows",initialState:Rd,reducers:{},extraReducers:t=>{t.addCase(Gi.pending,(e,o)=>{let n=Id(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Xi.pending,(e,o)=>{let n=Id(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(ct.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(ct.rejected,e=>{e.fetchState="error"}),t.addCase(ct.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(M,()=>Rd)}}),Ad=(0,Rt.createAsyncThunk)("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(ct(t))}),s.on("sessionCompleted",()=>{o(ct(t))})}),Ld=(0,Rt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Md=dh.reducer;var It=require("@reduxjs/toolkit");var Nd={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Od=t=>t.customMessages.list,Dd=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Hd=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Bd=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),wn=(0,It.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),vr=(0,It.createAsyncThunk)("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)}),Sr=(0,It.createAsyncThunk)("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)}),Fd=(0,It.createSlice)({name:"customMessages",initialState:Nd,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(wn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(wn.rejected,e=>{e.fetchState="error"}).addCase(wn.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(vr.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(vr.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(Sr.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(Sr.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(M,()=>Nd)}}),Kd=(0,It.createAsyncThunk)("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(Fd.actions.onCustomMessage(r))})}),Ud=(0,It.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),zd=Fd.reducer;var Tn=require("@reduxjs/toolkit"),uh={token:null,accountUrl:null,interval:null},jd=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},Zi=(0,Tn.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),Qi=(0,Tn.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(Zi()),setInterval(()=>n(Zi()),o)}),Vd=(0,Tn.createSlice)({name:"passwordlessToken",initialState:uh,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Zi.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(Qi.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:qd}=Vd.actions,Wd=Vd.reducer;function $d(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var ou=require("react"),nu=require("react-redux");var Yd=k(require("classnames")),eu=require("react");var Xd=k(require("classnames"));var Gd={root:"_root_838fd_1"};var Qd=require("react/jsx-runtime"),gh=({className:t,children:e})=>{let o=y("Unicode",Gd);return(0,Qd.jsx)("span",{className:(0,Xd.default)(t,o.root),children:e})},Zd=gh;var Jd={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 Ji={};$(Ji,{enUS:()=>mh,nlNL:()=>fh});var mh={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"}]},fh={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"}]};var me=require("react/jsx-runtime"),yh=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",Jd),a=T(Ji),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,me.jsxs)(L,{className:(0,Yd.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,me.jsx)(D,{children:(0,me.jsxs)(D.Content,{children:[(0,me.jsxs)(D.Title,{children:[e&&(0,me.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,me.jsx)("span",{children:n})]})}),(0,me.jsx)(L.Actions,{fixed:e==="Started",children:(0,me.jsx)(L.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,me.jsxs)(eu.Fragment,{children:[(0,me.jsx)(Zd,{children:c})," ",(0,me.jsx)("span",{children:a(l)})]})})})]})},tu=yh;var Yi=require("react/jsx-runtime"),vh=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Sh=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,Yi.jsx)(ou.Fragment,{children:t.map(s=>(0,Yi.jsx)(tu,{displayName:s.displayName,description:s.description,disabled:s.isBusy||vh(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),_h=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},xh={onStartAutoflow:Gi,onStopAutoflow:Xi},su=(0,nu.connect)(_h,xh)(Sh);var ru=k(require("classnames")),ea=require("react"),Yt=require("react-redux");var pt={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"};var pe=require("react/jsx-runtime"),bh=({suggestion:t})=>{let e=T(Ut),o=(0,Yt.useDispatch)(),n=(0,Yt.useSelector)(Dd(t.text)),s=(0,Yt.useSelector)(Hd(t.text)),r=(0,Yt.useSelector)(Bd(t.text)),i=(0,Yt.useSelector)($n),{replyOptions:a}=t,l=(0,ea.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(vr({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,ea.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),g=a[d];o(Sr({platformSessionId:i,reply:g,suggestion:t}))},[t,n,o,i]);return(0,pe.jsxs)(L,{onClick:l,className:(0,ru.default)(pt.root,{[pt.isUsed]:n,[pt.hasError]:r}),children:[(0,pe.jsx)(D,{children:(0,pe.jsxs)(D.Content,{children:[(0,pe.jsxs)(D.Title,{className:pt.title,children:[t.text," ",(0,pe.jsx)(Vn,{className:pt.label,children:"analyse tool"})," ",r&&(0,pe.jsx)("span",{className:pt.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,pe.jsx)("ul",{className:pt.quickReplies,children:a.map(p=>(0,pe.jsx)("li",{className:pt.quickReply,children:p.title},p.title))})]})}),(0,pe.jsxs)(L.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,pe.jsx)(L.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>(0,pe.jsx)(L.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),(0,pe.jsx)(L.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},iu=bh;var _r=require("react"),lu=require("react-redux"),na=k(require("classnames"));var ta=require("react/jsx-runtime"),oa=()=>(0,ta.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,ta.jsx)("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 au={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};var Ve=require("react/jsx-runtime"),Ch=({entities:t})=>{let e=y("EntitiesWidgetList",au),[o,n]=(0,_r.useState)(void 0),s=(0,lu.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),$t(a.text),s(Q({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,_r.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,Ve.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,Ve.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Ve.jsx)("span",{className:e.entityText,children:a.text}),(0,Ve.jsxs)("span",{className:e.iconWrapper,children:[(0,Ve.jsx)("span",{className:(0,na.default)(e.icon),children:(0,Ve.jsx)(oa,{})}),(0,Ve.jsx)("span",{className:(0,na.default)(e.icon,o===l&&e.iconClicked),children:(0,Ve.jsx)(oa,{})})]})]},a.text))})},cu=Ch;var sa=require("react/jsx-runtime"),pu=()=>(0,sa.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,sa.jsx)("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});var ra=require("react/jsx-runtime"),du=()=>(0,ra.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,ra.jsx)("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"})});var ia=require("react/jsx-runtime"),uu=()=>(0,ia.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,ia.jsx)("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"})});var fu=require("react-redux");var gu=require("react");var fe=require("react/jsx-runtime"),wh=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var g;let s=t.text||t.url||t.message,r=Ns(s),i=T(Ut),a=C("showImages"),l=C("fallbackImage"),c=u=>{u.preventDefault(),u.stopPropagation(),n(s)},p=u=>{u.preventDefault(),u.stopPropagation(),o(t)},d=(0,gu.useCallback)(u=>{window.open(r,"_blank"),u.stopPropagation(),u.preventDefault()},[r]);return(0,fe.jsxs)(L,{onClick:c,"data-testid":"edit-suggestion",children:[(0,fe.jsxs)(D,{children:[a&&t.image&&(0,fe.jsx)(D.Image,{src:mr(t,"small",l||void 0),title:t.title}),(0,fe.jsxs)(D.Content,{children:[t.title&&(0,fe.jsx)(D.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((g=t.searchKeywords)==null?void 0:g.length)>0&&(0,fe.jsx)(L.Labels,{labels:t.searchKeywords}),(0,fe.jsx)(D.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),(0,fe.jsxs)(L.Actions,{children:[r&&(0,fe.jsx)(L.ActionButton,{onClick:d,label:i("visitUrl")}),(0,fe.jsx)(L.ActionButton,{primary:!0,onClick:p,label:i("preview")}),(0,fe.jsx)(L.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},mu=wh;var En=require("react/jsx-runtime"),Th=({contentType:t,lines:e,suggestions:o})=>{let n=be(),s=(0,fu.useSelector)(_t),r=a=>{n.send(Ci,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(tt,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,En.jsx)(En.Fragment,{children:o.map(a=>(0,En.jsx)(mu,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},hu=Th;var aa={};$(aa,{enUS:()=>Eh,nlNL:()=>kh});var Eh={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"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},kh={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"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var yu={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"};var xr=require("react");var la={};$(la,{enUS:()=>Rh,nlNL:()=>Ih});var Rh={copyCue:[{type:0,value:"Copy"}],copiedCue:[{type:0,value:"Copied!"}],removeCue:[{type:0,value:"Discard"}]},Ih={copyCue:[{type:0,value:"Kopieer"}],copiedCue:[{type:0,value:"Gekopieerd!"}],removeCue:[{type:0,value:"Verwijderen"}]};var dt=require("react/jsx-runtime"),Ph=({cue:t,onRemove:e,onCopy:o})=>{let n=T(la),[s,r]=(0,xr.useState)(!1),i=l=>{l.preventDefault(),l.stopPropagation(),o&&(o(t.text),r(!0))},a=l=>{l.preventDefault(),l.stopPropagation(),e&&e(t.id)};return(0,xr.useEffect)(()=>{if(!s)return;let l=setTimeout(()=>{r(!1)},1e3);return()=>{clearTimeout(l)}},[s]),(0,dt.jsx)(L,{"data-testid":"cue",children:(0,dt.jsxs)(D,{expandOnHover:!0,children:[(0,dt.jsxs)(D.Content,{lineClamp:!0,children:[t.title&&(0,dt.jsx)(D.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.text]}),(0,dt.jsxs)(L.Actions,{children:[e&&(0,dt.jsx)(L.ActionButton,{primary:!0,onClick:a,label:n("removeCue")}),o&&(0,dt.jsx)(L.ActionButton,{primary:!0,onClick:i,label:n(s?"copiedCue":"copyCue")})]})]})})},vu=Ph;var kn=require("react/jsx-runtime"),Ah=({cues:t,onCopyCue:e,onRemoveCue:o})=>(0,kn.jsx)(kn.Fragment,{children:t.map(n=>(0,kn.jsx)(vu,{cue:n,onRemove:o,onCopy:e},`${n.id}_${n.timestamp}`))}),Su=Ah;var I=require("react/jsx-runtime"),br=(t,e)=>{let o=(0,X.useSelector)(ne);(0,xu.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},Lh=({onLogIn:t})=>{let e=T(aa),o=(0,X.useDispatch)(),n=C("isEmbedded"),s=y("Widget",yu),r=C("showAutoflows"),i=C("showCustomMessages"),a=C("showSummaryCommand"),l=C("showKnowledgeSearch"),c=C("showSearch"),p=(0,X.useSelector)(Ct),d=(0,X.useSelector)(Qs),g=(0,X.useSelector)(Pd),u=(0,X.useSelector)(Wc),m=(0,X.useSelector)(Ws),f=(0,X.useSelector)(Od),h=(0,X.useSelector)(Gn),E=(0,X.useSelector)(lo),x=(0,X.useSelector)(ne),_=(0,X.useSelector)($n),b=(0,X.useSelector)($d),v=(0,X.useSelector)(_t),A=be(),O=(0,X.useSelector)(_c),K=(0,X.useSelector)(jd("/admin/")),H=C("adminUrl"),W=C("productName");if(br(()=>(o(wn(_)),o(Kd(_)),()=>{o(Ud(_))}),[o,E,i,_]),br(()=>(o(ct(_)),o(Ad(_)),()=>{o(Ld(_))}),[o,E,r,_]),br(()=>{d.forEach(({type:R})=>{o(R==="entities"?Ne():Le(R))})},[o,E,h,p]),br(()=>(o(Qi()),()=>{o(qd())}),[o]),E===!1)return(0,I.jsx)("div",{className:s.stateText,children:(0,I.jsx)("div",{children:(0,I.jsx)("p",{children:e("notSupported")})})},"supported");if(x===!1)return(0,I.jsx)("div",{className:s.loginText,children:(0,I.jsx)("div",{children:(0,I.jsx)(nr,{isEmbedded:n,loginUrl:H,onLogIn:t})})},"login");if(!p||!_||x===null||O||b)return(0,I.jsx)("div",{className:s.stateText,children:(0,I.jsx)("div",{children:(0,I.jsx)("p",{children:e("waiting")})})},"waiting");let z=c||a||l||K;return(0,I.jsx)("div",{className:(0,_u.default)(s.root),"data-testid":"widget",children:(0,I.jsxs)(qn,{className:s.sectionList,children:[z&&(0,I.jsx)(qe,{title:e("actions"),type:"shortcuts",children:(0,I.jsxs)("div",{className:s.shortcutList,children:[c&&(0,I.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-search",onClick:()=>A.send("ShowCommandPalette",{isOpen:!0}),children:[(0,I.jsx)(xo,{}),e("linkSearch")]}),a&&(0,I.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-summary",onClick:()=>A.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,I.jsx)(uu,{}),e("linkSummary")]}),l&&(0,I.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>A.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,I.jsx)(du,{}),e("linkKnowledgeSearch")]}),K&&(0,I.jsxs)("a",{className:s.shortcut,target:"_blank",href:K,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[(0,I.jsx)(pu,{}),e("linkStudioLogin",{productName:W})]})]})}),i&&f.length>0&&(0,I.jsx)(qe,{type:"custom-messages","data-testid":"custom-messages",children:(0,I.jsx)(de,{withDivider:!0,children:f.map(R=>(0,I.jsx)(iu,{suggestion:R},R.text))})}),r&&g.length>0&&(0,I.jsx)(qe,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,I.jsx)(de,{withDivider:!0,children:(0,I.jsx)(su,{})})}),d.map(({type:R,title:he,amount:Lr,lines:Ko})=>{var Uo;switch(R){case"entities":return m&&m.length>0&&(0,I.jsx)(qe,{type:R,title:he,"data-testid":`type-${R}`,children:(0,I.jsx)(cu,{entities:m})},R);case"cues":return u&&u.length>0&&(0,I.jsx)(qe,{type:R,title:he,"data-testid":`type-${R}`,children:(0,I.jsx)(de,{withDivider:!0,children:(0,I.jsx)(Su,{cues:u,onCopyCue:oo=>$t(oo)})})},R);default:return((Uo=v[R])==null?void 0:Uo.fetchState)==="done"&&v[R].suggestions.length>0&&(0,I.jsx)(qe,{type:R,title:he,"data-testid":`type-${R}`,children:(0,I.jsx)(de,{withDivider:!0,children:(0,I.jsx)(hu,{lines:Ko,contentType:R,suggestions:v[R].suggestions.slice(0,Lr)||[]})})},R)}})]})})},bu=Lh;function Ho(t){let e=new Range;return e.selectNodeContents(t),e}function Cu(t,e,o){try{return Pt(t,e,o),!0}catch{return!1}}function Cr(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function wr(t){return"tagName"in t&&t.tagName==="BR"}var Rn=/[\u200B-\u200D\uFEFF]/g;function Pt(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 g=0;g<=l.length;g++)if(d.test(l[g])||p++,p===c)return g;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(Rn,""),d=s+p.length,g=e>=s&&e<=d,u=o>=s&&o<=d;if(g){let m=i(c,e-s);m===0&&!u?n.setStartBefore(l):n.setStart(l,m)}u&&(n.setEnd(l,i(c,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(wr(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;Cr(l)&&c&&!Cr(c)&&!wr(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function In(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 g=d===o,u=d===s;switch(d.nodeType){case Node.TEXT_NODE:{let m=d.textContent;g&&(a=c+m.substring(0,n).replace(Rn,"").length),u&&(l=c+m.substring(0,r).replace(Rn,"").length),c+=m.replace(Rn,"").length;break}case Node.ELEMENT_NODE:{let m=d.nextSibling===null;wr(d)&&!m&&c++;for(let f=0;f<d.childNodes.length;f++){let h=g&&f===n,E=u&&f===r;if(h&&(a=c),E&&(l=c),l!==void 0||((!h||!i)&&p(d.childNodes[f]),u&&f===r-1&&(l=c),l!==void 0))break}!u&&Cr(d)&&!m&&c++,u&&(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 Pn(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 g=p?n:0,u=d?r:void 0,m=c.textContent.replace(Rn,"");g===0&&u===void 0?a+=m:a+=m.substring(g,u);break}case Node.ELEMENT_NODE:{let g=c.nextSibling===null;i===0&&wr(c)&&!g&&(a+=`
8
+ `);for(let u=p?n:0;u<(d?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[u]),i!==1);u++);!d&&i===0&&Cr(c)&&!g&&(a+=`
9
+ `);break}default:break}d&&i++}return l(t),a}function wu(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var eo=class extends Ge{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),Pn(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!wu(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!wu(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return In(this.element,e);let o=this.lastKnownSelection;if(o&&Cu(this.element,o.start,o.end))return o;let n=Ho(this.element);return n.collapse(!1),In(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return Pn(this.element,Pt(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 Tu(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 ca=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(JSON.stringify(e))}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},pa=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=Tu(e,`${this.targetOrigin}/sdk/proxy/proxy.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(JSON.stringify(e),this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},da=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(),w.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 pa(e,this.deepdeskUrl,{debug:!0}):new ca(e),n=s=>{var i,a;if(s.origin!==this.deepdeskUrl)return;let r=typeof s.data=="string"?JSON.parse(s.data):s.data;r.type==="event"&&r.channel===e&&(w.info("Received broadcast event",this.sessionId,s),(a=(i=this.eventMap)[r.name])==null||a.call(i,r.payload))};return o.onMessage(n),o}send(e,o,n){var i,a;w.info("Broadcast event",{sessionId:this.sessionId,name:e,payload:o});let s={type:"event",name:e,payload:o};n!==!1&&((a=(i=this.eventMap)[e])==null||a.call(i,o));let r=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;r==null||r.postMessage({...s,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)}},Eu=da;var Bo=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var ua=t=>new Promise(e=>{setTimeout(e,t)});var Fo=class extends Bo{name="ClientError"},ga=class extends Bo{name="ServerError"},De=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:g=b=>b instanceof TypeError,retryOnResponse:u=b=>b.status>=500,version:m="v1",...f}=o,h={credentials:"include",...f,headers:{"Content-Type":"application/json",...f.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(h.headers={...h.headers,"X-CSRFToken":this.csrfToken}),typeof m=="string"&&(h.headers={...h.headers,"X-Deepdesk-API-Version":m});let E=c,x=!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 _=async()=>(E--,a(i,h).then(async b=>u(b)&&!r.isAborted&&E>0?(await ua(p),_()):b.status===401&&d===!0&&x===!1?(x=!0,await this.refreshToken(),_()):b).catch(async b=>{if(g(b)&&!r.isAborted&&E>0)return await ua(p),_();throw b}));_().then(b=>b.json().catch(()=>null).then(v=>{b.status>=500?s(new ga("Server Error",v)):b.status===401?s(new Fo("Unauthorized",v)):b.status===403?s(new Fo("Forbidden",v)):b.status===404?s(new Fo("Not Found",v)):b.status>=400&&s(new Fo("Bad Request",v)),delete this.latestRequestByUrl[i],n(v)})).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 Mh;(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||={})})(Mh||={});function Tr(t){return{...N(t),tags:t.tags}}var ut=class t{constructor(e,o={}){this.options=o;this.client=new De(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(),w.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...G(e),tags:e.tags},{version:"v2"});return Tr(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return N(o)}async getKnowledgeAssistant(e){let o=await this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{version:null});return N(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return N(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return N(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(),w.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 w.info(`Successfully retrieved conversation ${r.id} for session ${e}`),Tr(r)}async isConversationSupported(e,o={}){w.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=G(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return Tr(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...G(s),tags:s.tags})),{version:"v2"})).map(s=>Tr(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",G({...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:G({...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),agent_id:o.agentId,id:o.externalConversationId},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 w.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",G(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}`,G(o),{abortLatest:!0})).map(r=>({...N(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`,G(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 N(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",G(e),{abortLatest:!0});return N(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,G(e),{version:"v2"});return N(o)}async knowledgeAssist(e,o,n,s={}){let r=await this.client.post(`/api/knowledge-assist/assistants/${n}/search`,G({question:e.question,promptInstruction:e.promptInstruction,chatHistory:o.map(i=>({question:i.question,answer:i.answer.answer})),agentId:s.agentId,conversationId:s.conversationId}),{version:"v2"});return N(r)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return N(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return N(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 N(o)}async evaluateRule(e,o,n,s={}){let r=new URLSearchParams;s.raiseForFailingConditions&&r.set("raise_for_failing_conditions","true");let i=await this.client.post(`/api/conversations/${o}/rules/${e}/evaluate?${r.toString()}`,n,{version:"v2"});return N(i.cues)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(Ba);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&w.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var An=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(fi(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,N(s))}catch{w.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 Nh;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(Nh||={});var Ln=class{constructor(e,o={}){this.apiUrl=e;this.client=new De(e,o)}client;streams={};logger=w;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return N(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,G(o));return N(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,G(o))}async getAutoflows(e){let o=await this.client.get(`/sessions/${e}/autoflows`);return N(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",G(e));return N(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new An(`${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])}};var Ir=require("@reduxjs/toolkit");var Ru=require("@reduxjs/toolkit");var ku={startTime:null,stopTime:null},Iu=(0,Ru.createSlice)({name:"handlingTime",initialState:ku,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(M,()=>ku)}}),{handlingTimeStart:Pu,handlingTimeStop:Er,handlingTimeReset:Au}=Iu.actions,Lu=Iu.reducer;var Mu=(t={})=>{let e={onAuthError:To(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var Rr=require("@reduxjs/toolkit");var kr={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var to=(0,Rr.createAsyncThunk)("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 kr.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),Oh=(0,Rr.createSlice)({name:"styleSuggestions",initialState:kr,reducers:{},extraReducers:t=>{t.addCase(to.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(to.rejected,e=>{e.fetchState="error"}).addCase(to.fulfilled,(e,o)=>{e.fetchState="done",mt(e.list,o.payload)||(e.list=o.payload)}).addCase(Nt,e=>{e.list=kr.list}).addCase(M,()=>kr)}}),Nu=Oh.reducer;var Ou=(t={})=>{let e,o=!0,n={getStyleSuggestions:to,debounce:500,...t};return s=>r=>i=>{var u;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(!((u=c.conversation.current)==null?void 0:u.id)||!p)return l;let{text:g}=c.input;return g===a&&!o||(clearTimeout(e),g==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:g}))},t.debounce)),l}};function Dh(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Du=(t={})=>{let e={getTextSuggestions:Le,getAutocompleteSuggestions:rn,debounce:200,check:Mo,...t},o;return n=>s=>r=>{var f;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:p}=l.settings,d=(f=l.conversation.current)==null?void 0:f.id,g=r.type===Ks.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:u}}=l;return Dh(u,i)&&!g||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let h=co(l);h===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(h))},g?0:e.debounce)),a}};var Hu=to.fulfilled.toString();function Hh(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 Bu=t=>e=>o=>n=>{var c;if(n.type!==Hu){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=Hh(s,i);n.type===Hu&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var Bh=(0,Ir.combineReducers)({activeSuggestion:Ac,answer:wp,auth:qc,autoflows:Md,conversation:Wa,contentTypes:ip,customMessages:zd,passwordlessToken:Wd,entities:pp,knowledgeAssistant:xp,handlingTime:Lu,info:sc,input:Kr.reducer,overlayInput:ae.reducer,settings:za,profile:kp,search:dc,summary:hp,styleSuggestions:Nu,ui:Dc,rules:Gc,textSuggestions:Tc});function Fu(t){return(0,Ir.configureStore)({reducer:Bh,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Mu(),Du({debounce:200}),Ou({debounce:500}),Bu(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Fh=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Kh=t=>e=>o=>n=>{var a;let s=e.getState(),r=Dr("inlineSuggestions")(s);switch(n.type){case Je.toString():{let l=Fs(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 To.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:Fh(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case ts.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 Wo.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case rs.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 Ne.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case ot.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 os.toString():t.handleKeyDown(n.payload);break;case Nt.toString():t.logSendMessage(n.payload);break;case ns.toString():t.logSendEditSuggestionMessage(n.payload);break;case ss.toString():t.handleInputChanged(n.payload);break;case et.fulfilled.toString():t.broadcast(wi,n.payload,!1),t.emit("cues",n.payload);break;default:break}let i=o(n);switch(n.type){case Nt.toString():t.handleAfterSendMessage(n.payload);break;case an.toString():t.onUpdateShowTabHint(n.payload);break;case Er.toString():t.logHandlingTime();break;case Ie.toString():{r&&(e.dispatch(Be([])),e.dispatch(We()));break}case Be.toString():{r&&n.payload.length>0&&e.dispatch(ht(0));break}default:break}return i},Ku=Kh;function ma(t){return t.toISOString().replace("T"," ").replace("Z","")}function Uu(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:ma(o),timeStop:ma(n)}}function fa(t,e,o){var O,K,H;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:d,cuts:g,deletions:u,textSuggestions:m,offeredTextSuggestions:f}}=e[t],h=n.length,x=m.reduce((W,{text:z,searchTerm:R})=>W+z.length-(R?R.length:0),0),_=c??Date.now(),b=(Date.now()-_)/1e3+(p||0),v=s/b,A=m.reduce((W,{searchTerm:z})=>W+(z?z.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:d,cuts:g,deletions:u,lenTextTyped:s+A,lenTextTotal:h,lenTextAssisted:x,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:b,charsPerSecond:v,numPastes:l,textSuggestionsV2:m,suggestionsCounters:[{source:"gpt",countOffered:f.filter(W=>W.source==="gpt").length}],agentId:(O=e.info.agentInfo)==null?void 0:O.agentId,agentName:(K=e.info.agentInfo)==null?void 0:K.agentName,agentEmail:(H=e.info.agentInfo)==null?void 0:H.agentEmail}}function ha(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return ha(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?ha(s,e):null}function zu(t,e){return ha(t,e)}function ju(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Uh(t){return typeof t=="object"&&t!==null&&"tagName"in t}function Pr(t){return Uh(t)&&(Tt(t)||bs(t))}var Vu=(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{w.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function zh(t){return t.offsetParent!==null}function qu(t){if(!zh(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 Ar(t,e,o=100){let n=qu(t);e({isVisible:n});let s=setInterval(()=>{let r=qu(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var q=require("react/jsx-runtime");var Wu=Vu("showTabHint",!0),Mn=class t{static version="10.12.1-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 ut(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Ku({broadcast:(d,g,u)=>{this.broadcastEvents.send(d,g,u)},emit:(d,g,u)=>this.emit(d,g,u),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=>Wu.update(d),sendEvent:(d,g)=>this.deepdeskApi.sendEvent(d,g)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new Ln(o)}),this.store=Fu(p),this.broadcastEvents=new Eu({debug:!0,deepdeskUrl:c,eventMap:Xc(this.store),createCustomChannel:l}),this.store.dispatch(qo),this.store.dispatch(an(Wu.value())),this.store.dispatch(qo({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?(w.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(w.warn("Profile has not been loaded (yet)"),!0):(w.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(To(null)),this.store.dispatch(Ye()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ne(n)&&Fc(n)!=="loading"&&(o(),e())});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(Ye())).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){w.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(Br({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Xn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Zn({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Fr(e))).payload}async postMessages(e){return(await this.store.dispatch(Jn(e))).payload}async updateConversation(e){return(await this.store.dispatch(Qn(e))).payload}resetConversation(){this.store.dispatch(M()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(ot());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(qo(e))}setVisitorInfo(e){this.store.dispatch(nc(e))}async setAgentInfo(e){await this.store.dispatch(tn(e))}async setAgentSettings(e){await this.store.dispatch(hi(e))}async getAgentSettings(){return(await this.store.dispatch(yi())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(Ks()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(ss(e))}notifyKeyDown(e){this.store.dispatch(os(e))}notifyPaste(e,o){this.store.dispatch(rl({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(nl(e))}notifyExternalSuggestion(e){this.store.dispatch(Ie(e)),this.store.dispatch(We())}notifyEditSuggestion(e){this.store.dispatch(Cc(e.contentType,e.suggestions)),this.store.dispatch(Je({contentType:e.contentType,suggestion:typeof e.index=="number"?e.suggestions[e.index]:null}))}async evaluateRule(e,o={}){let{payload:n,error:s}=await this.store.dispatch(et({label:e,params:o}));if(s)throw s;return n}handleInputChanged(e){let{overlayCollapsed:o,openOverlayWhenTyping:n}=this.state.ui;o&&n&&this.store.dispatch(xt({collapse:!1})),this.inputMediator&&this.store.dispatch(Qa({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Be([])))}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(sl(es(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(el()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{o||!a||i&&s<=0||r&&(e.shiftKey||(this.store.dispatch(ol()),e.preventDefault(),!i&&(this.state.input.selectedSuggestionIndex===-1?this.store.dispatch(Wo()):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(ht(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(ht(-1)),this.store.dispatch(Wo()),e.preventDefault()):o||(this.store.dispatch(xt({collapse:!0})),this.store.dispatch(Nc(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:d}=this.state.input,g=d.text.substring(0,d.selection.end),{tabCompletionSuggestion:u}=this.state.input;this.store.dispatch(an(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&u&&u.text.startsWith(g)&&(this.store.dispatch(Ie({text:u.text,suggestion:u,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(We())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(il()),this.store.dispatch(Be([]))}handlingTimeStart(){this.state.handlingTime.startTime||(w.info("Start handling time"),this.store.dispatch(Pu()))}handlingTimeStop(){this.state.handlingTime.startTime&&(w.info("Stop handling time"),this.store.dispatch(Er()))}logSendMessage(e){let o=fa("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=fa("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(Ya(this.state.overlayInput.metrics))}logHandlingTime(){let e=Uu(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Au())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(We()),this.store.dispatch(Nt(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){w.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),w.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=Ht(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,Te.unmountComponentAtNode)(r),i(),r.remove()}),r}createInlineContainer(e,o){var i;let n=document.createElement("div");n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.style.height="0px",n.style.width="0px";let s=document.createElement("div");s.style.display="none",s.style.position="absolute",s.style.height="0px",s.style.width="0px",s.style.backgroundColor="red",n.appendChild(s);let r=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;if(r){let[a,l]=Ht(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{(0,Te.unmountComponentAtNode)(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Dt(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(()=>{(0,Te.unmountComponentAtNode)(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),w.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()?(w.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(ll(n.metrics))):w.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(!Pr(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:g,insertLink:u,inputMediator:m,closestScrollSelector:f,appendOverlayTo:h,inlineSuggestions:E,floatingMenu:x}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:u,isEmbedded:d,inlineSuggestions:E,floatingMenu:!!x}),o.automaticHandlingTime&&this.setupHandlingTime(e),Dt(e),this.inputMediator=m||(Tt(e)?new Xe(e):new eo(e)),this.inputMediator.on("change",({plainText:v})=>{this.notifyInputChanged(v)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(al({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",v=>{this.notifyKeyDown(v)}),this.inputMediator.on("paste",({pastedText:v,selectionText:A})=>{this.notifyPaste(v,A)}),this.inputMediator.on("cut",({selectionText:v})=>{this.notifyCut(v)});let _=f&&zu(e,f)||void 0;if(E){let{customStyles:v,appendOverlayTo:A}=o;if(Tt(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let O=this.createInlineContainer(e,"deepdesk-caret");(0,Te.render)((0,q.jsx)(Jt,{store:this.store,customStyles:v,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(Xp,{})})}),O),this.inputMediator.on("caret",H=>{this.store.dispatch(Be([])),H?(O.style.display="block",O.style.top=`${H.top}px`,O.style.left=`${H.left}px`):O.style.display="none"});let K=this.overlayContainerFactory("floating-menu",_||e,{appendTo:typeof x=="object"&&"appendOverlayTo"in x?x.appendOverlayTo:A},v==null?void 0:v.floatingMenuRootNode);(0,Te.render)((0,q.jsx)(Jt,{store:this.store,customStyles:v,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(zp,{onLogIn:()=>this.loginViaPopup().catch(H=>w.warn(H.message))})})}),K)}else{let v=this.overlayContainerFactory("deepdesk-tab-completion",_||e,{appendTo:h,closestScrollElement:_,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),A=this.overlayContainerFactory("deepdesk-suggestions-overlay",_||e,{appendTo:h},n==null?void 0:n.suggestionsRootNode);(0,Te.render)((0,q.jsx)(Jt,{store:this.store,customStyles:n,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(kd,{inputElement:e})})}),v),(0,Te.render)((0,q.jsx)(Jt,{store:this.store,customStyles:n,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(rd,{onLogIn:()=>this.loginViaPopup().catch(O=>w.warn(O.message))})})}),A)}(0,Te.render)((0,q.jsx)(Jt,{store:this.store,customStyles:n,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(Op,{})})}),this.createContainer("deepdesk-overlays"));let b;this.inputMediator.on("selection",v=>{clearTimeout(b),v===null?b=setTimeout(()=>{v!==null&&this.store.dispatch(Ur(v))},500):this.store.dispatch(Ur(v))}),this.inputMediator.on("disabled",()=>{var v;(v=this.inputMediator)==null||v.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{g&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(Co(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(Co(!0))),this.store.dispatch(Ja({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(We()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var v;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((v=this.state.conversation.current)==null?void 0:v.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&&w.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}),(0,Te.render)((0,q.jsx)(Jt,{store:this.store,customStyles:n,children:(0,q.jsx)(Wt,{broadcastEvents:this.broadcastEvents,children:(0,q.jsx)(bu,{onLogIn:()=>this.loginViaPopup().catch(i=>w.warn(i.message))})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setSessionId((i=this.state.conversation.current)==null?void 0:i.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Te.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=Ar(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){ju(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(Sn());let e=Ct(this.state);e&&(await this.store.dispatch(hn()),this.store.dispatch(qo({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:!!e.knowledgeAssistant,recommendTextSuggestions:e.recommendTextSuggestions})))}),this.loadProfileConfigPromise)}async loginViaPopup(e){return new Promise((o,n)=>{let s=new MessageChannel,r=s.port1,i=this.state.settings.adminUrl,a=new URL(e!=null&&e.url?e==null?void 0:e.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,c=()=>{p&&!p.closed&&p.close(),window.removeEventListener("message",d),clearInterval(g)};r.onmessage=async u=>{var m,f;if((m=u.data)!=null&&m.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((f=u.data)==null?void 0:f.jwt),await this.isLoggedIn(),this.broadcastEvents.send(pn),l=!0,s.port1.close(),o()}catch(h){console.error(h),n(h)}finally{l=!0,c()}};let p=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");p===null&&n(new Error("Popup blocked by browser"));let d=async u=>{var m;if(u.origin===a.origin)switch((m=u.data)==null?void 0:m.type){case"deepdesk-popup-loaded":{try{let f=JSON.stringify({type:"deepdesk-popup-create-channel"});p==null||p.postMessage(f,a.origin,[s.port2])}catch(f){w.error("Error posting message to popup",f),n(f)}break}case"deepdesk-popup-error":{c(),u.data.message==="Timeout"&&w.warn("Popup timed out. Check if the account's platform url is configured correctly."),n(new Error(u.data.message));break}}};window.addEventListener("message",d);let g=setInterval(()=>{p&&!p.closed||(c(),l||n(new Error("Popup closed by user")))},200);this.unmountHandlers.push(c)})}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(w.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;w.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=Qs(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Ne()):this.store.dispatch(Le(n))})}catch(n){this.handleError(n)}}};async function $u(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 Gu(t,e,o={}){let n=o.replace?Pt(t,o.replace.start,o.replace.end):Ho(t),s,r=()=>{if(o.setRange)return o.setRange(n.cloneRange());n.deleteContents(),s=document.createElement("span"),n.insertNode(s),o.insertBRs!==!1?e.split(`
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?Pt(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 jh(t){let e=document.createElement("template");return e.innerHTML=t.replace(/(\[([^\]]+)])\(([^)]+)\)/g,'<a href="$3" target="_blank" rel="noopener noreferrer">$2</a>'),e.content}function Vh(t){let e=document.createDocumentFragment();return t.split(`
11
+ `).forEach((o,n)=>{n>0&&e.appendChild(document.createElement("br"));let s={index:0},r=0;for(;s=o.slice(r).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=s[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(s[2])),e.appendChild(document.createTextNode(o.slice(r,r+s.index))),e.appendChild(i),r=r+s.index+s[0].length}e.appendChild(document.createTextNode(o.slice(r)))}),e}function Xu(t,e){return!t.contains(e)||e===t?null:e.parentNode===t?e:Xu(t,e.parentNode)}async function Zu(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?jh(e):Vh(e);if(o){let p=l.startContainer===t?t.childNodes[l.startOffset]:l.startContainer,d=Xu(t,p)??t.firstChild;t.insertBefore(c,(d==null?void 0:d.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 Qu(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function Ju(t,e,o){await new ut(t).authenticateWithKey(e,o)}async function Yu(t){let o=await new De(t).get("/platform/config/",{version:null});return N(o)}async function qh(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 eg(t,e){let o=await qh(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}}0&&(module.exports={Card,ContentEditableInput,DeepdeskAPI,DeepdeskSDK,HTTPClient,InputMediator,InputType,KeyboardHint,Label,Locale,Section,SectionList,Sources,Suggestion,SuggestionList,TextAreaInput,ToggleButton,attachFile,authenticateWithKey,createFullRange,createOverlayContainer,createRangeFromOffsets,escapeHTML,fetchPlatformConfig,formatTextMarkup,getRangeOffsets,getRangeText,insertCKEditor,isHTML,isSupportedInputElement,updateContentEditable,updateTextArea,useStyles,waitForElementVisibilityChange});