@deepdesk/deepdesk-sdk 10.10.1 → 10.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +7 -7
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +7 -7
- package/dist/index.iife.js +13 -13
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";var Xu=Object.create;var An=Object.defineProperty;var Qu=Object.getOwnPropertyDescriptor;var Zu=Object.getOwnPropertyNames;var Ju=Object.getPrototypeOf,Yu=Object.prototype.hasOwnProperty;var W=(t,e)=>{for(var o in e)An(t,o,{get:e[o],enumerable:!0})},ua=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Zu(e))!Yu.call(t,s)&&s!==o&&An(t,s,{get:()=>e[s],enumerable:!(n=Qu(e,s))||n.enumerable});return t};var k=(t,e,o)=>(o=t!=null?Xu(Ju(t)):{},ua(e||!t||!t.__esModule?An(o,"default",{value:t,enumerable:!0}):o,t)),eg=t=>ua(An({},"__esModule",{value:!0}),t);var Ch={};W(Ch,{Card:()=>F,ContentEditableInput:()=>Gt,DeepdeskAPI:()=>at,DeepdeskSDK:()=>kn,HTTPClient:()=>Ne,InputMediator:()=>qe,InputType:()=>ct,KeyboardHint:()=>Hn,Label:()=>Bn,Locale:()=>Ho,Section:()=>lt,SectionList:()=>Fn,Sources:()=>Te,Suggestion:()=>D,SuggestionList:()=>Se,TextAreaInput:()=>We,ToggleButton:()=>It,attachFile:()=>Bu,authenticateWithKey:()=>Hu,createFullRange:()=>Po,createOverlayContainer:()=>Mt,createRangeFromOffsets:()=>Et,escapeHTML:()=>uo,fetchPlatformConfig:()=>kr,formatTextMarkup:()=>Du,getRangeOffsets:()=>Cn,getRangeText:()=>wn,insertCKEditor:()=>Ou,isSupportedInputElement:()=>wr,updateContentEditable:()=>Mu,updateTextArea:()=>Lu,useStyles:()=>v,waitForElementVisibilityChange:()=>Tr});module.exports=eg(Ch);var Nn=k(require("classnames")),he=k(require("react"));var Ln=k(require("react")),ga=k(require("classnames")),Oo=Ln.default.createContext({});function v(t,e){let{debug:o,...n}=(0,Ln.useContext)(Oo),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,ga.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var ma={root:"_root_vr71j_1"};var kt=require("react/jsx-runtime"),Mn=()=>(0,kt.jsxs)("svg",{className:ma.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,kt.jsx)("defs",{children:(0,kt.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,kt.jsx)("title",{children:"Failed loading image"}),(0,kt.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 Ir={root:"_root_4e7lf_1",imageWrapper:"_imageWrapper_4e7lf_7",image:"_image_4e7lf_7",content:"_content_4e7lf_24",title:"_title_4e7lf_35",contentIsCropped:"_contentIsCropped_4e7lf_45",lineClamp:"_lineClamp_4e7lf_51"};var Rt=require("react/jsx-runtime"),On=(0,he.createContext)(Ir),tg=({title:t,src:e})=>{let o=(0,he.useContext)(On),[n,s]=(0,he.useState)(!1);return(0,he.useEffect)(()=>{s(!1)},[e]),(0,Rt.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,Rt.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,Rt.jsx)(Mn,{})})},og=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,he.useContext)(On);return(0,Rt.jsx)("div",{className:(0,Nn.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},ng=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,he.useContext)(On);return he.default.createElement(t,{className:(0,Nn.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Dn=({children:t})=>{let e=v("Card",Ir);return(0,Rt.jsx)("div",{className:(0,Nn.default)(e.root),children:(0,Rt.jsx)(On.Provider,{value:e,children:t})})};Dn.Image=tg;Dn.Content=og;Dn.Title=ng;var F=Dn;var ha=k(require("classnames"));var fa={root:"_root_cq1yq_1"};var ya=require("react/jsx-runtime");var sg={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},rg=({className:t,keyCode:e,...o})=>{let n=v("KeyboardHint",fa);return(0,ya.jsx)("span",{"data-key":sg[e],className:(0,ha.default)(t,n.root),...o})},Hn=rg;var Sa=k(require("classnames"));var va={root:"_root_4a08n_1"};var _a=require("react/jsx-runtime"),ig=({className:t,children:e,...o})=>{let n=v("Label",va);return(0,_a.jsx)("span",{...o,className:(0,Sa.default)(t,n.root),children:e})},Bn=ig;var xa={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var Jt=require("react/jsx-runtime"),ag=({title:t,children:e,type:o,...n})=>{let s=v("Section",xa);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})]})},lt=ag;var Ca=k(require("classnames")),wa=k(require("react"));var ba={root:"_root_19wxp_1"};var Ta=require("react/jsx-runtime"),lg=wa.default.forwardRef(({className:t,children:e},o)=>{let n=v("SectionList",ba);return(0,Ta.jsx)("div",{ref:o,className:(0,Ca.default)(n.root,t),children:e})}),Fn=lg;var Do=k(require("classnames")),ve=k(require("react"));var Pr={root:"_root_ipo0b_11",fadein:"_fadein_ipo0b_1",isClickable:"_isClickable_ipo0b_46",isSelected:"_isSelected_ipo0b_51",actions:"_actions_ipo0b_75",actionsIsFixed:"_actionsIsFixed_ipo0b_97",actionButton:"_actionButton_ipo0b_105",dropdownList:"_dropdownList_ipo0b_126",dropdownButton:"_dropdownButton_ipo0b_141",dropdownItem:"_dropdownItem_ipo0b_151",dropdownItemButton:"_dropdownItemButton_ipo0b_160",actionButtonIsPrimary:"_actionButtonIsPrimary_ipo0b_174",actionButtonIsDisabled:"_actionButtonIsDisabled_ipo0b_178",labels:"_labels_ipo0b_186",label:"_label_ipo0b_186"};var ye=require("react/jsx-runtime"),Yt=(0,ve.createContext)(Pr),cg=({fixed:t,children:e,...o})=>{let n=(0,ve.useContext)(Yt);return(0,ye.jsx)("div",{...o,className:(0,Do.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},pg=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,ve.useContext)(Yt);return(0,ye.jsxs)("div",{className:(0,Do.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,(0,ye.jsx)("ul",{className:r.dropdownList,children:s})]})},dg=({index:t,label:e,onClick:o})=>{let n=(0,ve.useContext)(Yt);return(0,ye.jsx)("li",{className:n.dropdownItem,children:(0,ye.jsx)("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},ug=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,ve.useContext)(Yt);return(0,ye.jsx)("button",{type:"button",className:(0,Do.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},Ar=({labels:t})=>{let e=(0,ve.useContext)(Yt);return(0,ye.jsx)("div",{className:e.labels,children:t.map(o=>(0,ye.jsx)("span",{className:e.label,children:o},o))})},eo=ve.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=v("Suggestion",Pr),l=(0,ve.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,ye.jsx)(s,{...r,ref:i,className:(0,Do.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,ye.jsx)(Yt.Provider,{value:a,children:n})})});eo.Labels=Ar;eo.Actions=cg;eo.ActionButton=ug;eo.DropdownButton=pg;eo.DropdownItem=dg;var D=eo;var ka=k(require("classnames"));var Ea={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var Ra=require("react/jsx-runtime"),gg=({withDivider:t,children:e})=>{let o=v("SuggestionList",Ea);return(0,Ra.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,ka.default)(o.root,{[o.isWithDivider]:t}),children:e})},Se=gg;var Pa=k(require("classnames"));var Ia={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var Kn=require("react/jsx-runtime"),mg=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=v("ToggleButton",Ia);return(0,Kn.jsx)("button",{type:"button",className:(0,Pa.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,Kn.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,Kn.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},It=mg;var Aa=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,to=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var La=/x-deepdesk-(([a-z0-9\-_])+-version)/,Te=(f=>(f.SEARCH="search",f.TEMPLATE="template",f.ELASTIC_SEARCH="search-autocomplete",f.GPT="gpt",f.TRIE="trie",f.TRIE_WITH_TYPOS="trie-with-typos",f.SEMANTIC="semantic",f.TEXT_RECOMMENDATION="text_recommendation",f.URL_RECOMMENDATION="url_recommendation",f.LINK_RECOMMENDATION="link_recommendation",f.PERSONAL_COLLECTION="personal-collection",f.PERSONAL_COLLECTION_SEARCH="personal-collection-search",f.SEARCH_OVERLAY="search-overlay",f.SEARCH_PREVIEW="search-preview",f.SEARCH_URL="search-url",f))(Te||{}),ct=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(ct||{});var we=require("react-dom");var bp=require("react");var Ma=require("@reduxjs/toolkit"),Na=require("react-redux");var Ho=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Ho||{});var fg={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"},Oa=(0,Ma.createSlice)({name:"settings",initialState:fg,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:Bo}=Oa.actions,Lr=t=>e=>e.settings[t],C=t=>(0,Na.useSelector)(Lr(t)),Da=Oa.reducer;var Bc=require("react"),xo=require("react-redux");var De=require("@reduxjs/toolkit"),Ua=require("diff"),za=require("react-redux");function Ha(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function pt(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)=>pt(r,e[i],o-1)):Ha(t)&&Ha(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>pt(t[i],e[i],o-1)):!1}function hg(t){return Math.max(...t.map(e=>e.length))}function yg(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 Ba(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<hg(n);s++){let r=yg(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 vg=2;function Mr(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=Ba(t,vg);return o&&o.text!==e?o:t[0]}var Ee=require("@reduxjs/toolkit"),Fa={current:null,isSupported:null},N=(0,Ee.createAction)("resetConversation"),Un=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},zn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},oo=t=>t.conversation.isSupported,Nr=(0,Ee.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),jn=(0,Ee.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Vn=(0,Ee.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),qn=(0,Ee.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=zn(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),Or=(0,Ee.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})})}),Wn=(0,Ee.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=zn(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Sg=[jn.rejected,Vn.rejected,qn.rejected,Wn.rejected].map(t=>t==null?void 0:t.toString()),_g=(0,Ee.createSlice)({name:"conversation",initialState:Fa,reducers:{},extraReducers:t=>{t.addCase(Nr.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(jn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Vn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Or.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(qn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Wn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(N,()=>Fa).addMatcher(e=>Sg.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),Ka=_g.reducer;var dt={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 $n(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 Xn=(0,De.createAction)("input/replaceText"),Qn=(0,De.createAction)("input/keyDown"),Pt=(0,De.createAction)("input/sendMessage"),Zn=(0,De.createAction)("input/sendEditSuggestionMessage"),Jn=(0,De.createAction)("input/uiInputChange"),Yn=(0,De.createAction)("input/applyImageSuggestion"),X=(0,De.createAction)("input/sendEvent");function Gn(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:l},eventMetrics:{inputType:c},replace:p}=t.stagedSuggestion,d=o==="search"||o==="personal-collection-search",u=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(d||p==="selection")&&(u=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(u=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:u,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:d?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var ja=t=>(0,De.createSlice)({name:t,initialState:dt,reducers:{initialInput(e,o){let{text:n,selection:s,html:r}=o.payload;e.text=n,e.selection.start=(s==null?void 0:s.start)??n.length,e.selection.end=(s==null?void 0:s.end)??n.length,e.userCommitted.text=n,e.userCommitted.selection.start=(s==null?void 0:s.start)??n.length,e.userCommitted.selection.end=(s==null?void 0:s.end)??n.length,e.html=r||null},reset(e){Object.assign(e,{...dt,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=Mr(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(pt(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Gn(e)))},platformInput(e,o){let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end),e.text=n,e.html=s||null},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:d,ctrlKey:u,metaKey:g,altKey:m}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:f}=e,{text:y}=o.payload,E=(0,Ua.diffChars)(f,y);f.length-y.length>1&&e.metrics.deletions.push(...E.filter(h=>h.removed).map(h=>h.value)),e.metrics.numCharsDeleted+=f.length-y.length;break}case"C":case"V":case"X":if(!u&&!g){e.metrics.numCharsTyped+=1;let f=((i=e.selection)==null?void 0:i.start)!==void 0&&((a=e.selection)==null?void 0:a.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}break;case"Shift":break;default:if(!u&&!g&&!m){e.metrics.numCharsTyped+=1;let f=((l=e.selection)==null?void 0:l.start)!==void 0&&((c=e.selection)==null?void 0:c.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=dt.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Gn(e);let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end,e.userCommitted.selection.start=r.start,e.userCommitted.selection.end=r.end),e.text=n,e.html=s||null,e.userCommitted.text=n,e.previousKeyDownEvent=null},stageSuggestion(e,o){let{text:n}=o.payload;switch(e.stagedSuggestion=o.payload,e.tabCompletionSuggestion=void 0,o.payload.replace){case"selection":e.text=`${e.text.slice(0,e.selection.start)}${n}${e.text.slice(e.selection.end)}`,e.selection.end=e.selection.start+n.length,e.selection.start+=n.length;break;case"until-selection-end":e.text=`${n}${e.text.slice(e.selection.end)}`,e.selection.start=n.length,e.selection.end=n.length;break;default:throw new Error(`Unknown replace ${o.payload.replace}`)}o.payload.eventMetrics.inputType==="tab"&&Gn(e)},commitSuggestion(e){Gn(e)},offeredTextSuggestion(e,o){let{text:n,suggestion:{source:s}}=o.payload;e.metrics.offeredTextSuggestions.find(i=>i.text===n)||e.metrics.offeredTextSuggestions.push({text:n,source:s})},registerCut(e,o){let{metrics:n}=e,s=o.payload;e.metrics={...e.metrics,numCharsCut:n.numCharsCut+s.length,cuts:[...n.cuts,s]}},registerPaste(e,o){let{metrics:n}=e,{text:s,selectionText:r}=o.payload,i=n.numCharsDeleted+(r&&r.length?r.length:0),a=r&&r.length?[...n.deletions,r]:n.deletions;e.metrics={...e.metrics,numCharsDeleted:i,deletions:a,numCharsPasted:n.numCharsPasted+s.length,numPaste:n.numPaste+1,pastes:[...n.pastes,s]}},registerKeyDown(e,o){e.previousKeyDownEvent=o.payload},nextTextSuggestionIndex(e){let o=e.textSuggestions.length;e.selectedSuggestionIndex=e.selectedSuggestionIndex<o-1?e.selectedSuggestionIndex+1:e.selectedSuggestionIndex},previousTextSuggestionIndex(e){e.selectedSuggestionIndex=e.selectedSuggestionIndex>=0?e.selectedSuggestionIndex-1:e.selectedSuggestionIndex},setTextSuggestions(e,o){if(e.selectedSuggestionIndex=-1,e.textSuggestions=o.payload,o.payload.length===0)return;let n=e.userCommitted.text.substring(0,e.userCommitted.selection.end),s=Mr(o.payload,n);e.tabCompletionSuggestion=s!=null&&s.text.includes(n)?s:void 0},setSelectedTextSuggestionIndex(e,o){e.selectedSuggestionIndex=o.payload},mergeMetrics(e,{payload:o}){let n=o.agentStartedTypingTimestamp!=null?o.agentStartedTypingTimestamp:Date.now(),s=(Date.now()-n)/1e3;e.metrics.externalTimeTotalSeconds=s,e.metrics.numCharsTyped+=o.numCharsTyped,e.metrics.numCharsPasted+=o.numCharsPasted,e.metrics.numCharsCut+=o.numCharsCut,e.metrics.numCharsDeleted+=o.numCharsDeleted,e.metrics.numPaste+=o.numPaste,e.metrics.pastes.push(...o.pastes),e.metrics.deletions.push(...o.deletions)},setMetrics(e,{payload:o}){e.metrics=o}},extraReducers:e=>{e.addCase(N,o=>{o.tabCompletionSuggestion=dt.tabCompletionSuggestion,o.previousKeyDownEvent=dt.previousKeyDownEvent,o.textSuggestions=dt.textSuggestions,o.selectedSuggestionIndex=dt.selectedSuggestionIndex,o.metrics=dt.metrics})}}),Dr=ja("input"),no=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),xg=t=>t.input.selection,Va=()=>(0,za.useSelector)(xg),{userInput:qa,changeSelection:Hr,initialInput:Wa,mergeMetrics:Ga,nextTextSuggestionIndex:$a,offeredTextSuggestion:Xa,previousTextSuggestionIndex:Qa,registerCut:Za,registerKeyDown:Ja,registerPaste:Ya,reset:el,resetToCommitted:Fo,platformInput:tl,setSelectedTextSuggestionIndex:ut,setTextSuggestions:He,stageSuggestion:ke,commitSuggestion:je,setMetrics:ol}=Dr.actions,ie=ja("overlay");var so=require("react");var nl={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};var Br=require("react/jsx-runtime"),bg=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=(0,so.useRef)(null),l=(0,so.useRef)(null),c=v("Dialog",nl);return(0,so.useEffect)(()=>{var u,g;let p=m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),s())},d=m=>{let f=window.getSelection();f!=null&&f.toString()||m.target===a.current&&t&&n()};return(u=a.current)==null||u.addEventListener("click",d),(g=a.current)==null||g.addEventListener("keyup",p),()=>{var m,f;(m=a.current)==null||m.removeEventListener("click",d),(f=a.current)==null||f.removeEventListener("keyup",p)}},[a,l,s,n]),(0,so.useEffect)(()=>{var p,d;!a.current||!t||!e||(d=(p=a.current)==null?void 0:p.querySelector("input, textarea"))==null||d.focus()},[t,e,a]),t?(0,Br.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,Br.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},ro=bg;var hi=require("react"),Ms=require("react-redux");var Fr={};W(Fr,{enUS:()=>Cg,nlNL:()=>wg});var Cg={dismiss:[{type:0,value:"Close"}],add:[{type:0,value:"Add to message"}],next:[{type:0,value:"Next"}],previous:[{type:0,value:"Previous"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},wg={dismiss:[{type:0,value:"Sluiten"}],add:[{type:0,value:"Toevoegen"}],next:[{type:0,value:"Volgende"}],previous:[{type:0,value:"Vorige"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var sl={root:"_root_l80t9_1",content:"_content_l80t9_3",title:"_title_l80t9_7",actions:"_actions_l80t9_15",pagination:"_pagination_l80t9_20",primaryButton:"_primaryButton_l80t9_51",primaryButtons:"_primaryButtons_l80t9_55"};var gs=require("react");var Kr=function(t,e){return Kr=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])},Kr(t,e)};function Ko(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Kr(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var pe=function(){return pe=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},pe.apply(this,arguments)};function rl(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 es(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 ts;(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"})(ts||(ts={}));var os=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Re;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(Re||(Re={}));var ns;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(ns||(ns={}));function Ur(t){return t.type===Re.literal}function il(t){return t.type===Re.argument}function ss(t){return t.type===Re.number}function rs(t){return t.type===Re.date}function is(t){return t.type===Re.time}function as(t){return t.type===Re.select}function ls(t){return t.type===Re.plural}function al(t){return t.type===Re.pound}function cs(t){return t.type===Re.tag}function ps(t){return!!(t&&typeof t=="object"&&t.type===ns.number)}function Uo(t){return!!(t&&typeof t=="object"&&t.type===ns.dateTime)}function zr(t){t.forEach(function(e){if(delete e.location,as(e)||ls(e))for(var o in e.options)delete e.options[o].location,zr(e.options[o].value);else ss(e)&&ps(e.style)||(rs(e)||is(e))&&Uo(e.style)?delete e.style.location:cs(e)&&zr(e.children)})}function ll(t,e){e===void 0&&(e={}),e=pe({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new os(t,e).parse();if(o.err){var n=SyntaxError(ts[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||zr(o.val),o.val}function ds(t,e){var o=e&&e.cache?e.cache:Pg,n=e&&e.serializer?e.serializer:Ig,s=e&&e.strategy?e.strategy:Eg;return s(t,{cache:o,serializer:n})}function Tg(t){return t==null||typeof t=="number"||typeof t=="boolean"}function cl(t,e,o,n){var s=Tg(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function pl(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 jr(t,e,o,n,s){return o.bind(e,t,n,s)}function Eg(t,e){var o=t.length===1?cl:pl;return jr(t,this,o,e.cache.create(),e.serializer)}function kg(t,e){return jr(t,this,pl,e.cache.create(),e.serializer)}function Rg(t,e){return jr(t,this,cl,e.cache.create(),e.serializer)}var Ig=function(){return JSON.stringify(arguments)};function Vr(){this.cache=Object.create(null)}Vr.prototype.get=function(t){return this.cache[t]};Vr.prototype.set=function(t,e){this.cache[t]=e};var Pg={create:function(){return new Vr}},us={variadic:kg,monadic:Rg};var At;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(At||(At={}));var zo=function(t){Ko(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 qr=function(t){Ko(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('", "'),'"'),At.INVALID_VALUE,r)||this}return e}(zo);var dl=function(t){Ko(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),At.INVALID_VALUE,s)||this}return e}(zo);var ul=function(t){Ko(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,'"'),At.MISSING_VALUE,n)||this}return e}(zo);var Q;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(Q||(Q={}));function Ag(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==Q.literal||o.type!==Q.literal?e.push(o):n.value+=o.value,e},[])}function Lg(t){return typeof t=="function"}function jo(t,e,o,n,s,r,i){if(t.length===1&&Ur(t[0]))return[{type:Q.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(Ur(p)){a.push({type:Q.literal,value:p.value});continue}if(al(p)){typeof r=="number"&&a.push({type:Q.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new ul(d,i);var u=s[d];if(il(p)){(!u||typeof u=="string"||typeof u=="number")&&(u=typeof u=="string"||typeof u=="number"?String(u):""),a.push({type:typeof u=="string"?Q.literal:Q.object,value:u});continue}if(rs(p)){var g=typeof p.style=="string"?n.date[p.style]:Uo(p.style)?p.style.parsedOptions:void 0;a.push({type:Q.literal,value:o.getDateTimeFormat(e,g).format(u)});continue}if(is(p)){var g=typeof p.style=="string"?n.time[p.style]:Uo(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:Q.literal,value:o.getDateTimeFormat(e,g).format(u)});continue}if(ss(p)){var g=typeof p.style=="string"?n.number[p.style]:ps(p.style)?p.style.parsedOptions:void 0;g&&g.scale&&(u=u*(g.scale||1)),a.push({type:Q.literal,value:o.getNumberFormat(e,g).format(u)});continue}if(cs(p)){var m=p.children,f=p.value,y=s[f];if(!Lg(y))throw new dl(f,"function",i);var E=jo(m,e,o,n,s,r),h=y(E.map(function(_){return _.value}));Array.isArray(h)||(h=[h]),a.push.apply(a,h.map(function(_){return{type:typeof _=="string"?Q.literal:Q.object,value:_}}))}if(as(p)){var x=p.options[u]||p.options.other;if(!x)throw new qr(p.value,u,Object.keys(p.options),i);a.push.apply(a,jo(x.value,e,o,n,s));continue}if(ls(p)){var x=p.options["=".concat(u)];if(!x){if(!Intl.PluralRules)throw new zo(`Intl.PluralRules is not available in this environment.
|
|
1
|
+
"use strict";var $u=Object.create;var An=Object.defineProperty;var Xu=Object.getOwnPropertyDescriptor;var Qu=Object.getOwnPropertyNames;var Zu=Object.getPrototypeOf,Ju=Object.prototype.hasOwnProperty;var W=(t,e)=>{for(var o in e)An(t,o,{get:e[o],enumerable:!0})},da=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Qu(e))!Ju.call(t,s)&&s!==o&&An(t,s,{get:()=>e[s],enumerable:!(n=Xu(e,s))||n.enumerable});return t};var k=(t,e,o)=>(o=t!=null?$u(Zu(t)):{},da(e||!t||!t.__esModule?An(o,"default",{value:t,enumerable:!0}):o,t)),Yu=t=>da(An({},"__esModule",{value:!0}),t);var xh={};W(xh,{Card:()=>F,ContentEditableInput:()=>Gt,DeepdeskAPI:()=>at,DeepdeskSDK:()=>kn,HTTPClient:()=>Ne,InputMediator:()=>qe,InputType:()=>ct,KeyboardHint:()=>Hn,Label:()=>Bn,Locale:()=>Ho,Section:()=>lt,SectionList:()=>Fn,Sources:()=>Te,Suggestion:()=>D,SuggestionList:()=>Se,TextAreaInput:()=>We,ToggleButton:()=>It,attachFile:()=>Hu,authenticateWithKey:()=>Du,createFullRange:()=>Po,createOverlayContainer:()=>Mt,createRangeFromOffsets:()=>Et,escapeHTML:()=>uo,fetchPlatformConfig:()=>Er,formatTextMarkup:()=>Ou,getRangeOffsets:()=>Cn,getRangeText:()=>wn,insertCKEditor:()=>Nu,isSupportedInputElement:()=>Cr,updateContentEditable:()=>Lu,updateTextArea:()=>Au,useStyles:()=>v,waitForElementVisibilityChange:()=>wr});module.exports=Yu(xh);var Nn=k(require("classnames")),he=k(require("react"));var Ln=k(require("react")),ua=k(require("classnames")),Oo=Ln.default.createContext({});function v(t,e){let{debug:o,...n}=(0,Ln.useContext)(Oo),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,ua.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var ga={root:"_root_vr71j_1"};var kt=require("react/jsx-runtime"),Mn=()=>(0,kt.jsxs)("svg",{className:ga.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,kt.jsx)("defs",{children:(0,kt.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,kt.jsx)("title",{children:"Failed loading image"}),(0,kt.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 Rr={root:"_root_4e7lf_1",imageWrapper:"_imageWrapper_4e7lf_7",image:"_image_4e7lf_7",content:"_content_4e7lf_24",title:"_title_4e7lf_35",contentIsCropped:"_contentIsCropped_4e7lf_45",lineClamp:"_lineClamp_4e7lf_51"};var Rt=require("react/jsx-runtime"),On=(0,he.createContext)(Rr),eg=({title:t,src:e})=>{let o=(0,he.useContext)(On),[n,s]=(0,he.useState)(!1);return(0,he.useEffect)(()=>{s(!1)},[e]),(0,Rt.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,Rt.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,Rt.jsx)(Mn,{})})},tg=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,he.useContext)(On);return(0,Rt.jsx)("div",{className:(0,Nn.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},og=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,he.useContext)(On);return he.default.createElement(t,{className:(0,Nn.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Dn=({children:t})=>{let e=v("Card",Rr);return(0,Rt.jsx)("div",{className:(0,Nn.default)(e.root),children:(0,Rt.jsx)(On.Provider,{value:e,children:t})})};Dn.Image=eg;Dn.Content=tg;Dn.Title=og;var F=Dn;var fa=k(require("classnames"));var ma={root:"_root_cq1yq_1"};var ha=require("react/jsx-runtime");var ng={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},sg=({className:t,keyCode:e,...o})=>{let n=v("KeyboardHint",ma);return(0,ha.jsx)("span",{"data-key":ng[e],className:(0,fa.default)(t,n.root),...o})},Hn=sg;var va=k(require("classnames"));var ya={root:"_root_4a08n_1"};var Sa=require("react/jsx-runtime"),rg=({className:t,children:e,...o})=>{let n=v("Label",ya);return(0,Sa.jsx)("span",{...o,className:(0,va.default)(t,n.root),children:e})},Bn=rg;var _a={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var Jt=require("react/jsx-runtime"),ig=({title:t,children:e,type:o,...n})=>{let s=v("Section",_a);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})]})},lt=ig;var ba=k(require("classnames")),Ca=k(require("react"));var xa={root:"_root_19wxp_1"};var wa=require("react/jsx-runtime"),ag=Ca.default.forwardRef(({className:t,children:e},o)=>{let n=v("SectionList",xa);return(0,wa.jsx)("div",{ref:o,className:(0,ba.default)(n.root,t),children:e})}),Fn=ag;var Do=k(require("classnames")),ve=k(require("react"));var Ir={root:"_root_ipo0b_11",fadein:"_fadein_ipo0b_1",isClickable:"_isClickable_ipo0b_46",isSelected:"_isSelected_ipo0b_51",actions:"_actions_ipo0b_75",actionsIsFixed:"_actionsIsFixed_ipo0b_97",actionButton:"_actionButton_ipo0b_105",dropdownList:"_dropdownList_ipo0b_126",dropdownButton:"_dropdownButton_ipo0b_141",dropdownItem:"_dropdownItem_ipo0b_151",dropdownItemButton:"_dropdownItemButton_ipo0b_160",actionButtonIsPrimary:"_actionButtonIsPrimary_ipo0b_174",actionButtonIsDisabled:"_actionButtonIsDisabled_ipo0b_178",labels:"_labels_ipo0b_186",label:"_label_ipo0b_186"};var ye=require("react/jsx-runtime"),Yt=(0,ve.createContext)(Ir),lg=({fixed:t,children:e,...o})=>{let n=(0,ve.useContext)(Yt);return(0,ye.jsx)("div",{...o,className:(0,Do.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},cg=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,ve.useContext)(Yt);return(0,ye.jsxs)("div",{className:(0,Do.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,(0,ye.jsx)("ul",{className:r.dropdownList,children:s})]})},pg=({index:t,label:e,onClick:o})=>{let n=(0,ve.useContext)(Yt);return(0,ye.jsx)("li",{className:n.dropdownItem,children:(0,ye.jsx)("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},dg=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,ve.useContext)(Yt);return(0,ye.jsx)("button",{type:"button",className:(0,Do.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},Pr=({labels:t})=>{let e=(0,ve.useContext)(Yt);return(0,ye.jsx)("div",{className:e.labels,children:t.map(o=>(0,ye.jsx)("span",{className:e.label,children:o},o))})},eo=ve.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=v("Suggestion",Ir),l=(0,ve.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,ye.jsx)(s,{...r,ref:i,className:(0,Do.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,ye.jsx)(Yt.Provider,{value:a,children:n})})});eo.Labels=Pr;eo.Actions=lg;eo.ActionButton=dg;eo.DropdownButton=cg;eo.DropdownItem=pg;var D=eo;var Ea=k(require("classnames"));var Ta={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var ka=require("react/jsx-runtime"),ug=({withDivider:t,children:e})=>{let o=v("SuggestionList",Ta);return(0,ka.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,Ea.default)(o.root,{[o.isWithDivider]:t}),children:e})},Se=ug;var Ia=k(require("classnames"));var Ra={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var Kn=require("react/jsx-runtime"),gg=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=v("ToggleButton",Ra);return(0,Kn.jsx)("button",{type:"button",className:(0,Ia.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,Kn.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,Kn.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},It=gg;var Pa=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,to=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Aa=/x-deepdesk-(([a-z0-9\-_])+-version)/,Te=(f=>(f.SEARCH="search",f.TEMPLATE="template",f.ELASTIC_SEARCH="search-autocomplete",f.GPT="gpt",f.TRIE="trie",f.TRIE_WITH_TYPOS="trie-with-typos",f.SEMANTIC="semantic",f.TEXT_RECOMMENDATION="text_recommendation",f.URL_RECOMMENDATION="url_recommendation",f.LINK_RECOMMENDATION="link_recommendation",f.PERSONAL_COLLECTION="personal-collection",f.PERSONAL_COLLECTION_SEARCH="personal-collection-search",f.SEARCH_OVERLAY="search-overlay",f.SEARCH_PREVIEW="search-preview",f.SEARCH_URL="search-url",f))(Te||{}),ct=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(ct||{});var we=require("react-dom");var xp=require("react");var La=require("@reduxjs/toolkit"),Ma=require("react-redux");var Ho=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Ho||{});var mg={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,La.createSlice)({name:"settings",initialState:mg,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:Bo}=Na.actions,Ar=t=>e=>e.settings[t],C=t=>(0,Ma.useSelector)(Ar(t)),Oa=Na.reducer;var Hc=require("react"),xo=require("react-redux");var De=require("@reduxjs/toolkit"),Ka=require("diff"),Ua=require("react-redux");function Da(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function pt(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)=>pt(r,e[i],o-1)):Da(t)&&Da(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>pt(t[i],e[i],o-1)):!1}function fg(t){return Math.max(...t.map(e=>e.length))}function hg(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 Ha(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<fg(n);s++){let r=hg(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 yg=2;function Lr(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=Ha(t,yg);return o&&o.text!==e?o:t[0]}var Ee=require("@reduxjs/toolkit"),Ba={current:null,isSupported:null},N=(0,Ee.createAction)("resetConversation"),Un=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},zn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},oo=t=>t.conversation.isSupported,Mr=(0,Ee.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),jn=(0,Ee.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Vn=(0,Ee.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),qn=(0,Ee.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=zn(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),Nr=(0,Ee.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})})}),Wn=(0,Ee.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=zn(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),vg=[jn.rejected,Vn.rejected,qn.rejected,Wn.rejected].map(t=>t==null?void 0:t.toString()),Sg=(0,Ee.createSlice)({name:"conversation",initialState:Ba,reducers:{},extraReducers:t=>{t.addCase(Mr.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(jn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Vn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Nr.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(qn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Wn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(N,()=>Ba).addMatcher(e=>vg.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),Fa=Sg.reducer;var dt={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 $n(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 Xn=(0,De.createAction)("input/replaceText"),Qn=(0,De.createAction)("input/keyDown"),Pt=(0,De.createAction)("input/sendMessage"),Zn=(0,De.createAction)("input/sendEditSuggestionMessage"),Jn=(0,De.createAction)("input/uiInputChange"),Yn=(0,De.createAction)("input/applyImageSuggestion"),X=(0,De.createAction)("input/sendEvent");function Gn(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:l},eventMetrics:{inputType:c},replace:p}=t.stagedSuggestion,d=o==="search"||o==="personal-collection-search",u=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(d||p==="selection")&&(u=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(u=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:u,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:d?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var za=t=>(0,De.createSlice)({name:t,initialState:dt,reducers:{initialInput(e,o){let{text:n,selection:s,html:r}=o.payload;e.text=n,e.selection.start=(s==null?void 0:s.start)??n.length,e.selection.end=(s==null?void 0:s.end)??n.length,e.userCommitted.text=n,e.userCommitted.selection.start=(s==null?void 0:s.start)??n.length,e.userCommitted.selection.end=(s==null?void 0:s.end)??n.length,e.html=r||null},reset(e){Object.assign(e,{...dt,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=Lr(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(pt(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Gn(e)))},platformInput(e,o){let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end),e.text=n,e.html=s||null},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:d,ctrlKey:u,metaKey:g,altKey:m}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:f}=e,{text:h}=o.payload,w=(0,Ka.diffChars)(f,h);f.length-h.length>1&&e.metrics.deletions.push(...w.filter(y=>y.removed).map(y=>y.value)),e.metrics.numCharsDeleted+=f.length-h.length;break}case"C":case"V":case"X":if(!u&&!g){e.metrics.numCharsTyped+=1;let f=((i=e.selection)==null?void 0:i.start)!==void 0&&((a=e.selection)==null?void 0:a.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}break;case"Shift":break;default:if(!u&&!g&&!m){e.metrics.numCharsTyped+=1;let f=((l=e.selection)==null?void 0:l.start)!==void 0&&((c=e.selection)==null?void 0:c.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=dt.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Gn(e);let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end,e.userCommitted.selection.start=r.start,e.userCommitted.selection.end=r.end),e.text=n,e.html=s||null,e.userCommitted.text=n,e.previousKeyDownEvent=null},stageSuggestion(e,o){let{text:n}=o.payload;switch(e.stagedSuggestion=o.payload,e.tabCompletionSuggestion=void 0,o.payload.replace){case"selection":e.text=`${e.text.slice(0,e.selection.start)}${n}${e.text.slice(e.selection.end)}`,e.selection.end=e.selection.start+n.length,e.selection.start+=n.length;break;case"until-selection-end":e.text=`${n}${e.text.slice(e.selection.end)}`,e.selection.start=n.length,e.selection.end=n.length;break;default:throw new Error(`Unknown replace ${o.payload.replace}`)}o.payload.eventMetrics.inputType==="tab"&&Gn(e)},commitSuggestion(e){Gn(e)},offeredTextSuggestion(e,o){let{text:n,suggestion:{source:s}}=o.payload;e.metrics.offeredTextSuggestions.find(i=>i.text===n)||e.metrics.offeredTextSuggestions.push({text:n,source:s})},registerCut(e,o){let{metrics:n}=e,s=o.payload;e.metrics={...e.metrics,numCharsCut:n.numCharsCut+s.length,cuts:[...n.cuts,s]}},registerPaste(e,o){let{metrics:n}=e,{text:s,selectionText:r}=o.payload,i=n.numCharsDeleted+(r&&r.length?r.length:0),a=r&&r.length?[...n.deletions,r]:n.deletions;e.metrics={...e.metrics,numCharsDeleted:i,deletions:a,numCharsPasted:n.numCharsPasted+s.length,numPaste:n.numPaste+1,pastes:[...n.pastes,s]}},registerKeyDown(e,o){e.previousKeyDownEvent=o.payload},nextTextSuggestionIndex(e){let o=e.textSuggestions.length;e.selectedSuggestionIndex=e.selectedSuggestionIndex<o-1?e.selectedSuggestionIndex+1:e.selectedSuggestionIndex},previousTextSuggestionIndex(e){e.selectedSuggestionIndex=e.selectedSuggestionIndex>=0?e.selectedSuggestionIndex-1:e.selectedSuggestionIndex},setTextSuggestions(e,o){if(e.selectedSuggestionIndex=-1,e.textSuggestions=o.payload,o.payload.length===0)return;let n=e.userCommitted.text.substring(0,e.userCommitted.selection.end),s=Lr(o.payload,n);e.tabCompletionSuggestion=s!=null&&s.text.includes(n)?s:void 0},setSelectedTextSuggestionIndex(e,o){e.selectedSuggestionIndex=o.payload},mergeMetrics(e,{payload:o}){let n=o.agentStartedTypingTimestamp!=null?o.agentStartedTypingTimestamp:Date.now(),s=(Date.now()-n)/1e3;e.metrics.externalTimeTotalSeconds=s,e.metrics.numCharsTyped+=o.numCharsTyped,e.metrics.numCharsPasted+=o.numCharsPasted,e.metrics.numCharsCut+=o.numCharsCut,e.metrics.numCharsDeleted+=o.numCharsDeleted,e.metrics.numPaste+=o.numPaste,e.metrics.pastes.push(...o.pastes),e.metrics.deletions.push(...o.deletions)},setMetrics(e,{payload:o}){e.metrics=o}},extraReducers:e=>{e.addCase(N,o=>{o.tabCompletionSuggestion=dt.tabCompletionSuggestion,o.previousKeyDownEvent=dt.previousKeyDownEvent,o.textSuggestions=dt.textSuggestions,o.selectedSuggestionIndex=dt.selectedSuggestionIndex,o.metrics=dt.metrics})}}),Or=za("input"),no=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),_g=t=>t.input.selection,ja=()=>(0,Ua.useSelector)(_g),{userInput:Va,changeSelection:Dr,initialInput:qa,mergeMetrics:Wa,nextTextSuggestionIndex:Ga,offeredTextSuggestion:$a,previousTextSuggestionIndex:Xa,registerCut:Qa,registerKeyDown:Za,registerPaste:Ja,reset:Ya,resetToCommitted:Fo,platformInput:el,setSelectedTextSuggestionIndex:ut,setTextSuggestions:He,stageSuggestion:ke,commitSuggestion:je,setMetrics:tl}=Or.actions,ie=za("overlay");var so=require("react");var ol={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};var Hr=require("react/jsx-runtime"),xg=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=(0,so.useRef)(null),l=(0,so.useRef)(null),c=v("Dialog",ol);return(0,so.useEffect)(()=>{var u,g;let p=m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),s())},d=m=>{let f=window.getSelection();f!=null&&f.toString()||m.target===a.current&&t&&n()};return(u=a.current)==null||u.addEventListener("click",d),(g=a.current)==null||g.addEventListener("keyup",p),()=>{var m,f;(m=a.current)==null||m.removeEventListener("click",d),(f=a.current)==null||f.removeEventListener("keyup",p)}},[a,l,s,n]),(0,so.useEffect)(()=>{var p,d;!a.current||!t||!e||(d=(p=a.current)==null?void 0:p.querySelector("input, textarea"))==null||d.focus()},[t,e,a]),t?(0,Hr.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,Hr.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},ro=xg;var fi=require("react"),Ls=require("react-redux");var Br={};W(Br,{enUS:()=>bg,nlNL:()=>Cg});var bg={dismiss:[{type:0,value:"Close"}],add:[{type:0,value:"Add to message"}],next:[{type:0,value:"Next"}],previous:[{type:0,value:"Previous"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},Cg={dismiss:[{type:0,value:"Sluiten"}],add:[{type:0,value:"Toevoegen"}],next:[{type:0,value:"Volgende"}],previous:[{type:0,value:"Vorige"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var nl={root:"_root_l80t9_1",content:"_content_l80t9_3",title:"_title_l80t9_7",actions:"_actions_l80t9_15",pagination:"_pagination_l80t9_20",primaryButton:"_primaryButton_l80t9_51",primaryButtons:"_primaryButtons_l80t9_55"};var gs=require("react");var Fr=function(t,e){return Fr=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])},Fr(t,e)};function Ko(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Fr(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var pe=function(){return pe=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},pe.apply(this,arguments)};function sl(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 es(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 ts;(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"})(ts||(ts={}));var os=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Re;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(Re||(Re={}));var ns;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(ns||(ns={}));function Kr(t){return t.type===Re.literal}function rl(t){return t.type===Re.argument}function ss(t){return t.type===Re.number}function rs(t){return t.type===Re.date}function is(t){return t.type===Re.time}function as(t){return t.type===Re.select}function ls(t){return t.type===Re.plural}function il(t){return t.type===Re.pound}function cs(t){return t.type===Re.tag}function ps(t){return!!(t&&typeof t=="object"&&t.type===ns.number)}function Uo(t){return!!(t&&typeof t=="object"&&t.type===ns.dateTime)}function Ur(t){t.forEach(function(e){if(delete e.location,as(e)||ls(e))for(var o in e.options)delete e.options[o].location,Ur(e.options[o].value);else ss(e)&&ps(e.style)||(rs(e)||is(e))&&Uo(e.style)?delete e.style.location:cs(e)&&Ur(e.children)})}function al(t,e){e===void 0&&(e={}),e=pe({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new os(t,e).parse();if(o.err){var n=SyntaxError(ts[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||Ur(o.val),o.val}function ds(t,e){var o=e&&e.cache?e.cache:Ig,n=e&&e.serializer?e.serializer:Rg,s=e&&e.strategy?e.strategy:Tg;return s(t,{cache:o,serializer:n})}function wg(t){return t==null||typeof t=="number"||typeof t=="boolean"}function ll(t,e,o,n){var s=wg(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function cl(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 zr(t,e,o,n,s){return o.bind(e,t,n,s)}function Tg(t,e){var o=t.length===1?ll:cl;return zr(t,this,o,e.cache.create(),e.serializer)}function Eg(t,e){return zr(t,this,cl,e.cache.create(),e.serializer)}function kg(t,e){return zr(t,this,ll,e.cache.create(),e.serializer)}var Rg=function(){return JSON.stringify(arguments)};function jr(){this.cache=Object.create(null)}jr.prototype.get=function(t){return this.cache[t]};jr.prototype.set=function(t,e){this.cache[t]=e};var Ig={create:function(){return new jr}},us={variadic:Eg,monadic:kg};var At;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(At||(At={}));var zo=function(t){Ko(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 Vr=function(t){Ko(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('", "'),'"'),At.INVALID_VALUE,r)||this}return e}(zo);var pl=function(t){Ko(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),At.INVALID_VALUE,s)||this}return e}(zo);var dl=function(t){Ko(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,'"'),At.MISSING_VALUE,n)||this}return e}(zo);var Q;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(Q||(Q={}));function Pg(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==Q.literal||o.type!==Q.literal?e.push(o):n.value+=o.value,e},[])}function Ag(t){return typeof t=="function"}function jo(t,e,o,n,s,r,i){if(t.length===1&&Kr(t[0]))return[{type:Q.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(Kr(p)){a.push({type:Q.literal,value:p.value});continue}if(il(p)){typeof r=="number"&&a.push({type:Q.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new dl(d,i);var u=s[d];if(rl(p)){(!u||typeof u=="string"||typeof u=="number")&&(u=typeof u=="string"||typeof u=="number"?String(u):""),a.push({type:typeof u=="string"?Q.literal:Q.object,value:u});continue}if(rs(p)){var g=typeof p.style=="string"?n.date[p.style]:Uo(p.style)?p.style.parsedOptions:void 0;a.push({type:Q.literal,value:o.getDateTimeFormat(e,g).format(u)});continue}if(is(p)){var g=typeof p.style=="string"?n.time[p.style]:Uo(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:Q.literal,value:o.getDateTimeFormat(e,g).format(u)});continue}if(ss(p)){var g=typeof p.style=="string"?n.number[p.style]:ps(p.style)?p.style.parsedOptions:void 0;g&&g.scale&&(u=u*(g.scale||1)),a.push({type:Q.literal,value:o.getNumberFormat(e,g).format(u)});continue}if(cs(p)){var m=p.children,f=p.value,h=s[f];if(!Ag(h))throw new pl(f,"function",i);var w=jo(m,e,o,n,s,r),y=h(w.map(function(_){return _.value}));Array.isArray(y)||(y=[y]),a.push.apply(a,y.map(function(_){return{type:typeof _=="string"?Q.literal:Q.object,value:_}}))}if(as(p)){var x=p.options[u]||p.options.other;if(!x)throw new Vr(p.value,u,Object.keys(p.options),i);a.push.apply(a,jo(x.value,e,o,n,s));continue}if(ls(p)){var x=p.options["=".concat(u)];if(!x){if(!Intl.PluralRules)throw new zo(`Intl.PluralRules is not available in this environment.
|
|
2
2
|
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
3
|
-
`,At.MISSING_INTL_API,i);var b=o.getPluralRules(e,{type:p.pluralType}).select(u-(p.offset||0));x=p.options[b]||p.options.other}if(!x)throw new qr(p.value,u,Object.keys(p.options),i);a.push.apply(a,jo(x.value,e,o,n,s,u-(p.offset||0)));continue}}return Ag(a)}function Mg(t,e){return e?pe(pe(pe({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=pe(pe({},t[n]),e[n]||{}),o},{})):t}function Ng(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Mg(t[n],e[n]),o},pe({},t)):t}function Wr(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:ds(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,es([void 0],o,!1)))},{cache:Wr(t.number),strategy:us.variadic}),getDateTimeFormat:ds(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,es([void 0],o,!1)))},{cache:Wr(t.dateTime),strategy:us.variadic}),getPluralRules:ds(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,es([void 0],o,!1)))},{cache:Wr(t.pluralRules),strategy:us.variadic})}}var gl=function(){function t(e,o,n,s){o===void 0&&(o=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var p=r.formatToParts(c);if(p.length===1)return p[0].value;var d=p.reduce(function(u,g){return!u.length||g.type!==Q.literal||typeof u[u.length-1]!="string"?u.push(g.value):u[u.length-1]+=g.value,u},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return jo(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=rl(i,["formatters"]);this.ast=t.__parse(e,pe(pe({},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=Ng(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=ll,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 Dg(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var Hg="dummy",Gr=(0,gs.createContext)(null);function w(t){let e=(0,gs.useContext)(Gr);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=Dg(o,n);return r?new gl(r).format(s):(e!==Hg&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var Vo=require("react/jsx-runtime"),ms=()=>(0,Vo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Vo.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Vo.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 qo=require("react/jsx-runtime"),ml=()=>(0,qo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,qo.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,qo.jsx)("path",{d:"M64 448c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L178.8 256L41.38 118.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l160 160c12.5 12.5 12.5 32.75 0 45.25l-160 160C80.38 444.9 72.19 448 64 448z"})]});var _e=require("react"),Ml=require("react-redux"),si=require("interweave"),ri=k(require("classnames"));var $r={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};var hl=require("interweave"),yl=k(require("classnames"));var io=require("react");function fl(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function fs(t){let e=(0,io.useRef)(null),[o,n]=(0,io.useState)(!1);return(0,io.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=fl((p,d)=>{let u=e.current;if(!u)return;let g=p/r,m=d/r,f=u.getBoundingClientRect(),y=g>f.x&&g<f.x+f.width&&m>f.y&&m<f.y+f.height;y&&!s?(s=!0,n(!0)):!y&&s&&(s=!1,n(!1))},({clientX:p,clientY:d})=>[p,d]),[l,c]=fl(()=>{s=!1,n(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",l),()=>{a(),c(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",l)}},[e]),[e,o]}var Ve={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var Xr=require("react/jsx-runtime"),Bg=({inputElement:t,children:e})=>{let o=v("TabCompletion",Ve),[n,s]=fs(t);return(0,Xr.jsx)("mark",{ref:n,className:(0,yl.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},ao=class extends hl.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,Xr.jsx)(Bg,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var lo=require("react");function hs(t){return t.contentEditable==="true"}function Fg(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 vl(t){let{selectionStart:e,selectionEnd:o}=hs(t)?Fg(t):t;return[e,o]}function ys(t){let[,e]=(0,lo.useState)(),o=(0,lo.useRef)(null);return o.current=vl(t),(0,lo.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=vl(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 vs(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(to);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 Sl=require("react");function co(t){(0,Sl.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Lt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var _l,Be=new Map,Kg=["bottom","height","left","right","top","width"],Ug=(t={},e={})=>Kg.some(o=>t[o]!==e[o]);function xl(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,...xl(e)]:[]}function bl(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var Ss=!1,Cl=()=>{Ss=!0;let t=[];if(Be.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),Be.delete(o);return}let n=o.getBoundingClientRect();Ug(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(bl,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),Be.size===0){Ss=!1;return}_l=window.requestAnimationFrame(Cl)};function Qr(t,e){let o=xl(t),n=[],s=o.map((r,i)=>Qr(r,a=>{n[i]=a;let l=Be.get(t);if(!l)return;let c=n.reduce(bl,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),Be.has(t)){let i=Be.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Be.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!Ss&&Cl()},unobserve(){s.forEach(i=>i.unobserve());let r=Be.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||Be.delete(t),Be.size||(cancelAnimationFrame(_l),Ss=!1)}}}}var wl,Fe=new Map,Tl=()=>{Fe.forEach((t,e)=>{if(!e.isConnected){Fe.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)))}),Fe.size!==0&&(wl=window.requestAnimationFrame(Tl))};function El(t,e){return{observe(){let o=Fe.size===0;Fe.has(t)?Fe.get(t).callbacks.push(e):Fe.set(t,{visible:void 0,callbacks:[e]}),o&&Tl()},unobserve(){let o=Fe.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Fe.delete(t),Fe.size||cancelAnimationFrame(wl)}}}}var Zr=["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 Jr(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function po(t){return parseFloat(t)}function _s(t){return Math.round(t*1e6)}function kl(t){return t/1e6}function Yr(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=po(t.width),r=po(t.borderLeftWidth),i=po(t.borderRightWidth),a=po(t.paddingRight),l=kl(_s(s)-_s(r)-_s(i)),c=kl(_s(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function Mt(t,e={}){var l;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",Lt(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Jr(n,o,Zr),Yr(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=El(t,()=>{Jr(n,o,Zr),Yr(n,t,o),r(),setTimeout(r,0)}),a=Qr(t,c=>{if(c===null){e.onRemove&&e.onRemove(),o.remove();return}if(c.height===0&&c.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Jr(n,o,Zr),Yr(n,t,o),r(),o.style.top=`${c.top}px`,o.style.left=`${c.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let p=e.closestScrollElement.getBoundingClientRect(),d=window.getComputedStyle(e.closestScrollElement),u=po(d.borderTopWidth),g=po(d.borderBottomWidth),m=p.top+u-c.top,f=c.top+c.height+-(p.top+p.height-g);o.style.clipPath=`inset(${m}px 0px ${f}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(l=t.parentElement)==null||l.appendChild(o),a.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),a.unobserve(),i.unobserve()}]}var ei={};W(ei,{enUS:()=>zg,nlNL:()=>jg});var zg={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"No placeholders found"}]},one:{value:[{type:0,value:"There is one placeholder in your message"}]},other:{value:[{type:0,value:"There are "},{type:7},{type:0,value:" placeholders in your message"}]}},offset:0,pluralType:"cardinal"}]},jg={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"Alle placeholders zijn uit je bericht"}]},one:{value:[{type:0,value:"Er is 1 placeholder in jouw bericht"}]},other:{value:[{type:0,value:"Er zijn "},{type:7},{type:0,value:" placeholders in jouw bericht"}]}},offset:0,pluralType:"cardinal"}]};var Wo=require("react/jsx-runtime"),Rl=()=>(0,Wo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,Wo.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,Wo.jsx)("path",{d:"M243.8 339.8C232.9 350.7 215.1 350.7 204.2 339.8L140.2 275.8C129.3 264.9 129.3 247.1 140.2 236.2C151.1 225.3 168.9 225.3 179.8 236.2L224 280.4L332.2 172.2C343.1 161.3 360.9 161.3 371.8 172.2C382.7 183.1 382.7 200.9 371.8 211.8L243.8 339.8zM512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256zM256 48C141.1 48 48 141.1 48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48z"})]});var ti=require("react/jsx-runtime"),Il=()=>(0,ti.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,ti.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});function Vg(t){let e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!n}function xs(t){return t?t instanceof ShadowRoot?xs(t.host):t===t.ownerDocument.body?t.ownerDocument:Vg(t)?t:xs(t.parentNode):document.body}var Pl=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(Pl||{}),qe=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();pt(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(Pl).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var n,s;let o=((n=e.clipboardData)==null?void 0:n.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()});let o=xs(this.element);if(o){let n=()=>{this.currentCaret!==null&&(this.currentCaret=null,this.emit("caret",null))};o.addEventListener("scroll",n),this.disposeHandlers.push(()=>{o.removeEventListener("scroll",n)})}this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};var We=class extends qe{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){let e=this.getSelection();return e?this.getText().slice(e.start,e.end):""}getCaretPosition(){return null}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let o=this.element.disabled,n=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>n.disconnect())}};var qg=/[.*+?^${}()|[\]\\]/g,Wg=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function Gg(t){return t.replace(qg,"\\$&")}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(Wg)}function Al(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${Gg(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function Ll(t){return t.replace(to,'<mark data-type="placeholder">$1</mark>')}function uo(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Qg(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 oi(t,e,o={}){if(e){let n=$g(e.toLowerCase(),t.toLowerCase()),s=uo(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(Aa).length>3||e.length>30?Qg(e.trim(),n):0;return`${`${i>0?"\u2026":""}${uo(t.substring(i,n))}`}<strong>${s}</strong>`}return t}function ni(t){return/<\/?[a-z][\s\S]*>/i.test(t)}function bs(t){if(ni(t)){let o=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(t);return o?o[1]:""}return t}var Z=require("react/jsx-runtime"),Zg=({value:t,onUse:e,...o})=>{var d;let n=w(ei),s=(0,Ml.useDispatch)(),r=ni(t),i=v("EditSuggestionTextInput",$r),[a,l]=(0,_e.useState)(null),c=(0,_e.useRef)(null),p=((d=t.match(to))==null?void 0:d.length)||0;return(0,_e.useEffect)(()=>{let u;return c.current&&(l(c.current),u=new We(c.current),u.on("change",({plainText:g})=>{s(ie.actions.userInput({text:g,selection:u.getSelection()}))}),u.on("keydown",g=>{s(ie.actions.registerKeyDown($n(g))),g.code==="Enter"&&g.shiftKey&&e(u.getText())}),u.on("paste",({pastedText:g,selectionText:m})=>{s(ie.actions.registerPaste({text:g,selectionText:m}))}),u.on("cut",({selectionText:g})=>{s(ie.actions.registerCut(g))})),()=>{s(ie.actions.reset()),u.dispose(),u.deactivate()}},[c]),(0,_e.useEffect)(()=>{t&&c.current&&(c.current.value=t)},[t,c]),(0,_e.useEffect)(()=>{c.current&&setTimeout(()=>{if(!c.current)return;let u=c.current.value.length;c.current.setSelectionRange(u,u),c.current.focus()},0)},[c]),r?(0,Z.jsx)("div",{className:i.textInputWrapper,children:(0,Z.jsx)(si.Interweave,{className:i.textInput,tagName:"div",content:t})}):(0,Z.jsxs)("div",{className:i.textInputWrapper,children:[(0,Z.jsx)("textarea",{...o,ref:c,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:t,onChange:()=>{}}),a&&(0,Z.jsx)(Jg,{inputElement:c.current,value:t}),(0,Z.jsxs)("div",{className:(0,ri.default)(i.alert,p===0?i.success:i.warning),children:[(0,Z.jsx)("div",{className:i.alertText,children:n("placeholders",{placeholderSize:p})}),p===0?(0,Z.jsx)(Rl,{}):(0,Z.jsx)(Il,{})]})]})},Jg=({inputElement:t,value:e})=>{let o=v("EditSuggestionTextInput",$r),n=(0,_e.useRef)(null),s=ys(t);return(0,_e.useEffect)(()=>{vs(t,s)},[s,t]),(0,Z.jsx)(Yg,{inputElement:t,children:(0,Z.jsxs)("div",{ref:n,className:(0,ri.default)(o.root,o.agentText),children:[(0,Z.jsx)(si.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new ao("placeholders")],inputElement:t,boundaryRef:n}),(0,Z.jsx)("br",{})]})})},Yg=({inputElement:t,children:e})=>{let o=(0,_e.useRef)(null);return(0,_e.useEffect)(()=>{if(!o.current)return()=>{};let[n,s]=Mt(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),(0,Z.jsx)("div",{ref:o,children:e})},Nl=Zg;var ho=require("react");var Ol=require("react"),Cs=k(require("classnames"));var ae={root:"_root_pc5uy_1",list:"_list_pc5uy_2",listWrapper:"_listWrapper_pc5uy_6",listHorizontal:"_listHorizontal_pc5uy_10",page:"_page_pc5uy_19",search:"_search_pc5uy_25",pageNav:"_pageNav_pc5uy_33",pageTitle:"_pageTitle_pc5uy_41",pageBackButton:"_pageBackButton_pc5uy_48",listHeading:"_listHeading_pc5uy_62",listItem:"_listItem_pc5uy_70",listItemContent:"_listItemContent_pc5uy_79",listItemText:"_listItemText_pc5uy_97",listItemDescription:"_listItemDescription_pc5uy_105",listItemActions:"_listItemActions_pc5uy_112",truncate:"_truncate_pc5uy_123",lineClamp:"_lineClamp_pc5uy_129",listItemTitle:"_listItemTitle_pc5uy_136",listItemAction:"_listItemAction_pc5uy_112",listItemPrimaryAction:"_listItemPrimaryAction_pc5uy_157",listItemSelected:"_listItemSelected_pc5uy_162",sources:"_sources_pc5uy_166",sourcesTitle:"_sourcesTitle_pc5uy_173",source:"_source_pc5uy_166",icon:"_icon_pc5uy_188",searchIcon:"_searchIcon_pc5uy_205",searchInputWrapper:"_searchInputWrapper_pc5uy_210",searchInput:"_searchInput_pc5uy_210",select:"_select_pc5uy_231",selectType:"_selectType_pc5uy_248",selectWrapper:"_selectWrapper_pc5uy_252",image:"_image_pc5uy_282",imageSrc:"_imageSrc_pc5uy_289",imageSrcHidden:"_imageSrcHidden_pc5uy_300",imageSrcStatus:"_imageSrcStatus_pc5uy_304",imageTitle:"_imageTitle_pc5uy_314",actions:"_actions_pc5uy_319",actionsWrapper:"_actionsWrapper_pc5uy_323",actionsBar:"_actionsBar_pc5uy_329",actionButton:"_actionButton_pc5uy_338",actionShortcut:"_actionShortcut_pc5uy_356",actionShortcutFixKerning:"_actionShortcutFixKerning_pc5uy_363"};var Nt={};W(Nt,{enUS:()=>em,nlNL:()=>tm});var em={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},tm={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};var gt=require("react/jsx-runtime"),om=({src:t,title:e})=>{let o=v("CommandPalette",ae),[n,s]=(0,Ol.useState)("loading"),r=w(Nt);return(0,gt.jsxs)("div",{className:o.image,children:[(0,gt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,Cs.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,gt.jsx)("span",{className:(0,Cs.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,gt.jsx)("span",{className:(0,Cs.default)(o.imageSrc,o.imageSrcStatus),children:(0,gt.jsx)(Mn,{})}),e&&(0,gt.jsx)("span",{className:o.imageTitle,children:e})]})},Dl=om;var Hl=k(require("react")),Bl=k(require("classnames"));var Go=require("react/jsx-runtime");function ii({children:t,heading:e,orientation:o}){let n=v("CommandPalette",ae);return Hl.default.Children.count(t)===0?null:(0,Go.jsxs)("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&(0,Go.jsx)("h4",{className:n.listHeading,children:e}),(0,Go.jsx)("div",{className:(0,Bl.default)(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}var $o=k(require("classnames"));var ws=k(require("react")),Ul=require("react/jsx-runtime"),Fl=ws.default.createContext(void 0);function mt(){let t=ws.default.useContext(Fl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Kl=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=ws.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,Ul.jsx)(Fl.Provider,{value:i,children:t})};var G=k(require("react")),zl=k(require("classnames"));var ai={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 Ot=require("react/jsx-runtime"),nm=0,jl=G.default.createContext(null),sm=()=>{let t=(0,G.useContext)(jl);if(!t)throw new Error("Invalid DropdownContext");return t},Vl=({trigger:t,children:e,position:o="bottom"})=>{let n=(0,G.useMemo)(()=>++nm,[]),s=(0,G.useRef)(null),r=(0,G.useRef)(null),i=v("Dropdown",ai),[a,l]=(0,G.useState)(!1),[c,p]=(0,G.useState)(o),d=g=>{g.preventDefault(),g.stopPropagation(),l(!a)},u=(0,G.useCallback)(([g])=>{!g.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return(0,G.useEffect)(()=>{let g=m=>{s.current&&!s.current.contains(m.target)&&l(!1)};return document.addEventListener("click",g),()=>{document.removeEventListener("click",g)}},[]),(0,G.useEffect)(()=>{if(!r.current&&!a)return()=>{};let g=new IntersectionObserver(u,{root:null,rootMargin:"0px",threshold:1});return r.current&&g.observe(r.current),()=>{r.current&&g.unobserve(r.current)}},[r,a]),(0,Ot.jsx)(jl.Provider,{value:{setIsOpen:l},children:(0,Ot.jsxs)("div",{ref:s,className:i.root,children:[(0,Ot.jsx)("button",{id:`dropdown-${n}`,"data-testid":"dropdown-trigger","aria-haspopup":"true","aria-expanded":a,"aria-label":"Dropdown trigger",type:"button",className:i.trigger,onClick:d,children:t}),(0,Ot.jsx)("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:(0,zl.default)(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function rm({as:t,children:e,onClick:o,...n}){let s=t||"button",r=v("Dropdown",ai),{setIsOpen:i}=sm(),a=l=>{i(!1),o(l),l.stopPropagation()};return(0,Ot.jsx)(s,{type:"button",className:r.item,onClick:a,...n,children:e})}Vl.Item=rm;var li=Vl;var ci=require("react/jsx-runtime"),ql=t=>(0,ci.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:(0,ci.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 Dt={};W(Dt,{enUS:()=>im,nlNL:()=>am});var im={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"}]},am={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 Ts=require("react/jsx-runtime"),lm="%0d%0a%0d%0a%0d%0a",cm=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(lm)}`},pm=({suggestion:t,onFeedback:e})=>{let o=w(Dt),n=C("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:(0,Ts.jsx)(li,{trigger:(0,Ts.jsx)(ql,{"data-testid":"feedback-dropdown-trigger"}),children:(0,Ts.jsx)(li.Item,{as:"a",href:cm(n,t),onClick:e,children:o("giveFeedback")})})},Es=pm;var Wl=require("interweave");var de=require("react/jsx-runtime");function pi({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onFeedback:s,onSourceClick:r,index:i,description:a,sources:l,styles:c,...p}){let{selected:d,setSelected:u,onChangeOpen:g}=mt(),m=v("CommandPalette",ae);function f(y){n(y),t&&g(!1)}return(0,de.jsxs)("div",{className:(0,$o.default)(m.listItem,d===i&&m.listItemSelected),children:[(0,de.jsx)("button",{onMouseEnter:()=>u(i),type:"button",className:(0,$o.default)("command-palette-list-item",m.listItemAction,m.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:f,...p,children:(0,de.jsxs)("div",{className:m.listItemContent,children:[typeof o=="string"?(0,de.jsx)("p",{className:(0,$o.default)(m.listItemText,m.truncate,c==null?void 0:c.title),children:o}):o,a&&(0,de.jsx)(Wl.Interweave,{tagName:"p",allowList:[],content:bs(a),className:(0,$o.default)(m.listItemDescription,c==null?void 0:c.description,e?m.lineClamp:m.truncate)})]})}),s&&d===i&&(0,de.jsx)("div",{className:m.listItemActions,children:(0,de.jsx)(Es,{suggestion:String(o),onFeedback:s})}),l&&(0,de.jsxs)("div",{className:m.sources,children:[(0,de.jsx)("span",{className:m.sourcesTitle,children:"Sources"}),l.map(y=>y.url?(0,de.jsx)("a",{className:m.source,href:y.url,target:"_blank",title:y.url,rel:"noopener noreferrer",onClick:()=>r&&r(y),children:y.name},y.url):(0,de.jsx)("span",{className:m.source,children:y.name},y.name))]})]})}var Ht=require("react/jsx-runtime");function di({children:t,title:e,id:o,onDismiss:n}){let s=w(Nt),r=v("CommandPalette",ae),{page:i}=mt();return i!==o?null:(0,Ht.jsxs)("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,Ht.jsxs)("div",{className:r.pageNav,children:[(0,Ht.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:n,children:[(0,Ht.jsx)(ms,{}),s("back")]}),e&&(0,Ht.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var ft=require("react");var ks=()=>/Mac/i.test(navigator.platform);var Is=require("@reduxjs/toolkit");var dm={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},T=dm;var go=require("@reduxjs/toolkit");function um(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function M(t){return Array.isArray(t)?t.map(M):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[um(o)]:M(t[o])}),{}):t}function ui(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,[ui(o)]:q(t[o])}),{}):t}var gm={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Qo=t=>{var e,o,n;return{timezone:((e=t.info.visitorInfo)==null?void 0:e.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((o=t.info.agentInfo)==null?void 0:o.agentNickname)||"",visitorName:((n=t.info.visitorInfo)==null?void 0:n.visitorName)||""}},Xo=(0,go.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?M(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),M(n))}),gi=(0,go.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}),mi=(0,go.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),Gl=t=>t.info.agentInfo,$l=(0,go.createSlice)({name:"info",initialState:gm,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Xo.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Xo.rejected,e=>{e.fetchState="error"}).addCase(Xo.fulfilled,(e,o)=>{e.fetchState="done",e.agentInfo={...e.agentInfo,...o.meta.arg,agentId:o.payload.externalId||o.meta.arg.agentId||"",agentNickname:o.payload.nickname||o.meta.arg.agentNickname||""}}).addCase(gi.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(mi.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(N,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Xl}=$l.actions,Ql=$l.reducer;var Rs={list:[],fetchState:"idle",isOpen:!1,page:"search"},Zl=t=>t.search.isOpen,Jl=t=>t.search.page,Yl=t=>t.search.list;function ec(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Bt=(0,Is.createAsyncThunk)("search/getAll",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r}=await o.search({profile:s,query:t.query,filters:{type:t.type},params:Qo(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),tc=(0,Is.createSlice)({name:"search",initialState:Rs,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=Rs.fetchState,t.list=Rs.list}},extraReducers:t=>{t.addCase(Bt.pending,e=>{e.fetchState="loading"}).addCase(Bt.rejected,(e,o)=>{e.fetchState="error",T.error(o.error)}).addCase(Bt.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(N,()=>Rs)}}),{resetSearch:Ps,setIsOpen:Y,setPage:ee}=tc.actions,oc=tc.reducer;var mm=/(https?:\/\/[^\s]+)/,As=t=>t.split(" ").find(e=>mm.test(e));var fi=k(require("classnames"));var Ls=require("react/jsx-runtime"),fm=({onClick:t,shortKeys:e,children:o,...n})=>{let s=v("CommandPalette",ae);return(0,Ls.jsxs)("button",{type:"button",...n,onClick:t,className:(0,fi.default)(s.actionButton,n.className),children:[o,e&&e.map(r=>(0,Ls.jsx)("span",{className:(0,fi.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},mo=fm;var Ge=require("react/jsx-runtime"),hm=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=v("CommandPalette",ae),a=w(Nt),{selected:l,setSelected:c}=mt(),p=r[l],d=p&&typeof p.text=="string"&&As(p.text),u=(0,ft.useRef)(null);function g(x){if(!u.current)return;let b=u.current.querySelectorAll(".command-palette-list-item"),_=0,A=0;x==="down"?(b.forEach((se,L)=>{L===l&&(_=L)}),A=_===b.length-1?0:_+1):x==="up"?(b.forEach((se,L)=>{L===l&&(_=L)}),A=_?_-1:b.length-1):c(0);let O=b[A];O&&typeof A=="number"&&(c(A),O.scrollIntoView&&O.scrollIntoView({behavior:"smooth",block:A?"center":"end"}))}function m(){if(!u.current)return;let x=u.current.querySelectorAll(".command-palette-list-item"),b=0;x.forEach((A,O)=>{O===l&&(b=O)});let _=x[b];_&&_.click()}let f=()=>{d&&window.open(d,"_blank")},y=()=>{p&&n(p,l)},E=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},h=(0,ft.useCallback)(x=>{if(x.key==="Enter"&&x.altKey&&d){f();return}if(x.key==="Enter"&&x.shiftKey){E();return}if(x.key==="ArrowDown"){x.preventDefault(),x.stopPropagation(),g("down");return}if(x.key==="ArrowUp"){x.preventDefault(),x.stopPropagation(),g("up");return}x.key==="Enter"&&l!==-1&&(x.preventDefault(),x.stopPropagation(),m())},[l]);return(0,ft.useEffect)(()=>(window.addEventListener("keyup",h),()=>{window.removeEventListener("keyup",h)}),[h]),(0,Ge.jsxs)("div",{className:i.actions,children:[(0,Ge.jsx)("div",{className:i.actionsWrapper,ref:u,children:t}),(0,Ge.jsxs)("div",{className:i.actionsBar,children:[d&&(0,Ge.jsx)(mo,{onClick:f,shortKeys:[ks()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,Ge.jsxs)(ft.Fragment,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&(0,Ge.jsx)(mo,{onClick:E,shortKeys:[8679,8629],children:o}),(0,Ge.jsx)(mo,{onClick:y,shortKeys:[8629],children:e})]})]})]})},sc=hm;var rc=require("react");var Zo=require("react/jsx-runtime"),fo=()=>(0,Zo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Zo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Zo.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 Ie=require("react/jsx-runtime");function ym({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=v("CommandPalette",ae);return(0,Ie.jsxs)("div",{className:l.search,children:[(0,Ie.jsx)("div",{className:l.searchIcon,children:(0,Ie.jsx)(fo,{})}),(0,Ie.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Ie.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,Ie.jsx)("div",{className:l.selectWrapper,children:(0,Ie.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,Ie.jsx)("option",{children:n}),s.map(c=>(0,Ie.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var ic=(0,rc.forwardRef)(ym);var Jo=require("react/jsx-runtime");function Ft({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:o="search",page:n,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:l,types:c,children:p,isOpen:d,search:u}){let[g,m]=(0,ho.useState)(0),f=(0,ho.useRef)(null),y=()=>{s&&s(o),i(void 0),r(""),a(!1)},E=()=>{var h;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(h=f.current)==null||h.focus();return}if(u.length>0){r("");return}a(!1)};return(0,ho.useEffect)(()=>{m(0)},[u,n]),(0,Jo.jsx)(ro,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:E,onClose:y,children:(0,Jo.jsxs)(Kl,{selected:g,setSelected:m,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&(0,Jo.jsx)(ic,{ref:f,onChange:r,onChangeType:i,placeholder:t,value:u,selectedType:l,types:c,typePlaceholder:e}),p]})})}Ft.Page=di;Ft.List=ii;Ft.Image=Dl;Ft.ListItem=pi;Ft.ActionsBar=sc;Ft.Button=mo;var I=Ft;var J=require("react/jsx-runtime"),vm=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=v("EditSuggestionForm",sl),l=(0,Ms.useDispatch)(),c=w(Fr),p=(0,Ms.useSelector)(m=>m.overlayInput.text);(0,hi.useEffect)(()=>{t&&(l(ie.actions.reset()),l(ie.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(ie.actions.commitSuggestion()))},[t]);let d=m=>{m.preventDefault(),u(p)},u=m=>{l(Zn(m)),e(m)},g=m=>f=>{p!==i?window.confirm(c("warning"))&&m(f):m(f)};return(0,hi.useEffect)(()=>{n&&n(p!==i)},[n,t,p]),(0,J.jsxs)("div",{className:a.root,children:[(0,J.jsxs)("div",{className:a.content,children:[t.title&&(0,J.jsx)("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&(0,J.jsx)(Ar,{labels:t.searchKeywords}),(0,J.jsx)(Nl,{onUse:u,value:bs(p)})]}),(0,J.jsxs)("form",{className:a.actions,onSubmit:d,children:[(0,J.jsxs)("div",{children:[(0,J.jsx)("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&g(r),children:(0,J.jsx)(ms,{})}),(0,J.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&g(s),children:(0,J.jsx)(ml,{})})]}),(0,J.jsxs)("div",{className:a.primaryButtons,children:[(0,J.jsx)(I.Button,{onClick:g(o),shortKeys:["esc"],children:c("dismiss")}),(0,J.jsx)(I.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},Ns=vm;var Kt=require("@reduxjs/toolkit");var Sm=["{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}"],_m=new RegExp(Sm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function ac(t,e){let o=t.split(_m),n=0,s=[];for(let r=0;r<o.length;r++){let i=o[r];if(s.push(i),r===o.length-1)break;if(e.indexOf(i)===-1)return t;let a=o[r+1],l=r===o.length-2;n+=i.length;let c=n;if(l){let d=a.charAt(0),u=0;do c=d?e.indexOf(d,c+1):-1,u+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&u>2)return t}else c=a&&a!==""?e.indexOf(a,n):-1;let p=c===-1?e.slice(n):e.slice(n,c);s.push(p),n=c}return s.join("")}function lc(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var pc={suggestions:[],fetchState:"idle",isInitialRequest:null},cc={default:pc},Os=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},dc=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")},ht=t=>t.textSuggestions,uc=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},Ds=(0,Kt.createAction)("textSuggestions/refresh"),Pe=(0,Kt.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=no(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Qo(n),t);if(t==="default"){let p=i?l.filter(uc(a)):l;e.dispatch(He(p.slice(0,r)))}return l}),Yo=(0,Kt.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,{...Qo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(uc(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?ac(p.text,t):p.text}))),l=lc(l,r),e.dispatch(He(l)),l}),gc=(0,Kt.createSlice)({name:"textSuggestions",initialState:cc,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(Pe.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||pc;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(Pe.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(Pe.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Yo.pending,e=>{e.default.fetchState="loading"}).addCase(Yo.rejected,e=>{e.default.fetchState="error"}).addCase(Yo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(N,()=>cc)}}),{setTextSuggestions:mc,setSuggestionState:fc}=gc.actions,hc=gc.reducer;var vc=require("@reduxjs/toolkit");var yc={contentType:null,suggestion:null},Sc=t=>t.activeSuggestion.suggestion,_c=t=>t.activeSuggestion.contentType,xc=(0,vc.createSlice)({name:"activeSuggestion",initialState:yc,reducers:{setActiveSuggestion(t,e){let{contentType:o,suggestion:n}=e.payload;t.contentType=o,t.suggestion=n},resetActiveSuggestion(t){t.contentType=null,t.suggestion=null}},extraReducers:t=>{t.addCase(N,()=>yc)}}),{setActiveSuggestion:$e,resetActiveSuggestion:yi}=xc.actions,bc=xc.reducer;var vi={};W(vi,{enUS:()=>xm,nlNL:()=>bm});var xm={warning:[{type:0,value:"Are you sure you want to discard the message?"}],editContentLabel:[{type:0,value:"Edit and view suggestion"}],overlayLabel:[{type:0,value:"Close dialog"}]},bm={warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}],editContentLabel:[{type:0,value:"Bewerk en bekijk suggestie"}],overlayLabel:[{type:0,value:"Sluit"}]};var Cc=require("@reduxjs/toolkit"),Cm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Hs=({ui:t})=>t.overlayCollapsed;var wc=(0,Cc.createSlice)({name:"ui",initialState:Cm,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputHasFocus(t,e){t.overlayCollapsedUserOverwrite!==!0&&(e.payload===!0&&(t.overlayCollapsed=!1),t.inputHasFocus=e.payload)},setOverlayCollapsed(t,e){e.payload.collapse===!1&&(t.openOverlayWhenTyping=!1),!(e.payload.skipWhenInputFocus&&t.inputHasFocus)&&(t.overlayCollapsed=e.payload.collapse)},setOpenOverlayWhenTyping(t,e){t.openOverlayWhenTyping=e.payload},setOverlayCollapsedUserOverwrite(t,e){t.overlayCollapsedUserOverwrite=e.payload,t.overlayCollapsed=e.payload}}}),{setShowTabHint:en,setInputHasFocus:yo,setOverlayCollapsed:yt,setOpenOverlayWhenTyping:Tc,setOverlayCollapsedUserOverwrite:Ec}=wc.actions,kc=wc.reducer;var tn=k(require("react")),Ic=require("react/jsx-runtime"),Rc=tn.default.createContext(null),Ut=({broadcastEvents:t,children:e})=>{let o=tn.default.useMemo(()=>t,[]);return(0,Ic.jsx)(Rc.Provider,{value:o,children:e})},xe=()=>{let t=(0,tn.useContext)(Rc);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var vo=require("@reduxjs/toolkit");var wm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ue=t=>t.auth.isLoggedIn,Pc=t=>t.auth.loginFetchState,Ac=t=>t.auth.verifyFetchState,Lc=t=>t.auth.showLoginOverlay,Xe=(0,vo.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),Mc=(0,vo.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),on=(0,vo.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),Nc=(0,vo.createSlice)({name:"auth",initialState:wm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(Xe.pending,e=>{e.loginFetchState="loading"}),t.addCase(Xe.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(Xe.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(on.pending,e=>{e.verifyFetchState="loading"}),t.addCase(on.rejected,e=>{e.verifyFetchState="error"}),t.addCase(on.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:So,setShowLoginOverlay:Oc}=Nc.actions,Dc=Nc.reducer;var Si="SetActiveSuggestion",_o="ShowLoginOverlay",nn="UserLoggedIn",Tm="UserLoggedOut",Qe="ApplySuggestion",_i="ApplyImageSuggestion",Em="ShowCommandPalette",km=t=>({[Si]:e=>{t.dispatch(fc(e.state)),t.dispatch($e({contentType:e.contentType,suggestion:e.suggestion}))},[Em]:e=>{t.dispatch(Y(e.isOpen)),e.page&&t.dispatch(ee(e.page))},[_o]:e=>{t.dispatch(Oc(e))},[nn]:()=>{t.dispatch(Xe())},[Tm]:()=>{t.dispatch(Xe())},[_i]:e=>{t.dispatch(Yn({suggestion:e.suggestion}))},[Qe]:e=>{t.dispatch(ke({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(je())}}),Hc=km;var xi=require("react/jsx-runtime"),Rm=()=>{var m;let[t,e]=(0,Bc.useState)(!1),o=(0,xo.useSelector)(Sc),n=(0,xo.useSelector)(_c),s=(0,xo.useSelector)(ht),r=(0,xo.useDispatch)(),i=xe(),a=w(vi),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(yi()),r(yo(!0)),r(ie.actions.reset())},p=(f,y)=>{r(yi()),r(yo(!0)),i.send(Qe,{text:f,suggestion:{...y,source:`${y.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let d=(m=s[n])==null?void 0:m.suggestions.indexOf(o),u=d===0||d===null?void 0:()=>r($e({contentType:n,suggestion:s[n].suggestions[d-1]})),g=d===s[n].suggestions.length-1||d===null?void 0:()=>r($e({contentType:n,suggestion:s[n].suggestions[d+1]}));return(0,xi.jsx)(ro,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,xi.jsx)(Ns,{onTouched:e,onDismiss:c,onUse:f=>p(f,o),suggestion:o,onNext:g,onPrevious:u})})},Fc=Rm;var Ci=require("react-redux");var Bs=k(require("classnames")),Ae=require("react"),Fs=require("react-redux");var Uc=k(require("classnames"));var Kc={root:"_root_1ukx5_1"};var zc=require("react/jsx-runtime"),Im=({className:t,value:e,...o})=>{let n=v("TextInput",Kc);return(0,zc.jsx)("input",{className:(0,Uc.default)(t,n.root),type:"text",value:e,...o})},sn=Im;var bi={};W(bi,{enUS:()=>Pm,nlNL:()=>Am});var Pm={back:[{type:0,value:"Back"}],promptTitle:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Paste the code from your email"}],verifyCodeBody:[{type:0,value:"Copy the code from the email you just received and paste it here."}],verifyCodeInputPlaceholder:[{type:0,value:"Paste link or code here"}],verifyCodeSubmitLabel:[{type:0,value:"Sign in"}],verifyCodeError:[{type:0,value:"Sign in failed. The code is probably no longer valid. Please "},{type:8,value:"login",children:[{type:0,value:"request new code"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Have a code sent to your email"}],requestCodeBody:[{type:0,value:"Enter your email and request a code. If you are an existing "},{type:1,value:"productName"},{type:0,value:" user you will receive an email with a code. If you are a new user you will receive an email asking to request access to "},{type:1,value:"productName"},{type:0,value:" first."}],requestCodeInputPlaceholder:[{type:0,value:"Enter your email"}],requestCodeSubmitLabel:[{type:0,value:"Request code"}]},Am={back:[{type:0,value:"Terug"}],promptTitle:[{type:0,value:"Login bij "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Plak de code uit je email"}],verifyCodeBody:[{type:0,value:"Kopieer de code uit de email en plak deze hier."}],verifyCodeInputPlaceholder:[{type:0,value:"Plak hier de code"}],verifyCodeSubmitLabel:[{type:0,value:"Inloggen"}],verifyCodeError:[{type:0,value:"Inloggen is niet gelukt. De code is waarschijnlijk niet meer geldig. "},{type:8,value:"login",children:[{type:0,value:"Vraag een nieuwe code aan"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Verstuur een login code naar je email"}],requestCodeBody:[{type:0,value:"Voer je e-mailadres in en krijg een login code. Als je een bestaande "},{type:1,value:"productName"},{type:0,value:" gebruiker bent krijg je een email met een code. Als je een nieuwe gebruiker bent wordt er een email verstuurd met een toegangsverzoek voor "},{type:1,value:"productName"},{type:0,value:"."}],requestCodeInputPlaceholder:[{type:0,value:"Typ hier je e-mailadres"}],requestCodeSubmitLabel:[{type:0,value:"Code aanvragen"}]};var jc={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 Lm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Mm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=w(bi),i=v("LoginTokenDialog",jc),a=(0,Fs.useSelector)(Ac),l=(0,Fs.useDispatch)(),c=C("productName"),[p,d]=(0,Ae.useState)(t||""),[u,g]=(0,Ae.useState)(0),[m,f]=(0,Ae.useState)(""),y=(0,Ae.useCallback)(async b=>{b.preventDefault(),l(Mc({email:p})),g(1)},[o,p]),E=()=>{f(""),g(0)},h=(0,Ae.useCallback)(async b=>{b.preventDefault();let _=Lm(b.target.elements.token.value);if(!_){f(r("verifyCodeError",{login:x}));return}l(on({token:_}))},[o]),x=(0,Ae.useMemo)(()=>b=>(0,K.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:E,children:b},"back-button"),[]);return(0,Ae.useEffect)(()=>{a==="error"&&f(r("verifyCodeError",{login:x})),a==="done"&&n()},[a]),(0,K.jsx)(ro,{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})}),u===0&&(0,K.jsxs)("form",{onSubmit:y,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)(sn,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:b=>d(b.target.value)}),(0,K.jsx)("div",{className:i.actions,children:(0,K.jsx)("button",{type:"submit",className:(0,Bs.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),u===1&&(0,K.jsxs)("form",{onSubmit:h,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,K.jsx)(sn,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),m&&(0,K.jsx)("div",{className:i.errorMessage,children:m}),(0,K.jsxs)("div",{className:i.actions,children:[(0,K.jsx)("button",{type:"button",className:(0,Bs.default)(i.button),onClick:E,children:r("back")}),(0,K.jsx)("button",{type:"submit",className:(0,Bs.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},Vc=Mm;var Wc=require("react/jsx-runtime"),Nm=()=>{let t=(0,Ci.useSelector)(Lc),e=(0,Ci.useSelector)(Gl),o=C("adminUrl"),n=xe(),s=()=>n.send(_o,!1),r=()=>{n.send(_o,!1),n.send(nn)};return(0,Wc.jsx)(Vc,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},qc=Nm;var _p=k(require("lodash.debounce")),te=require("react"),Ye=require("react-redux");var Ks=require("@reduxjs/toolkit");var Om={data:null,fetchState:"idle"},Gc=t=>t.contentTypes.data,rn=(0,Ks.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Dm=(0,Ks.createSlice)({name:"contentTypes",initialState:Om,reducers:{},extraReducers:t=>{t.addCase(rn.pending,e=>{e.fetchState="loading"}).addCase(rn.rejected,e=>{e.fetchState="error"}).addCase(rn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),$c=Dm.reducer;function an(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}var Xc=require("react");function Qc(t,e){(0,Xc.useEffect)(()=>{let o=n=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?n.metaKey:n.ctrlKey)&&n.key===t&&(n.preventDefault(),n.stopPropagation(),e())};return document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o)}},[])}var ln=require("react"),js=require("react-redux");var Us=require("@reduxjs/toolkit");var Zc={data:null,fetchState:"idle"},zs=t=>{var r;let e=[],{visitorName:o}=t.info.visitorInfo??{},{agentName:n,agentNickname:s}=t.info.agentInfo??{};return n&&n!==o&&e.push(n),s&&s!==o&&e.push(s),((r=t.entities.data)==null?void 0:r.filter(i=>!e.includes(i.text)))??null},Le=(0,Us.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)}),Hm=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Bm=(0,Us.createSlice)({name:"entities",initialState:Zc,reducers:{},extraReducers:t=>{t.addCase(Le.pending,e=>{e.fetchState="loading"}).addCase(Le.rejected,e=>{e.fetchState="error"}).addCase(Le.fulfilled,(e,o)=>{e.fetchState="done",e.data=Hm(e.data?[...e.data,...o.payload]:o.payload)}).addCase(N,()=>Zc)}}),Jc=Bm.reducer;var wi={};W(wi,{enUS:()=>Fm,nlNL:()=>Km});var Fm={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Km={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Yc={root:"_root_17kae_1",empty:"_empty_17kae_5"};var zt=require("react/jsx-runtime"),Um=({onCopy:t,onUse:e})=>{let o=(0,ln.useRef)(null),n=v("EntitiesList",Yc),s=w(wi),r=(0,js.useSelector)(zs),i=(0,js.useDispatch)();return(0,ln.useEffect)(()=>{i(Le())},[]),(0,ln.useEffect)(()=>{o.current&&o.current.focus()},[o]),(0,zt.jsxs)("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&(0,zt.jsx)(I.ActionsBar,{primaryLabel:s("copy"),secondaryLabel:s("use"),onPrimary:(a,l)=>t(r[l]),onSecondary:(a,l)=>e(r[l]),list:r.map(a=>({text:a.text,type:a.label,primaryAction:"copy",secondaryAction:"use"})),children:(0,zt.jsx)(I.List,{children:r.map((a,l)=>(0,zt.jsx)(I.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&(0,zt.jsx)("p",{className:n.empty,children:s("noResults")})]})},ep=Um;var Me=require("react"),cn=require("react-redux");var Vs=require("@reduxjs/toolkit");var tp={data:null,fetchState:"idle"},op=t=>t.summary.data,np=t=>t.summary.fetchState==="error",Ze=(0,Vs.createAsyncThunk)("summary/getSummary",async(t,e)=>{let o=e.getState().profile.data;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:n,dynamicThunkObject:s}=e.extra;if(!s.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let r=s.conversationQuery,i=await r();if(i.length===0)return Promise.reject(new Error("No messages are included"));let a=await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return a?{summary:a}:Promise.reject(new Error("Summary is not provided"))}),zm=(0,Vs.createSlice)({name:"summary",initialState:tp,reducers:{},extraReducers:t=>{t.addCase(Ze.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(Ze.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(Ze.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(N,()=>tp)}}),sp=zm.reducer;var Ti={};W(Ti,{enUS:()=>jm,nlNL:()=>Vm});var jm={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."}]},Vm={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 rp={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 Je=require("react/jsx-runtime"),qm=({onCopy:t})=>{let e=(0,Me.useRef)(null),o=v("SummaryForm",rp),[n,s]=(0,Me.useState)(""),r=w(Ti),i=(0,cn.useSelector)(op),a=(0,cn.useSelector)(np),l=(0,cn.useDispatch)(),c=()=>{l(X({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let d=document.getSelection();d&&l(X({name:"summary copied to clipboard",data:{originalText:i,finalText:d==null?void 0:d.toString()},options:{includeConversationData:!0}}))};return(0,Me.useEffect)(()=>{l(Ze())},[]),(0,Me.useEffect)(()=>{s(i||"")},[i]),(0,Me.useEffect)(()=>{e.current&&i&&e.current.focus()},[e,i]),(0,Me.useEffect)(()=>{let d=u=>{u.key==="Enter"&&u.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[n]),(0,Je.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,Je.jsx)("p",{className:o.error,children:r("error")}):(0,Je.jsxs)(Me.Fragment,{children:[(0,Je.jsx)("div",{className:o.main,children:(0,Je.jsx)("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:d=>s(d.target.value)})}),(0,Je.jsx)("div",{className:o.actions,children:(0,Je.jsx)(I.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},ip=qm;var pn={};W(pn,{enUS:()=>Wm,nlNL:()=>Gm});var Wm={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?"}]},Gm={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 vt=k(require("react")),gn=require("react-redux");var Ei={};W(Ei,{enUS:()=>$m,nlNL:()=>Xm});var $m={use:[{type:0,value:"Use"}],loading:[{type:0,value:"Loading..."}],error:[{type:0,value:"Something went wrong, please try again later."}],anotherQuestion:[{type:0,value:"Send a message..."}],reset:[{type:0,value:"Reset conversation"}]},Xm={use:[{type:0,value:"Gebruik"}],loading:[{type:0,value:"Laden..."}],error:[{type:0,value:"Er ging iets mis, probeer het later opnieuw."}],anotherQuestion:[{type:0,value:"Stuur een bericht..."}],reset:[{type:0,value:"Reset gesprek"}]};var ap={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 Co=require("@reduxjs/toolkit");var qs=require("@reduxjs/toolkit");var Qm={data:null,fetchState:"idle"},lp=t=>{var e;return(e=t.knowledgeAssistant)==null?void 0:e.data},dn=(0,qs.createAsyncThunk)("knowledgeAssistant/getKnoeledgeAssistant",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}),Zm=(0,qs.createSlice)({name:"knowledgeAssistant",initialState:Qm,reducers:{},extraReducers:t=>{t.addCase(dn.pending,e=>{e.fetchState="loading"}).addCase(dn.rejected,e=>{e.fetchState="error"}).addCase(dn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),cp=Zm.reducer;var ki={data:[],fetchState:"idle"},pp=t=>{var e;return(e=t.answer)==null?void 0:e.data},dp=t=>t.answer.fetchState,wo=(0,Co.createAction)("answer/resetKnowledgeSearch"),bo=(0,Co.createAsyncThunk)("answer/getAnswer",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=lp(e.getState());if(!s)throw new Error("KnowledgeAssistant is not defined");let r=await o.knowledgeAssist({promptInstruction:s.prompt,question:t},n,s.code);return{question:t,answer:r}}),Jm=(0,Co.createSlice)({name:"answer",initialState:ki,reducers:{},extraReducers:t=>{t.addCase(bo.pending,e=>{e.fetchState="loading"}).addCase(bo.rejected,e=>{e.fetchState="error"}).addCase(bo.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(N,()=>ki).addCase(wo,()=>ki)}}),up=Jm.reducer;var un=require("react/jsx-runtime"),gp=()=>(0,un.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,un.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,un.jsx)("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});var le=require("react/jsx-runtime"),Ym=({onUse:t,onResetQuestion:e,question:o})=>{let[n,s]=vt.default.useState(""),{setSelected:r}=mt(),i=(0,vt.useRef)(null),a=v("EntitiesList",ap),l=w(Ei),c=(0,gn.useDispatch)(),p=(0,gn.useSelector)(pp),d=(0,gn.useSelector)(dp),u=async m=>{m.preventDefault(),m.stopPropagation(),n!==""&&c(bo(n))},g=(m,f)=>{c(X({name:"knowledge assist source viewed",data:{question:f,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return(0,vt.useEffect)(()=>{var m;o&&d==="idle"?c(bo(o)):(m=i.current)==null||m.focus()},[i,d]),(0,vt.useEffect)(()=>{d==="done"&&(c(X({name:"knowledge assist question answered",data:{question:n||o,sources:p[p.length-1].answer.sources,answer:p[p.length-1].answer.answer,isFollowUpQuestion:p.length>1},options:{includeConversationData:!0}})),r(p.length-1),s(""))},[d,p]),(0,vt.useEffect)(()=>{i.current&&i.current.scrollIntoView({behavior:"smooth"})},[i,p]),(0,le.jsxs)("div",{className:a.root,children:[p.length>0&&(0,le.jsx)("div",{className:a.alignRight,children:(0,le.jsx)(I.Button,{onClick:e,children:l("reset")})}),(0,le.jsxs)(I.ActionsBar,{list:p.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:l("use"),onPrimary:m=>t(m.text),children:[p.map(({question:m,answer:f},y)=>(0,le.jsx)(I.List,{children:(0,le.jsx)(I.ListItem,{"data-testid":"knowledge-search-answer",index:y,description:f.answer,closeOnSelect:!0,onClick:()=>t(f.answer),onSourceClick:E=>g(E,m),sources:f.sources,styles:{title:a.question,description:a.answer},children:m})},`${f.answer}_${y}`)),d==="loading"&&(0,le.jsx)("p",{className:a.status,children:l("loading")}),d==="error"&&(0,le.jsx)("p",{className:a.status,children:l("error")}),(0,le.jsxs)("form",{className:a.form,onSubmit:u,children:[(0,le.jsx)("input",{ref:i,placeholder:l("anotherQuestion"),className:a.input,type:"text",value:n,onFocus:()=>{r(-1)},onChange:m=>{r(-1),s(m.target.value)}}),(0,le.jsx)("button",{type:"submit",className:a.submit,children:(0,le.jsx)(gp,{})})]})]})]})},mp=Ym;var Ws=require("@reduxjs/toolkit");var ef={data:null,fetchState:"idle"},St=t=>t.profile.data,Gs=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],mn=(0,Ws.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)}),tf=(0,Ws.createSlice)({name:"profile",initialState:ef,reducers:{},extraReducers:t=>{t.addCase(mn.pending,e=>{e.fetchState="loading"}).addCase(mn.rejected,e=>{e.fetchState="error"}).addCase(mn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),fp=tf.reducer;var hp=require("react");var yp=require("react-redux");var Ri=require("react-redux");var jt=require("react/jsx-runtime"),of=({commands:t,onClick:e,onEdit:o})=>{var p,d,u;let n=(0,yp.useDispatch)(),s=w(pn),r=(0,Ri.useSelector)(St),i=(0,Ri.useSelector)(ht),a=((u=(d=(p=r==null?void 0:r.uiConfig)==null?void 0:p.search)==null?void 0:d.initialTypes)==null?void 0:u.filter(({isActive:g})=>g))||[],l=0,c=a.map(({type:g})=>{var m;return(m=i[g])==null?void 0:m.suggestions.map(f=>({text:f.text||f.url||f.message,type:g}))}).flat(1);return(0,hp.useEffect)(()=>{a.forEach(({type:g})=>{(!i[g]||i[g].suggestions.length===0)&&n(Pe(g))})},[]),(0,jt.jsxs)(I.ActionsBar,{list:[...t.map(g=>({text:g.label,type:"command"})),...c],primaryLabel:s("use"),secondaryLabel:s("preview"),onPrimary:({text:g},m)=>e(g,c[m]),onSecondary:(g,m)=>{o(c[m],i[c[m].type].suggestions)},children:[t.length>0&&(0,jt.jsx)(I.List,{heading:s("commands"),children:t.map((g,m)=>(0,jt.jsx)(I.ListItem,{index:m,closeOnSelect:!1,onClick:g.onClick,children:g.label},g.label))}),a.map(({type:g,title:m})=>{var f;return(0,jt.jsx)(I.List,{heading:m,orientation:"vertical",children:(f=i[g])==null?void 0:f.suggestions.map(y=>(l++,(0,jt.jsx)(I.ListItem,{index:l+t.length-1,closeOnSelect:!1,description:y.text,onClick:()=>e(y.text,y),"data-testid":"search-overlay-suggestion",children:y.title},`${y.id}-${y.text}`)))},g)})]})},vp=of;var z=require("react/jsx-runtime"),nf=200,sf=5,rf=4,af=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Sp=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),lf=()=>{let t=(0,Ye.useDispatch)(),e=xe(),o=w(pn),[n,s]=(0,te.useState)(!1),[r,i]=(0,te.useState)(""),a=(0,Ye.useSelector)(Jl),l=(0,Ye.useSelector)(St),[c,p]=(0,te.useState)(null),[d,u]=(0,te.useState)([]),[g,m]=(0,te.useState)(),f=(0,Ye.useSelector)(ue),y=C("showSearch"),E=C("showEntitiesCommand"),h=C("showSummaryCommand"),x=C("showKnowledgeSearch"),b=C("showImageSearch"),_=C("searchTriggerKey"),A=(0,Ye.useSelector)(Gc),O=(0,Ye.useSelector)(Yl),se=(0,Ye.useSelector)(Zl),L=S=>Rr(O.filter(H=>H.type===S.toUpperCase()),S),re=[{value:"PERSONAL",label:o("personalSuggestions"),list:L("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:L("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:L("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:L("IMAGE"),listOrientation:"horizontal",shouldShow:b}].filter(S=>S.shouldShow),P=[{label:o("entitiesClipboard"),onClick:()=>t(ee("entities")),shouldShow:E&&Sp(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(ee("summary")),shouldShow:h&&Sp(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(ee("knowledgeAssist")),shouldShow:x}].filter(S=>S.shouldShow),U=(A==null?void 0:A.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:L(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],Qt=(0,te.useCallback)((0,_p.default)((S,H)=>{t(Bt({query:S,type:H,tags:["search-overlay"]}))},nf),[]),Mo=af([...U,...re]),No=(0,te.useCallback)((S,H)=>{t(ee("edit")),p({...S,searchTerm:void 0}),u(H)},[t,c,U]),Rn=(0,te.useCallback)((S,H)=>{switch(H.type){case"IMAGE":e.send(_i,{suggestion:H});break;default:e.send(Qe,{text:S,suggestion:H})}t(Y(!1))},[t]),Fu=S=>{an(S.text),t(X({name:"entity copied",data:{entity:S,type:"copy"}})),t(Y(!1))},Ku=(0,te.useCallback)(S=>{t(X({name:"suggestion feedback",data:{text:S.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),Uu=S=>{e.send(Qe,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(X({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(ee("search")),t(wo()),t(Y(!1))},zu=S=>{an(S),t(Y(!1))},ju=S=>{e.send(Qe,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(Y(!1))},Vu=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),qu=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function Rr(S,H){return S.slice(0,g?10:H.toLowerCase()==="image"?rf:sf)}function da(S,H,Oe){return H.reduce((In,Pn)=>Oe&&g===Oe?Pn.length+In:Rr(Pn,Oe).length+In,S)}function Zt(S){return H=>{n?window.confirm(o("warning"))&&(S(H),s(!1)):S(H)}}return(0,te.useEffect)(()=>{r?Qt(r,g):t(Ps())},[r,g]),(0,te.useEffect)(()=>{a==="search"&&t(wo())},[a]),(0,te.useEffect)(()=>{f&&t(rn())},[f]),Qc(_,()=>t(Y(!0))),!y||!l?null:(0,z.jsxs)(I,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Zt(S=>t(Y(S))),onChangeType:S=>m(S),onChangePage:Zt(S=>t(ee(S))),selectedType:g,search:r,page:a,isOpen:se,types:[...U,...re],children:[(0,z.jsxs)(I.Page,{id:"search",children:[r.length===0&&(0,z.jsx)(vp,{commands:P,onClick:Rn,onEdit:No}),r.length>0&&(0,z.jsxs)(I.ActionsBar,{list:[...P.map(S=>({text:S.label,type:"command"})),...Mo.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},H)=>Rn(S,Mo[H]),onSecondary:(S,H)=>{let Oe=Mo[H-P.length];!Oe||!Oe.type||No(Oe,L(Oe.type))},children:[P.length>0&&(0,z.jsx)(I.List,{heading:o("commands"),children:P.map((S,H)=>(0,z.jsx)(I.ListItem,{index:da(H,[],"commands"),closeOnSelect:!1,onClick:S.onClick,children:S.label},S.label))}),[...U,...re].map(({value:S,label:H,list:Oe,lineClamp:In,listOrientation:Pn},Wu)=>(0,z.jsx)(I.List,{heading:H,orientation:Pn==="horizontal"?"horizontal":"vertical",children:Rr(Oe,S).map((fe,Gu)=>(0,z.jsx)(I.ListItem,{index:da(P.length+Gu,[...U,...re].slice(0,Wu).map(({list:$u})=>$u),S),closeOnSelect:!1,lineClamp:In,onClick:()=>Rn(fe.text,fe),description:S!=="IMAGE"?fe.title&&fe.text:void 0,onFeedback:S!=="IMAGE"?()=>Ku(fe):void 0,children:S==="IMAGE"?(0,z.jsx)(I.Image,{title:fe.title||fe.text,src:fe.image}):fe.title||fe.text},`${fe.id}-${fe.text}`))},S))]})]}),(0,z.jsx)(I.Page,{id:"edit",onDismiss:Zt(()=>{t(ee("search")),p(null)}),children:c&&(0,z.jsx)(Ns,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(ee("search")),p(null),u([])},onNext:qu,onPrevious:Vu,onUse:S=>{t(ee("search")),Rn(S,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(Y(!1)),u([]),p(null)}})}),(0,z.jsx)(I.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:Zt(()=>{t(ee("search"))}),children:(0,z.jsx)(ep,{onUse:ju,onCopy:Fu})}),(0,z.jsx)(I.Page,{id:"summary",title:o("summaryTitle"),onDismiss:Zt(()=>{t(ee("search"))}),children:(0,z.jsx)(ip,{onCopy:zu})}),(0,z.jsx)(I.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:Zt(()=>{t(wo()),t(ee("search"))}),children:(0,z.jsx)(mp,{question:r,onUse:Uu,onResetQuestion:()=>{t(wo()),i("")}})})]})},xp=lf;var To=require("react/jsx-runtime"),cf=()=>{let t=C("showSearch"),e=C("isEmbedded");return(0,To.jsxs)(bp.Fragment,{children:[t&&(0,To.jsx)(xp,{}),(0,To.jsx)(Fc,{}),e&&(0,To.jsx)(qc,{})]})},Cp=cf;var Zs=require("react"),et=require("react-redux");function Eo(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:o,showSuggestionsAfterPattern:n}=t.settings,{text:s,selection:r}=t.input.userCommitted;return r.start!==r.end?!1:r.end>=s.length?!0:e?o&&new RegExp(o).test(s.substring(r.end))||n&&new RegExp(n).test(s.substring(0,r.end))?!0:o===!1&&n===!1:!1}var Xs=require("react");var kp=require("interweave"),ko=require("react"),$s=require("react-redux");var wp=require("react");function Tp(t,e,o){(0,wp.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var Ep={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};var Vt=require("react/jsx-runtime"),df=["search","personal-collection-search","search-autocomplete"];function uf(t,e,o,n={}){let s="";return df.includes(e)?s=Al(oi(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=oi(t,o,n),n.placeholders===!0&&(s=Ll(s)),s}var gf=()=>{},mf=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=C("inlineSuggestions"),r=(0,$s.useSelector)(no),i=(0,$s.useDispatch)(),a=v("TextSuggestion",Ep),l=(0,ko.useRef)(null);(0,ko.useEffect)(()=>{let p=setTimeout(()=>{i(Xa({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),Tp(l,"click",()=>{i(ut(t)),i(ke({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=(0,ko.useMemo)(()=>uf(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,Vt.jsxs)("div",{className:a.root,onMouseEnter:()=>i(ut(t)),children:[(0,Vt.jsx)(D,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:gf,children:(0,Vt.jsx)(kp.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&(0,Vt.jsx)("div",{className:a.actions,children:(0,Vt.jsx)(Es,{onFeedback:()=>n(o),suggestion:o.text})})]})},Rp=mf;var Ii=require("react/jsx-runtime"),ff=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=(0,Xs.useMemo)(()=>{let r=e.map((i,a)=>(0,Ii.jsx)(Rp,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return(0,Ii.jsx)(Xs.Fragment,{children:s})},Qs=ff;var Ip={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var fn=require("react/jsx-runtime"),hf=({textSuggestions:t,selectedIndex:e})=>{let o=(0,Zs.useRef)(null),n=v("InlineSuggestionsOverlay",Ip),s=(0,et.useSelector)(Eo),r=(0,et.useDispatch)(),i=(0,et.useSelector)(ue),a=(0,et.useSelector)(oo),l=(0,et.useSelector)(Hs),c=C("showTextSuggestions");return co(()=>{r(yt({collapse:!0,skipWhenInputFocus:!0}))}),(0,Zs.useEffect)(()=>{let p=o.current;if(!p||!p.parentElement)return;p.parentElement.style.left="0px";let d=p.getBoundingClientRect();p.parentElement.style.left=`${Math.min(window.innerWidth-4-d.right,0)}px`}),l||!s||!c||t.length===0||i!==!0||a===!1?null:(0,fn.jsx)("div",{className:n.root,"data-variant":"inline",children:(0,fn.jsx)("div",{ref:o,className:n.paper,children:(0,fn.jsx)(Se,{children:(0,fn.jsx)(Qs,{suggestions:t,selectedIndex:e})})})})},yf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Pp=(0,et.connect)(yf)(hf);var Ys=k(require("classnames")),Ro=require("react"),Ke=require("react-redux");var Ap=require("react");function Lp(t,e){let[o,n]=(0,Ap.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return T.error(r),e}});return[o,r=>{try{let i=r instanceof Function?r(o):r;n(i),typeof window<"u"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){T.error(i)}}]}var Np=k(require("classnames")),tt=require("react");var Pi={};W(Pi,{enUS:()=>vf,nlNL:()=>Sf});var vf={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"}]}]},Sf={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 Mp={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var _t=require("react/jsx-runtime"),Ai=(t,e,o)=>n=>(0,_t.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),_f=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=w(Pi),i=xe(),a=v("Login",Mp),l=C("productName"),c=(0,tt.useCallback)(y=>{y.preventDefault(),n&&n(parseInt(y.target.value,10))},[]),p=(0,tt.useCallback)(y=>{y.preventDefault(),i.send(_o,!0)},[e]),d=(0,tt.useMemo)(()=>y=>(0,_t.jsx)("a",{onClick:h=>{h.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:y},"login"),[e]),u=(0,tt.useCallback)(y=>(0,_t.jsx)("button",{type:"button",className:a.anchorButton,onClick:p,children:y},"prompt"),[p]),{min:g,hour:m,day:f}=(0,tt.useMemo)(()=>({min:Ai(a,60*10,c),hour:Ai(a,60*60,c),day:Ai(a,60*60*12,c)}),[]);return(0,_t.jsxs)("div",{className:(0,Np.default)(t,a.root),children:[r("loginPlease",{login:o?u:d,productName:l}),n&&(0,_t.jsxs)(tt.Fragment,{children:[(0,_t.jsx)("br",{}),r("snooze",{min:g,hour:m,day:f})]})]})},Js=_f;var Dp=require("react-redux");var Op={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var hn=require("react/jsx-runtime"),xf=({title:t})=>{let e=v("SearchTrigger",Op),o=(0,Dp.useDispatch)();return(0,hn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(Y(!0)),children:[(0,hn.jsx)(fo,{}),(0,hn.jsx)("span",{className:e.text,children:t})]})},Hp=xf;var Li={};W(Li,{enUS:()=>bf,nlNL:()=>Cf});var bf={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"}]},Cf={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 Bp={root:"_root_onpov_1",isInline:"_isInline_onpov_14",toggleButton:"_toggleButton_onpov_21",toggleButtonWrapper:"_toggleButtonWrapper_onpov_25",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_onpov_32",isCollapsed:"_isCollapsed_onpov_36",collapsible:"_collapsible_onpov_36",hints:"_hints_onpov_44",hintsHidden:"_hintsHidden_onpov_51",triggers:"_triggers_onpov_56",triggersRight:"_triggersRight_onpov_71"};var B=require("react/jsx-runtime"),wf=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=v("SuggestionsOverlay",Bp),s=w(Li),r=(0,Ke.useSelector)(Eo),i=Va(),a=(0,Ke.useDispatch)(),l=(0,Ro.useRef)(null),c=C("searchTriggerKey"),p=C("productName"),d=(0,Ke.useSelector)(Hs),u=(0,Ke.useSelector)(ue),g=(0,Ke.useSelector)(oo),[m,f]=(0,Ro.useState)(null),y=C("showSearch"),E=C("showTextSuggestions"),h=C("adminUrl"),x=C("isEmbedded"),[b,_]=Lp("dd-snooze-until-ms",0),A=d||b>Date.now(),O=(0,Ke.useSelector)(U=>U.input.text),se=t.filter(U=>U.source!=="gpt").length,L=()=>{A&&_(0),a(Ec(!A))},re=U=>{a(X({name:"suggestion feedback",data:{text:U.text,source:"overlay",context:O},options:{includeConversationData:!0}}))},P=U=>{let Qt=Date.now()+U*1e3;_(Qt),T.info(`Snooze until: ${new Date(Qt)}`),a(yt({collapse:!0}))};return(0,Ro.useEffect)(()=>{se===0&&f(null)},[t,se]),co(()=>{a(yt({collapse:!0,skipWhenInputFocus:!0}))}),u===null||g===!1?null:u===!1?(0,B.jsxs)("div",{ref:l,className:(0,Ys.default)(n.root,{[n.isCollapsed]:A}),children:[!A&&(0,B.jsxs)("div",{className:n.triggers,children:[(0,B.jsx)("div",{style:{flex:1}}),(0,B.jsx)("div",{className:n.triggersRight,children:(0,B.jsx)(It,{className:n.toggleButton,title:s("collapse"),onClick:L,isCollapsed:!1})})]}),(0,B.jsx)("div",{className:n.toggleButtonWrapper,children:(0,B.jsx)(It,{className:n.toggleButton,title:s("open",{productName:p}),onClick:L,isCollapsed:!0})}),(0,B.jsx)("div",{className:n.collapsible,children:(0,B.jsx)(Js,{loginUrl:h,isEmbedded:x,onLogIn:o,onSnooze:P})})]}):!i||!r?null:(0,B.jsxs)("div",{ref:l,className:(0,Ys.default)(n.root,{[n.isCollapsed]:A}),children:[!A&&(0,B.jsxs)("div",{className:n.triggers,children:[(0,B.jsx)("div",{style:{flex:1},children:y&&(0,B.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(s(ks()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>f(null),children:(0,B.jsx)(Hp,{title:s("search")})})}),(0,B.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,B.jsx)("div",{className:(0,Ys.default)(!m&&n.hintsHidden,n.hints),children:m}),(0,B.jsx)(It,{className:n.toggleButton,title:s("collapse"),onClick:L,isCollapsed:!1})]})]}),(0,B.jsx)("div",{className:n.toggleButtonWrapper,children:(0,B.jsx)(It,{className:n.toggleButton,title:s("open",{productName:p}),onClick:L,isCollapsed:!0})}),se>0&&E&&(0,B.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,B.jsx)(Se,{children:(0,B.jsx)(Qs,{onFeedback:re,suggestions:t,selectedIndex:e,reverse:!0})})})]})},Tf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Fp=(0,Ke.connect)(Tf)(wf);var Kp=require("react-redux");var yn=require("react/jsx-runtime"),Ef=({children:t})=>{let o=C("locale").replace("-","");return(0,yn.jsx)(Gr.Provider,{value:o,children:t})},kf=({store:t,customStyles:e={},children:o})=>(0,yn.jsx)(Kp.Provider,{store:t,children:(0,yn.jsx)(Ef,{children:(0,yn.jsx)(Oo.Provider,{value:e,children:o})})}),qt=kf;var ur=k(require("classnames")),rd=require("interweave"),st=require("react"),id=require("react-redux");var Up=require("react"),Rf=["div","span","mark","strong","b","i","u","em"];function Mi(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(Rf.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,Up.cloneElement)(n,{children:Mi(i,e,o+1)})]}return[...t,...e]}function xt(t){return t.tagName.toLowerCase()==="textarea"}var zp={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var Zp=k(require("classnames")),Jp=require("interweave"),lr=require("react");function jp(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function er(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function Vp(t){return t!=null}var Oi=k(require("classnames")),be=require("react");var tr=require("react"),If=["bottom","height","left","right","top","width"],Pf=(t={},e={})=>If.some(o=>t[o]!==e[o]),ot=new Map,qp,Wp=()=>{let t=[],e=[];ot.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Pf(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{ot.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),qp=window.requestAnimationFrame(Wp)};function Af(t,e){return{observe(){let o=ot.size===0;if(ot.has(t)){let n=ot.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else ot.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&Wp()},unobserve(){let o=ot.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||ot.delete(t),ot.size||cancelAnimationFrame(qp)}}}}function Ni(t){let[e,o]=(0,tr.useState)(null);return(0,tr.useLayoutEffect)(()=>{if(!t.current)return;let n=Af(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var Io=require("react"),$p=require("react-dom");var Gp={root:"_root_1jq08_1"};var Xp=({children:t})=>{let[e,o]=(0,Io.useState)(null),n=(0,Io.useContext)(Oo);return(0,Io.useLayoutEffect)(()=>{let s=document.createElement("div");return Lt(s),s.classList.add(Gp.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,$p.createPortal)(t,e):null};var Ue={ref:"_ref_1rcyi_1",root:"_root_1rcyi_7",positionAbove:"_positionAbove_1rcyi_13",positionBelow:"_positionBelow_1rcyi_17",positionLeft:"_positionLeft_1rcyi_21",positionRight:"_positionRight_1rcyi_25",alignStart:"_alignStart_1rcyi_29",alignCenter:"_alignCenter_1rcyi_34",alignEnd:"_alignEnd_1rcyi_40"};var or=require("react/jsx-runtime"),nr=(t=!1)=>{let[e,o]=(0,be.useState)(t),n=(0,be.useCallback)(()=>o(!0),[]),s=(0,be.useCallback)(()=>o(!1),[]),r=(0,be.useCallback)(()=>o(a=>!a),[]),i=(0,be.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function Di(t,e=null,o=0){if(!t)return{display:"none"};let n=e?t.top-e.top<0||t.top<e.top-o?e.top-o:t.top+t.height>e.top+e.height+o?e.top+e.height+o-t.height:t.top:t.top,s=e?t.left<e.left-o?e.left-o:t.left+t.width>e.left+e.width+o?e.left+e.width+o-t.width:t.left:t.left;return{top:n,left:s,height:t.height,width:t.width}}var sr=({className:t,triggerRef:e,boundaryRef:o=(0,be.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=Di,...a})=>{let l=Ni(e),c=Ni(o),p=(0,be.useMemo)(()=>i(l,c,0),[l,c]);return(0,or.jsx)(Xp,{children:(0,or.jsx)("div",{className:(0,Oi.default)(Ue.ref,{[Ue.positionAbove]:n==="above",[Ue.positionBelow]:n==="below",[Ue.positionLeft]:n==="left",[Ue.positionRight]:n==="right",[Ue.alignStart]:s==="start",[Ue.alignCenter]:s==="center",[Ue.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:(0,or.jsx)("div",{className:(0,Oi.default)(t,Ue.root),children:r})})})};var Qp=k(require("classnames")),rr=require("react");var Hi=require("react/jsx-runtime"),ir=(0,rr.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,rr.useRef)(null),r=v("TabCompletion",Ve);return(0,Hi.jsx)("div",{ref:er([s,n]),className:(0,Qp.default)(t,r.popoverContentContainer),...o,children:(0,Hi.jsx)("div",{className:r.popoverContent,children:e})})});var bt=require("react/jsx-runtime"),Lf=t=>e=>{let o=Di(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Mf=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=v("TabCompletion",Ve),i=nr(),a=(0,lr.useMemo)(()=>Lf(t.getBoundingClientRect()),[t]),[l,c]=fs(t);return(0,lr.useEffect)(()=>{c?i.open():i.close()},[c]),(0,bt.jsxs)("span",{children:[(0,bt.jsx)("mark",{ref:er([l,i.triggerRef]),className:(0,Zp.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,bt.jsx)(sr,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,bt.jsx)(ir,{style:o,children:(0,bt.jsx)("div",{className:r.hintText,children:s})})})]})},ar=class extends Jp.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${jp(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(Vp);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,bt.jsx)(Mf,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var pr=k(require("classnames")),nd=require("interweave"),ne=require("react"),sd=require("react-redux");var Bi=require("react/jsx-runtime"),Yp=()=>(0,Bi.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,Bi.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 Ct=require("react"),vn=require("react-redux"),td=k(require("lodash.debounce"));var ed={root:"_root_1muu8_1",content:"_content_1muu8_7"};function cr(t,e,o){var s;let n=((s=t.imageSizes)==null?void 0:s[e])||t.image||o;if(!n)return null;try{return new URL(n).toString()}catch{return null}}function Fi(t){return t.replace("https://www.","").replace("https://","")}var Ce=require("react/jsx-runtime"),Nf=3,Of=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Df=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=Nf})=>{let r=v("LinkSearch",ed),[i,a]=(0,Ct.useState)(""),l=(0,vn.useDispatch)(),c=(0,vn.useSelector)(Os("url")),p=(0,vn.useSelector)(ec("URL",Of)),[d,u]=(0,Ct.useState)(p.length-1),g=C("fallbackImage"),m=h=>{let x=h.target;a(x.value)},f=(h,x)=>{h.stopPropagation(),h.preventDefault(),window.open(x,"_blank")},y=h=>{var _;let x=d-1<0?p.length-1:d-1,b=d+1===p.length?0:d+1;h.code==="Escape"&&(a(""),e()),h.code==="ArrowUp"&&u(x),h.code==="ArrowDown"&&u(b),h.code==="Enter"&&t(((_=p[d])==null?void 0:_.text)||i)},E=(0,Ct.useCallback)((0,td.default)(h=>{l(Bt({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,Ct.useEffect)(()=>{i&&E(i)},[i]),(0,Ct.useEffect)(()=>()=>{l(Ps())},[]),(0,Ce.jsxs)("div",{className:r.root,children:[(0,Ce.jsx)(Se,{withDivider:!0,children:(i?p:c).slice(0,s).map((h,x)=>(0,Ce.jsx)(D,{selected:d===x,onClick:()=>t(h.text),"data-testid":"linksearch-suggestion",children:(0,Ce.jsxs)(F,{children:[(0,Ce.jsx)(F.Image,{src:cr(h,"small",g||void 0),title:h.title||h.text}),(0,Ce.jsxs)(F.Content,{className:r.content,cropText:!0,children:[(0,Ce.jsx)(F.Title,{children:h.title||Fi(h.text)}),h.title&&Fi(h.text)]}),(0,Ce.jsx)(D.Actions,{children:(0,Ce.jsx)(D.ActionButton,{label:n,onClick:b=>f(b,h.text)})})]})},h.text))}),(0,Ce.jsx)(sn,{value:i,onChange:m,autoFocus:!0,placeholder:o,onKeyUp:y})]})},od=Df;var Ki={};W(Ki,{enUS:()=>Hf,nlNL:()=>Bf});var Hf={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Bf={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var oe=require("react/jsx-runtime"),Ff=(0,ne.forwardRef)((t,e)=>{let o=v("TabCompletion",Ve);return(0,oe.jsx)("mark",{ref:e,className:(0,pr.default)(o.matchSelection)},"selection-start")}),Kf=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=w(Ki),i=v("TabCompletion",Ve),a=(0,ne.useRef)(null),l=(0,ne.useRef)(null),[c,p]=(0,ne.useState)(null),d=(0,sd.useDispatch)(),u=nr(document.activeElement===n),[g]=(0,ne.useState)(()=>document.createRange());u.triggerRef.current=g,(0,ne.useEffect)(()=>()=>g.detach(),[]),(0,ne.useEffect)(()=>{let f=t.current,y=a.current;!f||!y||(g.setStart(f,0),g.setEnd(y,0))},[t.current,a.current]),co(()=>{u.close()});let m=(0,ne.useCallback)(f=>{let y=g.toString(),E=/^http(s?):\/\//.test(f)?f:`https://${f}`;d(Xn({text:`[${y}](${E})`,replace:"selection"}))},[]);return(0,oe.jsxs)("span",{children:[(0,oe.jsx)("mark",{ref:a,className:(0,pr.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":u.opened?"true":"false",children:s}),u.opened&&(0,oe.jsx)(sr,{className:i.popoverRoot,triggerRef:u.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,oe.jsxs)(ir,{style:o,ref:l,children:[(0,oe.jsx)("div",{className:(0,pr.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,oe.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,oe.jsx)(Yp,{}),(0,oe.jsx)("span",{children:"\xA0"}),(0,oe.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,oe.jsx)(od,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:m,onDismiss:()=>{p(null),u.close()}})]})})]},"selection-end")},dr=class extends nd.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,ne.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,oe.jsx)(Ff,{ref:this.startRef}):(0,oe.jsx)(Kf,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var nt=require("react/jsx-runtime"),Uf=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=v("TabCompletion",zp),p=C("insertLink"),d=C("showMidSentenceSuggestions"),u=C("inlineSuggestions"),g=ys(a),m=(0,st.useRef)(null);(0,st.useEffect)(()=>{xt(a)&&g&&vs(a,g)},[g]);let f=(0,st.useCallback)(h=>{if(!s||!o)return h;let x=[(0,nt.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,nt.jsx)("span",{"data-testid":"tab-completion",className:(0,ur.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&x.push((0,nt.jsx)("span",{className:(0,ur.default)(c.hint,c.resetIndent),children:(0,nt.jsx)(Hn,{keyCode:"tab"},"tabHint")})),Mi(h,x)},[s,o,n]),y=(0,st.useMemo)(()=>{let h=[];return p&&h.push(new dr("selection")),h.push(new ao("placeholders")),r&&h.push(new ar("keywords")),h},[u,p,r]),E=(0,st.useMemo)(()=>{let h=window.getComputedStyle(a);return{"--dd-color":h.color,"--dd-font-size":h.fontSize,"--dd-font-family":h.fontFamily,"--dd-font-variant":h.fontVariant}},[]);return t?(0,nt.jsxs)("div",{ref:h=>{h!=null&&h.parentElement&&(m.current=h==null?void 0:h.parentElement)},className:c.root,style:E,children:[(0,nt.jsx)(rd.Interweave,{tagName:"span",containerTagName:"div",className:(0,ur.default)(c.container,c.agentText),disableLineBreaks:xt(a),content:e||"\u200B",onAfterParse:f,matchers:y,selection:g,keywordMatches:i,inputElement:a,inputStyle:E,boundaryRef:m,inlineSuggestionsOnlyAtEnd:!d}),(0,nt.jsx)("br",{})]}):null},zf=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var f;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??uo(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:u,visible:g,showStyleSuggestions:m}=o;return{showTabHint:p,showStyleSuggestions:m,showTabCompletion:u,content:l,tabText:c,source:a,keywordMatches:((f=n.list)==null?void 0:f.keywordMatches)??[],enabled:g&&d!==!1}},ad=(0,id.connect)(zf)(Uf);var Jd=k(require("classnames")),Yd=require("react"),$=require("react-redux");var wt=require("@reduxjs/toolkit");var ld={list:[],fetchState:"idle",isInitialRequest:null},pd=t=>t.autoflows.list||[],cd=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},rt=(0,wt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Ui=(0,wt.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(rt(t.platformSessionId))}),zi=(0,wt.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(rt(t.platformSessionId))}),jf=(0,wt.createSlice)({name:"autoflows",initialState:ld,reducers:{},extraReducers:t=>{t.addCase(Ui.pending,(e,o)=>{let n=cd(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(zi.pending,(e,o)=>{let n=cd(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(rt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(rt.rejected,e=>{e.fetchState="error"}),t.addCase(rt.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(N,()=>ld)}}),dd=(0,wt.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(rt(t))}),s.on("sessionCompleted",()=>{o(rt(t))})}),ud=(0,wt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),gd=jf.reducer;var Tt=require("@reduxjs/toolkit");var md={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},fd=t=>t.customMessages.list,hd=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),yd=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),vd=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),Sn=(0,Tt.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),gr=(0,Tt.createAsyncThunk)("customMessages/send",async(t,e)=>{let{platformSessionId:o,suggestion:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.sendCustomMessage(o,n)}),mr=(0,Tt.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)}),Sd=(0,Tt.createSlice)({name:"customMessages",initialState:md,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(Sn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(Sn.rejected,e=>{e.fetchState="error"}).addCase(Sn.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(gr.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(gr.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(mr.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(mr.rejected,(e,o)=>{let n=e.answeredSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1)),e.answeredSuggestions.splice(n,1)}).addCase(N,()=>md)}}),_d=(0,Tt.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(Sd.actions.onCustomMessage(r))})}),xd=(0,Tt.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),bd=Sd.reducer;var _n=require("@reduxjs/toolkit"),Vf={token:null,accountUrl:null,interval:null},Cd=t=>e=>{let{passwordlessToken:{token:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/passwordless/login/?token=${o}&redirect=${t}`:null},ji=(0,_n.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),Vi=(0,_n.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(ji()),setInterval(()=>n(ji()),o)}),wd=(0,_n.createSlice)({name:"passwordlessToken",initialState:Vf,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(ji.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(Vi.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:Td}=wd.actions,Ed=wd.reducer;function kd(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var Dd=require("react"),Hd=require("react-redux");var Md=k(require("classnames")),Nd=require("react");var Id=k(require("classnames"));var Rd={root:"_root_838fd_1"};var Ad=require("react/jsx-runtime"),qf=({className:t,children:e})=>{let o=v("Unicode",Rd);return(0,Ad.jsx)("span",{className:(0,Id.default)(t,o.root),children:e})},Pd=qf;var Ld={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 qi={};W(qi,{enUS:()=>Wf,nlNL:()=>Gf});var Wf={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"}]},Gf={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]};var ge=require("react/jsx-runtime"),Xf=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=v("Autoflow",Ld),a=w(qi),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,ge.jsxs)(D,{className:(0,Md.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,ge.jsx)(F,{children:(0,ge.jsxs)(F.Content,{children:[(0,ge.jsxs)(F.Title,{children:[e&&(0,ge.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,ge.jsx)("span",{children:n})]})}),(0,ge.jsx)(D.Actions,{fixed:e==="Started",children:(0,ge.jsx)(D.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,ge.jsxs)(Nd.Fragment,{children:[(0,ge.jsx)(Pd,{children:c})," ",(0,ge.jsx)("span",{children:a(l)})]})})})]})},Od=Xf;var Wi=require("react/jsx-runtime"),Qf=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Zf=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,Wi.jsx)(Dd.Fragment,{children:t.map(s=>(0,Wi.jsx)(Od,{displayName:s.displayName,description:s.description,disabled:s.isBusy||Qf(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),Jf=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},Yf={onStartAutoflow:Ui,onStopAutoflow:zi},Bd=(0,Hd.connect)(Jf,Yf)(Zf);var fr=require("react"),Kd=require("react-redux"),Xi=k(require("classnames"));var Gi=require("react/jsx-runtime"),$i=()=>(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 Fd={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 ze=require("react/jsx-runtime"),eh=({entities:t})=>{let e=v("EntitiesWidgetList",Fd),[o,n]=(0,fr.useState)(void 0),s=(0,Kd.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),an(a.text),s(X({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,fr.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,ze.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,ze.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,ze.jsx)("span",{className:e.entityText,children:a.text}),(0,ze.jsxs)("span",{className:e.iconWrapper,children:[(0,ze.jsx)("span",{className:(0,Xi.default)(e.icon),children:(0,ze.jsx)($i,{})}),(0,ze.jsx)("span",{className:(0,Xi.default)(e.icon,o===l&&e.iconClicked),children:(0,ze.jsx)($i,{})})]})]},a.text))})},Ud=eh;var zd=k(require("classnames")),Qi=require("react"),Wt=require("react-redux");var it={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 ce=require("react/jsx-runtime"),th=({suggestion:t})=>{let e=w(Dt),o=(0,Wt.useDispatch)(),n=(0,Wt.useSelector)(hd(t.text)),s=(0,Wt.useSelector)(yd(t.text)),r=(0,Wt.useSelector)(vd(t.text)),i=(0,Wt.useSelector)(Un),{replyOptions:a}=t,l=(0,Qi.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(gr({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,Qi.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),u=a[d];o(mr({platformSessionId:i,reply:u,suggestion:t}))},[t,n,o,i]);return(0,ce.jsxs)(D,{onClick:l,className:(0,zd.default)(it.root,{[it.isUsed]:n,[it.hasError]:r}),children:[(0,ce.jsx)(F,{children:(0,ce.jsxs)(F.Content,{children:[(0,ce.jsxs)(F.Title,{className:it.title,children:[t.text," ",(0,ce.jsx)(Bn,{className:it.label,children:"analyse tool"})," ",r&&(0,ce.jsx)("span",{className:it.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,ce.jsx)("ul",{className:it.quickReplies,children:a.map(p=>(0,ce.jsx)("li",{className:it.quickReply,children:p.title},p.title))})]})}),(0,ce.jsxs)(D.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,ce.jsx)(D.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>(0,ce.jsx)(D.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),(0,ce.jsx)(D.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},jd=th;var Zi=require("react/jsx-runtime"),Vd=()=>(0,Zi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Zi.jsx)("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});var Gd=require("react-redux");var qd=require("react");var me=require("react/jsx-runtime"),oh=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var u;let s=t.text||t.url||t.message,r=As(s),i=w(Dt),a=C("showImages"),l=C("fallbackImage"),c=g=>{g.preventDefault(),g.stopPropagation(),n(s)},p=g=>{g.preventDefault(),g.stopPropagation(),o(t)},d=(0,qd.useCallback)(g=>{window.open(r,"_blank"),g.stopPropagation(),g.preventDefault()},[r]);return(0,me.jsxs)(D,{onClick:c,"data-testid":"edit-suggestion",children:[(0,me.jsxs)(F,{children:[a&&t.image&&(0,me.jsx)(F.Image,{src:cr(t,"small",l||void 0),title:t.title}),(0,me.jsxs)(F.Content,{children:[t.title&&(0,me.jsx)(F.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&(0,me.jsx)(D.Labels,{labels:t.searchKeywords}),(0,me.jsx)(F.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),(0,me.jsxs)(D.Actions,{children:[r&&(0,me.jsx)(D.ActionButton,{onClick:d,label:i("visitUrl")}),(0,me.jsx)(D.ActionButton,{primary:!0,onClick:p,label:i("preview")}),(0,me.jsx)(D.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},Wd=oh;var xn=require("react/jsx-runtime"),nh=({contentType:t,lines:e,suggestions:o})=>{let n=xe(),s=(0,Gd.useSelector)(ht),r=a=>{n.send(Si,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(Qe,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,xn.jsx)(xn.Fragment,{children:o.map(a=>(0,xn.jsx)(Wd,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},$d=nh;var Ji={};W(Ji,{enUS:()=>sh,nlNL:()=>rh});var sh={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},rh={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Xd={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 Yi=require("react/jsx-runtime"),Qd=()=>(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 ea=require("react/jsx-runtime"),Zd=()=>(0,ea.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,ea.jsx)("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});var R=require("react/jsx-runtime"),hr=(t,e)=>{let o=(0,$.useSelector)(ue);(0,Yd.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},ih=({onLogIn:t})=>{let e=w(Ji),o=(0,$.useDispatch)(),n=C("isEmbedded"),s=v("Widget",Xd),r=C("showAutoflows"),i=C("showCustomMessages"),a=C("showSummaryCommand"),l=C("showKnowledgeSearch"),c=C("showSearch"),p=(0,$.useSelector)(St),d=(0,$.useSelector)(Gs),u=(0,$.useSelector)(pd),g=(0,$.useSelector)(zs),m=(0,$.useSelector)(fd),f=(0,$.useSelector)(zn),y=(0,$.useSelector)(oo),E=(0,$.useSelector)(ue),h=(0,$.useSelector)(Un),x=(0,$.useSelector)(kd),b=(0,$.useSelector)(ht),_=xe(),A=(0,$.useSelector)(dc),O=(0,$.useSelector)(Cd("/admin/")),se=C("adminUrl"),L=C("productName");if(hr(()=>(o(Sn(h)),o(_d(h)),()=>{o(xd(h))}),[o,y,i,h]),hr(()=>(o(rt(h)),o(dd(h)),()=>{o(ud(h))}),[o,y,r,h]),hr(()=>{d.forEach(({type:P})=>{o(P==="entities"?Le():Pe(P))})},[o,y,f,p]),hr(()=>(o(Vi()),()=>{o(Td())}),[o]),y===!1)return(0,R.jsx)("div",{className:s.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:e("notSupported")})})},"supported");if(E===!1)return(0,R.jsx)("div",{className:s.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(Js,{isEmbedded:n,loginUrl:se,onLogIn:t})})},"login");if(!p||!h||E===null||A||x)return(0,R.jsx)("div",{className:s.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:e("waiting")})})},"waiting");let re=c||a||l||O;return(0,R.jsx)("div",{className:(0,Jd.default)(s.root),"data-testid":"widget",children:(0,R.jsxs)(Fn,{className:s.sectionList,children:[re&&(0,R.jsx)(lt,{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:()=>_.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(fo,{}),e("linkSearch")]}),a&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-summary",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(Zd,{}),e("linkSummary")]}),l&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,R.jsx)(Qd,{}),e("linkKnowledgeSearch")]}),O&&(0,R.jsxs)("a",{className:s.shortcut,target:"_blank",href:O,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[(0,R.jsx)(Vd,{}),e("linkStudioLogin",{productName:L})]})]})}),i&&m.length>0&&(0,R.jsx)(lt,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(Se,{withDivider:!0,children:m.map(P=>(0,R.jsx)(jd,{suggestion:P},P.text))})}),r&&u.length>0&&(0,R.jsx)(lt,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(Se,{withDivider:!0,children:(0,R.jsx)(Bd,{})})}),d.map(({type:P,title:U,amount:Qt,lines:Mo})=>{var No;switch(P){case"entities":return g&&g.length>0&&(0,R.jsx)(lt,{type:P,title:U,"data-testid":`type-${P}`,children:(0,R.jsx)(Ud,{entities:g})},P);default:return((No=b[P])==null?void 0:No.fetchState)==="done"&&b[P].suggestions.length>0&&(0,R.jsx)(lt,{type:P,title:U,"data-testid":`type-${P}`,children:(0,R.jsx)(Se,{withDivider:!0,children:(0,R.jsx)($d,{lines:Mo,contentType:P,suggestions:b[P].suggestions.slice(0,Qt)||[]})})},P)}})]})})},eu=ih;function Po(t){let e=new Range;return e.selectNodeContents(t),e}function tu(t,e,o){try{return Et(t,e,o),!0}catch{return!1}}function yr(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function vr(t){return"tagName"in t&&t.tagName==="BR"}var bn=/[\u200B-\u200D\uFEFF]/g;function Et(t,e,o){let n=new Range;if(t.firstChild===null&&e===0&&o===0)return n.selectNodeContents(t),n;let s=0,r=!1;function i(l,c){let p=-1,d=/[\u200B-\u200D\uFEFF]/;if(!d.test(l))return c;for(let u=0;u<=l.length;u++)if(d.test(l[u])||p++,p===c)return u;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(bn,""),d=s+p.length,u=e>=s&&e<=d,g=o>=s&&o<=d;if(u){let m=i(c,e-s);m===0&&!g?n.setStartBefore(l):n.setStart(l,m)}g&&(n.setEnd(l,i(c,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(vr(l)&&(s===e&&n.setStartBefore(l),s++,s===o)){n.setEndAfter(l),r=!0;return}for(let p=0;p<l.childNodes.length&&(a(l.childNodes[p]),!r);p++);let c=l.lastChild;yr(l)&&c&&!yr(c)&&!vr(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function Cn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r,collapsed:i}=e,a,l,c=0;function p(d){let u=d===o,g=d===s;switch(d.nodeType){case Node.TEXT_NODE:{let m=d.textContent;u&&(a=c+m.substring(0,n).replace(bn,"").length),g&&(l=c+m.substring(0,r).replace(bn,"").length),c+=m.replace(bn,"").length;break}case Node.ELEMENT_NODE:{let m=d.nextSibling===null;vr(d)&&!m&&c++;for(let f=0;f<d.childNodes.length;f++){let y=u&&f===n,E=g&&f===r;if(y&&(a=c),E&&(l=c),l!==void 0||((!y||!i)&&p(d.childNodes[f]),g&&f===r-1&&(l=c),l!==void 0))break}!g&&yr(d)&&!m&&c++,g&&(l=c);break}default:break}}if(p(t),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function wn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let p=c===o,d=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let u=p?n:0,g=d?r:void 0,m=c.textContent.replace(bn,"");u===0&&g===void 0?a+=m:a+=m.substring(u,g);break}case Node.ELEMENT_NODE:{let u=c.nextSibling===null;i===0&&vr(c)&&!u&&(a+=`
|
|
4
|
-
`);for(let g=p?n:0;g<(d?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[g]),i!==1);g++);!d&&i===0&&
|
|
5
|
-
`);break}default:break}d&&i++}return l(t),a}function ou(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Gt=class extends qe{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),wn(this.element,e)}getHTML(){return this.element.innerHTML||""}getRange(){var r;let e=this.getRootNode();if(e.activeElement!==this.element)return null;let o="getSelection"in e?e.getSelection():window.getSelection();if(!o)return null;let n="getComposedRanges"in o&&e instanceof ShadowRoot?(r=o.getComposedRanges(e))==null?void 0:r[0]:o.rangeCount>0?o.getRangeAt(0):null;if(!n)return null;let s=this.element.ownerDocument.createRange();return s.setStart(n==null?void 0:n.startContainer,n==null?void 0:n.startOffset),s.setEnd(n==null?void 0:n.endContainer,n==null?void 0:n.endOffset),!s||!this.element.contains(s.startContainer)||!this.element.contains(s.endContainer)?null:s}getCaretPosition(){let e=this.getRange();if(!e||!e.collapsed||!("getBoundingClientRect"in e))return null;let o=e.getBoundingClientRect();return!ou(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!ou(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&&tu(this.element,o.start,o.end))return o;let n=Po(this.element);return n.collapse(!1),Cn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return wn(this.element,Et(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return(s=this.observer)==null||s.takeRecords(),Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};function nu(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 ta=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(e)}broadcastChannel;disposeHandlers=[];onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(e)}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},oa=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=nu(e,`${this.targetOrigin}/v2/widget/liveengage/channel.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(e,this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},na=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),T.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new oa(e,this.deepdeskUrl,{debug:!0}):new ta(e),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&s.data.channel===e&&(T.info("Received broadcast event",this.sessionId,s),(i=(r=this.eventMap)[s.data.name])==null||i.call(r,s.data.payload))};return o.onMessage(n),o}send(e,o){var r,i;T.info("broadcast event",{sessionId:this.sessionId,name:e,payload:o});let n={type:"event",name:e,payload:o};(i=(r=this.eventMap)[e])==null||i.call(r,o);let s=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage({...n,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},su=na;var Ao=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var sa=t=>new Promise(e=>{setTimeout(e,t)});var Lo=class extends Ao{name="ClientError"},ra=class extends Ao{name="ServerError"},Ne=class t{constructor(e="",o={}){this.baseUrl=e;this.options=o;o.fetch&&(this.fetch=o.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,o={}){return new Promise((n,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,{abortLatest:l=!1,attempts:c=1,retryDelay:p=500,refreshTokenOn401:d=!0,retryOnError:u=b=>b instanceof TypeError,retryOnResponse:g=b=>b.status>=500,version:m="v1",...f}=o,y={credentials:"include",...f,headers:{"Content-Type":"application/json",...f.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(y.headers={...y.headers,"X-CSRFToken":this.csrfToken}),typeof m=="string"&&(y.headers={...y.headers,"X-Deepdesk-API-Version":m});let E=c,h=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&l&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let x=async()=>(E--,a(i,y).then(async b=>g(b)&&!r.isAborted&&E>0?(await sa(p),x()):b.status===401&&d===!0&&h===!1?(h=!0,await this.refreshToken(),x()):b).catch(async b=>{if(u(b)&&!r.isAborted&&E>0)return await sa(p),x();throw b}));x().then(b=>b.json().catch(()=>null).then(_=>{b.status>=500?s(new ra("Server Error",_)):b.status===401?s(new Lo("Unauthorized",_)):b.status===403?s(new Lo("Forbidden",_)):b.status===404?s(new Lo("Not Found",_)):b.status>=400&&s(new Lo("Bad Request",_)),delete this.latestRequestByUrl[i],n(_)})).catch(b=>{s(b)})})}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var ah;(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||={})})(ah||={});function Sr(t){return{...M(t),tags:t.tags}}var at=class t{constructor(e,o={}){this.options=o;this.client=new Ne(e,{fetch:o.fetch}),this.client.patchFetch(n=>async(s,r)=>{let i=await n(s,r);return this.handleDeepdeskVersionHeaders(i),i})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=await this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(t.exchangeTokenPromise||(t.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),t.exchangeTokenPromise):Promise.resolve()}async createConversation(e){await this.preflight(),T.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...q(e),tags:e.tags},{version:"v2"});return Sr(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return M(o)}async getKnowledgeAssistant(e){let o=await this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{version:null});return M(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return M(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return M(e)}async checkUserExists(e){let{exists:o}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return o}async getConversationBySessionId(e,o={}){await this.preflight(),T.info(`Getting conversation for session ${e}`);let{attempts:n=1,retryDelay:s=1e3}=o,r=await this.client.get(`/api/conversations/by_session_id/${e}`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"});return Sr(r)}async isConversationSupported(e,o={}){T.info(`Check if conversation for session ${e} is supported`);let{attempts:n=1,retryDelay:s=1e3}=o;return(await this.client.get(`/api/conversations/by_session_id/${e}/active_profile`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"})).has_active_profile}async updateConversation(e,o){let n=q(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return Sr(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...q(s),tags:s.tags})),{version:"v2"})).map(s=>Sr(s))}async sendEvent(e,o){let{data:n,...s}=o,r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((i,[a,l])=>({...i,[a]:l}),{});return this.client.post("/api/events",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)},prompt_instruction:o.promptInstruction,model:o.model})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(e){return this.client.post("/apis/admin/session/jwt/",{jwt:e},{version:null}).catch(o=>{throw T.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",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=>({...M(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 M(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 M(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,q(e),{version:"v2"});return M(o)}async knowledgeAssist(e,o,n){let s=await this.client.post(`/api/knowledge-assist/assistants/${n}/search`,q({question:e.question,promptInstruction:e.promptInstruction,chatHistory:o.map(r=>({question:r.question,answer:r.answer.answer}))}),{version:"v2"});return M(s)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return M(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return M(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 M(o)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(La);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&T.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var Tn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(ui(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,M(s))}catch{T.warn(`Invalid JSON for ${e}: ${n}`)}})}connect(){clearTimeout(this.timeoutTimer);let e=new EventSource(this.url,{withCredentials:!0});this.eventSource=e;let o=!1;e.onopen=()=>{o=!0},e.onerror=()=>{o&&e.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{e.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(n=>{this.proxyEvent(n)})}disconnect(){var e;clearTimeout(this.timeoutTimer),this.eventListeners={},(e=this.eventSource)==null||e.close()}emit(e,o){this.eventListeners[e]&&this.eventListeners[e].forEach(n=>n(o))}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),this.proxyEvent(e),()=>{this.off(e,o)}}off(e,o){let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}};var lh;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(lh||={});var En=class{constructor(e,o={}){this.apiUrl=e;this.client=new Ne(e,o)}client;streams={};logger=T;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return M(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,q(o));return M(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 M(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",q(e));return M(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new Tn(`${this.apiUrl}/sessions/${e}/events`),this.streams[e].connect()),this.streams[e]}closeStream(e){this.streams[e]||(this.streams[e].disconnect(),delete this.streams[e])}};var Cr=require("@reduxjs/toolkit");var iu=require("@reduxjs/toolkit");var ru={startTime:null,stopTime:null},au=(0,iu.createSlice)({name:"handlingTime",initialState:ru,reducers:{handlingTimeStart(t){if(t.startTime&&!t.stopTime)throw new Error("Timing already started");t.startTime=new Date,t.stopTime=null},handlingTimeStop(t){if(!t.startTime)throw new Error("Timing not started");t.stopTime=new Date},handlingTimeReset(t){t.startTime=null,t.stopTime=null}},extraReducers:t=>{t.addCase(N,()=>ru)}}),{handlingTimeStart:lu,handlingTimeStop:_r,handlingTimeReset:cu}=au.actions,pu=au.reducer;var du=(t={})=>{let e={onAuthError:So(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var br=require("@reduxjs/toolkit");var xr={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var $t=(0,br.createAsyncThunk)("styleSuggestions/getAll",async({text:t},e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),{showStyleSuggestions:s}=n.settings,r=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)return xr.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),ch=(0,br.createSlice)({name:"styleSuggestions",initialState:xr,reducers:{},extraReducers:t=>{t.addCase($t.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase($t.rejected,e=>{e.fetchState="error"}).addCase($t.fulfilled,(e,o)=>{e.fetchState="done",pt(e.list,o.payload)||(e.list=o.payload)}).addCase(Pt,e=>{e.list=xr.list}).addCase(N,()=>xr)}}),uu=ch.reducer;var gu=(t={})=>{let e,o=!0,n={getStyleSuggestions:$t,debounce:500,...t};return s=>r=>i=>{var g;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:p}=c.settings;if(!((g=c.conversation.current)==null?void 0:g.id)||!p)return l;let{text:u}=c.input;return u===a&&!o||(clearTimeout(e),u==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:u}))},t.debounce)),l}};function ph(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var mu=(t={})=>{let e={getTextSuggestions:Pe,getAutocompleteSuggestions:Yo,debounce:200,check:Eo,...t},o;return n=>s=>r=>{var f;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:p}=l.settings,d=(f=l.conversation.current)==null?void 0:f.id,u=r.type===Ds.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:g}}=l;return ph(g,i)&&!u||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let y=no(l);y===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(y))},u?0:e.debounce)),a}};var fu=$t.fulfilled.toString();function dh(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 hu=t=>e=>o=>n=>{var c;if(n.type!==fu){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=dh(s,i);n.type===fu&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var uh=(0,Cr.combineReducers)({activeSuggestion:bc,answer:up,auth:Dc,autoflows:gd,conversation:Ka,contentTypes:$c,customMessages:bd,passwordlessToken:Ed,entities:Jc,knowledgeAssistant:cp,handlingTime:pu,info:Ql,input:Dr.reducer,overlayInput:ie.reducer,settings:Da,profile:fp,search:oc,summary:sp,styleSuggestions:uu,ui:kc,textSuggestions:hc});function yu(t){return(0,Cr.configureStore)({reducer:uh,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),du(),mu({debounce:200}),gu({debounce:500}),hu(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var gh=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},mh=t=>e=>o=>n=>{var a;let s=e.getState(),r=Lr("inlineSuggestions")(s);switch(n.type){case $e.toString():{let l=Os(n.payload.contentType)(e.getState()),c=l.indexOf(n.payload.suggestion);t.emit("edit-suggestion",{contentType:n.payload.contentType,index:c,suggestions:l});break}case So.toString():{!n.payload&&t.emit("logout",void 0);break}case ke.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:gh(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Xn.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 Fo.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case Yn.toString():t.emit("select-image",n.payload,{mayApplyChanges:!0}),t.sendEvent("Image attached",{conversationId:s.conversation.current.id,data:{path:n.payload.suggestion.image,title:n.payload.suggestion.title}});break;case Le.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case Ze.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary}});break;case X.toString():t.sendEvent(n.payload.name,{conversationId:((a=n.payload.options)==null?void 0:a.includeConversationData)&&s.conversation.current.id,data:n.payload.data});break;case Qn.toString():t.handleKeyDown(n.payload);break;case Pt.toString():t.logSendMessage(n.payload);break;case Zn.toString():t.logSendEditSuggestionMessage(n.payload);break;case Jn.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case Pt.toString():t.handleAfterSendMessage(n.payload);break;case en.toString():t.onUpdateShowTabHint(n.payload);break;case _r.toString():t.logHandlingTime();break;case ke.toString():{r&&(e.dispatch(He([])),e.dispatch(je()));break}case He.toString():{r&&n.payload.length>0&&e.dispatch(ut(0));break}default:break}return i},vu=mh;function ia(t){return t.toISOString().replace("T"," ").replace("Z","")}function Su(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:ia(o),timeStop:ia(n)}}function aa(t,e,o){var O,se,L;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:d,cuts:u,deletions:g,textSuggestions:m,offeredTextSuggestions:f}}=e[t],y=n.length,h=m.reduce((re,{text:P,searchTerm:U})=>re+P.length-(U?U.length:0),0),x=c??Date.now(),b=(Date.now()-x)/1e3+(p||0),_=s/b,A=m.reduce((re,{searchTerm:P})=>re+(P?P.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:d,cuts:u,deletions:g,lenTextTyped:s+A,lenTextTotal:y,lenTextAssisted:h,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:b,charsPerSecond:_,numPastes:l,textSuggestionsV2:m,suggestionsCounters:[{source:"gpt",countOffered:f.filter(re=>re.source==="gpt").length}],agentId:(O=e.info.agentInfo)==null?void 0:O.agentId,agentName:(se=e.info.agentInfo)==null?void 0:se.agentName,agentEmail:(L=e.info.agentInfo)==null?void 0:L.agentEmail}}function la(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return la(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?la(s,e):null}function _u(t,e){return la(t,e)}function xu(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function fh(t){return typeof t=="object"&&t!==null&&"tagName"in t}function wr(t){return fh(t)&&(xt(t)||hs(t))}var bu=(t,e)=>({value(){try{let o=sessionStorage.getItem(`dd-${t}`);if(!o)return e;try{return JSON.parse(o)}catch{return e}}catch{return e}},update(o){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(o))}catch{T.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function hh(t){return t.offsetParent!==null}function Cu(t){if(!hh(t))return!1;let e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function Tr(t,e,o=100){let n=Cu(t);e({isVisible:n});let s=setInterval(()=>{let r=Cu(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var ku=k(require("classnames")),Ru=require("react-redux");var Er=require("react/jsx-runtime"),wu=({className:t})=>(0,Er.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,Er.jsx)("g",{children:(0,Er.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
|
+
`,At.MISSING_INTL_API,i);var b=o.getPluralRules(e,{type:p.pluralType}).select(u-(p.offset||0));x=p.options[b]||p.options.other}if(!x)throw new Vr(p.value,u,Object.keys(p.options),i);a.push.apply(a,jo(x.value,e,o,n,s,u-(p.offset||0)));continue}}return Pg(a)}function Lg(t,e){return e?pe(pe(pe({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=pe(pe({},t[n]),e[n]||{}),o},{})):t}function Mg(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Lg(t[n],e[n]),o},pe({},t)):t}function qr(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Ng(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:ds(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,es([void 0],o,!1)))},{cache:qr(t.number),strategy:us.variadic}),getDateTimeFormat:ds(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,es([void 0],o,!1)))},{cache:qr(t.dateTime),strategy:us.variadic}),getPluralRules:ds(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,es([void 0],o,!1)))},{cache:qr(t.pluralRules),strategy:us.variadic})}}var ul=function(){function t(e,o,n,s){o===void 0&&(o=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var p=r.formatToParts(c);if(p.length===1)return p[0].value;var d=p.reduce(function(u,g){return!u.length||g.type!==Q.literal||typeof u[u.length-1]!="string"?u.push(g.value):u[u.length-1]+=g.value,u},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return jo(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=sl(i,["formatters"]);this.ast=t.__parse(e,pe(pe({},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=Mg(t.formats,n),this.formatters=s&&s.formatters||Ng(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=al,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 Og(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var Dg="dummy",Wr=(0,gs.createContext)(null);function T(t){let e=(0,gs.useContext)(Wr);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=Og(o,n);return r?new ul(r).format(s):(e!==Dg&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var Vo=require("react/jsx-runtime"),ms=()=>(0,Vo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Vo.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Vo.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 qo=require("react/jsx-runtime"),gl=()=>(0,qo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,qo.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,qo.jsx)("path",{d:"M64 448c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L178.8 256L41.38 118.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l160 160c12.5 12.5 12.5 32.75 0 45.25l-160 160C80.38 444.9 72.19 448 64 448z"})]});var _e=require("react"),Ll=require("react-redux"),ni=require("interweave"),si=k(require("classnames"));var Gr={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};var fl=require("interweave"),hl=k(require("classnames"));var io=require("react");function ml(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function fs(t){let e=(0,io.useRef)(null),[o,n]=(0,io.useState)(!1);return(0,io.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=ml((p,d)=>{let u=e.current;if(!u)return;let g=p/r,m=d/r,f=u.getBoundingClientRect(),h=g>f.x&&g<f.x+f.width&&m>f.y&&m<f.y+f.height;h&&!s?(s=!0,n(!0)):!h&&s&&(s=!1,n(!1))},({clientX:p,clientY:d})=>[p,d]),[l,c]=ml(()=>{s=!1,n(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",l),()=>{a(),c(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",l)}},[e]),[e,o]}var Ve={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var $r=require("react/jsx-runtime"),Hg=({inputElement:t,children:e})=>{let o=v("TabCompletion",Ve),[n,s]=fs(t);return(0,$r.jsx)("mark",{ref:n,className:(0,hl.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},ao=class extends fl.Matcher{match(e){let o=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return o?{index:o.index,length:o[0].length,match:o[0],matchString:o[0],valid:!0}:null}replaceWith(e,o){return(0,$r.jsx)(Hg,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var lo=require("react");function hs(t){return t.contentEditable==="true"}function Bg(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 yl(t){let{selectionStart:e,selectionEnd:o}=hs(t)?Bg(t):t;return[e,o]}function ys(t){let[,e]=(0,lo.useState)(),o=(0,lo.useRef)(null);return o.current=yl(t),(0,lo.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=yl(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 vs(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(to);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 vl=require("react");function co(t){(0,vl.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Lt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var Sl,Be=new Map,Fg=["bottom","height","left","right","top","width"],Kg=(t={},e={})=>Fg.some(o=>t[o]!==e[o]);function _l(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,..._l(e)]:[]}function xl(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var Ss=!1,bl=()=>{Ss=!0;let t=[];if(Be.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),Be.delete(o);return}let n=o.getBoundingClientRect();Kg(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(xl,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),Be.size===0){Ss=!1;return}Sl=window.requestAnimationFrame(bl)};function Xr(t,e){let o=_l(t),n=[],s=o.map((r,i)=>Xr(r,a=>{n[i]=a;let l=Be.get(t);if(!l)return;let c=n.reduce(xl,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),Be.has(t)){let i=Be.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Be.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!Ss&&bl()},unobserve(){s.forEach(i=>i.unobserve());let r=Be.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||Be.delete(t),Be.size||(cancelAnimationFrame(Sl),Ss=!1)}}}}var Cl,Fe=new Map,wl=()=>{Fe.forEach((t,e)=>{if(!e.isConnected){Fe.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)))}),Fe.size!==0&&(Cl=window.requestAnimationFrame(wl))};function Tl(t,e){return{observe(){let o=Fe.size===0;Fe.has(t)?Fe.get(t).callbacks.push(e):Fe.set(t,{visible:void 0,callbacks:[e]}),o&&wl()},unobserve(){let o=Fe.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Fe.delete(t),Fe.size||cancelAnimationFrame(Cl)}}}}var Qr=["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth","borderStyle","boxSizing","color","overflowWrap","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontWeight","fontKerning","lineHeight","letterSpacing","paddingLeft","paddingTop","paddingRight","paddingBottom","width","height","textIndent","whiteSpace","wordBreak","wordSpacing","wordWrap"];function Zr(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function po(t){return parseFloat(t)}function _s(t){return Math.round(t*1e6)}function El(t){return t/1e6}function Jr(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=po(t.width),r=po(t.borderLeftWidth),i=po(t.borderRightWidth),a=po(t.paddingRight),l=El(_s(s)-_s(r)-_s(i)),c=El(_s(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function Mt(t,e={}){var p;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",Lt(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Zr(n,o,Qr),Jr(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=Tl(t,()=>{Zr(n,o,Qr),Jr(n,t,o),r(),setTimeout(r,0)}),a,l=!0,c=Xr(t,d=>{if(d===null){e.onRemove&&e.onRemove(),o.remove();return}if(!l&&e.onMoveStart&&(Promise.resolve().then(()=>e.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{e.onMoveEnd&&e.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Zr(n,o,Qr),Jr(n,t,o),r(),o.style.top=`${d.top}px`,o.style.left=`${d.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let u=e.closestScrollElement.getBoundingClientRect(),g=window.getComputedStyle(e.closestScrollElement),m=po(g.borderTopWidth),f=po(g.borderBottomWidth),h=u.top+m-d.top,w=d.top+d.height+-(u.top+u.height-f);o.style.clipPath=`inset(${h}px 0px ${w}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(p=t.parentElement)==null||p.appendChild(o),c.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),c.unobserve(),i.unobserve()}]}var Yr={};W(Yr,{enUS:()=>Ug,nlNL:()=>zg});var Ug={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"No placeholders found"}]},one:{value:[{type:0,value:"There is one placeholder in your message"}]},other:{value:[{type:0,value:"There are "},{type:7},{type:0,value:" placeholders in your message"}]}},offset:0,pluralType:"cardinal"}]},zg={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"Alle placeholders zijn uit je bericht"}]},one:{value:[{type:0,value:"Er is 1 placeholder in jouw bericht"}]},other:{value:[{type:0,value:"Er zijn "},{type:7},{type:0,value:" placeholders in jouw bericht"}]}},offset:0,pluralType:"cardinal"}]};var Wo=require("react/jsx-runtime"),kl=()=>(0,Wo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,Wo.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,Wo.jsx)("path",{d:"M243.8 339.8C232.9 350.7 215.1 350.7 204.2 339.8L140.2 275.8C129.3 264.9 129.3 247.1 140.2 236.2C151.1 225.3 168.9 225.3 179.8 236.2L224 280.4L332.2 172.2C343.1 161.3 360.9 161.3 371.8 172.2C382.7 183.1 382.7 200.9 371.8 211.8L243.8 339.8zM512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256zM256 48C141.1 48 48 141.1 48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48z"})]});var ei=require("react/jsx-runtime"),Rl=()=>(0,ei.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,ei.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var Il=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(Il||{}),qe=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();pt(e,this.currentCaret)||(this.currentCaret=e,this.emit("caret",e))}handleKeyUp(e){let{key:o,shiftKey:n}=e;(o==="Enter"&&n===!0||o==="Backspace")&&this.triggerChange(),this.triggerSelection()}handleClick(){this.triggerSelection()}handleFocus(){this.isFocused||this.emit("focus"),this.triggerSelection(),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(e){let{key:o,ctrlKey:n,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(Il).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var n,s;let o=((n=e.clipboardData)==null?void 0:n.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",o=>this.handleKeyDown(o)),this.addEventListener("keyup",o=>this.handleKeyUp(o)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",o=>this.handlePaste(o)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()}),this.currentSelection=this.getSelection()}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};var We=class extends qe{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){let e=this.getSelection();return e?this.getText().slice(e.start,e.end):""}getCaretPosition(){return null}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let o=this.element.disabled,n=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>n.disconnect())}};var jg=/[.*+?^${}()|[\]\\]/g,Vg=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function qg(t){return t.replace(jg,"\\$&")}function Wg(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function Gg(t){return t.search(Vg)}function Pl(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${qg(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function Al(t){return t.replace(to,'<mark data-type="placeholder">$1</mark>')}function uo(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function $g(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 ti(t,e,o={}){if(e){let n=Wg(e.toLowerCase(),t.toLowerCase()),s=uo(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=Gg(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(Pa).length>3||e.length>30?$g(e.trim(),n):0;return`${`${i>0?"\u2026":""}${uo(t.substring(i,n))}`}<strong>${s}</strong>`}return t}function oi(t){return/<\/?[a-z][\s\S]*>/i.test(t)}function xs(t){if(oi(t)){let o=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(t);return o?o[1]:""}return t}var Z=require("react/jsx-runtime"),Xg=({value:t,onUse:e,...o})=>{var d;let n=T(Yr),s=(0,Ll.useDispatch)(),r=oi(t),i=v("EditSuggestionTextInput",Gr),[a,l]=(0,_e.useState)(null),c=(0,_e.useRef)(null),p=((d=t.match(to))==null?void 0:d.length)||0;return(0,_e.useEffect)(()=>{let u;return c.current&&(l(c.current),u=new We(c.current),u.on("change",({plainText:g})=>{s(ie.actions.userInput({text:g,selection:u.getSelection()}))}),u.on("keydown",g=>{s(ie.actions.registerKeyDown($n(g))),g.code==="Enter"&&g.shiftKey&&e(u.getText())}),u.on("paste",({pastedText:g,selectionText:m})=>{s(ie.actions.registerPaste({text:g,selectionText:m}))}),u.on("cut",({selectionText:g})=>{s(ie.actions.registerCut(g))})),()=>{s(ie.actions.reset()),u.dispose(),u.deactivate()}},[c]),(0,_e.useEffect)(()=>{t&&c.current&&(c.current.value=t)},[t,c]),(0,_e.useEffect)(()=>{c.current&&setTimeout(()=>{if(!c.current)return;let u=c.current.value.length;c.current.setSelectionRange(u,u),c.current.focus()},0)},[c]),r?(0,Z.jsx)("div",{className:i.textInputWrapper,children:(0,Z.jsx)(ni.Interweave,{className:i.textInput,tagName:"div",content:t})}):(0,Z.jsxs)("div",{className:i.textInputWrapper,children:[(0,Z.jsx)("textarea",{...o,ref:c,"data-testid":"edit-suggestion-dialog-textarea",className:i.textInput,defaultValue:t,onChange:()=>{}}),a&&(0,Z.jsx)(Qg,{inputElement:c.current,value:t}),(0,Z.jsxs)("div",{className:(0,si.default)(i.alert,p===0?i.success:i.warning),children:[(0,Z.jsx)("div",{className:i.alertText,children:n("placeholders",{placeholderSize:p})}),p===0?(0,Z.jsx)(kl,{}):(0,Z.jsx)(Rl,{})]})]})},Qg=({inputElement:t,value:e})=>{let o=v("EditSuggestionTextInput",Gr),n=(0,_e.useRef)(null),s=ys(t);return(0,_e.useEffect)(()=>{vs(t,s)},[s,t]),(0,Z.jsx)(Zg,{inputElement:t,children:(0,Z.jsxs)("div",{ref:n,className:(0,si.default)(o.root,o.agentText),children:[(0,Z.jsx)(ni.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new ao("placeholders")],inputElement:t,boundaryRef:n}),(0,Z.jsx)("br",{})]})})},Zg=({inputElement:t,children:e})=>{let o=(0,_e.useRef)(null);return(0,_e.useEffect)(()=>{if(!o.current)return()=>{};let[n,s]=Mt(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),(0,Z.jsx)("div",{ref:o,children:e})},Ml=Xg;var ho=require("react");var Nl=require("react"),bs=k(require("classnames"));var ae={root:"_root_pc5uy_1",list:"_list_pc5uy_2",listWrapper:"_listWrapper_pc5uy_6",listHorizontal:"_listHorizontal_pc5uy_10",page:"_page_pc5uy_19",search:"_search_pc5uy_25",pageNav:"_pageNav_pc5uy_33",pageTitle:"_pageTitle_pc5uy_41",pageBackButton:"_pageBackButton_pc5uy_48",listHeading:"_listHeading_pc5uy_62",listItem:"_listItem_pc5uy_70",listItemContent:"_listItemContent_pc5uy_79",listItemText:"_listItemText_pc5uy_97",listItemDescription:"_listItemDescription_pc5uy_105",listItemActions:"_listItemActions_pc5uy_112",truncate:"_truncate_pc5uy_123",lineClamp:"_lineClamp_pc5uy_129",listItemTitle:"_listItemTitle_pc5uy_136",listItemAction:"_listItemAction_pc5uy_112",listItemPrimaryAction:"_listItemPrimaryAction_pc5uy_157",listItemSelected:"_listItemSelected_pc5uy_162",sources:"_sources_pc5uy_166",sourcesTitle:"_sourcesTitle_pc5uy_173",source:"_source_pc5uy_166",icon:"_icon_pc5uy_188",searchIcon:"_searchIcon_pc5uy_205",searchInputWrapper:"_searchInputWrapper_pc5uy_210",searchInput:"_searchInput_pc5uy_210",select:"_select_pc5uy_231",selectType:"_selectType_pc5uy_248",selectWrapper:"_selectWrapper_pc5uy_252",image:"_image_pc5uy_282",imageSrc:"_imageSrc_pc5uy_289",imageSrcHidden:"_imageSrcHidden_pc5uy_300",imageSrcStatus:"_imageSrcStatus_pc5uy_304",imageTitle:"_imageTitle_pc5uy_314",actions:"_actions_pc5uy_319",actionsWrapper:"_actionsWrapper_pc5uy_323",actionsBar:"_actionsBar_pc5uy_329",actionButton:"_actionButton_pc5uy_338",actionShortcut:"_actionShortcut_pc5uy_356",actionShortcutFixKerning:"_actionShortcutFixKerning_pc5uy_363"};var Nt={};W(Nt,{enUS:()=>Jg,nlNL:()=>Yg});var Jg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},Yg={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};var gt=require("react/jsx-runtime"),em=({src:t,title:e})=>{let o=v("CommandPalette",ae),[n,s]=(0,Nl.useState)("loading"),r=T(Nt);return(0,gt.jsxs)("div",{className:o.image,children:[(0,gt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,bs.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,gt.jsx)("span",{className:(0,bs.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,gt.jsx)("span",{className:(0,bs.default)(o.imageSrc,o.imageSrcStatus),children:(0,gt.jsx)(Mn,{})}),e&&(0,gt.jsx)("span",{className:o.imageTitle,children:e})]})},Ol=em;var Dl=k(require("react")),Hl=k(require("classnames"));var Go=require("react/jsx-runtime");function ri({children:t,heading:e,orientation:o}){let n=v("CommandPalette",ae);return Dl.default.Children.count(t)===0?null:(0,Go.jsxs)("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&(0,Go.jsx)("h4",{className:n.listHeading,children:e}),(0,Go.jsx)("div",{className:(0,Hl.default)(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}var $o=k(require("classnames"));var Cs=k(require("react")),Kl=require("react/jsx-runtime"),Bl=Cs.default.createContext(void 0);function mt(){let t=Cs.default.useContext(Bl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var Fl=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=Cs.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,Kl.jsx)(Bl.Provider,{value:i,children:t})};var G=k(require("react")),Ul=k(require("classnames"));var ii={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 Ot=require("react/jsx-runtime"),tm=0,zl=G.default.createContext(null),om=()=>{let t=(0,G.useContext)(zl);if(!t)throw new Error("Invalid DropdownContext");return t},jl=({trigger:t,children:e,position:o="bottom"})=>{let n=(0,G.useMemo)(()=>++tm,[]),s=(0,G.useRef)(null),r=(0,G.useRef)(null),i=v("Dropdown",ii),[a,l]=(0,G.useState)(!1),[c,p]=(0,G.useState)(o),d=g=>{g.preventDefault(),g.stopPropagation(),l(!a)},u=(0,G.useCallback)(([g])=>{!g.isIntersecting&&a&&p(c==="top"?"bottom":"top")},[a]);return(0,G.useEffect)(()=>{let g=m=>{s.current&&!s.current.contains(m.target)&&l(!1)};return document.addEventListener("click",g),()=>{document.removeEventListener("click",g)}},[]),(0,G.useEffect)(()=>{if(!r.current&&!a)return()=>{};let g=new IntersectionObserver(u,{root:null,rootMargin:"0px",threshold:1});return r.current&&g.observe(r.current),()=>{r.current&&g.unobserve(r.current)}},[r,a]),(0,Ot.jsx)(zl.Provider,{value:{setIsOpen:l},children:(0,Ot.jsxs)("div",{ref:s,className:i.root,children:[(0,Ot.jsx)("button",{id:`dropdown-${n}`,"data-testid":"dropdown-trigger","aria-haspopup":"true","aria-expanded":a,"aria-label":"Dropdown trigger",type:"button",className:i.trigger,onClick:d,children:t}),(0,Ot.jsx)("div",{"data-testid":"dropdown-content",ref:r,"aria-hidden":!a,"aria-labelledby":`dropdown-${n}`,className:(0,Ul.default)(i.content,{[i.contentOpen]:a,[i.contentTop]:c==="top",[i.contentBottom]:c==="bottom"}),children:e})]})})};function nm({as:t,children:e,onClick:o,...n}){let s=t||"button",r=v("Dropdown",ii),{setIsOpen:i}=om(),a=l=>{i(!1),o(l),l.stopPropagation()};return(0,Ot.jsx)(s,{type:"button",className:r.item,onClick:a,...n,children:e})}jl.Item=nm;var ai=jl;var li=require("react/jsx-runtime"),Vl=t=>(0,li.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...t,children:(0,li.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 Dt={};W(Dt,{enUS:()=>sm,nlNL:()=>rm});var sm={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"}]},rm={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 ws=require("react/jsx-runtime"),im="%0d%0a%0d%0a%0d%0a",am=(t,e)=>{let o=[`Suggestie: ${encodeURIComponent(e)}`,"Beschrijf je feedback:"];return`mailto:${t.join(",")}?subject=Suggestie feedback&body=${o.join(im)}`},lm=({suggestion:t,onFeedback:e})=>{let o=T(Dt),n=C("suggestionFeedbackEmailAddresses");return!n||n.length===0?null:(0,ws.jsx)(ai,{trigger:(0,ws.jsx)(Vl,{"data-testid":"feedback-dropdown-trigger"}),children:(0,ws.jsx)(ai.Item,{as:"a",href:am(n,t),onClick:e,children:o("giveFeedback")})})},Ts=lm;var ql=require("interweave");var de=require("react/jsx-runtime");function ci({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onFeedback:s,onSourceClick:r,index:i,description:a,sources:l,styles:c,...p}){let{selected:d,setSelected:u,onChangeOpen:g}=mt(),m=v("CommandPalette",ae);function f(h){n(h),t&&g(!1)}return(0,de.jsxs)("div",{className:(0,$o.default)(m.listItem,d===i&&m.listItemSelected),children:[(0,de.jsx)("button",{onMouseEnter:()=>u(i),type:"button",className:(0,$o.default)("command-palette-list-item",m.listItemAction,m.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:f,...p,children:(0,de.jsxs)("div",{className:m.listItemContent,children:[typeof o=="string"?(0,de.jsx)("p",{className:(0,$o.default)(m.listItemText,m.truncate,c==null?void 0:c.title),children:o}):o,a&&(0,de.jsx)(ql.Interweave,{tagName:"p",allowList:[],content:xs(a),className:(0,$o.default)(m.listItemDescription,c==null?void 0:c.description,e?m.lineClamp:m.truncate)})]})}),s&&d===i&&(0,de.jsx)("div",{className:m.listItemActions,children:(0,de.jsx)(Ts,{suggestion:String(o),onFeedback:s})}),l&&(0,de.jsxs)("div",{className:m.sources,children:[(0,de.jsx)("span",{className:m.sourcesTitle,children:"Sources"}),l.map(h=>h.url?(0,de.jsx)("a",{className:m.source,href:h.url,target:"_blank",title:h.url,rel:"noopener noreferrer",onClick:()=>r&&r(h),children:h.name},h.url):(0,de.jsx)("span",{className:m.source,children:h.name},h.name))]})]})}var Ht=require("react/jsx-runtime");function pi({children:t,title:e,id:o,onDismiss:n}){let s=T(Nt),r=v("CommandPalette",ae),{page:i}=mt();return i!==o?null:(0,Ht.jsxs)("div",{className:r.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,Ht.jsxs)("div",{className:r.pageNav,children:[(0,Ht.jsxs)("button",{className:r.pageBackButton,type:"button",onClick:n,children:[(0,Ht.jsx)(ms,{}),s("back")]}),e&&(0,Ht.jsx)("h3",{className:r.pageTitle,children:e})]}),t]})}var ft=require("react");var Es=()=>/Mac/i.test(navigator.platform);var Rs=require("@reduxjs/toolkit");var cm={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},E=cm;var go=require("@reduxjs/toolkit");function pm(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function M(t){return Array.isArray(t)?t.map(M):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[pm(o)]:M(t[o])}),{}):t}function di(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,[di(o)]:q(t[o])}),{}):t}var dm={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Qo=t=>{var e,o,n;return{timezone:((e=t.info.visitorInfo)==null?void 0:e.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((o=t.info.agentInfo)==null?void 0:o.agentNickname)||"",visitorName:((n=t.info.visitorInfo)==null?void 0:n.visitorName)||""}},Xo=(0,go.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?M(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),M(n))}),ui=(0,go.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}),gi=(0,go.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),Wl=t=>t.info.agentInfo,Gl=(0,go.createSlice)({name:"info",initialState:dm,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Xo.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Xo.rejected,e=>{e.fetchState="error"}).addCase(Xo.fulfilled,(e,o)=>{e.fetchState="done",e.agentInfo={...e.agentInfo,...o.meta.arg,agentId:o.payload.externalId||o.meta.arg.agentId||"",agentNickname:o.payload.nickname||o.meta.arg.agentNickname||""}}).addCase(ui.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(gi.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(N,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:$l}=Gl.actions,Xl=Gl.reducer;var ks={list:[],fetchState:"idle",isOpen:!1,page:"search"},Ql=t=>t.search.isOpen,Zl=t=>t.search.page,Jl=t=>t.search.list;function Yl(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Bt=(0,Rs.createAsyncThunk)("search/getAll",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r}=await o.search({profile:s,query:t.query,filters:{type:t.type},params:Qo(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),ec=(0,Rs.createSlice)({name:"search",initialState:ks,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=ks.fetchState,t.list=ks.list}},extraReducers:t=>{t.addCase(Bt.pending,e=>{e.fetchState="loading"}).addCase(Bt.rejected,(e,o)=>{e.fetchState="error",E.error(o.error)}).addCase(Bt.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(N,()=>ks)}}),{resetSearch:Is,setIsOpen:Y,setPage:ee}=ec.actions,tc=ec.reducer;var um=/(https?:\/\/[^\s]+)/,Ps=t=>t.split(" ").find(e=>um.test(e));var mi=k(require("classnames"));var As=require("react/jsx-runtime"),gm=({onClick:t,shortKeys:e,children:o,...n})=>{let s=v("CommandPalette",ae);return(0,As.jsxs)("button",{type:"button",...n,onClick:t,className:(0,mi.default)(s.actionButton,n.className),children:[o,e&&e.map(r=>(0,As.jsx)("span",{className:(0,mi.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},mo=gm;var Ge=require("react/jsx-runtime"),mm=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=v("CommandPalette",ae),a=T(Nt),{selected:l,setSelected:c}=mt(),p=r[l],d=p&&typeof p.text=="string"&&Ps(p.text),u=(0,ft.useRef)(null);function g(x){if(!u.current)return;let b=u.current.querySelectorAll(".command-palette-list-item"),_=0,A=0;x==="down"?(b.forEach((se,L)=>{L===l&&(_=L)}),A=_===b.length-1?0:_+1):x==="up"?(b.forEach((se,L)=>{L===l&&(_=L)}),A=_?_-1:b.length-1):c(0);let O=b[A];O&&typeof A=="number"&&(c(A),O.scrollIntoView&&O.scrollIntoView({behavior:"smooth",block:A?"center":"end"}))}function m(){if(!u.current)return;let x=u.current.querySelectorAll(".command-palette-list-item"),b=0;x.forEach((A,O)=>{O===l&&(b=O)});let _=x[b];_&&_.click()}let f=()=>{d&&window.open(d,"_blank")},h=()=>{p&&n(p,l)},w=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},y=(0,ft.useCallback)(x=>{if(x.key==="Enter"&&x.altKey&&d){f();return}if(x.key==="Enter"&&x.shiftKey){w();return}if(x.key==="ArrowDown"){x.preventDefault(),x.stopPropagation(),g("down");return}if(x.key==="ArrowUp"){x.preventDefault(),x.stopPropagation(),g("up");return}x.key==="Enter"&&l!==-1&&(x.preventDefault(),x.stopPropagation(),m())},[l]);return(0,ft.useEffect)(()=>(window.addEventListener("keyup",y),()=>{window.removeEventListener("keyup",y)}),[y]),(0,Ge.jsxs)("div",{className:i.actions,children:[(0,Ge.jsx)("div",{className:i.actionsWrapper,ref:u,children:t}),(0,Ge.jsxs)("div",{className:i.actionsBar,children:[d&&(0,Ge.jsx)(mo,{onClick:f,shortKeys:[Es()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,Ge.jsxs)(ft.Fragment,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&(0,Ge.jsx)(mo,{onClick:w,shortKeys:[8679,8629],children:o}),(0,Ge.jsx)(mo,{onClick:h,shortKeys:[8629],children:e})]})]})]})},nc=mm;var sc=require("react");var Zo=require("react/jsx-runtime"),fo=()=>(0,Zo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Zo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Zo.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 Ie=require("react/jsx-runtime");function fm({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=v("CommandPalette",ae);return(0,Ie.jsxs)("div",{className:l.search,children:[(0,Ie.jsx)("div",{className:l.searchIcon,children:(0,Ie.jsx)(fo,{})}),(0,Ie.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Ie.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,Ie.jsx)("div",{className:l.selectWrapper,children:(0,Ie.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,Ie.jsx)("option",{children:n}),s.map(c=>(0,Ie.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var rc=(0,sc.forwardRef)(fm);var Jo=require("react/jsx-runtime");function Ft({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:o="search",page:n,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:l,types:c,children:p,isOpen:d,search:u}){let[g,m]=(0,ho.useState)(0),f=(0,ho.useRef)(null),h=()=>{s&&s(o),i(void 0),r(""),a(!1)},w=()=>{var y;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(y=f.current)==null||y.focus();return}if(u.length>0){r("");return}a(!1)};return(0,ho.useEffect)(()=>{m(0)},[u,n]),(0,Jo.jsx)(ro,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:w,onClose:h,children:(0,Jo.jsxs)(Fl,{selected:g,setSelected:m,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&(0,Jo.jsx)(rc,{ref:f,onChange:r,onChangeType:i,placeholder:t,value:u,selectedType:l,types:c,typePlaceholder:e}),p]})})}Ft.Page=pi;Ft.List=ri;Ft.Image=Ol;Ft.ListItem=ci;Ft.ActionsBar=nc;Ft.Button=mo;var I=Ft;var J=require("react/jsx-runtime"),hm=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=v("EditSuggestionForm",nl),l=(0,Ls.useDispatch)(),c=T(Br),p=(0,Ls.useSelector)(m=>m.overlayInput.text);(0,fi.useEffect)(()=>{t&&(l(ie.actions.reset()),l(ie.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(ie.actions.commitSuggestion()))},[t]);let d=m=>{m.preventDefault(),u(p)},u=m=>{l(Zn(m)),e(m)},g=m=>f=>{p!==i?window.confirm(c("warning"))&&m(f):m(f)};return(0,fi.useEffect)(()=>{n&&n(p!==i)},[n,t,p]),(0,J.jsxs)("div",{className:a.root,children:[(0,J.jsxs)("div",{className:a.content,children:[t.title&&(0,J.jsx)("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&(0,J.jsx)(Pr,{labels:t.searchKeywords}),(0,J.jsx)(Ml,{onUse:u,value:xs(p)})]}),(0,J.jsxs)("form",{className:a.actions,onSubmit:d,children:[(0,J.jsxs)("div",{children:[(0,J.jsx)("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&g(r),children:(0,J.jsx)(ms,{})}),(0,J.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&g(s),children:(0,J.jsx)(gl,{})})]}),(0,J.jsxs)("div",{className:a.primaryButtons,children:[(0,J.jsx)(I.Button,{onClick:g(o),shortKeys:["esc"],children:c("dismiss")}),(0,J.jsx)(I.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},Ms=hm;var Kt=require("@reduxjs/toolkit");var ym=["{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}"],vm=new RegExp(ym.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function ic(t,e){let o=t.split(vm),n=0,s=[];for(let r=0;r<o.length;r++){let i=o[r];if(s.push(i),r===o.length-1)break;if(e.indexOf(i)===-1)return t;let a=o[r+1],l=r===o.length-2;n+=i.length;let c=n;if(l){let d=a.charAt(0),u=0;do c=d?e.indexOf(d,c+1):-1,u+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&u>2)return t}else c=a&&a!==""?e.indexOf(a,n):-1;let p=c===-1?e.slice(n):e.slice(n,c);s.push(p),n=c}return s.join("")}function ac(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var cc={suggestions:[],fetchState:"idle",isInitialRequest:null},lc={default:cc},Ns=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},pc=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")},ht=t=>t.textSuggestions,dc=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},Os=(0,Kt.createAction)("textSuggestions/refresh"),Pe=(0,Kt.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=no(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Qo(n),t);if(t==="default"){let p=i?l.filter(dc(a)):l;e.dispatch(He(p.slice(0,r)))}return l}),Yo=(0,Kt.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,{...Qo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(dc(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?ic(p.text,t):p.text}))),l=ac(l,r),e.dispatch(He(l)),l}),uc=(0,Kt.createSlice)({name:"textSuggestions",initialState:lc,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(Pe.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||cc;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(Pe.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(Pe.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Yo.pending,e=>{e.default.fetchState="loading"}).addCase(Yo.rejected,e=>{e.default.fetchState="error"}).addCase(Yo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(N,()=>lc)}}),{setTextSuggestions:gc,setSuggestionState:mc}=uc.actions,fc=uc.reducer;var yc=require("@reduxjs/toolkit");var hc={contentType:null,suggestion:null},vc=t=>t.activeSuggestion.suggestion,Sc=t=>t.activeSuggestion.contentType,_c=(0,yc.createSlice)({name:"activeSuggestion",initialState:hc,reducers:{setActiveSuggestion(t,e){let{contentType:o,suggestion:n}=e.payload;t.contentType=o,t.suggestion=n},resetActiveSuggestion(t){t.contentType=null,t.suggestion=null}},extraReducers:t=>{t.addCase(N,()=>hc)}}),{setActiveSuggestion:$e,resetActiveSuggestion:hi}=_c.actions,xc=_c.reducer;var yi={};W(yi,{enUS:()=>Sm,nlNL:()=>_m});var Sm={warning:[{type:0,value:"Are you sure you want to discard the message?"}],editContentLabel:[{type:0,value:"Edit and view suggestion"}],overlayLabel:[{type:0,value:"Close dialog"}]},_m={warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}],editContentLabel:[{type:0,value:"Bewerk en bekijk suggestie"}],overlayLabel:[{type:0,value:"Sluit"}]};var bc=require("@reduxjs/toolkit"),xm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Ds=({ui:t})=>t.overlayCollapsed;var Cc=(0,bc.createSlice)({name:"ui",initialState:xm,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputHasFocus(t,e){t.overlayCollapsedUserOverwrite!==!0&&(e.payload===!0&&(t.overlayCollapsed=!1),t.inputHasFocus=e.payload)},setOverlayCollapsed(t,e){e.payload.collapse===!1&&(t.openOverlayWhenTyping=!1),!(e.payload.skipWhenInputFocus&&t.inputHasFocus)&&(t.overlayCollapsed=e.payload.collapse)},setOpenOverlayWhenTyping(t,e){t.openOverlayWhenTyping=e.payload},setOverlayCollapsedUserOverwrite(t,e){t.overlayCollapsedUserOverwrite=e.payload,t.overlayCollapsed=e.payload}}}),{setShowTabHint:en,setInputHasFocus:yo,setOverlayCollapsed:yt,setOpenOverlayWhenTyping:wc,setOverlayCollapsedUserOverwrite:Tc}=Cc.actions,Ec=Cc.reducer;var tn=k(require("react")),Rc=require("react/jsx-runtime"),kc=tn.default.createContext(null),Ut=({broadcastEvents:t,children:e})=>{let o=tn.default.useMemo(()=>t,[]);return(0,Rc.jsx)(kc.Provider,{value:o,children:e})},xe=()=>{let t=(0,tn.useContext)(kc);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var vo=require("@reduxjs/toolkit");var bm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},ue=t=>t.auth.isLoggedIn,Ic=t=>t.auth.loginFetchState,Pc=t=>t.auth.verifyFetchState,Ac=t=>t.auth.showLoginOverlay,Xe=(0,vo.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),Lc=(0,vo.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),on=(0,vo.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),Mc=(0,vo.createSlice)({name:"auth",initialState:bm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(Xe.pending,e=>{e.loginFetchState="loading"}),t.addCase(Xe.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(Xe.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(on.pending,e=>{e.verifyFetchState="loading"}),t.addCase(on.rejected,e=>{e.verifyFetchState="error"}),t.addCase(on.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:So,setShowLoginOverlay:Nc}=Mc.actions,Oc=Mc.reducer;var vi="SetActiveSuggestion",_o="ShowLoginOverlay",nn="UserLoggedIn",Cm="UserLoggedOut",Qe="ApplySuggestion",Si="ApplyImageSuggestion",wm="ShowCommandPalette",Tm=t=>({[vi]:e=>{t.dispatch(mc(e.state)),t.dispatch($e({contentType:e.contentType,suggestion:e.suggestion}))},[wm]:e=>{t.dispatch(Y(e.isOpen)),e.page&&t.dispatch(ee(e.page))},[_o]:e=>{t.dispatch(Nc(e))},[nn]:()=>{t.dispatch(Xe())},[Cm]:()=>{t.dispatch(Xe())},[Si]:e=>{t.dispatch(Yn({suggestion:e.suggestion}))},[Qe]:e=>{t.dispatch(ke({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(je())}}),Dc=Tm;var _i=require("react/jsx-runtime"),Em=()=>{var m;let[t,e]=(0,Hc.useState)(!1),o=(0,xo.useSelector)(vc),n=(0,xo.useSelector)(Sc),s=(0,xo.useSelector)(ht),r=(0,xo.useDispatch)(),i=xe(),a=T(yi),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(hi()),r(yo(!0)),r(ie.actions.reset())},p=(f,h)=>{r(hi()),r(yo(!0)),i.send(Qe,{text:f,suggestion:{...h,source:`${h.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let d=(m=s[n])==null?void 0:m.suggestions.indexOf(o),u=d===0||d===null?void 0:()=>r($e({contentType:n,suggestion:s[n].suggestions[d-1]})),g=d===s[n].suggestions.length-1||d===null?void 0:()=>r($e({contentType:n,suggestion:s[n].suggestions[d+1]}));return(0,_i.jsx)(ro,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,_i.jsx)(Ms,{onTouched:e,onDismiss:c,onUse:f=>p(f,o),suggestion:o,onNext:g,onPrevious:u})})},Bc=Em;var bi=require("react-redux");var Hs=k(require("classnames")),Ae=require("react"),Bs=require("react-redux");var Kc=k(require("classnames"));var Fc={root:"_root_1ukx5_1"};var Uc=require("react/jsx-runtime"),km=({className:t,value:e,...o})=>{let n=v("TextInput",Fc);return(0,Uc.jsx)("input",{className:(0,Kc.default)(t,n.root),type:"text",value:e,...o})},sn=km;var xi={};W(xi,{enUS:()=>Rm,nlNL:()=>Im});var Rm={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"}]},Im={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 zc={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 Pm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Am=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=T(xi),i=v("LoginTokenDialog",zc),a=(0,Bs.useSelector)(Pc),l=(0,Bs.useDispatch)(),c=C("productName"),[p,d]=(0,Ae.useState)(t||""),[u,g]=(0,Ae.useState)(0),[m,f]=(0,Ae.useState)(""),h=(0,Ae.useCallback)(async b=>{b.preventDefault(),l(Lc({email:p})),g(1)},[o,p]),w=()=>{f(""),g(0)},y=(0,Ae.useCallback)(async b=>{b.preventDefault();let _=Pm(b.target.elements.token.value);if(!_){f(r("verifyCodeError",{login:x}));return}l(on({token:_}))},[o]),x=(0,Ae.useMemo)(()=>b=>(0,K.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:b},"back-button"),[]);return(0,Ae.useEffect)(()=>{a==="error"&&f(r("verifyCodeError",{login:x})),a==="done"&&n()},[a]),(0,K.jsx)(ro,{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})}),u===0&&(0,K.jsxs)("form",{onSubmit:h,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)(sn,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:b=>d(b.target.value)}),(0,K.jsx)("div",{className:i.actions,children:(0,K.jsx)("button",{type:"submit",className:(0,Hs.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),u===1&&(0,K.jsxs)("form",{onSubmit:y,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,K.jsx)(sn,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),m&&(0,K.jsx)("div",{className:i.errorMessage,children:m}),(0,K.jsxs)("div",{className:i.actions,children:[(0,K.jsx)("button",{type:"button",className:(0,Hs.default)(i.button),onClick:w,children:r("back")}),(0,K.jsx)("button",{type:"submit",className:(0,Hs.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},jc=Am;var qc=require("react/jsx-runtime"),Lm=()=>{let t=(0,bi.useSelector)(Ac),e=(0,bi.useSelector)(Wl),o=C("adminUrl"),n=xe(),s=()=>n.send(_o,!1),r=()=>{n.send(_o,!1),n.send(nn)};return(0,qc.jsx)(jc,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},Vc=Lm;var Sp=k(require("lodash.debounce")),te=require("react"),Ye=require("react-redux");var Fs=require("@reduxjs/toolkit");var Mm={data:null,fetchState:"idle"},Wc=t=>t.contentTypes.data,rn=(0,Fs.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Nm=(0,Fs.createSlice)({name:"contentTypes",initialState:Mm,reducers:{},extraReducers:t=>{t.addCase(rn.pending,e=>{e.fetchState="loading"}).addCase(rn.rejected,e=>{e.fetchState="error"}).addCase(rn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Gc=Nm.reducer;function an(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}var $c=require("react");function Xc(t,e){(0,$c.useEffect)(()=>{let o=n=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?n.metaKey:n.ctrlKey)&&n.key===t&&(n.preventDefault(),n.stopPropagation(),e())};return document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o)}},[])}var ln=require("react"),zs=require("react-redux");var Ks=require("@reduxjs/toolkit");var Qc={data:null,fetchState:"idle"},Us=t=>{var r;let e=[],{visitorName:o}=t.info.visitorInfo??{},{agentName:n,agentNickname:s}=t.info.agentInfo??{};return n&&n!==o&&e.push(n),s&&s!==o&&e.push(s),((r=t.entities.data)==null?void 0:r.filter(i=>!e.includes(i.text)))??null},Le=(0,Ks.createAsyncThunk)("entities/getEntities",async(t,e)=>{let{deepdeskAPI:o,dynamicThunkObject:n}=e.extra;if(!n.conversationQuery)return Promise.resolve([]);let s=n.conversationQuery,r=await s();return r.length===0?Promise.resolve([]):o.getEntities(r)}),Om=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Dm=(0,Ks.createSlice)({name:"entities",initialState:Qc,reducers:{},extraReducers:t=>{t.addCase(Le.pending,e=>{e.fetchState="loading"}).addCase(Le.rejected,e=>{e.fetchState="error"}).addCase(Le.fulfilled,(e,o)=>{e.fetchState="done",e.data=Om(e.data?[...e.data,...o.payload]:o.payload)}).addCase(N,()=>Qc)}}),Zc=Dm.reducer;var Ci={};W(Ci,{enUS:()=>Hm,nlNL:()=>Bm});var Hm={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Bm={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Jc={root:"_root_17kae_1",empty:"_empty_17kae_5"};var zt=require("react/jsx-runtime"),Fm=({onCopy:t,onUse:e})=>{let o=(0,ln.useRef)(null),n=v("EntitiesList",Jc),s=T(Ci),r=(0,zs.useSelector)(Us),i=(0,zs.useDispatch)();return(0,ln.useEffect)(()=>{i(Le())},[]),(0,ln.useEffect)(()=>{o.current&&o.current.focus()},[o]),(0,zt.jsxs)("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&(0,zt.jsx)(I.ActionsBar,{primaryLabel:s("copy"),secondaryLabel:s("use"),onPrimary:(a,l)=>t(r[l]),onSecondary:(a,l)=>e(r[l]),list:r.map(a=>({text:a.text,type:a.label,primaryAction:"copy",secondaryAction:"use"})),children:(0,zt.jsx)(I.List,{children:r.map((a,l)=>(0,zt.jsx)(I.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&(0,zt.jsx)("p",{className:n.empty,children:s("noResults")})]})},Yc=Fm;var Me=require("react"),cn=require("react-redux");var js=require("@reduxjs/toolkit");var ep={data:null,fetchState:"idle"},tp=t=>t.summary.data,op=t=>t.summary.fetchState==="error",Ze=(0,js.createAsyncThunk)("summary/getSummary",async(t,e)=>{let o=e.getState().profile.data;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:n,dynamicThunkObject:s}=e.extra;if(!s.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let r=s.conversationQuery,i=await r();if(i.length===0)return Promise.reject(new Error("No messages are included"));let a=await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return a?{summary:a}:Promise.reject(new Error("Summary is not provided"))}),Km=(0,js.createSlice)({name:"summary",initialState:ep,reducers:{},extraReducers:t=>{t.addCase(Ze.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(Ze.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(Ze.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(N,()=>ep)}}),np=Km.reducer;var wi={};W(wi,{enUS:()=>Um,nlNL:()=>zm});var Um={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."}]},zm={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 sp={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 Je=require("react/jsx-runtime"),jm=({onCopy:t})=>{let e=(0,Me.useRef)(null),o=v("SummaryForm",sp),[n,s]=(0,Me.useState)(""),r=T(wi),i=(0,cn.useSelector)(tp),a=(0,cn.useSelector)(op),l=(0,cn.useDispatch)(),c=()=>{l(X({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let d=document.getSelection();d&&l(X({name:"summary copied to clipboard",data:{originalText:i,finalText:d==null?void 0:d.toString()},options:{includeConversationData:!0}}))};return(0,Me.useEffect)(()=>{l(Ze())},[]),(0,Me.useEffect)(()=>{s(i||"")},[i]),(0,Me.useEffect)(()=>{e.current&&i&&e.current.focus()},[e,i]),(0,Me.useEffect)(()=>{let d=u=>{u.key==="Enter"&&u.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[n]),(0,Je.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,Je.jsx)("p",{className:o.error,children:r("error")}):(0,Je.jsxs)(Me.Fragment,{children:[(0,Je.jsx)("div",{className:o.main,children:(0,Je.jsx)("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:d=>s(d.target.value)})}),(0,Je.jsx)("div",{className:o.actions,children:(0,Je.jsx)(I.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},rp=jm;var pn={};W(pn,{enUS:()=>Vm,nlNL:()=>qm});var Vm={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},qm={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 vt=k(require("react")),gn=require("react-redux");var Ti={};W(Ti,{enUS:()=>Wm,nlNL:()=>Gm});var Wm={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"}]},Gm={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 ip={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 Co=require("@reduxjs/toolkit");var Vs=require("@reduxjs/toolkit");var $m={data:null,fetchState:"idle"},ap=t=>{var e;return(e=t.knowledgeAssistant)==null?void 0:e.data},dn=(0,Vs.createAsyncThunk)("knowledgeAssistant/getKnoeledgeAssistant",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}),Xm=(0,Vs.createSlice)({name:"knowledgeAssistant",initialState:$m,reducers:{},extraReducers:t=>{t.addCase(dn.pending,e=>{e.fetchState="loading"}).addCase(dn.rejected,e=>{e.fetchState="error"}).addCase(dn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),lp=Xm.reducer;var Ei={data:[],fetchState:"idle"},cp=t=>{var e;return(e=t.answer)==null?void 0:e.data},pp=t=>t.answer.fetchState,wo=(0,Co.createAction)("answer/resetKnowledgeSearch"),bo=(0,Co.createAsyncThunk)("answer/getAnswer",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=ap(e.getState());if(!s)throw new Error("KnowledgeAssistant is not defined");let r=await o.knowledgeAssist({promptInstruction:s.prompt,question:t},n,s.code);return{question:t,answer:r}}),Qm=(0,Co.createSlice)({name:"answer",initialState:Ei,reducers:{},extraReducers:t=>{t.addCase(bo.pending,e=>{e.fetchState="loading"}).addCase(bo.rejected,e=>{e.fetchState="error"}).addCase(bo.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(N,()=>Ei).addCase(wo,()=>Ei)}}),dp=Qm.reducer;var un=require("react/jsx-runtime"),up=()=>(0,un.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,un.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,un.jsx)("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});var le=require("react/jsx-runtime"),Zm=({onUse:t,onResetQuestion:e,question:o})=>{let[n,s]=vt.default.useState(""),{setSelected:r}=mt(),i=(0,vt.useRef)(null),a=v("EntitiesList",ip),l=T(Ti),c=(0,gn.useDispatch)(),p=(0,gn.useSelector)(cp),d=(0,gn.useSelector)(pp),u=async m=>{m.preventDefault(),m.stopPropagation(),n!==""&&c(bo(n))},g=(m,f)=>{c(X({name:"knowledge assist source viewed",data:{question:f,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return(0,vt.useEffect)(()=>{var m;o&&d==="idle"?c(bo(o)):(m=i.current)==null||m.focus()},[i,d]),(0,vt.useEffect)(()=>{d==="done"&&(c(X({name:"knowledge assist question answered",data:{question:n||o,sources:p[p.length-1].answer.sources,answer:p[p.length-1].answer.answer,isFollowUpQuestion:p.length>1},options:{includeConversationData:!0}})),r(p.length-1),s(""))},[d,p]),(0,vt.useEffect)(()=>{i.current&&i.current.scrollIntoView({behavior:"smooth"})},[i,p]),(0,le.jsxs)("div",{className:a.root,children:[p.length>0&&(0,le.jsx)("div",{className:a.alignRight,children:(0,le.jsx)(I.Button,{onClick:e,children:l("reset")})}),(0,le.jsxs)(I.ActionsBar,{list:p.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:l("use"),onPrimary:m=>t(m.text),children:[p.map(({question:m,answer:f},h)=>(0,le.jsx)(I.List,{children:(0,le.jsx)(I.ListItem,{"data-testid":"knowledge-search-answer",index:h,description:f.answer,closeOnSelect:!0,onClick:()=>t(f.answer),onSourceClick:w=>g(w,m),sources:f.sources,styles:{title:a.question,description:a.answer},children:m})},`${f.answer}_${h}`)),d==="loading"&&(0,le.jsx)("p",{className:a.status,children:l("loading")}),d==="error"&&(0,le.jsx)("p",{className:a.status,children:l("error")}),(0,le.jsxs)("form",{className:a.form,onSubmit:u,children:[(0,le.jsx)("input",{ref:i,placeholder:l("anotherQuestion"),className:a.input,type:"text",value:n,onFocus:()=>{r(-1)},onChange:m=>{r(-1),s(m.target.value)}}),(0,le.jsx)("button",{type:"submit",className:a.submit,children:(0,le.jsx)(up,{})})]})]})]})},gp=Zm;var qs=require("@reduxjs/toolkit");var Jm={data:null,fetchState:"idle"},St=t=>t.profile.data,Ws=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],mn=(0,qs.createAsyncThunk)("profile/getProfile",async(t,e)=>{var r;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");return((r=n.profile.data)==null?void 0:r.code)===s.profileCode?n.profile.data:o.getProfile(s.profileCode)}),Ym=(0,qs.createSlice)({name:"profile",initialState:Jm,reducers:{},extraReducers:t=>{t.addCase(mn.pending,e=>{e.fetchState="loading"}).addCase(mn.rejected,e=>{e.fetchState="error"}).addCase(mn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),mp=Ym.reducer;var fp=require("react");var hp=require("react-redux");var ki=require("react-redux");var jt=require("react/jsx-runtime"),ef=({commands:t,onClick:e,onEdit:o})=>{var p,d,u;let n=(0,hp.useDispatch)(),s=T(pn),r=(0,ki.useSelector)(St),i=(0,ki.useSelector)(ht),a=((u=(d=(p=r==null?void 0:r.uiConfig)==null?void 0:p.search)==null?void 0:d.initialTypes)==null?void 0:u.filter(({isActive:g})=>g))||[],l=0,c=a.map(({type:g})=>{var m;return(m=i[g])==null?void 0:m.suggestions.map(f=>({text:f.text||f.url||f.message,type:g}))}).flat(1);return(0,fp.useEffect)(()=>{a.forEach(({type:g})=>{(!i[g]||i[g].suggestions.length===0)&&n(Pe(g))})},[]),(0,jt.jsxs)(I.ActionsBar,{list:[...t.map(g=>({text:g.label,type:"command"})),...c],primaryLabel:s("use"),secondaryLabel:s("preview"),onPrimary:({text:g},m)=>e(g,c[m]),onSecondary:(g,m)=>{o(c[m],i[c[m].type].suggestions)},children:[t.length>0&&(0,jt.jsx)(I.List,{heading:s("commands"),children:t.map((g,m)=>(0,jt.jsx)(I.ListItem,{index:m,closeOnSelect:!1,onClick:g.onClick,children:g.label},g.label))}),a.map(({type:g,title:m})=>{var f;return(0,jt.jsx)(I.List,{heading:m,orientation:"vertical",children:(f=i[g])==null?void 0:f.suggestions.map(h=>(l++,(0,jt.jsx)(I.ListItem,{index:l+t.length-1,closeOnSelect:!1,description:h.text,onClick:()=>e(h.text,h),"data-testid":"search-overlay-suggestion",children:h.title},`${h.id}-${h.text}`)))},g)})]})},yp=ef;var z=require("react/jsx-runtime"),tf=200,of=5,nf=4,sf=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),vp=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),rf=()=>{let t=(0,Ye.useDispatch)(),e=xe(),o=T(pn),[n,s]=(0,te.useState)(!1),[r,i]=(0,te.useState)(""),a=(0,Ye.useSelector)(Zl),l=(0,Ye.useSelector)(St),[c,p]=(0,te.useState)(null),[d,u]=(0,te.useState)([]),[g,m]=(0,te.useState)(),f=(0,Ye.useSelector)(ue),h=C("showSearch"),w=C("showEntitiesCommand"),y=C("showSummaryCommand"),x=C("showKnowledgeSearch"),b=C("showImageSearch"),_=C("searchTriggerKey"),A=(0,Ye.useSelector)(Wc),O=(0,Ye.useSelector)(Jl),se=(0,Ye.useSelector)(Ql),L=S=>kr(O.filter(H=>H.type===S.toUpperCase()),S),re=[{value:"PERSONAL",label:o("personalSuggestions"),list:L("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:L("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:L("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:L("IMAGE"),listOrientation:"horizontal",shouldShow:b}].filter(S=>S.shouldShow),P=[{label:o("entitiesClipboard"),onClick:()=>t(ee("entities")),shouldShow:w&&vp(o("entitiesClipboard"),r)},{label:o("summaryClipboard"),onClick:()=>t(ee("summary")),shouldShow:y&&vp(o("summaryClipboard"),r)},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(ee("knowledgeAssist")),shouldShow:x}].filter(S=>S.shouldShow),U=(A==null?void 0:A.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:L(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],Qt=(0,te.useCallback)((0,Sp.default)((S,H)=>{t(Bt({query:S,type:H,tags:["search-overlay"]}))},tf),[]),Mo=sf([...U,...re]),No=(0,te.useCallback)((S,H)=>{t(ee("edit")),p({...S,searchTerm:void 0}),u(H)},[t,c,U]),Rn=(0,te.useCallback)((S,H)=>{switch(H.type){case"IMAGE":e.send(Si,{suggestion:H});break;default:e.send(Qe,{text:S,suggestion:H})}t(Y(!1))},[t]),Bu=S=>{an(S.text),t(X({name:"entity copied",data:{entity:S,type:"copy"}})),t(Y(!1))},Fu=(0,te.useCallback)(S=>{t(X({name:"suggestion feedback",data:{text:S.text,source:"search",context:r},options:{includeConversationData:!0}}))},[r]),Ku=S=>{e.send(Qe,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(X({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(ee("search")),t(wo()),t(Y(!1))},Uu=S=>{an(S),t(Y(!1))},zu=S=>{e.send(Qe,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(Y(!1))},ju=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),Vu=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function kr(S,H){return S.slice(0,g?10:H.toLowerCase()==="image"?nf:of)}function pa(S,H,Oe){return H.reduce((In,Pn)=>Oe&&g===Oe?Pn.length+In:kr(Pn,Oe).length+In,S)}function Zt(S){return H=>{n?window.confirm(o("warning"))&&(S(H),s(!1)):S(H)}}return(0,te.useEffect)(()=>{r?Qt(r,g):t(Is())},[r,g]),(0,te.useEffect)(()=>{a==="search"&&t(wo())},[a]),(0,te.useEffect)(()=>{f&&t(rn())},[f]),Xc(_,()=>t(Y(!0))),!h||!l?null:(0,z.jsxs)(I,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Zt(S=>t(Y(S))),onChangeType:S=>m(S),onChangePage:Zt(S=>t(ee(S))),selectedType:g,search:r,page:a,isOpen:se,types:[...U,...re],children:[(0,z.jsxs)(I.Page,{id:"search",children:[r.length===0&&(0,z.jsx)(yp,{commands:P,onClick:Rn,onEdit:No}),r.length>0&&(0,z.jsxs)(I.ActionsBar,{list:[...P.map(S=>({text:S.label,type:"command"})),...Mo.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},H)=>Rn(S,Mo[H]),onSecondary:(S,H)=>{let Oe=Mo[H-P.length];!Oe||!Oe.type||No(Oe,L(Oe.type))},children:[P.length>0&&(0,z.jsx)(I.List,{heading:o("commands"),children:P.map((S,H)=>(0,z.jsx)(I.ListItem,{index:pa(H,[],"commands"),closeOnSelect:!1,onClick:S.onClick,children:S.label},S.label))}),[...U,...re].map(({value:S,label:H,list:Oe,lineClamp:In,listOrientation:Pn},qu)=>(0,z.jsx)(I.List,{heading:H,orientation:Pn==="horizontal"?"horizontal":"vertical",children:kr(Oe,S).map((fe,Wu)=>(0,z.jsx)(I.ListItem,{index:pa(P.length+Wu,[...U,...re].slice(0,qu).map(({list:Gu})=>Gu),S),closeOnSelect:!1,lineClamp:In,onClick:()=>Rn(fe.text,fe),description:S!=="IMAGE"?fe.title&&fe.text:void 0,onFeedback:S!=="IMAGE"?()=>Fu(fe):void 0,children:S==="IMAGE"?(0,z.jsx)(I.Image,{title:fe.title||fe.text,src:fe.image}):fe.title||fe.text},`${fe.id}-${fe.text}`))},S))]})]}),(0,z.jsx)(I.Page,{id:"edit",onDismiss:Zt(()=>{t(ee("search")),p(null)}),children:c&&(0,z.jsx)(Ms,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(ee("search")),p(null),u([])},onNext:Vu,onPrevious:ju,onUse:S=>{t(ee("search")),Rn(S,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(Y(!1)),u([]),p(null)}})}),(0,z.jsx)(I.Page,{id:"entities",title:o("entitiesTitle"),onDismiss:Zt(()=>{t(ee("search"))}),children:(0,z.jsx)(Yc,{onUse:zu,onCopy:Bu})}),(0,z.jsx)(I.Page,{id:"summary",title:o("summaryTitle"),onDismiss:Zt(()=>{t(ee("search"))}),children:(0,z.jsx)(rp,{onCopy:Uu})}),(0,z.jsx)(I.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),onDismiss:Zt(()=>{t(wo()),t(ee("search"))}),children:(0,z.jsx)(gp,{question:r,onUse:Ku,onResetQuestion:()=>{t(wo()),i("")}})})]})},_p=rf;var To=require("react/jsx-runtime"),af=()=>{let t=C("showSearch"),e=C("isEmbedded");return(0,To.jsxs)(xp.Fragment,{children:[t&&(0,To.jsx)(_p,{}),(0,To.jsx)(Bc,{}),e&&(0,To.jsx)(Vc,{})]})},bp=af;var Qs=require("react"),et=require("react-redux");function Eo(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 $s=require("react");var Ep=require("interweave"),ko=require("react"),Gs=require("react-redux");var Cp=require("react");function wp(t,e,o){(0,Cp.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var Tp={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};var Vt=require("react/jsx-runtime"),cf=["search","personal-collection-search","search-autocomplete"];function pf(t,e,o,n={}){let s="";return cf.includes(e)?s=Pl(ti(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=ti(t,o,n),n.placeholders===!0&&(s=Al(s)),s}var df=()=>{},uf=({index:t,selected:e,suggestion:o,onFeedback:n})=>{let s=C("inlineSuggestions"),r=(0,Gs.useSelector)(no),i=(0,Gs.useDispatch)(),a=v("TextSuggestion",Tp),l=(0,ko.useRef)(null);(0,ko.useEffect)(()=>{let p=setTimeout(()=>{i($a({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(p)}},[o]),wp(l,"click",()=>{i(ut(t)),i(ke({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let c=(0,ko.useMemo)(()=>pf(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,Vt.jsxs)("div",{className:a.root,onMouseEnter:()=>i(ut(t)),children:[(0,Vt.jsx)(D,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:df,children:(0,Vt.jsx)(Ep.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:c})}),e&&n&&(0,Vt.jsx)("div",{className:a.actions,children:(0,Vt.jsx)(Ts,{onFeedback:()=>n(o),suggestion:o.text})})]})},kp=uf;var Ri=require("react/jsx-runtime"),gf=({onFeedback:t,suggestions:e,selectedIndex:o,reverse:n})=>{let s=(0,$s.useMemo)(()=>{let r=e.map((i,a)=>(0,Ri.jsx)(kp,{index:a,selected:a===o,suggestion:i,onFeedback:t},`${i.text}-${i.source}`));return n?r.reverse():r},[e,o,n]);return(0,Ri.jsx)($s.Fragment,{children:s})},Xs=gf;var Rp={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var fn=require("react/jsx-runtime"),mf=({textSuggestions:t,selectedIndex:e})=>{let o=(0,Qs.useRef)(null),n=v("InlineSuggestionsOverlay",Rp),s=(0,et.useSelector)(Eo),r=(0,et.useDispatch)(),i=(0,et.useSelector)(ue),a=(0,et.useSelector)(oo),l=(0,et.useSelector)(Ds),c=C("showTextSuggestions");return co(()=>{r(yt({collapse:!0,skipWhenInputFocus:!0}))}),(0,Qs.useEffect)(()=>{let p=o.current;if(!p||!p.parentElement)return;p.parentElement.style.left="0px";let d=p.getBoundingClientRect();p.parentElement.style.left=`${Math.min(window.innerWidth-4-d.right,0)}px`}),l||!s||!c||t.length===0||i!==!0||a===!1?null:(0,fn.jsx)("div",{className:n.root,"data-variant":"inline",children:(0,fn.jsx)("div",{ref:o,className:n.paper,children:(0,fn.jsx)(Se,{children:(0,fn.jsx)(Xs,{suggestions:t,selectedIndex:e})})})})},ff=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Ip=(0,et.connect)(ff)(mf);var Js=k(require("classnames")),Ro=require("react"),Ke=require("react-redux");var Pp=require("react");function Ap(t,e){let[o,n]=(0,Pp.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return E.error(r),e}});return[o,r=>{try{let i=r instanceof Function?r(o):r;n(i),typeof window<"u"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){E.error(i)}}]}var Mp=k(require("classnames")),tt=require("react");var Ii={};W(Ii,{enUS:()=>hf,nlNL:()=>yf});var hf={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"}]}]},yf={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 Lp={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var _t=require("react/jsx-runtime"),Pi=(t,e,o)=>n=>(0,_t.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),vf=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n,onLogIn:s})=>{let r=T(Ii),i=xe(),a=v("Login",Lp),l=C("productName"),c=(0,tt.useCallback)(h=>{h.preventDefault(),n&&n(parseInt(h.target.value,10))},[]),p=(0,tt.useCallback)(h=>{h.preventDefault(),i.send(_o,!0)},[e]),d=(0,tt.useMemo)(()=>h=>(0,_t.jsx)("a",{onClick:y=>{y.preventDefault(),s()},href:e,className:a.anchor,target:"_blank",rel:"noreferrer",children:h},"login"),[e]),u=(0,tt.useCallback)(h=>(0,_t.jsx)("button",{type:"button",className:a.anchorButton,onClick:p,children:h},"prompt"),[p]),{min:g,hour:m,day:f}=(0,tt.useMemo)(()=>({min:Pi(a,60*10,c),hour:Pi(a,60*60,c),day:Pi(a,60*60*12,c)}),[]);return(0,_t.jsxs)("div",{className:(0,Mp.default)(t,a.root),children:[r("loginPlease",{login:o?u:d,productName:l}),n&&(0,_t.jsxs)(tt.Fragment,{children:[(0,_t.jsx)("br",{}),r("snooze",{min:g,hour:m,day:f})]})]})},Zs=vf;var Op=require("react-redux");var Np={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var hn=require("react/jsx-runtime"),Sf=({title:t})=>{let e=v("SearchTrigger",Np),o=(0,Op.useDispatch)();return(0,hn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(Y(!0)),children:[(0,hn.jsx)(fo,{}),(0,hn.jsx)("span",{className:e.text,children:t})]})},Dp=Sf;var Ai={};W(Ai,{enUS:()=>_f,nlNL:()=>xf});var _f={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"}]},xf={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 Hp={root:"_root_onpov_1",isInline:"_isInline_onpov_14",toggleButton:"_toggleButton_onpov_21",toggleButtonWrapper:"_toggleButtonWrapper_onpov_25",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_onpov_32",isCollapsed:"_isCollapsed_onpov_36",collapsible:"_collapsible_onpov_36",hints:"_hints_onpov_44",hintsHidden:"_hintsHidden_onpov_51",triggers:"_triggers_onpov_56",triggersRight:"_triggersRight_onpov_71"};var B=require("react/jsx-runtime"),bf=({textSuggestions:t,selectedIndex:e,onLogIn:o})=>{let n=v("SuggestionsOverlay",Hp),s=T(Ai),r=(0,Ke.useSelector)(Eo),i=ja(),a=(0,Ke.useDispatch)(),l=(0,Ro.useRef)(null),c=C("searchTriggerKey"),p=C("productName"),d=(0,Ke.useSelector)(Ds),u=(0,Ke.useSelector)(ue),g=(0,Ke.useSelector)(oo),[m,f]=(0,Ro.useState)(null),h=C("showSearch"),w=C("showTextSuggestions"),y=C("adminUrl"),x=C("isEmbedded"),[b,_]=Ap("dd-snooze-until-ms",0),A=d||b>Date.now(),O=(0,Ke.useSelector)(U=>U.input.text),se=t.filter(U=>U.source!=="gpt").length,L=()=>{A&&_(0),a(Tc(!A))},re=U=>{a(X({name:"suggestion feedback",data:{text:U.text,source:"overlay",context:O},options:{includeConversationData:!0}}))},P=U=>{let Qt=Date.now()+U*1e3;_(Qt),E.info(`Snooze until: ${new Date(Qt)}`),a(yt({collapse:!0}))};return(0,Ro.useEffect)(()=>{se===0&&f(null)},[t,se]),co(()=>{a(yt({collapse:!0,skipWhenInputFocus:!0}))}),u===null||g===!1?null:u===!1?(0,B.jsxs)("div",{ref:l,className:(0,Js.default)(n.root,{[n.isCollapsed]:A}),children:[!A&&(0,B.jsxs)("div",{className:n.triggers,children:[(0,B.jsx)("div",{style:{flex:1}}),(0,B.jsx)("div",{className:n.triggersRight,children:(0,B.jsx)(It,{className:n.toggleButton,title:s("collapse"),onClick:L,isCollapsed:!1})})]}),(0,B.jsx)("div",{className:n.toggleButtonWrapper,children:(0,B.jsx)(It,{className:n.toggleButton,title:s("open",{productName:p}),onClick:L,isCollapsed:!0})}),(0,B.jsx)("div",{className:n.collapsible,children:(0,B.jsx)(Zs,{loginUrl:y,isEmbedded:x,onLogIn:o,onSnooze:P})})]}):!i||!r?null:(0,B.jsxs)("div",{ref:l,className:(0,Js.default)(n.root,{[n.isCollapsed]:A}),children:[!A&&(0,B.jsxs)("div",{className:n.triggers,children:[(0,B.jsx)("div",{style:{flex:1},children:h&&(0,B.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(s(Es()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>f(null),children:(0,B.jsx)(Dp,{title:s("search")})})}),(0,B.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,B.jsx)("div",{className:(0,Js.default)(!m&&n.hintsHidden,n.hints),children:m}),(0,B.jsx)(It,{className:n.toggleButton,title:s("collapse"),onClick:L,isCollapsed:!1})]})]}),(0,B.jsx)("div",{className:n.toggleButtonWrapper,children:(0,B.jsx)(It,{className:n.toggleButton,title:s("open",{productName:p}),onClick:L,isCollapsed:!0})}),se>0&&w&&(0,B.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,B.jsx)(Se,{children:(0,B.jsx)(Xs,{onFeedback:re,suggestions:t,selectedIndex:e,reverse:!0})})})]})},Cf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Bp=(0,Ke.connect)(Cf)(bf);var Fp=require("react-redux");var yn=require("react/jsx-runtime"),wf=({children:t})=>{let o=C("locale").replace("-","");return(0,yn.jsx)(Wr.Provider,{value:o,children:t})},Tf=({store:t,customStyles:e={},children:o})=>(0,yn.jsx)(Fp.Provider,{store:t,children:(0,yn.jsx)(wf,{children:(0,yn.jsx)(Oo.Provider,{value:e,children:o})})}),qt=Tf;var dr=k(require("classnames")),sd=require("interweave"),st=require("react"),rd=require("react-redux");var Kp=require("react"),Ef=["div","span","mark","strong","b","i","u","em"];function Li(t,e,o=0){var r;let n=t[t.length-1],s=typeof n=="object"&&n!==null?(r=n.props)==null?void 0:r.tagName:void 0;if(s==="br")return t.pop(),[...t,...e,n];if(Ef.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,Kp.cloneElement)(n,{children:Li(i,e,o+1)})]}return[...t,...e]}function xt(t){return t.tagName.toLowerCase()==="textarea"}var Up={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 Qp=k(require("classnames")),Zp=require("interweave"),ar=require("react");function zp(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Ys(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function jp(t){return t!=null}var Ni=k(require("classnames")),be=require("react");var er=require("react"),kf=["bottom","height","left","right","top","width"],Rf=(t={},e={})=>kf.some(o=>t[o]!==e[o]),ot=new Map,Vp,qp=()=>{let t=[],e=[];ot.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Rf(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{ot.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),Vp=window.requestAnimationFrame(qp)};function If(t,e){return{observe(){let o=ot.size===0;if(ot.has(t)){let n=ot.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else ot.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&qp()},unobserve(){let o=ot.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||ot.delete(t),ot.size||cancelAnimationFrame(Vp)}}}}function Mi(t){let[e,o]=(0,er.useState)(null);return(0,er.useLayoutEffect)(()=>{if(!t.current)return;let n=If(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var Io=require("react"),Gp=require("react-dom");var Wp={root:"_root_1jq08_1"};var $p=({children:t})=>{let[e,o]=(0,Io.useState)(null),n=(0,Io.useContext)(Oo);return(0,Io.useLayoutEffect)(()=>{let s=document.createElement("div");return Lt(s),s.classList.add(Wp.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,Gp.createPortal)(t,e):null};var Ue={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 tr=require("react/jsx-runtime"),or=(t=!1)=>{let[e,o]=(0,be.useState)(t),n=(0,be.useCallback)(()=>o(!0),[]),s=(0,be.useCallback)(()=>o(!1),[]),r=(0,be.useCallback)(()=>o(a=>!a),[]),i=(0,be.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function Oi(t,e=null,o=0){if(!t)return{display:"none"};let n=e?t.top-e.top<0||t.top<e.top-o?e.top-o:t.top+t.height>e.top+e.height+o?e.top+e.height+o-t.height:t.top:t.top,s=e?t.left<e.left-o?e.left-o:t.left+t.width>e.left+e.width+o?e.left+e.width+o-t.width:t.left:t.left;return{top:n,left:s,height:t.height,width:t.width}}var nr=({className:t,triggerRef:e,boundaryRef:o=(0,be.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=Oi,...a})=>{let l=Mi(e),c=Mi(o),p=(0,be.useMemo)(()=>i(l,c,0),[l,c]);return(0,tr.jsx)($p,{children:(0,tr.jsx)("div",{className:(0,Ni.default)(Ue.ref,{[Ue.positionAbove]:n==="above",[Ue.positionBelow]:n==="below",[Ue.positionLeft]:n==="left",[Ue.positionRight]:n==="right",[Ue.alignStart]:s==="start",[Ue.alignCenter]:s==="center",[Ue.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:(0,tr.jsx)("div",{className:(0,Ni.default)(t,Ue.root),children:r})})})};var Xp=k(require("classnames")),sr=require("react");var Di=require("react/jsx-runtime"),rr=(0,sr.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,sr.useRef)(null),r=v("TabCompletion",Ve);return(0,Di.jsx)("div",{ref:Ys([s,n]),className:(0,Xp.default)(t,r.popoverContentContainer),...o,children:(0,Di.jsx)("div",{className:r.popoverContent,children:e})})});var bt=require("react/jsx-runtime"),Pf=t=>e=>{let o=Oi(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Af=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=v("TabCompletion",Ve),i=or(),a=(0,ar.useMemo)(()=>Pf(t.getBoundingClientRect()),[t]),[l,c]=fs(t);return(0,ar.useEffect)(()=>{c?i.open():i.close()},[c]),(0,bt.jsxs)("span",{children:[(0,bt.jsx)("mark",{ref:Ys([l,i.triggerRef]),className:(0,Qp.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,bt.jsx)(nr,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,bt.jsx)(rr,{style:o,children:(0,bt.jsx)("div",{className:r.hintText,children:s})})})]})},ir=class extends Zp.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${zp(n.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),e}match(e){let o=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let r=e.match(s.keywordRegex);if(!r)return null;let i=e.charAt(r.index-1),a=e.charAt(r.index+s.keyword.length);return i==="{"&&a==="}"?null:{index:r.index,length:r[0].length,match:r[0],matchString:r[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(jp);if(o.length===0)return null;let n=o.reduce((s,r)=>r.index<s.index?r:s);return this.usedKeywordMatches.add(n.preparedKeywordMatch),n}replaceWith(e,o){return(0,bt.jsx)(Af,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var cr=k(require("classnames")),od=require("interweave"),ne=require("react"),nd=require("react-redux");var Hi=require("react/jsx-runtime"),Jp=()=>(0,Hi.jsx)("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:(0,Hi.jsx)("path",{fill:"currentColor",d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})});var Ct=require("react"),vn=require("react-redux"),ed=k(require("lodash.debounce"));var Yp={root:"_root_1muu8_1",content:"_content_1muu8_7"};function lr(t,e,o){var s;let n=((s=t.imageSizes)==null?void 0:s[e])||t.image||o;if(!n)return null;try{return new URL(n).toString()}catch{return null}}function Bi(t){return t.replace("https://www.","").replace("https://","")}var Ce=require("react/jsx-runtime"),Lf=3,Mf=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),Nf=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=Lf})=>{let r=v("LinkSearch",Yp),[i,a]=(0,Ct.useState)(""),l=(0,vn.useDispatch)(),c=(0,vn.useSelector)(Ns("url")),p=(0,vn.useSelector)(Yl("URL",Mf)),[d,u]=(0,Ct.useState)(p.length-1),g=C("fallbackImage"),m=y=>{let x=y.target;a(x.value)},f=(y,x)=>{y.stopPropagation(),y.preventDefault(),window.open(x,"_blank")},h=y=>{var _;let x=d-1<0?p.length-1:d-1,b=d+1===p.length?0:d+1;y.code==="Escape"&&(a(""),e()),y.code==="ArrowUp"&&u(x),y.code==="ArrowDown"&&u(b),y.code==="Enter"&&t(((_=p[d])==null?void 0:_.text)||i)},w=(0,Ct.useCallback)((0,ed.default)(y=>{l(Bt({query:y,type:"URL",tags:["link-search"]}))},300),[]);return(0,Ct.useEffect)(()=>{i&&w(i)},[i]),(0,Ct.useEffect)(()=>()=>{l(Is())},[]),(0,Ce.jsxs)("div",{className:r.root,children:[(0,Ce.jsx)(Se,{withDivider:!0,children:(i?p:c).slice(0,s).map((y,x)=>(0,Ce.jsx)(D,{selected:d===x,onClick:()=>t(y.text),"data-testid":"linksearch-suggestion",children:(0,Ce.jsxs)(F,{children:[(0,Ce.jsx)(F.Image,{src:lr(y,"small",g||void 0),title:y.title||y.text}),(0,Ce.jsxs)(F.Content,{className:r.content,cropText:!0,children:[(0,Ce.jsx)(F.Title,{children:y.title||Bi(y.text)}),y.title&&Bi(y.text)]}),(0,Ce.jsx)(D.Actions,{children:(0,Ce.jsx)(D.ActionButton,{label:n,onClick:b=>f(b,y.text)})})]})},y.text))}),(0,Ce.jsx)(sn,{value:i,onChange:m,autoFocus:!0,placeholder:o,onKeyUp:h})]})},td=Nf;var Fi={};W(Fi,{enUS:()=>Of,nlNL:()=>Df});var Of={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Df={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var oe=require("react/jsx-runtime"),Hf=(0,ne.forwardRef)((t,e)=>{let o=v("TabCompletion",Ve);return(0,oe.jsx)("mark",{ref:e,className:(0,cr.default)(o.matchSelection)},"selection-start")}),Bf=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=T(Fi),i=v("TabCompletion",Ve),a=(0,ne.useRef)(null),l=(0,ne.useRef)(null),[c,p]=(0,ne.useState)(null),d=(0,nd.useDispatch)(),u=or(document.activeElement===n),[g]=(0,ne.useState)(()=>document.createRange());u.triggerRef.current=g,(0,ne.useEffect)(()=>()=>g.detach(),[]),(0,ne.useEffect)(()=>{let f=t.current,h=a.current;!f||!h||(g.setStart(f,0),g.setEnd(h,0))},[t.current,a.current]),co(()=>{u.close()});let m=(0,ne.useCallback)(f=>{let h=g.toString(),w=/^http(s?):\/\//.test(f)?f:`https://${f}`;d(Xn({text:`[${h}](${w})`,replace:"selection"}))},[]);return(0,oe.jsxs)("span",{children:[(0,oe.jsx)("mark",{ref:a,className:(0,cr.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":u.opened?"true":"false",children:s}),u.opened&&(0,oe.jsx)(nr,{className:i.popoverRoot,triggerRef:u.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,oe.jsxs)(rr,{style:o,ref:l,children:[(0,oe.jsx)("div",{className:(0,cr.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,oe.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,oe.jsx)(Jp,{}),(0,oe.jsx)("span",{children:"\xA0"}),(0,oe.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,oe.jsx)(td,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:m,onDismiss:()=>{p(null),u.close()}})]})})]},"selection-end")},pr=class extends od.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,ne.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,oe.jsx)(Hf,{ref:this.startRef}):(0,oe.jsx)(Bf,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var nt=require("react/jsx-runtime"),Ff=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=v("TabCompletion",Up),p=C("insertLink"),d=C("showMidSentenceSuggestions"),u=C("inlineSuggestions"),g=ys(a),m=(0,st.useRef)(null);(0,st.useEffect)(()=>{xt(a)&&g&&vs(a,g)},[g]);let f=(0,st.useCallback)(y=>{if(!s||!o)return y;let x=[(0,nt.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,nt.jsx)("span",{"data-testid":"tab-completion",className:(0,dr.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&x.push((0,nt.jsx)("span",{className:(0,dr.default)(c.hint,c.resetIndent),children:(0,nt.jsx)(Hn,{keyCode:"tab"},"tabHint")})),Li(y,x)},[s,o,n]),h=(0,st.useMemo)(()=>{let y=[];return p&&y.push(new pr("selection")),y.push(new ao("placeholders")),r&&y.push(new ir("keywords")),y},[u,p,r]),w=(0,st.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?(0,nt.jsxs)("div",{ref:y=>{y!=null&&y.parentElement&&(m.current=y==null?void 0:y.parentElement)},className:c.root,style:w,children:[(0,nt.jsx)(sd.Interweave,{tagName:"span",containerTagName:"div",className:(0,dr.default)(c.container,c.agentText),disableLineBreaks:xt(a),content:e||"\u200B",onAfterParse:f,matchers:h,selection:g,keywordMatches:i,inputElement:a,inputStyle:w,boundaryRef:m,inlineSuggestionsOnlyAtEnd:!d}),(0,nt.jsx)("br",{})]}):null},Kf=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var f;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??uo(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:u,visible:g,showStyleSuggestions:m}=o;return{showTabHint:p,showStyleSuggestions:m,showTabCompletion:u,content:l,tabText:c,source:a,keywordMatches:((f=n.list)==null?void 0:f.keywordMatches)??[],enabled:g&&d!==!1}},id=(0,rd.connect)(Kf)(Ff);var Zd=k(require("classnames")),Jd=require("react"),$=require("react-redux");var wt=require("@reduxjs/toolkit");var ad={list:[],fetchState:"idle",isInitialRequest:null},cd=t=>t.autoflows.list||[],ld=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},rt=(0,wt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Ki=(0,wt.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(rt(t.platformSessionId))}),Ui=(0,wt.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(rt(t.platformSessionId))}),Uf=(0,wt.createSlice)({name:"autoflows",initialState:ad,reducers:{},extraReducers:t=>{t.addCase(Ki.pending,(e,o)=>{let n=ld(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Ui.pending,(e,o)=>{let n=ld(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(rt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(rt.rejected,e=>{e.fetchState="error"}),t.addCase(rt.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(N,()=>ad)}}),pd=(0,wt.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(rt(t))}),s.on("sessionCompleted",()=>{o(rt(t))})}),dd=(0,wt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),ud=Uf.reducer;var Tt=require("@reduxjs/toolkit");var gd={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},md=t=>t.customMessages.list,fd=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),hd=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),yd=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),Sn=(0,Tt.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),ur=(0,Tt.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)}),gr=(0,Tt.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)}),vd=(0,Tt.createSlice)({name:"customMessages",initialState:gd,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(Sn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(Sn.rejected,e=>{e.fetchState="error"}).addCase(Sn.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(ur.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(ur.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(gr.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(gr.rejected,(e,o)=>{let n=e.answeredSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1)),e.answeredSuggestions.splice(n,1)}).addCase(N,()=>gd)}}),Sd=(0,Tt.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(vd.actions.onCustomMessage(r))})}),_d=(0,Tt.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),xd=vd.reducer;var _n=require("@reduxjs/toolkit"),zf={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},zi=(0,_n.createAsyncThunk)("passwordlessToken/getTemporaryPasswordlessToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.requestPasswordlessToken();return{accountUrl:o.client.baseUrl,token:n}}),ji=(0,_n.createAsyncThunk)("passwordlessToken/pollPasswordlessToken",(t={},e)=>{let{interval:o=1e3*60*10}=t,{dispatch:n}=e;return n(zi()),setInterval(()=>n(zi()),o)}),Cd=(0,_n.createSlice)({name:"passwordlessToken",initialState:zf,reducers:{stopPollPasswordlessToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(zi.fulfilled,(e,o)=>{e.token=o.payload.token,e.accountUrl=o.payload.accountUrl}),t.addCase(ji.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollPasswordlessToken:wd}=Cd.actions,Td=Cd.reducer;function Ed(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var Od=require("react"),Dd=require("react-redux");var Ld=k(require("classnames")),Md=require("react");var Rd=k(require("classnames"));var kd={root:"_root_838fd_1"};var Pd=require("react/jsx-runtime"),jf=({className:t,children:e})=>{let o=v("Unicode",kd);return(0,Pd.jsx)("span",{className:(0,Rd.default)(t,o.root),children:e})},Id=jf;var Ad={isDisabled:"_isDisabled_1rmfm_1",buttonStart:"_buttonStart_1rmfm_5",root:"_root_1rmfm_8",buttonStop:"_buttonStop_1rmfm_8",stateBadge:"_stateBadge_1rmfm_19",isCompleted:"_isCompleted_1rmfm_26",isStarted:"_isStarted_1rmfm_30",isAborted:"_isAborted_1rmfm_34"};var Vi={};W(Vi,{enUS:()=>Vf,nlNL:()=>qf});var Vf={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"}]},qf={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]};var ge=require("react/jsx-runtime"),Gf=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=v("Autoflow",Ad),a=T(Vi),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,ge.jsxs)(D,{className:(0,Ld.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,ge.jsx)(F,{children:(0,ge.jsxs)(F.Content,{children:[(0,ge.jsxs)(F.Title,{children:[e&&(0,ge.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,ge.jsx)("span",{children:n})]})}),(0,ge.jsx)(D.Actions,{fixed:e==="Started",children:(0,ge.jsx)(D.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,ge.jsxs)(Md.Fragment,{children:[(0,ge.jsx)(Id,{children:c})," ",(0,ge.jsx)("span",{children:a(l)})]})})})]})},Nd=Gf;var qi=require("react/jsx-runtime"),$f=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Xf=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,qi.jsx)(Od.Fragment,{children:t.map(s=>(0,qi.jsx)(Nd,{displayName:s.displayName,description:s.description,disabled:s.isBusy||$f(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),Qf=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},Zf={onStartAutoflow:Ki,onStopAutoflow:Ui},Hd=(0,Dd.connect)(Qf,Zf)(Xf);var mr=require("react"),Fd=require("react-redux"),$i=k(require("classnames"));var Wi=require("react/jsx-runtime"),Gi=()=>(0,Wi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,Wi.jsx)("path",{d:"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z"})});var Bd={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 ze=require("react/jsx-runtime"),Jf=({entities:t})=>{let e=v("EntitiesWidgetList",Bd),[o,n]=(0,mr.useState)(void 0),s=(0,Fd.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),an(a.text),s(X({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,mr.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,ze.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,ze.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,ze.jsx)("span",{className:e.entityText,children:a.text}),(0,ze.jsxs)("span",{className:e.iconWrapper,children:[(0,ze.jsx)("span",{className:(0,$i.default)(e.icon),children:(0,ze.jsx)(Gi,{})}),(0,ze.jsx)("span",{className:(0,$i.default)(e.icon,o===l&&e.iconClicked),children:(0,ze.jsx)(Gi,{})})]})]},a.text))})},Kd=Jf;var Ud=k(require("classnames")),Xi=require("react"),Wt=require("react-redux");var it={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 ce=require("react/jsx-runtime"),Yf=({suggestion:t})=>{let e=T(Dt),o=(0,Wt.useDispatch)(),n=(0,Wt.useSelector)(fd(t.text)),s=(0,Wt.useSelector)(hd(t.text)),r=(0,Wt.useSelector)(yd(t.text)),i=(0,Wt.useSelector)(Un),{replyOptions:a}=t,l=(0,Xi.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(ur({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,Xi.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),u=a[d];o(gr({platformSessionId:i,reply:u,suggestion:t}))},[t,n,o,i]);return(0,ce.jsxs)(D,{onClick:l,className:(0,Ud.default)(it.root,{[it.isUsed]:n,[it.hasError]:r}),children:[(0,ce.jsx)(F,{children:(0,ce.jsxs)(F.Content,{children:[(0,ce.jsxs)(F.Title,{className:it.title,children:[t.text," ",(0,ce.jsx)(Bn,{className:it.label,children:"analyse tool"})," ",r&&(0,ce.jsx)("span",{className:it.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,ce.jsx)("ul",{className:it.quickReplies,children:a.map(p=>(0,ce.jsx)("li",{className:it.quickReply,children:p.title},p.title))})]})}),(0,ce.jsxs)(D.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,ce.jsx)(D.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>(0,ce.jsx)(D.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),(0,ce.jsx)(D.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},zd=Yf;var Qi=require("react/jsx-runtime"),jd=()=>(0,Qi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Qi.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 Wd=require("react-redux");var Vd=require("react");var me=require("react/jsx-runtime"),eh=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var u;let s=t.text||t.url||t.message,r=Ps(s),i=T(Dt),a=C("showImages"),l=C("fallbackImage"),c=g=>{g.preventDefault(),g.stopPropagation(),n(s)},p=g=>{g.preventDefault(),g.stopPropagation(),o(t)},d=(0,Vd.useCallback)(g=>{window.open(r,"_blank"),g.stopPropagation(),g.preventDefault()},[r]);return(0,me.jsxs)(D,{onClick:c,"data-testid":"edit-suggestion",children:[(0,me.jsxs)(F,{children:[a&&t.image&&(0,me.jsx)(F.Image,{src:lr(t,"small",l||void 0),title:t.title}),(0,me.jsxs)(F.Content,{children:[t.title&&(0,me.jsx)(F.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&(0,me.jsx)(D.Labels,{labels:t.searchKeywords}),(0,me.jsx)(F.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),(0,me.jsxs)(D.Actions,{children:[r&&(0,me.jsx)(D.ActionButton,{onClick:d,label:i("visitUrl")}),(0,me.jsx)(D.ActionButton,{primary:!0,onClick:p,label:i("preview")}),(0,me.jsx)(D.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},qd=eh;var xn=require("react/jsx-runtime"),th=({contentType:t,lines:e,suggestions:o})=>{let n=xe(),s=(0,Wd.useSelector)(ht),r=a=>{n.send(vi,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(Qe,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,xn.jsx)(xn.Fragment,{children:o.map(a=>(0,xn.jsx)(qd,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},Gd=th;var Zi={};W(Zi,{enUS:()=>oh,nlNL:()=>nh});var oh={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},nh={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var $d={root:"_root_x0pwe_1",loginText:"_loginText_x0pwe_7",stateText:"_stateText_x0pwe_8",sectionList:"_sectionList_x0pwe_20",shortcutList:"_shortcutList_x0pwe_24",shortcut:"_shortcut_x0pwe_24",link:"_link_x0pwe_52"};var Ji=require("react/jsx-runtime"),Xd=()=>(0,Ji.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Ji.jsx)("path",{d:"M543-340q16.595 0 28.798-12.202Q584-364.405 584-381t-12.202-28.798Q559.595-422 543-422t-28.798 12.202Q502-397.595 502-381t12.202 28.798Q526.405-340 543-340Zm-25-126h47q2-29 8.5-43t32.5-39q27-26 37.5-45.395Q654-612.79 654-639q0-45.882-31.5-74.941Q591-743 540-743q-38 0-68 20.5T428-665l45 19q11-25 27.5-38t39.5-13q29.778 0 48.389 17Q607-663 607-637q0 20-9 35t-32 32q-32 29-40 46.5t-8 57.5ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-620h60v620h620v60H140Zm120-740v560-560Z"})});var Yi=require("react/jsx-runtime"),Qd=()=>(0,Yi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Yi.jsx)("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});var R=require("react/jsx-runtime"),fr=(t,e)=>{let o=(0,$.useSelector)(ue);(0,Jd.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},sh=({onLogIn:t})=>{let e=T(Zi),o=(0,$.useDispatch)(),n=C("isEmbedded"),s=v("Widget",$d),r=C("showAutoflows"),i=C("showCustomMessages"),a=C("showSummaryCommand"),l=C("showKnowledgeSearch"),c=C("showSearch"),p=(0,$.useSelector)(St),d=(0,$.useSelector)(Ws),u=(0,$.useSelector)(cd),g=(0,$.useSelector)(Us),m=(0,$.useSelector)(md),f=(0,$.useSelector)(zn),h=(0,$.useSelector)(oo),w=(0,$.useSelector)(ue),y=(0,$.useSelector)(Un),x=(0,$.useSelector)(Ed),b=(0,$.useSelector)(ht),_=xe(),A=(0,$.useSelector)(pc),O=(0,$.useSelector)(bd("/admin/")),se=C("adminUrl"),L=C("productName");if(fr(()=>(o(Sn(y)),o(Sd(y)),()=>{o(_d(y))}),[o,h,i,y]),fr(()=>(o(rt(y)),o(pd(y)),()=>{o(dd(y))}),[o,h,r,y]),fr(()=>{d.forEach(({type:P})=>{o(P==="entities"?Le():Pe(P))})},[o,h,f,p]),fr(()=>(o(ji()),()=>{o(wd())}),[o]),h===!1)return(0,R.jsx)("div",{className:s.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:e("notSupported")})})},"supported");if(w===!1)return(0,R.jsx)("div",{className:s.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(Zs,{isEmbedded:n,loginUrl:se,onLogIn:t})})},"login");if(!p||!y||w===null||A||x)return(0,R.jsx)("div",{className:s.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:e("waiting")})})},"waiting");let re=c||a||l||O;return(0,R.jsx)("div",{className:(0,Zd.default)(s.root),"data-testid":"widget",children:(0,R.jsxs)(Fn,{className:s.sectionList,children:[re&&(0,R.jsx)(lt,{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:()=>_.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(fo,{}),e("linkSearch")]}),a&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-summary",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(Qd,{}),e("linkSummary")]}),l&&(0,R.jsxs)("button",{className:s.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>_.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,R.jsx)(Xd,{}),e("linkKnowledgeSearch")]}),O&&(0,R.jsxs)("a",{className:s.shortcut,target:"_blank",href:O,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[(0,R.jsx)(jd,{}),e("linkStudioLogin",{productName:L})]})]})}),i&&m.length>0&&(0,R.jsx)(lt,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(Se,{withDivider:!0,children:m.map(P=>(0,R.jsx)(zd,{suggestion:P},P.text))})}),r&&u.length>0&&(0,R.jsx)(lt,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(Se,{withDivider:!0,children:(0,R.jsx)(Hd,{})})}),d.map(({type:P,title:U,amount:Qt,lines:Mo})=>{var No;switch(P){case"entities":return g&&g.length>0&&(0,R.jsx)(lt,{type:P,title:U,"data-testid":`type-${P}`,children:(0,R.jsx)(Kd,{entities:g})},P);default:return((No=b[P])==null?void 0:No.fetchState)==="done"&&b[P].suggestions.length>0&&(0,R.jsx)(lt,{type:P,title:U,"data-testid":`type-${P}`,children:(0,R.jsx)(Se,{withDivider:!0,children:(0,R.jsx)(Gd,{lines:Mo,contentType:P,suggestions:b[P].suggestions.slice(0,Qt)||[]})})},P)}})]})})},Yd=sh;function Po(t){let e=new Range;return e.selectNodeContents(t),e}function eu(t,e,o){try{return Et(t,e,o),!0}catch{return!1}}function hr(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function yr(t){return"tagName"in t&&t.tagName==="BR"}var bn=/[\u200B-\u200D\uFEFF]/g;function Et(t,e,o){let n=new Range;if(t.firstChild===null&&e===0&&o===0)return n.selectNodeContents(t),n;let s=0,r=!1;function i(l,c){let p=-1,d=/[\u200B-\u200D\uFEFF]/;if(!d.test(l))return c;for(let u=0;u<=l.length;u++)if(d.test(l[u])||p++,p===c)return u;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(bn,""),d=s+p.length,u=e>=s&&e<=d,g=o>=s&&o<=d;if(u){let m=i(c,e-s);m===0&&!g?n.setStartBefore(l):n.setStart(l,m)}g&&(n.setEnd(l,i(c,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(yr(l)&&(s===e&&n.setStartBefore(l),s++,s===o)){n.setEndAfter(l),r=!0;return}for(let p=0;p<l.childNodes.length&&(a(l.childNodes[p]),!r);p++);let c=l.lastChild;hr(l)&&c&&!hr(c)&&!yr(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function Cn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r,collapsed:i}=e,a,l,c=0;function p(d){let u=d===o,g=d===s;switch(d.nodeType){case Node.TEXT_NODE:{let m=d.textContent;u&&(a=c+m.substring(0,n).replace(bn,"").length),g&&(l=c+m.substring(0,r).replace(bn,"").length),c+=m.replace(bn,"").length;break}case Node.ELEMENT_NODE:{let m=d.nextSibling===null;yr(d)&&!m&&c++;for(let f=0;f<d.childNodes.length;f++){let h=u&&f===n,w=g&&f===r;if(h&&(a=c),w&&(l=c),l!==void 0||((!h||!i)&&p(d.childNodes[f]),g&&f===r-1&&(l=c),l!==void 0))break}!g&&hr(d)&&!m&&c++,g&&(l=c);break}default:break}}if(p(t),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function wn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let p=c===o,d=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let u=p?n:0,g=d?r:void 0,m=c.textContent.replace(bn,"");u===0&&g===void 0?a+=m:a+=m.substring(u,g);break}case Node.ELEMENT_NODE:{let u=c.nextSibling===null;i===0&&yr(c)&&!u&&(a+=`
|
|
4
|
+
`);for(let g=p?n:0;g<(d?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[g]),i!==1);g++);!d&&i===0&&hr(c)&&!u&&(a+=`
|
|
5
|
+
`);break}default:break}d&&i++}return l(t),a}function tu(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Gt=class extends qe{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),wn(this.element,e)}getHTML(){return this.element.innerHTML||""}getRange(){var r;let e=this.getRootNode();if(e.activeElement!==this.element)return null;let o="getSelection"in e?e.getSelection():window.getSelection();if(!o)return null;let n="getComposedRanges"in o&&e instanceof ShadowRoot?(r=o.getComposedRanges(e))==null?void 0:r[0]:o.rangeCount>0?o.getRangeAt(0):null;if(!n)return null;let s=this.element.ownerDocument.createRange();return s.setStart(n==null?void 0:n.startContainer,n==null?void 0:n.startOffset),s.setEnd(n==null?void 0:n.endContainer,n==null?void 0:n.endOffset),!s||!this.element.contains(s.startContainer)||!this.element.contains(s.endContainer)?null:s}getCaretPosition(){let e=this.getRange();if(!e||!e.collapsed||!("getBoundingClientRect"in e))return null;let o=e.getBoundingClientRect();return!tu(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!tu(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&&eu(this.element,o.start,o.end))return o;let n=Po(this.element);return n.collapse(!1),Cn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return wn(this.element,Et(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return(s=this.observer)==null||s.takeRecords(),Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};function ou(t,e,o){let n=`deepdesk-iframe-${t}`,s=document.getElementById(n);if(s)return s;let r=document.createElement("iframe"),i=new URL(e);return Object.entries(o).forEach(([a,l])=>{i.searchParams.append(a,l)}),r.style.position="absolute",r.style.left="-999em",r.style.width="0px",r.style.height="0px",r.tabIndex=-1,r.id=n,r.title=`iframe-${t}`,r.src=i.toString(),window.document.body.appendChild(r),r}var ea=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(e)}broadcastChannel;disposeHandlers=[];onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(e)}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},ta=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=ou(e,`${this.targetOrigin}/v2/widget/liveengage/channel.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(e,this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},oa=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),E.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new ta(e,this.deepdeskUrl,{debug:!0}):new ea(e),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&s.data.channel===e&&(E.info("Received broadcast event",this.sessionId,s),(i=(r=this.eventMap)[s.data.name])==null||i.call(r,s.data.payload))};return o.onMessage(n),o}send(e,o){var r,i;E.info("broadcast event",{sessionId:this.sessionId,name:e,payload:o});let n={type:"event",name:e,payload:o};(i=(r=this.eventMap)[e])==null||i.call(r,o);let s=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage({...n,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},nu=oa;var Ao=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var na=t=>new Promise(e=>{setTimeout(e,t)});var Lo=class extends Ao{name="ClientError"},sa=class extends Ao{name="ServerError"},Ne=class t{constructor(e="",o={}){this.baseUrl=e;this.options=o;o.fetch&&(this.fetch=o.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,o={}){return new Promise((n,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,{abortLatest:l=!1,attempts:c=1,retryDelay:p=500,refreshTokenOn401:d=!0,retryOnError:u=b=>b instanceof TypeError,retryOnResponse:g=b=>b.status>=500,version:m="v1",...f}=o,h={credentials:"include",...f,headers:{"Content-Type":"application/json",...f.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(h.headers={...h.headers,"X-CSRFToken":this.csrfToken}),typeof m=="string"&&(h.headers={...h.headers,"X-Deepdesk-API-Version":m});let w=c,y=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&l&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let x=async()=>(w--,a(i,h).then(async b=>g(b)&&!r.isAborted&&w>0?(await na(p),x()):b.status===401&&d===!0&&y===!1?(y=!0,await this.refreshToken(),x()):b).catch(async b=>{if(u(b)&&!r.isAborted&&w>0)return await na(p),x();throw b}));x().then(b=>b.json().catch(()=>null).then(_=>{b.status>=500?s(new sa("Server Error",_)):b.status===401?s(new Lo("Unauthorized",_)):b.status===403?s(new Lo("Forbidden",_)):b.status===404?s(new Lo("Not Found",_)):b.status>=400&&s(new Lo("Bad Request",_)),delete this.latestRequestByUrl[i],n(_)})).catch(b=>{s(b)})})}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var rh;(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||={})})(rh||={});function vr(t){return{...M(t),tags:t.tags}}var at=class t{constructor(e,o={}){this.options=o;this.client=new Ne(e,{fetch:o.fetch}),this.client.patchFetch(n=>async(s,r)=>{let i=await n(s,r);return this.handleDeepdeskVersionHeaders(i),i})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=await this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(t.exchangeTokenPromise||(t.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),t.exchangeTokenPromise):Promise.resolve()}async createConversation(e){await this.preflight(),E.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...q(e),tags:e.tags},{version:"v2"});return vr(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return M(o)}async getKnowledgeAssistant(e){let o=await this.client.get(`/apis/admin/knowledge-assist/assistants/${e}/`,{version:null});return M(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return M(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return M(e)}async checkUserExists(e){let{exists:o}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return o}async getConversationBySessionId(e,o={}){await this.preflight(),E.info(`Getting conversation for session ${e}`);let{attempts:n=1,retryDelay:s=1e3}=o,r=await this.client.get(`/api/conversations/by_session_id/${e}`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"});return vr(r)}async isConversationSupported(e,o={}){E.info(`Check if conversation for session ${e} is supported`);let{attempts:n=1,retryDelay:s=1e3}=o;return(await this.client.get(`/api/conversations/by_session_id/${e}/active_profile`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"})).has_active_profile}async updateConversation(e,o){let n=q(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return vr(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=>vr(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)},prompt_instruction:o.promptInstruction,model:o.model})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(e){return this.client.post("/apis/admin/session/jwt/",{jwt:e},{version:null}).catch(o=>{throw E.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",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=>({...M(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 M(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 M(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,q(e),{version:"v2"});return M(o)}async knowledgeAssist(e,o,n){let s=await this.client.post(`/api/knowledge-assist/assistants/${n}/search`,q({question:e.question,promptInstruction:e.promptInstruction,chatHistory:o.map(r=>({question:r.question,answer:r.answer.answer}))}),{version:"v2"});return M(s)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return M(o)}async requestPasswordlessToken(){let e=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return M(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 M(o)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(Aa);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&E.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var Tn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(di(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,M(s))}catch{E.warn(`Invalid JSON for ${e}: ${n}`)}})}connect(){clearTimeout(this.timeoutTimer);let e=new EventSource(this.url,{withCredentials:!0});this.eventSource=e;let o=!1;e.onopen=()=>{o=!0},e.onerror=()=>{o&&e.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{e.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(n=>{this.proxyEvent(n)})}disconnect(){var e;clearTimeout(this.timeoutTimer),this.eventListeners={},(e=this.eventSource)==null||e.close()}emit(e,o){this.eventListeners[e]&&this.eventListeners[e].forEach(n=>n(o))}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),this.proxyEvent(e),()=>{this.off(e,o)}}off(e,o){let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}};var ih;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(ih||={});var En=class{constructor(e,o={}){this.apiUrl=e;this.client=new Ne(e,o)}client;streams={};logger=E;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return M(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,q(o));return M(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 M(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",q(e));return M(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new Tn(`${this.apiUrl}/sessions/${e}/events`),this.streams[e].connect()),this.streams[e]}closeStream(e){this.streams[e]||(this.streams[e].disconnect(),delete this.streams[e])}};var br=require("@reduxjs/toolkit");var ru=require("@reduxjs/toolkit");var su={startTime:null,stopTime:null},iu=(0,ru.createSlice)({name:"handlingTime",initialState:su,reducers:{handlingTimeStart(t){if(t.startTime&&!t.stopTime)throw new Error("Timing already started");t.startTime=new Date,t.stopTime=null},handlingTimeStop(t){if(!t.startTime)throw new Error("Timing not started");t.stopTime=new Date},handlingTimeReset(t){t.startTime=null,t.stopTime=null}},extraReducers:t=>{t.addCase(N,()=>su)}}),{handlingTimeStart:au,handlingTimeStop:Sr,handlingTimeReset:lu}=iu.actions,cu=iu.reducer;var pu=(t={})=>{let e={onAuthError:So(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var xr=require("@reduxjs/toolkit");var _r={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var $t=(0,xr.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 _r.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),ah=(0,xr.createSlice)({name:"styleSuggestions",initialState:_r,reducers:{},extraReducers:t=>{t.addCase($t.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase($t.rejected,e=>{e.fetchState="error"}).addCase($t.fulfilled,(e,o)=>{e.fetchState="done",pt(e.list,o.payload)||(e.list=o.payload)}).addCase(Pt,e=>{e.list=_r.list}).addCase(N,()=>_r)}}),du=ah.reducer;var uu=(t={})=>{let e,o=!0,n={getStyleSuggestions:$t,debounce:500,...t};return s=>r=>i=>{var g;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:p}=c.settings;if(!((g=c.conversation.current)==null?void 0:g.id)||!p)return l;let{text:u}=c.input;return u===a&&!o||(clearTimeout(e),u==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:u}))},t.debounce)),l}};function lh(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var gu=(t={})=>{let e={getTextSuggestions:Pe,getAutocompleteSuggestions:Yo,debounce:200,check:Eo,...t},o;return n=>s=>r=>{var f;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:p}=l.settings,d=(f=l.conversation.current)==null?void 0:f.id,u=r.type===Os.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:g}}=l;return lh(g,i)&&!u||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let h=no(l);h===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(h))},u?0:e.debounce)),a}};var mu=$t.fulfilled.toString();function ch(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 fu=t=>e=>o=>n=>{var c;if(n.type!==mu){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=ch(s,i);n.type===mu&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var ph=(0,br.combineReducers)({activeSuggestion:xc,answer:dp,auth:Oc,autoflows:ud,conversation:Fa,contentTypes:Gc,customMessages:xd,passwordlessToken:Td,entities:Zc,knowledgeAssistant:lp,handlingTime:cu,info:Xl,input:Or.reducer,overlayInput:ie.reducer,settings:Oa,profile:mp,search:tc,summary:np,styleSuggestions:du,ui:Ec,textSuggestions:fc});function hu(t){return(0,br.configureStore)({reducer:ph,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),pu(),gu({debounce:200}),uu({debounce:500}),fu(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var dh=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},uh=t=>e=>o=>n=>{var a;let s=e.getState(),r=Ar("inlineSuggestions")(s);switch(n.type){case $e.toString():{let l=Ns(n.payload.contentType)(e.getState()),c=l.indexOf(n.payload.suggestion);t.emit("edit-suggestion",{contentType:n.payload.contentType,index:c,suggestions:l});break}case So.toString():{!n.payload&&t.emit("logout",void 0);break}case ke.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:dh(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Xn.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 Fo.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case Yn.toString():t.emit("select-image",n.payload,{mayApplyChanges:!0}),t.sendEvent("Image attached",{conversationId:s.conversation.current.id,data:{path:n.payload.suggestion.image,title:n.payload.suggestion.title}});break;case Le.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case Ze.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary}});break;case X.toString():t.sendEvent(n.payload.name,{conversationId:((a=n.payload.options)==null?void 0:a.includeConversationData)&&s.conversation.current.id,data:n.payload.data});break;case Qn.toString():t.handleKeyDown(n.payload);break;case Pt.toString():t.logSendMessage(n.payload);break;case Zn.toString():t.logSendEditSuggestionMessage(n.payload);break;case Jn.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case Pt.toString():t.handleAfterSendMessage(n.payload);break;case en.toString():t.onUpdateShowTabHint(n.payload);break;case Sr.toString():t.logHandlingTime();break;case ke.toString():{r&&(e.dispatch(He([])),e.dispatch(je()));break}case He.toString():{r&&n.payload.length>0&&e.dispatch(ut(0));break}default:break}return i},yu=uh;function ra(t){return t.toISOString().replace("T"," ").replace("Z","")}function vu(t,e){var s,r,i;let{startTime:o,stopTime:n}=t.handlingTime;if(!o||!n)throw new Error("No startTime and stopTime for handling time metrics");return{conversationId:t.conversation.current.id,clientVersion:e.version,agentId:(s=t.info.agentInfo)==null?void 0:s.agentId,agentName:(r=t.info.agentInfo)==null?void 0:r.agentName,agentEmail:(i=t.info.agentInfo)==null?void 0:i.agentEmail,timeStart:ra(o),timeStop:ra(n)}}function ia(t,e,o){var O,se,L;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:d,cuts:u,deletions:g,textSuggestions:m,offeredTextSuggestions:f}}=e[t],h=n.length,y=m.reduce((re,{text:P,searchTerm:U})=>re+P.length-(U?U.length:0),0),x=c??Date.now(),b=(Date.now()-x)/1e3+(p||0),_=s/b,A=m.reduce((re,{searchTerm:P})=>re+(P?P.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:d,cuts:u,deletions:g,lenTextTyped:s+A,lenTextTotal:h,lenTextAssisted:y,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:b,charsPerSecond:_,numPastes:l,textSuggestionsV2:m,suggestionsCounters:[{source:"gpt",countOffered:f.filter(re=>re.source==="gpt").length}],agentId:(O=e.info.agentInfo)==null?void 0:O.agentId,agentName:(se=e.info.agentInfo)==null?void 0:se.agentName,agentEmail:(L=e.info.agentInfo)==null?void 0:L.agentEmail}}function aa(t,e){var r;let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;if(n instanceof HTMLElement)return aa(n,e);let s=(r=t.ownerDocument.defaultView)==null?void 0:r.frameElement;return s?aa(s,e):null}function Su(t,e){return aa(t,e)}function _u(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function gh(t){return typeof t=="object"&&t!==null&&"tagName"in t}function Cr(t){return gh(t)&&(xt(t)||hs(t))}var xu=(t,e)=>({value(){try{let o=sessionStorage.getItem(`dd-${t}`);if(!o)return e;try{return JSON.parse(o)}catch{return e}}catch{return e}},update(o){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(o))}catch{E.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function mh(t){return t.offsetParent!==null}function bu(t){if(!mh(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 wr(t,e,o=100){let n=bu(t);e({isVisible:n});let s=setInterval(()=>{let r=bu(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var Eu=k(require("classnames")),ku=require("react-redux");var Tr=require("react/jsx-runtime"),Cu=({className:t})=>(0,Tr.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,Tr.jsx)("g",{children:(0,Tr.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
|
|
6
6
|
c-17.9,17.9-27.3,40.1-27.3,65.7C163.4,163,163.4,233,163.4,233z M465.5,267.9V477c0,9.4-3.4,17.9-10.2,24.7
|
|
7
7
|
c-6.8,6.8-15.4,10.2-24.7,10.2h-349c-9.4,0-17.9-3.4-24.7-10.2c-6.8-6.8-10.2-15.4-10.2-24.7V267.9c0-9.4,3.4-17.9,10.2-24.7
|
|
8
8
|
c6.8-6.8,15.4-10.2,24.7-10.2h11.9v-70c0-44.4,16.2-82.8,47.8-115.2S212.1,0,256.4,0s82.8,16.2,115.2,47.8
|
|
9
|
-
c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var ca=require("react/jsx-runtime"),yh={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Tu=({className:t,color:e})=>(0,ca.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ca.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:yh[e||"pink"]})});var Eu={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 pa={};W(pa,{enUS:()=>vh,nlNL:()=>Sh});var vh={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},Sh={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Iu=require("react-redux"),Xt=require("react/jsx-runtime"),Pu=({onLogIn:t})=>{let e=w(pa),o=C("productName"),n=(0,Iu.useDispatch)(),s=(0,Ru.useSelector)(ue),r=v("FloatingMenu",Eu);if(s===null)return null;let i=()=>{s===!0?n(Y(!0)):t()};return(0,Xt.jsxs)("button",{className:(0,ku.default)(r.root,{[r.isLoggedIn]:s,[r.isLoggedOut]:!s}),onClick:i,children:[(0,Xt.jsx)("div",{className:r.text,children:e(s?"search":"signin",{productName:o})}),(0,Xt.jsxs)("div",{className:r.icon,children:[(0,Xt.jsx)(Tu,{className:r.logo,color:"pink"}),s===!1&&(0,Xt.jsx)(wu,{className:r.lock})]})]})};async function kr(t){let o=await new Ne(t).get("/platform/config/",{version:null});return M(o)}var j=require("react/jsx-runtime");var Au=bu("showTabHint",!0),kn=class t{static version="10.10.1";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new at(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[vu({emit:(d,u,g)=>this.emit(d,u,g),handleAfterSendMessage:d=>this.handleAfterSendMessage(d),handleInputChanged:d=>this.handleInputChanged(d),handleKeyDown:d=>this.handleKeyDown(d),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:d=>this.logSendMessage(d),logSendEditSuggestionMessage:d=>this.logSendEditMessage(d),onUpdateShowTabHint:d=>Au.update(d),sendEvent:(d,u)=>this.deepdeskApi.sendEvent(d,u)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new En(o)}),this.store=yu(p),this.broadcastEvents=new su({debug:!0,deepdeskUrl:c,eventMap:Hc(this.store),createCustomChannel:l}),this.store.dispatch(Bo),this.store.dispatch(en(Au.value())),this.store.dispatch(Bo({locale:s,adminUrl:c,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(T.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(T.warn("Profile has not been loaded (yet)"),!0):(T.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(So(null)),this.store.dispatch(Xe()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ue(n)&&Pc(n)!=="loading"&&(o(),e())});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(Xe())).payload}async setPlatformAgentId(e){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:e}),version:null})}catch(o){T.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(Nr({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(jn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Vn({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Or(e))).payload}async postMessages(e){return(await this.store.dispatch(Wn(e))).payload}async updateConversation(e){return(await this.store.dispatch(qn(e))).payload}resetConversation(){this.store.dispatch(N()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(Ze());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Bo(e))}setVisitorInfo(e){this.store.dispatch(Xl(e))}async setAgentInfo(e){await this.store.dispatch(Xo(e))}async setAgentSettings(e){await this.store.dispatch(gi(e))}async getAgentSettings(){return(await this.store.dispatch(mi())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(Ds()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Jn(e))}notifyKeyDown(e){this.store.dispatch(Qn(e))}notifyPaste(e,o){this.store.dispatch(Ya({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Za(e))}notifyExternalSuggestion(e){this.store.dispatch(ke(e)),this.store.dispatch(je())}notifyEditSuggestion(e){this.store.dispatch(mc(e.contentType,e.suggestions)),this.store.dispatch($e({contentType:e.contentType,suggestion:typeof e.index=="number"?e.suggestions[e.index]:null}))}handleInputChanged(e){let{overlayCollapsed:o,openOverlayWhenTyping:n}=this.state.ui;o&&n&&this.store.dispatch(yt({collapse:!1})),this.inputMediator&&this.store.dispatch(qa({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(He([])))}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(Ja($n(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch($a()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Qa());let{selectedSuggestionIndex:d}=this.state.input;e.preventDefault(),!i&&(d===-1?this.store.dispatch(Fo()):this.stageSelectedSuggestion({inputType:"arrow"}))};switch(e.key){case"Up":case"ArrowUp":i?p():c();return;case"Down":case"ArrowDown":{i?c():p();return}case"Esc":case"Escape":{i&&l&&this.store.dispatch(ut(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(ut(-1)),this.store.dispatch(Fo()),e.preventDefault()):o||(this.store.dispatch(yt({collapse:!0})),this.store.dispatch(Tc(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:d}=this.state.input,u=d.text.substring(0,d.selection.end),{tabCompletionSuggestion:g}=this.state.input;this.store.dispatch(en(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&g&&g.text.startsWith(u)&&(this.store.dispatch(ke({text:g.text,suggestion:g,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(el()),this.store.dispatch(He([]))}handlingTimeStart(){this.state.handlingTime.startTime||(T.info("Start handling time"),this.store.dispatch(lu()))}handlingTimeStop(){this.state.handlingTime.startTime&&(T.info("Stop handling time"),this.store.dispatch(_r()))}logSendMessage(e){let o=aa("input",this.state,{version:this.version});e&&(Object.assign(o,{text:e}),Object.assign(o,{lenTextTotal:e.length})),this.deepdeskApi.sendEventV1("Send Message",o),this.emit("send-message-event",o)}logSendEditMessage(e){let o=aa("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(Ga(this.state.overlayInput.metrics))}logHandlingTime(){let e=Su(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(cu())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(je()),this.store.dispatch(Pt(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(ke({text:n[o].text,suggestion:n[o],eventMetrics:e,replace:"until-selection-end"}))}emit(e,o,n={}){let s=()=>{this.eventListeners[e]&&this.eventListeners[e].forEach(r=>{try{r(o)}catch(i){T.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),T.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=Mt(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,we.unmountComponentAtNode)(r),i(),r.remove()}),r}createInlineContainer(e,o){var i;let n=document.createElement("div");n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.style.height="0px",n.style.width="0px";let s=document.createElement("div");s.style.display="none",s.style.position="absolute",s.style.height="0px",s.style.width="0px",s.style.backgroundColor="red",n.appendChild(s);let r=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;if(r){let[a,l]=Mt(r,{appendTo:document.body});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{(0,we.unmountComponentAtNode)(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Lt(s),s.dataset.testid=e,s.style.color=n.color,s.style.fontSize=n.fontSize,s.style.fontFamily=n.fontFamily,s.style.fontVariant=n.fontVariant,s.setAttribute("translate","no"),o.appendChild(s),this.unmountHandlers.push(()=>{(0,we.unmountComponentAtNode)(s),s.remove()}),s}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,o),T.info(`Stored analytics for ${this.conversationId()}`)}catch{}}restoreMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=window.sessionStorage.getItem(e);if(!o)return;let n=JSON.parse(o);n.text.trim()===this.state.input.text.trim()?(T.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(ol(n.metrics))):T.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(e)}catch{}}mount(e,o={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!wr(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:n={},showStyleSuggestions:s,showTabCompletion:r,showTextSuggestions:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,isEmbedded:d,detectSubmit:u,insertLink:g,inputMediator:m,closestScrollSelector:f,appendOverlayTo:y,inlineSuggestions:E,floatingMenu:h}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:g,isEmbedded:d,inlineSuggestions:E,floatingMenu:!!h}),o.automaticHandlingTime&&this.setupHandlingTime(e),Lt(e),this.inputMediator=m||(xt(e)?new We(e):new Gt(e)),this.inputMediator.on("change",({plainText:_})=>{this.notifyInputChanged(_)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(tl({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",_=>{this.notifyKeyDown(_)}),this.inputMediator.on("paste",({pastedText:_,selectionText:A})=>{this.notifyPaste(_,A)}),this.inputMediator.on("cut",({selectionText:_})=>{this.notifyCut(_)});let x=f&&_u(e,f)||void 0;if(E){let{customStyles:_,appendOverlayTo:A}=o;if(xt(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let O=this.createInlineContainer(e,"deepdesk-caret");(0,we.render)((0,j.jsx)(qt,{store:this.store,customStyles:_,children:(0,j.jsx)(Ut,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(Pp,{})})}),O),this.inputMediator.on("caret",L=>{this.store.dispatch(He([])),L?(O.style.display="block",O.style.top=`${L.top}px`,O.style.left=`${L.left}px`):O.style.display="none"});let se=this.overlayContainerFactory("floating-menu",x||e,{appendTo:typeof h=="object"&&"appendOverlayTo"in h?h.appendOverlayTo:A},_==null?void 0:_.floatingMenuRootNode);(0,we.render)((0,j.jsx)(qt,{store:this.store,customStyles:_,children:(0,j.jsx)(Ut,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(Pu,{onLogIn:()=>this.loginViaPopup().catch(L=>T.warn(L.message))})})}),se)}else{let _=this.overlayContainerFactory("deepdesk-tab-completion",x||e,{appendTo:y,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),A=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||e,{appendTo:y},n==null?void 0:n.suggestionsRootNode);(0,we.render)((0,j.jsx)(qt,{store:this.store,customStyles:n,children:(0,j.jsx)(Ut,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(ad,{inputElement:e})})}),_),(0,we.render)((0,j.jsx)(qt,{store:this.store,customStyles:n,children:(0,j.jsx)(Ut,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(Fp,{onLogIn:()=>this.loginViaPopup().catch(O=>T.warn(O.message))})})}),A)}(0,we.render)((0,j.jsx)(qt,{store:this.store,customStyles:n,children:(0,j.jsx)(Ut,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(Cp,{})})}),this.createContainer("deepdesk-overlays"));let b;this.inputMediator.on("selection",_=>{clearTimeout(b),_===null?b=setTimeout(()=>{_!==null&&this.store.dispatch(Hr(_))},500):this.store.dispatch(Hr(_))}),this.inputMediator.on("disabled",()=>{var _;(_=this.inputMediator)==null||_.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{u&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(yo(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(yo(!0))),this.store.dispatch(Wa({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 _;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((_=this.state.conversation.current)==null?void 0:_.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&T.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:n,showImages:s,isEmbedded:r}=o;this.widgetRoot=e,this.configure({showImages:s,isEmbedded:r}),(0,we.render)((0,j.jsx)(qt,{store:this.store,customStyles:n,children:(0,j.jsx)(Ut,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(eu,{onLogIn:()=>this.loginViaPopup().catch(i=>T.warn(i.message))})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setSessionId((i=this.state.conversation.current)==null?void 0:i.sessionId)})}unmountWidget(){this.widgetRoot&&(0,we.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=Tr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){xu(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(mn());let e=St(this.state);e&&(await this.store.dispatch(dn()),this.store.dispatch(Bo({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(){let e=this.state.settings.adminUrl,o=new URL(e),n=await kr(o.origin);return new Promise((s,r)=>{let i=new MessageChannel,a=i.port1,l=new URL(n.config.platform.hasSso?`${e}/platform/sso/`:`${e}/admin/`);l.searchParams.append("redirect","/sdk/popup/close.html");let c=!1,p=()=>{d&&!d.closed&&d.close(),window.removeEventListener("message",u),clearInterval(g)};a.onmessage=async m=>{var f,y;if((f=m.data)!=null&&f.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((y=m.data)==null?void 0:y.jwt),await this.isLoggedIn(),this.broadcastEvents.send(nn),p(),c=!0,i.port1.close(),s()}catch(E){r(E)}};let d=window.open(l.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");d===null&&r(new Error("Popup blocked by browser"));let u=async m=>{var f;if(m.origin===l.origin)switch((f=m.data)==null?void 0:f.type){case"deepdesk-popup-loaded":{d==null||d.postMessage({type:"deepdesk-popup-create-channel"},l.origin,[i.port2]);break}case"deepdesk-popup-error":{p(),m.data.message==="Timeout"&&T.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(m.data.message));break}}};window.addEventListener("message",u);let g=setInterval(()=>{d&&!d.closed||(p(),c||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(p)})}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(T.info("Trial is active"),!await this.deepdeskApi.checkUserExists(e))throw new Error("User is not in trial");this.shouldRender=!0}catch(o){let{message:n}=o;T.info(n),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let o=Gs(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Le()):this.store.dispatch(Pe(n))})}catch(n){this.handleError(n)}}};async function Lu(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 Mu(t,e,o={}){let n=o.replace?Et(t,o.replace.start,o.replace.end):Po(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?Et(t,o.selectionAfter.start,o.selectionAfter.end):(n.collapse(!1),n),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(i)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function
|
|
11
|
-
`).forEach((o,n)=>{n>0&&e.appendChild(document.createElement("br")),e.appendChild(document.createTextNode(o))}),e}function
|
|
9
|
+
c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var la=require("react/jsx-runtime"),fh={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},wu=({className:t,color:e})=>(0,la.jsx)("svg",{className:t,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,la.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:fh[e||"pink"]})});var Tu={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 ca={};W(ca,{enUS:()=>hh,nlNL:()=>yh});var hh={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},yh={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Ru=require("react-redux"),Xt=require("react/jsx-runtime"),Iu=({onLogIn:t})=>{let e=T(ca),o=C("productName"),n=(0,Ru.useDispatch)(),s=(0,ku.useSelector)(ue),r=v("FloatingMenu",Tu);if(s===null)return null;let i=()=>{s===!0?n(Y(!0)):t()};return(0,Xt.jsxs)("button",{className:(0,Eu.default)(r.root,{[r.isLoggedIn]:s,[r.isLoggedOut]:!s}),onClick:i,children:[(0,Xt.jsx)("div",{className:r.text,children:e(s?"search":"signin",{productName:o})}),(0,Xt.jsxs)("div",{className:r.icon,children:[(0,Xt.jsx)(wu,{className:r.logo,color:"pink"}),s===!1&&(0,Xt.jsx)(Cu,{className:r.lock})]})]})};async function Er(t){let o=await new Ne(t).get("/platform/config/",{version:null});return M(o)}var j=require("react/jsx-runtime");var Pu=xu("showTabHint",!0),kn=class t{static version="10.10.2";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new at(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[yu({emit:(d,u,g)=>this.emit(d,u,g),handleAfterSendMessage:d=>this.handleAfterSendMessage(d),handleInputChanged:d=>this.handleInputChanged(d),handleKeyDown:d=>this.handleKeyDown(d),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:d=>this.logSendMessage(d),logSendEditSuggestionMessage:d=>this.logSendEditMessage(d),onUpdateShowTabHint:d=>Pu.update(d),sendEvent:(d,u)=>this.deepdeskApi.sendEvent(d,u)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new En(o)}),this.store=hu(p),this.broadcastEvents=new nu({debug:!0,deepdeskUrl:c,eventMap:Dc(this.store),createCustomChannel:l}),this.store.dispatch(Bo),this.store.dispatch(en(Pu.value())),this.store.dispatch(Bo({locale:s,adminUrl:c,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(E.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(E.warn("Profile has not been loaded (yet)"),!0):(E.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(So(null)),this.store.dispatch(Xe()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();ue(n)&&Ic(n)!=="loading"&&(o(),e())});this.unmountHandlers.push(()=>{o()})})}async isLoggedIn(){return(await this.store.dispatch(Xe())).payload}async setPlatformAgentId(e){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:e}),version:null})}catch(o){E.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(Mr({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(jn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Vn({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Nr(e))).payload}async postMessages(e){return(await this.store.dispatch(Wn(e))).payload}async updateConversation(e){return(await this.store.dispatch(qn(e))).payload}resetConversation(){this.store.dispatch(N()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(Ze());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Bo(e))}setVisitorInfo(e){this.store.dispatch($l(e))}async setAgentInfo(e){await this.store.dispatch(Xo(e))}async setAgentSettings(e){await this.store.dispatch(ui(e))}async getAgentSettings(){return(await this.store.dispatch(gi())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(Os()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Jn(e))}notifyKeyDown(e){this.store.dispatch(Qn(e))}notifyPaste(e,o){this.store.dispatch(Ja({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Qa(e))}notifyExternalSuggestion(e){this.store.dispatch(ke(e)),this.store.dispatch(je())}notifyEditSuggestion(e){this.store.dispatch(gc(e.contentType,e.suggestions)),this.store.dispatch($e({contentType:e.contentType,suggestion:typeof e.index=="number"?e.suggestions[e.index]:null}))}handleInputChanged(e){let{overlayCollapsed:o,openOverlayWhenTyping:n}=this.state.ui;o&&n&&this.store.dispatch(yt({collapse:!1})),this.inputMediator&&this.store.dispatch(Va({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(He([])))}handleKeyDown(e){let{overlayCollapsed:o}=this.state.ui,{textSuggestions:n,selectedSuggestionIndex:s,selection:r}=this.state.input,{inlineSuggestions:i}=this.state.settings,a=n.length>0,l=s!==-1;if(this.store.dispatch(Za($n(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(Ga()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Xa());let{selectedSuggestionIndex:d}=this.state.input;e.preventDefault(),!i&&(d===-1?this.store.dispatch(Fo()):this.stageSelectedSuggestion({inputType:"arrow"}))};switch(e.key){case"Up":case"ArrowUp":i?p():c();return;case"Down":case"ArrowDown":{i?c():p();return}case"Esc":case"Escape":{i&&l&&this.store.dispatch(ut(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(ut(-1)),this.store.dispatch(Fo()),e.preventDefault()):o||(this.store.dispatch(yt({collapse:!0})),this.store.dispatch(wc(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:d}=this.state.input,u=d.text.substring(0,d.selection.end),{tabCompletionSuggestion:g}=this.state.input;this.store.dispatch(en(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&g&&g.text.startsWith(u)&&(this.store.dispatch(ke({text:g.text,suggestion:g,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(Ya()),this.store.dispatch(He([]))}handlingTimeStart(){this.state.handlingTime.startTime||(E.info("Start handling time"),this.store.dispatch(au()))}handlingTimeStop(){this.state.handlingTime.startTime&&(E.info("Stop handling time"),this.store.dispatch(Sr()))}logSendMessage(e){let o=ia("input",this.state,{version:this.version});e&&(Object.assign(o,{text:e}),Object.assign(o,{lenTextTotal:e.length})),this.deepdeskApi.sendEventV1("Send Message",o),this.emit("send-message-event",o)}logSendEditMessage(e){let o=ia("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(Wa(this.state.overlayInput.metrics))}logHandlingTime(){let e=vu(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(lu())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(je()),this.store.dispatch(Pt(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(ke({text:n[o].text,suggestion:n[o],eventMetrics:e,replace:"until-selection-end"}))}emit(e,o,n={}){let s=()=>{this.eventListeners[e]&&this.eventListeners[e].forEach(r=>{try{r(o)}catch(i){E.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),E.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=Mt(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,we.unmountComponentAtNode)(r),i(),r.remove()}),r}createInlineContainer(e,o){var i;let n=document.createElement("div");n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.style.height="0px",n.style.width="0px";let s=document.createElement("div");s.style.display="none",s.style.position="absolute",s.style.height="0px",s.style.width="0px",s.style.backgroundColor="red",n.appendChild(s);let r=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;if(r){let[a,l]=Mt(r,{appendTo:document.body,onMoveStart:()=>{s.style.display="none"}});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{(0,we.unmountComponentAtNode)(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Lt(s),s.dataset.testid=e,s.style.color=n.color,s.style.fontSize=n.fontSize,s.style.fontFamily=n.fontFamily,s.style.fontVariant=n.fontVariant,s.setAttribute("translate","no"),o.appendChild(s),this.unmountHandlers.push(()=>{(0,we.unmountComponentAtNode)(s),s.remove()}),s}storeMetrics(){try{let e=`dd-metrics-${this.conversationId()}`,o=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(e,o),E.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()?(E.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(tl(n.metrics))):E.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(!Cr(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:n={},showStyleSuggestions:s,showTabCompletion:r,showTextSuggestions:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,isEmbedded:d,detectSubmit:u,insertLink:g,inputMediator:m,closestScrollSelector:f,appendOverlayTo:h,inlineSuggestions:w,floatingMenu:y}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:g,isEmbedded:d,inlineSuggestions:w,floatingMenu:!!y}),o.automaticHandlingTime&&this.setupHandlingTime(e),Lt(e),this.inputMediator=m||(xt(e)?new We(e):new Gt(e)),this.inputMediator.on("change",({plainText:_})=>{this.notifyInputChanged(_)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(el({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",_=>{this.notifyKeyDown(_)}),this.inputMediator.on("paste",({pastedText:_,selectionText:A})=>{this.notifyPaste(_,A)}),this.inputMediator.on("cut",({selectionText:_})=>{this.notifyCut(_)});let x=f&&Su(e,f)||void 0;if(w){let{customStyles:_,appendOverlayTo:A}=o;if(xt(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let O=this.createInlineContainer(e,"deepdesk-caret");(0,we.render)((0,j.jsx)(qt,{store:this.store,customStyles:_,children:(0,j.jsx)(Ut,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(Ip,{})})}),O),this.inputMediator.on("caret",L=>{this.store.dispatch(He([])),L?(O.style.display="block",O.style.top=`${L.top}px`,O.style.left=`${L.left}px`):O.style.display="none"});let se=this.overlayContainerFactory("floating-menu",x||e,{appendTo:typeof y=="object"&&"appendOverlayTo"in y?y.appendOverlayTo:A},_==null?void 0:_.floatingMenuRootNode);(0,we.render)((0,j.jsx)(qt,{store:this.store,customStyles:_,children:(0,j.jsx)(Ut,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(Iu,{onLogIn:()=>this.loginViaPopup().catch(L=>E.warn(L.message))})})}),se)}else{let _=this.overlayContainerFactory("deepdesk-tab-completion",x||e,{appendTo:h,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),A=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||e,{appendTo:h},n==null?void 0:n.suggestionsRootNode);(0,we.render)((0,j.jsx)(qt,{store:this.store,customStyles:n,children:(0,j.jsx)(Ut,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(id,{inputElement:e})})}),_),(0,we.render)((0,j.jsx)(qt,{store:this.store,customStyles:n,children:(0,j.jsx)(Ut,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(Bp,{onLogIn:()=>this.loginViaPopup().catch(O=>E.warn(O.message))})})}),A)}(0,we.render)((0,j.jsx)(qt,{store:this.store,customStyles:n,children:(0,j.jsx)(Ut,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(bp,{})})}),this.createContainer("deepdesk-overlays"));let b;this.inputMediator.on("selection",_=>{clearTimeout(b),_===null?b=setTimeout(()=>{_!==null&&this.store.dispatch(Dr(_))},500):this.store.dispatch(Dr(_))}),this.inputMediator.on("disabled",()=>{var _;(_=this.inputMediator)==null||_.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{u&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(yo(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(yo(!0))),this.store.dispatch(qa({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 _;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((_=this.state.conversation.current)==null?void 0:_.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&E.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:n,showImages:s,isEmbedded:r}=o;this.widgetRoot=e,this.configure({showImages:s,isEmbedded:r}),(0,we.render)((0,j.jsx)(qt,{store:this.store,customStyles:n,children:(0,j.jsx)(Ut,{broadcastEvents:this.broadcastEvents,children:(0,j.jsx)(Yd,{onLogIn:()=>this.loginViaPopup().catch(i=>E.warn(i.message))})})}),e),this.whenConversationLoaded(()=>{var i;this.broadcastEvents.setSessionId((i=this.state.conversation.current)==null?void 0:i.sessionId)})}unmountWidget(){this.widgetRoot&&(0,we.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=wr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){_u(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(mn());let e=St(this.state);e&&(await this.store.dispatch(dn()),this.store.dispatch(Bo({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(){let e=this.state.settings.adminUrl,o=new URL(e),n=await Er(o.origin);return new Promise((s,r)=>{let i=new MessageChannel,a=i.port1,l=new URL(n.config.platform.hasSso?`${e}/platform/sso/`:`${e}/admin/`);l.searchParams.append("redirect","/sdk/popup/close.html");let c=!1,p=()=>{d&&!d.closed&&d.close(),window.removeEventListener("message",u),clearInterval(g)};a.onmessage=async m=>{var f,h;if((f=m.data)!=null&&f.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((h=m.data)==null?void 0:h.jwt),await this.isLoggedIn(),this.broadcastEvents.send(nn),p(),c=!0,i.port1.close(),s()}catch(w){r(w)}};let d=window.open(l.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");d===null&&r(new Error("Popup blocked by browser"));let u=async m=>{var f;if(m.origin===l.origin)switch((f=m.data)==null?void 0:f.type){case"deepdesk-popup-loaded":{d==null||d.postMessage({type:"deepdesk-popup-create-channel"},l.origin,[i.port2]);break}case"deepdesk-popup-error":{p(),m.data.message==="Timeout"&&E.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(m.data.message));break}}};window.addEventListener("message",u);let g=setInterval(()=>{d&&!d.closed||(p(),c||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(p)})}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(E.info("Trial is active"),!await this.deepdeskApi.checkUserExists(e))throw new Error("User is not in trial");this.shouldRender=!0}catch(o){let{message:n}=o;E.info(n),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let o=Ws(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Le()):this.store.dispatch(Pe(n))})}catch(n){this.handleError(n)}}};async function Au(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 Lu(t,e,o={}){let n=o.replace?Et(t,o.replace.start,o.replace.end):Po(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?Et(t,o.selectionAfter.start,o.selectionAfter.end):(n.collapse(!1),n),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(i)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function vh(t){let e=document.createElement("template");return e.innerHTML=t,e.content}function Sh(t){let e=document.createDocumentFragment();return t.split(`
|
|
11
|
+
`).forEach((o,n)=>{n>0&&e.appendChild(document.createElement("br")),e.appendChild(document.createTextNode(o))}),e}function Mu(t,e){return!t.contains(e)||e===t?null:e.parentNode===t?e:Mu(t,e.parentNode)}async function Nu(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?vh(e):Sh(e);if(o){let p=Mu(t,l.startContainer)??t.firstChild;t.insertBefore(c,(p==null?void 0:p.nextSibling)??null)}else l.insertNode(c),l.collapse(!1)};return Promise.resolve(r()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!s)try{s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function Ou(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function Du(t,e,o){await new at(t).authenticateWithKey(e,o)}async function _h(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 Hu(t,e){let o=await _h(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,isSupportedInputElement,updateContentEditable,updateTextArea,useStyles,waitForElementVisibilityChange});
|