@deepdesk/deepdesk-sdk 10.12.1-beta.9 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,11 +1,11 @@
1
- "use strict";var cu=Object.create;var fn=Object.defineProperty;var du=Object.getOwnPropertyDescriptor;var pu=Object.getOwnPropertyNames;var uu=Object.getPrototypeOf,gu=Object.prototype.hasOwnProperty;var Y=(t,e)=>{for(var o in e)fn(t,o,{get:e[o],enumerable:!0})},Mi=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of pu(e))!gu.call(t,s)&&s!==o&&fn(t,s,{get:()=>e[s],enumerable:!(n=du(e,s))||n.enumerable});return t};var E=(t,e,o)=>(o=t!=null?cu(uu(t)):{},Mi(e||!t||!t.__esModule?fn(o,"default",{value:t,enumerable:!0}):o,t)),mu=t=>Mi(fn({},"__esModule",{value:!0}),t);var Mf={};Y(Mf,{Card:()=>D,ContentEditableInput:()=>Kt,DeepdeskAPI:()=>st,DeepdeskSDK:()=>mn,HTTPClient:()=>Re,InputMediator:()=>nt,InputType:()=>wt,KeyboardHint:()=>Sn,Label:()=>_n,Locale:()=>To,Section:()=>Be,SectionList:()=>xn,Sources:()=>Ke,Suggestion:()=>L,SuggestionList:()=>ae,TextAreaInput:()=>Ut,ToggleButton:()=>bt,attachFile:()=>iu,authenticateWithKey:()=>su,createFullRange:()=>ho,createOverlayContainer:()=>gn,createRangeFromOffsets:()=>St,escapeHTML:()=>to,fetchPlatformConfig:()=>ru,formatTextMarkup:()=>nu,getRangeOffsets:()=>cn,getRangeText:()=>dn,insertCKEditor:()=>ou,isHTML:()=>rs,isSupportedInputElement:()=>tr,updateContentEditable:()=>eu,updateTextArea:()=>Yp,useStyles:()=>h,waitForElementVisibilityChange:()=>sr});module.exports=mu(Mf);var vn=E(require("classnames")),ie=E(require("react"));var hn=E(require("react")),Oi=E(require("classnames")),_o=hn.default.createContext({});function h(t,e){let{debug:o,...n}=(0,hn.useContext)(_o),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,Oi.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var xo=require("react/jsx-runtime"),Ni=({className:t})=>(0,xo.jsxs)("svg",{viewBox:"0 0 12 12",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,xo.jsx)("line",{x1:"1",y1:"11",x2:"11",y2:"1",stroke:"black",strokeWidth:"2"}),(0,xo.jsx)("line",{x1:"1",y1:"1",x2:"11",y2:"11",stroke:"black",strokeWidth:"2"})]});var Di={root:"_root_vr71j_1"};var xt=require("react/jsx-runtime"),yn=()=>(0,xt.jsxs)("svg",{className:Di.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,xt.jsx)("defs",{children:(0,xt.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,xt.jsx)("title",{children:"Failed loading image"}),(0,xt.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 ar={root:"_root_15d2a_1",imageWrapper:"_imageWrapper_15d2a_7",image:"_image_15d2a_7",content:"_content_15d2a_24",title:"_title_15d2a_35",contentIsCropped:"_contentIsCropped_15d2a_45",lineClamp:"_lineClamp_15d2a_51",closeIcon:"_closeIcon_15d2a_58"};var Fe=require("react/jsx-runtime"),bo=(0,ie.createContext)(ar),fu=({title:t,src:e})=>{let o=(0,ie.useContext)(bo),[n,s]=(0,ie.useState)(!1);return(0,ie.useEffect)(()=>{s(!1)},[e]),(0,Fe.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,Fe.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,Fe.jsx)(yn,{})})},hu=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,ie.useContext)(bo);return(0,Fe.jsx)("div",{className:(0,vn.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},yu=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,ie.useContext)(bo);return ie.default.createElement(t,{className:(0,vn.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},vu=({className:t,title:e,...o})=>{let n=(0,ie.useContext)(bo);return(0,Fe.jsx)("div",{className:(0,vn.default)(n.closeIcon,t),title:e,role:"button","aria-label":e,...o,children:(0,Fe.jsx)(Ni,{})})},wo=({children:t})=>{let e=h("Card",ar);return(0,Fe.jsx)("div",{className:e.root,children:(0,Fe.jsx)(bo.Provider,{value:e,children:t})})};wo.Image=fu;wo.Content=hu;wo.Title=yu;wo.CloseIcon=vu;var D=wo;var Fi=E(require("classnames"));var Hi={root:"_root_cq1yq_1"};var Bi=require("react/jsx-runtime");var Su={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},_u=({className:t,keyCode:e,...o})=>{let n=h("KeyboardHint",Hi);return(0,Bi.jsx)("span",{"data-key":Su[e],className:(0,Fi.default)(t,n.root),...o})},Sn=_u;var Ui=E(require("classnames"));var Ki={root:"_root_4a08n_1"};var zi=require("react/jsx-runtime"),xu=({className:t,children:e,...o})=>{let n=h("Label",Ki);return(0,zi.jsx)("span",{...o,className:(0,Ui.default)(t,n.root),children:e})},_n=xu;var ji={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var Vt=require("react/jsx-runtime"),bu=({title:t,children:e,type:o,...n})=>{let s=h("Section",ji);return(0,Vt.jsxs)("section",{...n,className:s.root,"data-section-type":o,children:[t&&(0,Vt.jsx)("div",{className:s.subTitleContainer,children:(0,Vt.jsx)("span",{className:s.subtitle,children:t})}),(0,Vt.jsx)("div",{className:s.suggestions,children:e})]})},Be=bu;var qi=E(require("classnames")),$i=E(require("react"));var Vi={root:"_root_19wxp_1"};var Wi=require("react/jsx-runtime"),wu=$i.default.forwardRef(({className:t,children:e},o)=>{let n=h("SectionList",Vi);return(0,Wi.jsx)("div",{ref:o,className:(0,qi.default)(n.root,t),children:e})}),xn=wu;var Co=E(require("classnames")),me=E(require("react"));var lr={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 ge=require("react/jsx-runtime"),qt=(0,me.createContext)(lr),Cu=({fixed:t,children:e,...o})=>{let n=(0,me.useContext)(qt);return(0,ge.jsx)("div",{...o,className:(0,Co.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},Tu=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,me.useContext)(qt);return(0,ge.jsxs)("div",{className:(0,Co.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,(0,ge.jsx)("ul",{className:r.dropdownList,children:s})]})},Eu=({index:t,label:e,onClick:o})=>{let n=(0,me.useContext)(qt);return(0,ge.jsx)("li",{className:n.dropdownItem,children:(0,ge.jsx)("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},ku=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,me.useContext)(qt);return(0,ge.jsx)("button",{type:"button",className:(0,Co.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},Iu=({labels:t})=>{let e=(0,me.useContext)(qt);return(0,ge.jsx)("div",{className:e.labels,children:t.map(o=>(0,ge.jsx)("span",{className:e.label,children:o},o))})},$t=me.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=h("Suggestion",lr),l=(0,me.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,ge.jsx)(s,{...r,ref:i,className:(0,Co.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,ge.jsx)(qt.Provider,{value:a,children:n})})});$t.Labels=Iu;$t.Actions=Cu;$t.ActionButton=ku;$t.DropdownButton=Tu;$t.DropdownItem=Eu;var L=$t;var Xi=E(require("classnames"));var Gi={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var Zi=require("react/jsx-runtime"),Ru=({withDivider:t,children:e})=>{let o=h("SuggestionList",Gi);return(0,Zi.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,Xi.default)(o.root,{[o.isWithDivider]:t}),children:e})},ae=Ru;var Ji=E(require("classnames"));var Qi={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var bn=require("react/jsx-runtime"),Pu=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=h("ToggleButton",Qi);return(0,bn.jsx)("button",{type:"button",className:(0,Ji.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,bn.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,bn.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},bt=Pu;var Yi=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,wn=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var ea=/x-deepdesk-(([a-z0-9\-_])+-version)/,Ke=(m=>(m.SEARCH="search",m.TEMPLATE="template",m.ELASTIC_SEARCH="search-autocomplete",m.GPT="gpt",m.TRIE="trie",m.TRIE_WITH_TYPOS="trie-with-typos",m.SEMANTIC="semantic",m.TEXT_RECOMMENDATION="text_recommendation",m.URL_RECOMMENDATION="url_recommendation",m.LINK_RECOMMENDATION="link_recommendation",m.PERSONAL_COLLECTION="personal-collection",m.PERSONAL_COLLECTION_SEARCH="personal-collection-search",m.SEARCH_OVERLAY="search-overlay",m.SEARCH_PREVIEW="search-preview",m.SEARCH_URL="search-url",m))(Ke||{}),wt=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(wt||{});var Se=require("react-dom");var yc=require("react");var ta=require("@reduxjs/toolkit"),oa=require("react-redux");var To=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(To||{});var Au={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,inlineSuggestions:!1,floatingMenu:!1,adminUrl:void 0,productName:"Deepdesk"},na=(0,ta.createSlice)({name:"settings",initialState:Au,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:Cn}=na.actions,cr=t=>e=>e.settings[t],b=t=>(0,oa.useSelector)(cr(t)),sa=na.reducer;var Pr=require("react-redux");var Wt=require("@reduxjs/toolkit");var Lu={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ee=t=>t.auth.isLoggedIn,ra=t=>t.auth.loginFetchState,ia=t=>t.auth.verifyFetchState,aa=t=>t.auth.showLoginOverlay,Ue=(0,Wt.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),la=(0,Wt.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),Eo=(0,Wt.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),ca=(0,Wt.createSlice)({name:"auth",initialState:Lu,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(Ue.pending,e=>{e.loginFetchState="loading"}),t.addCase(Ue.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(Ue.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(Eo.pending,e=>{e.verifyFetchState="loading"}),t.addCase(Eo.rejected,e=>{e.verifyFetchState="error"}),t.addCase(Eo.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Gt,setShowLoginOverlay:da}=ca.actions,pa=ca.reducer;var ze=require("@reduxjs/toolkit"),ha=require("diff"),ya=require("react-redux");function ua(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function rt(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)=>rt(r,e[i],o-1)):ua(t)&&ua(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>rt(t[i],e[i],o-1)):!1}function Mu(t){return Math.max(...t.map(e=>e.length))}function Ou(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 ga(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Mu(n);s++){let r=Ou(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 Nu=2;function dr(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=ga(t,Nu);return o&&o.text!==e?o:t[0]}var _e=require("@reduxjs/toolkit");var Du={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},C=Du;var ma={current:null,isSupported:null},O=(0,_e.createAction)("resetConversation"),Tn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},En=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Xt=t=>t.conversation.isSupported,pr=(0,_e.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),kn=(0,_e.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),In=(0,_e.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Rn=(0,_e.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=En(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),ur=(0,_e.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})})}),Pn=(0,_e.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=En(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Hu=[kn.rejected,In.rejected,Rn.rejected,Pn.rejected].map(t=>t==null?void 0:t.toString()),Fu=(0,_e.createSlice)({name:"conversation",initialState:ma,reducers:{},extraReducers:t=>{t.addCase(pr.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(kn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(In.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(ur.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Rn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Pn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(O,()=>ma).addMatcher(e=>Hu.includes(e.type),(e,o)=>{var n;throw C.info("Conversation action rejected",o.type,((n=o.error)==null?void 0:n.message)||"No message"),new Error(o.error.message)})}}),fa=Fu.reducer;var it={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 va(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 Ln=(0,ze.createAction)("input/replaceText"),Mn=(0,ze.createAction)("input/keyDown"),Ct=(0,ze.createAction)("input/sendMessage"),On=(0,ze.createAction)("input/uiInputChange"),Nn=(0,ze.createAction)("input/applyImageSuggestion"),Q=(0,ze.createAction)("input/sendEvent");function An(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:d}=t.stagedSuggestion,p=o==="search"||o==="personal-collection-search",g=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(p||d==="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:p?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var Sa=(0,ze.createSlice)({name:"input",initialState:it,reducers:{initialInput(t,e){let{text:o,selection:n,html:s}=e.payload;t.text=o,t.selection.start=(n==null?void 0:n.start)??o.length,t.selection.end=(n==null?void 0:n.end)??o.length,t.userCommitted.text=o,t.userCommitted.selection.start=(n==null?void 0:n.start)??o.length,t.userCommitted.selection.end=(n==null?void 0:n.end)??o.length,t.html=s||null},reset(t){Object.assign(t,{...it,selection:t.selection})},resetToCommitted(t){t.text=t.userCommitted.text,t.selection=t.userCommitted.selection,t.stagedSuggestion=null,t.tabCompletionSuggestion=dr(t.textSuggestions,t.userCommitted.text)},changeSelection(t,e){e.payload&&(rt(t.selection,e.payload)||(t.selection=e.payload,t.userCommitted.selection=t.selection,t.stagedSuggestion&&An(t)))},platformInput(t,e){let{text:o,html:n,selection:s}=e.payload;s&&(t.selection.start=s.start,t.selection.end=s.end),t.text=o,t.html=n||null},userInput(t,e){var r,i,a,l;if(t.previousKeyDownEvent){let{key:c,shiftKey:d,ctrlKey:p,metaKey:g,altKey:u}=t.previousKeyDownEvent;switch(c){case"Enter":d&&(t.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:f}=t,{text:m}=e.payload,v=(0,ha.diffChars)(f,m);f.length-m.length>1&&t.metrics.deletions.push(...v.filter(T=>T.removed).map(T=>T.value)),t.metrics.numCharsDeleted+=f.length-m.length;break}case"C":case"V":case"X":if(!p&&!g){t.metrics.numCharsTyped+=1;let f=((r=t.selection)==null?void 0:r.start)!==void 0&&((i=t.selection)==null?void 0:i.end)!==void 0?t.text.substring(t.selection.start,t.selection.end):null;f&&f.length>0&&(t.metrics.numCharsDeleted+=f.length,t.metrics.deletions.push(f))}break;case"Shift":break;default:if(!p&&!g&&!u){t.metrics.numCharsTyped+=1;let f=((a=t.selection)==null?void 0:a.start)!==void 0&&((l=t.selection)==null?void 0:l.end)!==void 0?t.text.substring(t.selection.start,t.selection.end):null;f&&f.length>0&&(t.metrics.numCharsDeleted+=f.length,t.metrics.deletions.push(f))}}}!t.metrics.agentStartedTypingTimestamp&&e.payload.text!==t.text&&(t.metrics.agentStartedTypingTimestamp=Date.now()),e.payload.text===""&&(t.metrics=it.metrics,t.textSuggestions=[],t.stagedSuggestion=null),t.text!==e.payload.text&&An(t);let{text:o,html:n,selection:s}=e.payload;s&&(t.selection.start=s.start,t.selection.end=s.end,t.userCommitted.selection.start=s.start,t.userCommitted.selection.end=s.end),t.text=o,t.html=n||null,t.userCommitted.text=o,t.previousKeyDownEvent=null},stageSuggestion(t,e){let{text:o}=e.payload;switch(t.stagedSuggestion=e.payload,t.tabCompletionSuggestion=void 0,e.payload.replace){case"selection":t.text=`${t.text.slice(0,t.selection.start)}${o}${t.text.slice(t.selection.end)}`,t.selection.end=t.selection.start+o.length,t.selection.start+=o.length;break;case"until-selection-end":t.text=`${o}${t.text.slice(t.selection.end)}`,t.selection.start=o.length,t.selection.end=o.length;break;default:throw new Error(`Unknown replace ${e.payload.replace}`)}e.payload.eventMetrics.inputType==="tab"&&An(t)},commitSuggestion(t){An(t)},offeredTextSuggestion(t,e){let{text:o,suggestion:{source:n}}=e.payload;t.metrics.offeredTextSuggestions.find(r=>r.text===o)||t.metrics.offeredTextSuggestions.push({text:o,source:n})},registerCut(t,e){let{metrics:o}=t,n=e.payload;t.metrics={...t.metrics,numCharsCut:o.numCharsCut+n.length,cuts:[...o.cuts,n]}},registerPaste(t,e){let{metrics:o}=t,{text:n,selectionText:s}=e.payload,r=o.numCharsDeleted+(s&&s.length?s.length:0),i=s&&s.length?[...o.deletions,s]:o.deletions;t.metrics={...t.metrics,numCharsDeleted:r,deletions:i,numCharsPasted:o.numCharsPasted+n.length,numPaste:o.numPaste+1,pastes:[...o.pastes,n]}},registerKeyDown(t,e){t.previousKeyDownEvent=e.payload},nextTextSuggestionIndex(t){let e=t.textSuggestions.length;t.selectedSuggestionIndex=t.selectedSuggestionIndex<e-1?t.selectedSuggestionIndex+1:t.selectedSuggestionIndex},previousTextSuggestionIndex(t){t.selectedSuggestionIndex=t.selectedSuggestionIndex>=0?t.selectedSuggestionIndex-1:t.selectedSuggestionIndex},setTextSuggestions(t,e){if(t.selectedSuggestionIndex=-1,t.textSuggestions=e.payload,e.payload.length===0)return;let o=t.userCommitted.text.substring(0,t.userCommitted.selection.end),n=dr(e.payload,o);t.tabCompletionSuggestion=n!=null&&n.text.includes(o)?n:void 0},setSelectedTextSuggestionIndex(t,e){t.selectedSuggestionIndex=e.payload},setMetrics(t,{payload:e}){t.metrics=e}},extraReducers:t=>{t.addCase(O,e=>{e.tabCompletionSuggestion=it.tabCompletionSuggestion,e.previousKeyDownEvent=it.previousKeyDownEvent,e.textSuggestions=it.textSuggestions,e.selectedSuggestionIndex=it.selectedSuggestionIndex,e.metrics=it.metrics})}}),Zt=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),Bu=t=>t.input.selection,_a=()=>(0,ya.useSelector)(Bu),{userInput:xa,changeSelection:gr,initialInput:ba,nextTextSuggestionIndex:wa,offeredTextSuggestion:Ca,previousTextSuggestionIndex:Ta,registerCut:Ea,registerKeyDown:ka,registerPaste:Ia,reset:Ra,resetToCommitted:ko,platformInput:Pa,setSelectedTextSuggestionIndex:at,setTextSuggestions:Pe,stageSuggestion:xe,commitSuggestion:je,setMetrics:Aa}=Sa.actions,La=Sa.reducer;var Hn=require("@reduxjs/toolkit");var Qt=require("@reduxjs/toolkit");function Ku(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function A(t){return Array.isArray(t)?t.map(A):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Ku(o)]:A(t[o])}),{}):t}function mr(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function q(t){return Array.isArray(t)?t.map(q):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[mr(o)]:q(t[o])}),{}):t}var Uu={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Ro=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)||""}},Io=(0,Qt.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?A(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),A(n))}),fr=(0,Qt.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}),hr=(0,Qt.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),Ma=t=>t.info.agentInfo,Oa=(0,Qt.createSlice)({name:"info",initialState:Uu,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Io.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Io.rejected,e=>{e.fetchState="error"}).addCase(Io.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(fr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(hr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(O,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Na}=Oa.actions,Da=Oa.reducer;var Dn={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},Ha=t=>t.search.isOpen,Fa=t=>t.search.page,Ba=t=>t.search.list,Ka=t=>t.search.aggregates;function Ua(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Tt=(0,Hn.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:Ro(n)});return{results:r.map(l=>({...l,source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:i}}),za=(0,Hn.createSlice)({name:"search",initialState:Dn,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=Dn.fetchState,t.list=Dn.list}},extraReducers:t=>{t.addCase(Tt.pending,e=>{e.fetchState="loading"}).addCase(Tt.rejected,(e,o)=>{e.fetchState="error",C.error(o.error)}).addCase(Tt.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload.results,e.aggregates=o.payload.aggregates||{}}).addCase(O,()=>Dn)}}),{resetSearch:Fn,setIsOpen:le,setPage:be}=za.actions,ja=za.reducer;var Jt=require("@reduxjs/toolkit");var yr={cues:[],fetchState:"idle"},Va=t=>{var e;return(e=t.rules)==null?void 0:e.cues},zu=(0,Jt.createAction)("rules/resetCues"),Ve=(0,Jt.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)}),qa=(0,Jt.createSlice)({name:"answer",initialState:yr,reducers:{removeCue(t,e){t.cues=t.cues.filter(o=>o.id!==e.payload.id)}},extraReducers:t=>{t.addCase(Ve.pending,e=>{e.fetchState="loading"}).addCase(Ve.rejected,e=>{e.fetchState="error"}).addCase(Ve.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(O,()=>yr).addCase(zu.toString(),()=>yr)}}),{removeCue:$a}=qa.actions,Wa=qa.reducer;var vr="SetCues",Yt="ShowLoginOverlay",Po="UserLoggedIn",ju="UserLoggedOut",eo="ApplySuggestion",Sr="ApplyImageSuggestion",Vu="ShowCommandPalette",qu=t=>({[vr]:e=>{t.dispatch({type:Ve.fulfilled,payload:e})},[Vu]:e=>{t.dispatch(le(e.isOpen)),e.page&&t.dispatch(be(e.page))},[Yt]:e=>{t.dispatch(da(e))},[Po]:()=>{t.dispatch(Ue())},[ju]:()=>{t.dispatch(Ue())},[Sr]:e=>{t.dispatch(Nn({suggestion:e.suggestion}))},[eo]:e=>{t.dispatch(xe({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(je())}}),Ga=qu;var Ao=E(require("react")),Za=require("react/jsx-runtime"),Xa=Ao.default.createContext(null),Et=({broadcastEvents:t,children:e})=>{let o=Ao.default.useMemo(()=>t,[]);return(0,Za.jsx)(Xa.Provider,{value:o,children:e})},Ae=()=>{let t=(0,Ao.useContext)(Xa);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var ts=E(require("classnames")),Ce=require("react"),os=require("react-redux");var Jn=require("react");var _r=function(t,e){return _r=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])},_r(t,e)};function Lo(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");_r(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var ce=function(){return ce=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},ce.apply(this,arguments)};function Qa(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 Bn(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 Kn;(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"})(Kn||(Kn={}));var Un=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var we;(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"})(we||(we={}));var zn;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(zn||(zn={}));function xr(t){return t.type===we.literal}function Ja(t){return t.type===we.argument}function jn(t){return t.type===we.number}function Vn(t){return t.type===we.date}function qn(t){return t.type===we.time}function $n(t){return t.type===we.select}function Wn(t){return t.type===we.plural}function Ya(t){return t.type===we.pound}function Gn(t){return t.type===we.tag}function Xn(t){return!!(t&&typeof t=="object"&&t.type===zn.number)}function Mo(t){return!!(t&&typeof t=="object"&&t.type===zn.dateTime)}function br(t){t.forEach(function(e){if(delete e.location,$n(e)||Wn(e))for(var o in e.options)delete e.options[o].location,br(e.options[o].value);else jn(e)&&Xn(e.style)||(Vn(e)||qn(e))&&Mo(e.style)?delete e.style.location:Gn(e)&&br(e.children)})}function el(t,e){e===void 0&&(e={}),e=ce({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new Un(t,e).parse();if(o.err){var n=SyntaxError(Kn[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||br(o.val),o.val}function Zn(t,e){var o=e&&e.cache?e.cache:Qu,n=e&&e.serializer?e.serializer:Zu,s=e&&e.strategy?e.strategy:Wu;return s(t,{cache:o,serializer:n})}function $u(t){return t==null||typeof t=="number"||typeof t=="boolean"}function tl(t,e,o,n){var s=$u(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function ol(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 wr(t,e,o,n,s){return o.bind(e,t,n,s)}function Wu(t,e){var o=t.length===1?tl:ol;return wr(t,this,o,e.cache.create(),e.serializer)}function Gu(t,e){return wr(t,this,ol,e.cache.create(),e.serializer)}function Xu(t,e){return wr(t,this,tl,e.cache.create(),e.serializer)}var Zu=function(){return JSON.stringify(arguments)};function Cr(){this.cache=Object.create(null)}Cr.prototype.get=function(t){return this.cache[t]};Cr.prototype.set=function(t,e){this.cache[t]=e};var Qu={create:function(){return new Cr}},Qn={variadic:Gu,monadic:Xu};var kt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(kt||(kt={}));var Oo=function(t){Lo(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 Tr=function(t){Lo(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('", "'),'"'),kt.INVALID_VALUE,r)||this}return e}(Oo);var nl=function(t){Lo(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),kt.INVALID_VALUE,s)||this}return e}(Oo);var sl=function(t){Lo(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,'"'),kt.MISSING_VALUE,n)||this}return e}(Oo);var J;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(J||(J={}));function Ju(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 Yu(t){return typeof t=="function"}function No(t,e,o,n,s,r,i){if(t.length===1&&xr(t[0]))return[{type:J.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var d=c[l];if(xr(d)){a.push({type:J.literal,value:d.value});continue}if(Ya(d)){typeof r=="number"&&a.push({type:J.literal,value:o.getNumberFormat(e).format(r)});continue}var p=d.value;if(!(s&&p in s))throw new sl(p,i);var g=s[p];if(Ja(d)){(!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(Vn(d)){var u=typeof d.style=="string"?n.date[d.style]:Mo(d.style)?d.style.parsedOptions:void 0;a.push({type:J.literal,value:o.getDateTimeFormat(e,u).format(g)});continue}if(qn(d)){var u=typeof d.style=="string"?n.time[d.style]:Mo(d.style)?d.style.parsedOptions:n.time.medium;a.push({type:J.literal,value:o.getDateTimeFormat(e,u).format(g)});continue}if(jn(d)){var u=typeof d.style=="string"?n.number[d.style]:Xn(d.style)?d.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(Gn(d)){var f=d.children,m=d.value,v=s[m];if(!Yu(v))throw new nl(m,"function",i);var T=No(f,e,o,n,s,r),_=v(T.map(function(S){return S.value}));Array.isArray(_)||(_=[_]),a.push.apply(a,_.map(function(S){return{type:typeof S=="string"?J.literal:J.object,value:S}}))}if($n(d)){var y=d.options[g]||d.options.other;if(!y)throw new Tr(d.value,g,Object.keys(d.options),i);a.push.apply(a,No(y.value,e,o,n,s));continue}if(Wn(d)){var y=d.options["=".concat(g)];if(!y){if(!Intl.PluralRules)throw new Oo(`Intl.PluralRules is not available in this environment.
1
+ "use strict";var cu=Object.create;var fn=Object.defineProperty;var du=Object.getOwnPropertyDescriptor;var pu=Object.getOwnPropertyNames;var uu=Object.getPrototypeOf,gu=Object.prototype.hasOwnProperty;var Y=(t,e)=>{for(var o in e)fn(t,o,{get:e[o],enumerable:!0})},Mi=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of pu(e))!gu.call(t,s)&&s!==o&&fn(t,s,{get:()=>e[s],enumerable:!(n=du(e,s))||n.enumerable});return t};var E=(t,e,o)=>(o=t!=null?cu(uu(t)):{},Mi(e||!t||!t.__esModule?fn(o,"default",{value:t,enumerable:!0}):o,t)),mu=t=>Mi(fn({},"__esModule",{value:!0}),t);var Of={};Y(Of,{Card:()=>D,ContentEditableInput:()=>Kt,DeepdeskAPI:()=>st,DeepdeskSDK:()=>mn,HTTPClient:()=>Ie,InputMediator:()=>nt,InputType:()=>wt,KeyboardHint:()=>Sn,Label:()=>_n,Locale:()=>To,Section:()=>Be,SectionList:()=>xn,Sources:()=>Ke,Suggestion:()=>L,SuggestionList:()=>ae,TextAreaInput:()=>Ut,ToggleButton:()=>bt,attachFile:()=>iu,authenticateWithKey:()=>su,createFullRange:()=>ho,createOverlayContainer:()=>gn,createRangeFromOffsets:()=>St,escapeHTML:()=>to,fetchPlatformConfig:()=>ru,formatTextMarkup:()=>nu,getRangeOffsets:()=>cn,getRangeText:()=>dn,insertCKEditor:()=>ou,isHTML:()=>rs,isSupportedInputElement:()=>tr,updateContentEditable:()=>eu,updateTextArea:()=>Yp,useStyles:()=>h,waitForElementVisibilityChange:()=>sr});module.exports=mu(Of);var vn=E(require("classnames")),ie=E(require("react"));var hn=E(require("react")),Oi=E(require("classnames")),_o=hn.default.createContext({});function h(t,e){let{debug:o,...n}=(0,hn.useContext)(_o),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,Oi.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var xo=require("react/jsx-runtime"),Ni=({className:t})=>(0,xo.jsxs)("svg",{viewBox:"0 0 12 12",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,xo.jsx)("line",{x1:"1",y1:"11",x2:"11",y2:"1",stroke:"black",strokeWidth:"2"}),(0,xo.jsx)("line",{x1:"1",y1:"1",x2:"11",y2:"11",stroke:"black",strokeWidth:"2"})]});var Di={root:"_root_vr71j_1"};var xt=require("react/jsx-runtime"),yn=()=>(0,xt.jsxs)("svg",{className:Di.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,xt.jsx)("defs",{children:(0,xt.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,xt.jsx)("title",{children:"Failed loading image"}),(0,xt.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 ar={root:"_root_15d2a_1",imageWrapper:"_imageWrapper_15d2a_7",image:"_image_15d2a_7",content:"_content_15d2a_24",title:"_title_15d2a_35",contentIsCropped:"_contentIsCropped_15d2a_45",lineClamp:"_lineClamp_15d2a_51",closeIcon:"_closeIcon_15d2a_58"};var Fe=require("react/jsx-runtime"),bo=(0,ie.createContext)(ar),fu=({title:t,src:e})=>{let o=(0,ie.useContext)(bo),[n,s]=(0,ie.useState)(!1);return(0,ie.useEffect)(()=>{s(!1)},[e]),(0,Fe.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,Fe.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,Fe.jsx)(yn,{})})},hu=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,ie.useContext)(bo);return(0,Fe.jsx)("div",{className:(0,vn.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},yu=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,ie.useContext)(bo);return ie.default.createElement(t,{className:(0,vn.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},vu=({className:t,title:e,...o})=>{let n=(0,ie.useContext)(bo);return(0,Fe.jsx)("div",{className:(0,vn.default)(n.closeIcon,t),title:e,role:"button","aria-label":e,...o,children:(0,Fe.jsx)(Ni,{})})},wo=({children:t})=>{let e=h("Card",ar);return(0,Fe.jsx)("div",{className:e.root,children:(0,Fe.jsx)(bo.Provider,{value:e,children:t})})};wo.Image=fu;wo.Content=hu;wo.Title=yu;wo.CloseIcon=vu;var D=wo;var Fi=E(require("classnames"));var Hi={root:"_root_cq1yq_1"};var Bi=require("react/jsx-runtime");var Su={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},_u=({className:t,keyCode:e,...o})=>{let n=h("KeyboardHint",Hi);return(0,Bi.jsx)("span",{"data-key":Su[e],className:(0,Fi.default)(t,n.root),...o})},Sn=_u;var Ui=E(require("classnames"));var Ki={root:"_root_4a08n_1"};var zi=require("react/jsx-runtime"),xu=({className:t,children:e,...o})=>{let n=h("Label",Ki);return(0,zi.jsx)("span",{...o,className:(0,Ui.default)(t,n.root),children:e})},_n=xu;var qi={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var jt=require("react/jsx-runtime"),bu=({title:t,children:e,type:o,...n})=>{let s=h("Section",qi);return(0,jt.jsxs)("section",{...n,className:s.root,"data-section-type":o,children:[t&&(0,jt.jsx)("div",{className:s.subTitleContainer,children:(0,jt.jsx)("span",{className:s.subtitle,children:t})}),(0,jt.jsx)("div",{className:s.suggestions,children:e})]})},Be=bu;var Vi=E(require("classnames")),$i=E(require("react"));var ji={root:"_root_19wxp_1"};var Wi=require("react/jsx-runtime"),wu=$i.default.forwardRef(({className:t,children:e},o)=>{let n=h("SectionList",ji);return(0,Wi.jsx)("div",{ref:o,className:(0,Vi.default)(n.root,t),children:e})}),xn=wu;var Co=E(require("classnames")),me=E(require("react"));var lr={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 ge=require("react/jsx-runtime"),Vt=(0,me.createContext)(lr),Cu=({fixed:t,children:e,...o})=>{let n=(0,me.useContext)(Vt);return(0,ge.jsx)("div",{...o,className:(0,Co.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},Tu=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,me.useContext)(Vt);return(0,ge.jsxs)("div",{className:(0,Co.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,(0,ge.jsx)("ul",{className:r.dropdownList,children:s})]})},Eu=({index:t,label:e,onClick:o})=>{let n=(0,me.useContext)(Vt);return(0,ge.jsx)("li",{className:n.dropdownItem,children:(0,ge.jsx)("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},ku=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,me.useContext)(Vt);return(0,ge.jsx)("button",{type:"button",className:(0,Co.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},Ru=({labels:t})=>{let e=(0,me.useContext)(Vt);return(0,ge.jsx)("div",{className:e.labels,children:t.map(o=>(0,ge.jsx)("span",{className:e.label,children:o},o))})},$t=me.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=h("Suggestion",lr),l=(0,me.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,ge.jsx)(s,{...r,ref:i,className:(0,Co.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,ge.jsx)(Vt.Provider,{value:a,children:n})})});$t.Labels=Ru;$t.Actions=Cu;$t.ActionButton=ku;$t.DropdownButton=Tu;$t.DropdownItem=Eu;var L=$t;var Xi=E(require("classnames"));var Gi={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var Zi=require("react/jsx-runtime"),Iu=({withDivider:t,children:e})=>{let o=h("SuggestionList",Gi);return(0,Zi.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,Xi.default)(o.root,{[o.isWithDivider]:t}),children:e})},ae=Iu;var Ji=E(require("classnames"));var Qi={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var bn=require("react/jsx-runtime"),Pu=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=h("ToggleButton",Qi);return(0,bn.jsx)("button",{type:"button",className:(0,Ji.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,bn.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,bn.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},bt=Pu;var Yi=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,wn=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var ea=/x-deepdesk-(([a-z0-9\-_])+-version)/,Ke=(m=>(m.SEARCH="search",m.TEMPLATE="template",m.ELASTIC_SEARCH="search-autocomplete",m.GPT="gpt",m.TRIE="trie",m.TRIE_WITH_TYPOS="trie-with-typos",m.SEMANTIC="semantic",m.TEXT_RECOMMENDATION="text_recommendation",m.URL_RECOMMENDATION="url_recommendation",m.LINK_RECOMMENDATION="link_recommendation",m.PERSONAL_COLLECTION="personal-collection",m.PERSONAL_COLLECTION_SEARCH="personal-collection-search",m.SEARCH_OVERLAY="search-overlay",m.SEARCH_PREVIEW="search-preview",m.SEARCH_URL="search-url",m))(Ke||{}),wt=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(wt||{});var Se=require("react-dom");var yc=require("react");var ta=require("@reduxjs/toolkit"),oa=require("react-redux");var To=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(To||{});var Au={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,inlineSuggestions:!1,floatingMenu:!1,adminUrl:void 0,productName:"Deepdesk"},na=(0,ta.createSlice)({name:"settings",initialState:Au,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:Cn}=na.actions,cr=t=>e=>e.settings[t],b=t=>(0,oa.useSelector)(cr(t)),sa=na.reducer;var Pr=require("react-redux");var Wt=require("@reduxjs/toolkit");var Lu={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ee=t=>t.auth.isLoggedIn,ra=t=>t.auth.loginFetchState,ia=t=>t.auth.verifyFetchState,aa=t=>t.auth.showLoginOverlay,Ue=(0,Wt.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),la=(0,Wt.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),Eo=(0,Wt.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),ca=(0,Wt.createSlice)({name:"auth",initialState:Lu,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(Ue.pending,e=>{e.loginFetchState="loading"}),t.addCase(Ue.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(Ue.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(Eo.pending,e=>{e.verifyFetchState="loading"}),t.addCase(Eo.rejected,e=>{e.verifyFetchState="error"}),t.addCase(Eo.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:Gt,setShowLoginOverlay:da}=ca.actions,pa=ca.reducer;var ze=require("@reduxjs/toolkit"),ha=require("diff"),ya=require("react-redux");function ua(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function rt(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)=>rt(r,e[i],o-1)):ua(t)&&ua(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>rt(t[i],e[i],o-1)):!1}function Mu(t){return Math.max(...t.map(e=>e.length))}function Ou(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 ga(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Mu(n);s++){let r=Ou(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 Nu=2;function dr(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=ga(t,Nu);return o&&o.text!==e?o:t[0]}var _e=require("@reduxjs/toolkit");var Du={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},C=Du;var ma={current:null,isSupported:null},O=(0,_e.createAction)("resetConversation"),Tn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},En=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Xt=t=>t.conversation.isSupported,pr=(0,_e.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),kn=(0,_e.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Rn=(0,_e.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),In=(0,_e.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=En(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),ur=(0,_e.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})})}),Pn=(0,_e.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=En(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Hu=[kn.rejected,Rn.rejected,In.rejected,Pn.rejected].map(t=>t==null?void 0:t.toString()),Fu=(0,_e.createSlice)({name:"conversation",initialState:ma,reducers:{},extraReducers:t=>{t.addCase(pr.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(kn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Rn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(ur.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(In.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Pn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(O,()=>ma).addMatcher(e=>Hu.includes(e.type),(e,o)=>{var n;throw C.info("Conversation action rejected",o.type,((n=o.error)==null?void 0:n.message)||"No message"),new Error(o.error.message)})}}),fa=Fu.reducer;var it={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 va(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 Ln=(0,ze.createAction)("input/replaceText"),Mn=(0,ze.createAction)("input/keyDown"),Ct=(0,ze.createAction)("input/sendMessage"),On=(0,ze.createAction)("input/uiInputChange"),Nn=(0,ze.createAction)("input/applyImageSuggestion"),Q=(0,ze.createAction)("input/sendEvent");function An(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:d}=t.stagedSuggestion,p=o==="search"||o==="personal-collection-search",g=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(p||d==="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:p?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var Sa=(0,ze.createSlice)({name:"input",initialState:it,reducers:{initialInput(t,e){let{text:o,selection:n,html:s}=e.payload;t.text=o,t.selection.start=(n==null?void 0:n.start)??o.length,t.selection.end=(n==null?void 0:n.end)??o.length,t.userCommitted.text=o,t.userCommitted.selection.start=(n==null?void 0:n.start)??o.length,t.userCommitted.selection.end=(n==null?void 0:n.end)??o.length,t.html=s||null},reset(t){Object.assign(t,{...it,selection:t.selection})},resetToCommitted(t){t.text=t.userCommitted.text,t.selection=t.userCommitted.selection,t.stagedSuggestion=null,t.tabCompletionSuggestion=dr(t.textSuggestions,t.userCommitted.text)},changeSelection(t,e){e.payload&&(rt(t.selection,e.payload)||(t.selection=e.payload,t.userCommitted.selection=t.selection,t.stagedSuggestion&&An(t)))},platformInput(t,e){let{text:o,html:n,selection:s}=e.payload;s&&(t.selection.start=s.start,t.selection.end=s.end),t.text=o,t.html=n||null},userInput(t,e){var r,i,a,l;if(t.previousKeyDownEvent){let{key:c,shiftKey:d,ctrlKey:p,metaKey:g,altKey:u}=t.previousKeyDownEvent;switch(c){case"Enter":d&&(t.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:f}=t,{text:m}=e.payload,v=(0,ha.diffChars)(f,m);f.length-m.length>1&&t.metrics.deletions.push(...v.filter(T=>T.removed).map(T=>T.value)),t.metrics.numCharsDeleted+=f.length-m.length;break}case"C":case"V":case"X":if(!p&&!g){t.metrics.numCharsTyped+=1;let f=((r=t.selection)==null?void 0:r.start)!==void 0&&((i=t.selection)==null?void 0:i.end)!==void 0?t.text.substring(t.selection.start,t.selection.end):null;f&&f.length>0&&(t.metrics.numCharsDeleted+=f.length,t.metrics.deletions.push(f))}break;case"Shift":break;default:if(!p&&!g&&!u){t.metrics.numCharsTyped+=1;let f=((a=t.selection)==null?void 0:a.start)!==void 0&&((l=t.selection)==null?void 0:l.end)!==void 0?t.text.substring(t.selection.start,t.selection.end):null;f&&f.length>0&&(t.metrics.numCharsDeleted+=f.length,t.metrics.deletions.push(f))}}}!t.metrics.agentStartedTypingTimestamp&&e.payload.text!==t.text&&(t.metrics.agentStartedTypingTimestamp=Date.now()),e.payload.text===""&&(t.metrics=it.metrics,t.textSuggestions=[],t.stagedSuggestion=null),t.text!==e.payload.text&&An(t);let{text:o,html:n,selection:s}=e.payload;s&&(t.selection.start=s.start,t.selection.end=s.end,t.userCommitted.selection.start=s.start,t.userCommitted.selection.end=s.end),t.text=o,t.html=n||null,t.userCommitted.text=o,t.previousKeyDownEvent=null},stageSuggestion(t,e){let{text:o}=e.payload;switch(t.stagedSuggestion=e.payload,t.tabCompletionSuggestion=void 0,e.payload.replace){case"selection":t.text=`${t.text.slice(0,t.selection.start)}${o}${t.text.slice(t.selection.end)}`,t.selection.end=t.selection.start+o.length,t.selection.start+=o.length;break;case"until-selection-end":t.text=`${o}${t.text.slice(t.selection.end)}`,t.selection.start=o.length,t.selection.end=o.length;break;default:throw new Error(`Unknown replace ${e.payload.replace}`)}e.payload.eventMetrics.inputType==="tab"&&An(t)},commitSuggestion(t){An(t)},offeredTextSuggestion(t,e){let{text:o,suggestion:{source:n}}=e.payload;t.metrics.offeredTextSuggestions.find(r=>r.text===o)||t.metrics.offeredTextSuggestions.push({text:o,source:n})},registerCut(t,e){let{metrics:o}=t,n=e.payload;t.metrics={...t.metrics,numCharsCut:o.numCharsCut+n.length,cuts:[...o.cuts,n]}},registerPaste(t,e){let{metrics:o}=t,{text:n,selectionText:s}=e.payload,r=o.numCharsDeleted+(s&&s.length?s.length:0),i=s&&s.length?[...o.deletions,s]:o.deletions;t.metrics={...t.metrics,numCharsDeleted:r,deletions:i,numCharsPasted:o.numCharsPasted+n.length,numPaste:o.numPaste+1,pastes:[...o.pastes,n]}},registerKeyDown(t,e){t.previousKeyDownEvent=e.payload},nextTextSuggestionIndex(t){let e=t.textSuggestions.length;t.selectedSuggestionIndex=t.selectedSuggestionIndex<e-1?t.selectedSuggestionIndex+1:t.selectedSuggestionIndex},previousTextSuggestionIndex(t){t.selectedSuggestionIndex=t.selectedSuggestionIndex>=0?t.selectedSuggestionIndex-1:t.selectedSuggestionIndex},setTextSuggestions(t,e){if(t.selectedSuggestionIndex=-1,t.textSuggestions=e.payload,e.payload.length===0)return;let o=t.userCommitted.text.substring(0,t.userCommitted.selection.end),n=dr(e.payload,o);t.tabCompletionSuggestion=n!=null&&n.text.includes(o)?n:void 0},setSelectedTextSuggestionIndex(t,e){t.selectedSuggestionIndex=e.payload},setMetrics(t,{payload:e}){t.metrics=e}},extraReducers:t=>{t.addCase(O,e=>{e.tabCompletionSuggestion=it.tabCompletionSuggestion,e.previousKeyDownEvent=it.previousKeyDownEvent,e.textSuggestions=it.textSuggestions,e.selectedSuggestionIndex=it.selectedSuggestionIndex,e.metrics=it.metrics})}}),Zt=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),Bu=t=>t.input.selection,_a=()=>(0,ya.useSelector)(Bu),{userInput:xa,changeSelection:gr,initialInput:ba,nextTextSuggestionIndex:wa,offeredTextSuggestion:Ca,previousTextSuggestionIndex:Ta,registerCut:Ea,registerKeyDown:ka,registerPaste:Ra,reset:Ia,resetToCommitted:ko,platformInput:Pa,setSelectedTextSuggestionIndex:at,setTextSuggestions:Pe,stageSuggestion:xe,commitSuggestion:qe,setMetrics:Aa}=Sa.actions,La=Sa.reducer;var Hn=require("@reduxjs/toolkit");var Qt=require("@reduxjs/toolkit");function Ku(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function A(t){return Array.isArray(t)?t.map(A):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Ku(o)]:A(t[o])}),{}):t}function mr(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function q(t){return Array.isArray(t)?t.map(q):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[mr(o)]:q(t[o])}),{}):t}var Uu={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Io=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)||""}},Ro=(0,Qt.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?A(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),A(n))}),fr=(0,Qt.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}),hr=(0,Qt.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),Ma=t=>t.info.agentInfo,Oa=(0,Qt.createSlice)({name:"info",initialState:Uu,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Ro.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Ro.rejected,e=>{e.fetchState="error"}).addCase(Ro.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(fr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(hr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(O,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Na}=Oa.actions,Da=Oa.reducer;var Dn={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},Ha=t=>t.search.isOpen,Fa=t=>t.search.page,Ba=t=>t.search.list,Ka=t=>t.search.aggregates;function Ua(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Tt=(0,Hn.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:Io(n)});return{results:r.map(l=>({...l,source:`search-${l.type.toLowerCase()}`,searchTerm:t.query})),aggregates:i}}),za=(0,Hn.createSlice)({name:"search",initialState:Dn,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=Dn.fetchState,t.list=Dn.list}},extraReducers:t=>{t.addCase(Tt.pending,e=>{e.fetchState="loading"}).addCase(Tt.rejected,(e,o)=>{e.fetchState="error",C.error(o.error)}).addCase(Tt.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload.results,e.aggregates=o.payload.aggregates||{}}).addCase(O,()=>Dn)}}),{resetSearch:Fn,setIsOpen:le,setPage:be}=za.actions,qa=za.reducer;var Jt=require("@reduxjs/toolkit");var yr={cues:[],fetchState:"idle"},ja=t=>{var e;return(e=t.rules)==null?void 0:e.cues},zu=(0,Jt.createAction)("rules/resetCues"),je=(0,Jt.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)}),Va=(0,Jt.createSlice)({name:"answer",initialState:yr,reducers:{removeCue(t,e){t.cues=t.cues.filter(o=>o.id!==e.payload.id)}},extraReducers:t=>{t.addCase(je.pending,e=>{e.fetchState="loading"}).addCase(je.rejected,e=>{e.fetchState="error"}).addCase(je.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(O,()=>yr).addCase(zu.toString(),()=>yr)}}),{removeCue:$a}=Va.actions,Wa=Va.reducer;var vr="SetCues",Yt="ShowLoginOverlay",Po="UserLoggedIn",qu="UserLoggedOut",eo="ApplySuggestion",Sr="ApplyImageSuggestion",ju="ShowCommandPalette",Vu=t=>({[vr]:e=>{t.dispatch({type:je.fulfilled,payload:e})},[ju]:e=>{t.dispatch(le(e.isOpen)),e.page&&t.dispatch(be(e.page))},[Yt]:e=>{t.dispatch(da(e))},[Po]:()=>{t.dispatch(Ue())},[qu]:()=>{t.dispatch(Ue())},[Sr]:e=>{t.dispatch(Nn({suggestion:e.suggestion}))},[eo]:e=>{t.dispatch(xe({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(qe())}}),Ga=Vu;var Ao=E(require("react")),Za=require("react/jsx-runtime"),Xa=Ao.default.createContext(null),Et=({broadcastEvents:t,children:e})=>{let o=Ao.default.useMemo(()=>t,[]);return(0,Za.jsx)(Xa.Provider,{value:o,children:e})},Ae=()=>{let t=(0,Ao.useContext)(Xa);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var ts=E(require("classnames")),Ce=require("react"),os=require("react-redux");var Jn=require("react");var _r=function(t,e){return _r=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])},_r(t,e)};function Lo(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");_r(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var ce=function(){return ce=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},ce.apply(this,arguments)};function Qa(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 Bn(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 Kn;(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"})(Kn||(Kn={}));var Un=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var we;(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"})(we||(we={}));var zn;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(zn||(zn={}));function xr(t){return t.type===we.literal}function Ja(t){return t.type===we.argument}function qn(t){return t.type===we.number}function jn(t){return t.type===we.date}function Vn(t){return t.type===we.time}function $n(t){return t.type===we.select}function Wn(t){return t.type===we.plural}function Ya(t){return t.type===we.pound}function Gn(t){return t.type===we.tag}function Xn(t){return!!(t&&typeof t=="object"&&t.type===zn.number)}function Mo(t){return!!(t&&typeof t=="object"&&t.type===zn.dateTime)}function br(t){t.forEach(function(e){if(delete e.location,$n(e)||Wn(e))for(var o in e.options)delete e.options[o].location,br(e.options[o].value);else qn(e)&&Xn(e.style)||(jn(e)||Vn(e))&&Mo(e.style)?delete e.style.location:Gn(e)&&br(e.children)})}function el(t,e){e===void 0&&(e={}),e=ce({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new Un(t,e).parse();if(o.err){var n=SyntaxError(Kn[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||br(o.val),o.val}function Zn(t,e){var o=e&&e.cache?e.cache:Qu,n=e&&e.serializer?e.serializer:Zu,s=e&&e.strategy?e.strategy:Wu;return s(t,{cache:o,serializer:n})}function $u(t){return t==null||typeof t=="number"||typeof t=="boolean"}function tl(t,e,o,n){var s=$u(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function ol(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 wr(t,e,o,n,s){return o.bind(e,t,n,s)}function Wu(t,e){var o=t.length===1?tl:ol;return wr(t,this,o,e.cache.create(),e.serializer)}function Gu(t,e){return wr(t,this,ol,e.cache.create(),e.serializer)}function Xu(t,e){return wr(t,this,tl,e.cache.create(),e.serializer)}var Zu=function(){return JSON.stringify(arguments)};function Cr(){this.cache=Object.create(null)}Cr.prototype.get=function(t){return this.cache[t]};Cr.prototype.set=function(t,e){this.cache[t]=e};var Qu={create:function(){return new Cr}},Qn={variadic:Gu,monadic:Xu};var kt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(kt||(kt={}));var Oo=function(t){Lo(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 Tr=function(t){Lo(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('", "'),'"'),kt.INVALID_VALUE,r)||this}return e}(Oo);var nl=function(t){Lo(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),kt.INVALID_VALUE,s)||this}return e}(Oo);var sl=function(t){Lo(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,'"'),kt.MISSING_VALUE,n)||this}return e}(Oo);var J;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(J||(J={}));function Ju(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 Yu(t){return typeof t=="function"}function No(t,e,o,n,s,r,i){if(t.length===1&&xr(t[0]))return[{type:J.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var d=c[l];if(xr(d)){a.push({type:J.literal,value:d.value});continue}if(Ya(d)){typeof r=="number"&&a.push({type:J.literal,value:o.getNumberFormat(e).format(r)});continue}var p=d.value;if(!(s&&p in s))throw new sl(p,i);var g=s[p];if(Ja(d)){(!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(jn(d)){var u=typeof d.style=="string"?n.date[d.style]:Mo(d.style)?d.style.parsedOptions:void 0;a.push({type:J.literal,value:o.getDateTimeFormat(e,u).format(g)});continue}if(Vn(d)){var u=typeof d.style=="string"?n.time[d.style]:Mo(d.style)?d.style.parsedOptions:n.time.medium;a.push({type:J.literal,value:o.getDateTimeFormat(e,u).format(g)});continue}if(qn(d)){var u=typeof d.style=="string"?n.number[d.style]:Xn(d.style)?d.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(Gn(d)){var f=d.children,m=d.value,v=s[m];if(!Yu(v))throw new nl(m,"function",i);var T=No(f,e,o,n,s,r),_=v(T.map(function(S){return S.value}));Array.isArray(_)||(_=[_]),a.push.apply(a,_.map(function(S){return{type:typeof S=="string"?J.literal:J.object,value:S}}))}if($n(d)){var y=d.options[g]||d.options.other;if(!y)throw new Tr(d.value,g,Object.keys(d.options),i);a.push.apply(a,No(y.value,e,o,n,s));continue}if(Wn(d)){var y=d.options["=".concat(g)];if(!y){if(!Intl.PluralRules)throw new Oo(`Intl.PluralRules is not available in this environment.
2
2
  Try polyfilling it using "@formatjs/intl-pluralrules"
3
- `,kt.MISSING_INTL_API,i);var x=o.getPluralRules(e,{type:d.pluralType}).select(g-(d.offset||0));y=d.options[x]||d.options.other}if(!y)throw new Tr(d.value,g,Object.keys(d.options),i);a.push.apply(a,No(y.value,e,o,n,s,g-(d.offset||0)));continue}}return Ju(a)}function eg(t,e){return e?ce(ce(ce({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=ce(ce({},t[n]),e[n]||{}),o},{})):t}function tg(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=eg(t[n],e[n]),o},ce({},t)):t}function Er(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function og(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Zn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,Bn([void 0],o,!1)))},{cache:Er(t.number),strategy:Qn.variadic}),getDateTimeFormat:Zn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,Bn([void 0],o,!1)))},{cache:Er(t.dateTime),strategy:Qn.variadic}),getPluralRules:Zn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,Bn([void 0],o,!1)))},{cache:Er(t.pluralRules),strategy:Qn.variadic})}}var rl=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 d=r.formatToParts(c);if(d.length===1)return d[0].value;var p=d.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 p.length<=1?p[0]||"":p},this.formatToParts=function(c){return No(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=Qa(i,["formatters"]);this.ast=t.__parse(e,ce(ce({},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=tg(t.formats,n),this.formatters=s&&s.formatters||og(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=el,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 ng(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var sg="dummy",kr=(0,Jn.createContext)(null);function k(t){let e=(0,Jn.useContext)(kr);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=ng(o,n);return r?new rl(r).format(s):(e!==sg&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var Yn=require("react");var il={root:"_root_1h19b_1",content:"_content_1h19b_24"};var Ir=require("react/jsx-runtime"),rg=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,onKeyDown:r,overlayAriaLabel:i,contentAriaLabel:a})=>{let l=(0,Yn.useRef)(null),c=h("Dialog",il),d=g=>{if(g.key==="Escape"){g.preventDefault(),g.stopPropagation(),s();return}r&&r(g)},p=g=>{g.target===l.current&&t&&n()};return(0,Yn.useEffect)(()=>{var g,u;!l.current||!t||!e||(u=(g=l.current)==null?void 0:g.querySelector("input, textarea"))==null||u.focus()},[t,e,l]),t?(0,Ir.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":i,ref:l,onKeyDown:d,onMouseDown:p,children:(0,Ir.jsx)("div",{"data-testid":"dialog-content",className:c.content,"aria-label":a,children:o})}):null},es=rg;var ll=E(require("classnames"));var al={root:"_root_1ukx5_1"};var cl=require("react/jsx-runtime"),ig=({className:t,value:e,...o})=>{let n=h("TextInput",al);return(0,cl.jsx)("input",{className:(0,ll.default)(t,n.root),type:"text",value:e,...o})},Do=ig;var Rr={};Y(Rr,{enUS:()=>ag,nlNL:()=>lg});var ag={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"}]},lg={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 dl={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 K=require("react/jsx-runtime");var cg=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},dg=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=k(Rr),i=h("LoginTokenDialog",dl),a=(0,os.useSelector)(ia),l=(0,os.useDispatch)(),c=b("productName"),[d,p]=(0,Ce.useState)(t||""),[g,u]=(0,Ce.useState)(0),[f,m]=(0,Ce.useState)(""),v=(0,Ce.useCallback)(async x=>{x.preventDefault(),l(la({email:d})),u(1)},[o,d]),T=()=>{m(""),u(0)},_=(0,Ce.useCallback)(async x=>{x.preventDefault();let S=cg(x.target.elements.token.value);if(!S){m(r("verifyCodeError",{login:y}));return}l(Eo({token:S}))},[o]),y=(0,Ce.useMemo)(()=>x=>(0,K.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:T,children:x},"back-button"),[]);return(0,Ce.useEffect)(()=>{a==="error"&&m(r("verifyCodeError",{login:y})),a==="done"&&n()},[a]),(0,K.jsx)(es,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:(0,K.jsxs)("div",{className:i.root,children:[(0,K.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:c})}),g===0&&(0,K.jsxs)("form",{onSubmit:v,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),(0,K.jsx)(Do,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:d,onChange:x=>p(x.target.value)}),(0,K.jsx)("div",{className:i.actions,children:(0,K.jsx)("button",{type:"submit",className:(0,ts.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),g===1&&(0,K.jsxs)("form",{onSubmit:_,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,K.jsx)(Do,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&(0,K.jsx)("div",{className:i.errorMessage,children:f}),(0,K.jsxs)("div",{className:i.actions,children:[(0,K.jsx)("button",{type:"button",className:(0,ts.default)(i.button),onClick:T,children:r("back")}),(0,K.jsx)("button",{type:"submit",className:(0,ts.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},pl=dg;var gl=require("react/jsx-runtime"),pg=()=>{let t=(0,Pr.useSelector)(aa),e=(0,Pr.useSelector)(Ma),o=b("adminUrl"),n=Ae(),s=()=>n.send(Yt,!1),r=()=>{n.send(Yt,!1),n.send(Po)};return(0,gl.jsx)(pl,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},ul=pg;var fc=E(require("lodash.debounce")),ne=require("react"),Le=require("react-redux");var ns=require("@reduxjs/toolkit");var ug={data:null,fetchState:"idle"},ml=t=>t.contentTypes.data,Ho=(0,ns.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),gg=(0,ns.createSlice)({name:"contentTypes",initialState:ug,reducers:{},extraReducers:t=>{t.addCase(Ho.pending,e=>{e.fetchState="loading"}).addCase(Ho.rejected,e=>{e.fetchState="error"}).addCase(Ho.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),fl=gg.reducer;function Fo(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 qe=require("react");var hl=require("react"),ss=E(require("classnames"));var fe={root:"_root_1xtw7_1",list:"_list_1xtw7_2",listWrapper:"_listWrapper_1xtw7_6",listHorizontal:"_listHorizontal_1xtw7_10",page:"_page_1xtw7_19",search:"_search_1xtw7_25",pageNav:"_pageNav_1xtw7_33",pageTitle:"_pageTitle_1xtw7_41",pageBackButton:"_pageBackButton_1xtw7_48",listHeader:"_listHeader_1xtw7_62",listHeading:"_listHeading_1xtw7_68",listMoreButton:"_listMoreButton_1xtw7_76",listItem:"_listItem_1xtw7_87",listItemContent:"_listItemContent_1xtw7_96",listItemText:"_listItemText_1xtw7_114",listItemDescription:"_listItemDescription_1xtw7_122",listItemActions:"_listItemActions_1xtw7_129",truncate:"_truncate_1xtw7_140",lineClamp:"_lineClamp_1xtw7_146",listItemTitle:"_listItemTitle_1xtw7_153",listItemAction:"_listItemAction_1xtw7_129",listItemPrimaryAction:"_listItemPrimaryAction_1xtw7_178",listItemSelected:"_listItemSelected_1xtw7_183",sources:"_sources_1xtw7_187",sourcesTitle:"_sourcesTitle_1xtw7_194",source:"_source_1xtw7_187",icon:"_icon_1xtw7_209",searchIcon:"_searchIcon_1xtw7_226",searchInputWrapper:"_searchInputWrapper_1xtw7_231",searchInput:"_searchInput_1xtw7_231",select:"_select_1xtw7_252",selectType:"_selectType_1xtw7_269",selectWrapper:"_selectWrapper_1xtw7_273",image:"_image_1xtw7_303",imageSrc:"_imageSrc_1xtw7_310",imageSrcHidden:"_imageSrcHidden_1xtw7_321",imageSrcStatus:"_imageSrcStatus_1xtw7_325",imageTitle:"_imageTitle_1xtw7_335",actions:"_actions_1xtw7_340",actionsWrapper:"_actionsWrapper_1xtw7_344",actionsBar:"_actionsBar_1xtw7_350",actionButton:"_actionButton_1xtw7_359",hasShortKeys:"_hasShortKeys_1xtw7_372",actionShortcut:"_actionShortcut_1xtw7_381",actionShortcutFixKerning:"_actionShortcutFixKerning_1xtw7_388"};var It={};Y(It,{enUS:()=>mg,nlNL:()=>fg});var mg={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"}]},fg={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 lt=require("react/jsx-runtime"),hg=({src:t,title:e})=>{let o=h("CommandPalette",fe),[n,s]=(0,hl.useState)("loading"),r=k(It);return(0,lt.jsxs)("div",{className:o.image,children:[(0,lt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,ss.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,lt.jsx)("span",{className:(0,ss.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,lt.jsx)("span",{className:(0,ss.default)(o.imageSrc,o.imageSrcStatus),children:(0,lt.jsx)(yn,{})}),e&&(0,lt.jsx)("span",{className:o.imageTitle,children:e})]})},yl=hg;var vl=E(require("react")),Sl=E(require("classnames"));var Rt=require("react/jsx-runtime");function Ar({children:t,heading:e,orientation:o,hasMore:n,onShowAll:s}){let r=k(It),i=h("CommandPalette",fe);return vl.default.Children.count(t)===0?null:(0,Rt.jsxs)("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||n)&&(0,Rt.jsxs)("div",{className:i.listHeader,children:[e&&(0,Rt.jsx)("h4",{className:i.listHeading,children:e}),n&&s&&(0,Rt.jsx)("button",{onClick:s,className:i.listMoreButton,type:"button",children:r("showAll")})]}),(0,Rt.jsx)("div",{className:(0,Sl.default)(i.listWrapper,o==="horizontal"&&i.listHorizontal),children:t})]})}var Bo=E(require("classnames")),Pl=require("interweave");var yg=/[.*+?^${}()|[\]\\]/g,vg=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function Sg(t){return t.replace(yg,"\\$&")}function _g(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function xg(t){return t.search(vg)}function _l(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${Sg(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function xl(t){return t.replace(wn,'<mark data-type="placeholder">$1</mark>')}function to(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function bg(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 Lr(t,e,o={}){if(e){let n=_g(e.toLowerCase(),t.toLowerCase()),s=to(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=xg(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(Yi).length>3||e.length>30?bg(e.trim(),n):0;return`${`${i>0?"\u2026":""}${to(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var wg=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function rs(t){return wg.test(t)}function bl(t){let e=document.createElement("template");return e.innerHTML=t,e.content.textContent??""}var W=E(require("react")),wl=E(require("classnames"));var Mr={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 Pt=require("react/jsx-runtime"),Cg=0,Cl=W.default.createContext(null),Tg=()=>{let t=(0,W.useContext)(Cl);if(!t)throw new Error("Invalid DropdownContext");return t},Tl=({trigger:t,children:e,position:o="bottom"})=>{let n=(0,W.useMemo)(()=>++Cg,[]),s=(0,W.useRef)(null),r=(0,W.useRef)(null),i=h("Dropdown",Mr),[a,l]=(0,W.useState)(!1),[c,d]=(0,W.useState)(o),p=u=>{u.preventDefault(),u.stopPropagation(),l(!a)},g=(0,W.useCallback)(([u])=>{!u.isIntersecting&&a&&d(c==="top"?"bottom":"top")},[a]);return(0,W.useEffect)(()=>{let u=f=>{s.current&&!s.current.contains(f.target)&&l(!1)};return document.addEventListener("click",u),()=>{document.removeEventListener("click",u)}},[]),(0,W.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,Pt.jsx)(Cl.Provider,{value:{setIsOpen:l},children:(0,Pt.jsxs)("div",{ref:s,className:i.root,children:[(0,Pt.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:p,children:t}),(0,Pt.jsx)("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:(0,wl.default)(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function Eg({as:t,children:e,onClick:o,...n}){let s=t||"button",r=h("Dropdown",Mr),{setIsOpen:i}=Tg(),a=l=>{i(!1),o(l),l.stopPropagation()};return(0,Pt.jsx)(s,{type:"button",className:r.item,onClick:a,...n,children:e})}Tl.Item=Eg;var Or=Tl;var Nr=require("react/jsx-runtime"),El=t=>(0,Nr.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:(0,Nr.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 At={};Y(At,{enUS:()=>kg,nlNL:()=>Ig});var kg={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],giveFeedback:[{type:0,value:"Give feedback"}],answer:[{type:0,value:"Answer"}]},Ig={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],giveFeedback:[{type:0,value:"Geef feedback"}],answer:[{type:0,value:"Antwoord"}]};var is=require("react/jsx-runtime"),Rg="%0d%0a%0d%0a%0d%0a",Pg=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(Rg)}`},Ag=({suggestion:t,onFeedback:e})=>{let o=k(At),n=b("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:(0,is.jsx)(Or,{trigger:(0,is.jsx)(El,{"data-testid":"feedback-dropdown-trigger"}),children:(0,is.jsx)(Or.Item,{as:"a",href:Pg(n,t),onClick:e,children:o("giveFeedback")})})},as=Ag;var ls=E(require("react")),Rl=require("react/jsx-runtime"),kl=ls.default.createContext(void 0);function ct(){let t=ls.default.useContext(kl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Il=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=ls.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,Rl.jsx)(kl.Provider,{value:i,children:t})};var de=require("react/jsx-runtime");function Dr({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onFeedback:s,onSourceClick:r,description:i,sources:a,id:l,styles:c,...d}){let{selected:p,onChangeOpen:g}=ct(),u=h("CommandPalette",fe);function f(m){n(m),t&&g(!1)}return(0,de.jsxs)("div",{className:(0,Bo.default)(u.listItem,l===p&&u.listItemSelected),children:[(0,de.jsx)("button",{type:"button",className:(0,Bo.default)(u.listItemAction,u.listItemPrimaryAction),"aria-disabled":d.disabled??!1,onClick:f,"data-command-palette-item":!0,"data-item-id":l,...d,children:(0,de.jsxs)("div",{className:u.listItemContent,children:[typeof o=="string"?(0,de.jsx)("p",{className:(0,Bo.default)(u.listItemText,u.truncate,c==null?void 0:c.title),children:o}):o,i&&(0,de.jsx)(Pl.Interweave,{tagName:"p",allowList:[],content:rs(i)?bl(i):i,className:(0,Bo.default)(u.listItemDescription,c==null?void 0:c.description,e?u.lineClamp:u.truncate)})]})}),s&&(0,de.jsx)("div",{className:u.listItemActions,children:(0,de.jsx)(as,{suggestion:String(o),onFeedback:s})}),a&&(0,de.jsxs)("div",{className:u.sources,children:[(0,de.jsx)("span",{className:u.sourcesTitle,children:"Sources"}),a.map(m=>m.url?(0,de.jsx)("a",{className:u.source,href:m.url,target:"_blank",title:m.url,rel:"noopener noreferrer",onClick:()=>r&&r(m),children:m.name},m.url):(0,de.jsx)("span",{className:u.source,children:m.name},m.name))]})]})}var Ko=require("react/jsx-runtime"),Al=()=>(0,Ko.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Ko.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Ko.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 Lt=require("react/jsx-runtime");function Hr({children:t,title:e,id:o,onDismiss:n}){let s=k(It),r=h("CommandPalette",fe),{page:i}=ct();return i!==o?null:(0,Lt.jsxs)("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,Lt.jsxs)("div",{className:r.pageNav,children:[(0,Lt.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:n,children:[(0,Lt.jsx)(Al,{}),s("back")]}),e&&(0,Lt.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var Ll=require("react");var Uo=require("react/jsx-runtime"),oo=()=>(0,Uo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Uo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Uo.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 Te=require("react/jsx-runtime");function Lg({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=h("CommandPalette",fe);return(0,Te.jsxs)("div",{className:l.search,children:[(0,Te.jsx)("div",{className:l.searchIcon,children:(0,Te.jsx)(oo,{})}),(0,Te.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Te.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,Te.jsx)("div",{className:l.selectWrapper,children:(0,Te.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,Te.jsx)("option",{children:n}),s.map(c=>(0,Te.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var Ml=(0,Ll.forwardRef)(Lg);var Fr=E(require("classnames"));var cs=require("react/jsx-runtime"),Mg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=h("CommandPalette",fe);return(0,cs.jsxs)("button",{type:"button",...n,onClick:t,className:(0,Fr.default)(s.actionButton,n.className,{[s.hasShortKeys]:e&&e.length>0}),children:[o,e&&e.map(r=>(0,cs.jsx)("span",{className:(0,Fr.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},Ol=Mg;var zo=require("react/jsx-runtime"),Og="[data-command-palette-item]";function no({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:d,isOpen:p,search:g}){let[u,f]=(0,qe.useState)(),m=(0,qe.useRef)(null),v=()=>{s&&s(o),i(void 0),r(""),a(!1)},T=()=>{var P;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(P=m.current)==null||P.focus();return}if(g.length>0){r("");return}a(!1)},_=()=>{let P=y();P.length!==0&&f(P[0].dataset.itemId)},y=()=>Array.from(document.querySelectorAll(Og)||[]),x=P=>document.querySelector(`[data-item-id=${P}]`),S=P=>{let M=x(P);M&&f(M.dataset.itemId)},N=P=>{let M=x(P);M&&M.scrollIntoView({behavior:"smooth"})},U=()=>{if(!u)return;let P=y(),M=x(u);if(!M)return;let I=P.indexOf(M),X=P[I+1];X&&X.dataset.itemId?S(X.dataset.itemId):_()},V=()=>{if(!u)return;let P=y(),M=x(u);if(!M)return;let I=P.indexOf(M),X=P[I-1];X&&X.dataset.itemId?S(X.dataset.itemId):S(P[P.length-1].dataset.itemId)},B=(0,qe.useCallback)(P=>{switch(P.key){case"ArrowDown":{P.preventDefault(),U();break}case"ArrowUp":{P.preventDefault(),V();break}case"Enter":{if(u){let M=x(u);M==null||M.click()}break}}},[u]);return(0,qe.useEffect)(()=>{_()},[g,n,l,p]),(0,qe.useEffect)(()=>{u&&N(u)},[u]),(0,zo.jsx)(es,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:p,onBack:T,onClose:v,onKeyDown:B,children:(0,zo.jsxs)(Il,{selected:u,setSelected:f,isOpen:p,onChangeOpen:a,page:n,children:[n===o&&(0,zo.jsx)(Ml,{ref:m,onChange:r,onChangeType:i,placeholder:t,value:g,selectedType:l,types:c,typePlaceholder:e}),d]})})}no.Page=Hr;no.List=Ar;no.Image=yl;no.ListItem=Dr;no.Button=Ol;var H=no;var Nl=require("react");function Dl(t,e){(0,Nl.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 jo=require("react"),us=require("react-redux");var ds=require("@reduxjs/toolkit");var Hl={data:null,fetchState:"idle"},ps=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},Ee=(0,ds.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)}),Ng=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Dg=(0,ds.createSlice)({name:"entities",initialState:Hl,reducers:{},extraReducers:t=>{t.addCase(Ee.pending,e=>{e.fetchState="loading"}).addCase(Ee.rejected,e=>{e.fetchState="error"}).addCase(Ee.fulfilled,(e,o)=>{e.fetchState="done",e.data=Ng(e.data?[...e.data,...o.payload]:o.payload)}).addCase(O,()=>Hl)}}),Fl=Dg.reducer;var Br={};Y(Br,{enUS:()=>Hg,nlNL:()=>Fg});var Hg={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Fg={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Bl={root:"_root_17kae_1",empty:"_empty_17kae_5"};var so=require("react/jsx-runtime"),Bg=({onCopy:t})=>{let e=(0,jo.useRef)(null),o=h("EntitiesList",Bl),n=(0,us.useSelector)(ps),{setSelected:s}=ct(),r=k(Br),i=(0,us.useDispatch)();return(0,jo.useEffect)(()=>{i(Ee())},[]),(0,jo.useEffect)(()=>{e.current&&(e.current.focus(),s("entity-0"))},[e]),(0,so.jsxs)("div",{className:o.root,ref:e,tabIndex:-1,children:[n&&n.length>0&&(0,so.jsx)(H.List,{children:n.map((a,l)=>(0,so.jsx)(H.ListItem,{id:`entity-${l}`,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities"),n&&n.length===0&&(0,so.jsx)("p",{className:o.empty,children:r("noResults")})]})},Kl=Bg;var ke=require("react"),Vo=require("react-redux");var gs=require("@reduxjs/toolkit");var Ul={data:null,fetchState:"idle"},zl=t=>t.summary.data,jl=t=>t.summary.fetchState==="error",$e=(0,gs.createAsyncThunk)("summary/getSummary",async(t,e)=>{var d,p,g;let o=e.getState().profile.data,n=(d=e.getState().conversation.current)==null?void 0:d.sessionId,s=(g=(p=e.getState().info)==null?void 0:p.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"))}),Kg=(0,gs.createSlice)({name:"summary",initialState:Ul,reducers:{},extraReducers:t=>{t.addCase($e.pending,e=>{e.data=null,e.fetchState="loading"}).addCase($e.rejected,e=>{e.data=null,e.fetchState="error"}).addCase($e.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(O,()=>Ul)}}),Vl=Kg.reducer;var Kr={};Y(Kr,{enUS:()=>Ug,nlNL:()=>zg});var Ug={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."}]},zg={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 ql={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 We=require("react/jsx-runtime"),jg=({onCopy:t})=>{let e=(0,ke.useRef)(null),o=h("SummaryForm",ql),[n,s]=(0,ke.useState)(""),r=k(Kr),i=(0,Vo.useSelector)(zl),a=(0,Vo.useSelector)(jl),l=(0,Vo.useDispatch)(),c=()=>{l(Q({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},d=()=>{let p=document.getSelection();p&&l(Q({name:"summary copied to clipboard",data:{originalText:i,finalText:p==null?void 0:p.toString()},options:{includeConversationData:!0}}))};return(0,ke.useEffect)(()=>{l($e())},[]),(0,ke.useEffect)(()=>{s(i||"")},[i]),(0,ke.useEffect)(()=>{e.current&&i&&e.current.focus()},[e,i]),(0,ke.useEffect)(()=>{let p=g=>{g.key==="Enter"&&g.shiftKey&&c()};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p)}},[n]),(0,We.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,We.jsx)("p",{className:o.error,children:r("error")}):(0,We.jsxs)(ke.Fragment,{children:[(0,We.jsx)("div",{className:o.main,children:(0,We.jsx)("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:d,onChange:p=>s(p.target.value)})}),(0,We.jsx)("div",{className:o.actions,children:(0,We.jsx)(H.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},$l=jg;var qo={};Y(qo,{enUS:()=>Vg,nlNL:()=>qg});var Vg={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?"}]},qg={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 dt=E(require("react")),Go=require("react-redux");var Ur={};Y(Ur,{enUS:()=>$g,nlNL:()=>Wg});var $g={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"}]},Wg={use:[{type:0,value:"Gebruik"}],loading:[{type:0,value:"Laden..."}],error:[{type:0,value:"Er ging iets mis, probeer het later opnieuw."}],anotherQuestion:[{type:0,value:"Stuur een bericht..."}],reset:[{type:0,value:"Reset gesprek"}]};var Wl={root:"_root_1g4pq_1",title:"_title_1g4pq_9",empty:"_empty_1g4pq_20",status:"_status_1g4pq_24",form:"_form_1g4pq_30",input:"_input_1g4pq_43",submit:"_submit_1g4pq_55",question:"_question_1g4pq_63",answer:"_answer_1g4pq_67",alignRight:"_alignRight_1g4pq_73"};var io=require("@reduxjs/toolkit");var ms=require("@reduxjs/toolkit");var Gg={data:null,fetchState:"idle"},Gl=t=>{var e;return(e=t.knowledgeAssistant)==null?void 0:e.data},$o=(0,ms.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}),Xg=(0,ms.createSlice)({name:"knowledgeAssistant",initialState:Gg,reducers:{},extraReducers:t=>{t.addCase($o.pending,e=>{e.fetchState="loading"}).addCase($o.rejected,e=>{e.fetchState="error"}).addCase($o.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Xl=Xg.reducer;var zr={data:[],fetchState:"idle"},Zl=t=>{var e;return(e=t.answer)==null?void 0:e.data},Ql=t=>t.answer.fetchState,ao=(0,io.createAction)("answer/resetKnowledgeSearch"),ro=(0,io.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var l,c,d;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=Gl(e.getState()),r=(l=e.getState().conversation.current)==null?void 0:l.sessionId,i=(d=(c=e.getState().info)==null?void 0:c.agentInfo)==null?void 0:d.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}}),Zg=(0,io.createSlice)({name:"answer",initialState:zr,reducers:{},extraReducers:t=>{t.addCase(ro.pending,e=>{e.fetchState="loading"}).addCase(ro.rejected,e=>{e.fetchState="error"}).addCase(ro.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(O,()=>zr).addCase(ao,()=>zr)}}),Jl=Zg.reducer;var Wo=require("react/jsx-runtime"),Yl=()=>(0,Wo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Wo.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Wo.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 pe=require("react/jsx-runtime"),Qg=({onUse:t,onResetQuestion:e,question:o})=>{let[n,s]=dt.default.useState(""),{setSelected:r}=ct(),i=(0,dt.useRef)(null),a=h("EntitiesList",Wl),l=k(Ur),c=(0,Go.useDispatch)(),d=(0,Go.useSelector)(Zl),p=(0,Go.useSelector)(Ql),g=async f=>{f.preventDefault(),f.stopPropagation(),n!==""&&c(ro(n))},u=(f,m)=>{c(Q({name:"knowledge assist source viewed",data:{question:m,sourceViewed:f.url||f.name},options:{includeConversationData:!0}}))};return(0,dt.useEffect)(()=>{var f;o&&p==="idle"?c(ro(o)):(f=i.current)==null||f.focus()},[i,p]),(0,dt.useEffect)(()=>{p==="done"&&(c(Q({name:"knowledge assist question answered",data:{question:n||o,sources:d[d.length-1].answer.sources,answer:d[d.length-1].answer.answer,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),r(`knowledge-assist-${d.length-1}`),s(""))},[p,d]),(0,dt.useEffect)(()=>{i.current&&i.current.scrollIntoView({behavior:"smooth"})},[i,d]),(0,pe.jsxs)("div",{className:a.root,children:[d.length>0&&(0,pe.jsx)("div",{className:a.alignRight,children:(0,pe.jsx)(H.Button,{onClick:e,children:l("reset")})}),d.map(({question:f,answer:m},v)=>(0,pe.jsx)(H.List,{children:(0,pe.jsx)(H.ListItem,{id:`knowledge-assist-${v}`,"data-testid":"knowledge-search-answer",description:m.answer,closeOnSelect:!0,onClick:()=>t(m.answer),onSourceClick:T=>u(T,f),sources:m.sources,styles:{title:a.question,description:a.answer},children:f})},`${m.answer}_${v}`)),p==="loading"&&(0,pe.jsx)("p",{className:a.status,children:l("loading")}),p==="error"&&(0,pe.jsx)("p",{className:a.status,children:l("error")}),(0,pe.jsxs)("form",{className:a.form,onSubmit:g,children:[(0,pe.jsx)("input",{ref:i,placeholder:l("anotherQuestion"),className:a.input,type:"text",value:n,onFocus:()=>{r(void 0)},onChange:f=>{r(void 0),s(f.target.value)}}),(0,pe.jsx)("button",{type:"submit",className:a.submit,children:(0,pe.jsx)(Yl,{})})]})]})},ec=Qg;var fs=require("@reduxjs/toolkit");var Jg={data:null,fetchState:"idle"},pt=t=>t.profile.data,hs=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],Xo=(0,fs.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)}),Yg=(0,fs.createSlice)({name:"profile",initialState:Jg,reducers:{},extraReducers:t=>{t.addCase(Xo.pending,e=>{e.fetchState="loading"}).addCase(Xo.rejected,e=>{e.fetchState="error"}).addCase(Xo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),tc=Yg.reducer;var pc=require("react");var uc=require("react-redux");var Mt=require("@reduxjs/toolkit");var em=["{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(em.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function oc(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 p=a.charAt(0),g=0;do c=p?e.indexOf(p,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 d=c===-1?e.slice(n):e.slice(n,c);s.push(d),n=c}return s.join("")}function nc(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var rc={suggestions:[],fetchState:"idle",isInitialRequest:null},sc={default:rc},ic=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},ac=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")},ys=t=>t.textSuggestions,lc=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},vs=(0,Mt.createAction)("textSuggestions/refresh"),Ie=(0,Mt.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=Zt(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Ro(n),t);if(t==="default"){let d=i?l.filter(lc(a)):l;e.dispatch(Pe(d.slice(0,r)))}return l}),Zo=(0,Mt.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,{...Ro(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(lc(t))),i&&(l=l.map(d=>({...d,text:d.source!=="trie-with-typos"?oc(d.text,t):d.text}))),l=nc(l,r),e.dispatch(Pe(l)),l}),cc=(0,Mt.createSlice)({name:"textSuggestions",initialState:sc,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(Ie.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||rc;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(Ie.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(Ie.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Zo.pending,e=>{e.default.fetchState="loading"}).addCase(Zo.rejected,e=>{e.default.fetchState="error"}).addCase(Zo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(O,()=>sc)}}),{setTextSuggestions:Ax,setSuggestionState:Lx}=cc.actions,dc=cc.reducer;var jr=require("react-redux");var Ot=require("react/jsx-runtime"),om=({commands:t,onClick:e})=>{var a,l,c;let o=(0,uc.useDispatch)(),n=k(qo),s=(0,jr.useSelector)(pt),r=(0,jr.useSelector)(ys),i=((c=(l=(a=s==null?void 0:s.uiConfig)==null?void 0:a.search)==null?void 0:l.initialTypes)==null?void 0:c.filter(({isActive:d})=>d))||[];return(0,pc.useEffect)(()=>{i.forEach(({type:d})=>{(!r[d]||r[d].suggestions.length===0)&&o(Ie(d))})},[]),(0,Ot.jsxs)("div",{children:[t.length>0&&(0,Ot.jsx)(H.List,{heading:n("commands"),children:t.map((d,p)=>(0,Ot.jsx)(H.ListItem,{id:`command-${p}`,closeOnSelect:!1,onClick:d.onClick,children:d.label},d.label))}),i.map(({type:d,title:p})=>{var g;return(0,Ot.jsx)(H.List,{heading:p,orientation:"vertical",children:(g=r[d])==null?void 0:g.suggestions.map((u,f)=>(0,Ot.jsx)(H.ListItem,{id:`${d}-${f}`,closeOnSelect:!1,description:u.text,onClick:()=>e(u.text,u),"data-testid":"search-overlay-suggestion",children:u.title},`${u.id}-${u.text}`))},d)})]})},gc=om;var G=require("react/jsx-runtime"),sm=200,rm=5,im=4,mc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),am=()=>{let t=(0,Le.useDispatch)(),e=Ae(),o=k(qo),[n,s]=(0,ne.useState)(!1),[r,i]=(0,ne.useState)(""),a=(0,Le.useSelector)(Fa),l=(0,Le.useSelector)(pt),[c,d]=(0,ne.useState)(),p=(0,Le.useSelector)(ee),g=b("showSearch"),u=b("showEntitiesCommand"),f=b("showSummaryCommand"),m=b("showKnowledgeSearch"),v=b("showImageSearch"),T=b("searchTriggerKey"),_=(0,Le.useSelector)(ml),y=(0,Le.useSelector)(Ba),x=(0,Le.useSelector)(Ka),S=(0,Le.useSelector)(Ha),N=w=>jt(y.filter(Z=>Z.type===w.toUpperCase()),w),U=[{value:"PERSONAL",label:o("personalSuggestions"),list:N("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:N("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:N("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:N("IMAGE"),listOrientation:"horizontal",shouldShow:v}].filter(w=>w.shouldShow),V=[{label:o("entitiesClipboard"),onClick:()=>t(be("entities")),shouldShow:u&&mc(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(be("summary")),shouldShow:f&&mc(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(be("knowledgeAssist")),shouldShow:m}].filter(w=>w.shouldShow),B=(_==null?void 0:_.map(w=>({value:w.code.toUpperCase(),label:`${w.name}s`,list:N(w.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],P=(0,ne.useCallback)((0,fc.default)((w,Z)=>{t(Tt({query:w,type:Z,tags:["search-overlay"],size:c?50:20}))},sm),[c]),M=(0,ne.useCallback)((w,Z)=>{switch(Z.type){case"IMAGE":e.send(Sr,{suggestion:Z});break;default:e.send(eo,{text:w,suggestion:Z})}t(le(!1))},[t]),I=w=>{Fo(w.text),t(Q({name:"entity copied",data:{entity:w,type:"copy"}})),t(le(!1))},X=(0,ne.useCallback)(w=>{t(Q({name:"suggestion feedback",data:{text:w.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),rr=w=>{e.send(eo,{text:w,suggestion:{source:"knowledge-assist",text:w}}),t(Q({name:"answer used",data:{originalText:w},options:{includeConversationData:!0}})),i(""),t(be("search")),t(ao()),t(le(!1))},ir=w=>{Fo(w),t(le(!1))};function jt(w,Z){return w.slice(0,c?10:Z.toLowerCase()==="image"?im:rm)}function _t(w){return Z=>{n?window.confirm(o("warning"))&&(w(Z),s(!1)):w(Z)}}return(0,ne.useEffect)(()=>{r?P(r,c):t(Fn())},[r,c]),(0,ne.useEffect)(()=>{a==="search"&&t(ao())},[a]),(0,ne.useEffect)(()=>{p&&t(Ho())},[p]),Dl(T,()=>t(le(!0))),!g||!l?null:(0,G.jsxs)(H,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:_t(w=>t(le(w))),onChangeType:w=>d(w),onChangePage:_t(w=>t(be(w))),selectedType:c,search:r,page:a,isOpen:S,types:[...B,...U],children:[(0,G.jsxs)(H.Page,{id:"search",children:[r.length===0&&(0,G.jsx)(gc,{commands:V,onClick:M}),r.length>0&&(0,G.jsxs)(ne.Fragment,{children:[V.length>0&&(0,G.jsx)(H.List,{heading:o("commands"),children:V.map((w,Z)=>(0,G.jsx)(H.ListItem,{closeOnSelect:!1,onClick:w.onClick,id:`commands-${Z}`,children:w.label},w.label))}),[...B,...U].map(({value:w,label:Z,list:Li,lineClamp:au,listOrientation:lu})=>(0,G.jsx)(H.List,{heading:Z,orientation:lu==="horizontal"?"horizontal":"vertical",onShowAll:()=>d(w),hasMore:!c&&x[w.toLowerCase()]>jt(Li,w).length,children:jt(Li,w).map(re=>(0,G.jsx)(H.ListItem,{id:`${w}-${re.id}`,closeOnSelect:!1,lineClamp:au,onClick:()=>M(re.text,re),description:w!=="IMAGE"?re.title&&re.text:void 0,onFeedback:w!=="IMAGE"?()=>X(re):void 0,children:w==="IMAGE"?(0,G.jsx)(H.Image,{title:re.title||re.text,src:re.image}):re.title||re.text},`${re.id}-${re.text}`))},w))]})]}),(0,G.jsx)(H.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:_t(()=>{t(be("search"))}),children:(0,G.jsx)(Kl,{onCopy:I})}),(0,G.jsx)(H.Page,{id:"summary",title:o("summaryTitle"),onDismiss:_t(()=>{t(be("search"))}),children:(0,G.jsx)($l,{onCopy:ir})}),(0,G.jsx)(H.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:_t(()=>{t(ao()),t(be("search"))}),children:(0,G.jsx)(ec,{question:r,onUse:rr,onResetQuestion:()=>{t(ao()),i("")}})})]})},hc=am;var Qo=require("react/jsx-runtime"),lm=()=>{let t=b("showSearch"),e=b("isEmbedded");return(0,Qo.jsxs)(yc.Fragment,{children:[t&&(0,Qo.jsx)(hc,{}),e&&(0,Qo.jsx)(ul,{})]})},vc=lm;var bc=E(require("classnames")),wc=require("react-redux");var Ss=require("react/jsx-runtime"),Sc=({className:t})=>(0,Ss.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,Ss.jsx)("g",{children:(0,Ss.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
+ `,kt.MISSING_INTL_API,i);var x=o.getPluralRules(e,{type:d.pluralType}).select(g-(d.offset||0));y=d.options[x]||d.options.other}if(!y)throw new Tr(d.value,g,Object.keys(d.options),i);a.push.apply(a,No(y.value,e,o,n,s,g-(d.offset||0)));continue}}return Ju(a)}function eg(t,e){return e?ce(ce(ce({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=ce(ce({},t[n]),e[n]||{}),o},{})):t}function tg(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=eg(t[n],e[n]),o},ce({},t)):t}function Er(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function og(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Zn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,Bn([void 0],o,!1)))},{cache:Er(t.number),strategy:Qn.variadic}),getDateTimeFormat:Zn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,Bn([void 0],o,!1)))},{cache:Er(t.dateTime),strategy:Qn.variadic}),getPluralRules:Zn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,Bn([void 0],o,!1)))},{cache:Er(t.pluralRules),strategy:Qn.variadic})}}var rl=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 d=r.formatToParts(c);if(d.length===1)return d[0].value;var p=d.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 p.length<=1?p[0]||"":p},this.formatToParts=function(c){return No(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=Qa(i,["formatters"]);this.ast=t.__parse(e,ce(ce({},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=tg(t.formats,n),this.formatters=s&&s.formatters||og(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=el,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 ng(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var sg="dummy",kr=(0,Jn.createContext)(null);function k(t){let e=(0,Jn.useContext)(kr);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=ng(o,n);return r?new rl(r).format(s):(e!==sg&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var Yn=require("react");var il={root:"_root_1h19b_1",content:"_content_1h19b_24"};var Rr=require("react/jsx-runtime"),rg=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,onKeyDown:r,overlayAriaLabel:i,contentAriaLabel:a})=>{let l=(0,Yn.useRef)(null),c=h("Dialog",il),d=g=>{if(g.key==="Escape"){g.preventDefault(),g.stopPropagation(),s();return}r&&r(g)},p=g=>{g.target===l.current&&t&&n()};return(0,Yn.useEffect)(()=>{var g,u;!l.current||!t||!e||(u=(g=l.current)==null?void 0:g.querySelector("input, textarea"))==null||u.focus()},[t,e,l]),t?(0,Rr.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":i,ref:l,onKeyDown:d,onMouseDown:p,children:(0,Rr.jsx)("div",{"data-testid":"dialog-content",className:c.content,"aria-label":a,children:o})}):null},es=rg;var ll=E(require("classnames"));var al={root:"_root_1ukx5_1"};var cl=require("react/jsx-runtime"),ig=({className:t,value:e,...o})=>{let n=h("TextInput",al);return(0,cl.jsx)("input",{className:(0,ll.default)(t,n.root),type:"text",value:e,...o})},Do=ig;var Ir={};Y(Ir,{enUS:()=>ag,nlNL:()=>lg});var ag={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"}]},lg={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 dl={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 K=require("react/jsx-runtime");var cg=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},dg=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=k(Ir),i=h("LoginTokenDialog",dl),a=(0,os.useSelector)(ia),l=(0,os.useDispatch)(),c=b("productName"),[d,p]=(0,Ce.useState)(t||""),[g,u]=(0,Ce.useState)(0),[f,m]=(0,Ce.useState)(""),v=(0,Ce.useCallback)(async x=>{x.preventDefault(),l(la({email:d})),u(1)},[o,d]),T=()=>{m(""),u(0)},_=(0,Ce.useCallback)(async x=>{x.preventDefault();let S=cg(x.target.elements.token.value);if(!S){m(r("verifyCodeError",{login:y}));return}l(Eo({token:S}))},[o]),y=(0,Ce.useMemo)(()=>x=>(0,K.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:T,children:x},"back-button"),[]);return(0,Ce.useEffect)(()=>{a==="error"&&m(r("verifyCodeError",{login:y})),a==="done"&&n()},[a]),(0,K.jsx)(es,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:(0,K.jsxs)("div",{className:i.root,children:[(0,K.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:c})}),g===0&&(0,K.jsxs)("form",{onSubmit:v,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),(0,K.jsx)(Do,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:d,onChange:x=>p(x.target.value)}),(0,K.jsx)("div",{className:i.actions,children:(0,K.jsx)("button",{type:"submit",className:(0,ts.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),g===1&&(0,K.jsxs)("form",{onSubmit:_,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,K.jsx)(Do,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&(0,K.jsx)("div",{className:i.errorMessage,children:f}),(0,K.jsxs)("div",{className:i.actions,children:[(0,K.jsx)("button",{type:"button",className:(0,ts.default)(i.button),onClick:T,children:r("back")}),(0,K.jsx)("button",{type:"submit",className:(0,ts.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},pl=dg;var gl=require("react/jsx-runtime"),pg=()=>{let t=(0,Pr.useSelector)(aa),e=(0,Pr.useSelector)(Ma),o=b("adminUrl"),n=Ae(),s=()=>n.send(Yt,!1),r=()=>{n.send(Yt,!1),n.send(Po)};return(0,gl.jsx)(pl,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},ul=pg;var fc=E(require("lodash.debounce")),ne=require("react"),Le=require("react-redux");var ns=require("@reduxjs/toolkit");var ug={data:null,fetchState:"idle"},ml=t=>t.contentTypes.data,Ho=(0,ns.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),gg=(0,ns.createSlice)({name:"contentTypes",initialState:ug,reducers:{},extraReducers:t=>{t.addCase(Ho.pending,e=>{e.fetchState="loading"}).addCase(Ho.rejected,e=>{e.fetchState="error"}).addCase(Ho.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),fl=gg.reducer;function Fo(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 Ve=require("react");var hl=require("react"),ss=E(require("classnames"));var fe={root:"_root_1xtw7_1",list:"_list_1xtw7_2",listWrapper:"_listWrapper_1xtw7_6",listHorizontal:"_listHorizontal_1xtw7_10",page:"_page_1xtw7_19",search:"_search_1xtw7_25",pageNav:"_pageNav_1xtw7_33",pageTitle:"_pageTitle_1xtw7_41",pageBackButton:"_pageBackButton_1xtw7_48",listHeader:"_listHeader_1xtw7_62",listHeading:"_listHeading_1xtw7_68",listMoreButton:"_listMoreButton_1xtw7_76",listItem:"_listItem_1xtw7_87",listItemContent:"_listItemContent_1xtw7_96",listItemText:"_listItemText_1xtw7_114",listItemDescription:"_listItemDescription_1xtw7_122",listItemActions:"_listItemActions_1xtw7_129",truncate:"_truncate_1xtw7_140",lineClamp:"_lineClamp_1xtw7_146",listItemTitle:"_listItemTitle_1xtw7_153",listItemAction:"_listItemAction_1xtw7_129",listItemPrimaryAction:"_listItemPrimaryAction_1xtw7_178",listItemSelected:"_listItemSelected_1xtw7_183",sources:"_sources_1xtw7_187",sourcesTitle:"_sourcesTitle_1xtw7_194",source:"_source_1xtw7_187",icon:"_icon_1xtw7_209",searchIcon:"_searchIcon_1xtw7_226",searchInputWrapper:"_searchInputWrapper_1xtw7_231",searchInput:"_searchInput_1xtw7_231",select:"_select_1xtw7_252",selectType:"_selectType_1xtw7_269",selectWrapper:"_selectWrapper_1xtw7_273",image:"_image_1xtw7_303",imageSrc:"_imageSrc_1xtw7_310",imageSrcHidden:"_imageSrcHidden_1xtw7_321",imageSrcStatus:"_imageSrcStatus_1xtw7_325",imageTitle:"_imageTitle_1xtw7_335",actions:"_actions_1xtw7_340",actionsWrapper:"_actionsWrapper_1xtw7_344",actionsBar:"_actionsBar_1xtw7_350",actionButton:"_actionButton_1xtw7_359",hasShortKeys:"_hasShortKeys_1xtw7_372",actionShortcut:"_actionShortcut_1xtw7_381",actionShortcutFixKerning:"_actionShortcutFixKerning_1xtw7_388"};var Rt={};Y(Rt,{enUS:()=>mg,nlNL:()=>fg});var mg={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"}]},fg={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 lt=require("react/jsx-runtime"),hg=({src:t,title:e})=>{let o=h("CommandPalette",fe),[n,s]=(0,hl.useState)("loading"),r=k(Rt);return(0,lt.jsxs)("div",{className:o.image,children:[(0,lt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,ss.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,lt.jsx)("span",{className:(0,ss.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,lt.jsx)("span",{className:(0,ss.default)(o.imageSrc,o.imageSrcStatus),children:(0,lt.jsx)(yn,{})}),e&&(0,lt.jsx)("span",{className:o.imageTitle,children:e})]})},yl=hg;var vl=E(require("react")),Sl=E(require("classnames"));var It=require("react/jsx-runtime");function Ar({children:t,heading:e,orientation:o,hasMore:n,onShowAll:s}){let r=k(Rt),i=h("CommandPalette",fe);return vl.default.Children.count(t)===0?null:(0,It.jsxs)("div",{"data-testid":"commandpalette-list",className:i.list,children:[(e||n)&&(0,It.jsxs)("div",{className:i.listHeader,children:[e&&(0,It.jsx)("h4",{className:i.listHeading,children:e}),n&&s&&(0,It.jsx)("button",{onClick:s,className:i.listMoreButton,type:"button",children:r("showAll")})]}),(0,It.jsx)("div",{className:(0,Sl.default)(i.listWrapper,o==="horizontal"&&i.listHorizontal),children:t})]})}var Bo=E(require("classnames")),Pl=require("interweave");var yg=/[.*+?^${}()|[\]\\]/g,vg=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function Sg(t){return t.replace(yg,"\\$&")}function _g(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function xg(t){return t.search(vg)}function _l(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${Sg(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function xl(t){return t.replace(wn,'<mark data-type="placeholder">$1</mark>')}function to(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function bg(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 Lr(t,e,o={}){if(e){let n=_g(e.toLowerCase(),t.toLowerCase()),s=to(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=xg(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(Yi).length>3||e.length>30?bg(e.trim(),n):0;return`${`${i>0?"\u2026":""}${to(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var wg=/(<\/[a-zA-Z]+[0-9]?>|<[a-zA-Z]+\s?\/>|<br>)/i;function rs(t){return wg.test(t)}function bl(t){let e=document.createElement("template");return e.innerHTML=t,e.content.textContent??""}var W=E(require("react")),wl=E(require("classnames"));var Mr={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 Pt=require("react/jsx-runtime"),Cg=0,Cl=W.default.createContext(null),Tg=()=>{let t=(0,W.useContext)(Cl);if(!t)throw new Error("Invalid DropdownContext");return t},Tl=({trigger:t,children:e,position:o="bottom"})=>{let n=(0,W.useMemo)(()=>++Cg,[]),s=(0,W.useRef)(null),r=(0,W.useRef)(null),i=h("Dropdown",Mr),[a,l]=(0,W.useState)(!1),[c,d]=(0,W.useState)(o),p=u=>{u.preventDefault(),u.stopPropagation(),l(!a)},g=(0,W.useCallback)(([u])=>{!u.isIntersecting&&a&&d(c==="top"?"bottom":"top")},[a]);return(0,W.useEffect)(()=>{let u=f=>{s.current&&!s.current.contains(f.target)&&l(!1)};return document.addEventListener("click",u),()=>{document.removeEventListener("click",u)}},[]),(0,W.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,Pt.jsx)(Cl.Provider,{value:{setIsOpen:l},children:(0,Pt.jsxs)("div",{ref:s,className:i.root,children:[(0,Pt.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:p,children:t}),(0,Pt.jsx)("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:(0,wl.default)(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function Eg({as:t,children:e,onClick:o,...n}){let s=t||"button",r=h("Dropdown",Mr),{setIsOpen:i}=Tg(),a=l=>{i(!1),o(l),l.stopPropagation()};return(0,Pt.jsx)(s,{type:"button",className:r.item,onClick:a,...n,children:e})}Tl.Item=Eg;var Or=Tl;var Nr=require("react/jsx-runtime"),El=t=>(0,Nr.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:(0,Nr.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 At={};Y(At,{enUS:()=>kg,nlNL:()=>Rg});var kg={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"}]},Rg={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 is=require("react/jsx-runtime"),Ig="%0d%0a%0d%0a%0d%0a",Pg=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(Ig)}`},Ag=({suggestion:t,onFeedback:e})=>{let o=k(At),n=b("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:(0,is.jsx)(Or,{trigger:(0,is.jsx)(El,{"data-testid":"feedback-dropdown-trigger"}),children:(0,is.jsx)(Or.Item,{as:"a",href:Pg(n,t),onClick:e,children:o("giveFeedback")})})},as=Ag;var ls=E(require("react")),Il=require("react/jsx-runtime"),kl=ls.default.createContext(void 0);function ct(){let t=ls.default.useContext(kl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Rl=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=ls.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,Il.jsx)(kl.Provider,{value:i,children:t})};var de=require("react/jsx-runtime");function Dr({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onFeedback:s,onSourceClick:r,description:i,sources:a,id:l,styles:c,...d}){let{selected:p,onChangeOpen:g}=ct(),u=h("CommandPalette",fe);function f(m){n(m),t&&g(!1)}return(0,de.jsxs)("div",{className:(0,Bo.default)(u.listItem,l===p&&u.listItemSelected),children:[(0,de.jsx)("button",{type:"button",className:(0,Bo.default)(u.listItemAction,u.listItemPrimaryAction),"aria-disabled":d.disabled??!1,onClick:f,"data-command-palette-item":!0,"data-item-id":l,...d,children:(0,de.jsxs)("div",{className:u.listItemContent,children:[typeof o=="string"?(0,de.jsx)("p",{className:(0,Bo.default)(u.listItemText,u.truncate,c==null?void 0:c.title),children:o}):o,i&&(0,de.jsx)(Pl.Interweave,{tagName:"p",allowList:[],content:rs(i)?bl(i):i,className:(0,Bo.default)(u.listItemDescription,c==null?void 0:c.description,e?u.lineClamp:u.truncate)})]})}),s&&(0,de.jsx)("div",{className:u.listItemActions,children:(0,de.jsx)(as,{suggestion:String(o),onFeedback:s})}),a&&(0,de.jsxs)("div",{className:u.sources,children:[(0,de.jsx)("span",{className:u.sourcesTitle,children:"Sources"}),a.map(m=>m.url?(0,de.jsx)("a",{className:u.source,href:m.url,target:"_blank",title:m.url,rel:"noopener noreferrer",onClick:()=>r&&r(m),children:m.name},m.url):(0,de.jsx)("span",{className:u.source,children:m.name},m.name))]})]})}var Ko=require("react/jsx-runtime"),Al=()=>(0,Ko.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Ko.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Ko.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 Lt=require("react/jsx-runtime");function Hr({children:t,title:e,id:o,onDismiss:n}){let s=k(Rt),r=h("CommandPalette",fe),{page:i}=ct();return i!==o?null:(0,Lt.jsxs)("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,Lt.jsxs)("div",{className:r.pageNav,children:[(0,Lt.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:n,children:[(0,Lt.jsx)(Al,{}),s("back")]}),e&&(0,Lt.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var Ll=require("react");var Uo=require("react/jsx-runtime"),oo=()=>(0,Uo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Uo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Uo.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 Te=require("react/jsx-runtime");function Lg({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=h("CommandPalette",fe);return(0,Te.jsxs)("div",{className:l.search,children:[(0,Te.jsx)("div",{className:l.searchIcon,children:(0,Te.jsx)(oo,{})}),(0,Te.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Te.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,Te.jsx)("div",{className:l.selectWrapper,children:(0,Te.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,Te.jsx)("option",{children:n}),s.map(c=>(0,Te.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var Ml=(0,Ll.forwardRef)(Lg);var Fr=E(require("classnames"));var cs=require("react/jsx-runtime"),Mg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=h("CommandPalette",fe);return(0,cs.jsxs)("button",{type:"button",...n,onClick:t,className:(0,Fr.default)(s.actionButton,n.className,{[s.hasShortKeys]:e&&e.length>0}),children:[o,e&&e.map(r=>(0,cs.jsx)("span",{className:(0,Fr.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},Ol=Mg;var zo=require("react/jsx-runtime"),Og="[data-command-palette-item]";function no({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:d,isOpen:p,search:g}){let[u,f]=(0,Ve.useState)(),m=(0,Ve.useRef)(null),v=()=>{s&&s(o),i(void 0),r(""),a(!1)},T=()=>{var P;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(P=m.current)==null||P.focus();return}if(g.length>0){r("");return}a(!1)},_=()=>{let P=y();P.length!==0&&f(P[0].dataset.itemId)},y=()=>Array.from(document.querySelectorAll(Og)||[]),x=P=>document.querySelector(`[data-item-id=${P}]`),S=P=>{let M=x(P);M&&f(M.dataset.itemId)},N=P=>{let M=x(P);M&&M.scrollIntoView({behavior:"smooth"})},U=()=>{if(!u)return;let P=y(),M=x(u);if(!M)return;let R=P.indexOf(M),X=P[R+1];X&&X.dataset.itemId?S(X.dataset.itemId):_()},V=()=>{if(!u)return;let P=y(),M=x(u);if(!M)return;let R=P.indexOf(M),X=P[R-1];X&&X.dataset.itemId?S(X.dataset.itemId):S(P[P.length-1].dataset.itemId)},B=(0,Ve.useCallback)(P=>{switch(P.key){case"ArrowDown":{P.preventDefault(),U();break}case"ArrowUp":{P.preventDefault(),V();break}case"Enter":{if(u){let M=x(u);M==null||M.click()}break}}},[u]);return(0,Ve.useEffect)(()=>{_()},[g,n,l,p]),(0,Ve.useEffect)(()=>{u&&N(u)},[u]),(0,zo.jsx)(es,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:p,onBack:T,onClose:v,onKeyDown:B,children:(0,zo.jsxs)(Rl,{selected:u,setSelected:f,isOpen:p,onChangeOpen:a,page:n,children:[n===o&&(0,zo.jsx)(Ml,{ref:m,onChange:r,onChangeType:i,placeholder:t,value:g,selectedType:l,types:c,typePlaceholder:e}),d]})})}no.Page=Hr;no.List=Ar;no.Image=yl;no.ListItem=Dr;no.Button=Ol;var H=no;var Nl=require("react");function Dl(t,e){(0,Nl.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 qo=require("react"),us=require("react-redux");var ds=require("@reduxjs/toolkit");var Hl={data:null,fetchState:"idle"},ps=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},Ee=(0,ds.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)}),Ng=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Dg=(0,ds.createSlice)({name:"entities",initialState:Hl,reducers:{},extraReducers:t=>{t.addCase(Ee.pending,e=>{e.fetchState="loading"}).addCase(Ee.rejected,e=>{e.fetchState="error"}).addCase(Ee.fulfilled,(e,o)=>{e.fetchState="done",e.data=Ng(e.data?[...e.data,...o.payload]:o.payload)}).addCase(O,()=>Hl)}}),Fl=Dg.reducer;var Br={};Y(Br,{enUS:()=>Hg,nlNL:()=>Fg});var Hg={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Fg={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Bl={root:"_root_17kae_1",empty:"_empty_17kae_5"};var so=require("react/jsx-runtime"),Bg=({onCopy:t})=>{let e=(0,qo.useRef)(null),o=h("EntitiesList",Bl),n=(0,us.useSelector)(ps),{setSelected:s}=ct(),r=k(Br),i=(0,us.useDispatch)();return(0,qo.useEffect)(()=>{i(Ee())},[]),(0,qo.useEffect)(()=>{e.current&&(e.current.focus(),s("entity-0"))},[e]),(0,so.jsxs)("div",{className:o.root,ref:e,tabIndex:-1,children:[n&&n.length>0&&(0,so.jsx)(H.List,{children:n.map((a,l)=>(0,so.jsx)(H.ListItem,{id:`entity-${l}`,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities"),n&&n.length===0&&(0,so.jsx)("p",{className:o.empty,children:r("noResults")})]})},Kl=Bg;var ke=require("react"),jo=require("react-redux");var gs=require("@reduxjs/toolkit");var Ul={data:null,fetchState:"idle"},zl=t=>t.summary.data,ql=t=>t.summary.fetchState==="error",$e=(0,gs.createAsyncThunk)("summary/getSummary",async(t,e)=>{var d,p,g;let o=e.getState().profile.data,n=(d=e.getState().conversation.current)==null?void 0:d.sessionId,s=(g=(p=e.getState().info)==null?void 0:p.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"))}),Kg=(0,gs.createSlice)({name:"summary",initialState:Ul,reducers:{},extraReducers:t=>{t.addCase($e.pending,e=>{e.data=null,e.fetchState="loading"}).addCase($e.rejected,e=>{e.data=null,e.fetchState="error"}).addCase($e.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(O,()=>Ul)}}),jl=Kg.reducer;var Kr={};Y(Kr,{enUS:()=>Ug,nlNL:()=>zg});var Ug={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."}]},zg={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 Vl={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 We=require("react/jsx-runtime"),qg=({onCopy:t})=>{let e=(0,ke.useRef)(null),o=h("SummaryForm",Vl),[n,s]=(0,ke.useState)(""),r=k(Kr),i=(0,jo.useSelector)(zl),a=(0,jo.useSelector)(ql),l=(0,jo.useDispatch)(),c=()=>{l(Q({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},d=()=>{let p=document.getSelection();p&&l(Q({name:"summary copied to clipboard",data:{originalText:i,finalText:p==null?void 0:p.toString()},options:{includeConversationData:!0}}))};return(0,ke.useEffect)(()=>{l($e())},[]),(0,ke.useEffect)(()=>{s(i||"")},[i]),(0,ke.useEffect)(()=>{e.current&&i&&e.current.focus()},[e,i]),(0,ke.useEffect)(()=>{let p=g=>{g.key==="Enter"&&g.shiftKey&&c()};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p)}},[n]),(0,We.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,We.jsx)("p",{className:o.error,children:r("error")}):(0,We.jsxs)(ke.Fragment,{children:[(0,We.jsx)("div",{className:o.main,children:(0,We.jsx)("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:d,onChange:p=>s(p.target.value)})}),(0,We.jsx)("div",{className:o.actions,children:(0,We.jsx)(H.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},$l=qg;var Vo={};Y(Vo,{enUS:()=>jg,nlNL:()=>Vg});var jg={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?"}]},Vg={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 dt=E(require("react")),Go=require("react-redux");var Ur={};Y(Ur,{enUS:()=>$g,nlNL:()=>Wg});var $g={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"}]},Wg={use:[{type:0,value:"Gebruik"}],loading:[{type:0,value:"Laden..."}],error:[{type:0,value:"Er ging iets mis, probeer het later opnieuw."}],anotherQuestion:[{type:0,value:"Stuur een bericht..."}],reset:[{type:0,value:"Reset gesprek"}]};var Wl={root:"_root_1g4pq_1",title:"_title_1g4pq_9",empty:"_empty_1g4pq_20",status:"_status_1g4pq_24",form:"_form_1g4pq_30",input:"_input_1g4pq_43",submit:"_submit_1g4pq_55",question:"_question_1g4pq_63",answer:"_answer_1g4pq_67",alignRight:"_alignRight_1g4pq_73"};var io=require("@reduxjs/toolkit");var ms=require("@reduxjs/toolkit");var Gg={data:null,fetchState:"idle"},Gl=t=>{var e;return(e=t.knowledgeAssistant)==null?void 0:e.data},$o=(0,ms.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}),Xg=(0,ms.createSlice)({name:"knowledgeAssistant",initialState:Gg,reducers:{},extraReducers:t=>{t.addCase($o.pending,e=>{e.fetchState="loading"}).addCase($o.rejected,e=>{e.fetchState="error"}).addCase($o.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Xl=Xg.reducer;var zr={data:[],fetchState:"idle"},Zl=t=>{var e;return(e=t.answer)==null?void 0:e.data},Ql=t=>t.answer.fetchState,ao=(0,io.createAction)("answer/resetKnowledgeSearch"),ro=(0,io.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var l,c,d;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=Gl(e.getState()),r=(l=e.getState().conversation.current)==null?void 0:l.sessionId,i=(d=(c=e.getState().info)==null?void 0:c.agentInfo)==null?void 0:d.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}}),Zg=(0,io.createSlice)({name:"answer",initialState:zr,reducers:{},extraReducers:t=>{t.addCase(ro.pending,e=>{e.fetchState="loading"}).addCase(ro.rejected,e=>{e.fetchState="error"}).addCase(ro.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(O,()=>zr).addCase(ao,()=>zr)}}),Jl=Zg.reducer;var Wo=require("react/jsx-runtime"),Yl=()=>(0,Wo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Wo.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Wo.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 pe=require("react/jsx-runtime"),Qg=({onUse:t,onResetQuestion:e,question:o})=>{let[n,s]=dt.default.useState(""),{setSelected:r}=ct(),i=(0,dt.useRef)(null),a=h("EntitiesList",Wl),l=k(Ur),c=(0,Go.useDispatch)(),d=(0,Go.useSelector)(Zl),p=(0,Go.useSelector)(Ql),g=async f=>{f.preventDefault(),f.stopPropagation(),n!==""&&c(ro(n))},u=(f,m)=>{c(Q({name:"knowledge assist source viewed",data:{question:m,sourceViewed:f.url||f.name},options:{includeConversationData:!0}}))};return(0,dt.useEffect)(()=>{var f;o&&p==="idle"?c(ro(o)):(f=i.current)==null||f.focus()},[i,p]),(0,dt.useEffect)(()=>{p==="done"&&(c(Q({name:"knowledge assist question answered",data:{question:n||o,sources:d[d.length-1].answer.sources,answer:d[d.length-1].answer.answer,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),r(`knowledge-assist-${d.length-1}`),s(""))},[p,d]),(0,dt.useEffect)(()=>{i.current&&i.current.scrollIntoView({behavior:"smooth"})},[i,d]),(0,pe.jsxs)("div",{className:a.root,children:[d.length>0&&(0,pe.jsx)("div",{className:a.alignRight,children:(0,pe.jsx)(H.Button,{onClick:e,children:l("reset")})}),d.map(({question:f,answer:m},v)=>(0,pe.jsx)(H.List,{children:(0,pe.jsx)(H.ListItem,{id:`knowledge-assist-${v}`,"data-testid":"knowledge-search-answer",description:m.answer,closeOnSelect:!0,onClick:()=>t(m.answer),onSourceClick:T=>u(T,f),sources:m.sources,styles:{title:a.question,description:a.answer},children:f})},`${m.answer}_${v}`)),p==="loading"&&(0,pe.jsx)("p",{className:a.status,children:l("loading")}),p==="error"&&(0,pe.jsx)("p",{className:a.status,children:l("error")}),(0,pe.jsxs)("form",{className:a.form,onSubmit:g,children:[(0,pe.jsx)("input",{ref:i,placeholder:l("anotherQuestion"),className:a.input,type:"text",value:n,onFocus:()=>{r(void 0)},onChange:f=>{r(void 0),s(f.target.value)}}),(0,pe.jsx)("button",{type:"submit",className:a.submit,children:(0,pe.jsx)(Yl,{})})]})]})},ec=Qg;var fs=require("@reduxjs/toolkit");var Jg={data:null,fetchState:"idle"},pt=t=>t.profile.data,hs=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],Xo=(0,fs.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)}),Yg=(0,fs.createSlice)({name:"profile",initialState:Jg,reducers:{},extraReducers:t=>{t.addCase(Xo.pending,e=>{e.fetchState="loading"}).addCase(Xo.rejected,e=>{e.fetchState="error"}).addCase(Xo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),tc=Yg.reducer;var pc=require("react");var uc=require("react-redux");var Mt=require("@reduxjs/toolkit");var em=["{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(em.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function oc(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 p=a.charAt(0),g=0;do c=p?e.indexOf(p,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 d=c===-1?e.slice(n):e.slice(n,c);s.push(d),n=c}return s.join("")}function nc(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var rc={suggestions:[],fetchState:"idle",isInitialRequest:null},sc={default:rc},ic=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},ac=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")},ys=t=>t.textSuggestions,lc=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},vs=(0,Mt.createAction)("textSuggestions/refresh"),Re=(0,Mt.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=Zt(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Io(n),t);if(t==="default"){let d=i?l.filter(lc(a)):l;e.dispatch(Pe(d.slice(0,r)))}return l}),Zo=(0,Mt.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,{...Io(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(lc(t))),i&&(l=l.map(d=>({...d,text:d.source!=="trie-with-typos"?oc(d.text,t):d.text}))),l=nc(l,r),e.dispatch(Pe(l)),l}),cc=(0,Mt.createSlice)({name:"textSuggestions",initialState:sc,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(Re.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||rc;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(Re.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(Re.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Zo.pending,e=>{e.default.fetchState="loading"}).addCase(Zo.rejected,e=>{e.default.fetchState="error"}).addCase(Zo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(O,()=>sc)}}),{setTextSuggestions:Lx,setSuggestionState:Mx}=cc.actions,dc=cc.reducer;var qr=require("react-redux");var Ot=require("react/jsx-runtime"),om=({commands:t,onClick:e})=>{var a,l,c;let o=(0,uc.useDispatch)(),n=k(Vo),s=(0,qr.useSelector)(pt),r=(0,qr.useSelector)(ys),i=((c=(l=(a=s==null?void 0:s.uiConfig)==null?void 0:a.search)==null?void 0:l.initialTypes)==null?void 0:c.filter(({isActive:d})=>d))||[];return(0,pc.useEffect)(()=>{i.forEach(({type:d})=>{(!r[d]||r[d].suggestions.length===0)&&o(Re(d))})},[]),(0,Ot.jsxs)("div",{children:[t.length>0&&(0,Ot.jsx)(H.List,{heading:n("commands"),children:t.map((d,p)=>(0,Ot.jsx)(H.ListItem,{id:`command-${p}`,closeOnSelect:!1,onClick:d.onClick,children:d.label},d.label))}),i.map(({type:d,title:p})=>{var g;return(0,Ot.jsx)(H.List,{heading:p,orientation:"vertical",children:(g=r[d])==null?void 0:g.suggestions.map((u,f)=>(0,Ot.jsx)(H.ListItem,{id:`${d}-${f}`,closeOnSelect:!1,description:u.text,onClick:()=>e(u.text,u),"data-testid":"search-overlay-suggestion",children:u.title},`${u.id}-${u.text}`))},d)})]})},gc=om;var G=require("react/jsx-runtime"),sm=200,rm=5,im=4,mc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),am=()=>{let t=(0,Le.useDispatch)(),e=Ae(),o=k(Vo),[n,s]=(0,ne.useState)(!1),[r,i]=(0,ne.useState)(""),a=(0,Le.useSelector)(Fa),l=(0,Le.useSelector)(pt),[c,d]=(0,ne.useState)(),p=(0,Le.useSelector)(ee),g=b("showSearch"),u=b("showEntitiesCommand"),f=b("showSummaryCommand"),m=b("showKnowledgeSearch"),v=b("showImageSearch"),T=b("searchTriggerKey"),_=(0,Le.useSelector)(ml),y=(0,Le.useSelector)(Ba),x=(0,Le.useSelector)(Ka),S=(0,Le.useSelector)(Ha),N=w=>qt(y.filter(Z=>Z.type===w.toUpperCase()),w),U=[{value:"PERSONAL",label:o("personalSuggestions"),list:N("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:N("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:N("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:N("IMAGE"),listOrientation:"horizontal",shouldShow:v}].filter(w=>w.shouldShow),V=[{label:o("entitiesClipboard"),onClick:()=>t(be("entities")),shouldShow:u&&mc(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(be("summary")),shouldShow:f&&mc(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(be("knowledgeAssist")),shouldShow:m}].filter(w=>w.shouldShow),B=(_==null?void 0:_.map(w=>({value:w.code.toUpperCase(),label:`${w.name}s`,list:N(w.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],P=(0,ne.useCallback)((0,fc.default)((w,Z)=>{t(Tt({query:w,type:Z,tags:["search-overlay"],size:c?50:20}))},sm),[c]),M=(0,ne.useCallback)((w,Z)=>{switch(Z.type){case"IMAGE":e.send(Sr,{suggestion:Z});break;default:e.send(eo,{text:w,suggestion:Z})}t(le(!1))},[t]),R=w=>{Fo(w.text),t(Q({name:"entity copied",data:{entity:w,type:"copy"}})),t(le(!1))},X=(0,ne.useCallback)(w=>{t(Q({name:"suggestion feedback",data:{text:w.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),rr=w=>{e.send(eo,{text:w,suggestion:{source:"knowledge-assist",text:w}}),t(Q({name:"answer used",data:{originalText:w},options:{includeConversationData:!0}})),i(""),t(be("search")),t(ao()),t(le(!1))},ir=w=>{Fo(w),t(le(!1))};function qt(w,Z){return w.slice(0,c?10:Z.toLowerCase()==="image"?im:rm)}function _t(w){return Z=>{n?window.confirm(o("warning"))&&(w(Z),s(!1)):w(Z)}}return(0,ne.useEffect)(()=>{r?P(r,c):t(Fn())},[r,c]),(0,ne.useEffect)(()=>{a==="search"&&t(ao())},[a]),(0,ne.useEffect)(()=>{p&&t(Ho())},[p]),Dl(T,()=>t(le(!0))),!g||!l?null:(0,G.jsxs)(H,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:_t(w=>t(le(w))),onChangeType:w=>d(w),onChangePage:_t(w=>t(be(w))),selectedType:c,search:r,page:a,isOpen:S,types:[...B,...U],children:[(0,G.jsxs)(H.Page,{id:"search",children:[r.length===0&&(0,G.jsx)(gc,{commands:V,onClick:M}),r.length>0&&(0,G.jsxs)(ne.Fragment,{children:[V.length>0&&(0,G.jsx)(H.List,{heading:o("commands"),children:V.map((w,Z)=>(0,G.jsx)(H.ListItem,{closeOnSelect:!1,onClick:w.onClick,id:`commands-${Z}`,children:w.label},w.label))}),[...B,...U].map(({value:w,label:Z,list:Li,lineClamp:au,listOrientation:lu})=>(0,G.jsx)(H.List,{heading:Z,orientation:lu==="horizontal"?"horizontal":"vertical",onShowAll:()=>d(w),hasMore:!c&&x[w.toLowerCase()]>qt(Li,w).length,children:qt(Li,w).map(re=>(0,G.jsx)(H.ListItem,{id:`${w}-${re.id}`,closeOnSelect:!1,lineClamp:au,onClick:()=>M(re.text,re),description:w!=="IMAGE"?re.title&&re.text:void 0,onFeedback:w!=="IMAGE"?()=>X(re):void 0,children:w==="IMAGE"?(0,G.jsx)(H.Image,{title:re.title||re.text,src:re.image}):re.title||re.text},`${re.id}-${re.text}`))},w))]})]}),(0,G.jsx)(H.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:_t(()=>{t(be("search"))}),children:(0,G.jsx)(Kl,{onCopy:R})}),(0,G.jsx)(H.Page,{id:"summary",title:o("summaryTitle"),onDismiss:_t(()=>{t(be("search"))}),children:(0,G.jsx)($l,{onCopy:ir})}),(0,G.jsx)(H.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:_t(()=>{t(ao()),t(be("search"))}),children:(0,G.jsx)(ec,{question:r,onUse:rr,onResetQuestion:()=>{t(ao()),i("")}})})]})},hc=am;var Qo=require("react/jsx-runtime"),lm=()=>{let t=b("showSearch"),e=b("isEmbedded");return(0,Qo.jsxs)(yc.Fragment,{children:[t&&(0,Qo.jsx)(hc,{}),e&&(0,Qo.jsx)(ul,{})]})},vc=lm;var bc=E(require("classnames")),wc=require("react-redux");var Ss=require("react/jsx-runtime"),Sc=({className:t})=>(0,Ss.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,Ss.jsx)("g",{children:(0,Ss.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 Vr=require("react/jsx-runtime"),cm={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},_c=({className:t,color:e})=>(0,Vr.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Vr.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:cm[e||"pink"]})});var xc={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 qr={};Y(qr,{enUS:()=>dm,nlNL:()=>pm});var dm={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},pm={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Cc=require("react-redux"),Nt=require("react/jsx-runtime"),Tc=({onLogIn:t})=>{let e=k(qr),o=b("floatingMenu"),n=b("productName"),s=(0,Cc.useDispatch)(),r=(0,wc.useSelector)(ee),i=h("FloatingMenu",xc);if(r===null||o===!1)return null;let a=()=>{r===!0?s(le(!0)):t()};return(0,Nt.jsxs)("button",{className:(0,bc.default)(i.root,{[i.isLoggedIn]:r,[i.isLoggedOut]:!r}),onClick:a,children:[(0,Nt.jsx)("div",{className:i.text,children:e(r?"search":"signin",{productName:n})}),(0,Nt.jsxs)("div",{className:i.icon,children:[(0,Nt.jsx)(_c,{className:i.logo,color:"pink"}),r===!1&&(0,Nt.jsx)(Sc,{className:i.lock})]})]})};var Cs=require("react"),Ge=require("react-redux");var Ec=require("react");function lo(t){(0,Ec.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)}function co(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 kc=require("@reduxjs/toolkit"),um={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var _s=({ui:t})=>t.overlayCollapsed;var Ic=(0,kc.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:Jo,setInputHasFocus:$r,setOverlayCollapsed:ut,setOpenOverlayWhenTyping:Rc,setOverlayCollapsedUserOverwrite:Pc}=Ic.actions,Ac=Ic.reducer;var bs=require("react");var Nc=require("interweave"),po=require("react"),xs=require("react-redux");var Lc=require("react");function Mc(t,e,o){(0,Lc.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var Oc={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};var Ht=require("react/jsx-runtime"),mm=["search","personal-collection-search","search-autocomplete"];function fm(t,e,o,n={}){let s="";return mm.includes(e)?s=_l(Lr(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=Lr(t,o,n),n.placeholders===!0&&(s=xl(s)),s}var hm=()=>{},ym=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=b("inlineSuggestions"),r=(0,xs.useSelector)(Zt),i=(0,xs.useDispatch)(),a=h("TextSuggestion",Oc),l=(0,po.useRef)(null);(0,po.useEffect)(()=>{let d=setTimeout(()=>{i(Ca({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(d)}},[o]),Mc(l,"click",()=>{i(at(t)),i(xe({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=(0,po.useMemo)(()=>fm(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,Ht.jsxs)("div",{className:a.root,onMouseEnter:()=>i(at(t)),children:[(0,Ht.jsx)(L,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:hm,children:(0,Ht.jsx)(Nc.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&(0,Ht.jsx)("div",{className:a.actions,children:(0,Ht.jsx)(as,{onFeedback:()=>n(o),suggestion:o.text})})]})},Dc=ym;var Wr=require("react/jsx-runtime"),vm=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=(0,bs.useMemo)(()=>{let r=e.map((i,a)=>(0,Wr.jsx)(Dc,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return(0,Wr.jsx)(bs.Fragment,{children:s})},ws=vm;var Hc={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var Yo=require("react/jsx-runtime"),Sm=({textSuggestions:t,selectedIndex:e})=>{let o=(0,Cs.useRef)(null),n=h("InlineSuggestionsOverlay",Hc),s=(0,Ge.useSelector)(co),r=(0,Ge.useDispatch)(),i=(0,Ge.useSelector)(ee),a=(0,Ge.useSelector)(Xt),l=(0,Ge.useSelector)(_s),c=b("showTextSuggestions");return lo(()=>{setTimeout(()=>{r(ut({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Cs.useEffect)(()=>{let d=o.current;if(!d||!d.parentElement)return;d.parentElement.style.left="0px";let p=d.getBoundingClientRect();d.parentElement.style.left=`${Math.min(window.innerWidth-4-p.right,0)}px`}),l||!s||!c||t.length===0||i!==!0||a===!1?null:(0,Yo.jsx)("div",{className:n.root,"data-variant":"inline",children:(0,Yo.jsx)("div",{ref:o,className:n.paper,children:(0,Yo.jsx)(ae,{children:(0,Yo.jsx)(ws,{suggestions:t,selectedIndex:e})})})})},_m=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Fc=(0,Ge.connect)(_m)(Sm);var Bc=require("react-redux");var en=require("react/jsx-runtime"),xm=({children:t})=>{let o=b("locale").replace("-","");return(0,en.jsx)(kr.Provider,{value:o,children:t})},bm=({store:t,customStyles:e={},children:o})=>(0,en.jsx)(Bc.Provider,{store:t,children:(0,en.jsx)(xm,{children:(0,en.jsx)(_o.Provider,{value:e,children:o})})}),Ft=bm;var Es=E(require("classnames")),uo=require("react"),Me=require("react-redux");var Kc=require("react");function Uc(t,e){let[o,n]=(0,Kc.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return C.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){C.error(i)}}]}var zc=()=>/Mac/i.test(navigator.platform);var Vc=E(require("classnames")),Xe=require("react");var Gr={};Y(Gr,{enUS:()=>wm,nlNL:()=>Cm});var wm={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"}]}]},Cm={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 jc={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var gt=require("react/jsx-runtime"),Xr=(t,e,o)=>n=>(0,gt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),Tm=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=k(Gr),i=Ae(),a=h("Login",jc),l=b("productName"),c=(0,Xe.useCallback)(v=>{v.preventDefault(),n&&n(parseInt(v.target.value,10))},[]),d=(0,Xe.useCallback)(v=>{v.preventDefault(),i.send(Yt,!0)},[e]),p=(0,Xe.useMemo)(()=>v=>(0,gt.jsx)("a",{onClick:_=>{_.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:v},"login"),[e]),g=(0,Xe.useCallback)(v=>(0,gt.jsx)("button",{type:"button",className:a.anchorButton,onClick:d,children:v},"prompt"),[d]),{min:u,hour:f,day:m}=(0,Xe.useMemo)(()=>({min:Xr(a,60*10,c),hour:Xr(a,60*60,c),day:Xr(a,60*60*12,c)}),[]);return(0,gt.jsxs)("div",{className:(0,Vc.default)(t,a.root),children:[r("loginPlease",{login:o?g:p,productName:l}),n&&(0,gt.jsxs)(Xe.Fragment,{children:[(0,gt.jsx)("br",{}),r("snooze",{min:u,hour:f,day:m})]})]})},Ts=Tm;var $c=require("react-redux");var qc={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var tn=require("react/jsx-runtime"),Em=({title:t})=>{let e=h("SearchTrigger",qc),o=(0,$c.useDispatch)();return(0,tn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(le(!0)),children:[(0,tn.jsx)(oo,{}),(0,tn.jsx)("span",{className:e.text,children:t})]})},Wc=Em;var Zr={};Y(Zr,{enUS:()=>km,nlNL:()=>Im});var km={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"}]},Im={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 Gc={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"),Rm=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=h("SuggestionsOverlay",Gc),s=k(Zr),r=(0,Me.useSelector)(co),i=_a(),a=(0,Me.useDispatch)(),l=(0,uo.useRef)(null),c=b("searchTriggerKey"),d=b("productName"),p=(0,Me.useSelector)(_s),g=(0,Me.useSelector)(ee),u=(0,Me.useSelector)(Xt),[f,m]=(0,uo.useState)(null),v=b("showSearch"),T=b("showTextSuggestions"),_=b("adminUrl"),y=b("isEmbedded"),[x,S]=Uc("dd-snooze-until-ms",0),N=p||x>Date.now(),U=(0,Me.useSelector)(I=>I.input.text),V=t.filter(I=>I.source!=="gpt").length,B=()=>{N&&S(0),a(Pc(!N))},P=I=>{a(Q({name:"suggestion feedback",data:{text:I.text,source:"overlay",context:U},options:{includeConversationData:!0}}))},M=I=>{let X=Date.now()+I*1e3;S(X),C.info(`Snooze until: ${new Date(X)}`),a(ut({collapse:!0}))};return(0,uo.useEffect)(()=>{V===0&&m(null)},[t,V]),lo(()=>{a(ut({collapse:!0,skipWhenInputFocus:!0}))}),g===null||u===!1?null:g===!1?(0,F.jsxs)("div",{ref:l,className:(0,Es.default)(n.root,{[n.isCollapsed]:N}),children:[!N&&(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)(bt,{className:n.toggleButton,title:s("collapse"),onClick:B,isCollapsed:!1})})]}),(0,F.jsx)("div",{className:n.toggleButtonWrapper,children:(0,F.jsx)(bt,{className:n.toggleButton,title:s("open",{productName:d}),onClick:B,isCollapsed:!0})}),(0,F.jsx)("div",{className:n.collapsible,children:(0,F.jsx)(Ts,{loginUrl:_,isEmbedded:y,onLogIn:o,onSnooze:M})})]}):!i||!r?null:(0,F.jsxs)("div",{ref:l,className:(0,Es.default)(n.root,{[n.isCollapsed]:N}),children:[!N&&(0,F.jsxs)("div",{className:n.triggers,children:[(0,F.jsx)("div",{style:{flex:1},children:v&&(0,F.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>m(s(zc()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>m(null),children:(0,F.jsx)(Wc,{title:s("search")})})}),(0,F.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,F.jsx)("div",{className:(0,Es.default)(!f&&n.hintsHidden,n.hints),children:f}),(0,F.jsx)(bt,{className:n.toggleButton,title:s("collapse"),onClick:B,isCollapsed:!1})]})]}),(0,F.jsx)("div",{className:n.toggleButtonWrapper,children:(0,F.jsx)(bt,{className:n.toggleButton,title:s("open",{productName:d}),onClick:B,isCollapsed:!0})}),V>0&&T&&(0,F.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,F.jsx)(ae,{children:(0,F.jsx)(ws,{onFeedback:P,suggestions:t,selectedIndex:e,reverse:!0})})})]})},Pm=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Xc=(0,Me.connect)(Pm)(Rm);var zs=E(require("classnames")),_d=require("interweave"),Ye=require("react"),xd=require("react-redux");var go=require("react");function ks(t){return t.contentEditable==="true"}function Am(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 Zc(t){let{selectionStart:e,selectionEnd:o}=ks(t)?Am(t):t;return[e,o]}function Qc(t){let[,e]=(0,go.useState)(),o=(0,go.useRef)(null);return o.current=Zc(t),(0,go.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=Zc(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 Jc(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(wn);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 Yc=require("react"),Lm=["div","span","mark","strong","b","i","u","em"];function Qr(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(Lm.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,Yc.cloneElement)(n,{children:Qr(i,e,o+1)})]}return[...t,...e]}function mt(t){return t.tagName.toLowerCase()==="textarea"}var ed={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 dd=E(require("classnames")),pd=require("interweave"),Hs=require("react");var mo=require("react");function td(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function Is(t){let e=(0,mo.useRef)(null),[o,n]=(0,mo.useState)(!1);return(0,mo.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=td((d,p)=>{let g=e.current;if(!g)return;let u=d/r,f=p/r,m=g.getBoundingClientRect(),v=u>m.x&&u<m.x+m.width&&f>m.y&&f<m.y+m.height;v&&!s?(s=!0,n(!0)):!v&&s&&(s=!1,n(!1))},({clientX:d,clientY:p})=>[d,p]),[l,c]=td(()=>{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]}function od(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Rs(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function nd(t){return t!=null}var Yr=E(require("classnames")),he=require("react");var Ps=require("react"),Mm=["bottom","height","left","right","top","width"],Om=(t={},e={})=>Mm.some(o=>t[o]!==e[o]),Ze=new Map,sd,rd=()=>{let t=[],e=[];Ze.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Om(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Ze.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),sd=window.requestAnimationFrame(rd)};function Nm(t,e){return{observe(){let o=Ze.size===0;if(Ze.has(t)){let n=Ze.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Ze.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&rd()},unobserve(){let o=Ze.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Ze.delete(t),Ze.size||cancelAnimationFrame(sd)}}}}function Jr(t){let[e,o]=(0,Ps.useState)(null);return(0,Ps.useLayoutEffect)(()=>{if(!t.current)return;let n=Nm(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var fo=require("react"),ad=require("react-dom");var id={root:"_root_1jq08_1"};var ld=({children:t})=>{let[e,o]=(0,fo.useState)(null),n=(0,fo.useContext)(_o);return(0,fo.useLayoutEffect)(()=>{let s=document.createElement("div");return Dt(s),s.classList.add(id.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,ad.createPortal)(t,e):null};var Oe={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 As=require("react/jsx-runtime"),Ls=(t=!1)=>{let[e,o]=(0,he.useState)(t),n=(0,he.useCallback)(()=>o(!0),[]),s=(0,he.useCallback)(()=>o(!1),[]),r=(0,he.useCallback)(()=>o(a=>!a),[]),i=(0,he.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function ei(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 Ms=({className:t,triggerRef:e,boundaryRef:o=(0,he.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=ei,...a})=>{let l=Jr(e),c=Jr(o),d=(0,he.useMemo)(()=>i(l,c,0),[l,c]);return(0,As.jsx)(ld,{children:(0,As.jsx)("div",{className:(0,Yr.default)(Oe.ref,{[Oe.positionAbove]:n==="above",[Oe.positionBelow]:n==="below",[Oe.positionLeft]:n==="left",[Oe.positionRight]:n==="right",[Oe.alignStart]:s==="start",[Oe.alignCenter]:s==="center",[Oe.alignEnd]:s==="end"}),style:d,...a,role:"dialog",children:(0,As.jsx)("div",{className:(0,Yr.default)(t,Oe.root),children:r})})})};var cd=E(require("classnames")),Os=require("react");var Qe={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 ti=require("react/jsx-runtime"),Ns=(0,Os.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,Os.useRef)(null),r=h("TabCompletion",Qe);return(0,ti.jsx)("div",{ref:Rs([s,n]),className:(0,cd.default)(t,r.popoverContentContainer),...o,children:(0,ti.jsx)("div",{className:r.popoverContent,children:e})})});var ft=require("react/jsx-runtime"),Dm=t=>e=>{let o=ei(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Hm=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=h("TabCompletion",Qe),i=Ls(),a=(0,Hs.useMemo)(()=>Dm(t.getBoundingClientRect()),[t]),[l,c]=Is(t);return(0,Hs.useEffect)(()=>{c?i.open():i.close()},[c]),(0,ft.jsxs)("span",{children:[(0,ft.jsx)("mark",{ref:Rs([l,i.triggerRef]),className:(0,dd.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,ft.jsx)(Ms,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,ft.jsx)(Ns,{style:o,children:(0,ft.jsx)("div",{className:r.hintText,children:s})})})]})},Ds=class extends pd.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${od(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(nd);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,ft.jsx)(Hm,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var ud=require("interweave"),gd=E(require("classnames"));var oi=require("react/jsx-runtime"),Fm=({inputElement:t,children:e})=>{let o=h("TabCompletion",Qe),[n,s]=Is(t);return(0,oi.jsx)("mark",{ref:n,className:(0,gd.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},Fs=class extends ud.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,oi.jsx)(Fm,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Ks=E(require("classnames")),vd=require("interweave"),oe=require("react"),Sd=require("react-redux");var ni=require("react/jsx-runtime"),md=()=>(0,ni.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,ni.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 ht=require("react"),on=require("react-redux"),hd=E(require("lodash.debounce"));var fd={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Bs(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 si(t){return t.replace("https://www.","").replace("https://","")}var ye=require("react/jsx-runtime"),Bm=3,Km=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Um=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=Bm})=>{let r=h("LinkSearch",fd),[i,a]=(0,ht.useState)(""),l=(0,on.useDispatch)(),c=(0,on.useSelector)(ic("url")),d=(0,on.useSelector)(Ua("URL",Km)),[p,g]=(0,ht.useState)(d.length-1),u=b("fallbackImage"),f=_=>{let y=_.target;a(y.value)},m=(_,y)=>{_.stopPropagation(),_.preventDefault(),window.open(y,"_blank")},v=_=>{var S;let y=p-1<0?d.length-1:p-1,x=p+1===d.length?0:p+1;_.code==="Escape"&&(a(""),e()),_.code==="ArrowUp"&&g(y),_.code==="ArrowDown"&&g(x),_.code==="Enter"&&t(((S=d[p])==null?void 0:S.text)||i)},T=(0,ht.useCallback)((0,hd.default)(_=>{l(Tt({query:_,type:"URL",tags:["link-search"]}))},300),[]);return(0,ht.useEffect)(()=>{i&&T(i)},[i]),(0,ht.useEffect)(()=>()=>{l(Fn())},[]),(0,ye.jsxs)("div",{className:r.root,children:[(0,ye.jsx)(ae,{withDivider:!0,children:(i?d:c).slice(0,s).map((_,y)=>(0,ye.jsx)(L,{selected:p===y,onClick:()=>t(_.text),"data-testid":"linksearch-suggestion",children:(0,ye.jsxs)(D,{children:[(0,ye.jsx)(D.Image,{src:Bs(_,"small",u||void 0),title:_.title||_.text}),(0,ye.jsxs)(D.Content,{className:r.content,cropText:!0,children:[(0,ye.jsx)(D.Title,{children:_.title||si(_.text)}),_.title&&si(_.text)]}),(0,ye.jsx)(L.Actions,{children:(0,ye.jsx)(L.ActionButton,{label:n,onClick:x=>m(x,_.text)})})]})},_.text))}),(0,ye.jsx)(Do,{value:i,onChange:f,autoFocus:!0,placeholder:o,onKeyUp:v})]})},yd=Um;var ri={};Y(ri,{enUS:()=>zm,nlNL:()=>jm});var zm={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},jm={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var te=require("react/jsx-runtime"),Vm=(0,oe.forwardRef)((t,e)=>{let o=h("TabCompletion",Qe);return(0,te.jsx)("mark",{ref:e,className:(0,Ks.default)(o.matchSelection)},"selection-start")}),qm=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=k(ri),i=h("TabCompletion",Qe),a=(0,oe.useRef)(null),l=(0,oe.useRef)(null),[c,d]=(0,oe.useState)(null),p=(0,Sd.useDispatch)(),g=Ls(document.activeElement===n),[u]=(0,oe.useState)(()=>document.createRange());g.triggerRef.current=u,(0,oe.useEffect)(()=>()=>u.detach(),[]),(0,oe.useEffect)(()=>{let m=t.current,v=a.current;!m||!v||(u.setStart(m,0),u.setEnd(v,0))},[t.current,a.current]),lo(()=>{g.close()});let f=(0,oe.useCallback)(m=>{let v=u.toString(),T=/^http(s?):\/\//.test(m)?m:`https://${m}`;p(Ln({text:`[${v}](${T})`,replace:"selection"}))},[]);return(0,te.jsxs)("span",{children:[(0,te.jsx)("mark",{ref:a,className:(0,Ks.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":g.opened?"true":"false",children:s}),g.opened&&(0,te.jsx)(Ms,{className:i.popoverRoot,triggerRef:g.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,te.jsxs)(Ns,{style:o,ref:l,children:[(0,te.jsx)("div",{className:(0,Ks.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,te.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>d("insertLink"),children:[(0,te.jsx)(md,{}),(0,te.jsx)("span",{children:"\xA0"}),(0,te.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,te.jsx)(yd,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:f,onDismiss:()=>{d(null),g.close()}})]})})]},"selection-end")},Us=class extends vd.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,oe.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,te.jsx)(Vm,{ref:this.startRef}):(0,te.jsx)(qm,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var bd=require("react-redux");var Je=require("react/jsx-runtime"),$m=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=h("TabCompletion",ed),d=b("insertLink"),p=b("showMidSentenceSuggestions"),g=b("inlineSuggestions"),u=Qc(a),f=(0,Ye.useRef)(null),m=(0,bd.useSelector)(ee);(0,Ye.useEffect)(()=>{mt(a)&&u&&Jc(a,u)},[u]);let v=(0,Ye.useCallback)(y=>{if(!s||!o)return y;let x=[(0,Je.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,Je.jsx)("span",{"data-testid":"tab-completion",className:(0,zs.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&x.push((0,Je.jsx)("span",{className:(0,zs.default)(c.hint,c.resetIndent),children:(0,Je.jsx)(Sn,{keyCode:"tab"},"tabHint")})),Qr(y,x)},[s,o,n]),T=(0,Ye.useMemo)(()=>{let y=[];return d&&y.push(new Us("selection")),y.push(new Fs("placeholders")),r&&y.push(new Ds("keywords")),y},[g,d,r]),_=(0,Ye.useMemo)(()=>{let y=window.getComputedStyle(a);return{"--dd-color":y.color,"--dd-font-size":y.fontSize,"--dd-font-family":y.fontFamily,"--dd-font-variant":y.fontVariant}},[]);return!t||!m?null:(0,Je.jsxs)("div",{ref:y=>{y!=null&&y.parentElement&&(f.current=y==null?void 0:y.parentElement)},className:c.root,style:_,children:[(0,Je.jsx)(_d.Interweave,{tagName:"span",containerTagName:"div",className:(0,zs.default)(c.container,c.agentText),disableLineBreaks:mt(a),content:e||"\u200B",onAfterParse:v,matchers:T,selection:u,keywordMatches:i,inputElement:a,inputStyle:_,boundaryRef:f,inlineSuggestionsOnlyAtEnd:!p}),(0,Je.jsx)("br",{})]})},Wm=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var m;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??to(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:d}=e,{isSupported:p}=s,{showTabCompletion:g,visible:u,showStyleSuggestions:f}=o;return{showTabHint:d,showStyleSuggestions:f,showTabCompletion:g,content:l,tabText:c,source:a,keywordMatches:((m=n.list)==null?void 0:m.keywordMatches)??[],enabled:u&&p!==!1}},wd=(0,xd.connect)(Wm)($m);var hp=E(require("classnames")),yp=require("react"),$=require("react-redux");var yt=require("@reduxjs/toolkit");var Cd={list:[],fetchState:"idle",isInitialRequest:null},Ed=t=>t.autoflows.list||[],Td=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},et=(0,yt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),ii=(0,yt.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(et(t.platformSessionId))}),ai=(0,yt.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(et(t.platformSessionId))}),Gm=(0,yt.createSlice)({name:"autoflows",initialState:Cd,reducers:{},extraReducers:t=>{t.addCase(ii.pending,(e,o)=>{let n=Td(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(ai.pending,(e,o)=>{let n=Td(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(et.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(et.rejected,e=>{e.fetchState="error"}),t.addCase(et.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(O,()=>Cd)}}),kd=(0,yt.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(et(t))}),s.on("sessionCompleted",()=>{o(et(t))})}),Id=(0,yt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Rd=Gm.reducer;var vt=require("@reduxjs/toolkit");var Pd={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Ad=t=>t.customMessages.list,Ld=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Md=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Od=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),nn=(0,vt.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),js=(0,vt.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)}),Vs=(0,vt.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)}),Nd=(0,vt.createSlice)({name:"customMessages",initialState:Pd,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(nn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(nn.rejected,e=>{e.fetchState="error"}).addCase(nn.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(js.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(js.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(Vs.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(Vs.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(O,()=>Pd)}}),Dd=(0,vt.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(Nd.actions.onCustomMessage(r))})}),Hd=(0,vt.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Fd=Nd.reducer;var sn=require("@reduxjs/toolkit"),Xm={token:null,accountUrl:null,interval:null},Bd=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},li=(0,sn.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),ci=(0,sn.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(li()),setInterval(()=>n(li()),o)}),Kd=(0,sn.createSlice)({name:"passwordlessToken",initialState:Xm,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(li.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(ci.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:Ud}=Kd.actions,zd=Kd.reducer;function jd(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var Jd=require("react"),Yd=require("react-redux");var Xd=E(require("classnames")),Zd=require("react");var qd=E(require("classnames"));var Vd={root:"_root_838fd_1"};var Wd=require("react/jsx-runtime"),Zm=({className:t,children:e})=>{let o=h("Unicode",Vd);return(0,Wd.jsx)("span",{className:(0,qd.default)(t,o.root),children:e})},$d=Zm;var Gd={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 di={};Y(di,{enUS:()=>Qm,nlNL:()=>Jm});var Qm={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"}]},Jm={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 ue=require("react/jsx-runtime"),ef=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=h("Autoflow",Gd),a=k(di),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,ue.jsxs)(L,{className:(0,Xd.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,ue.jsx)(D,{children:(0,ue.jsxs)(D.Content,{children:[(0,ue.jsxs)(D.Title,{children:[e&&(0,ue.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,ue.jsx)("span",{children:n})]})}),(0,ue.jsx)(L.Actions,{fixed:e==="Started",children:(0,ue.jsx)(L.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,ue.jsxs)(Zd.Fragment,{children:[(0,ue.jsx)($d,{children:c})," ",(0,ue.jsx)("span",{children:a(l)})]})})})]})},Qd=ef;var pi=require("react/jsx-runtime"),tf=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},of=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,pi.jsx)(Jd.Fragment,{children:t.map(s=>(0,pi.jsx)(Qd,{displayName:s.displayName,description:s.description,disabled:s.isBusy||tf(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),nf=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},sf={onStartAutoflow:ii,onStopAutoflow:ai},ep=(0,Yd.connect)(nf,sf)(of);var tp=E(require("classnames")),ui=require("react"),Bt=require("react-redux");var tt={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 se=require("react/jsx-runtime"),rf=({suggestion:t})=>{let e=k(At),o=(0,Bt.useDispatch)(),n=(0,Bt.useSelector)(Ld(t.text)),s=(0,Bt.useSelector)(Md(t.text)),r=(0,Bt.useSelector)(Od(t.text)),i=(0,Bt.useSelector)(Tn),{replyOptions:a}=t,l=(0,ui.useCallback)(d=>{d.preventDefault(),d.stopPropagation(),!(n||!i)&&o(js({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,ui.useCallback)(d=>{if(d.preventDefault(),d.stopPropagation(),!i||!a)return;let p=parseInt(d.target.dataset.index,10),g=a[p];o(Vs({platformSessionId:i,reply:g,suggestion:t}))},[t,n,o,i]);return(0,se.jsxs)(L,{onClick:l,className:(0,tp.default)(tt.root,{[tt.isUsed]:n,[tt.hasError]:r}),children:[(0,se.jsx)(D,{children:(0,se.jsxs)(D.Content,{children:[(0,se.jsxs)(D.Title,{className:tt.title,children:[t.text," ",(0,se.jsx)(_n,{className:tt.label,children:"analyse tool"})," ",r&&(0,se.jsx)("span",{className:tt.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,se.jsx)("ul",{className:tt.quickReplies,children:a.map(d=>(0,se.jsx)("li",{className:tt.quickReply,children:d.title},d.title))})]})}),(0,se.jsxs)(L.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,se.jsx)(L.DropdownButton,{label:e("answer"),disabled:s,children:a.map((d,p)=>(0,se.jsx)(L.DropdownItem,{index:p,label:d.title,onClick:c},d.title))}),(0,se.jsx)(L.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},op=rf;var qs=require("react"),sp=require("react-redux"),fi=E(require("classnames"));var gi=require("react/jsx-runtime"),mi=()=>(0,gi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,gi.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 np={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 Ne=require("react/jsx-runtime"),af=({entities:t})=>{let e=h("EntitiesWidgetList",np),[o,n]=(0,qs.useState)(void 0),s=(0,sp.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),Fo(a.text),s(Q({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,qs.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,Ne.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,Ne.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Ne.jsx)("span",{className:e.entityText,children:a.text}),(0,Ne.jsxs)("span",{className:e.iconWrapper,children:[(0,Ne.jsx)("span",{className:(0,fi.default)(e.icon),children:(0,Ne.jsx)(mi,{})}),(0,Ne.jsx)("span",{className:(0,fi.default)(e.icon,o===l&&e.iconClicked),children:(0,Ne.jsx)(mi,{})})]})]},a.text))})},rp=af;var hi=require("react/jsx-runtime"),ip=()=>(0,hi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,hi.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 yi=require("react/jsx-runtime"),ap=()=>(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:"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 vi=require("react/jsx-runtime"),lp=()=>(0,vi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,vi.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 $s=require("react");var Si={};Y(Si,{enUS:()=>lf,nlNL:()=>cf});var lf={copyCue:[{type:0,value:"Copy"}],copiedCue:[{type:0,value:"Copied!"}],removeCue:[{type:0,value:"Close"}]},cf={copyCue:[{type:0,value:"Kopieer"}],copiedCue:[{type:0,value:"Gekopieerd!"}],removeCue:[{type:0,value:"Sluiten"}]};var ot=require("react/jsx-runtime"),df=({cue:t,onRemove:e,onCopy:o})=>{let n=k(Si),[s,r]=(0,$s.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,$s.useEffect)(()=>{if(!s)return;let l=setTimeout(()=>{r(!1)},1e3);return()=>{clearTimeout(l)}},[s]),(0,ot.jsx)(L,{"data-testid":"cue",children:(0,ot.jsxs)(D,{children:[(0,ot.jsxs)(D.Content,{children:[t.title&&(0,ot.jsx)(D.Title,{"data-testid":"widget-cue-title",children:t.title}),t.text]}),(0,ot.jsx)(L.Actions,{children:o&&(0,ot.jsx)(L.ActionButton,{primary:!0,onClick:i,label:n(s?"copiedCue":"copyCue")})}),(0,ot.jsx)(D.CloseIcon,{title:n("removeCue"),onClick:a})]})})},cp=df;var rn=require("react/jsx-runtime"),pf=({cues:t,onCopyCue:e,onRemoveCue:o})=>(0,rn.jsx)(rn.Fragment,{children:t.map(n=>(0,rn.jsx)(cp,{cue:n,onRemove:o,onCopy:e},`${n.id}_${n.timestamp}`))}),dp=pf;var up=require("react");var uf=/(https?:\/\/[^\s]+)/,pp=t=>t.split(" ").find(e=>uf.test(e));var ve=require("react/jsx-runtime"),gf=({suggestion:t,lines:e,onUse:o})=>{var d;let n=t.text||t.url||t.message,s=pp(n),r=k(At),i=b("showImages"),a=b("fallbackImage"),l=p=>{p.preventDefault(),p.stopPropagation(),o(n)},c=(0,up.useCallback)(p=>{window.open(s,"_blank"),p.stopPropagation(),p.preventDefault()},[s]);return(0,ve.jsxs)(L,{onClick:l,"data-testid":"edit-suggestion",children:[(0,ve.jsxs)(D,{children:[i&&t.image&&(0,ve.jsx)(D.Image,{src:Bs(t,"small",a||void 0),title:t.title}),(0,ve.jsxs)(D.Content,{children:[t.title&&(0,ve.jsx)(D.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((d=t.searchKeywords)==null?void 0:d.length)>0&&(0,ve.jsx)(L.Labels,{labels:t.searchKeywords}),(0,ve.jsx)(D.Content,{cropText:e==="single",lineClamp:e==="multiple",children:n})]})]}),(0,ve.jsxs)(L.Actions,{children:[s&&(0,ve.jsx)(L.ActionButton,{onClick:c,label:r("visitUrl")}),(0,ve.jsx)(L.ActionButton,{primary:!0,onClick:l,label:r("useSuggestion")})]})]})},gp=gf;var an=require("react/jsx-runtime"),mf=({lines:t,suggestions:e})=>{let o=Ae(),n=(s,r)=>{o.send(eo,{text:s,suggestion:{...r,source:r.source,sourceText:r.text}})};return(0,an.jsx)(an.Fragment,{children:e.map(s=>(0,an.jsx)(gp,{suggestion:s,lines:t,onUse:r=>n(r,s)},s.text||s.url||s.message))})},mp=mf;var _i={};Y(_i,{enUS:()=>ff,nlNL:()=>hf});var ff={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"}]},hf={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 fp={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 R=require("react/jsx-runtime"),Ws=(t,e)=>{let o=(0,$.useSelector)(ee);(0,yp.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},yf=({onLogIn:t})=>{let e=k(_i),o=(0,$.useDispatch)(),n=b("isEmbedded"),s=h("Widget",fp),r=b("showAutoflows"),i=b("showCustomMessages"),a=b("showSummaryCommand"),l=b("showKnowledgeSearch"),c=b("showSearch"),d=(0,$.useSelector)(pt),p=(0,$.useSelector)(hs),g=(0,$.useSelector)(Ed),u=(0,$.useSelector)(Va),f=(0,$.useSelector)(ps),m=(0,$.useSelector)(Ad),v=(0,$.useSelector)(En),T=(0,$.useSelector)(Xt),_=(0,$.useSelector)(ee),y=(0,$.useSelector)(Tn),x=(0,$.useSelector)(jd),S=(0,$.useSelector)(ys),N=Ae(),U=(0,$.useSelector)(ac),V=(0,$.useSelector)(Bd("/admin/")),B=b("adminUrl"),P=b("productName");if(Ws(()=>(o(nn(y)),o(Dd(y)),()=>{o(Hd(y))}),[o,T,i,y]),Ws(()=>(o(et(y)),o(kd(y)),()=>{o(Id(y))}),[o,T,r,y]),Ws(()=>{p.forEach(({type:I})=>{o(I==="entities"?Ee():Ie(I))})},[o,T,v,d]),Ws(()=>(o(ci()),()=>{o(Ud())}),[o]),T===!1)return(0,R.jsx)("div",{className:s.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:e("notSupported")})})},"supported");if(_===!1)return(0,R.jsx)("div",{className:s.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(Ts,{isEmbedded:n,loginUrl:B,onLogIn:t})})},"login");if(!d||!y||_===null||U||x)return(0,R.jsx)("div",{className:s.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:e("waiting")})})},"waiting");let M=c||a||l||V;return(0,R.jsx)("div",{className:(0,hp.default)(s.root),"data-testid":"widget",children:(0,R.jsxs)(xn,{className:s.sectionList,children:[M&&(0,R.jsx)(Be,{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:()=>N.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(oo,{}),e("linkSearch")]}),a&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-summary",onClick:()=>N.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(lp,{}),e("linkSummary")]}),l&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>N.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,R.jsx)(ap,{}),e("linkKnowledgeSearch")]}),V&&(0,R.jsxs)("a",{className:s.shortcut,target:"_blank",href:V,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[(0,R.jsx)(ip,{}),e("linkStudioLogin",{productName:P})]})]})}),i&&m.length>0&&(0,R.jsx)(Be,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(ae,{withDivider:!0,children:m.map(I=>(0,R.jsx)(op,{suggestion:I},I.text))})}),r&&g.length>0&&(0,R.jsx)(Be,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(ae,{withDivider:!0,children:(0,R.jsx)(ep,{})})}),p.map(({type:I,title:X,amount:rr,lines:ir})=>{var jt;switch(I){case"entities":return f&&f.length>0&&(0,R.jsx)(Be,{type:I,title:X,"data-testid":`type-${I}`,children:(0,R.jsx)(rp,{entities:f})},I);case"cues":return u&&u.length>0&&(0,R.jsx)(Be,{type:I,title:X,"data-testid":`type-${I}`,children:(0,R.jsx)(ae,{withDivider:!0,children:(0,R.jsx)(dp,{cues:u,onRemoveCue:_t=>o($a({id:_t}))})})},I);default:return((jt=S[I])==null?void 0:jt.fetchState)==="done"&&S[I].suggestions.length>0&&(0,R.jsx)(Be,{type:I,title:X,"data-testid":`type-${I}`,children:(0,R.jsx)(ae,{withDivider:!0,children:(0,R.jsx)(mp,{lines:ir,contentType:I,suggestions:S[I].suggestions.slice(0,rr)||[]})})},I)}})]})})},vp=yf;function ho(t){let e=new Range;return e.selectNodeContents(t),e}function Sp(t,e,o){try{return St(t,e,o),!0}catch{return!1}}function Gs(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function Xs(t){return"tagName"in t&&t.tagName==="BR"}var ln=/[\u200B-\u200D\uFEFF]/g;function St(t,e,o){let n=new Range;if(t.firstChild===null&&e===0&&o===0)return n.selectNodeContents(t),n;let s=0,r=!1;function i(l,c){let d=-1,p=/[\u200B-\u200D\uFEFF]/;if(!p.test(l))return c;for(let g=0;g<=l.length;g++)if(p.test(l[g])||d++,d===c)return g;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,d=c.replace(ln,""),p=s+d.length,g=e>=s&&e<=p,u=o>=s&&o<=p;if(g){let f=i(c,e-s);f===0&&!u?n.setStartBefore(l):n.setStart(l,f)}u&&(n.setEnd(l,i(c,o-s)),r=!0),s=p;break}case Node.ELEMENT_NODE:{if(Xs(l)&&(s===e&&n.setStartBefore(l),s++,s===o)){n.setEndAfter(l),r=!0;return}for(let d=0;d<l.childNodes.length&&(a(l.childNodes[d]),!r);d++);let c=l.lastChild;Gs(l)&&c&&!Gs(c)&&!Xs(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 d(p){let g=p===o,u=p===s;switch(p.nodeType){case Node.TEXT_NODE:{let f=p.textContent;g&&(a=c+f.substring(0,n).replace(ln,"").length),u&&(l=c+f.substring(0,r).replace(ln,"").length),c+=f.replace(ln,"").length;break}case Node.ELEMENT_NODE:{let f=p.nextSibling===null;Xs(p)&&!f&&c++;for(let m=0;m<p.childNodes.length;m++){let v=g&&m===n,T=u&&m===r;if(v&&(a=c),T&&(l=c),l!==void 0||((!v||!i)&&d(p.childNodes[m]),u&&m===r-1&&(l=c),l!==void 0))break}!u&&Gs(p)&&!f&&c++,u&&(l=c);break}default:break}}if(d(t),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function dn(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 d=c===o,p=c===s;switch(d&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let g=d?n:0,u=p?r:void 0,f=c.textContent.replace(ln,"");g===0&&u===void 0?a+=f:a+=f.substring(g,u);break}case Node.ELEMENT_NODE:{let g=c.nextSibling===null;i===0&&Xs(c)&&!g&&(a+=`
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 jr=require("react/jsx-runtime"),cm={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},_c=({className:t,color:e})=>(0,jr.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,jr.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:cm[e||"pink"]})});var xc={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 Vr={};Y(Vr,{enUS:()=>dm,nlNL:()=>pm});var dm={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},pm={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Cc=require("react-redux"),Nt=require("react/jsx-runtime"),Tc=({onLogIn:t})=>{let e=k(Vr),o=b("floatingMenu"),n=b("productName"),s=(0,Cc.useDispatch)(),r=(0,wc.useSelector)(ee),i=h("FloatingMenu",xc);if(r===null||o===!1)return null;let a=()=>{r===!0?s(le(!0)):t()};return(0,Nt.jsxs)("button",{className:(0,bc.default)(i.root,{[i.isLoggedIn]:r,[i.isLoggedOut]:!r}),onClick:a,children:[(0,Nt.jsx)("div",{className:i.text,children:e(r?"search":"signin",{productName:n})}),(0,Nt.jsxs)("div",{className:i.icon,children:[(0,Nt.jsx)(_c,{className:i.logo,color:"pink"}),r===!1&&(0,Nt.jsx)(Sc,{className:i.lock})]})]})};var Cs=require("react"),Ge=require("react-redux");var Ec=require("react");function lo(t){(0,Ec.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)}function co(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 kc=require("@reduxjs/toolkit"),um={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var _s=({ui:t})=>t.overlayCollapsed;var Rc=(0,kc.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:Jo,setInputHasFocus:$r,setOverlayCollapsed:ut,setOpenOverlayWhenTyping:Ic,setOverlayCollapsedUserOverwrite:Pc}=Rc.actions,Ac=Rc.reducer;var bs=require("react");var Nc=require("interweave"),po=require("react"),xs=require("react-redux");var Lc=require("react");function Mc(t,e,o){(0,Lc.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var Oc={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};var Ht=require("react/jsx-runtime"),mm=["search","personal-collection-search","search-autocomplete"];function fm(t,e,o,n={}){let s="";return mm.includes(e)?s=_l(Lr(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=Lr(t,o,n),n.placeholders===!0&&(s=xl(s)),s}var hm=()=>{},ym=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=b("inlineSuggestions"),r=(0,xs.useSelector)(Zt),i=(0,xs.useDispatch)(),a=h("TextSuggestion",Oc),l=(0,po.useRef)(null);(0,po.useEffect)(()=>{let d=setTimeout(()=>{i(Ca({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(d)}},[o]),Mc(l,"click",()=>{i(at(t)),i(xe({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=(0,po.useMemo)(()=>fm(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,Ht.jsxs)("div",{className:a.root,onMouseEnter:()=>i(at(t)),children:[(0,Ht.jsx)(L,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:hm,children:(0,Ht.jsx)(Nc.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&(0,Ht.jsx)("div",{className:a.actions,children:(0,Ht.jsx)(as,{onFeedback:()=>n(o),suggestion:o.text})})]})},Dc=ym;var Wr=require("react/jsx-runtime"),vm=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=(0,bs.useMemo)(()=>{let r=e.map((i,a)=>(0,Wr.jsx)(Dc,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return(0,Wr.jsx)(bs.Fragment,{children:s})},ws=vm;var Hc={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var Yo=require("react/jsx-runtime"),Sm=({textSuggestions:t,selectedIndex:e})=>{let o=(0,Cs.useRef)(null),n=h("InlineSuggestionsOverlay",Hc),s=(0,Ge.useSelector)(co),r=(0,Ge.useDispatch)(),i=(0,Ge.useSelector)(ee),a=(0,Ge.useSelector)(Xt),l=(0,Ge.useSelector)(_s),c=b("showTextSuggestions");return lo(()=>{setTimeout(()=>{r(ut({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Cs.useEffect)(()=>{let d=o.current;if(!d||!d.parentElement)return;d.parentElement.style.left="0px";let p=d.getBoundingClientRect();d.parentElement.style.left=`${Math.min(window.innerWidth-4-p.right,0)}px`}),l||!s||!c||t.length===0||i!==!0||a===!1?null:(0,Yo.jsx)("div",{className:n.root,"data-variant":"inline",children:(0,Yo.jsx)("div",{ref:o,className:n.paper,children:(0,Yo.jsx)(ae,{children:(0,Yo.jsx)(ws,{suggestions:t,selectedIndex:e})})})})},_m=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Fc=(0,Ge.connect)(_m)(Sm);var Bc=require("react-redux");var en=require("react/jsx-runtime"),xm=({children:t})=>{let o=b("locale").replace("-","");return(0,en.jsx)(kr.Provider,{value:o,children:t})},bm=({store:t,customStyles:e={},children:o})=>(0,en.jsx)(Bc.Provider,{store:t,children:(0,en.jsx)(xm,{children:(0,en.jsx)(_o.Provider,{value:e,children:o})})}),Ft=bm;var Es=E(require("classnames")),uo=require("react"),Me=require("react-redux");var Kc=require("react");function Uc(t,e){let[o,n]=(0,Kc.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return C.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){C.error(i)}}]}var zc=()=>/Mac/i.test(navigator.platform);var jc=E(require("classnames")),Xe=require("react");var Gr={};Y(Gr,{enUS:()=>wm,nlNL:()=>Cm});var wm={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"}]}]},Cm={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 qc={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var gt=require("react/jsx-runtime"),Xr=(t,e,o)=>n=>(0,gt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),Tm=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=k(Gr),i=Ae(),a=h("Login",qc),l=b("productName"),c=(0,Xe.useCallback)(v=>{v.preventDefault(),n&&n(parseInt(v.target.value,10))},[]),d=(0,Xe.useCallback)(v=>{v.preventDefault(),i.send(Yt,!0)},[e]),p=(0,Xe.useMemo)(()=>v=>(0,gt.jsx)("a",{onClick:_=>{_.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:v},"login"),[e]),g=(0,Xe.useCallback)(v=>(0,gt.jsx)("button",{type:"button",className:a.anchorButton,onClick:d,children:v},"prompt"),[d]),{min:u,hour:f,day:m}=(0,Xe.useMemo)(()=>({min:Xr(a,60*10,c),hour:Xr(a,60*60,c),day:Xr(a,60*60*12,c)}),[]);return(0,gt.jsxs)("div",{className:(0,jc.default)(t,a.root),children:[r("loginPlease",{login:o?g:p,productName:l}),n&&(0,gt.jsxs)(Xe.Fragment,{children:[(0,gt.jsx)("br",{}),r("snooze",{min:u,hour:f,day:m})]})]})},Ts=Tm;var $c=require("react-redux");var Vc={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var tn=require("react/jsx-runtime"),Em=({title:t})=>{let e=h("SearchTrigger",Vc),o=(0,$c.useDispatch)();return(0,tn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(le(!0)),children:[(0,tn.jsx)(oo,{}),(0,tn.jsx)("span",{className:e.text,children:t})]})},Wc=Em;var Zr={};Y(Zr,{enUS:()=>km,nlNL:()=>Rm});var km={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"}]},Rm={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 Gc={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"),Im=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=h("SuggestionsOverlay",Gc),s=k(Zr),r=(0,Me.useSelector)(co),i=_a(),a=(0,Me.useDispatch)(),l=(0,uo.useRef)(null),c=b("searchTriggerKey"),d=b("productName"),p=(0,Me.useSelector)(_s),g=(0,Me.useSelector)(ee),u=(0,Me.useSelector)(Xt),[f,m]=(0,uo.useState)(null),v=b("showSearch"),T=b("showTextSuggestions"),_=b("adminUrl"),y=b("isEmbedded"),[x,S]=Uc("dd-snooze-until-ms",0),N=p||x>Date.now(),U=(0,Me.useSelector)(R=>R.input.text),V=t.filter(R=>R.source!=="gpt").length,B=()=>{N&&S(0),a(Pc(!N))},P=R=>{a(Q({name:"suggestion feedback",data:{text:R.text,source:"overlay",context:U},options:{includeConversationData:!0}}))},M=R=>{let X=Date.now()+R*1e3;S(X),C.info(`Snooze until: ${new Date(X)}`),a(ut({collapse:!0}))};return(0,uo.useEffect)(()=>{V===0&&m(null)},[t,V]),lo(()=>{a(ut({collapse:!0,skipWhenInputFocus:!0}))}),g===null||u===!1?null:g===!1?(0,F.jsxs)("div",{ref:l,className:(0,Es.default)(n.root,{[n.isCollapsed]:N}),children:[!N&&(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)(bt,{className:n.toggleButton,title:s("collapse"),onClick:B,isCollapsed:!1})})]}),(0,F.jsx)("div",{className:n.toggleButtonWrapper,children:(0,F.jsx)(bt,{className:n.toggleButton,title:s("open",{productName:d}),onClick:B,isCollapsed:!0})}),(0,F.jsx)("div",{className:n.collapsible,children:(0,F.jsx)(Ts,{loginUrl:_,isEmbedded:y,onLogIn:o,onSnooze:M})})]}):!i||!r?null:(0,F.jsxs)("div",{ref:l,className:(0,Es.default)(n.root,{[n.isCollapsed]:N}),children:[!N&&(0,F.jsxs)("div",{className:n.triggers,children:[(0,F.jsx)("div",{style:{flex:1},children:v&&(0,F.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>m(s(zc()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>m(null),children:(0,F.jsx)(Wc,{title:s("search")})})}),(0,F.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,F.jsx)("div",{className:(0,Es.default)(!f&&n.hintsHidden,n.hints),children:f}),(0,F.jsx)(bt,{className:n.toggleButton,title:s("collapse"),onClick:B,isCollapsed:!1})]})]}),(0,F.jsx)("div",{className:n.toggleButtonWrapper,children:(0,F.jsx)(bt,{className:n.toggleButton,title:s("open",{productName:d}),onClick:B,isCollapsed:!0})}),V>0&&T&&(0,F.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,F.jsx)(ae,{children:(0,F.jsx)(ws,{onFeedback:P,suggestions:t,selectedIndex:e,reverse:!0})})})]})},Pm=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Xc=(0,Me.connect)(Pm)(Im);var zs=E(require("classnames")),_d=require("interweave"),Ye=require("react"),xd=require("react-redux");var go=require("react");function ks(t){return t.contentEditable==="true"}function Am(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 Zc(t){let{selectionStart:e,selectionEnd:o}=ks(t)?Am(t):t;return[e,o]}function Qc(t){let[,e]=(0,go.useState)(),o=(0,go.useRef)(null);return o.current=Zc(t),(0,go.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=Zc(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 Jc(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(wn);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 Yc=require("react"),Lm=["div","span","mark","strong","b","i","u","em"];function Qr(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(Lm.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,Yc.cloneElement)(n,{children:Qr(i,e,o+1)})]}return[...t,...e]}function mt(t){return t.tagName.toLowerCase()==="textarea"}var ed={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 dd=E(require("classnames")),pd=require("interweave"),Hs=require("react");var mo=require("react");function td(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function Rs(t){let e=(0,mo.useRef)(null),[o,n]=(0,mo.useState)(!1);return(0,mo.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=td((d,p)=>{let g=e.current;if(!g)return;let u=d/r,f=p/r,m=g.getBoundingClientRect(),v=u>m.x&&u<m.x+m.width&&f>m.y&&f<m.y+m.height;v&&!s?(s=!0,n(!0)):!v&&s&&(s=!1,n(!1))},({clientX:d,clientY:p})=>[d,p]),[l,c]=td(()=>{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]}function od(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Is(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function nd(t){return t!=null}var Yr=E(require("classnames")),he=require("react");var Ps=require("react"),Mm=["bottom","height","left","right","top","width"],Om=(t={},e={})=>Mm.some(o=>t[o]!==e[o]),Ze=new Map,sd,rd=()=>{let t=[],e=[];Ze.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Om(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Ze.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),sd=window.requestAnimationFrame(rd)};function Nm(t,e){return{observe(){let o=Ze.size===0;if(Ze.has(t)){let n=Ze.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Ze.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&rd()},unobserve(){let o=Ze.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Ze.delete(t),Ze.size||cancelAnimationFrame(sd)}}}}function Jr(t){let[e,o]=(0,Ps.useState)(null);return(0,Ps.useLayoutEffect)(()=>{if(!t.current)return;let n=Nm(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var fo=require("react"),ad=require("react-dom");var id={root:"_root_1jq08_1"};var ld=({children:t})=>{let[e,o]=(0,fo.useState)(null),n=(0,fo.useContext)(_o);return(0,fo.useLayoutEffect)(()=>{let s=document.createElement("div");return Dt(s),s.classList.add(id.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,ad.createPortal)(t,e):null};var Oe={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 As=require("react/jsx-runtime"),Ls=(t=!1)=>{let[e,o]=(0,he.useState)(t),n=(0,he.useCallback)(()=>o(!0),[]),s=(0,he.useCallback)(()=>o(!1),[]),r=(0,he.useCallback)(()=>o(a=>!a),[]),i=(0,he.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function ei(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 Ms=({className:t,triggerRef:e,boundaryRef:o=(0,he.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=ei,...a})=>{let l=Jr(e),c=Jr(o),d=(0,he.useMemo)(()=>i(l,c,0),[l,c]);return(0,As.jsx)(ld,{children:(0,As.jsx)("div",{className:(0,Yr.default)(Oe.ref,{[Oe.positionAbove]:n==="above",[Oe.positionBelow]:n==="below",[Oe.positionLeft]:n==="left",[Oe.positionRight]:n==="right",[Oe.alignStart]:s==="start",[Oe.alignCenter]:s==="center",[Oe.alignEnd]:s==="end"}),style:d,...a,role:"dialog",children:(0,As.jsx)("div",{className:(0,Yr.default)(t,Oe.root),children:r})})})};var cd=E(require("classnames")),Os=require("react");var Qe={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 ti=require("react/jsx-runtime"),Ns=(0,Os.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,Os.useRef)(null),r=h("TabCompletion",Qe);return(0,ti.jsx)("div",{ref:Is([s,n]),className:(0,cd.default)(t,r.popoverContentContainer),...o,children:(0,ti.jsx)("div",{className:r.popoverContent,children:e})})});var ft=require("react/jsx-runtime"),Dm=t=>e=>{let o=ei(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Hm=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=h("TabCompletion",Qe),i=Ls(),a=(0,Hs.useMemo)(()=>Dm(t.getBoundingClientRect()),[t]),[l,c]=Rs(t);return(0,Hs.useEffect)(()=>{c?i.open():i.close()},[c]),(0,ft.jsxs)("span",{children:[(0,ft.jsx)("mark",{ref:Is([l,i.triggerRef]),className:(0,dd.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,ft.jsx)(Ms,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,ft.jsx)(Ns,{style:o,children:(0,ft.jsx)("div",{className:r.hintText,children:s})})})]})},Ds=class extends pd.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${od(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(nd);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,ft.jsx)(Hm,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var ud=require("interweave"),gd=E(require("classnames"));var oi=require("react/jsx-runtime"),Fm=({inputElement:t,children:e})=>{let o=h("TabCompletion",Qe),[n,s]=Rs(t);return(0,oi.jsx)("mark",{ref:n,className:(0,gd.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},Fs=class extends ud.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,oi.jsx)(Fm,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Ks=E(require("classnames")),vd=require("interweave"),oe=require("react"),Sd=require("react-redux");var ni=require("react/jsx-runtime"),md=()=>(0,ni.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,ni.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 ht=require("react"),on=require("react-redux"),hd=E(require("lodash.debounce"));var fd={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Bs(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 si(t){return t.replace("https://www.","").replace("https://","")}var ye=require("react/jsx-runtime"),Bm=3,Km=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Um=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=Bm})=>{let r=h("LinkSearch",fd),[i,a]=(0,ht.useState)(""),l=(0,on.useDispatch)(),c=(0,on.useSelector)(ic("url")),d=(0,on.useSelector)(Ua("URL",Km)),[p,g]=(0,ht.useState)(d.length-1),u=b("fallbackImage"),f=_=>{let y=_.target;a(y.value)},m=(_,y)=>{_.stopPropagation(),_.preventDefault(),window.open(y,"_blank")},v=_=>{var S;let y=p-1<0?d.length-1:p-1,x=p+1===d.length?0:p+1;_.code==="Escape"&&(a(""),e()),_.code==="ArrowUp"&&g(y),_.code==="ArrowDown"&&g(x),_.code==="Enter"&&t(((S=d[p])==null?void 0:S.text)||i)},T=(0,ht.useCallback)((0,hd.default)(_=>{l(Tt({query:_,type:"URL",tags:["link-search"]}))},300),[]);return(0,ht.useEffect)(()=>{i&&T(i)},[i]),(0,ht.useEffect)(()=>()=>{l(Fn())},[]),(0,ye.jsxs)("div",{className:r.root,children:[(0,ye.jsx)(ae,{withDivider:!0,children:(i?d:c).slice(0,s).map((_,y)=>(0,ye.jsx)(L,{selected:p===y,onClick:()=>t(_.text),"data-testid":"linksearch-suggestion",children:(0,ye.jsxs)(D,{children:[(0,ye.jsx)(D.Image,{src:Bs(_,"small",u||void 0),title:_.title||_.text}),(0,ye.jsxs)(D.Content,{className:r.content,cropText:!0,children:[(0,ye.jsx)(D.Title,{children:_.title||si(_.text)}),_.title&&si(_.text)]}),(0,ye.jsx)(L.Actions,{children:(0,ye.jsx)(L.ActionButton,{label:n,onClick:x=>m(x,_.text)})})]})},_.text))}),(0,ye.jsx)(Do,{value:i,onChange:f,autoFocus:!0,placeholder:o,onKeyUp:v})]})},yd=Um;var ri={};Y(ri,{enUS:()=>zm,nlNL:()=>qm});var zm={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},qm={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var te=require("react/jsx-runtime"),jm=(0,oe.forwardRef)((t,e)=>{let o=h("TabCompletion",Qe);return(0,te.jsx)("mark",{ref:e,className:(0,Ks.default)(o.matchSelection)},"selection-start")}),Vm=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=k(ri),i=h("TabCompletion",Qe),a=(0,oe.useRef)(null),l=(0,oe.useRef)(null),[c,d]=(0,oe.useState)(null),p=(0,Sd.useDispatch)(),g=Ls(document.activeElement===n),[u]=(0,oe.useState)(()=>document.createRange());g.triggerRef.current=u,(0,oe.useEffect)(()=>()=>u.detach(),[]),(0,oe.useEffect)(()=>{let m=t.current,v=a.current;!m||!v||(u.setStart(m,0),u.setEnd(v,0))},[t.current,a.current]),lo(()=>{g.close()});let f=(0,oe.useCallback)(m=>{let v=u.toString(),T=/^http(s?):\/\//.test(m)?m:`https://${m}`;p(Ln({text:`[${v}](${T})`,replace:"selection"}))},[]);return(0,te.jsxs)("span",{children:[(0,te.jsx)("mark",{ref:a,className:(0,Ks.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":g.opened?"true":"false",children:s}),g.opened&&(0,te.jsx)(Ms,{className:i.popoverRoot,triggerRef:g.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,te.jsxs)(Ns,{style:o,ref:l,children:[(0,te.jsx)("div",{className:(0,Ks.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,te.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>d("insertLink"),children:[(0,te.jsx)(md,{}),(0,te.jsx)("span",{children:"\xA0"}),(0,te.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,te.jsx)(yd,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:f,onDismiss:()=>{d(null),g.close()}})]})})]},"selection-end")},Us=class extends vd.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,oe.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,te.jsx)(jm,{ref:this.startRef}):(0,te.jsx)(Vm,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var bd=require("react-redux");var Je=require("react/jsx-runtime"),$m=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=h("TabCompletion",ed),d=b("insertLink"),p=b("showMidSentenceSuggestions"),g=b("inlineSuggestions"),u=Qc(a),f=(0,Ye.useRef)(null),m=(0,bd.useSelector)(ee);(0,Ye.useEffect)(()=>{mt(a)&&u&&Jc(a,u)},[u]);let v=(0,Ye.useCallback)(y=>{if(!s||!o)return y;let x=[(0,Je.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,Je.jsx)("span",{"data-testid":"tab-completion",className:(0,zs.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&x.push((0,Je.jsx)("span",{className:(0,zs.default)(c.hint,c.resetIndent),children:(0,Je.jsx)(Sn,{keyCode:"tab"},"tabHint")})),Qr(y,x)},[s,o,n]),T=(0,Ye.useMemo)(()=>{let y=[];return d&&y.push(new Us("selection")),y.push(new Fs("placeholders")),r&&y.push(new Ds("keywords")),y},[g,d,r]),_=(0,Ye.useMemo)(()=>{let y=window.getComputedStyle(a);return{"--dd-color":y.color,"--dd-font-size":y.fontSize,"--dd-font-family":y.fontFamily,"--dd-font-variant":y.fontVariant}},[]);return!t||!m?null:(0,Je.jsxs)("div",{ref:y=>{y!=null&&y.parentElement&&(f.current=y==null?void 0:y.parentElement)},className:c.root,style:_,children:[(0,Je.jsx)(_d.Interweave,{tagName:"span",containerTagName:"div",className:(0,zs.default)(c.container,c.agentText),disableLineBreaks:mt(a),content:e||"\u200B",onAfterParse:v,matchers:T,selection:u,keywordMatches:i,inputElement:a,inputStyle:_,boundaryRef:f,inlineSuggestionsOnlyAtEnd:!p}),(0,Je.jsx)("br",{})]})},Wm=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var m;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??to(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:d}=e,{isSupported:p}=s,{showTabCompletion:g,visible:u,showStyleSuggestions:f}=o;return{showTabHint:d,showStyleSuggestions:f,showTabCompletion:g,content:l,tabText:c,source:a,keywordMatches:((m=n.list)==null?void 0:m.keywordMatches)??[],enabled:u&&p!==!1}},wd=(0,xd.connect)(Wm)($m);var hp=E(require("classnames")),yp=require("react"),$=require("react-redux");var yt=require("@reduxjs/toolkit");var Cd={list:[],fetchState:"idle",isInitialRequest:null},Ed=t=>t.autoflows.list||[],Td=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},et=(0,yt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),ii=(0,yt.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(et(t.platformSessionId))}),ai=(0,yt.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(et(t.platformSessionId))}),Gm=(0,yt.createSlice)({name:"autoflows",initialState:Cd,reducers:{},extraReducers:t=>{t.addCase(ii.pending,(e,o)=>{let n=Td(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(ai.pending,(e,o)=>{let n=Td(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(et.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(et.rejected,e=>{e.fetchState="error"}),t.addCase(et.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(O,()=>Cd)}}),kd=(0,yt.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(et(t))}),s.on("sessionCompleted",()=>{o(et(t))})}),Rd=(0,yt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Id=Gm.reducer;var vt=require("@reduxjs/toolkit");var Pd={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Ad=t=>t.customMessages.list,Ld=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Md=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Od=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),nn=(0,vt.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),qs=(0,vt.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)}),js=(0,vt.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)}),Nd=(0,vt.createSlice)({name:"customMessages",initialState:Pd,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(nn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(nn.rejected,e=>{e.fetchState="error"}).addCase(nn.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(qs.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(qs.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(js.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(js.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(O,()=>Pd)}}),Dd=(0,vt.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(Nd.actions.onCustomMessage(r))})}),Hd=(0,vt.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Fd=Nd.reducer;var sn=require("@reduxjs/toolkit"),Xm={token:null,accountUrl:null,interval:null},Bd=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},li=(0,sn.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),ci=(0,sn.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(li()),setInterval(()=>n(li()),o)}),Kd=(0,sn.createSlice)({name:"passwordlessToken",initialState:Xm,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(li.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(ci.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:Ud}=Kd.actions,zd=Kd.reducer;function qd(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var Jd=require("react"),Yd=require("react-redux");var Xd=E(require("classnames")),Zd=require("react");var Vd=E(require("classnames"));var jd={root:"_root_838fd_1"};var Wd=require("react/jsx-runtime"),Zm=({className:t,children:e})=>{let o=h("Unicode",jd);return(0,Wd.jsx)("span",{className:(0,Vd.default)(t,o.root),children:e})},$d=Zm;var Gd={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 di={};Y(di,{enUS:()=>Qm,nlNL:()=>Jm});var Qm={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"}]},Jm={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 ue=require("react/jsx-runtime"),ef=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=h("Autoflow",Gd),a=k(di),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,ue.jsxs)(L,{className:(0,Xd.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,ue.jsx)(D,{children:(0,ue.jsxs)(D.Content,{children:[(0,ue.jsxs)(D.Title,{children:[e&&(0,ue.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,ue.jsx)("span",{children:n})]})}),(0,ue.jsx)(L.Actions,{fixed:e==="Started",children:(0,ue.jsx)(L.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,ue.jsxs)(Zd.Fragment,{children:[(0,ue.jsx)($d,{children:c})," ",(0,ue.jsx)("span",{children:a(l)})]})})})]})},Qd=ef;var pi=require("react/jsx-runtime"),tf=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},of=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,pi.jsx)(Jd.Fragment,{children:t.map(s=>(0,pi.jsx)(Qd,{displayName:s.displayName,description:s.description,disabled:s.isBusy||tf(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),nf=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},sf={onStartAutoflow:ii,onStopAutoflow:ai},ep=(0,Yd.connect)(nf,sf)(of);var tp=E(require("classnames")),ui=require("react"),Bt=require("react-redux");var tt={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 se=require("react/jsx-runtime"),rf=({suggestion:t})=>{let e=k(At),o=(0,Bt.useDispatch)(),n=(0,Bt.useSelector)(Ld(t.text)),s=(0,Bt.useSelector)(Md(t.text)),r=(0,Bt.useSelector)(Od(t.text)),i=(0,Bt.useSelector)(Tn),{replyOptions:a}=t,l=(0,ui.useCallback)(d=>{d.preventDefault(),d.stopPropagation(),!(n||!i)&&o(qs({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,ui.useCallback)(d=>{if(d.preventDefault(),d.stopPropagation(),!i||!a)return;let p=parseInt(d.target.dataset.index,10),g=a[p];o(js({platformSessionId:i,reply:g,suggestion:t}))},[t,n,o,i]);return(0,se.jsxs)(L,{onClick:l,className:(0,tp.default)(tt.root,{[tt.isUsed]:n,[tt.hasError]:r}),children:[(0,se.jsx)(D,{children:(0,se.jsxs)(D.Content,{children:[(0,se.jsxs)(D.Title,{className:tt.title,children:[t.text," ",(0,se.jsx)(_n,{className:tt.label,children:"analyse tool"})," ",r&&(0,se.jsx)("span",{className:tt.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,se.jsx)("ul",{className:tt.quickReplies,children:a.map(d=>(0,se.jsx)("li",{className:tt.quickReply,children:d.title},d.title))})]})}),(0,se.jsxs)(L.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,se.jsx)(L.DropdownButton,{label:e("answer"),disabled:s,children:a.map((d,p)=>(0,se.jsx)(L.DropdownItem,{index:p,label:d.title,onClick:c},d.title))}),(0,se.jsx)(L.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},op=rf;var Vs=require("react"),sp=require("react-redux"),fi=E(require("classnames"));var gi=require("react/jsx-runtime"),mi=()=>(0,gi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,gi.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 np={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 Ne=require("react/jsx-runtime"),af=({entities:t})=>{let e=h("EntitiesWidgetList",np),[o,n]=(0,Vs.useState)(void 0),s=(0,sp.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),Fo(a.text),s(Q({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Vs.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,Ne.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,Ne.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Ne.jsx)("span",{className:e.entityText,children:a.text}),(0,Ne.jsxs)("span",{className:e.iconWrapper,children:[(0,Ne.jsx)("span",{className:(0,fi.default)(e.icon),children:(0,Ne.jsx)(mi,{})}),(0,Ne.jsx)("span",{className:(0,fi.default)(e.icon,o===l&&e.iconClicked),children:(0,Ne.jsx)(mi,{})})]})]},a.text))})},rp=af;var hi=require("react/jsx-runtime"),ip=()=>(0,hi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,hi.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 yi=require("react/jsx-runtime"),ap=()=>(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:"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 vi=require("react/jsx-runtime"),lp=()=>(0,vi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,vi.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 $s=require("react");var Si={};Y(Si,{enUS:()=>lf,nlNL:()=>cf});var lf={copyCue:[{type:0,value:"Copy"}],copiedCue:[{type:0,value:"Copied!"}],removeCue:[{type:0,value:"Close"}]},cf={copyCue:[{type:0,value:"Kopieer"}],copiedCue:[{type:0,value:"Gekopieerd!"}],removeCue:[{type:0,value:"Sluiten"}]};var ot=require("react/jsx-runtime"),df=({cue:t,onRemove:e,onCopy:o})=>{let n=k(Si),[s,r]=(0,$s.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,$s.useEffect)(()=>{if(!s)return;let l=setTimeout(()=>{r(!1)},1e3);return()=>{clearTimeout(l)}},[s]),(0,ot.jsx)(L,{"data-testid":"cue",children:(0,ot.jsxs)(D,{children:[(0,ot.jsxs)(D.Content,{children:[t.title&&(0,ot.jsx)(D.Title,{"data-testid":"widget-cue-title",children:t.title}),t.text]}),(0,ot.jsx)(L.Actions,{children:o&&(0,ot.jsx)(L.ActionButton,{primary:!0,onClick:i,label:n(s?"copiedCue":"copyCue")})}),(0,ot.jsx)(D.CloseIcon,{title:n("removeCue"),onClick:a})]})})},cp=df;var rn=require("react/jsx-runtime"),pf=({cues:t,onCopyCue:e,onRemoveCue:o})=>(0,rn.jsx)(rn.Fragment,{children:t.map(n=>(0,rn.jsx)(cp,{cue:n,onRemove:o,onCopy:e},`${n.id}_${n.timestamp}`))}),dp=pf;var up=require("react");var uf=/(https?:\/\/[^\s]+)/,pp=t=>t.split(" ").find(e=>uf.test(e));var ve=require("react/jsx-runtime"),gf=({suggestion:t,lines:e,onUse:o})=>{var d;let n=t.text||t.url||t.message,s=pp(n),r=k(At),i=b("showImages"),a=b("fallbackImage"),l=p=>{p.preventDefault(),p.stopPropagation(),o(n)},c=(0,up.useCallback)(p=>{window.open(s,"_blank"),p.stopPropagation(),p.preventDefault()},[s]);return(0,ve.jsxs)(L,{onClick:l,"data-testid":"edit-suggestion",children:[(0,ve.jsxs)(D,{children:[i&&t.image&&(0,ve.jsx)(D.Image,{src:Bs(t,"small",a||void 0),title:t.title}),(0,ve.jsxs)(D.Content,{children:[t.title&&(0,ve.jsx)(D.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((d=t.searchKeywords)==null?void 0:d.length)>0&&(0,ve.jsx)(L.Labels,{labels:t.searchKeywords}),(0,ve.jsx)(D.Content,{cropText:e==="single",lineClamp:e==="multiple",children:n})]})]}),(0,ve.jsxs)(L.Actions,{children:[s&&(0,ve.jsx)(L.ActionButton,{onClick:c,label:r("visitUrl")}),(0,ve.jsx)(L.ActionButton,{primary:!0,onClick:l,label:r("useSuggestion")})]})]})},gp=gf;var an=require("react/jsx-runtime"),mf=({lines:t,suggestions:e})=>{let o=Ae(),n=(s,r)=>{o.send(eo,{text:s,suggestion:{...r,source:r.source,sourceText:r.text}})};return(0,an.jsx)(an.Fragment,{children:e.map(s=>(0,an.jsx)(gp,{suggestion:s,lines:t,onUse:r=>n(r,s)},s.text||s.url||s.message))})},mp=mf;var _i={};Y(_i,{enUS:()=>ff,nlNL:()=>hf});var ff={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"}]},hf={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 fp={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 I=require("react/jsx-runtime"),Ws=(t,e)=>{let o=(0,$.useSelector)(ee);(0,yp.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},yf=({onLogIn:t})=>{let e=k(_i),o=(0,$.useDispatch)(),n=b("isEmbedded"),s=h("Widget",fp),r=b("showAutoflows"),i=b("showCustomMessages"),a=b("showSummaryCommand"),l=b("showKnowledgeSearch"),c=b("showSearch"),d=(0,$.useSelector)(pt),p=(0,$.useSelector)(hs),g=(0,$.useSelector)(Ed),u=(0,$.useSelector)(ja),f=(0,$.useSelector)(ps),m=(0,$.useSelector)(Ad),v=(0,$.useSelector)(En),T=(0,$.useSelector)(Xt),_=(0,$.useSelector)(ee),y=(0,$.useSelector)(Tn),x=(0,$.useSelector)(qd),S=(0,$.useSelector)(ys),N=Ae(),U=(0,$.useSelector)(ac),V=(0,$.useSelector)(Bd("/admin/")),B=b("adminUrl"),P=b("productName");if(Ws(()=>(o(nn(y)),o(Dd(y)),()=>{o(Hd(y))}),[o,T,i,y]),Ws(()=>(o(et(y)),o(kd(y)),()=>{o(Rd(y))}),[o,T,r,y]),Ws(()=>{p.forEach(({type:R})=>{o(R==="entities"?Ee():Re(R))})},[o,T,v,d]),Ws(()=>(o(ci()),()=>{o(Ud())}),[o]),T===!1)return(0,I.jsx)("div",{className:s.stateText,children:(0,I.jsx)("div",{children:(0,I.jsx)("p",{children:e("notSupported")})})},"supported");if(_===!1)return(0,I.jsx)("div",{className:s.loginText,children:(0,I.jsx)("div",{children:(0,I.jsx)(Ts,{isEmbedded:n,loginUrl:B,onLogIn:t})})},"login");if(!d||!y||_===null||U||x)return(0,I.jsx)("div",{className:s.stateText,children:(0,I.jsx)("div",{children:(0,I.jsx)("p",{children:e("waiting")})})},"waiting");let M=c||a||l||V;return(0,I.jsx)("div",{className:(0,hp.default)(s.root),"data-testid":"widget",children:(0,I.jsxs)(xn,{className:s.sectionList,children:[M&&(0,I.jsx)(Be,{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:()=>N.send("ShowCommandPalette",{isOpen:!0}),children:[(0,I.jsx)(oo,{}),e("linkSearch")]}),a&&(0,I.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-summary",onClick:()=>N.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,I.jsx)(lp,{}),e("linkSummary")]}),l&&(0,I.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>N.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,I.jsx)(ap,{}),e("linkKnowledgeSearch")]}),V&&(0,I.jsxs)("a",{className:s.shortcut,target:"_blank",href:V,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[(0,I.jsx)(ip,{}),e("linkStudioLogin",{productName:P})]})]})}),i&&m.length>0&&(0,I.jsx)(Be,{type:"custom-messages","data-testid":"custom-messages",children:(0,I.jsx)(ae,{withDivider:!0,children:m.map(R=>(0,I.jsx)(op,{suggestion:R},R.text))})}),r&&g.length>0&&(0,I.jsx)(Be,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,I.jsx)(ae,{withDivider:!0,children:(0,I.jsx)(ep,{})})}),p.map(({type:R,title:X,amount:rr,lines:ir})=>{var qt;switch(R){case"entities":return f&&f.length>0&&(0,I.jsx)(Be,{type:R,title:X,"data-testid":`type-${R}`,children:(0,I.jsx)(rp,{entities:f})},R);case"cues":return u&&u.length>0&&(0,I.jsx)(Be,{type:R,title:X,"data-testid":`type-${R}`,children:(0,I.jsx)(ae,{withDivider:!0,children:(0,I.jsx)(dp,{cues:u,onRemoveCue:_t=>o($a({id:_t}))})})},R);default:return((qt=S[R])==null?void 0:qt.fetchState)==="done"&&S[R].suggestions.length>0&&(0,I.jsx)(Be,{type:R,title:X,"data-testid":`type-${R}`,children:(0,I.jsx)(ae,{withDivider:!0,children:(0,I.jsx)(mp,{lines:ir,contentType:R,suggestions:S[R].suggestions.slice(0,rr)||[]})})},R)}})]})})},vp=yf;function ho(t){let e=new Range;return e.selectNodeContents(t),e}function Sp(t,e,o){try{return St(t,e,o),!0}catch{return!1}}function Gs(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function Xs(t){return"tagName"in t&&t.tagName==="BR"}var ln=/[\u200B-\u200D\uFEFF]/g;function St(t,e,o){let n=new Range;if(t.firstChild===null&&e===0&&o===0)return n.selectNodeContents(t),n;let s=0,r=!1;function i(l,c){let d=-1,p=/[\u200B-\u200D\uFEFF]/;if(!p.test(l))return c;for(let g=0;g<=l.length;g++)if(p.test(l[g])||d++,d===c)return g;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,d=c.replace(ln,""),p=s+d.length,g=e>=s&&e<=p,u=o>=s&&o<=p;if(g){let f=i(c,e-s);f===0&&!u?n.setStartBefore(l):n.setStart(l,f)}u&&(n.setEnd(l,i(c,o-s)),r=!0),s=p;break}case Node.ELEMENT_NODE:{if(Xs(l)&&(s===e&&n.setStartBefore(l),s++,s===o)){n.setEndAfter(l),r=!0;return}for(let d=0;d<l.childNodes.length&&(a(l.childNodes[d]),!r);d++);let c=l.lastChild;Gs(l)&&c&&!Gs(c)&&!Xs(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 d(p){let g=p===o,u=p===s;switch(p.nodeType){case Node.TEXT_NODE:{let f=p.textContent;g&&(a=c+f.substring(0,n).replace(ln,"").length),u&&(l=c+f.substring(0,r).replace(ln,"").length),c+=f.replace(ln,"").length;break}case Node.ELEMENT_NODE:{let f=p.nextSibling===null;Xs(p)&&!f&&c++;for(let m=0;m<p.childNodes.length;m++){let v=g&&m===n,T=u&&m===r;if(v&&(a=c),T&&(l=c),l!==void 0||((!v||!i)&&d(p.childNodes[m]),u&&m===r-1&&(l=c),l!==void 0))break}!u&&Gs(p)&&!f&&c++,u&&(l=c);break}default:break}}if(d(t),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function dn(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 d=c===o,p=c===s;switch(d&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let g=d?n:0,u=p?r:void 0,f=c.textContent.replace(ln,"");g===0&&u===void 0?a+=f:a+=f.substring(g,u);break}case Node.ELEMENT_NODE:{let g=c.nextSibling===null;i===0&&Xs(c)&&!g&&(a+=`
8
8
  `);for(let u=d?n:0;u<(p?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[u]),i!==1);u++);!p&&i===0&&Gs(c)&&!g&&(a+=`
9
- `);break}default:break}p&&i++}return l(t),a}var _p=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(_p||{}),nt=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();rt(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(_p).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}};function xp(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Kt=class extends nt{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),dn(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!xp(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!xp(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&&Sp(this.element,o.start,o.end))return o;let n=ho(this.element);return n.collapse(!1),cn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return dn(this.element,St(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return(s=this.observer)==null||s.takeRecords(),Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};var Ut=class extends nt{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())}};function bp(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 xi=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()}},bi=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=bp(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()}},wi=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(),C.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 bi(e,this.deepdeskUrl,{debug:!0}):new xi(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&&(C.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;C.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)}},wp=wi;var yo=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Ci=t=>new Promise(e=>{setTimeout(e,t)});var vo=class extends yo{name="ClientError"},Ti=class extends yo{name="ServerError"},Re=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:d=500,refreshTokenOn401:p=!0,retryOnError:g=x=>x instanceof TypeError,retryOnResponse:u=x=>x.status>=500,version:f="v1",...m}=o,v={credentials:"include",...m,headers:{"Content-Type":"application/json",...m.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(v.headers={...v.headers,"X-CSRFToken":this.csrfToken}),typeof f=="string"&&(v.headers={...v.headers,"X-Deepdesk-API-Version":f});let T=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 y=async()=>(T--,a(i,v).then(async x=>u(x)&&!r.isAborted&&T>0?(await Ci(d),y()):x.status===401&&p===!0&&_===!1?(_=!0,await this.refreshToken(),y()):x).catch(async x=>{if(g(x)&&!r.isAborted&&T>0)return await Ci(d),y();throw x}));y().then(x=>x.json().catch(()=>null).then(S=>{x.status>=500?s(new Ti("Server Error",S)):x.status===401?s(new vo("Unauthorized",S)):x.status===403?s(new vo("Forbidden",S)):x.status===404?s(new vo("Not Found",S)):x.status>=400&&s(new vo("Bad Request",S)),delete this.latestRequestByUrl[i],n(S)})).catch(x=>{s(x)})})}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var vf;(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||={})})(vf||={});function Zs(t){return{...A(t),tags:t.tags}}var st=class t{constructor(e,o={}){this.options=o;this.client=new Re(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(),C.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...q(e),tags:e.tags},{version:"v2"});return Zs(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return A(o)}async getKnowledgeAssistant(e){let o=await this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{version:null});return A(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return A(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return A(e)}async checkUserExists(e){let{exists:o}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return o}async getConversationBySessionId(e,o={}){await this.preflight(),C.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 C.info(`Successfully retrieved conversation ${r.id} for session ${e}`),Zs(r)}async isConversationSupported(e,o={}){C.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=q(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return Zs(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...q(s),tags:s.tags})),{version:"v2"})).map(s=>Zs(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",q({...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:q({...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 C.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.preflight(),await this.client.post("/apis/admin/session/api-key/",q(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}`,q(o),{abortLatest:!0})).map(r=>({...A(r),text:r.text||r.url||r.message,source:n,type:n})).filter((r,i,a)=>i===a.findIndex(l=>l.text===r.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(e,o){return(await this.client.post(`/api/conversations/${e}/autocomplete`,q(o),{abortLatest:!0})).map(s=>({score:1,source:s.source,sourceText:s.source_text,text:s.label,trainingJobs:s.training_jobs,searchKeywords:s.search_keywords,type:s.source})).filter((s,r,i)=>r===i.findIndex(a=>a.text===s.text))}async getPinnedMessages(e){let o=await this.client.get(`/api/conversations/${e}/sticky-messages`,{abortLatest:!0});return A(o).map(n=>({...n,text:n.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(e){let o=await this.client.post("/api/style-suggestions",q(e),{abortLatest:!0});return A(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,q(e),{version:"v2"});return A(o)}async knowledgeAssist(e,o,n,s={}){let r=await this.client.post(`/api/knowledge-assist/assistants/${n}/search`,q({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 A(r)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return A(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return A(e.token)}async getCsrfToken(){let{token:e}=await this.client.get("/apis/admin/session/csrf/",{version:null});return e}async verifyLoginToken(e){let o=await this.client.post("/apis/admin/session/passwordless/login/",{token:e},{version:null});return A(o)}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 A(i.cues)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(ea);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&C.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var pn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(mr(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,A(s))}catch{C.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 Sf;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(Sf||={});var un=class{constructor(e,o={}){this.apiUrl=e;this.client=new Re(e,o)}client;streams={};logger=C;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return A(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,q(o));return A(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,q(o))}async getAutoflows(e){let o=await this.client.get(`/sessions/${e}/autoflows`);return A(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",q(e));return A(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new pn(`${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 er=require("@reduxjs/toolkit");var Tp=require("@reduxjs/toolkit");var Cp={startTime:null,stopTime:null},Ep=(0,Tp.createSlice)({name:"handlingTime",initialState:Cp,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(O,()=>Cp)}}),{handlingTimeStart:kp,handlingTimeStop:Qs,handlingTimeReset:Ip}=Ep.actions,Rp=Ep.reducer;var Pp=(t={})=>{let e={onAuthError:Gt(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var Ys=require("@reduxjs/toolkit");var Js={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var zt=(0,Ys.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 Js.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),_f=(0,Ys.createSlice)({name:"styleSuggestions",initialState:Js,reducers:{},extraReducers:t=>{t.addCase(zt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(zt.rejected,e=>{e.fetchState="error"}).addCase(zt.fulfilled,(e,o)=>{e.fetchState="done",rt(e.list,o.payload)||(e.list=o.payload)}).addCase(Ct,e=>{e.list=Js.list}).addCase(O,()=>Js)}}),Ap=_f.reducer;var Lp=(t={})=>{let e,o=!0,n={getStyleSuggestions:zt,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:d}=c.settings;if(!((u=c.conversation.current)==null?void 0:u.id)||!d)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 xf(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Mp=(t={})=>{let e={getTextSuggestions:Ie,getAutocompleteSuggestions:Zo,debounce:200,check:co,...t},o;return n=>s=>r=>{var m;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:d}=l.settings,p=(m=l.conversation.current)==null?void 0:m.id,g=r.type===vs.toString();if(!p||!c&&!d)return a;let{input:{userCommitted:u}}=l;return xf(u,i)&&!g||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let v=Zt(l);v===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(v))},g?0:e.debounce)),a}};var Op=zt.fulfilled.toString();function bf(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 Np=t=>e=>o=>n=>{var c;if(n.type!==Op){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=bf(s,i);n.type===Op&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var wf=(0,er.combineReducers)({answer:Jl,auth:pa,autoflows:Rd,conversation:fa,contentTypes:fl,customMessages:Fd,passwordlessToken:zd,entities:Fl,knowledgeAssistant:Xl,handlingTime:Rp,info:Da,input:La,settings:sa,profile:tc,search:ja,summary:Vl,styleSuggestions:Ap,ui:Ac,rules:Wa,textSuggestions:dc});function Dp(t){return(0,er.configureStore)({reducer:wf,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Pp(),Mp({debounce:200}),Lp({debounce:500}),Np(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Cf=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Tf=t=>e=>o=>n=>{var a;let s=e.getState(),r=cr("inlineSuggestions")(s);switch(n.type){case Gt.toString():{!n.payload&&t.emit("logout",void 0);break}case xe.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:Cf(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Ln.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:d}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:d},{mayApplyChanges:!0});break}case Nn.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 Ee.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case $e.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 Mn.toString():t.handleKeyDown(n.payload);break;case Ct.toString():t.logSendMessage(n.payload);break;case On.toString():t.handleInputChanged(n.payload);break;case Ve.fulfilled.toString():t.broadcast(vr,n.payload,!1),t.emit("cues",n.payload);break;default:break}let i=o(n);switch(n.type){case Ct.toString():t.handleAfterSendMessage(n.payload);break;case Jo.toString():t.onUpdateShowTabHint(n.payload);break;case Qs.toString():t.logHandlingTime();break;case xe.toString():{r&&(e.dispatch(Pe([])),e.dispatch(je()));break}case Pe.toString():{r&&n.payload.length>0&&e.dispatch(at(0));break}default:break}return i},Hp=Tf;function Ei(t){return t.toISOString().replace("T"," ").replace("Z","")}function Fp(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:Ei(o),timeStop:Ei(n)}}function Bp(t,e,o){var U,V,B;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:d,pastes:p,cuts:g,deletions:u,textSuggestions:f,offeredTextSuggestions:m}}=e[t],v=n.length,_=f.reduce((P,{text:M,searchTerm:I})=>P+M.length-(I?I.length:0),0),y=c??Date.now(),x=(Date.now()-y)/1e3+(d||0),S=s/x,N=f.reduce((P,{searchTerm:M})=>P+(M?M.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:p,cuts:g,deletions:u,lenTextTyped:s+N,lenTextTotal:v,lenTextAssisted:_,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:x,charsPerSecond:S,numPastes:l,textSuggestionsV2:f,suggestionsCounters:[{source:"gpt",countOffered:m.filter(P=>P.source==="gpt").length}],agentId:(U=e.info.agentInfo)==null?void 0:U.agentId,agentName:(V=e.info.agentInfo)==null?void 0:V.agentName,agentEmail:(B=e.info.agentInfo)==null?void 0:B.agentEmail}}function ki(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return ki(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?ki(s,e):null}function Kp(t,e){return ki(t,e)}function Up(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Ef(t){return typeof t=="object"&&t!==null&&"tagName"in t}function tr(t){return Ef(t)&&(mt(t)||ks(t))}var zp,De=new Map,kf=["bottom","height","left","right","top","width"],If=(t={},e={})=>kf.some(o=>t[o]!==e[o]);function jp(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,...jp(e)]:[]}function Vp(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var or=!1,qp=()=>{or=!0;let t=[];if(De.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),De.delete(o);return}let n=o.getBoundingClientRect();If(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(Vp,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),De.size===0){or=!1;return}zp=window.requestAnimationFrame(qp)};function Ii(t,e){let o=jp(t),n=[],s=o.map((r,i)=>Ii(r,a=>{n[i]=a;let l=De.get(t);if(!l)return;let c=n.reduce(Vp,l.rect);l.callbacks.forEach(d=>d(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),De.has(t)){let i=De.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else De.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!or&&qp()},unobserve(){s.forEach(i=>i.unobserve());let r=De.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||De.delete(t),De.size||(cancelAnimationFrame(zp),or=!1)}}}}var $p,He=new Map,Wp=()=>{He.forEach((t,e)=>{if(!e.isConnected){He.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)))}),He.size!==0&&($p=window.requestAnimationFrame(Wp))};function Gp(t,e){return{observe(){let o=He.size===0;He.has(t)?He.get(t).callbacks.push(e):He.set(t,{visible:void 0,callbacks:[e]}),o&&Wp()},unobserve(){let o=He.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||He.delete(t),He.size||cancelAnimationFrame($p)}}}}var Ri=["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 Pi(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function So(t){return parseFloat(t)}function nr(t){return Math.round(t*1e6)}function Xp(t){return t/1e6}function Ai(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=So(t.width),r=So(t.borderLeftWidth),i=So(t.borderRightWidth),a=So(t.paddingRight),l=Xp(nr(s)-nr(r)-nr(i)),c=Xp(nr(n));if(l-c>2){let d=l-c;o.style.paddingRight=`${a+d}px`}}function gn(t,e={}){var d;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};Pi(n,o,Ri),Ai(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=Gp(t,()=>{Pi(n,o,Ri),Ai(n,t,o),r(),setTimeout(r,0)}),a,l=!0,c=Ii(t,p=>{if(p===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),p.height===0&&p.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Pi(n,o,Ri),Ai(n,t,o),r(),o.style.top=`${p.top}px`,o.style.left=`${p.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let g=e.closestScrollElement.getBoundingClientRect(),u=window.getComputedStyle(e.closestScrollElement),f=So(u.borderTopWidth),m=So(u.borderBottomWidth),v=g.top+f-p.top,T=p.top+p.height+-(g.top+g.height-m);o.style.clipPath=`inset(${v}px 0px ${T}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(d=t.parentElement)==null||d.appendChild(o),c.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),c.unobserve(),i.unobserve()}]}var Zp=(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{C.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Rf(t){return t.offsetParent!==null}function Qp(t){if(!Rf(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 sr(t,e,o=100){let n=Qp(t);e({isVisible:n});let s=setInterval(()=>{let r=Qp(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var j=require("react/jsx-runtime");var Jp=Zp("showTabHint",!0),mn=class t{static version="10.12.1-beta.9";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 st(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let d={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Hp({broadcast:(p,g,u)=>{this.broadcastEvents.send(p,g,u)},emit:(p,g,u)=>this.emit(p,g,u),handleAfterSendMessage:p=>this.handleAfterSendMessage(p),handleInputChanged:p=>this.handleInputChanged(p),handleKeyDown:p=>this.handleKeyDown(p),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:p=>this.logSendMessage(p),onUpdateShowTabHint:p=>Jp.update(p),sendEvent:(p,g)=>this.deepdeskApi.sendEvent(p,g)})]};o&&Object.assign(d,{deepdeskBrokerAPI:new un(o)}),this.store=Dp(d),this.broadcastEvents=new wp({debug:!0,deepdeskUrl:c,eventMap:Ga(this.store),createCustomChannel:l}),this.store.dispatch(Jo(Jp.value())),this.store.dispatch(Cn({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?(C.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(C.warn("Profile has not been loaded (yet)"),!0):(C.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Gt(null)),this.store.dispatch(Ue()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ee(n)&&ra(n)!=="loading"&&(o(),e())});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(Ue())).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){C.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(pr({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(kn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(In({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(ur(e))).payload}async postMessages(e){return(await this.store.dispatch(Pn(e))).payload}async updateConversation(e){return(await this.store.dispatch(Rn(e))).payload}resetConversation(){this.store.dispatch(O()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch($e());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Cn(e))}setVisitorInfo(e){this.store.dispatch(Na(e))}async setAgentInfo(e){await this.store.dispatch(Io(e))}async setAgentSettings(e){await this.store.dispatch(fr(e))}async getAgentSettings(){return(await this.store.dispatch(hr())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(vs()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(On(e))}notifyKeyDown(e){this.store.dispatch(Mn(e))}notifyPaste(e,o){this.store.dispatch(Ia({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Ea(e))}notifyExternalSuggestion(e){this.store.dispatch(xe(e)),this.store.dispatch(je())}async evaluateRule(e,o={}){let{payload:n,error:s}=await this.store.dispatch(Ve({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(ut({collapse:!1})),this.inputMediator&&this.store.dispatch(xa({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Pe([])))}handleKeyDown(e){let{overlayCollapsed:o}=this.state.ui,{textSuggestions:n,selectedSuggestionIndex:s,selection:r}=this.state.input,{inlineSuggestions:i}=this.state.settings,a=n.length>0,l=s!==-1;if(this.store.dispatch(ka(va(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()))},d=()=>{o||!a||i&&s<=0||r&&(e.shiftKey||(this.store.dispatch(Ta()),e.preventDefault(),!i&&(this.state.input.selectedSuggestionIndex===-1?this.store.dispatch(ko()):this.stageSelectedSuggestion({inputType:"arrow"}))))};switch(e.key){case"Up":case"ArrowUp":i?d():c();return;case"Down":case"ArrowDown":{i?c():d();return}case"Esc":case"Escape":{i&&l&&this.store.dispatch(at(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(at(-1)),this.store.dispatch(ko()),e.preventDefault()):o||(this.store.dispatch(ut({collapse:!0})),this.store.dispatch(Rc(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:p}=this.state.input,g=p.text.substring(0,p.selection.end),{tabCompletionSuggestion:u}=this.state.input;this.store.dispatch(Jo(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&u&&u.text.startsWith(g)&&(this.store.dispatch(xe({text:u.text,suggestion:u,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(je())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ra()),this.store.dispatch(Pe([]))}handlingTimeStart(){this.state.handlingTime.startTime||(C.info("Start handling time"),this.store.dispatch(kp()))}handlingTimeStop(){this.state.handlingTime.startTime&&(C.info("Stop handling time"),this.store.dispatch(Qs()))}logSendMessage(e){let o=Bp("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)}logHandlingTime(){let e=Fp(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Ip())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(je()),this.store.dispatch(Ct(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(xe({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){C.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),C.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]=gn(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,Se.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]=gn(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{(0,Se.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,Se.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),C.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()?(C.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(Aa(n.metrics))):C.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(!tr(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:d,isEmbedded:p,detectSubmit:g,insertLink:u,inputMediator:f,closestScrollSelector:m,appendOverlayTo:v,inlineSuggestions:T,floatingMenu:_}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:d,showTextSuggestions:i,insertLink:u,isEmbedded:p,inlineSuggestions:T,floatingMenu:!!_}),o.automaticHandlingTime&&this.setupHandlingTime(e),Dt(e),this.inputMediator=f||(mt(e)?new Ut(e):new Kt(e)),this.inputMediator.on("change",({plainText:S})=>{this.notifyInputChanged(S)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Pa({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",S=>{this.notifyKeyDown(S)}),this.inputMediator.on("paste",({pastedText:S,selectionText:N})=>{this.notifyPaste(S,N)}),this.inputMediator.on("cut",({selectionText:S})=>{this.notifyCut(S)});let y=m&&Kp(e,m)||void 0;if(T){let{customStyles:S,appendOverlayTo:N}=o;if(mt(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let U=this.createInlineContainer(e,"deepdesk-caret");(0,Se.render)((0,j.jsx)(Ft,{store:this.store,customStyles:S,children:(0,j.jsx)(Et,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(Fc,{})})}),U),this.inputMediator.on("caret",B=>{this.store.dispatch(Pe([])),B?(U.style.display="block",U.style.top=`${B.top}px`,U.style.left=`${B.left}px`):U.style.display="none"});let V=this.overlayContainerFactory("floating-menu",y||e,{appendTo:typeof _=="object"&&"appendOverlayTo"in _?_.appendOverlayTo:N},S==null?void 0:S.floatingMenuRootNode);(0,Se.render)((0,j.jsx)(Ft,{store:this.store,customStyles:S,children:(0,j.jsx)(Et,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(Tc,{onLogIn:()=>this.loginViaPopup().catch(B=>C.warn(B.message))})})}),V)}else{let S=this.overlayContainerFactory("deepdesk-tab-completion",y||e,{appendTo:v,closestScrollElement:y,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),N=this.overlayContainerFactory("deepdesk-suggestions-overlay",y||e,{appendTo:v},n==null?void 0:n.suggestionsRootNode);(0,Se.render)((0,j.jsx)(Ft,{store:this.store,customStyles:n,children:(0,j.jsx)(Et,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(wd,{inputElement:e})})}),S),(0,Se.render)((0,j.jsx)(Ft,{store:this.store,customStyles:n,children:(0,j.jsx)(Et,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(Xc,{onLogIn:()=>this.loginViaPopup().catch(U=>C.warn(U.message))})})}),N)}(0,Se.render)((0,j.jsx)(Ft,{store:this.store,customStyles:n,children:(0,j.jsx)(Et,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(vc,{})})}),this.createContainer("deepdesk-overlays"));let x;this.inputMediator.on("selection",S=>{clearTimeout(x),S===null?x=setTimeout(()=>{S!==null&&this.store.dispatch(gr(S))},500):this.store.dispatch(gr(S))}),this.inputMediator.on("disabled",()=>{var S;(S=this.inputMediator)==null||S.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{g&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch($r(!1))),this.inputMediator.on("focus",()=>this.store.dispatch($r(!0))),this.store.dispatch(ba({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(je()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var S;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((S=this.state.conversation.current)==null?void 0:S.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&C.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,Se.render)((0,j.jsx)(Ft,{store:this.store,customStyles:n,children:(0,j.jsx)(Et,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(vp,{onLogIn:()=>this.loginViaPopup().catch(i=>C.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,Se.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=sr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Up(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(Xo());let e=pt(this.state);e&&(await this.store.dispatch($o()),this.store.dispatch(Cn({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=()=>{d&&!d.closed&&d.close(),window.removeEventListener("message",p),clearInterval(g)};r.onmessage=async u=>{var f,m;if((f=u.data)!=null&&f.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((m=u.data)==null?void 0:m.jwt),await this.isLoggedIn(),this.broadcastEvents.send(Po),l=!0,s.port1.close(),o()}catch(v){console.error(v),n(v)}finally{l=!0,c()}};let d=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");d===null&&n(new Error("Popup blocked by browser"));let p=async u=>{var f;if(u.origin===a.origin)switch((f=u.data)==null?void 0:f.type){case"deepdesk-popup-loaded":{try{let m=JSON.stringify({type:"deepdesk-popup-create-channel"});d==null||d.postMessage(m,a.origin,[s.port2])}catch(m){C.error("Error posting message to popup",m),n(m)}break}case"deepdesk-popup-error":{c(),u.data.message==="Timeout"&&C.warn("Popup timed out. Check if the account's platform url is configured correctly."),n(new Error(u.data.message));break}}};window.addEventListener("message",p);let g=setInterval(()=>{d&&!d.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(C.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;C.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=hs(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Ee()):this.store.dispatch(Ie(n))})}catch(n){this.handleError(n)}}};async function Yp(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 eu(t,e,o={}){let n=o.replace?St(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?St(t,o.selectionAfter.start,o.selectionAfter.end):(n.collapse(!1),n),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(i)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function Pf(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 Af(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 tu(t,e){return!t.contains(e)||e===t?null:e.parentNode===t?e:tu(t,e.parentNode)}async function ou(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?Pf(e):Af(e);if(o){let d=l.startContainer===t?t.childNodes[l.startOffset]:l.startContainer,p=tu(t,d)??t.firstChild;t.insertBefore(c,(p==null?void 0:p.nextSibling)??null)}else l.insertNode(c),l.collapse(!1)};return Promise.resolve(r()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!s)try{s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function nu(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function su(t,e,o){await new st(t).authenticateWithKey(e,o)}async function ru(t){let o=await new Re(t).get("/platform/config/",{version:null});return A(o)}async function Lf(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 iu(t,e){let o=await Lf(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});
9
+ `);break}default:break}p&&i++}return l(t),a}var _p=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(_p||{}),nt=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();rt(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(_p).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}};function xp(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Kt=class extends nt{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),dn(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!xp(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!xp(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&&Sp(this.element,o.start,o.end))return o;let n=ho(this.element);return n.collapse(!1),cn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return dn(this.element,St(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return(s=this.observer)==null||s.takeRecords(),Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};var Ut=class extends nt{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())}};function bp(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}function vf(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}}var xi=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()}},bi=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=bp(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()}},wi=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(),C.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 bi(e,this.deepdeskUrl,{debug:!0}):new xi(e),n=s=>{var i,a;if(s.origin!==this.deepdeskUrl)return;let r=vf(s.data);typeof r!="object"||r.type!=="event"||r.channel!==e||(C.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;C.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)}},wp=wi;var yo=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Ci=t=>new Promise(e=>{setTimeout(e,t)});var vo=class extends yo{name="ClientError"},Ti=class extends yo{name="ServerError"},Ie=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:d=500,refreshTokenOn401:p=!0,retryOnError:g=x=>x instanceof TypeError,retryOnResponse:u=x=>x.status>=500,version:f="v1",...m}=o,v={credentials:"include",...m,headers:{"Content-Type":"application/json",...m.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(v.headers={...v.headers,"X-CSRFToken":this.csrfToken}),typeof f=="string"&&(v.headers={...v.headers,"X-Deepdesk-API-Version":f});let T=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 y=async()=>(T--,a(i,v).then(async x=>u(x)&&!r.isAborted&&T>0?(await Ci(d),y()):x.status===401&&p===!0&&_===!1?(_=!0,await this.refreshToken(),y()):x).catch(async x=>{if(g(x)&&!r.isAborted&&T>0)return await Ci(d),y();throw x}));y().then(x=>x.json().catch(()=>null).then(S=>{x.status>=500?s(new Ti("Server Error",S)):x.status===401?s(new vo("Unauthorized",S)):x.status===403?s(new vo("Forbidden",S)):x.status===404?s(new vo("Not Found",S)):x.status>=400&&s(new vo("Bad Request",S)),delete this.latestRequestByUrl[i],n(S)})).catch(x=>{s(x)})})}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var Sf;(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||={})})(Sf||={});function Zs(t){return{...A(t),tags:t.tags}}var st=class t{constructor(e,o={}){this.options=o;this.client=new Ie(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(),C.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...q(e),tags:e.tags},{version:"v2"});return Zs(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return A(o)}async getKnowledgeAssistant(e){let o=await this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{version:null});return A(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return A(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return A(e)}async checkUserExists(e){let{exists:o}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return o}async getConversationBySessionId(e,o={}){await this.preflight(),C.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 C.info(`Successfully retrieved conversation ${r.id} for session ${e}`),Zs(r)}async isConversationSupported(e,o={}){C.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=q(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return Zs(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...q(s),tags:s.tags})),{version:"v2"})).map(s=>Zs(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",q({...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:q({...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 C.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.preflight(),await this.client.post("/apis/admin/session/api-key/",q(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}`,q(o),{abortLatest:!0})).map(r=>({...A(r),text:r.text||r.url||r.message,source:n,type:n})).filter((r,i,a)=>i===a.findIndex(l=>l.text===r.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(e,o){return(await this.client.post(`/api/conversations/${e}/autocomplete`,q(o),{abortLatest:!0})).map(s=>({score:1,source:s.source,sourceText:s.source_text,text:s.label,trainingJobs:s.training_jobs,searchKeywords:s.search_keywords,type:s.source})).filter((s,r,i)=>r===i.findIndex(a=>a.text===s.text))}async getPinnedMessages(e){let o=await this.client.get(`/api/conversations/${e}/sticky-messages`,{abortLatest:!0});return A(o).map(n=>({...n,text:n.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(e){let o=await this.client.post("/api/style-suggestions",q(e),{abortLatest:!0});return A(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,q(e),{version:"v2"});return A(o)}async knowledgeAssist(e,o,n,s={}){let r=await this.client.post(`/api/knowledge-assist/assistants/${n}/search`,q({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 A(r)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return A(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return A(e.token)}async getCsrfToken(){let{token:e}=await this.client.get("/apis/admin/session/csrf/",{version:null});return e}async verifyLoginToken(e){let o=await this.client.post("/apis/admin/session/passwordless/login/",{token:e},{version:null});return A(o)}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 A(i.cues)}async translateMessages(e){let o=await this.client.post("/api/translate",q(e),{version:"v2"});return A(o)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(ea);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&C.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var pn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(mr(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,A(s))}catch{C.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 _f;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(_f||={});var un=class{constructor(e,o={}){this.apiUrl=e;this.client=new Ie(e,o)}client;streams={};logger=C;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return A(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,q(o));return A(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,q(o))}async getAutoflows(e){let o=await this.client.get(`/sessions/${e}/autoflows`);return A(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",q(e));return A(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new pn(`${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 er=require("@reduxjs/toolkit");var Tp=require("@reduxjs/toolkit");var Cp={startTime:null,stopTime:null},Ep=(0,Tp.createSlice)({name:"handlingTime",initialState:Cp,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(O,()=>Cp)}}),{handlingTimeStart:kp,handlingTimeStop:Qs,handlingTimeReset:Rp}=Ep.actions,Ip=Ep.reducer;var Pp=(t={})=>{let e={onAuthError:Gt(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var Ys=require("@reduxjs/toolkit");var Js={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var zt=(0,Ys.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 Js.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),xf=(0,Ys.createSlice)({name:"styleSuggestions",initialState:Js,reducers:{},extraReducers:t=>{t.addCase(zt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(zt.rejected,e=>{e.fetchState="error"}).addCase(zt.fulfilled,(e,o)=>{e.fetchState="done",rt(e.list,o.payload)||(e.list=o.payload)}).addCase(Ct,e=>{e.list=Js.list}).addCase(O,()=>Js)}}),Ap=xf.reducer;var Lp=(t={})=>{let e,o=!0,n={getStyleSuggestions:zt,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:d}=c.settings;if(!((u=c.conversation.current)==null?void 0:u.id)||!d)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 bf(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Mp=(t={})=>{let e={getTextSuggestions:Re,getAutocompleteSuggestions:Zo,debounce:200,check:co,...t},o;return n=>s=>r=>{var m;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:d}=l.settings,p=(m=l.conversation.current)==null?void 0:m.id,g=r.type===vs.toString();if(!p||!c&&!d)return a;let{input:{userCommitted:u}}=l;return bf(u,i)&&!g||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let v=Zt(l);v===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(v))},g?0:e.debounce)),a}};var Op=zt.fulfilled.toString();function wf(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 Np=t=>e=>o=>n=>{var c;if(n.type!==Op){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=wf(s,i);n.type===Op&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var Cf=(0,er.combineReducers)({answer:Jl,auth:pa,autoflows:Id,conversation:fa,contentTypes:fl,customMessages:Fd,passwordlessToken:zd,entities:Fl,knowledgeAssistant:Xl,handlingTime:Ip,info:Da,input:La,settings:sa,profile:tc,search:qa,summary:jl,styleSuggestions:Ap,ui:Ac,rules:Wa,textSuggestions:dc});function Dp(t){return(0,er.configureStore)({reducer:Cf,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Pp(),Mp({debounce:200}),Lp({debounce:500}),Np(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Tf=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Ef=t=>e=>o=>n=>{var a;let s=e.getState(),r=cr("inlineSuggestions")(s);switch(n.type){case Gt.toString():{!n.payload&&t.emit("logout",void 0);break}case xe.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:Tf(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Ln.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:d}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:d},{mayApplyChanges:!0});break}case Nn.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 Ee.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case $e.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 Mn.toString():t.handleKeyDown(n.payload);break;case Ct.toString():t.logSendMessage(n.payload);break;case On.toString():t.handleInputChanged(n.payload);break;case je.fulfilled.toString():t.broadcast(vr,n.payload,!1),t.emit("cues",n.payload);break;default:break}let i=o(n);switch(n.type){case Ct.toString():t.handleAfterSendMessage(n.payload);break;case Jo.toString():t.onUpdateShowTabHint(n.payload);break;case Qs.toString():t.logHandlingTime();break;case xe.toString():{r&&(e.dispatch(Pe([])),e.dispatch(qe()));break}case Pe.toString():{r&&n.payload.length>0&&e.dispatch(at(0));break}default:break}return i},Hp=Ef;function Ei(t){return t.toISOString().replace("T"," ").replace("Z","")}function Fp(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:Ei(o),timeStop:Ei(n)}}function Bp(t,e,o){var U,V,B;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:d,pastes:p,cuts:g,deletions:u,textSuggestions:f,offeredTextSuggestions:m}}=e[t],v=n.length,_=f.reduce((P,{text:M,searchTerm:R})=>P+M.length-(R?R.length:0),0),y=c??Date.now(),x=(Date.now()-y)/1e3+(d||0),S=s/x,N=f.reduce((P,{searchTerm:M})=>P+(M?M.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:p,cuts:g,deletions:u,lenTextTyped:s+N,lenTextTotal:v,lenTextAssisted:_,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:x,charsPerSecond:S,numPastes:l,textSuggestionsV2:f,suggestionsCounters:[{source:"gpt",countOffered:m.filter(P=>P.source==="gpt").length}],agentId:(U=e.info.agentInfo)==null?void 0:U.agentId,agentName:(V=e.info.agentInfo)==null?void 0:V.agentName,agentEmail:(B=e.info.agentInfo)==null?void 0:B.agentEmail}}function ki(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return ki(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?ki(s,e):null}function Kp(t,e){return ki(t,e)}function Up(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function kf(t){return typeof t=="object"&&t!==null&&"tagName"in t}function tr(t){return kf(t)&&(mt(t)||ks(t))}var zp,De=new Map,Rf=["bottom","height","left","right","top","width"],If=(t={},e={})=>Rf.some(o=>t[o]!==e[o]);function qp(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,...qp(e)]:[]}function jp(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var or=!1,Vp=()=>{or=!0;let t=[];if(De.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),De.delete(o);return}let n=o.getBoundingClientRect();If(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(jp,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),De.size===0){or=!1;return}zp=window.requestAnimationFrame(Vp)};function Ri(t,e){let o=qp(t),n=[],s=o.map((r,i)=>Ri(r,a=>{n[i]=a;let l=De.get(t);if(!l)return;let c=n.reduce(jp,l.rect);l.callbacks.forEach(d=>d(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),De.has(t)){let i=De.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else De.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!or&&Vp()},unobserve(){s.forEach(i=>i.unobserve());let r=De.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||De.delete(t),De.size||(cancelAnimationFrame(zp),or=!1)}}}}var $p,He=new Map,Wp=()=>{He.forEach((t,e)=>{if(!e.isConnected){He.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)))}),He.size!==0&&($p=window.requestAnimationFrame(Wp))};function Gp(t,e){return{observe(){let o=He.size===0;He.has(t)?He.get(t).callbacks.push(e):He.set(t,{visible:void 0,callbacks:[e]}),o&&Wp()},unobserve(){let o=He.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||He.delete(t),He.size||cancelAnimationFrame($p)}}}}var Ii=["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 Pi(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function So(t){return parseFloat(t)}function nr(t){return Math.round(t*1e6)}function Xp(t){return t/1e6}function Ai(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=So(t.width),r=So(t.borderLeftWidth),i=So(t.borderRightWidth),a=So(t.paddingRight),l=Xp(nr(s)-nr(r)-nr(i)),c=Xp(nr(n));if(l-c>2){let d=l-c;o.style.paddingRight=`${a+d}px`}}function gn(t,e={}){var d;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};Pi(n,o,Ii),Ai(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=Gp(t,()=>{Pi(n,o,Ii),Ai(n,t,o),r(),setTimeout(r,0)}),a,l=!0,c=Ri(t,p=>{if(p===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),p.height===0&&p.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Pi(n,o,Ii),Ai(n,t,o),r(),o.style.top=`${p.top}px`,o.style.left=`${p.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let g=e.closestScrollElement.getBoundingClientRect(),u=window.getComputedStyle(e.closestScrollElement),f=So(u.borderTopWidth),m=So(u.borderBottomWidth),v=g.top+f-p.top,T=p.top+p.height+-(g.top+g.height-m);o.style.clipPath=`inset(${v}px 0px ${T}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(d=t.parentElement)==null||d.appendChild(o),c.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),c.unobserve(),i.unobserve()}]}var Zp=(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{C.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Pf(t){return t.offsetParent!==null}function Qp(t){if(!Pf(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 sr(t,e,o=100){let n=Qp(t);e({isVisible:n});let s=setInterval(()=>{let r=Qp(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var j=require("react/jsx-runtime");var Jp=Zp("showTabHint",!0),mn=class t{static version="11.0.0";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new st(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let d={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Hp({broadcast:(p,g,u)=>{this.broadcastEvents.send(p,g,u)},emit:(p,g,u)=>this.emit(p,g,u),handleAfterSendMessage:p=>this.handleAfterSendMessage(p),handleInputChanged:p=>this.handleInputChanged(p),handleKeyDown:p=>this.handleKeyDown(p),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:p=>this.logSendMessage(p),onUpdateShowTabHint:p=>Jp.update(p),sendEvent:(p,g)=>this.deepdeskApi.sendEvent(p,g)})]};o&&Object.assign(d,{deepdeskBrokerAPI:new un(o)}),this.store=Dp(d),this.broadcastEvents=new wp({debug:!0,deepdeskUrl:c,eventMap:Ga(this.store),createCustomChannel:l}),this.store.dispatch(Jo(Jp.value())),this.store.dispatch(Cn({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?(C.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(C.warn("Profile has not been loaded (yet)"),!0):(C.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Gt(null)),this.store.dispatch(Ue()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ee(n)&&ra(n)!=="loading"&&(o(),e())});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(Ue())).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){C.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(pr({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(kn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Rn({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(ur(e))).payload}async postMessages(e){return(await this.store.dispatch(Pn(e))).payload}async updateConversation(e){return(await this.store.dispatch(In(e))).payload}resetConversation(){this.store.dispatch(O()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch($e());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Cn(e))}setVisitorInfo(e){this.store.dispatch(Na(e))}async setAgentInfo(e){await this.store.dispatch(Ro(e))}async setAgentSettings(e){await this.store.dispatch(fr(e))}async getAgentSettings(){return(await this.store.dispatch(hr())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(vs()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(On(e))}notifyKeyDown(e){this.store.dispatch(Mn(e))}notifyPaste(e,o){this.store.dispatch(Ra({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Ea(e))}notifyExternalSuggestion(e){this.store.dispatch(xe(e)),this.store.dispatch(qe())}async evaluateRule(e,o={}){let{payload:n,error:s}=await this.store.dispatch(je({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(ut({collapse:!1})),this.inputMediator&&this.store.dispatch(xa({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Pe([])))}handleKeyDown(e){let{overlayCollapsed:o}=this.state.ui,{textSuggestions:n,selectedSuggestionIndex:s,selection:r}=this.state.input,{inlineSuggestions:i}=this.state.settings,a=n.length>0,l=s!==-1;if(this.store.dispatch(ka(va(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()))},d=()=>{o||!a||i&&s<=0||r&&(e.shiftKey||(this.store.dispatch(Ta()),e.preventDefault(),!i&&(this.state.input.selectedSuggestionIndex===-1?this.store.dispatch(ko()):this.stageSelectedSuggestion({inputType:"arrow"}))))};switch(e.key){case"Up":case"ArrowUp":i?d():c();return;case"Down":case"ArrowDown":{i?c():d();return}case"Esc":case"Escape":{i&&l&&this.store.dispatch(at(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(at(-1)),this.store.dispatch(ko()),e.preventDefault()):o||(this.store.dispatch(ut({collapse:!0})),this.store.dispatch(Ic(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:p}=this.state.input,g=p.text.substring(0,p.selection.end),{tabCompletionSuggestion:u}=this.state.input;this.store.dispatch(Jo(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&u&&u.text.startsWith(g)&&(this.store.dispatch(xe({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(Ia()),this.store.dispatch(Pe([]))}handlingTimeStart(){this.state.handlingTime.startTime||(C.info("Start handling time"),this.store.dispatch(kp()))}handlingTimeStop(){this.state.handlingTime.startTime&&(C.info("Stop handling time"),this.store.dispatch(Qs()))}logSendMessage(e){let o=Bp("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)}logHandlingTime(){let e=Fp(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Rp())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(qe()),this.store.dispatch(Ct(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(xe({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){C.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),C.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]=gn(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,Se.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]=gn(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{(0,Se.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,Se.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),C.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()?(C.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(Aa(n.metrics))):C.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(!tr(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:d,isEmbedded:p,detectSubmit:g,insertLink:u,inputMediator:f,closestScrollSelector:m,appendOverlayTo:v,inlineSuggestions:T,floatingMenu:_}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:d,showTextSuggestions:i,insertLink:u,isEmbedded:p,inlineSuggestions:T,floatingMenu:!!_}),o.automaticHandlingTime&&this.setupHandlingTime(e),Dt(e),this.inputMediator=f||(mt(e)?new Ut(e):new Kt(e)),this.inputMediator.on("change",({plainText:S})=>{this.notifyInputChanged(S)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Pa({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",S=>{this.notifyKeyDown(S)}),this.inputMediator.on("paste",({pastedText:S,selectionText:N})=>{this.notifyPaste(S,N)}),this.inputMediator.on("cut",({selectionText:S})=>{this.notifyCut(S)});let y=m&&Kp(e,m)||void 0;if(T){let{customStyles:S,appendOverlayTo:N}=o;if(mt(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let U=this.createInlineContainer(e,"deepdesk-caret");(0,Se.render)((0,j.jsx)(Ft,{store:this.store,customStyles:S,children:(0,j.jsx)(Et,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(Fc,{})})}),U),this.inputMediator.on("caret",B=>{this.store.dispatch(Pe([])),B?(U.style.display="block",U.style.top=`${B.top}px`,U.style.left=`${B.left}px`):U.style.display="none"});let V=this.overlayContainerFactory("floating-menu",y||e,{appendTo:typeof _=="object"&&"appendOverlayTo"in _?_.appendOverlayTo:N},S==null?void 0:S.floatingMenuRootNode);(0,Se.render)((0,j.jsx)(Ft,{store:this.store,customStyles:S,children:(0,j.jsx)(Et,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(Tc,{onLogIn:()=>this.loginViaPopup().catch(B=>C.warn(B.message))})})}),V)}else{let S=this.overlayContainerFactory("deepdesk-tab-completion",y||e,{appendTo:v,closestScrollElement:y,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),N=this.overlayContainerFactory("deepdesk-suggestions-overlay",y||e,{appendTo:v},n==null?void 0:n.suggestionsRootNode);(0,Se.render)((0,j.jsx)(Ft,{store:this.store,customStyles:n,children:(0,j.jsx)(Et,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(wd,{inputElement:e})})}),S),(0,Se.render)((0,j.jsx)(Ft,{store:this.store,customStyles:n,children:(0,j.jsx)(Et,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(Xc,{onLogIn:()=>this.loginViaPopup().catch(U=>C.warn(U.message))})})}),N)}(0,Se.render)((0,j.jsx)(Ft,{store:this.store,customStyles:n,children:(0,j.jsx)(Et,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(vc,{})})}),this.createContainer("deepdesk-overlays"));let x;this.inputMediator.on("selection",S=>{clearTimeout(x),S===null?x=setTimeout(()=>{S!==null&&this.store.dispatch(gr(S))},500):this.store.dispatch(gr(S))}),this.inputMediator.on("disabled",()=>{var S;(S=this.inputMediator)==null||S.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{g&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch($r(!1))),this.inputMediator.on("focus",()=>this.store.dispatch($r(!0))),this.store.dispatch(ba({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 S;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((S=this.state.conversation.current)==null?void 0:S.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&C.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,Se.render)((0,j.jsx)(Ft,{store:this.store,customStyles:n,children:(0,j.jsx)(Et,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(vp,{onLogIn:()=>this.loginViaPopup().catch(i=>C.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,Se.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=sr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Up(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(Xo());let e=pt(this.state);e&&(await this.store.dispatch($o()),this.store.dispatch(Cn({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=()=>{d&&!d.closed&&d.close(),window.removeEventListener("message",p),clearInterval(g)};r.onmessage=async u=>{var f,m;if((f=u.data)!=null&&f.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((m=u.data)==null?void 0:m.jwt),await this.isLoggedIn(),this.broadcastEvents.send(Po),l=!0,s.port1.close(),o()}catch(v){console.error(v),n(v)}finally{l=!0,c()}};let d=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");d===null&&n(new Error("Popup blocked by browser"));let p=async u=>{var f;if(u.origin===a.origin)switch((f=u.data)==null?void 0:f.type){case"deepdesk-popup-loaded":{try{let m=JSON.stringify({type:"deepdesk-popup-create-channel"});d==null||d.postMessage(m,a.origin,[s.port2])}catch(m){C.error("Error posting message to popup",m),n(m)}break}case"deepdesk-popup-error":{c(),u.data.message==="Timeout"&&C.warn("Popup timed out. Check if the account's platform url is configured correctly."),n(new Error(u.data.message));break}}};window.addEventListener("message",p);let g=setInterval(()=>{d&&!d.closed||(c(),l||n(new Error("Popup closed by user")))},200);this.unmountHandlers.push(c)})}translateMessages(e){return this.deepdeskApi.translateMessages(e)}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(C.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;C.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=hs(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Ee()):this.store.dispatch(Re(n))})}catch(n){this.handleError(n)}}};async function Yp(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 eu(t,e,o={}){let n=o.replace?St(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?St(t,o.selectionAfter.start,o.selectionAfter.end):(n.collapse(!1),n),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(i)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function Af(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 Lf(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 tu(t,e){return!t.contains(e)||e===t?null:e.parentNode===t?e:tu(t,e.parentNode)}async function ou(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?Af(e):Lf(e);if(o){let d=l.startContainer===t?t.childNodes[l.startOffset]:l.startContainer,p=tu(t,d)??t.firstChild;t.insertBefore(c,(p==null?void 0:p.nextSibling)??null)}else l.insertNode(c),l.collapse(!1)};return Promise.resolve(r()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!s)try{s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function nu(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function su(t,e,o){await new st(t).authenticateWithKey(e,o)}async function ru(t){let o=await new Ie(t).get("/platform/config/",{version:null});return A(o)}async function Mf(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 iu(t,e){let o=await Mf(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});