@deepdesk/deepdesk-sdk 16.0.2-beta.2 → 16.0.2-beta.3

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.
@@ -11,9 +11,9 @@ The error may be correlated with this previous error:
11
11
  ${fe.current.stack}
12
12
 
13
13
  `),ye}ta(()=>{fe.current=void 0,V.current=void 0,H.current=ie});let oe=Ie.useMemo(()=>Ie.createElement(g,Fo({},ie,{ref:L})),[L,g,ie]);return Ie.useMemo(()=>y?Ie.createElement(D.Provider,{value:N},oe):oe,[D,oe,N])}let E=Ie.memo(w);if(E.WrappedComponent=g,E.displayName=w.displayName=v,l){let I=Ie.forwardRef(function(G,D){return Ie.createElement(E,Fo({},G,{reactReduxForwardedRef:D}))});return I.displayName=v,I.WrappedComponent=g,(0,Zy.default)(I,g)}return(0,Zy.default)(E,g)}}var wi=JN;var tu=S($());function e2({store:e,context:t,children:n,serverState:r,stabilityCheck:o="once",noopCheck:i="once"}){let s=tu.useMemo(()=>{let u=If(e);return{store:e,subscription:u,getServerState:r?()=>r:void 0,stabilityCheck:o,noopCheck:i}},[e,r,o,i]),a=tu.useMemo(()=>e.getState(),[e]);return ta(()=>{let{subscription:u}=s;return u.onStateChange=u.notifyNestedSubs,u.trySubscribe(),a!==e.getState()&&u.notifyNestedSubs(),()=>{u.tryUnsubscribe(),u.onStateChange=void 0}},[s,a]),tu.createElement((t||At).Provider,{value:s},n)}var Jy=e2;function Of(e=At){let t=e===At?sf:Jl(e);return function(){let{store:r}=t();return r}}var ev=Of();function XE(e=At){let t=e===At?ev:Of(e);return function(){return t().dispatch}}var he=XE();TE(ZE.useSyncExternalStoreWithSelector);YE(QE.useSyncExternalStore);vE(jy.unstable_batchedUpdates);var nu=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(nu||{});var t2={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!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,detectSubmit:!1,automaticHandlingTime:!1,enableSuggestionFeedback:!1,enableFeedbackForm:!1,adminUrl:void 0,productName:"Deepdesk",hasKeyboardInput:!0},JE=Ce({name:"settings",initialState:t2,reducers:{set(e,t){Object.entries(t.payload).forEach(n=>{let[r,o]=n;typeof o!="undefined"&&(e[r]=o)})}}}),{set:Mf}=JE.actions,ru=e=>t=>t.settings[e],J=e=>K(ru(e)),eT=JE.reducer;var n2={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},zt=e=>e.auth.isLoggedIn,tT=e=>e.auth.loginFetchState,nT=e=>e.auth.verifyFetchState,rT=e=>e.auth.showLoginOverlay,jr=ge("auth/validate",(e,t)=>A(void 0,null,function*(){return t.extra.deepdeskAPI.isLoggedIn()})),oT=ge("auth/requestLogin",(n,r)=>A(void 0,[n,r],function*({email:e},t){let{deepdeskAPI:o}=t.extra;return o.requestLoginByEmail(e)})),ou=ge("auth/verifyLoginToken",(n,r)=>A(void 0,[n,r],function*({token:e},t){let{deepdeskAPI:o}=t.extra;return o.verifyLoginToken(e)})),iT=Ce({name:"auth",initialState:n2,reducers:{setIsLoggedIn(e,t){e.isLoggedIn=t.payload},setShowLoginOverlay(e,t){e.showLoginOverlay=t.payload}},extraReducers:e=>{e.addCase(jr.pending,t=>{t.loginFetchState="loading"}),e.addCase(jr.fulfilled,(t,{payload:n})=>{t.isLoggedIn=n,t.loginFetchState="done"}),e.addCase(jr.rejected,t=>{t.loginFetchState="error",t.isLoggedIn=!1}),e.addCase(ou.pending,t=>{t.verifyFetchState="loading"}),e.addCase(ou.rejected,t=>{t.verifyFetchState="error"}),e.addCase(ou.fulfilled,(t,n)=>{n.payload.isLoggedIn?t.verifyFetchState="done":t.verifyFetchState="error"})}}),{setIsLoggedIn:ra,setShowLoginOverlay:sT}=iT.actions,aT=iT.reducer;function Vr(){}Vr.prototype={diff:function(t,n){var r,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=o.callback;typeof o=="function"&&(i=o,o={}),this.options=o;var s=this;function a(w){return i?(setTimeout(function(){i(void 0,w)},0),!0):w}t=this.castInput(t),n=this.castInput(n),t=this.removeEmpty(this.tokenize(t)),n=this.removeEmpty(this.tokenize(n));var l=n.length,u=t.length,c=1,f=l+u;o.maxEditLength&&(f=Math.min(f,o.maxEditLength));var d=(r=o.timeout)!==null&&r!==void 0?r:1/0,p=Date.now()+d,y=[{oldPos:-1,lastComponent:void 0}],h=this.extractCommon(y[0],n,t,0);if(y[0].oldPos+1>=u&&h+1>=l)return a([{value:this.join(n),count:n.length}]);var g=-1/0,m=1/0;function v(){for(var w=Math.max(g,-c);w<=Math.min(m,c);w+=2){var C=void 0,E=y[w-1],k=y[w+1];E&&(y[w-1]=void 0);var I=!1;if(k){var L=k.oldPos-w;I=k&&0<=L&&L<l}var G=E&&E.oldPos+1<u;if(!I&&!G){y[w]=void 0;continue}if(!G||I&&E.oldPos+1<k.oldPos?C=s.addToPath(k,!0,void 0,0):C=s.addToPath(E,void 0,!0,1),h=s.extractCommon(C,n,t,w),C.oldPos+1>=u&&h+1>=l)return a(r2(s,C.lastComponent,n,t,s.useLongestToken));y[w]=C,C.oldPos+1>=u&&(m=Math.min(m,w-1)),h+1>=l&&(g=Math.max(g,w+1))}c++}if(i)(function w(){setTimeout(function(){if(c>f||Date.now()>p)return i();v()||w()},0)})();else for(;c<=f&&Date.now()<=p;){var x=v();if(x)return x}},addToPath:function(t,n,r,o){var i=t.lastComponent;return i&&i.added===n&&i.removed===r?{oldPos:t.oldPos+o,lastComponent:{count:i.count+1,added:n,removed:r,previousComponent:i.previousComponent}}:{oldPos:t.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:i}}},extractCommon:function(t,n,r,o){for(var i=n.length,s=r.length,a=t.oldPos,l=a-o,u=0;l+1<i&&a+1<s&&this.equals(n[l+1],r[a+1]);)l++,a++,u++;return u&&(t.lastComponent={count:u,previousComponent:t.lastComponent}),t.oldPos=a,l},equals:function(t,n){return this.options.comparator?this.options.comparator(t,n):t===n||this.options.ignoreCase&&t.toLowerCase()===n.toLowerCase()},removeEmpty:function(t){for(var n=[],r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n},castInput:function(t){return t},tokenize:function(t){return t.split("")},join:function(t){return t.join("")}};function r2(e,t,n,r,o){for(var i=[],s;t;)i.push(t),s=t.previousComponent,delete t.previousComponent,t=s;i.reverse();for(var a=0,l=i.length,u=0,c=0;a<l;a++){var f=i[a];if(f.removed){if(f.value=e.join(r.slice(c,c+f.count)),c+=f.count,a&&i[a-1].added){var p=i[a-1];i[a-1]=i[a],i[a]=p}}else{if(!f.added&&o){var d=n.slice(u,u+f.count);d=d.map(function(h,g){var m=r[c+g];return m.length>h.length?m:h}),f.value=e.join(d)}else f.value=e.join(n.slice(u,u+f.count));u+=f.count,f.added||(c+=f.count)}}var y=i[l-1];return l>1&&typeof y.value=="string"&&(y.added||y.removed)&&e.equals("",y.value)&&(i[l-2].value+=y.value,i.pop()),i}var o2=new Vr;function cT(e,t,n){return o2.diff(e,t,n)}var lT=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,uT=/\S/,dT=new Vr;dT.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!uT.test(e)&&!uT.test(t)};dT.tokenize=function(e){for(var t=e.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),n=0;n<t.length-1;n++)!t[n+1]&&t[n+2]&&lT.test(t[n])&&lT.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var fT=new Vr;fT.tokenize=function(e){this.options.stripTrailingCr&&(e=e.replace(/\r\n/g,`
14
- `));var t=[],n=e.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(var r=0;r<n.length;r++){var o=n[r];r%2&&!this.options.newlineIsToken?t[t.length-1]+=o:(this.options.ignoreWhitespace&&(o=o.trim()),t.push(o))}return t};var i2=new Vr;i2.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var s2=new Vr;s2.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function Nf(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Nf=function(t){return typeof t}:Nf=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Nf(e)}var a2=Object.prototype.toString,iu=new Vr;iu.useLongestToken=!0;iu.tokenize=fT.tokenize;iu.castInput=function(e){var t=this.options,n=t.undefinedReplacement,r=t.stringifyReplacer,o=r===void 0?function(i,s){return typeof s=="undefined"?n:s}:r;return typeof e=="string"?e:JSON.stringify(tv(e,null,null,o),o," ")};iu.equals=function(e,t){return Vr.prototype.equals.call(iu,e.replace(/,([\r\n])/g,"$1"),t.replace(/,([\r\n])/g,"$1"))};function tv(e,t,n,r,o){t=t||[],n=n||[],r&&(e=r(o,e));var i;for(i=0;i<t.length;i+=1)if(t[i]===e)return n[i];var s;if(a2.call(e)==="[object Array]"){for(t.push(e),s=new Array(e.length),n.push(s),i=0;i<e.length;i+=1)s[i]=tv(e[i],t,n,r,o);return t.pop(),n.pop(),s}if(e&&e.toJSON&&(e=e.toJSON()),Nf(e)==="object"&&e!==null){t.push(e),s={},n.push(s);var a=[],l;for(l in e)e.hasOwnProperty(l)&&a.push(l);for(a.sort(),i=0;i<a.length;i+=1)l=a[i],s[l]=tv(e[l],t,n,r,l);t.pop(),n.pop()}else s=e;return s}var nv=new Vr;nv.tokenize=function(e){return e.slice()};nv.join=nv.removeEmpty=function(e){return e};function pT(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function Ho(e,t,n=10){let r=typeof e,o=typeof t;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return r!==o?!1:e==null||r==="string"||r==="number"||r==="boolean"?e===t:Array.isArray(e)&&Array.isArray(t)?e.length!==t.length?!1:e.every((i,s)=>Ho(i,t[s],n-1)):pT(e)&&pT(t)?Object.keys(e).length!==Object.keys(t).length?!1:Object.keys(e).every(s=>Ho(e[s],t[s],n-1)):!1}function l2(e){return Math.max(...e.map(t=>t.length))}function u2(e,t){let n=e.reduce((r,o)=>{if(o){let i=r[o]?r[o]+1:1;return P(b({},r),{[o]:i})}return r},{});return Object.keys(n).reduce((r,o)=>(n[o]<t&&r.push(o),r),[])}function mT(e,t){let r=[...e.map(({text:o})=>o.split(/\b(\w+)\b/))];for(let o=0;o<l2(r);o++){let i=u2(r.map(a=>a[o]),t),s=r.filter(a=>!i.includes(a[o]));if(s.length>=t)r=s;else return{text:r[0].slice(0,o).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var c2=2;function gT(e,t=""){if(e.length===0)return;if(e.length===1)return e[0];let n=mT(e,c2);return n&&n.text!==t?n:e[0]}var d2={info(...e){console.info("[Deepdesk]",...e)},warn(...e){console.warn("[Deepdesk]",...e)},error(...e){console.error("[Deepdesk]",...e)}},ee=d2;var hT={current:null,isSupported:null},it=ot("resetConversation"),yT=e=>{let{current:t}=e.conversation;return(t==null?void 0:t.sessionId)||null},yr=e=>{let{current:t}=e.conversation;return(t==null?void 0:t.id)||null},oa=e=>e.conversation.isSupported,rv=ge("conversation/isSupported",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.isConversationSupported(e.sessionId,e.options)}),_f=ge("conversation/create",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.createConversation(e)}),Df=ge("conversation/bySessionId",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.getConversationBySessionId(e.sessionId,e.options)}),Ff=ge("conversation/update",(e,t)=>{let{deepdeskAPI:n}=t.extra,r=yr(t.getState());if(!r)throw new Error("No current conversation to update");return n.updateConversation(r,e)}),ov=ge("conversation/upsert",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.getConversationBySessionId(e.sessionId).catch(()=>null).then(r=>{if(!r)return n.createConversation(e);let{agentId:o,agentName:i,agentEmail:s,agentNickname:a,tags:l}=e;return n.updateConversation(r.id,{agentId:o,agentEmail:s,agentName:i,agentNickname:a,tags:l})})}),Hf=ge("conversation/postMessages",(e,t)=>{let{deepdeskAPI:n}=t.extra,r=yr(t.getState());if(!r)throw new Error("No current conversation to update messages");return n.postMessages(r,e.map(o=>b({},o)))}),f2=[_f.rejected,Df.rejected,Ff.rejected,Hf.rejected].map(e=>e==null?void 0:e.toString()),p2=Ce({name:"conversation",initialState:hT,reducers:{},extraReducers:e=>{e.addCase(rv.fulfilled,(t,n)=>{t.isSupported=n.payload}).addCase(_f.fulfilled,(t,n)=>{var r,o;t.current=n.payload,t.isSupported=(o=(r=n.payload)==null?void 0:r.hasActiveProfile)!=null?o:null}).addCase(Df.fulfilled,(t,n)=>{var r,o;t.current=n.payload,t.isSupported=(o=(r=n.payload)==null?void 0:r.hasActiveProfile)!=null?o:null}).addCase(ov.fulfilled,(t,n)=>{var r,o;t.current=n.payload,t.isSupported=(o=(r=n.payload)==null?void 0:r.hasActiveProfile)!=null?o:null}).addCase(Ff.fulfilled,(t,n)=>{var r,o;t.current=n.payload,t.isSupported=(o=(r=n.payload)==null?void 0:r.hasActiveProfile)!=null?o:null}).addCase(Hf.fulfilled,(t,n)=>{t.current&&(t.current.messages=n.payload)}).addCase(it,()=>hT).addMatcher(t=>f2.includes(t.type),(t,n)=>{var r;throw ee.info("Conversation action rejected",n.type,((r=n.error)==null?void 0:r.message)||"No message"),new Error(n.error.message)})}}),vT=p2.reducer;var Si={text:"",html:null,selection:{start:0,end:0},beforeInputChange:null,mixedSuggestion: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 iv(e){let{key:t,shiftKey:n,ctrlKey:r,metaKey:o,altKey:i}=e;return{key:t,shiftKey:n,ctrlKey:r,metaKey:o,altKey:i}}var zf=ot("input/replaceText"),bi=ot("input/sendMessage"),Bf=ot("input/applyImageSuggestion"),Wr=ot("input/sendEvent"),xT=Ce({name:"input",initialState:Si,reducers:{setInput(e,t){var i,s;let{beforeInputChange:n}=e,{text:r,html:o}=t.payload;if(e.text=r,e.html=o!=null?o:null,r==="")e.metrics=Si.metrics,e.textSuggestions=[],e.mixedSuggestion=null;else if(n!==null&&e.text!==n.text){let{key:a,shiftKey:l,ctrlKey:u,metaKey:c,altKey:f}=n.keyDown;switch(a){case"Enter":l&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:d}=e,p=cT(n.text,d);n.text.length-d.length>1&&e.metrics.deletions.push(...p.filter(y=>y.removed).map(y=>y.value)),e.metrics.numCharsDeleted+=n.text.length-d.length;break}case"Shift":case"Meta":case"Tab":break;case"C":case"V":case"X":case"c":case"v":case"x":if(u||c)break;default:if(!u&&!c&&!f){e.metrics.numCharsTyped+=1;let d=((i=n.selection)==null?void 0:i.start)!==void 0&&((s=n.selection)==null?void 0:s.end)!==void 0?n.text.substring(n.selection.start,n.selection.end):null;d&&d.length>0&&(e.metrics.numCharsDeleted+=d.length,e.metrics.deletions.push(d))}}e.metrics.agentStartedTypingTimestamp||(e.metrics.agentStartedTypingTimestamp=Date.now())}e.beforeInputChange=null},setSelection(e,t){t.payload!==null&&(Ho(e.selection,t.payload)||(e.selection=t.payload))},commitSuggestion(e,t){let n=t.payload,{text:r,suggestion:{source:o,abVariant:i,abTestName:s,trainingJobs:a,sourceText:l,searchTerm:u,text:c},eventMetrics:{inputType:f},replace:d}=n,p=o==="search"||o==="personal-collection-search",y=r.slice(e.text.substring(0,e.selection.start).length);(p||d==="selection")&&(y=r),n.suggestion.source==="search-overlay"&&(y=c),e.metrics.textSuggestions.push({text:y,source:o,abVariant:i,abTestName:s,inputType:f,sourceText:l,trainingJobs:a||[],searchTerm:p?e.text:u}),e.textSuggestions=[],e.selectedSuggestionIndex=-1},offeredTextSuggestion(e,t){let{text:n,suggestion:{source:r}}=t.payload;e.metrics.offeredTextSuggestions.find(i=>i.text===n)||e.metrics.offeredTextSuggestions.push({text:n,source:r})},registerKeyDown(e,t){let{key:n}=t.payload;["Control","Meta","Shift","Alt"].includes(n)||(e.beforeInputChange={text:e.text,selection:e.selection,keyDown:t.payload})},registerKeyUp(e,t){},registerCut(e,t){let{metrics:n}=e,r=t.payload;e.metrics=P(b({},e.metrics),{numCharsCut:n.numCharsCut+r.length,cuts:[...n.cuts,r]})},registerPaste(e,t){let{metrics:n}=e,{text:r,selectionText:o}=t.payload,i=n.numCharsDeleted+(o!=null&&o.length?o.length:0),s=o!=null&&o.length?[...n.deletions,o]:n.deletions;e.metrics=P(b({},e.metrics),{numCharsDeleted:i,deletions:s,numCharsPasted:n.numCharsPasted+r.length,numPaste:n.numPaste+1,pastes:[...n.pastes,r]})},selectNextTextSuggestion(e){let t=e.textSuggestions.length;e.selectedSuggestionIndex=e.selectedSuggestionIndex<t-1?e.selectedSuggestionIndex+1:e.selectedSuggestionIndex},selectPreviousTextSuggestion(e){e.selectedSuggestionIndex=e.selectedSuggestionIndex>=0?e.selectedSuggestionIndex-1:e.selectedSuggestionIndex},selectTextSuggestionByIndex(e,t){e.selectedSuggestionIndex=t.payload},setTextSuggestions(e,t){if(e.selectedSuggestionIndex=-1,e.textSuggestions=t.payload,t.payload.length===0){e.mixedSuggestion=null;return}let n=e.text.substring(0,e.selection.end),r=gT(t.payload,n);e.mixedSuggestion=r!=null&&r.text.includes(n)?r:null},setMetrics(e,{payload:t}){e.metrics=t},resetMetrics(e){e.metrics=Si.metrics}},extraReducers:e=>{e.addCase(it,t=>{t.mixedSuggestion=Si.mixedSuggestion,t.textSuggestions=Si.textSuggestions,t.selectedSuggestionIndex=Si.selectedSuggestionIndex,t.metrics=Si.metrics})}}),ia=e=>e.input.text.substring(0,e.input.selection.end),m2=e=>e.input.selection,sa=e=>{let{mixedSuggestion:t,selectedSuggestionIndex:n,textSuggestions:r}=e.input;return n>-1?r[n]:t},wT=()=>K(m2),{commitSuggestion:jn,offeredTextSuggestion:ST,registerCut:bT,registerKeyDown:ET,registerKeyUp:TT,registerPaste:CT,selectNextTextSuggestion:kT,selectPreviousTextSuggestion:RT,selectTextSuggestionByIndex:Uf,setInput:jf,setMetrics:PT,setSelection:Vf,setTextSuggestions:zo,resetMetrics:AT}=xT.actions,IT=xT.reducer;function LT(e){try{return Intl.DateTimeFormat(void 0,{timeZone:e}),!0}catch(t){return!1}}var g2={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,platformVariables:void 0,fetchState:"idle"},aa=e=>{var t;return(t=e.info.agentInfo)!=null?t:null},OT=e=>{var t;return(t=e.info.visitorInfo)!=null?t:null},MT=e=>{var t;return(t=e.info.customData)!=null?t:null},au=({info:{visitorInfo:e,agentInfo:t}})=>{var n,r;return{timezone:e!=null&&e.visitorTimeZone&&LT(e.visitorTimeZone)?e.visitorTimeZone:Dw,agentName:(n=t==null?void 0:t.agentNickname)!=null?n:"",visitorName:(r=e==null?void 0:e.visitorName)!=null?r:""}},h2=[["agentNickname","nickname"],["agentDefaultLocale","defaultLocale"],["agentEmail","email"]],su=ge("info/setAgentInfo",(e,t)=>A(void 0,null,function*(){var i,s,a;let{deepdeskAPI:n}=t.extra,r=yield n.getMe(),o=[];if(e.agentId&&e.skipSync!==!0&&o.push(n.postIdentity({externalId:e.agentId})),e.skipSync!==!0){let l=h2.reduce((u,[c,f])=>!r[f]&&c in e?P(b({},u),{[f]:e[c]}):u,{});Object.keys(l).length>0&&o.push(n.patchMe(l).then(u=>r=u))}return o.length>0&&(yield Promise.all(o)),{agentId:e.agentId,agentName:e.agentName,agentNickname:(i=r.nickname)!=null?i:e.agentNickname,agentEmail:(s=r.email)!=null?s:e.agentEmail,agentDefaultLocale:(a=r.defaultLocale)!=null?a:e.agentDefaultLocale,agentTimeZone:e.agentTimeZone}})),sv=ge("info/setAgentSettings",(e,t)=>A(void 0,null,function*(){let{deepdeskAPI:n}=t.extra,r=yield n.getMe(),o=b(b({},typeof r.uiConfig=="object"?r.uiConfig:{}),e);return yield n.patchMe({uiConfig:o}),o})),av=ge("info/getAgentSettings",(e,t)=>A(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return(yield n.getMe()).uiConfig})),NT=Ce({name:"info",initialState:g2,reducers:{setVisitorInfo(e,t){e.visitorInfo=b(b({},e.visitorInfo),t.payload)},setCustomData(e,t){e.customData=t.payload},setPlatformVariables(e,t){e.platformVariables=t.payload}},extraReducers:e=>{e.addCase(su.pending,(t,n)=>{t.fetchState="loading",t.agentInfo=b(b({},t.agentInfo),n.meta.arg)}).addCase(su.rejected,t=>{t.fetchState="error"}).addCase(su.fulfilled,(t,n)=>{t.fetchState="done",t.agentInfo=n.payload}).addCase(sv.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(av.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(it,t=>{t.visitorInfo=void 0})}}),{setVisitorInfo:_T,setCustomData:DT,setPlatformVariables:FT}=NT.actions,HT=NT.reducer;function rn(e,t){return Object.entries(t).reduce((n,[r,o])=>n.replaceAll(r,o),e)}var Wf={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},zT=e=>e.search.isOpen,BT=e=>e.search.page,lv=e=>e.search.list,UT=e=>e.search.aggregates,y2=Un([lv,(e,t)=>t],(e,t)=>e.filter(n=>n.type===t)),jT=e=>t=>y2(t,e),Ei=ge("search/getAll",(e,t)=>A(void 0,null,function*(){var l;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(l=r.conversation.current)==null?void 0:l.profileCode,{platformVariables:i}=r.info;if(!o)throw new Error("Profile should be provided in order to be able to search");let{results:s,aggregates:a}=yield n.search({profile:o,query:e.query,tags:e.tags,size:e.size,current:e.current,filters:{type:e.type},params:au(r)});return{results:s.map(u=>P(b(b({},u),u.title&&i?{title:rn(u.title,i)}:{}),{text:rn(u.text,i!=null?i:{}),source:`search-${u.type.toLowerCase()}`,searchTerm:e.query})),aggregates:a}})),VT=Ce({name:"search",initialState:Wf,reducers:{setIsOpen(e,t){e.isOpen=t.payload},setPage(e,t){e.page=t.payload},resetSearch(e){e.fetchState=Wf.fetchState,e.list=Wf.list}},extraReducers:e=>{e.addCase(Ei.pending,t=>{t.fetchState="loading"}).addCase(Ei.rejected,(t,n)=>{t.fetchState="error",ee.error(n.error)}).addCase(Ei.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload.results,t.aggregates=n.payload.aggregates||{}}).addCase(it,()=>Wf)}}),{resetSearch:Kf,setIsOpen:An,setPage:Kr}=VT.actions,WT=VT.reducer;var uv="SetOutputs",la="ShowLoginOverlay",lu="UserLoggedIn",v2="UserLoggedOut",vr="ApplySuggestion",cv="ApplyImageSuggestion",x2="ShowCommandPalette",w2=e=>({[uv]:t=>{e.dispatch(P(b({},t),{isBroadcasted:!0}))},[x2]:t=>{e.dispatch(An(t.isOpen)),t.page&&e.dispatch(Kr(t.page))},[la]:t=>{e.dispatch(sT(t))},[lu]:()=>{e.dispatch(jr())},[v2]:()=>{e.dispatch(jr())},[cv]:t=>{e.dispatch(Bf({suggestion:t.suggestion}))},[vr]:t=>{e.dispatch(jn(P(b({},t),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),KT=w2;var uu=S($()),qT=S(R()),$T=uu.default.createContext(null),Bo=({broadcastEvents:e,children:t})=>{let n=uu.default.useMemo(()=>e,[]);return(0,qT.jsx)($T.Provider,{value:n,children:t})},on=()=>{let e=(0,uu.useContext)($T);if(!e)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return e};var np=S(Fe()),Vn=S($());var Jf=S($());var dv=function(e,t){return dv=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},dv(e,t)};function cu(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");dv(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var pn=function(){return pn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},pn.apply(this,arguments)};function GT(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function $f(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}function qf(e,t){var n=t&&t.cache?t.cache:R2,r=t&&t.serializer?t.serializer:C2,o=t&&t.strategy?t.strategy:b2;return o(e,{cache:n,serializer:r})}function S2(e){return e==null||typeof e=="number"||typeof e=="boolean"}function YT(e,t,n,r){var o=S2(r)?r:n(r),i=t.get(o);return typeof i=="undefined"&&(i=e.call(this,r),t.set(o,i)),i}function XT(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=n(r),i=t.get(o);return typeof i=="undefined"&&(i=e.apply(this,r),t.set(o,i)),i}function fv(e,t,n,r,o){return n.bind(t,e,r,o)}function b2(e,t){var n=e.length===1?YT:XT;return fv(e,this,n,t.cache.create(),t.serializer)}function E2(e,t){return fv(e,this,XT,t.cache.create(),t.serializer)}function T2(e,t){return fv(e,this,YT,t.cache.create(),t.serializer)}var C2=function(){return JSON.stringify(arguments)},k2=function(){function e(){this.cache=Object.create(null)}return e.prototype.get=function(t){return this.cache[t]},e.prototype.set=function(t,n){this.cache[t]=n},e}(),R2={create:function(){return new k2}},Gf={variadic:E2,monadic:T2};var Yf;(function(e){e[e.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",e[e.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",e[e.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",e[e.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",e[e.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",e[e.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",e[e.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",e[e.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",e[e.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",e[e.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",e[e.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",e[e.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",e[e.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",e[e.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",e[e.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",e[e.INVALID_TAG=23]="INVALID_TAG",e[e.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",e[e.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",e[e.UNCLOSED_TAG=27]="UNCLOSED_TAG"})(Yf||(Yf={}));var Xf=class{constructor(t){console.warn(`[vite-messages-plugin]: Message "${t}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var In;(function(e){e[e.literal=0]="literal",e[e.argument=1]="argument",e[e.number=2]="number",e[e.date=3]="date",e[e.time=4]="time",e[e.select=5]="select",e[e.plural=6]="plural",e[e.pound=7]="pound",e[e.tag=8]="tag"})(In||(In={}));var Qf;(function(e){e[e.number=0]="number",e[e.dateTime=1]="dateTime"})(Qf||(Qf={}));function pv(e){return e.type===In.literal}function mv(e){return e.type===In.argument}function du(e){return e.type===In.number}function fu(e){return e.type===In.date}function pu(e){return e.type===In.time}function mu(e){return e.type===In.select}function gu(e){return e.type===In.plural}function QT(e){return e.type===In.pound}function hu(e){return e.type===In.tag}function Zf(e){return!!(e&&typeof e=="object"&&e.type===Qf.number)}function yu(e){return!!(e&&typeof e=="object"&&e.type===Qf.dateTime)}function gv(e){e.forEach(function(t){if(delete t.location,mu(t)||gu(t))for(var n in t.options)delete t.options[n].location,gv(t.options[n].value);else du(t)&&Zf(t.style)||(fu(t)||pu(t))&&yu(t.style)?delete t.style.location:hu(t)&&gv(t.children)})}function ZT(e,t){t===void 0&&(t={}),t=pn({shouldParseSkeletons:!0,requiresOtherClause:!0},t);var n=new Xf(e,t).parse();if(n.err){var r=SyntaxError(Yf[n.err.kind]);throw r.location=n.err.location,r.originalMessage=n.err.message,r}return t!=null&&t.captureLocation||gv(n.val),n.val}var Ti;(function(e){e.MISSING_VALUE="MISSING_VALUE",e.INVALID_VALUE="INVALID_VALUE",e.MISSING_INTL_API="MISSING_INTL_API"})(Ti||(Ti={}));var vu=function(e){cu(t,e);function t(n,r,o){var i=e.call(this,n)||this;return i.code=r,i.originalMessage=o,i}return t.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},t}(Error);var hv=function(e){cu(t,e);function t(n,r,o,i){return e.call(this,'Invalid values for "'.concat(n,'": "').concat(r,'". Options are "').concat(Object.keys(o).join('", "'),'"'),Ti.INVALID_VALUE,i)||this}return t}(vu);var JT=function(e){cu(t,e);function t(n,r,o){return e.call(this,'Value for "'.concat(n,'" must be of type ').concat(r),Ti.INVALID_VALUE,o)||this}return t}(vu);var eC=function(e){cu(t,e);function t(n,r){return e.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(r,'"'),Ti.MISSING_VALUE,r)||this}return t}(vu);var It;(function(e){e[e.literal=0]="literal",e[e.object=1]="object"})(It||(It={}));function P2(e){return e.length<2?e:e.reduce(function(t,n){var r=t[t.length-1];return!r||r.type!==It.literal||n.type!==It.literal?t.push(n):r.value+=n.value,t},[])}function A2(e){return typeof e=="function"}function xu(e,t,n,r,o,i,s){if(e.length===1&&pv(e[0]))return[{type:It.literal,value:e[0].value}];for(var a=[],l=0,u=e;l<u.length;l++){var c=u[l];if(pv(c)){a.push({type:It.literal,value:c.value});continue}if(QT(c)){typeof i=="number"&&a.push({type:It.literal,value:n.getNumberFormat(t).format(i)});continue}var f=c.value;if(!(o&&f in o))throw new eC(f,s);var d=o[f];if(mv(c)){(!d||typeof d=="string"||typeof d=="number")&&(d=typeof d=="string"||typeof d=="number"?String(d):""),a.push({type:typeof d=="string"?It.literal:It.object,value:d});continue}if(fu(c)){var p=typeof c.style=="string"?r.date[c.style]:yu(c.style)?c.style.parsedOptions:void 0;a.push({type:It.literal,value:n.getDateTimeFormat(t,p).format(d)});continue}if(pu(c)){var p=typeof c.style=="string"?r.time[c.style]:yu(c.style)?c.style.parsedOptions:r.time.medium;a.push({type:It.literal,value:n.getDateTimeFormat(t,p).format(d)});continue}if(du(c)){var p=typeof c.style=="string"?r.number[c.style]:Zf(c.style)?c.style.parsedOptions:void 0;p&&p.scale&&(d=d*(p.scale||1)),a.push({type:It.literal,value:n.getNumberFormat(t,p).format(d)});continue}if(hu(c)){var y=c.children,h=c.value,g=o[h];if(!A2(g))throw new JT(h,"function",s);var m=xu(y,t,n,r,o,i),v=g(m.map(function(C){return C.value}));Array.isArray(v)||(v=[v]),a.push.apply(a,v.map(function(C){return{type:typeof C=="string"?It.literal:It.object,value:C}}))}if(mu(c)){var x=c.options[d]||c.options.other;if(!x)throw new hv(c.value,d,Object.keys(c.options),s);a.push.apply(a,xu(x.value,t,n,r,o));continue}if(gu(c)){var x=c.options["=".concat(d)];if(!x){if(!Intl.PluralRules)throw new vu(`Intl.PluralRules is not available in this environment.
14
+ `));var t=[],n=e.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(var r=0;r<n.length;r++){var o=n[r];r%2&&!this.options.newlineIsToken?t[t.length-1]+=o:(this.options.ignoreWhitespace&&(o=o.trim()),t.push(o))}return t};var i2=new Vr;i2.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var s2=new Vr;s2.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function Nf(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Nf=function(t){return typeof t}:Nf=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Nf(e)}var a2=Object.prototype.toString,iu=new Vr;iu.useLongestToken=!0;iu.tokenize=fT.tokenize;iu.castInput=function(e){var t=this.options,n=t.undefinedReplacement,r=t.stringifyReplacer,o=r===void 0?function(i,s){return typeof s=="undefined"?n:s}:r;return typeof e=="string"?e:JSON.stringify(tv(e,null,null,o),o," ")};iu.equals=function(e,t){return Vr.prototype.equals.call(iu,e.replace(/,([\r\n])/g,"$1"),t.replace(/,([\r\n])/g,"$1"))};function tv(e,t,n,r,o){t=t||[],n=n||[],r&&(e=r(o,e));var i;for(i=0;i<t.length;i+=1)if(t[i]===e)return n[i];var s;if(a2.call(e)==="[object Array]"){for(t.push(e),s=new Array(e.length),n.push(s),i=0;i<e.length;i+=1)s[i]=tv(e[i],t,n,r,o);return t.pop(),n.pop(),s}if(e&&e.toJSON&&(e=e.toJSON()),Nf(e)==="object"&&e!==null){t.push(e),s={},n.push(s);var a=[],l;for(l in e)e.hasOwnProperty(l)&&a.push(l);for(a.sort(),i=0;i<a.length;i+=1)l=a[i],s[l]=tv(e[l],t,n,r,l);t.pop(),n.pop()}else s=e;return s}var nv=new Vr;nv.tokenize=function(e){return e.slice()};nv.join=nv.removeEmpty=function(e){return e};function pT(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function Ho(e,t,n=10){let r=typeof e,o=typeof t;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return r!==o?!1:e==null||r==="string"||r==="number"||r==="boolean"?e===t:Array.isArray(e)&&Array.isArray(t)?e.length!==t.length?!1:e.every((i,s)=>Ho(i,t[s],n-1)):pT(e)&&pT(t)?Object.keys(e).length!==Object.keys(t).length?!1:Object.keys(e).every(s=>Ho(e[s],t[s],n-1)):!1}function l2(e){return Math.max(...e.map(t=>t.length))}function u2(e,t){let n=e.reduce((r,o)=>{if(o){let i=r[o]?r[o]+1:1;return P(b({},r),{[o]:i})}return r},{});return Object.keys(n).reduce((r,o)=>(n[o]<t&&r.push(o),r),[])}function mT(e,t){let r=[...e.map(({text:o})=>o.split(/\b(\w+)\b/))];for(let o=0;o<l2(r);o++){let i=u2(r.map(a=>a[o]),t),s=r.filter(a=>!i.includes(a[o]));if(s.length>=t)r=s;else return{text:r[0].slice(0,o).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var c2=2;function gT(e,t=""){if(e.length===0)return;if(e.length===1)return e[0];let n=mT(e,c2);return n&&n.text!==t?n:e[0]}var d2={info(...e){console.info("[Deepdesk]",...e)},warn(...e){console.warn("[Deepdesk]",...e)},error(...e){console.error("[Deepdesk]",...e)}},ee=d2;var hT={current:null,isSupported:null},it=ot("resetConversation"),yT=e=>{let{current:t}=e.conversation;return(t==null?void 0:t.externalId)||null},yr=e=>{let{current:t}=e.conversation;return(t==null?void 0:t.id)||null},oa=e=>e.conversation.isSupported,rv=ge("conversation/isSupported",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.isConversationSupported(e.externalId,e.options)}),_f=ge("conversation/create",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.createConversation(e)}),Df=ge("conversation/byExternalId",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.getConversationByExternalId(e.externalId,e.options)}),Ff=ge("conversation/update",(e,t)=>{let{deepdeskAPI:n}=t.extra,r=yr(t.getState());if(!r)throw new Error("No current conversation to update");return n.updateConversation(r,e)}),ov=ge("conversation/upsert",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.getConversationByExternalId(e.externalId).catch(()=>null).then(r=>{if(!r)return n.createConversation(e);let{agentId:o,agentName:i,agentEmail:s,agentNickname:a,metadata:l}=e;return n.updateConversation(r.id,{agentId:o,agentEmail:s,agentName:i,agentNickname:a,metadata:l})})}),Hf=ge("conversation/postMessages",(e,t)=>{let{deepdeskAPI:n}=t.extra,r=yr(t.getState());if(!r)throw new Error("No current conversation to update messages");return n.postMessages(r,e.map(o=>b({},o)))}),f2=[_f.rejected,Df.rejected,Ff.rejected,Hf.rejected].map(e=>e==null?void 0:e.toString()),p2=Ce({name:"conversation",initialState:hT,reducers:{},extraReducers:e=>{e.addCase(rv.fulfilled,(t,n)=>{t.isSupported=n.payload}).addCase(_f.fulfilled,(t,n)=>{var r;t.current=n.payload,t.isSupported=!!((r=n.payload)!=null&&r.profileCode)}).addCase(Df.fulfilled,(t,n)=>{var r;t.current=n.payload,t.isSupported=!!((r=n.payload)!=null&&r.profileCode)}).addCase(ov.fulfilled,(t,n)=>{var r;t.current=n.payload,t.isSupported=!!((r=n.payload)!=null&&r.profileCode)}).addCase(Ff.fulfilled,(t,n)=>{var r;t.current=n.payload,t.isSupported=!!((r=n.payload)!=null&&r.profileCode)}).addCase(Hf.fulfilled,(t,n)=>{t.current&&(t.current.messages=n.payload)}).addCase(it,()=>hT).addMatcher(t=>f2.includes(t.type),(t,n)=>{var r;throw ee.info("Conversation action rejected",n.type,((r=n.error)==null?void 0:r.message)||"No message"),new Error(n.error.message)})}}),vT=p2.reducer;var Si={text:"",html:null,selection:{start:0,end:0},beforeInputChange:null,mixedSuggestion: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 iv(e){let{key:t,shiftKey:n,ctrlKey:r,metaKey:o,altKey:i}=e;return{key:t,shiftKey:n,ctrlKey:r,metaKey:o,altKey:i}}var zf=ot("input/replaceText"),bi=ot("input/sendMessage"),Bf=ot("input/applyImageSuggestion"),Wr=ot("input/sendEvent"),xT=Ce({name:"input",initialState:Si,reducers:{setInput(e,t){var i,s;let{beforeInputChange:n}=e,{text:r,html:o}=t.payload;if(e.text=r,e.html=o!=null?o:null,r==="")e.metrics=Si.metrics,e.textSuggestions=[],e.mixedSuggestion=null;else if(n!==null&&e.text!==n.text){let{key:a,shiftKey:l,ctrlKey:u,metaKey:c,altKey:f}=n.keyDown;switch(a){case"Enter":l&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:d}=e,p=cT(n.text,d);n.text.length-d.length>1&&e.metrics.deletions.push(...p.filter(y=>y.removed).map(y=>y.value)),e.metrics.numCharsDeleted+=n.text.length-d.length;break}case"Shift":case"Meta":case"Tab":break;case"C":case"V":case"X":case"c":case"v":case"x":if(u||c)break;default:if(!u&&!c&&!f){e.metrics.numCharsTyped+=1;let d=((i=n.selection)==null?void 0:i.start)!==void 0&&((s=n.selection)==null?void 0:s.end)!==void 0?n.text.substring(n.selection.start,n.selection.end):null;d&&d.length>0&&(e.metrics.numCharsDeleted+=d.length,e.metrics.deletions.push(d))}}e.metrics.agentStartedTypingTimestamp||(e.metrics.agentStartedTypingTimestamp=Date.now())}e.beforeInputChange=null},setSelection(e,t){t.payload!==null&&(Ho(e.selection,t.payload)||(e.selection=t.payload))},commitSuggestion(e,t){let n=t.payload,{text:r,suggestion:{source:o,abVariant:i,abTestName:s,trainingJobs:a,sourceText:l,searchTerm:u,text:c},eventMetrics:{inputType:f},replace:d}=n,p=o==="search"||o==="personal-collection-search",y=r.slice(e.text.substring(0,e.selection.start).length);(p||d==="selection")&&(y=r),n.suggestion.source==="search-overlay"&&(y=c),e.metrics.textSuggestions.push({text:y,source:o,abVariant:i,abTestName:s,inputType:f,sourceText:l,trainingJobs:a||[],searchTerm:p?e.text:u}),e.textSuggestions=[],e.selectedSuggestionIndex=-1},offeredTextSuggestion(e,t){let{text:n,suggestion:{source:r}}=t.payload;e.metrics.offeredTextSuggestions.find(i=>i.text===n)||e.metrics.offeredTextSuggestions.push({text:n,source:r})},registerKeyDown(e,t){let{key:n}=t.payload;["Control","Meta","Shift","Alt"].includes(n)||(e.beforeInputChange={text:e.text,selection:e.selection,keyDown:t.payload})},registerKeyUp(e,t){},registerCut(e,t){let{metrics:n}=e,r=t.payload;e.metrics=P(b({},e.metrics),{numCharsCut:n.numCharsCut+r.length,cuts:[...n.cuts,r]})},registerPaste(e,t){let{metrics:n}=e,{text:r,selectionText:o}=t.payload,i=n.numCharsDeleted+(o!=null&&o.length?o.length:0),s=o!=null&&o.length?[...n.deletions,o]:n.deletions;e.metrics=P(b({},e.metrics),{numCharsDeleted:i,deletions:s,numCharsPasted:n.numCharsPasted+r.length,numPaste:n.numPaste+1,pastes:[...n.pastes,r]})},selectNextTextSuggestion(e){let t=e.textSuggestions.length;e.selectedSuggestionIndex=e.selectedSuggestionIndex<t-1?e.selectedSuggestionIndex+1:e.selectedSuggestionIndex},selectPreviousTextSuggestion(e){e.selectedSuggestionIndex=e.selectedSuggestionIndex>=0?e.selectedSuggestionIndex-1:e.selectedSuggestionIndex},selectTextSuggestionByIndex(e,t){e.selectedSuggestionIndex=t.payload},setTextSuggestions(e,t){if(e.selectedSuggestionIndex=-1,e.textSuggestions=t.payload,t.payload.length===0){e.mixedSuggestion=null;return}let n=e.text.substring(0,e.selection.end),r=gT(t.payload,n);e.mixedSuggestion=r!=null&&r.text.includes(n)?r:null},setMetrics(e,{payload:t}){e.metrics=t},resetMetrics(e){e.metrics=Si.metrics}},extraReducers:e=>{e.addCase(it,t=>{t.mixedSuggestion=Si.mixedSuggestion,t.textSuggestions=Si.textSuggestions,t.selectedSuggestionIndex=Si.selectedSuggestionIndex,t.metrics=Si.metrics})}}),ia=e=>e.input.text.substring(0,e.input.selection.end),m2=e=>e.input.selection,sa=e=>{let{mixedSuggestion:t,selectedSuggestionIndex:n,textSuggestions:r}=e.input;return n>-1?r[n]:t},wT=()=>K(m2),{commitSuggestion:jn,offeredTextSuggestion:ST,registerCut:bT,registerKeyDown:ET,registerKeyUp:TT,registerPaste:CT,selectNextTextSuggestion:kT,selectPreviousTextSuggestion:RT,selectTextSuggestionByIndex:Uf,setInput:jf,setMetrics:PT,setSelection:Vf,setTextSuggestions:zo,resetMetrics:AT}=xT.actions,IT=xT.reducer;function LT(e){try{return Intl.DateTimeFormat(void 0,{timeZone:e}),!0}catch(t){return!1}}var g2={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,platformVariables:void 0,fetchState:"idle"},aa=e=>{var t;return(t=e.info.agentInfo)!=null?t:null},OT=e=>{var t;return(t=e.info.visitorInfo)!=null?t:null},MT=e=>{var t;return(t=e.info.customData)!=null?t:null},au=({info:{visitorInfo:e,agentInfo:t}})=>{var n,r;return{timezone:e!=null&&e.visitorTimeZone&&LT(e.visitorTimeZone)?e.visitorTimeZone:Dw,agentName:(n=t==null?void 0:t.agentNickname)!=null?n:"",visitorName:(r=e==null?void 0:e.visitorName)!=null?r:""}},h2=[["agentNickname","nickname"],["agentDefaultLocale","defaultLocale"],["agentEmail","email"]],su=ge("info/setAgentInfo",(e,t)=>A(void 0,null,function*(){var i,s,a;let{deepdeskAPI:n}=t.extra,r=yield n.getMe(),o=[];if(e.agentId&&e.skipSync!==!0&&o.push(n.postIdentity({externalId:e.agentId})),e.skipSync!==!0){let l=h2.reduce((u,[c,f])=>!r[f]&&c in e?P(b({},u),{[f]:e[c]}):u,{});Object.keys(l).length>0&&o.push(n.patchMe(l).then(u=>r=u))}return o.length>0&&(yield Promise.all(o)),{agentId:e.agentId,agentName:e.agentName,agentNickname:(i=r.nickname)!=null?i:e.agentNickname,agentEmail:(s=r.email)!=null?s:e.agentEmail,agentDefaultLocale:(a=r.defaultLocale)!=null?a:e.agentDefaultLocale,agentTimeZone:e.agentTimeZone}})),sv=ge("info/setAgentSettings",(e,t)=>A(void 0,null,function*(){let{deepdeskAPI:n}=t.extra,r=yield n.getMe(),o=b(b({},typeof r.uiConfig=="object"?r.uiConfig:{}),e);return yield n.patchMe({uiConfig:o}),o})),av=ge("info/getAgentSettings",(e,t)=>A(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return(yield n.getMe()).uiConfig})),NT=Ce({name:"info",initialState:g2,reducers:{setVisitorInfo(e,t){e.visitorInfo=b(b({},e.visitorInfo),t.payload)},setCustomData(e,t){e.customData=t.payload},setPlatformVariables(e,t){e.platformVariables=t.payload}},extraReducers:e=>{e.addCase(su.pending,(t,n)=>{t.fetchState="loading",t.agentInfo=b(b({},t.agentInfo),n.meta.arg)}).addCase(su.rejected,t=>{t.fetchState="error"}).addCase(su.fulfilled,(t,n)=>{t.fetchState="done",t.agentInfo=n.payload}).addCase(sv.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(av.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(it,t=>{t.visitorInfo=void 0})}}),{setVisitorInfo:_T,setCustomData:DT,setPlatformVariables:FT}=NT.actions,HT=NT.reducer;function rn(e,t){return Object.entries(t).reduce((n,[r,o])=>n.replaceAll(r,o),e)}var Wf={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},zT=e=>e.search.isOpen,BT=e=>e.search.page,lv=e=>e.search.list,UT=e=>e.search.aggregates,y2=Un([lv,(e,t)=>t],(e,t)=>e.filter(n=>n.type===t)),jT=e=>t=>y2(t,e),Ei=ge("search/getAll",(e,t)=>A(void 0,null,function*(){var l;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(l=r.conversation.current)==null?void 0:l.profileCode,{platformVariables:i}=r.info;if(!o)throw new Error("Profile should be provided in order to be able to search");let{results:s,aggregates:a}=yield n.search({profile:o,query:e.query,tags:e.tags,size:e.size,current:e.current,filters:{type:e.type},params:au(r)});return{results:s.map(u=>P(b(b({},u),u.title&&i?{title:rn(u.title,i)}:{}),{text:rn(u.text,i!=null?i:{}),source:`search-${u.type.toLowerCase()}`,searchTerm:e.query})),aggregates:a}})),VT=Ce({name:"search",initialState:Wf,reducers:{setIsOpen(e,t){e.isOpen=t.payload},setPage(e,t){e.page=t.payload},resetSearch(e){e.fetchState=Wf.fetchState,e.list=Wf.list}},extraReducers:e=>{e.addCase(Ei.pending,t=>{t.fetchState="loading"}).addCase(Ei.rejected,(t,n)=>{t.fetchState="error",ee.error(n.error)}).addCase(Ei.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload.results,t.aggregates=n.payload.aggregates||{}}).addCase(it,()=>Wf)}}),{resetSearch:Kf,setIsOpen:An,setPage:Kr}=VT.actions,WT=VT.reducer;var uv="SetOutputs",la="ShowLoginOverlay",lu="UserLoggedIn",v2="UserLoggedOut",vr="ApplySuggestion",cv="ApplyImageSuggestion",x2="ShowCommandPalette",w2=e=>({[uv]:t=>{e.dispatch(P(b({},t),{isBroadcasted:!0}))},[x2]:t=>{e.dispatch(An(t.isOpen)),t.page&&e.dispatch(Kr(t.page))},[la]:t=>{e.dispatch(sT(t))},[lu]:()=>{e.dispatch(jr())},[v2]:()=>{e.dispatch(jr())},[cv]:t=>{e.dispatch(Bf({suggestion:t.suggestion}))},[vr]:t=>{e.dispatch(jn(P(b({},t),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),KT=w2;var uu=S($()),qT=S(R()),$T=uu.default.createContext(null),Bo=({broadcastEvents:e,children:t})=>{let n=uu.default.useMemo(()=>e,[]);return(0,qT.jsx)($T.Provider,{value:n,children:t})},on=()=>{let e=(0,uu.useContext)($T);if(!e)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return e};var np=S(Fe()),Vn=S($());var Jf=S($());var dv=function(e,t){return dv=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},dv(e,t)};function cu(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");dv(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var pn=function(){return pn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},pn.apply(this,arguments)};function GT(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function $f(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}function qf(e,t){var n=t&&t.cache?t.cache:R2,r=t&&t.serializer?t.serializer:C2,o=t&&t.strategy?t.strategy:b2;return o(e,{cache:n,serializer:r})}function S2(e){return e==null||typeof e=="number"||typeof e=="boolean"}function YT(e,t,n,r){var o=S2(r)?r:n(r),i=t.get(o);return typeof i=="undefined"&&(i=e.call(this,r),t.set(o,i)),i}function XT(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=n(r),i=t.get(o);return typeof i=="undefined"&&(i=e.apply(this,r),t.set(o,i)),i}function fv(e,t,n,r,o){return n.bind(t,e,r,o)}function b2(e,t){var n=e.length===1?YT:XT;return fv(e,this,n,t.cache.create(),t.serializer)}function E2(e,t){return fv(e,this,XT,t.cache.create(),t.serializer)}function T2(e,t){return fv(e,this,YT,t.cache.create(),t.serializer)}var C2=function(){return JSON.stringify(arguments)},k2=function(){function e(){this.cache=Object.create(null)}return e.prototype.get=function(t){return this.cache[t]},e.prototype.set=function(t,n){this.cache[t]=n},e}(),R2={create:function(){return new k2}},Gf={variadic:E2,monadic:T2};var Yf;(function(e){e[e.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",e[e.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",e[e.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",e[e.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",e[e.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",e[e.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",e[e.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",e[e.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",e[e.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",e[e.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",e[e.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",e[e.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",e[e.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",e[e.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",e[e.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",e[e.INVALID_TAG=23]="INVALID_TAG",e[e.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",e[e.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",e[e.UNCLOSED_TAG=27]="UNCLOSED_TAG"})(Yf||(Yf={}));var Xf=class{constructor(t){console.warn(`[vite-messages-plugin]: Message "${t}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var In;(function(e){e[e.literal=0]="literal",e[e.argument=1]="argument",e[e.number=2]="number",e[e.date=3]="date",e[e.time=4]="time",e[e.select=5]="select",e[e.plural=6]="plural",e[e.pound=7]="pound",e[e.tag=8]="tag"})(In||(In={}));var Qf;(function(e){e[e.number=0]="number",e[e.dateTime=1]="dateTime"})(Qf||(Qf={}));function pv(e){return e.type===In.literal}function mv(e){return e.type===In.argument}function du(e){return e.type===In.number}function fu(e){return e.type===In.date}function pu(e){return e.type===In.time}function mu(e){return e.type===In.select}function gu(e){return e.type===In.plural}function QT(e){return e.type===In.pound}function hu(e){return e.type===In.tag}function Zf(e){return!!(e&&typeof e=="object"&&e.type===Qf.number)}function yu(e){return!!(e&&typeof e=="object"&&e.type===Qf.dateTime)}function gv(e){e.forEach(function(t){if(delete t.location,mu(t)||gu(t))for(var n in t.options)delete t.options[n].location,gv(t.options[n].value);else du(t)&&Zf(t.style)||(fu(t)||pu(t))&&yu(t.style)?delete t.style.location:hu(t)&&gv(t.children)})}function ZT(e,t){t===void 0&&(t={}),t=pn({shouldParseSkeletons:!0,requiresOtherClause:!0},t);var n=new Xf(e,t).parse();if(n.err){var r=SyntaxError(Yf[n.err.kind]);throw r.location=n.err.location,r.originalMessage=n.err.message,r}return t!=null&&t.captureLocation||gv(n.val),n.val}var Ti;(function(e){e.MISSING_VALUE="MISSING_VALUE",e.INVALID_VALUE="INVALID_VALUE",e.MISSING_INTL_API="MISSING_INTL_API"})(Ti||(Ti={}));var vu=function(e){cu(t,e);function t(n,r,o){var i=e.call(this,n)||this;return i.code=r,i.originalMessage=o,i}return t.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},t}(Error);var hv=function(e){cu(t,e);function t(n,r,o,i){return e.call(this,'Invalid values for "'.concat(n,'": "').concat(r,'". Options are "').concat(Object.keys(o).join('", "'),'"'),Ti.INVALID_VALUE,i)||this}return t}(vu);var JT=function(e){cu(t,e);function t(n,r,o){return e.call(this,'Value for "'.concat(n,'" must be of type ').concat(r),Ti.INVALID_VALUE,o)||this}return t}(vu);var eC=function(e){cu(t,e);function t(n,r){return e.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(r,'"'),Ti.MISSING_VALUE,r)||this}return t}(vu);var It;(function(e){e[e.literal=0]="literal",e[e.object=1]="object"})(It||(It={}));function P2(e){return e.length<2?e:e.reduce(function(t,n){var r=t[t.length-1];return!r||r.type!==It.literal||n.type!==It.literal?t.push(n):r.value+=n.value,t},[])}function A2(e){return typeof e=="function"}function xu(e,t,n,r,o,i,s){if(e.length===1&&pv(e[0]))return[{type:It.literal,value:e[0].value}];for(var a=[],l=0,u=e;l<u.length;l++){var c=u[l];if(pv(c)){a.push({type:It.literal,value:c.value});continue}if(QT(c)){typeof i=="number"&&a.push({type:It.literal,value:n.getNumberFormat(t).format(i)});continue}var f=c.value;if(!(o&&f in o))throw new eC(f,s);var d=o[f];if(mv(c)){(!d||typeof d=="string"||typeof d=="number")&&(d=typeof d=="string"||typeof d=="number"?String(d):""),a.push({type:typeof d=="string"?It.literal:It.object,value:d});continue}if(fu(c)){var p=typeof c.style=="string"?r.date[c.style]:yu(c.style)?c.style.parsedOptions:void 0;a.push({type:It.literal,value:n.getDateTimeFormat(t,p).format(d)});continue}if(pu(c)){var p=typeof c.style=="string"?r.time[c.style]:yu(c.style)?c.style.parsedOptions:r.time.medium;a.push({type:It.literal,value:n.getDateTimeFormat(t,p).format(d)});continue}if(du(c)){var p=typeof c.style=="string"?r.number[c.style]:Zf(c.style)?c.style.parsedOptions:void 0;p&&p.scale&&(d=d*(p.scale||1)),a.push({type:It.literal,value:n.getNumberFormat(t,p).format(d)});continue}if(hu(c)){var y=c.children,h=c.value,g=o[h];if(!A2(g))throw new JT(h,"function",s);var m=xu(y,t,n,r,o,i),v=g(m.map(function(C){return C.value}));Array.isArray(v)||(v=[v]),a.push.apply(a,v.map(function(C){return{type:typeof C=="string"?It.literal:It.object,value:C}}))}if(mu(c)){var x=c.options[d]||c.options.other;if(!x)throw new hv(c.value,d,Object.keys(c.options),s);a.push.apply(a,xu(x.value,t,n,r,o));continue}if(gu(c)){var x=c.options["=".concat(d)];if(!x){if(!Intl.PluralRules)throw new vu(`Intl.PluralRules is not available in this environment.
15
15
  Try polyfilling it using "@formatjs/intl-pluralrules"
16
- `,Ti.MISSING_INTL_API,s);var w=n.getPluralRules(t,{type:c.pluralType}).select(d-(c.offset||0));x=c.options[w]||c.options.other}if(!x)throw new hv(c.value,d,Object.keys(c.options),s);a.push.apply(a,xu(x.value,t,n,r,o,d-(c.offset||0)));continue}}return P2(a)}function I2(e,t){return t?pn(pn(pn({},e||{}),t||{}),Object.keys(e).reduce(function(n,r){return n[r]=pn(pn({},e[r]),t[r]||{}),n},{})):e}function L2(e,t){return t?Object.keys(e).reduce(function(n,r){return n[r]=I2(e[r],t[r]),n},pn({},e)):e}function yv(e){return{create:function(){return{get:function(t){return e[t]},set:function(t,n){e[t]=n}}}}}function O2(e){return e===void 0&&(e={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:qf(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.NumberFormat).bind.apply(t,$f([void 0],n,!1)))},{cache:yv(e.number),strategy:Gf.variadic}),getDateTimeFormat:qf(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.DateTimeFormat).bind.apply(t,$f([void 0],n,!1)))},{cache:yv(e.dateTime),strategy:Gf.variadic}),getPluralRules:qf(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.PluralRules).bind.apply(t,$f([void 0],n,!1)))},{cache:yv(e.pluralRules),strategy:Gf.variadic})}}var vv=function(){function e(t,n,r,o){n===void 0&&(n=e.defaultLocale);var i=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(u){var c=i.formatToParts(u);if(c.length===1)return c[0].value;var f=c.reduce(function(d,p){return!d.length||p.type!==It.literal||typeof d[d.length-1]!="string"?d.push(p.value):d[d.length-1]+=p.value,d},[]);return f.length<=1?f[0]||"":f},this.formatToParts=function(u){return xu(i.ast,i.locales,i.formatters,i.formats,u,void 0,i.message)},this.resolvedOptions=function(){var u;return{locale:((u=i.resolvedLocale)===null||u===void 0?void 0:u.toString())||Intl.NumberFormat.supportedLocalesOf(i.locales)[0]}},this.getAst=function(){return i.ast},this.locales=n,this.resolvedLocale=e.resolveLocale(n),typeof t=="string"){if(this.message=t,!e.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var s=o||{},a=s.formatters,l=GT(s,["formatters"]);this.ast=e.__parse(t,pn(pn({},l),{locale:this.resolvedLocale}))}else this.ast=t;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=L2(e.formats,r),this.formatters=o&&o.formatters||O2(this.formatterCache)}return Object.defineProperty(e,"defaultLocale",{get:function(){return e.memoizedDefaultLocale||(e.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),e.memoizedDefaultLocale},enumerable:!1,configurable:!0}),e.memoizedDefaultLocale=null,e.resolveLocale=function(t){if(typeof Intl.Locale!="undefined"){var n=Intl.NumberFormat.supportedLocalesOf(t);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof t=="string"?t:t[0])}},e.__parse=ZT,e.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"}}},e}();function M2(e,t){return t.split(".").reduce((n,r)=>n?n[r]:void 0,e)}var N2="dummy",xv=(0,Jf.createContext)(null);function ue(e){var r;let t=(0,Jf.useContext)(xv);if(!t)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let n=(r=e[t])!=null?r:{};return(o,i)=>{let s=M2(n,o);return s?new vv(s).format(i):(t!==N2&&console.warn(`${o} does not exist in messages of ${t}`),`[${o}]`)}}var ep=S($());var tC={root:"dd-tvkOF",content:"dd-eXA1D"};var wv=S(R()),_2=({isOpen:e,autoFocus:t,children:n,onClose:r,onBack:o,onKeyDown:i,overlayAriaLabel:s,contentAriaLabel:a})=>{let l=(0,ep.useRef)(null),u=F("Dialog",tC),c=d=>{if(d.key==="Escape"){d.preventDefault(),d.stopPropagation(),o();return}i&&i(d)},f=d=>{d.target===l.current&&e&&r()};return(0,ep.useEffect)(()=>{var d,p;!l.current||!e||!t||(p=(d=l.current)==null?void 0:d.querySelector("input, textarea"))==null||p.focus()},[e,t,l]),e?(0,wv.jsx)("div",{role:"dialog","data-testid":"dialog",className:u.root,"aria-label":s,ref:l,onKeyDown:c,onMouseDown:f,children:(0,wv.jsx)("div",{"data-testid":"dialog-content",className:u.content,"aria-label":a,children:n})}):null},tp=_2;var rC=S(Fe());var nC={root:"dd-ranhW"};var oC=S(R()),D2=r=>{var o=r,{className:e,value:t}=o,n=se(o,["className","value"]);let i=F("TextInput",nC);return(0,oC.jsx)("input",b({className:(0,rC.default)(e,i.root),type:"text",value:t},n))},wu=D2;var Sv={};bt(Sv,{enUS:()=>F2,nlNL:()=>H2});var F2={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"}]},H2={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 iC={root:"dd-lWxnE",anchorButton:"dd-TZ4in",errorMessage:"dd-fIsPg",title:"dd-pGhJx",subtitle:"dd-f5l29",text:"dd-iamoD",input:"dd-uhQZ3",actions:"dd-lubvx",button:"dd-CJsNI",primaryButton:"dd-MWBfl"};var et=S(R());var z2=e=>{try{let t=new URL(e);return new URLSearchParams(t.search).get("token")||void 0}catch(t){return e}},B2=({agentEmail:e,isOpen:t,origin:n="",onSuccess:r,onDismiss:o})=>{let i=ue(Sv),s=F("LoginTokenDialog",iC),a=K(nT),l=he(),u=J("productName"),[c,f]=(0,Vn.useState)(e||""),[d,p]=(0,Vn.useState)(0),[y,h]=(0,Vn.useState)(""),g=(0,Vn.useCallback)(w=>A(void 0,null,function*(){w.preventDefault(),l(oT({email:c})),p(1)}),[n,c]),m=()=>{h(""),p(0)},v=(0,Vn.useCallback)(w=>A(void 0,null,function*(){w.preventDefault();let C=z2(w.target.elements.token.value);if(!C){h(i("verifyCodeError",{login:x}));return}l(ou({token:C}))}),[n]),x=(0,Vn.useMemo)(()=>w=>(0,et.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:s.anchorButton,onClick:m,children:w},"back-button"),[]);return(0,Vn.useEffect)(()=>{a==="error"&&h(i("verifyCodeError",{login:x})),a==="done"&&r()},[a]),(0,et.jsx)(tp,{autoFocus:!0,isOpen:t,contentAriaLabel:i("promptTitle",{productName:u}),overlayAriaLabel:i("promptTitle",{productName:u}),onClose:o,onBack:o,children:(0,et.jsxs)("div",{className:s.root,children:[(0,et.jsx)("h1",{className:s.title,children:i("promptTitle",{productName:u})}),d===0&&(0,et.jsxs)("form",{onSubmit:g,children:[(0,et.jsx)("h2",{className:s.subtitle,children:i("requestCodeTitle")}),(0,et.jsx)("p",{className:s.text,children:i("requestCodeBody",{productName:u})}),(0,et.jsx)(wu,{className:s.input,name:"email",placeholder:i("requestCodeInputPlaceholder"),value:c,onChange:w=>f(w.target.value)}),(0,et.jsx)("div",{className:s.actions,children:(0,et.jsx)("button",{type:"submit",className:(0,np.default)(s.button,s.primaryButton),children:i("requestCodeSubmitLabel")})})]}),d===1&&(0,et.jsxs)("form",{onSubmit:v,children:[(0,et.jsx)("h2",{className:s.subtitle,children:i("verifyCodeTitle")}),(0,et.jsx)("p",{className:s.text,children:i("verifyCodeBody")}),(0,et.jsx)(wu,{className:s.input,name:"token",placeholder:i("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),y&&(0,et.jsx)("div",{className:s.errorMessage,children:y}),(0,et.jsxs)("div",{className:s.actions,children:[(0,et.jsx)("button",{type:"button",className:(0,np.default)(s.button),onClick:m,children:i("back")}),(0,et.jsx)("button",{type:"submit",className:(0,np.default)(s.button,s.primaryButton),disabled:["loading","done"].includes(a),children:i("verifyCodeSubmitLabel")})]})]})]})})},sC=B2;var lC=S(R()),U2=()=>{let e=K(rT),t=K(aa),n=J("adminUrl"),r=on(),o=()=>r.send(la,!1),i=()=>{r.send(la,!1),r.send(lu)};return(0,lC.jsx)(sC,{isOpen:e,agentEmail:t==null?void 0:t.agentEmail,origin:n,onDismiss:o,onSuccess:i})},aC=U2;var vP=S(Tv()),$t=S($());var Su="__summarizerAssistant__",fC={cues:[],threads:{},fetchState:"idle"},pC=e=>{var t;return(t=e.assistants)==null?void 0:t.cues};var bu=e=>t=>{var n,r;return(r=(n=t.assistants)==null?void 0:n.threads[e])!=null?r:null},rp=ot("assistants/callToAction"),Wn=ge("assistants/evaluateSummaryAssistant",(e,t)=>A(void 0,null,function*(){let r=t.getState().profile.data;if(!r)throw new Error("No Profile is loaded");let{summarizerAssistantNew:o}=r;if(!o)throw new Error("No Summarizer Assistant set in Profile");let i=yield t.dispatch(Kn(b({assistantCode:o,expectFormat:"text",transcript:"in-memory-transcript",skipState:!0},e)));if(i.error)throw new Error(i.error.message);if(typeof i.payload!="string")throw ee.warn("Unexpected summary output",i),new Error("Unexpected summary output");return i.payload})),i_=1,Ci=ge("assistants/evaluateKnowledgeAssistantLegacy",(e,t)=>A(void 0,null,function*(){var p,y,h,g;let{threadId:n}=e,{onNewThreadId:r,input:o}=e,{deepdeskAPI:i}=t.extra,s=t.getState(),{platformVariables:a}=s.info;n||(n=i_++,r&&r(n));let l=(p=bu(n)(s))!=null?p:[],u=yield i.getKnowledgeAssistant(e.assistantCode),c=(y=s.conversation.current)==null?void 0:y.sessionId,f=(g=(h=s.info)==null?void 0:h.agentInfo)==null?void 0:g.agentId;if(!u)throw new Error("KnowledgeAssistant is not found");let d=yield i.knowledgeAssist({customerInstruction:u.customerInstruction,doNotKnowAnswer:u.doNotKnowAnswer,question:o},l,u.code,{agentId:f,conversationId:c});return a&&(d.answer=rn(d.answer,a)),{threadId:n,question:o,answer:d}})),ki=ge("assistants/evaluateKnowledgeAssistant",(e,t)=>A(void 0,null,function*(){let{threadId:n}=e,{onNewThreadId:r}=e,{deepdeskAPI:o}=t.extra,i=t.getState(),{platformVariables:s}=i.info;n||(n=(yield o.createAssistantThread({assistantCode:e.assistantCode})).id,r&&r(n)),yield o.postMessageToAssistantThread({assistantCode:e.assistantCode,threadId:n,message:e.input});let a=yield t.dispatch(Kn(P(b({expectFormat:"json-schema:knowledge-assist",skipState:!0},e),{input:{},threadId:n})));if(a.error)throw new Error(a.error.message);let l=a.payload;return{threadId:n,question:e.input,answer:{answer:rn(l.response,s!=null?s:{}),sources:l.sources}}})),Kn=ge("assistants/evaluate",(e,t)=>A(void 0,null,function*(){var p;let{deepdeskAPI:n,dynamicThunkObject:r}=t.extra,{transcript:o,input:i={},expectFormat:s,threadId:a}=e,l=t.getState(),{platformVariables:u}=l.info,c=(p=l.conversation.current)==null?void 0:p.sessionId,f;if(o==="in-memory-transcript"){if(!r.conversationQuery)throw new Error("Can't include in-memory-transcript, setConversationQuery is not defined");f=yield r.conversationQuery()}else if(o==="stored-transcript"){if(!l.conversation.current)throw new Error("Can't include stored-transcript, no current conversation");f=l.conversation.current.messages.map(y=>({text:y.text,source:y.source}))}else Array.isArray(o)&&(f=o);if(e.includeTags){if(!l.conversation.current)throw new Error("Can't include tags, no current conversation");let{tags:y}=l.conversation.current;Object.assign(i,{tags:y})}let d=yield n.evaluateAssistant(e.assistantCode,{expectFormat:s,input:i,transcript:f,externalConversationId:c,threadId:a});if(!u)return d;switch(s){case"text":return rn(d,u);case"json-schema:cues":return d.map(y=>P(b({},y),{name:rn(y.name,u),response:rn(y.response,u)}));case"json-schema:knowledge-assist":{let y=d;return P(b({},y),{answer:rn(y.response,u)})}default:return d}})),mC=Ce({name:"assistants",initialState:fC,reducers:{resetCues(e){e.cues=[]},removeCueByCode(e,t){e.cues=e.cues.filter(n=>n.code!==t.payload.code)},removeThreadById(e,t){delete e.threads[t.payload]}},extraReducers:e=>{e.addCase(Kn.pending,(t,n)=>{n.meta.arg.skipState||(t.fetchState="loading")}).addCase(Kn.rejected,(t,n)=>{var r;ee.warn((r=n.error)==null?void 0:r.message),!n.meta.arg.skipState&&(t.fetchState="error")}).addCase(Kn.fulfilled,(t,n)=>{if(!n.meta.arg.skipState)switch(n.meta.arg.expectFormat){case"json-schema:cues":{let r=n.payload,o=r.map(s=>s.code),i=t.cues.filter(s=>!o.includes(s.code));t.fetchState="done",t.cues=[...i,...r];break}}}).addCase(ki.fulfilled,(t,n)=>{let i=n.payload,{threadId:r}=i,o=se(i,["threadId"]);t.threads[r]=[...t.threads[r]||[],o]}).addCase(Ci.fulfilled,(t,n)=>{let i=n.payload,{threadId:r}=i,o=se(i,["threadId"]);t.threads[r]=[...t.threads[r]||[],o]}).addCase(Wn.pending,t=>{let n={code:Su,name:"Summary",response:"",isLoading:!0},r=t.cues.filter(o=>o.code!==Su);t.cues=[...r,n]}).addCase(Wn.rejected,t=>{let n=t.cues.filter(r=>r.code!==Su);t.cues=n}).addCase(Wn.fulfilled,(t,n)=>{let r={code:Su,name:"Summary",response:n.payload,specialType:"summary"},o=t.cues.filter(i=>i.code!==Su);t.cues=[...o,r]}).addCase(it,()=>fC)}}),{removeCueByCode:gC,resetCues:uB,removeThreadById:ua}=mC.actions,hC=mC.reducer;var s_={data:null,fetchState:"idle"},yC=e=>e.contentTypes.data,Eu=ge("contentTypes/getContentTypes",(e,t)=>A(void 0,null,function*(){return t.extra.deepdeskAPI.getContentTypes()})),a_=Ce({name:"contentTypes",initialState:s_,reducers:{},extraReducers:e=>{e.addCase(Eu.pending,t=>{t.fetchState="loading"}).addCase(Eu.rejected,t=>{t.fetchState="error"}).addCase(Eu.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),vC=a_.reducer;var l_={data:null,fetchState:"idle"},u_=[],Ri=e=>e.profile.data,c_=e=>e.profile.data?e.profile.data.uiConfig.widget.types:u_,Cu=Un([c_],e=>e.filter(t=>t.isActive)),xC=e=>{var t;return(t=e.profile.data)==null?void 0:t.summarizerAssistantNew},wC=e=>{var t;return((t=e.profile.data)==null?void 0:t.onDemandAssistants)||[]},Cv=e=>t=>Cu(t).some(n=>n.type===e),SC=e=>e.profile.data?!!e.profile.data.uiConfig.widget.types.find(t=>t.type==="custom-data"):!1,op=e=>{var t;return(t=e.profile.data)==null?void 0:t.knowledgeAssistantNew},ip=e=>{var t;return(t=e.profile.data)==null?void 0:t.knowledgeAssistant},Tu=ge("profile/getProfile",(e,t)=>A(void 0,null,function*(){var i;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=r.conversation.current;if(!o||!o.profileCode)throw new Error("No conversation of conversation profileCode found");return((i=r.profile.data)==null?void 0:i.code)===o.profileCode?r.profile.data:n.getProfile(o.profileCode)})),d_=Ce({name:"profile",initialState:l_,reducers:{},extraReducers:e=>{e.addCase(Tu.pending,t=>{t.fetchState="loading"}).addCase(Tu.rejected,t=>{t.fetchState="error"}).addCase(Tu.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),bC=d_.reducer;function xr(e){let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select(),document.execCommand("copy"),t.remove()}var Qr=S($());var EC=S($()),sp=S(Fe());var mn={root:"dd-U2SX4",list:"dd-cYTlj",listWrapper:"dd-GLQFR",listHorizontal:"dd-x-knl",page:"dd-1F4vk",search:"dd-nvbxc",pageNav:"dd-sRUuT",pageTitle:"dd-t-MKS",pageBackButton:"dd-cjptm",listHeader:"dd-Fg666",listHeading:"dd-w-xhJ",listMoreButton:"dd--mKep",listItem:"dd-wpvuA",listItemContent:"dd-V-mKo",listItemText:"dd-ukCHL",listItemDescription:"dd-sSyu4",listItemActions:"dd-xelho",listItemTooltip:"dd-SWFsE",listItemTooltipContent:"dd-I7J9N",truncate:"dd-IlopJ",lineClamp:"dd-Twaca",listItemTitle:"dd-lMGHq",listItemAction:"dd-xPLAs",listItemSelected:"dd-jFX0Y",sources:"dd-pZx4v",sourcesTitle:"dd-phYVd",source:"dd-DaR6h",sourceShowMore:"dd-M1-8j",icon:"dd-m6yxD",searchIcon:"dd-0AU-O",searchInputWrapper:"dd-DUFcE",searchInput:"dd-ukrlD",select:"dd--Tifv",selectType:"dd-IkZb2",selectWrapper:"dd-J14mx",image:"dd-RQgsB",imageSrc:"dd-jxh8F",imageSrcHidden:"dd-e20Jk",imageSrcStatus:"dd-j50Tt",imageTitle:"dd-qCjfW",actions:"dd-3mfWc",actionsWrapper:"dd-TjDyI",actionsBar:"dd-LiA35",actionButton:"dd-4wk0u",hasShortKeys:"dd-XilV-",actionShortcut:"dd-s4Mla",actionShortcutFixKerning:"dd-lyh5e"};var $r={};bt($r,{enUS:()=>f_,nlNL:()=>p_});var f_={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}],showAll:[{type:0,value:"Show more"}],sources:[{type:0,value:"Sources"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},p_={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}],showAll:[{type:0,value:"Toon meer"}],sources:[{type:0,value:"Bronnen"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var Uo=S(R()),m_=({src:e,title:t})=>{let n=F("CommandPalette",mn),[r,o]=(0,EC.useState)("loading"),i=ue($r);return(0,Uo.jsxs)("div",{className:n.image,children:[(0,Uo.jsx)("img",{src:e,alt:t,onLoad:()=>o("done"),onError:()=>o("error"),className:(0,sp.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(r)})}),r==="loading"&&(0,Uo.jsx)("span",{className:(0,sp.default)(n.imageSrc,n.imageSrcStatus),children:i("loading")}),r==="error"&&(0,Uo.jsx)("span",{className:(0,sp.default)(n.imageSrc,n.imageSrcStatus),children:(0,Uo.jsx)(Oc,{})}),t&&(0,Uo.jsx)("span",{className:n.imageTitle,children:t})]})},TC=m_;var CC=S($()),kC=S(Fe());var Pi=S(R());function kv({children:e,heading:t,orientation:n,hasMore:r,onShowAll:o}){let i=ue($r),s=F("CommandPalette",mn);return CC.default.Children.count(e)===0?null:(0,Pi.jsxs)("div",{"data-testid":"commandpalette-list",className:s.list,children:[(t||r)&&(0,Pi.jsxs)("div",{className:s.listHeader,children:[t&&(0,Pi.jsx)("h4",{className:s.listHeading,children:t}),r&&o&&(0,Pi.jsx)("button",{onClick:o,className:s.listMoreButton,type:"button",children:i("showAll")})]}),(0,Pi.jsx)("div",{className:(0,kC.default)(s.listWrapper,n==="horizontal"&&s.listHorizontal),children:e})]})}var Bu=S(Fe());var ap=S($());function ku(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ke=1,Pv=2,Av=4,st=8,lp=16,Ru=32,$n=64,Rv={a:{content:ke|st,self:!1,type:ke|st|Ru|$n},address:{invalid:["h1","h2","h3","h4","h5","h6","address","article","aside","section","div","header","footer"],self:!1},audio:{children:["track","source"]},br:{type:ke|st,void:!0},body:{content:ke|Pv|Av|st|lp|Ru|$n},button:{content:st,type:ke|st|Ru|$n},caption:{content:ke,parent:["table"]},col:{parent:["colgroup"],void:!0},colgroup:{children:["col"],parent:["table"]},details:{children:["summary"],type:ke|Ru|$n},dd:{content:ke,parent:["dl"]},dl:{children:["dt","dd"],type:ke},dt:{content:ke,invalid:["footer","header"],parent:["dl"]},figcaption:{content:ke,parent:["figure"]},footer:{invalid:["footer","header"]},header:{invalid:["footer","header"]},hr:{type:ke,void:!0},img:{void:!0},li:{content:ke,parent:["ul","ol","menu"]},main:{self:!1},ol:{children:["li"],type:ke},picture:{children:["source","img"],type:ke|st|lp},rb:{parent:["ruby","rtc"]},rp:{parent:["ruby","rtc"]},rt:{content:st,parent:["ruby","rtc"]},rtc:{content:st,parent:["ruby"]},ruby:{children:["rb","rp","rt","rtc"]},source:{parent:["audio","video","picture"],void:!0},summary:{content:st,parent:["details"]},table:{children:["caption","colgroup","thead","tbody","tfoot","tr"],type:ke},tbody:{parent:["table"],children:["tr"]},td:{content:ke,parent:["tr"]},tfoot:{parent:["table"],children:["tr"]},th:{content:ke,parent:["tr"]},thead:{parent:["table"],children:["tr"]},tr:{parent:["table","tbody","thead","tfoot"],children:["th","td"]},track:{parent:["audio","video"],void:!0},ul:{children:["li"],type:ke},video:{children:["track","source"]},wbr:{type:ke|st,void:!0}};function Ii(e){return t=>{Rv[t]=b(b({},e),Rv[t])}}["address","main","div","figure","p","pre"].forEach(Ii({content:ke,type:ke|$n}));["abbr","b","bdi","bdo","cite","code","data","dfn","em","i","kbd","mark","q","ruby","samp","strong","sub","sup","time","u","var"].forEach(Ii({content:st,type:ke|st|$n}));["p","pre"].forEach(Ii({content:st,type:ke|$n}));["s","small","span","del","ins"].forEach(Ii({content:st,type:ke|st}));["article","aside","footer","header","nav","section","blockquote"].forEach(Ii({content:ke,type:ke|Pv|$n}));["h1","h2","h3","h4","h5","h6"].forEach(Ii({content:st,type:ke|Av|$n}));["audio","canvas","iframe","img","video"].forEach(Ii({type:ke|st|lp|$n}));var Au=Object.freeze(Rv),Iv=["applet","base","body","command","embed","frame","frameset","head","html","link","meta","noscript","object","script","style","title"],Lv=Object.keys(Au).filter(e=>e!=="canvas"&&e!=="iframe"),_e=1,Ov=2,Ai=3,jo=4,cp=5,dp=Object.freeze({alt:_e,cite:_e,class:_e,colspan:Ai,controls:jo,datetime:_e,default:jo,disabled:jo,dir:_e,height:_e,href:_e,id:_e,kind:_e,label:_e,lang:_e,loading:_e,loop:jo,media:_e,muted:jo,poster:_e,rel:_e,role:_e,rowspan:Ai,scope:_e,sizes:_e,span:Ai,start:Ai,style:cp,src:_e,srclang:_e,srcset:_e,tabindex:_e,target:_e,title:_e,type:_e,width:_e}),Mv=Object.freeze({class:"className",colspan:"colSpan",datetime:"dateTime",rowspan:"rowSpan",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex"});function up(){return up=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},up.apply(this,arguments)}function fp({attributes:e={},className:t,children:n=null,selfClose:r=!1,tagName:o}){let i=o;return r?ap.default.createElement(i,up({className:t},e)):ap.default.createElement(i,up({className:t},e),n)}var Pu=class{attribute(t,n){return n}node(t,n){return n}};function RC(e,t,n,r=!1){let o=e.match(t instanceof RegExp?t:new RegExp(t,"i"));return o?P(b({match:o[0],void:r},n(o)),{index:o.index,length:o[0].length,valid:!0}):null}var qr=class{constructor(t,n,r){ku(this,"greedy",!1),ku(this,"options",void 0),ku(this,"propName",void 0),ku(this,"inverseName",void 0),ku(this,"factory",void 0),this.options=b({},n),this.propName=t,this.inverseName=`no${t.charAt(0).toUpperCase()+t.slice(1)}`,this.factory=r!=null?r:null}createElement(t,n){return this.factory?ap.default.createElement(this.factory,n,t):this.replaceWith(t,n)}doMatch(t,n,r,o=!1){return RC(t,n,r,o)}onBeforeParse(t,n){return t}onAfterParse(t,n){return t}};var Li=S($()),LC=S(AC());function Gr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var y_=/(url|image|image-set)\(/i,Nv=class extends Pu{attribute(t,n){return t==="style"&&Object.keys(n).forEach(r=>{String(n[r]).match(y_)&&delete n[r]}),n}},IC=1,v_=3,x_=/^<(!doctype|(html|head|body)(\s|>))/i,w_=/^(aria-|data-|\w+:)/iu,S_=/{{{(\w+)\/?}}}/;function b_(){if(!(typeof window=="undefined"||typeof document=="undefined"))return document.implementation.createHTMLDocument("Interweave")}var pp=class{constructor(t,n={},r=[],o=[]){var i;Gr(this,"allowed",void 0),Gr(this,"banned",void 0),Gr(this,"blocked",void 0),Gr(this,"container",void 0),Gr(this,"content",[]),Gr(this,"props",void 0),Gr(this,"matchers",void 0),Gr(this,"filters",void 0),Gr(this,"keyIndex",void 0),this.props=n,this.matchers=r,this.filters=[...o,new Nv],this.keyIndex=-1,this.container=this.createContainer(t||""),this.allowed=new Set((i=n.allowList)!==null&&i!==void 0?i:Lv),this.banned=new Set(Iv),this.blocked=new Set(n.blockList)}applyAttributeFilters(t,n){return this.filters.reduce((r,o)=>r!==null&&typeof o.attribute=="function"?o.attribute(t,r):r,n)}applyNodeFilters(t,n){return this.filters.reduce((r,o)=>r!==null&&typeof o.node=="function"?o.node(t,r):r,n)}applyMatchers(t,n){let r={},{props:o}=this,i=t,s=0,a=null;return this.matchers.forEach(l=>{let u=l.asTag().toLowerCase(),c=this.getTagConfig(u);if(o[l.inverseName]||!this.isTagAllowed(u)||!this.canRenderChild(n,c))return;let f="";for(;i&&(a=l.match(i));){let d=a,{index:p,length:y,match:h,valid:g,void:m}=d,v=se(d,["index","length","match","valid","void"]),x=l.propName+String(s);p>0&&(f+=i.slice(0,p)),g?(f+=m?`{{{${x}/}}}`:`{{{${x}}}}${h}{{{/${x}}}}`,this.keyIndex+=1,s+=1,r[x]={children:h,matcher:l,props:P(b(b({},o),v),{key:this.keyIndex})}):f+=h,l.greedy?(i=f+i.slice(p+y),f=""):i=i.slice(p+(y||h.length))}l.greedy||(i=f+i)}),s===0?t:this.replaceTokens(i,r)}canRenderChild(t,n){return!t.tagName||!n.tagName||t.void?!1:t.children.length>0?t.children.includes(n.tagName):t.invalid.length>0&&t.invalid.includes(n.tagName)?!1:n.parent.length>0?n.parent.includes(t.tagName):!t.self&&t.tagName===n.tagName?!1:!!(t&&t.content&n.type)}convertLineBreaks(t){let{noHtml:n,disableLineBreaks:r}=this.props;if(n||r||t.match(/<((?:\/[ a-z]+)|(?:[ a-z]+\/))>/gi))return t;let o=t.replace(/\r\n/g,`
16
+ `,Ti.MISSING_INTL_API,s);var w=n.getPluralRules(t,{type:c.pluralType}).select(d-(c.offset||0));x=c.options[w]||c.options.other}if(!x)throw new hv(c.value,d,Object.keys(c.options),s);a.push.apply(a,xu(x.value,t,n,r,o,d-(c.offset||0)));continue}}return P2(a)}function I2(e,t){return t?pn(pn(pn({},e||{}),t||{}),Object.keys(e).reduce(function(n,r){return n[r]=pn(pn({},e[r]),t[r]||{}),n},{})):e}function L2(e,t){return t?Object.keys(e).reduce(function(n,r){return n[r]=I2(e[r],t[r]),n},pn({},e)):e}function yv(e){return{create:function(){return{get:function(t){return e[t]},set:function(t,n){e[t]=n}}}}}function O2(e){return e===void 0&&(e={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:qf(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.NumberFormat).bind.apply(t,$f([void 0],n,!1)))},{cache:yv(e.number),strategy:Gf.variadic}),getDateTimeFormat:qf(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.DateTimeFormat).bind.apply(t,$f([void 0],n,!1)))},{cache:yv(e.dateTime),strategy:Gf.variadic}),getPluralRules:qf(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.PluralRules).bind.apply(t,$f([void 0],n,!1)))},{cache:yv(e.pluralRules),strategy:Gf.variadic})}}var vv=function(){function e(t,n,r,o){n===void 0&&(n=e.defaultLocale);var i=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(u){var c=i.formatToParts(u);if(c.length===1)return c[0].value;var f=c.reduce(function(d,p){return!d.length||p.type!==It.literal||typeof d[d.length-1]!="string"?d.push(p.value):d[d.length-1]+=p.value,d},[]);return f.length<=1?f[0]||"":f},this.formatToParts=function(u){return xu(i.ast,i.locales,i.formatters,i.formats,u,void 0,i.message)},this.resolvedOptions=function(){var u;return{locale:((u=i.resolvedLocale)===null||u===void 0?void 0:u.toString())||Intl.NumberFormat.supportedLocalesOf(i.locales)[0]}},this.getAst=function(){return i.ast},this.locales=n,this.resolvedLocale=e.resolveLocale(n),typeof t=="string"){if(this.message=t,!e.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var s=o||{},a=s.formatters,l=GT(s,["formatters"]);this.ast=e.__parse(t,pn(pn({},l),{locale:this.resolvedLocale}))}else this.ast=t;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=L2(e.formats,r),this.formatters=o&&o.formatters||O2(this.formatterCache)}return Object.defineProperty(e,"defaultLocale",{get:function(){return e.memoizedDefaultLocale||(e.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),e.memoizedDefaultLocale},enumerable:!1,configurable:!0}),e.memoizedDefaultLocale=null,e.resolveLocale=function(t){if(typeof Intl.Locale!="undefined"){var n=Intl.NumberFormat.supportedLocalesOf(t);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof t=="string"?t:t[0])}},e.__parse=ZT,e.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"}}},e}();function M2(e,t){return t.split(".").reduce((n,r)=>n?n[r]:void 0,e)}var N2="dummy",xv=(0,Jf.createContext)(null);function ue(e){var r;let t=(0,Jf.useContext)(xv);if(!t)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let n=(r=e[t])!=null?r:{};return(o,i)=>{let s=M2(n,o);return s?new vv(s).format(i):(t!==N2&&console.warn(`${o} does not exist in messages of ${t}`),`[${o}]`)}}var ep=S($());var tC={root:"dd-tvkOF",content:"dd-eXA1D"};var wv=S(R()),_2=({isOpen:e,autoFocus:t,children:n,onClose:r,onBack:o,onKeyDown:i,overlayAriaLabel:s,contentAriaLabel:a})=>{let l=(0,ep.useRef)(null),u=F("Dialog",tC),c=d=>{if(d.key==="Escape"){d.preventDefault(),d.stopPropagation(),o();return}i&&i(d)},f=d=>{d.target===l.current&&e&&r()};return(0,ep.useEffect)(()=>{var d,p;!l.current||!e||!t||(p=(d=l.current)==null?void 0:d.querySelector("input, textarea"))==null||p.focus()},[e,t,l]),e?(0,wv.jsx)("div",{role:"dialog","data-testid":"dialog",className:u.root,"aria-label":s,ref:l,onKeyDown:c,onMouseDown:f,children:(0,wv.jsx)("div",{"data-testid":"dialog-content",className:u.content,"aria-label":a,children:n})}):null},tp=_2;var rC=S(Fe());var nC={root:"dd-ranhW"};var oC=S(R()),D2=r=>{var o=r,{className:e,value:t}=o,n=se(o,["className","value"]);let i=F("TextInput",nC);return(0,oC.jsx)("input",b({className:(0,rC.default)(e,i.root),type:"text",value:t},n))},wu=D2;var Sv={};bt(Sv,{enUS:()=>F2,nlNL:()=>H2});var F2={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"}]},H2={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 iC={root:"dd-lWxnE",anchorButton:"dd-TZ4in",errorMessage:"dd-fIsPg",title:"dd-pGhJx",subtitle:"dd-f5l29",text:"dd-iamoD",input:"dd-uhQZ3",actions:"dd-lubvx",button:"dd-CJsNI",primaryButton:"dd-MWBfl"};var et=S(R());var z2=e=>{try{let t=new URL(e);return new URLSearchParams(t.search).get("token")||void 0}catch(t){return e}},B2=({agentEmail:e,isOpen:t,origin:n="",onSuccess:r,onDismiss:o})=>{let i=ue(Sv),s=F("LoginTokenDialog",iC),a=K(nT),l=he(),u=J("productName"),[c,f]=(0,Vn.useState)(e||""),[d,p]=(0,Vn.useState)(0),[y,h]=(0,Vn.useState)(""),g=(0,Vn.useCallback)(w=>A(void 0,null,function*(){w.preventDefault(),l(oT({email:c})),p(1)}),[n,c]),m=()=>{h(""),p(0)},v=(0,Vn.useCallback)(w=>A(void 0,null,function*(){w.preventDefault();let C=z2(w.target.elements.token.value);if(!C){h(i("verifyCodeError",{login:x}));return}l(ou({token:C}))}),[n]),x=(0,Vn.useMemo)(()=>w=>(0,et.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:s.anchorButton,onClick:m,children:w},"back-button"),[]);return(0,Vn.useEffect)(()=>{a==="error"&&h(i("verifyCodeError",{login:x})),a==="done"&&r()},[a]),(0,et.jsx)(tp,{autoFocus:!0,isOpen:t,contentAriaLabel:i("promptTitle",{productName:u}),overlayAriaLabel:i("promptTitle",{productName:u}),onClose:o,onBack:o,children:(0,et.jsxs)("div",{className:s.root,children:[(0,et.jsx)("h1",{className:s.title,children:i("promptTitle",{productName:u})}),d===0&&(0,et.jsxs)("form",{onSubmit:g,children:[(0,et.jsx)("h2",{className:s.subtitle,children:i("requestCodeTitle")}),(0,et.jsx)("p",{className:s.text,children:i("requestCodeBody",{productName:u})}),(0,et.jsx)(wu,{className:s.input,name:"email",placeholder:i("requestCodeInputPlaceholder"),value:c,onChange:w=>f(w.target.value)}),(0,et.jsx)("div",{className:s.actions,children:(0,et.jsx)("button",{type:"submit",className:(0,np.default)(s.button,s.primaryButton),children:i("requestCodeSubmitLabel")})})]}),d===1&&(0,et.jsxs)("form",{onSubmit:v,children:[(0,et.jsx)("h2",{className:s.subtitle,children:i("verifyCodeTitle")}),(0,et.jsx)("p",{className:s.text,children:i("verifyCodeBody")}),(0,et.jsx)(wu,{className:s.input,name:"token",placeholder:i("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),y&&(0,et.jsx)("div",{className:s.errorMessage,children:y}),(0,et.jsxs)("div",{className:s.actions,children:[(0,et.jsx)("button",{type:"button",className:(0,np.default)(s.button),onClick:m,children:i("back")}),(0,et.jsx)("button",{type:"submit",className:(0,np.default)(s.button,s.primaryButton),disabled:["loading","done"].includes(a),children:i("verifyCodeSubmitLabel")})]})]})]})})},sC=B2;var lC=S(R()),U2=()=>{let e=K(rT),t=K(aa),n=J("adminUrl"),r=on(),o=()=>r.send(la,!1),i=()=>{r.send(la,!1),r.send(lu)};return(0,lC.jsx)(sC,{isOpen:e,agentEmail:t==null?void 0:t.agentEmail,origin:n,onDismiss:o,onSuccess:i})},aC=U2;var vP=S(Tv()),$t=S($());var Su="__summarizerAssistant__",fC={cues:[],threads:{},fetchState:"idle"},pC=e=>{var t;return(t=e.assistants)==null?void 0:t.cues};var bu=e=>t=>{var n,r;return(r=(n=t.assistants)==null?void 0:n.threads[e])!=null?r:null},rp=ot("assistants/callToAction"),Wn=ge("assistants/evaluateSummaryAssistant",(e,t)=>A(void 0,null,function*(){let r=t.getState().profile.data;if(!r)throw new Error("No Profile is loaded");let{summarizerAssistantNew:o}=r;if(!o)throw new Error("No Summarizer Assistant set in Profile");let i=yield t.dispatch(Kn(b({assistantCode:o,expectFormat:"text",transcript:"in-memory-transcript",skipState:!0},e)));if(i.error)throw new Error(i.error.message);if(typeof i.payload!="string")throw ee.warn("Unexpected summary output",i),new Error("Unexpected summary output");return i.payload})),i_=1,Ci=ge("assistants/evaluateKnowledgeAssistantLegacy",(e,t)=>A(void 0,null,function*(){var p,y,h,g;let{threadId:n}=e,{onNewThreadId:r,input:o}=e,{deepdeskAPI:i}=t.extra,s=t.getState(),{platformVariables:a}=s.info;n||(n=i_++,r&&r(n));let l=(p=bu(n)(s))!=null?p:[],u=yield i.getKnowledgeAssistant(e.assistantCode),c=(y=s.conversation.current)==null?void 0:y.externalId,f=(g=(h=s.info)==null?void 0:h.agentInfo)==null?void 0:g.agentId;if(!u)throw new Error("KnowledgeAssistant is not found");let d=yield i.knowledgeAssist({customerInstruction:u.customerInstruction,doNotKnowAnswer:u.doNotKnowAnswer,question:o},l,u.code,{agentId:f,conversationId:c});return a&&(d.answer=rn(d.answer,a)),{threadId:n,question:o,answer:d}})),ki=ge("assistants/evaluateKnowledgeAssistant",(e,t)=>A(void 0,null,function*(){let{threadId:n}=e,{onNewThreadId:r}=e,{deepdeskAPI:o}=t.extra,i=t.getState(),{platformVariables:s}=i.info;n||(n=(yield o.createAssistantThread({assistantCode:e.assistantCode})).id,r&&r(n)),yield o.postMessageToAssistantThread({assistantCode:e.assistantCode,threadId:n,message:e.input});let a=yield t.dispatch(Kn(P(b({expectFormat:"json-schema:knowledge-assist",skipState:!0},e),{input:{},threadId:n})));if(a.error)throw new Error(a.error.message);let l=a.payload;return{threadId:n,question:e.input,answer:{answer:rn(l.response,s!=null?s:{}),sources:l.sources}}})),Kn=ge("assistants/evaluate",(e,t)=>A(void 0,null,function*(){var p;let{deepdeskAPI:n,dynamicThunkObject:r}=t.extra,{transcript:o,input:i={},expectFormat:s,threadId:a}=e,l=t.getState(),{platformVariables:u}=l.info,c=(p=l.conversation.current)==null?void 0:p.externalId,f;if(o==="in-memory-transcript"){if(!r.conversationQuery)throw new Error("Can't include in-memory-transcript, setConversationQuery is not defined");f=yield r.conversationQuery()}else if(o==="stored-transcript"){if(!l.conversation.current)throw new Error("Can't include stored-transcript, no current conversation");f=l.conversation.current.messages.map(y=>({text:y.text,source:y.source}))}else Array.isArray(o)&&(f=o);if(e.includeMetadata){if(!l.conversation.current)throw new Error("Can't include metadata, no current conversation");let{metadata:y}=l.conversation.current;Object.assign(i,{metadata:y})}let d=yield n.evaluateAssistant(e.assistantCode,{expectFormat:s,input:i,transcript:f,externalConversationId:c,threadId:a});if(!u)return d;switch(s){case"text":return rn(d,u);case"json-schema:cues":return d.map(y=>P(b({},y),{name:rn(y.name,u),response:rn(y.response,u)}));case"json-schema:knowledge-assist":{let y=d;return P(b({},y),{answer:rn(y.response,u)})}default:return d}})),mC=Ce({name:"assistants",initialState:fC,reducers:{resetCues(e){e.cues=[]},removeCueByCode(e,t){e.cues=e.cues.filter(n=>n.code!==t.payload.code)},removeThreadById(e,t){delete e.threads[t.payload]}},extraReducers:e=>{e.addCase(Kn.pending,(t,n)=>{n.meta.arg.skipState||(t.fetchState="loading")}).addCase(Kn.rejected,(t,n)=>{var r;ee.warn((r=n.error)==null?void 0:r.message),!n.meta.arg.skipState&&(t.fetchState="error")}).addCase(Kn.fulfilled,(t,n)=>{if(!n.meta.arg.skipState)switch(n.meta.arg.expectFormat){case"json-schema:cues":{let r=n.payload,o=r.map(s=>s.code),i=t.cues.filter(s=>!o.includes(s.code));t.fetchState="done",t.cues=[...i,...r];break}}}).addCase(ki.fulfilled,(t,n)=>{let i=n.payload,{threadId:r}=i,o=se(i,["threadId"]);t.threads[r]=[...t.threads[r]||[],o]}).addCase(Ci.fulfilled,(t,n)=>{let i=n.payload,{threadId:r}=i,o=se(i,["threadId"]);t.threads[r]=[...t.threads[r]||[],o]}).addCase(Wn.pending,t=>{let n={code:Su,name:"Summary",response:"",isLoading:!0},r=t.cues.filter(o=>o.code!==Su);t.cues=[...r,n]}).addCase(Wn.rejected,t=>{let n=t.cues.filter(r=>r.code!==Su);t.cues=n}).addCase(Wn.fulfilled,(t,n)=>{let r={code:Su,name:"Summary",response:n.payload,specialType:"summary"},o=t.cues.filter(i=>i.code!==Su);t.cues=[...o,r]}).addCase(it,()=>fC)}}),{removeCueByCode:gC,resetCues:uB,removeThreadById:ua}=mC.actions,hC=mC.reducer;var s_={data:null,fetchState:"idle"},yC=e=>e.contentTypes.data,Eu=ge("contentTypes/getContentTypes",(e,t)=>A(void 0,null,function*(){return t.extra.deepdeskAPI.getContentTypes()})),a_=Ce({name:"contentTypes",initialState:s_,reducers:{},extraReducers:e=>{e.addCase(Eu.pending,t=>{t.fetchState="loading"}).addCase(Eu.rejected,t=>{t.fetchState="error"}).addCase(Eu.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),vC=a_.reducer;var l_={data:null,fetchState:"idle"},u_=[],Ri=e=>e.profile.data,c_=e=>e.profile.data?e.profile.data.uiConfig.widget.types:u_,Cu=Un([c_],e=>e.filter(t=>t.isActive)),xC=e=>{var t;return(t=e.profile.data)==null?void 0:t.summarizerAssistantNew},wC=e=>{var t;return((t=e.profile.data)==null?void 0:t.onDemandAssistants)||[]},Cv=e=>t=>Cu(t).some(n=>n.type===e),SC=e=>e.profile.data?!!e.profile.data.uiConfig.widget.types.find(t=>t.type==="custom-data"):!1,op=e=>{var t;return(t=e.profile.data)==null?void 0:t.knowledgeAssistantNew},ip=e=>{var t;return(t=e.profile.data)==null?void 0:t.knowledgeAssistant},Tu=ge("profile/getProfile",(e,t)=>A(void 0,null,function*(){var i;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=r.conversation.current;if(!o||!o.profileCode)throw new Error("No conversation of conversation profileCode found");return((i=r.profile.data)==null?void 0:i.code)===o.profileCode?r.profile.data:n.getProfile(o.profileCode)})),d_=Ce({name:"profile",initialState:l_,reducers:{},extraReducers:e=>{e.addCase(Tu.pending,t=>{t.fetchState="loading"}).addCase(Tu.rejected,t=>{t.fetchState="error"}).addCase(Tu.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),bC=d_.reducer;function xr(e){let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select(),document.execCommand("copy"),t.remove()}var Qr=S($());var EC=S($()),sp=S(Fe());var mn={root:"dd-U2SX4",list:"dd-cYTlj",listWrapper:"dd-GLQFR",listHorizontal:"dd-x-knl",page:"dd-1F4vk",search:"dd-nvbxc",pageNav:"dd-sRUuT",pageTitle:"dd-t-MKS",pageBackButton:"dd-cjptm",listHeader:"dd-Fg666",listHeading:"dd-w-xhJ",listMoreButton:"dd--mKep",listItem:"dd-wpvuA",listItemContent:"dd-V-mKo",listItemText:"dd-ukCHL",listItemDescription:"dd-sSyu4",listItemActions:"dd-xelho",listItemTooltip:"dd-SWFsE",listItemTooltipContent:"dd-I7J9N",truncate:"dd-IlopJ",lineClamp:"dd-Twaca",listItemTitle:"dd-lMGHq",listItemAction:"dd-xPLAs",listItemSelected:"dd-jFX0Y",sources:"dd-pZx4v",sourcesTitle:"dd-phYVd",source:"dd-DaR6h",sourceShowMore:"dd-M1-8j",icon:"dd-m6yxD",searchIcon:"dd-0AU-O",searchInputWrapper:"dd-DUFcE",searchInput:"dd-ukrlD",select:"dd--Tifv",selectType:"dd-IkZb2",selectWrapper:"dd-J14mx",image:"dd-RQgsB",imageSrc:"dd-jxh8F",imageSrcHidden:"dd-e20Jk",imageSrcStatus:"dd-j50Tt",imageTitle:"dd-qCjfW",actions:"dd-3mfWc",actionsWrapper:"dd-TjDyI",actionsBar:"dd-LiA35",actionButton:"dd-4wk0u",hasShortKeys:"dd-XilV-",actionShortcut:"dd-s4Mla",actionShortcutFixKerning:"dd-lyh5e"};var $r={};bt($r,{enUS:()=>f_,nlNL:()=>p_});var f_={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}],showAll:[{type:0,value:"Show more"}],sources:[{type:0,value:"Sources"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},p_={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}],showAll:[{type:0,value:"Toon meer"}],sources:[{type:0,value:"Bronnen"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var Uo=S(R()),m_=({src:e,title:t})=>{let n=F("CommandPalette",mn),[r,o]=(0,EC.useState)("loading"),i=ue($r);return(0,Uo.jsxs)("div",{className:n.image,children:[(0,Uo.jsx)("img",{src:e,alt:t,onLoad:()=>o("done"),onError:()=>o("error"),className:(0,sp.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(r)})}),r==="loading"&&(0,Uo.jsx)("span",{className:(0,sp.default)(n.imageSrc,n.imageSrcStatus),children:i("loading")}),r==="error"&&(0,Uo.jsx)("span",{className:(0,sp.default)(n.imageSrc,n.imageSrcStatus),children:(0,Uo.jsx)(Oc,{})}),t&&(0,Uo.jsx)("span",{className:n.imageTitle,children:t})]})},TC=m_;var CC=S($()),kC=S(Fe());var Pi=S(R());function kv({children:e,heading:t,orientation:n,hasMore:r,onShowAll:o}){let i=ue($r),s=F("CommandPalette",mn);return CC.default.Children.count(e)===0?null:(0,Pi.jsxs)("div",{"data-testid":"commandpalette-list",className:s.list,children:[(t||r)&&(0,Pi.jsxs)("div",{className:s.listHeader,children:[t&&(0,Pi.jsx)("h4",{className:s.listHeading,children:t}),r&&o&&(0,Pi.jsx)("button",{onClick:o,className:s.listMoreButton,type:"button",children:i("showAll")})]}),(0,Pi.jsx)("div",{className:(0,kC.default)(s.listWrapper,n==="horizontal"&&s.listHorizontal),children:e})]})}var Bu=S(Fe());var ap=S($());function ku(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ke=1,Pv=2,Av=4,st=8,lp=16,Ru=32,$n=64,Rv={a:{content:ke|st,self:!1,type:ke|st|Ru|$n},address:{invalid:["h1","h2","h3","h4","h5","h6","address","article","aside","section","div","header","footer"],self:!1},audio:{children:["track","source"]},br:{type:ke|st,void:!0},body:{content:ke|Pv|Av|st|lp|Ru|$n},button:{content:st,type:ke|st|Ru|$n},caption:{content:ke,parent:["table"]},col:{parent:["colgroup"],void:!0},colgroup:{children:["col"],parent:["table"]},details:{children:["summary"],type:ke|Ru|$n},dd:{content:ke,parent:["dl"]},dl:{children:["dt","dd"],type:ke},dt:{content:ke,invalid:["footer","header"],parent:["dl"]},figcaption:{content:ke,parent:["figure"]},footer:{invalid:["footer","header"]},header:{invalid:["footer","header"]},hr:{type:ke,void:!0},img:{void:!0},li:{content:ke,parent:["ul","ol","menu"]},main:{self:!1},ol:{children:["li"],type:ke},picture:{children:["source","img"],type:ke|st|lp},rb:{parent:["ruby","rtc"]},rp:{parent:["ruby","rtc"]},rt:{content:st,parent:["ruby","rtc"]},rtc:{content:st,parent:["ruby"]},ruby:{children:["rb","rp","rt","rtc"]},source:{parent:["audio","video","picture"],void:!0},summary:{content:st,parent:["details"]},table:{children:["caption","colgroup","thead","tbody","tfoot","tr"],type:ke},tbody:{parent:["table"],children:["tr"]},td:{content:ke,parent:["tr"]},tfoot:{parent:["table"],children:["tr"]},th:{content:ke,parent:["tr"]},thead:{parent:["table"],children:["tr"]},tr:{parent:["table","tbody","thead","tfoot"],children:["th","td"]},track:{parent:["audio","video"],void:!0},ul:{children:["li"],type:ke},video:{children:["track","source"]},wbr:{type:ke|st,void:!0}};function Ii(e){return t=>{Rv[t]=b(b({},e),Rv[t])}}["address","main","div","figure","p","pre"].forEach(Ii({content:ke,type:ke|$n}));["abbr","b","bdi","bdo","cite","code","data","dfn","em","i","kbd","mark","q","ruby","samp","strong","sub","sup","time","u","var"].forEach(Ii({content:st,type:ke|st|$n}));["p","pre"].forEach(Ii({content:st,type:ke|$n}));["s","small","span","del","ins"].forEach(Ii({content:st,type:ke|st}));["article","aside","footer","header","nav","section","blockquote"].forEach(Ii({content:ke,type:ke|Pv|$n}));["h1","h2","h3","h4","h5","h6"].forEach(Ii({content:st,type:ke|Av|$n}));["audio","canvas","iframe","img","video"].forEach(Ii({type:ke|st|lp|$n}));var Au=Object.freeze(Rv),Iv=["applet","base","body","command","embed","frame","frameset","head","html","link","meta","noscript","object","script","style","title"],Lv=Object.keys(Au).filter(e=>e!=="canvas"&&e!=="iframe"),_e=1,Ov=2,Ai=3,jo=4,cp=5,dp=Object.freeze({alt:_e,cite:_e,class:_e,colspan:Ai,controls:jo,datetime:_e,default:jo,disabled:jo,dir:_e,height:_e,href:_e,id:_e,kind:_e,label:_e,lang:_e,loading:_e,loop:jo,media:_e,muted:jo,poster:_e,rel:_e,role:_e,rowspan:Ai,scope:_e,sizes:_e,span:Ai,start:Ai,style:cp,src:_e,srclang:_e,srcset:_e,tabindex:_e,target:_e,title:_e,type:_e,width:_e}),Mv=Object.freeze({class:"className",colspan:"colSpan",datetime:"dateTime",rowspan:"rowSpan",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex"});function up(){return up=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},up.apply(this,arguments)}function fp({attributes:e={},className:t,children:n=null,selfClose:r=!1,tagName:o}){let i=o;return r?ap.default.createElement(i,up({className:t},e)):ap.default.createElement(i,up({className:t},e),n)}var Pu=class{attribute(t,n){return n}node(t,n){return n}};function RC(e,t,n,r=!1){let o=e.match(t instanceof RegExp?t:new RegExp(t,"i"));return o?P(b({match:o[0],void:r},n(o)),{index:o.index,length:o[0].length,valid:!0}):null}var qr=class{constructor(t,n,r){ku(this,"greedy",!1),ku(this,"options",void 0),ku(this,"propName",void 0),ku(this,"inverseName",void 0),ku(this,"factory",void 0),this.options=b({},n),this.propName=t,this.inverseName=`no${t.charAt(0).toUpperCase()+t.slice(1)}`,this.factory=r!=null?r:null}createElement(t,n){return this.factory?ap.default.createElement(this.factory,n,t):this.replaceWith(t,n)}doMatch(t,n,r,o=!1){return RC(t,n,r,o)}onBeforeParse(t,n){return t}onAfterParse(t,n){return t}};var Li=S($()),LC=S(AC());function Gr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var y_=/(url|image|image-set)\(/i,Nv=class extends Pu{attribute(t,n){return t==="style"&&Object.keys(n).forEach(r=>{String(n[r]).match(y_)&&delete n[r]}),n}},IC=1,v_=3,x_=/^<(!doctype|(html|head|body)(\s|>))/i,w_=/^(aria-|data-|\w+:)/iu,S_=/{{{(\w+)\/?}}}/;function b_(){if(!(typeof window=="undefined"||typeof document=="undefined"))return document.implementation.createHTMLDocument("Interweave")}var pp=class{constructor(t,n={},r=[],o=[]){var i;Gr(this,"allowed",void 0),Gr(this,"banned",void 0),Gr(this,"blocked",void 0),Gr(this,"container",void 0),Gr(this,"content",[]),Gr(this,"props",void 0),Gr(this,"matchers",void 0),Gr(this,"filters",void 0),Gr(this,"keyIndex",void 0),this.props=n,this.matchers=r,this.filters=[...o,new Nv],this.keyIndex=-1,this.container=this.createContainer(t||""),this.allowed=new Set((i=n.allowList)!==null&&i!==void 0?i:Lv),this.banned=new Set(Iv),this.blocked=new Set(n.blockList)}applyAttributeFilters(t,n){return this.filters.reduce((r,o)=>r!==null&&typeof o.attribute=="function"?o.attribute(t,r):r,n)}applyNodeFilters(t,n){return this.filters.reduce((r,o)=>r!==null&&typeof o.node=="function"?o.node(t,r):r,n)}applyMatchers(t,n){let r={},{props:o}=this,i=t,s=0,a=null;return this.matchers.forEach(l=>{let u=l.asTag().toLowerCase(),c=this.getTagConfig(u);if(o[l.inverseName]||!this.isTagAllowed(u)||!this.canRenderChild(n,c))return;let f="";for(;i&&(a=l.match(i));){let d=a,{index:p,length:y,match:h,valid:g,void:m}=d,v=se(d,["index","length","match","valid","void"]),x=l.propName+String(s);p>0&&(f+=i.slice(0,p)),g?(f+=m?`{{{${x}/}}}`:`{{{${x}}}}${h}{{{/${x}}}}`,this.keyIndex+=1,s+=1,r[x]={children:h,matcher:l,props:P(b(b({},o),v),{key:this.keyIndex})}):f+=h,l.greedy?(i=f+i.slice(p+y),f=""):i=i.slice(p+(y||h.length))}l.greedy||(i=f+i)}),s===0?t:this.replaceTokens(i,r)}canRenderChild(t,n){return!t.tagName||!n.tagName||t.void?!1:t.children.length>0?t.children.includes(n.tagName):t.invalid.length>0&&t.invalid.includes(n.tagName)?!1:n.parent.length>0?n.parent.includes(t.tagName):!t.self&&t.tagName===n.tagName?!1:!!(t&&t.content&n.type)}convertLineBreaks(t){let{noHtml:n,disableLineBreaks:r}=this.props;if(n||r||t.match(/<((?:\/[ a-z]+)|(?:[ a-z]+\/))>/gi))return t;let o=t.replace(/\r\n/g,`
17
17
  `);return o=o.replace(/\n{3,}/g,`
18
18
 
19
19
 
@@ -74,13 +74,13 @@ ${t}</tr>
74
74
  `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Er(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:n,tokens:r}){let o=this.parser.parseInline(r),i=qR(t);if(i===null)return o;t=i;let s='<a href="'+t+'"';return n&&(s+=' title="'+Er(n)+'"'),s+=">"+o+"</a>",s}image({href:t,title:n,text:r}){let o=qR(t);if(o===null)return Er(r);t=o;let i=`<img src="${t}" alt="${r}"`;return n&&(i+=` title="${Er(n)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Er(t.text)}},tc=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}},tr=class e{constructor(t){Ne(this,"options");Ne(this,"renderer");Ne(this,"textRenderer");this.options=t||Ki,this.options.renderer=this.options.renderer||new La,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new tc}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(t,n=!0){var o,i;let r="";for(let s=0;s<t.length;s++){let a=t[s];if((i=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&i[a.type]){let u=a,c=this.options.extensions.renderers[u.type].call({parser:this},u);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(u.type)){r+=c||"";continue}}let l=a;switch(l.type){case"space":{r+=this.renderer.space(l);continue}case"hr":{r+=this.renderer.hr(l);continue}case"heading":{r+=this.renderer.heading(l);continue}case"code":{r+=this.renderer.code(l);continue}case"table":{r+=this.renderer.table(l);continue}case"blockquote":{r+=this.renderer.blockquote(l);continue}case"list":{r+=this.renderer.list(l);continue}case"html":{r+=this.renderer.html(l);continue}case"paragraph":{r+=this.renderer.paragraph(l);continue}case"text":{let u=l,c=this.renderer.text(u);for(;s+1<t.length&&t[s+1].type==="text";)u=t[++s],c+=`
75
75
  `+this.renderer.text(u);n?r+=this.renderer.paragraph({type:"paragraph",raw:c,text:c,tokens:[{type:"text",raw:c,text:c,escaped:!0}]}):r+=c;continue}default:{let u='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}parseInline(t,n=this.renderer){var o,i;let r="";for(let s=0;s<t.length;s++){let a=t[s];if((i=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&i[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=u||"";continue}}let l=a;switch(l.type){case"escape":{r+=n.text(l);break}case"html":{r+=n.html(l);break}case"link":{r+=n.link(l);break}case"image":{r+=n.image(l);break}case"strong":{r+=n.strong(l);break}case"em":{r+=n.em(l);break}case"codespan":{r+=n.codespan(l);break}case"br":{r+=n.br(l);break}case"del":{r+=n.del(l);break}case"text":{r+=n.text(l);break}default:{let u='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}},Vi=class{constructor(t){Ne(this,"options");Ne(this,"block");this.options=t||Ki}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?er.lex:er.lexInline}provideParser(){return this.block?tr.parse:tr.parseInline}};Ne(Vi,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));var A0=class{constructor(...t){Ne(this,"defaults",I0());Ne(this,"options",this.setOptions);Ne(this,"parse",this.parseMarkdown(!0));Ne(this,"parseInline",this.parseMarkdown(!1));Ne(this,"Parser",tr);Ne(this,"Renderer",La);Ne(this,"TextRenderer",tc);Ne(this,"Lexer",er);Ne(this,"Tokenizer",Ia);Ne(this,"Hooks",Vi);this.use(...t)}walkTokens(t,n){var o,i;let r=[];for(let s of t)switch(r=r.concat(n.call(this,s)),s.type){case"table":{let a=s;for(let l of a.header)r=r.concat(this.walkTokens(l.tokens,n));for(let l of a.rows)for(let u of l)r=r.concat(this.walkTokens(u.tokens,n));break}case"list":{let a=s;r=r.concat(this.walkTokens(a.items,n));break}default:{let a=s;(i=(o=this.defaults.extensions)==null?void 0:o.childTokens)!=null&&i[a.type]?this.defaults.extensions.childTokens[a.type].forEach(l=>{let u=a[l].flat(1/0);r=r.concat(this.walkTokens(u,n))}):a.tokens&&(r=r.concat(this.walkTokens(a.tokens,n)))}}return r}use(...t){let n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{let o=b({},r);if(o.async=this.defaults.async||o.async||!1,r.extensions&&(r.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=n.renderers[i.name];s?n.renderers[i.name]=function(...a){let l=i.renderer.apply(this,a);return l===!1&&(l=s.apply(this,a)),l}:n.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=n[i.level];s?s.unshift(i.tokenizer):n[i.level]=[i.tokenizer],i.start&&(i.level==="block"?n.startBlock?n.startBlock.push(i.start):n.startBlock=[i.start]:i.level==="inline"&&(n.startInline?n.startInline.push(i.start):n.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(n.childTokens[i.name]=i.childTokens)}),o.extensions=n),r.renderer){let i=this.defaults.renderer||new La(this.defaults);for(let s in r.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let a=s,l=r.renderer[a],u=i[a];i[a]=(...c)=>{let f=l.apply(i,c);return f===!1&&(f=u.apply(i,c)),f||""}}o.renderer=i}if(r.tokenizer){let i=this.defaults.tokenizer||new Ia(this.defaults);for(let s in r.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let a=s,l=r.tokenizer[a],u=i[a];i[a]=(...c)=>{let f=l.apply(i,c);return f===!1&&(f=u.apply(i,c)),f}}o.tokenizer=i}if(r.hooks){let i=this.defaults.hooks||new Vi;for(let s in r.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let a=s,l=r.hooks[a],u=i[a];Vi.passThroughHooks.has(s)?i[a]=c=>{if(this.defaults.async)return Promise.resolve(l.call(i,c)).then(d=>u.call(i,d));let f=l.call(i,c);return u.call(i,f)}:i[a]=(...c)=>{let f=l.apply(i,c);return f===!1&&(f=u.apply(i,c)),f}}o.hooks=i}if(r.walkTokens){let i=this.defaults.walkTokens,s=r.walkTokens;o.walkTokens=function(a){let l=[];return l.push(s.call(this,a)),i&&(l=l.concat(i.call(this,a))),l}}this.defaults=b(b({},this.defaults),o)}),this}setOptions(t){return this.defaults=b(b({},this.defaults),t),this}lexer(t,n){return er.lex(t,n!=null?n:this.defaults)}parser(t,n){return tr.parse(t,n!=null?n:this.defaults)}parseMarkdown(t){return(r,o)=>{let i=b({},o),s=b(b({},this.defaults),i),a=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&i.async===!1)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof r=="undefined"||r===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));s.hooks&&(s.hooks.options=s,s.hooks.block=t);let l=s.hooks?s.hooks.provideLexer():t?er.lex:er.lexInline,u=s.hooks?s.hooks.provideParser():t?tr.parse:tr.parseInline;if(s.async)return Promise.resolve(s.hooks?s.hooks.preprocess(r):r).then(c=>l(c,s)).then(c=>s.hooks?s.hooks.processAllTokens(c):c).then(c=>s.walkTokens?Promise.all(this.walkTokens(c,s.walkTokens)).then(()=>c):c).then(c=>u(c,s)).then(c=>s.hooks?s.hooks.postprocess(c):c).catch(a);try{s.hooks&&(r=s.hooks.preprocess(r));let c=l(r,s);s.hooks&&(c=s.hooks.processAllTokens(c)),s.walkTokens&&this.walkTokens(c,s.walkTokens);let f=u(c,s);return s.hooks&&(f=s.hooks.postprocess(f)),f}catch(c){return a(c)}}}onError(t,n){return r=>{if(r.message+=`
76
76
  Please report this to https://github.com/markedjs/marked.`,t){let o="<p>An error occurred:</p><pre>"+Er(r.message+"",!0)+"</pre>";return n?Promise.resolve(o):o}if(n)return Promise.reject(r);throw r}}},Wi=new A0;function Re(e,t){return Wi.parse(e,t)}Re.options=Re.setOptions=function(e){return Wi.setOptions(e),Re.defaults=Wi.defaults,XR(Re.defaults),Re};Re.getDefaults=I0;Re.defaults=Ki;Re.use=function(...e){return Wi.use(...e),Re.defaults=Wi.defaults,XR(Re.defaults),Re};Re.walkTokens=function(e,t){return Wi.walkTokens(e,t)};Re.parseInline=Wi.parseInline;Re.Parser=tr;Re.parser=tr.parse;Re.Renderer=La;Re.TextRenderer=tc;Re.Lexer=er;Re.lexer=er.lex;Re.Tokenizer=Ia;Re.Hooks=Vi;Re.parse=Re;var kW=Re.options,RW=Re.setOptions,PW=Re.use,AW=Re.walkTokens,IW=Re.parseInline;var LW=tr.parse,OW=er.lex;var nr=S(R());function p4(e){return`<button type="button" data-copy-icon class=${e}><svg version="1.1" x="0px" y="0px" viewBox="0 0 115.77 122.88" width="10px" height="10px" fill="black"><g><path d="M89.62,13.96v7.73h12.19h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02v0.02 v73.27v0.01h-0.02c-0.01,3.84-1.57,7.33-4.1,9.86c-2.51,2.5-5.98,4.06-9.82,4.07v0.02h-0.02h-61.7H40.1v-0.02 c-3.84-0.01-7.34-1.57-9.86-4.1c-2.5-2.51-4.06-5.98-4.07-9.82h-0.02v-0.02V92.51H13.96h-0.01v-0.02c-3.84-0.01-7.34-1.57-9.86-4.1 c-2.5-2.51-4.06-5.98-4.07-9.82H0v-0.02V13.96v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07V0h0.02h61.7 h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02V13.96L89.62,13.96z M79.04,21.69v-7.73v-0.02h0.02 c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v64.59v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h12.19V35.65 v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07v-0.02h0.02H79.04L79.04,21.69z M105.18,108.92V35.65v-0.02 h0.02c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v73.27v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h61.7h0.02 v0.02c0.91,0,1.75-0.39,2.37-1.01c0.61-0.61,1-1.46,1-2.37h-0.02V108.92L105.18,108.92z"/></g></svg></button>`}function F0(e){var n,r;let t=e.cloneNode(!0);return t.querySelectorAll("div,button").forEach(o=>o.remove()),(r=(n=t.textContent)==null?void 0:n.trim())!=null?r:""}function m4(e){return e.replace(/\r\n/g,`
77
- `)}var g4=({content:e,useLabel:t,copyLabel:n,onCopy:r,onUse:o})=>{let i=F("Markdown",WR),s=(0,to.useRef)(null),[a,l]=(0,to.useState)(null),u=(0,to.useMemo)(()=>{let h=Re.parse(m4(e));return FR.sanitize(h.toString()).replaceAll("</code>",`${p4(i.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[e]),c=h=>{var v;let g=h.target,m=!!((v=s.current)!=null&&v.querySelector("code"));if(["A","BUTTON"].includes(g.tagName)){l(null);return}a||m&&g.tagName!=="CODE"||!m&&g!==s.current||(g.addEventListener("mouseleave",()=>l(null),{once:!0}),l(g))},f=()=>{if(!a)return;l(null);let h=a.querySelector("button");h&&(ka(h,i.fadeup),r==null||r(F0(a)))},d=h=>{let g=h.target;if(g.tagName==="A"){h.stopPropagation();return}"copyIcon"in g.dataset&&(ka(g,i.fadeup),r==null||r(F0(g.parentElement)))},p=()=>{!a||!o||(l(null),o(F0(a)))},y=h=>{if(h===null)return;let g=h.getBoundingClientRect();g.left<0?h.style.transform=`translateX(${-g.left+2}px)`:g.right>window.innerWidth&&(h.style.transform=`translateX(${window.innerWidth-g.right-2}px)`)};return(0,nr.jsxs)(to.Fragment,{children:[a&&(r||o)&&(0,nr.jsxs)(Aa,{triggerRef:{current:a},className:i.popover,parentNode:a,children:[(0,nr.jsxs)("div",{className:i.options,ref:y,children:[r&&(0,nr.jsx)("button",{type:"button",className:i.option,onClick:f,children:n}),o&&(0,nr.jsxs)(to.Fragment,{children:[(0,nr.jsx)("div",{className:i.divider}),(0,nr.jsx)("button",{type:"button",className:i.option,onClick:p,children:t})]})]}),(0,nr.jsx)("div",{className:i.arrow})]}),(0,nr.jsx)("div",{ref:s,"data-testid":"widget-markdown-content",className:i.root,dangerouslySetInnerHTML:{__html:u},onMouseOver:c,onClick:d})]})},$i=g4;var Ot=S(R()),h4=({threadId:e,onEvaluate:t,onUse:n,onResetQuestion:r,question:o})=>{var g;let[i,s]=qi.default.useState(""),{setSelected:a}=Vo(),l=(0,qi.useRef)(null),u=F("KnowledgeSearchStyles",bR),c=ue(y0),f=at(),d=(g=K(bu(e!=null?e:-1)))!=null?g:[],p=Zr(t,{onSuccess(m){f("knowledge assist question answered",{question:i||o||"",sources:m.answer.sources,answer:m.answer.answer,isFollowUpQuestion:d.length>=1,isAutoInitiated:!i&&!!o}),a(`knowledge-assist-${d.length}`),s("")}}),y=m=>A(void 0,null,function*(){m.preventDefault(),m.stopPropagation(),i!==""&&p.call(i)}),h=(m,v)=>{f("knowledge assist source viewed",{question:v,sourceViewed:m.url||m.name})};return(0,qi.useEffect)(()=>{var m;o&&p.state==="idle"?p.call(o):(m=l.current)==null||m.focus()},[l,p.state]),(0,qi.useEffect)(()=>{l.current&&l.current.scrollIntoView({behavior:"smooth"})},[l,d]),(0,Ot.jsxs)("div",{className:u.root,children:[d.length>0&&(0,Ot.jsx)("div",{className:u.alignRight,children:(0,Ot.jsx)(qe.Button,{onClick:r,children:c("reset")})}),d.map(({question:m,answer:v},x)=>(0,Ot.jsx)(qe.List,{children:(0,Ot.jsx)(qe.ListItem,{id:`knowledge-assist-${x}`,"data-testid":"knowledge-search-answer",description:(0,Ot.jsx)($i,{content:v.answer}),closeOnSelect:!0,onClick:()=>n(v.answer),onSourceClick:w=>h(w,m),sources:v.sources,styles:{title:u.question,description:u.answer},extra:(0,Ot.jsx)("div",{className:u.listItemFeedback,children:(0,Ot.jsx)(Bi,{feedbackText:v.answer,feedbackType:"knowledge-assist-answer",eventName:"knowledge assist feedback",eventData:b({question:m,isAgent:o!==m,isFollowUpQuestion:d.length>1},v)})}),children:m})},`${v.answer}_${x}`)),p.state==="loading"&&(0,Ot.jsx)("p",{className:u.status,children:c("loading")}),p.state==="error"&&(0,Ot.jsx)("p",{className:u.status,children:c("error")}),(0,Ot.jsxs)("form",{className:u.form,onSubmit:y,children:[(0,Ot.jsx)("input",{ref:l,placeholder:c("anotherQuestion"),className:u.input,type:"text",value:i,onFocus:()=>{a(void 0)},onChange:m=>{a(void 0),s(m.target.value)}}),(0,Ot.jsx)("button",{type:"submit",className:u.submit,disabled:p.state==="loading",children:(0,Ot.jsx)(SR,{})})]})]})},aP=h4;var H0=S(R()),Zp=e=>(0,H0.jsx)("svg",P(b({xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512"},e),{children:(0,H0.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 rc={};bt(rc,{enUS:()=>y4,nlNL:()=>v4});var y4={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"}]},v4={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 Jp={trigger:"dd-dQ-OH",content:"dd-9k0N3",item:"dd-va6pa"};var Gi=S(R()),x4=({suggestion:e,source:t,context:n})=>{let r=ue(rc),o=K(yr),i=he(),s=J("enableSuggestionFeedback"),a=`${e.text}`,l=K(Ra(`/admin/feedback?conversationId=${o}&type=${t}&text=${a}&data=${JSON.stringify({context:n})}`)),u=()=>{i(Wr({name:"suggestion feedback",data:{text:e.text,source:t,context:n},options:{includeConversationData:!0}}))};return!s||!l?null:(0,Gi.jsxs)(pt,{placement:"top-end",children:[(0,Gi.jsx)(pt.Trigger,{className:Jp.trigger,children:(0,Gi.jsx)(Zp,{"data-testid":"feedback-dropdown-trigger"})}),(0,Gi.jsx)(pt.Content,{className:Jp.content,children:(0,Gi.jsx)(pt.Button,{className:Jp.item,as:"a",onClick:u,target:"_blank",href:l,children:r("giveFeedback")})})]})},em=x4;var oc={};bt(oc,{enUS:()=>w4,nlNL:()=>S4});var w4={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"URL 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"}],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?"}]},S4={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:"URL 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"}],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 hP=S($());var b4=["{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}"],E4=new RegExp(b4.map(e=>`(?:${e.replace("{","\\{").replace("}","\\}")})`).join("|"));function lP(e,t){let n=e.split(E4),r=0,o=[];for(let i=0;i<n.length;i++){let s=n[i];if(o.push(s),i===n.length-1)break;if(t.indexOf(s)===-1)return e;let a=n[i+1],l=i===n.length-2;r+=s.length;let u=r;if(l){let f=a.charAt(0),d=0;do u=f?t.indexOf(f,u+1):-1,d+=1;while(u!==-1&&a.indexOf(t.slice(u))!==0);if(u===-1&&d>2)return e}else u=a&&a!==""?t.indexOf(a,r):-1;let c=u===-1?t.slice(r):t.slice(r,u);o.push(c),r=u}return o.join("")}function uP(e,t){return typeof t=="boolean"?e:e.slice(0,t)}var dP={suggestions:[],fetchState:"idle"},cP={default:dP},fP=e=>t=>{var n,r;return(r=(n=t.textSuggestions[e])==null?void 0:n.suggestions)!=null?r:[]},tm=e=>e.textSuggestions,pP=e=>{let t=e.toLowerCase();return n=>{let r=n.text.toLowerCase();return r.startsWith(t)&&r.length>t.length}},nm=ot("textSuggestions/refresh"),rr=ge("textSuggestions/recommendations",(e,t)=>A(void 0,null,function*(){var c;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(c=r.conversation.current)==null?void 0:c.id,{platformVariables:i}=r.info,{textSuggestionsCount:s,inlineSuggestions:a}=r.settings,l=ia(r);if(!o)throw new Error("No current conversation to fetch text suggestions");let u=yield n.getTextSuggestions(o,au(r),e);if(i&&(u=u.map(f=>b(P(b({},f),{text:rn(f.text,i)}),f.title?{title:rn(f.title,i)}:{}))),e==="default"){let f=a?u.filter(pP(l)):u;t.dispatch(zo(f.slice(0,s)))}return u})),ic=ge("textSuggestions/autocompletions",(e,t)=>A(void 0,null,function*(){var c;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(c=r.conversation.current)==null?void 0:c.id,{platformVariables:i}=r.info,{textSuggestionsCount:s,deanonymize:a,inlineSuggestions:l}=r.settings;if(!o)throw new Error("No current conversation to fetch text suggestions");let u=yield n.getAutocompleteSuggestions(o,P(b({},au(r)),{input:e}));if(!t.getState().input.text)throw new Error("Abort");return l&&(u=u.filter(pP(e))),i&&(u=u.map(f=>P(b({},f),{text:rn(f.text,i)}))),a&&(u=u.map(f=>P(b({},f),{text:f.source!=="trie-with-typos"?lP(f.text,e):f.text}))),u=uP(u,s),t.dispatch(zo(u)),u})),mP=Ce({name:"textSuggestions",initialState:cP,reducers:{setTextSuggestions:{reducer(e,t){let{contentType:n}=t.payload;e[n].fetchState="done",e[n].suggestions=t.payload.suggestions},prepare(e,t){return{payload:{contentType:e,suggestions:t}}}}},extraReducers:e=>{e.addCase(rr.pending,(t,n)=>{let r=n.meta.arg,o=t[r]||dP;return P(b({},t),{[r]:P(b({},o),{fetchState:"loading"})})}).addCase(rr.rejected,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="error")}).addCase(rr.fulfilled,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="done",t[r].suggestions=n.payload)}).addCase(ic.pending,t=>{t.default.fetchState="loading"}).addCase(ic.rejected,t=>{t.default.fetchState="error"}).addCase(ic.fulfilled,(t,n)=>{t.default.fetchState="done",t.default.suggestions=n.payload}).addCase(it,()=>cP)}}),{setTextSuggestions:NK}=mP.actions,gP=mP.reducer;var Yi=S(R()),T4=({types:e,commands:t,onClick:n})=>{let r=he(),o=ue(oc),i=K(tm);return(0,hP.useEffect)(()=>{e.forEach(({type:s})=>{(!i[s]||i[s].suggestions.length===0)&&r(rr(s))})},[]),(0,Yi.jsxs)("div",{children:[t.length>0&&(0,Yi.jsx)(qe.List,{heading:o("commands"),children:t.map((s,a)=>(0,Yi.jsx)(qe.ListItem,{id:`command-${a}`,closeOnSelect:!1,onClick:s.onClick,children:s.label},s.label))}),e.map(({type:s,title:a})=>{var l;return(0,Yi.jsx)(qe.List,{heading:a,orientation:"vertical",children:(l=i[s])==null?void 0:l.suggestions.map((u,c)=>(0,Yi.jsx)(qe.ListItem,{id:`${s}-${c}`,closeOnSelect:!1,description:u.title&&u.text,onClick:()=>n(u.text,u),"data-testid":"search-overlay-suggestion",children:u.title||u.text},`${u.id}-${u.text}`))},s)})]})},yP=T4;var vt=S(R()),k4=200,R4=5,P4=4,z0=(e,t,n)=>e.slice(0,n?10:t.toLowerCase()==="image"?P4:R4),A4=(e,t)=>!t||e.toLowerCase().includes(t.toLowerCase()),I4=()=>{var N,H,ce;let e=he(),t=on(),n=ue(oc),[r,o]=(0,$t.useState)(!1),[i,s]=(0,$t.useState)(""),[a,l]=(0,$t.useState)(null),u=K(BT),c=K(Ri),[f,d]=(0,$t.useState)(),p=K(zt),y=J("showSearch"),h=J("enableSuggestionFeedback"),g=J("showEntitiesCommand"),m=J("showKnowledgeSearch"),v=J("showImageSearch"),x=J("searchTriggerKey"),w=K(op),C=K(ip),E=K(yC),k=K(lv),I=K(UT),L=K(zT),G=((ce=(H=(N=c==null?void 0:c.uiConfig)==null?void 0:N.search)==null?void 0:H.initialTypes)==null?void 0:ce.filter(({isActive:V})=>V))||[],D=at(),j=(0,$t.useMemo)(()=>{let V=fe=>z0(k.filter(ne=>ne.type===fe.toUpperCase()),fe,f),me=(E==null?void 0:E.map(fe=>({value:fe.code.toUpperCase(),label:`${fe.name}s`,list:V(fe.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[];if(me.push({value:"PERSONAL",label:n("personalSuggestions"),list:V("PERSONAL"),lineClamp:!1,listOrientation:"vertical"},{value:"URL",label:n("urlSuggestions"),list:V("URL"),lineClamp:!1,listOrientation:"vertical"},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:V("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical"}),v&&me.push({value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:V("IMAGE"),listOrientation:"horizontal"}),G.length===0)return me;let pe=G.map(fe=>me.find(ne=>ne.value.toLowerCase()===fe.type)).filter(fe=>!!fe),Se=me.filter(fe=>!pe.find(ne=>ne.value===fe.value));return[...pe,...Se]},[E,G,v,f]),M=[{label:n("entitiesClipboard"),onClick:()=>e(Kr("entities")),shouldShow:g&&A4(n("entitiesClipboard"),i)},{label:i?`${n("knowledgeAssist")}: ${i}`:n("knowledgeAssist"),onClick:()=>{e(Kr("knowledgeAssist")),D("open knowledge assistant",{via:"search-command"})},shouldShow:m}].filter(V=>V.shouldShow).filter(()=>!f),_=(0,$t.useCallback)((0,vP.default)((V,me)=>{e(Ei({query:V,type:me,tags:["search-overlay"],size:f?50:20}))},k4),[f]),X=(0,$t.useCallback)((V,me)=>{switch(me.type){case"IMAGE":t.send(cv,{suggestion:me});break;default:t.send(vr,{text:V,suggestion:me})}e(An(!1))},[e]),te=V=>{xr(V.text),e(Wr({name:"entity copied",data:{entity:V,type:"copy"}})),e(An(!1))},q=V=>{t.send(vr,{text:V,suggestion:{source:"knowledge-assist",text:V}}),e(Wr({name:"answer used",data:{originalText:V},options:{includeConversationData:!0}})),s(""),a&&e(ua(a)),e(Kr("search")),e(An(!1))},W=V=>{let me={input:V,threadId:a,onNewThreadId:pe=>l(pe)};if(C)return Ci(b({assistantCode:C},me));if(w)return ki(b({assistantCode:w},me))};function B(V){return me=>{r?window.confirm(n("warning"))&&(V(me),o(!1)):V(me)}}return(0,$t.useEffect)(()=>{i?_(i,f):e(Kf())},[i,f]),(0,$t.useEffect)(()=>{p&&e(Eu())},[p]),fR(x,()=>{e(An(!0)),D("open search",{via:"ctrl+k"})}),!y||!c?null:(0,vt.jsxs)(qe,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:s,onChangeOpen:B(V=>e(An(V))),onChangeType:V=>d(V),onChangePage:B(V=>e(Kr(V))),selectedType:f,search:i,page:u,isOpen:L,types:j,updateDeps:[k],children:[(0,vt.jsxs)(qe.Page,{id:"search",children:[i.length===0&&(0,vt.jsx)(yP,{types:G,commands:M,onClick:X}),i.length>0&&(0,vt.jsxs)($t.Fragment,{children:[M.length>0&&(0,vt.jsx)(qe.List,{heading:n("commands"),children:M.map((V,me)=>(0,vt.jsx)(qe.ListItem,{closeOnSelect:!1,onClick:V.onClick,id:`commands-${me}`,children:V.label},V.label))}),j.map(({value:V,label:me,list:pe,lineClamp:Se,listOrientation:fe})=>(0,vt.jsx)(qe.List,{heading:me,orientation:fe==="horizontal"?"horizontal":"vertical",onShowAll:()=>d(V),hasMore:!f&&I[V.toLowerCase()]>z0(pe,V,f).length,children:z0(pe,V,f).map(ne=>(0,vt.jsx)(qe.ListItem,{id:`${V}-${ne.id}`,closeOnSelect:!1,lineClamp:Se,onClick:()=>X(ne.text,ne),description:V!=="IMAGE"?ne.title&&ne.text:void 0,tooltip:ne.text,extra:h&&(0,vt.jsx)(qe.ListItemActions,{children:(0,vt.jsx)(em,{context:i,source:"search",suggestion:ne})}),children:V==="IMAGE"?(0,vt.jsx)(qe.Image,{title:ne.title||ne.text,src:ne.image}):ne.title||ne.text},`${ne.id}-${ne.text}`))},V))]})]}),(0,vt.jsx)(qe.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:B(()=>{e(Kr("search"))}),children:(0,vt.jsx)(hR,{onCopy:te})}),(w!=null?w:C)&&(0,vt.jsx)(qe.Page,{id:"knowledgeAssist",title:n("knowledgeAssist"),onDismiss:B(()=>{a&&e(ua(a)),e(Kr("search"))}),children:(0,vt.jsx)(aP,{threadId:a,onEvaluate:W,question:i,onUse:q,onResetQuestion:()=>{a&&e(ua(a)),s(""),l(null)}})})]})},xP=I4;var sc=S(R()),L4=()=>{let e=J("showSearch"),t=J("isEmbedded");return(0,sc.jsxs)(wP.Fragment,{children:[e&&(0,sc.jsx)(xP,{}),t&&(0,sc.jsx)(aC,{})]})},SP=L4;var CP=S(Fe());var rm=S(R()),bP=({className:e})=>(0,rm.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:e,children:(0,rm.jsx)("g",{children:(0,rm.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
77
+ `)}var g4=({content:e,useLabel:t,copyLabel:n,onCopy:r,onUse:o})=>{let i=F("Markdown",WR),s=(0,to.useRef)(null),[a,l]=(0,to.useState)(null),u=(0,to.useMemo)(()=>{let h=Re.parse(m4(e));return FR.sanitize(h.toString()).replaceAll("</code>",`${p4(i.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[e]),c=h=>{var v;let g=h.target,m=!!((v=s.current)!=null&&v.querySelector("code"));if(["A","BUTTON"].includes(g.tagName)){l(null);return}a||m&&g.tagName!=="CODE"||!m&&g!==s.current||(g.addEventListener("mouseleave",()=>l(null),{once:!0}),l(g))},f=()=>{if(!a)return;l(null);let h=a.querySelector("button");h&&(ka(h,i.fadeup),r==null||r(F0(a)))},d=h=>{let g=h.target;if(g.tagName==="A"){h.stopPropagation();return}"copyIcon"in g.dataset&&(ka(g,i.fadeup),r==null||r(F0(g.parentElement)))},p=()=>{!a||!o||(l(null),o(F0(a)))},y=h=>{if(h===null)return;let g=h.getBoundingClientRect();g.left<0?h.style.transform=`translateX(${-g.left+2}px)`:g.right>window.innerWidth&&(h.style.transform=`translateX(${window.innerWidth-g.right-2}px)`)};return(0,nr.jsxs)(to.Fragment,{children:[a&&(r||o)&&(0,nr.jsxs)(Aa,{triggerRef:{current:a},className:i.popover,parentNode:a,children:[(0,nr.jsxs)("div",{className:i.options,ref:y,children:[r&&(0,nr.jsx)("button",{type:"button",className:i.option,onClick:f,children:n}),o&&(0,nr.jsxs)(to.Fragment,{children:[(0,nr.jsx)("div",{className:i.divider}),(0,nr.jsx)("button",{type:"button",className:i.option,onClick:p,children:t})]})]}),(0,nr.jsx)("div",{className:i.arrow})]}),(0,nr.jsx)("div",{ref:s,"data-testid":"widget-markdown-content",className:i.root,dangerouslySetInnerHTML:{__html:u},onMouseOver:c,onClick:d})]})},$i=g4;var Ot=S(R()),h4=({threadId:e,onEvaluate:t,onUse:n,onResetQuestion:r,question:o})=>{var g;let[i,s]=qi.default.useState(""),{setSelected:a}=Vo(),l=(0,qi.useRef)(null),u=F("KnowledgeSearchStyles",bR),c=ue(y0),f=at(),d=(g=K(bu(e!=null?e:-1)))!=null?g:[],p=Zr(t,{onSuccess(m){f("knowledge assist question answered",{question:i||o||"",sources:m.answer.sources,answer:m.answer.answer,isFollowUpQuestion:d.length>=1,isAutoInitiated:!i&&!!o}),a(`knowledge-assist-${d.length}`),s("")}}),y=m=>A(void 0,null,function*(){m.preventDefault(),m.stopPropagation(),i!==""&&p.call(i)}),h=(m,v)=>{f("knowledge assist source viewed",{question:v,sourceViewed:m.url||m.name})};return(0,qi.useEffect)(()=>{var m;o&&p.state==="idle"?p.call(o):(m=l.current)==null||m.focus()},[l,p.state]),(0,qi.useEffect)(()=>{l.current&&l.current.scrollIntoView({behavior:"smooth"})},[l,d]),(0,Ot.jsxs)("div",{className:u.root,children:[d.length>0&&(0,Ot.jsx)("div",{className:u.alignRight,children:(0,Ot.jsx)(qe.Button,{onClick:r,children:c("reset")})}),d.map(({question:m,answer:v},x)=>(0,Ot.jsx)(qe.List,{children:(0,Ot.jsx)(qe.ListItem,{id:`knowledge-assist-${x}`,"data-testid":"knowledge-search-answer",description:(0,Ot.jsx)($i,{content:v.answer}),closeOnSelect:!0,onClick:()=>n(v.answer),onSourceClick:w=>h(w,m),sources:v.sources,styles:{title:u.question,description:u.answer},extra:(0,Ot.jsx)("div",{className:u.listItemFeedback,children:(0,Ot.jsx)(Bi,{feedbackText:v.answer,feedbackType:"knowledge-assist-answer",eventName:"knowledge assist feedback",eventData:b({question:m,isAgent:o!==m,isFollowUpQuestion:d.length>1},v)})}),children:m})},`${v.answer}_${x}`)),p.state==="loading"&&(0,Ot.jsx)("p",{className:u.status,children:c("loading")}),p.state==="error"&&(0,Ot.jsx)("p",{className:u.status,children:c("error")}),(0,Ot.jsxs)("form",{className:u.form,onSubmit:y,children:[(0,Ot.jsx)("input",{ref:l,placeholder:c("anotherQuestion"),className:u.input,type:"text",value:i,onFocus:()=>{a(void 0)},onChange:m=>{a(void 0),s(m.target.value)}}),(0,Ot.jsx)("button",{type:"submit",className:u.submit,disabled:p.state==="loading",children:(0,Ot.jsx)(SR,{})})]})]})},aP=h4;var H0=S(R()),Zp=e=>(0,H0.jsx)("svg",P(b({xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512"},e),{children:(0,H0.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 rc={};bt(rc,{enUS:()=>y4,nlNL:()=>v4});var y4={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"}]},v4={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 Jp={trigger:"dd-dQ-OH",content:"dd-9k0N3",item:"dd-va6pa"};var Gi=S(R()),x4=({suggestion:e,source:t,context:n})=>{let r=ue(rc),o=K(yr),i=he(),s=J("enableSuggestionFeedback"),a=`${e.text}`,l=K(Ra(`/admin/feedback?conversationId=${o}&type=${t}&text=${a}&data=${JSON.stringify({context:n})}`)),u=()=>{i(Wr({name:"suggestion feedback",data:{text:e.text,source:t,context:n},options:{includeConversationData:!0}}))};return!s||!l?null:(0,Gi.jsxs)(pt,{placement:"top-end",children:[(0,Gi.jsx)(pt.Trigger,{className:Jp.trigger,children:(0,Gi.jsx)(Zp,{"data-testid":"feedback-dropdown-trigger"})}),(0,Gi.jsx)(pt.Content,{className:Jp.content,children:(0,Gi.jsx)(pt.Button,{className:Jp.item,as:"a",onClick:u,target:"_blank",href:l,children:r("giveFeedback")})})]})},em=x4;var oc={};bt(oc,{enUS:()=>w4,nlNL:()=>S4});var w4={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"URL 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"}],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?"}]},S4={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:"URL 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"}],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 hP=S($());var b4=["{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}"],E4=new RegExp(b4.map(e=>`(?:${e.replace("{","\\{").replace("}","\\}")})`).join("|"));function lP(e,t){let n=e.split(E4),r=0,o=[];for(let i=0;i<n.length;i++){let s=n[i];if(o.push(s),i===n.length-1)break;if(t.indexOf(s)===-1)return e;let a=n[i+1],l=i===n.length-2;r+=s.length;let u=r;if(l){let f=a.charAt(0),d=0;do u=f?t.indexOf(f,u+1):-1,d+=1;while(u!==-1&&a.indexOf(t.slice(u))!==0);if(u===-1&&d>2)return e}else u=a&&a!==""?t.indexOf(a,r):-1;let c=u===-1?t.slice(r):t.slice(r,u);o.push(c),r=u}return o.join("")}function uP(e,t){return typeof t=="boolean"?e:e.slice(0,t)}var dP={suggestions:[],fetchState:"idle"},cP={default:dP},fP=e=>t=>{var n,r;return(r=(n=t.textSuggestions[e])==null?void 0:n.suggestions)!=null?r:[]},tm=e=>e.textSuggestions,pP=e=>{let t=e.toLowerCase();return n=>{let r=n.text.toLowerCase();return r.startsWith(t)&&r.length>t.length}},nm=ot("textSuggestions/refresh"),rr=ge("textSuggestions/recommendations",(e,t)=>A(void 0,null,function*(){var u,c;let{deepdeskAPI:n}=t.extra,r=t.getState(),{platformVariables:o}=r.info,{textSuggestionsCount:i,inlineSuggestions:s}=r.settings,a=ia(r),l=[];if(e==="sticky-messages"){let f=(u=r.profile.data)==null?void 0:u.code;if(!f)throw new Error("No current profile to fetch pinned messages");l=yield n.getPinnedMessages(f)}else{let f=(c=r.conversation.current)==null?void 0:c.id;if(!f)throw new Error("No current conversation to fetch text suggestions");l=yield n.getTextSuggestions(f,au(r),e)}if(o&&(l=l.map(f=>b(P(b({},f),{text:rn(f.text,o)}),f.title?{title:rn(f.title,o)}:{}))),e==="default"){let f=s?l.filter(pP(a)):l;t.dispatch(zo(f.slice(0,i)))}return l})),ic=ge("textSuggestions/autocompletions",(e,t)=>A(void 0,null,function*(){var c;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(c=r.conversation.current)==null?void 0:c.id,{platformVariables:i}=r.info,{textSuggestionsCount:s,deanonymize:a,inlineSuggestions:l}=r.settings;if(!o)throw new Error("No current conversation to fetch text suggestions");let u=yield n.getAutocompleteSuggestions(o,P(b({},au(r)),{input:e}));if(!t.getState().input.text)throw new Error("Abort");return l&&(u=u.filter(pP(e))),i&&(u=u.map(f=>P(b({},f),{text:rn(f.text,i)}))),a&&(u=u.map(f=>P(b({},f),{text:f.source!=="trie-with-typos"?lP(f.text,e):f.text}))),u=uP(u,s),t.dispatch(zo(u)),u})),mP=Ce({name:"textSuggestions",initialState:cP,reducers:{setTextSuggestions:{reducer(e,t){let{contentType:n}=t.payload;e[n].fetchState="done",e[n].suggestions=t.payload.suggestions},prepare(e,t){return{payload:{contentType:e,suggestions:t}}}}},extraReducers:e=>{e.addCase(rr.pending,(t,n)=>{let r=n.meta.arg,o=t[r]||dP;return P(b({},t),{[r]:P(b({},o),{fetchState:"loading"})})}).addCase(rr.rejected,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="error")}).addCase(rr.fulfilled,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="done",t[r].suggestions=n.payload)}).addCase(ic.pending,t=>{t.default.fetchState="loading"}).addCase(ic.rejected,t=>{t.default.fetchState="error"}).addCase(ic.fulfilled,(t,n)=>{t.default.fetchState="done",t.default.suggestions=n.payload}).addCase(it,()=>cP)}}),{setTextSuggestions:_K}=mP.actions,gP=mP.reducer;var Yi=S(R()),T4=({types:e,commands:t,onClick:n})=>{let r=he(),o=ue(oc),i=K(tm);return(0,hP.useEffect)(()=>{e.forEach(({type:s})=>{(!i[s]||i[s].suggestions.length===0)&&r(rr(s))})},[]),(0,Yi.jsxs)("div",{children:[t.length>0&&(0,Yi.jsx)(qe.List,{heading:o("commands"),children:t.map((s,a)=>(0,Yi.jsx)(qe.ListItem,{id:`command-${a}`,closeOnSelect:!1,onClick:s.onClick,children:s.label},s.label))}),e.map(({type:s,title:a})=>{var l;return(0,Yi.jsx)(qe.List,{heading:a,orientation:"vertical",children:(l=i[s])==null?void 0:l.suggestions.map((u,c)=>(0,Yi.jsx)(qe.ListItem,{id:`${s}-${c}`,closeOnSelect:!1,description:u.title&&u.text,onClick:()=>n(u.text,u),"data-testid":"search-overlay-suggestion",children:u.title||u.text},`${u.id}-${u.text}`))},s)})]})},yP=T4;var vt=S(R()),k4=200,R4=5,P4=4,z0=(e,t,n)=>e.slice(0,n?10:t.toLowerCase()==="image"?P4:R4),A4=(e,t)=>!t||e.toLowerCase().includes(t.toLowerCase()),I4=()=>{var N,H,ce;let e=he(),t=on(),n=ue(oc),[r,o]=(0,$t.useState)(!1),[i,s]=(0,$t.useState)(""),[a,l]=(0,$t.useState)(null),u=K(BT),c=K(Ri),[f,d]=(0,$t.useState)(),p=K(zt),y=J("showSearch"),h=J("enableSuggestionFeedback"),g=J("showEntitiesCommand"),m=J("showKnowledgeSearch"),v=J("showImageSearch"),x=J("searchTriggerKey"),w=K(op),C=K(ip),E=K(yC),k=K(lv),I=K(UT),L=K(zT),G=((ce=(H=(N=c==null?void 0:c.uiConfig)==null?void 0:N.search)==null?void 0:H.initialTypes)==null?void 0:ce.filter(({isActive:V})=>V))||[],D=at(),j=(0,$t.useMemo)(()=>{let V=fe=>z0(k.filter(ne=>ne.type===fe.toUpperCase()),fe,f),me=(E==null?void 0:E.map(fe=>({value:fe.code.toUpperCase(),label:`${fe.name}s`,list:V(fe.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[];if(me.push({value:"PERSONAL",label:n("personalSuggestions"),list:V("PERSONAL"),lineClamp:!1,listOrientation:"vertical"},{value:"URL",label:n("urlSuggestions"),list:V("URL"),lineClamp:!1,listOrientation:"vertical"},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:V("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical"}),v&&me.push({value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:V("IMAGE"),listOrientation:"horizontal"}),G.length===0)return me;let pe=G.map(fe=>me.find(ne=>ne.value.toLowerCase()===fe.type)).filter(fe=>!!fe),Se=me.filter(fe=>!pe.find(ne=>ne.value===fe.value));return[...pe,...Se]},[E,G,v,f]),M=[{label:n("entitiesClipboard"),onClick:()=>e(Kr("entities")),shouldShow:g&&A4(n("entitiesClipboard"),i)},{label:i?`${n("knowledgeAssist")}: ${i}`:n("knowledgeAssist"),onClick:()=>{e(Kr("knowledgeAssist")),D("open knowledge assistant",{via:"search-command"})},shouldShow:m}].filter(V=>V.shouldShow).filter(()=>!f),_=(0,$t.useCallback)((0,vP.default)((V,me)=>{e(Ei({query:V,type:me,tags:["search-overlay"],size:f?50:20}))},k4),[f]),X=(0,$t.useCallback)((V,me)=>{switch(me.type){case"IMAGE":t.send(cv,{suggestion:me});break;default:t.send(vr,{text:V,suggestion:me})}e(An(!1))},[e]),te=V=>{xr(V.text),e(Wr({name:"entity copied",data:{entity:V,type:"copy"}})),e(An(!1))},q=V=>{t.send(vr,{text:V,suggestion:{source:"knowledge-assist",text:V}}),e(Wr({name:"answer used",data:{originalText:V},options:{includeConversationData:!0}})),s(""),a&&e(ua(a)),e(Kr("search")),e(An(!1))},W=V=>{let me={input:V,threadId:a,onNewThreadId:pe=>l(pe)};if(C)return Ci(b({assistantCode:C},me));if(w)return ki(b({assistantCode:w},me))};function B(V){return me=>{r?window.confirm(n("warning"))&&(V(me),o(!1)):V(me)}}return(0,$t.useEffect)(()=>{i?_(i,f):e(Kf())},[i,f]),(0,$t.useEffect)(()=>{p&&e(Eu())},[p]),fR(x,()=>{e(An(!0)),D("open search",{via:"ctrl+k"})}),!y||!c?null:(0,vt.jsxs)(qe,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:s,onChangeOpen:B(V=>e(An(V))),onChangeType:V=>d(V),onChangePage:B(V=>e(Kr(V))),selectedType:f,search:i,page:u,isOpen:L,types:j,updateDeps:[k],children:[(0,vt.jsxs)(qe.Page,{id:"search",children:[i.length===0&&(0,vt.jsx)(yP,{types:G,commands:M,onClick:X}),i.length>0&&(0,vt.jsxs)($t.Fragment,{children:[M.length>0&&(0,vt.jsx)(qe.List,{heading:n("commands"),children:M.map((V,me)=>(0,vt.jsx)(qe.ListItem,{closeOnSelect:!1,onClick:V.onClick,id:`commands-${me}`,children:V.label},V.label))}),j.map(({value:V,label:me,list:pe,lineClamp:Se,listOrientation:fe})=>(0,vt.jsx)(qe.List,{heading:me,orientation:fe==="horizontal"?"horizontal":"vertical",onShowAll:()=>d(V),hasMore:!f&&I[V.toLowerCase()]>z0(pe,V,f).length,children:z0(pe,V,f).map(ne=>(0,vt.jsx)(qe.ListItem,{id:`${V}-${ne.id}`,closeOnSelect:!1,lineClamp:Se,onClick:()=>X(ne.text,ne),description:V!=="IMAGE"?ne.title&&ne.text:void 0,tooltip:ne.text,extra:h&&(0,vt.jsx)(qe.ListItemActions,{children:(0,vt.jsx)(em,{context:i,source:"search",suggestion:ne})}),children:V==="IMAGE"?(0,vt.jsx)(qe.Image,{title:ne.title||ne.text,src:ne.image}):ne.title||ne.text},`${ne.id}-${ne.text}`))},V))]})]}),(0,vt.jsx)(qe.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:B(()=>{e(Kr("search"))}),children:(0,vt.jsx)(hR,{onCopy:te})}),(w!=null?w:C)&&(0,vt.jsx)(qe.Page,{id:"knowledgeAssist",title:n("knowledgeAssist"),onDismiss:B(()=>{a&&e(ua(a)),e(Kr("search"))}),children:(0,vt.jsx)(aP,{threadId:a,onEvaluate:W,question:i,onUse:q,onResetQuestion:()=>{a&&e(ua(a)),s(""),l(null)}})})]})},xP=I4;var sc=S(R()),L4=()=>{let e=J("showSearch"),t=J("isEmbedded");return(0,sc.jsxs)(wP.Fragment,{children:[e&&(0,sc.jsx)(xP,{}),t&&(0,sc.jsx)(aC,{})]})},SP=L4;var CP=S(Fe());var rm=S(R()),bP=({className:e})=>(0,rm.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:e,children:(0,rm.jsx)("g",{children:(0,rm.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
78
78
  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
79
79
  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
80
80
  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
81
81
  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 B0=S(R()),O4={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},EP=({className:e,color:t})=>(0,B0.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,B0.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:O4[t||"pink"]})});var TP={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var U0={};bt(U0,{enUS:()=>M4,nlNL:()=>N4});var M4={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},N4={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Xi=S(R()),kP=({onLogIn:e})=>{let t=ue(U0),n=J("floatingMenu"),r=J("productName"),o=he(),i=K(zt),s=F("FloatingMenu",TP);if(i===null||n===!1)return null;let a=()=>{i===!0?o(An(!0)):e()};return(0,Xi.jsxs)("button",{type:"button",className:(0,CP.default)(s.root,{[s.isLoggedIn]:i,[s.isLoggedOut]:!i}),onClick:a,children:[(0,Xi.jsx)("div",{className:s.text,children:t(i?"search":"signin",{productName:r})}),(0,Xi.jsxs)("div",{className:s.icon,children:[(0,Xi.jsx)(EP,{className:s.logo,color:"pink"}),i===!1&&(0,Xi.jsx)(bP,{className:s.lock})]})]})};var am=S($());function Tr(e){let{showMidSentenceSuggestions:t,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:r}=e.settings,{text:o,selection:i}=e.input;return i.start!==i.end?!1:i.end>=o.length?!0:t?n&&new RegExp(n).test(o.substring(i.end))||r&&new RegExp(r).test(o.substring(0,i.end))?!0:n===!1&&r===!1:!1}var _4={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},om=({ui:e})=>e.overlayCollapsed,RP=Ce({name:"ui",initialState:_4,reducers:{setShowTabHint(e,t){e.showTabHint=t.payload},setInputFocus(e,t){e.overlayCollapsedUserOverwrite!==!0&&(t.payload===!0&&(e.overlayCollapsed=!1),e.inputHasFocus=t.payload)},setOverlayCollapsed(e,t){t.payload.collapse===!1&&(e.openOverlayWhenTyping=!1),!(t.payload.skipWhenInputFocus&&e.inputHasFocus)&&(e.overlayCollapsed=t.payload.collapse)},setOpenOverlayWhenTyping(e,t){e.openOverlayWhenTyping=t.payload},setOverlayCollapsedUserOverwrite(e,t){e.overlayCollapsedUserOverwrite=t.payload,e.overlayCollapsed=t.payload}}}),{setShowTabHint:ac,setInputFocus:im,setOverlayCollapsed:qo,setOpenOverlayWhenTyping:PP,setOverlayCollapsedUserOverwrite:AP}=RP.actions,IP=RP.reducer;var _P=S($());var Go=S($());var LP=S($());function OP(e,t,n){(0,LP.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var MP={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var Qi=S(R()),F4=["search","personal-collection-search","search-autocomplete"];function H4(e,t,n,r={}){var i;let o="";return F4.includes(t)?o=OC(_v(e,n,{stripAgentPart:!0}),(i=r.searchKeywords)!=null?i:[n]):o=_v(e,n,r),r.placeholders===!0&&(o=MC(o)),o}var z4=()=>{},B4=({selected:e,suggestion:t})=>{let n=J("inlineSuggestions"),r=K(ia),[o,i]=(0,Go.useState)(!1),s=J("enableSuggestionFeedback"),a=K(d=>d.input.text),l=he(),u=F("TextSuggestion",MP),c=(0,Go.useRef)(null);(0,Go.useEffect)(()=>{let d=setTimeout(()=>{l(ST({text:t.text,suggestion:t}))},500);return()=>{clearTimeout(d)}},[t]),OP(c,"click",()=>{l(jn({suggestion:t,text:t.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let f=(0,Go.useMemo)(()=>H4(t.text,t.source,r,{stripAgentPart:n,placeholders:!0,searchKeywords:t.searchKeywords}),[n,t.text,t.source,r,t.searchKeywords]);return t.source==="gpt"&&!n?null:(0,Qi.jsxs)("div",{className:u.root,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[(0,Qi.jsx)(Ee,{ref:c,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:z4,children:(0,Qi.jsx)(Oi,{containerTagName:"div",noWrap:!1,tagName:"span",className:u.formattedText,content:f})}),s&&o&&(0,Qi.jsx)("div",{className:u.actions,children:(0,Qi.jsx)(em,{source:"overlay",context:a,suggestion:t})})]})},NP=B4;var DP=S(R()),U4=({suggestions:e,selectedIndex:t,reverse:n})=>(0,_P.useMemo)(()=>{let o=e.map((i,s)=>(0,DP.jsx)(NP,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]),sm=U4;var FP={root:"dd-PfvRI",paper:"dd-HYlyY"};var lc=S(R()),j4=({textSuggestions:e,selectedIndex:t})=>{let n=(0,am.useRef)(null),r=F("InlineSuggestionsOverlay",FP),o=K(Tr),i=he(),s=K(zt),a=K(oa),l=K(om),u=J("showTextSuggestions");return $o(()=>{setTimeout(()=>{i(qo({collapse:!0,skipWhenInputFocus:!0}))})}),(0,am.useEffect)(()=>{let c=n.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let f=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-f.right,0)}px`}),l||!o||!u||e.length===0||s!==!0||a===!1?null:(0,lc.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,lc.jsx)("div",{ref:n,className:r.paper,children:(0,lc.jsx)(Zt,{children:(0,lc.jsx)(sm,{suggestions:e,selectedIndex:t})})})})},V4=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),HP=wi(V4)(j4);var uc=S(R()),W4=({children:e})=>{let n=J("locale").replace("-","");return(0,uc.jsx)(xv.Provider,{value:n,children:e})},K4=({store:e,customStyles:t={},children:n})=>(0,uc.jsx)(Jy,{store:e,children:(0,uc.jsx)(W4,{children:(0,uc.jsx)(Ya.Provider,{value:t,children:n})})}),Yo=K4;var um=S(Fe()),Oa=S($());var zP=S($());function BP(e,t){let[n,r]=(0,zP.useState)(()=>{if(typeof window=="undefined")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return ee.error(i),t}});return[n,i=>{try{let s=i instanceof Function?i(n):i;r(s),typeof window!="undefined"&&window.localStorage.setItem(e,JSON.stringify(s))}catch(s){ee.error(s)}}]}var UP=()=>/Mac/i.test(navigator.platform);var VP=S(Fe()),no=S($());var j0={};bt(j0,{enUS:()=>$4,nlNL:()=>q4});var $4={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"}]}]},q4={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 jP={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var Xo=S(R()),V0=(e,t,n)=>r=>(0,Xo.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),G4=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=ue(j0),s=on(),a=F("Login",jP),l=J("productName"),u=(0,no.useCallback)(g=>{g.preventDefault(),r&&r(Number.parseInt(g.target.value,10))},[]),c=(0,no.useCallback)(g=>{g.preventDefault(),s.send(la,!0)},[t]),f=(0,no.useMemo)(()=>g=>(0,Xo.jsx)("a",{onClick:v=>{v.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[t]),d=(0,no.useCallback)(g=>(0,Xo.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:p,hour:y,day:h}=(0,no.useMemo)(()=>({min:V0(a,60*10,u),hour:V0(a,60*60,u),day:V0(a,60*60*12,u)}),[]);return(0,Xo.jsxs)("div",{className:(0,VP.default)(e,a.root),children:[i("loginPlease",{login:n?d:f,productName:l}),r&&(0,Xo.jsxs)(no.Fragment,{children:[(0,Xo.jsx)("br",{}),i("snooze",{min:p,hour:y,day:h})]})]})},lm=G4;var WP={root:"dd-DoQhb",text:"dd-Jwnev"};var cc=S(R()),Y4=({title:e})=>{let t=F("SearchTrigger",WP),n=he(),r=at();return(0,cc.jsxs)("button",{type:"button",className:t.root,onClick:()=>{n(An(!0)),r("open search",{via:"autocomplete-overlay"})},children:[(0,cc.jsx)(Ea,{}),(0,cc.jsx)("span",{className:t.text,children:e})]})},KP=Y4;var W0={};bt(W0,{enUS:()=>X4,nlNL:()=>Q4});var X4={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"}]},Q4={arrowHint:[{type:0,value:"Tip: Selecteer suggesties met pijltoetsen"}],searchHintWindows:[{type:0,value:"Druk CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],searchHintMac:[{type:0,value:"Druk CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Sluiten"}],search:[{type:0,value:"Zoeken"}]};var $P={root:"dd-oa7Vc",isInline:"dd-bwk31",toggleButton:"dd-MSB8Z",toggleButtonWrapper:"dd-ZkCzT",toggleButtonWrapperHidden:"dd-Sq66c",isCollapsed:"dd-vkrPk",collapsible:"dd-CWQJe",hints:"dd-IOoo3",hintsHidden:"dd-psVuT",triggers:"dd-toIoo",triggersRight:"dd-mc4l2"};var Ke=S(R()),Z4=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=F("SuggestionsOverlay",$P),o=ue(W0),i=K(Tr),s=wT(),a=he(),l=(0,Oa.useRef)(null),u=J("searchTriggerKey"),c=J("productName"),f=K(om),d=K(zt),p=K(oa),[y,h]=(0,Oa.useState)(null),g=J("showSearch"),m=J("showTextSuggestions"),v=J("adminUrl"),x=J("isEmbedded"),[w,C]=BP("dd-snooze-until-ms",0),E=f||w>Date.now(),k=e.filter(G=>G.source!=="gpt").length,I=()=>{E&&C(0),a(AP(!E))},L=G=>{let D=Date.now()+G*1e3;C(D),ee.info(`Snooze until: ${new Date(D)}`),a(qo({collapse:!0}))};return(0,Oa.useEffect)(()=>{k===0&&h(null)},[e,k]),$o(()=>{a(qo({collapse:!0,skipWhenInputFocus:!0}))}),d===null||p===!1?null:d===!1?(0,Ke.jsxs)("div",{ref:l,className:(0,um.default)(r.root,{[r.isCollapsed]:E}),children:[!E&&(0,Ke.jsxs)("div",{className:r.triggers,children:[(0,Ke.jsx)("div",{style:{flex:1}}),(0,Ke.jsx)("div",{className:r.triggersRight,children:(0,Ke.jsx)(ni,{className:r.toggleButton,title:o("collapse"),onClick:I,isCollapsed:!1})})]}),(0,Ke.jsx)("div",{className:r.toggleButtonWrapper,children:(0,Ke.jsx)(ni,{className:r.toggleButton,title:o("open",{productName:c}),onClick:I,isCollapsed:!0})}),(0,Ke.jsx)("div",{className:r.collapsible,children:(0,Ke.jsx)(lm,{loginUrl:v,isEmbedded:x,onLogIn:n,onSnooze:L})})]}):!s||!i?null:(0,Ke.jsxs)("div",{ref:l,className:(0,um.default)(r.root,{[r.isCollapsed]:E}),children:[!E&&(0,Ke.jsxs)("div",{className:r.triggers,children:[(0,Ke.jsx)("div",{style:{flex:1},children:g&&(0,Ke.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>h(o(UP()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>h(null),children:(0,Ke.jsx)(KP,{title:o("search")})})}),(0,Ke.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,Ke.jsx)("div",{className:(0,um.default)(!y&&r.hintsHidden,r.hints),children:y}),(0,Ke.jsx)(ni,{className:r.toggleButton,title:o("collapse"),onClick:I,isCollapsed:!1})]})]}),(0,Ke.jsx)("div",{className:r.toggleButtonWrapper,children:(0,Ke.jsx)(ni,{className:r.toggleButton,title:o("open",{productName:c}),onClick:I,isCollapsed:!0})}),k>0&&m&&(0,Ke.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,Ke.jsx)(Zt,{children:(0,Ke.jsx)(sm,{suggestions:e,selectedIndex:t,reverse:!0})})})]})},J4=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),qP=wi(J4)(Z4);var Sm=S(Fe());var io=S($());var Ma=S($());function cm(e){return e.contentEditable==="true"}function eF(e){let t=0,n=0,r=window.getSelection();if(r.rangeCount!==0){let o=r.getRangeAt(0),i=o.cloneRange();i.selectNodeContents(e),i.setEnd(o.endContainer,o.endOffset),n=i.toString().length,i.selectNodeContents(e),i.setEnd(o.startContainer,o.startOffset),t=i.toString().length}return{selectionStart:t,selectionEnd:n}}function GP(e){let{selectionStart:t,selectionEnd:n}=cm(e)?eF(e):e;return[t,n]}function YP(e){let[,t]=(0,Ma.useState)(),n=(0,Ma.useRef)(null);return n.current=GP(e),(0,Ma.useEffect)(()=>{let r=()=>{var a;let[o,i]=(a=n.current)!=null?a:[],s=GP(e);(!s||o!==s[0]||i!==s[1])&&(n.current=s,t({}))};return e.addEventListener("keyup",r),e.addEventListener("click",r),e.addEventListener("focus",r),document.addEventListener("selectionchange",r),()=>{e.removeEventListener("keyup",r),e.removeEventListener("click",r),e.removeEventListener("focus",r),document.removeEventListener("selectionchange",r)}},[e]),n.current}function XP(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(Fc);if(!s||s.length===0)return;let a=0;s.find(l=>{let u=r.indexOf(l,a);return o>u&&i<u+l.length?(n.selectionStart=u,n.selectionEnd=u+l.length,!0):(a=u+l.length,!1)})}var QP=S($()),tF=["div","span","mark","strong","b","i","u","em"];function K0(e,t,n=0){var i;let r=e[e.length-1],o=typeof r=="object"&&r!==null?(i=r.props)==null?void 0:i.tagName:void 0;if(o==="br")return e.pop(),[...e,...t,r];if(tF.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,QP.cloneElement)(r,{children:K0(s,t,n+1)})]}return[...e,...t]}function Zi(e){return e.tagName.toLowerCase()==="textarea"}var ZP={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var rA=S(Fe());var hm=S($());var Na=S($());function JP(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function dm(e){let t=(0,Na.useRef)(null),[n,r]=(0,Na.useState)(!1);return(0,Na.useEffect)(()=>{var c;let o=!1,i=Number.parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[s,a]=JP((f,d)=>{let p=t.current;if(!p)return;let y=f/i,h=d/i,g=p.getBoundingClientRect(),m=y>g.x&&y<g.x+g.width&&h>g.y&&h<g.y+g.height;m&&!o?(o=!0,r(!0)):!m&&o&&(o=!1,r(!1))},({clientX:f,clientY:d})=>[f,d]),[l,u]=JP(()=>{o=!1,r(!1)});return e.addEventListener("mousemove",s),e.addEventListener("mouseleave",l),()=>{a(),u(),e.removeEventListener("mousemove",s),e.removeEventListener("mouseleave",l)}},[t]),[t,n]}function eA(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function fm(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function tA(e){return e!=null}var nA=S(Fe()),pm=S($());var ro={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var $0=S(R()),mm=(0,pm.forwardRef)((o,r)=>{var i=o,{className:e,children:t}=i,n=se(i,["className","children"]);let s=(0,pm.useRef)(null),a=F("TabCompletion",ro);return(0,$0.jsx)("div",P(b({ref:fm([s,r]),className:(0,nA.default)(e,a.popoverContentContainer)},n),{children:(0,$0.jsx)("div",{className:a.popoverContent,children:t})}))});var Qo=S(R()),nF=e=>t=>{let n=R0(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},rF=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=F("TabCompletion",ro),s=qp(),a=(0,hm.useMemo)(()=>nF(e.getBoundingClientRect()),[e]),[l,u]=dm(e);return(0,hm.useEffect)(()=>{u?s.open():s.close()},[u]),(0,Qo.jsxs)("span",{children:[(0,Qo.jsx)("mark",{ref:fm([l,s.triggerRef]),className:(0,rA.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,Qo.jsx)(Aa,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,Qo.jsx)(mm,{style:n,children:(0,Qo.jsx)("div",{className:i.hintText,children:o})})})]})},gm=class extends qr{constructor(){super(...arguments);this.keywordMatches=[];this.preparedKeywordMatches=[];this.usedKeywordMatches=new Set}onBeforeParse(n,r){return r.keywordMatches&&r.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=r.keywordMatches.map(o=>P(b({},o),{keywordRegex:new RegExp(`\\b${eA(o.keyword)}\\b`,"i")})),this.keywordMatches=r.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let r=this.preparedKeywordMatches.map(i=>{if(this.usedKeywordMatches.has(i))return null;let s=n.match(i.keywordRegex);if(!s)return null;let a=n.charAt(s.index-1),l=n.charAt(s.index+i.keyword.length);return a==="{"&&l==="}"?null:{index:s.index,length:s[0].length,match:s[0],matchString:s[0],suggestion:i.suggestion,preparedKeywordMatch:i,valid:!0}}).filter(tA);if(r.length===0)return null;let o=r.reduce((i,s)=>s.index<i.index?s:i);return this.usedKeywordMatches.add(o.preparedKeywordMatch),o}replaceWith(n,r){return(0,Qo.jsx)(rF,{inputElement:r.inputElement,suggestion:r.suggestion,inputStyle:r.inputStyle,boundaryRef:r.boundaryRef,children:n},`keyword_${r.matchString}_${r.key}`)}asTag(){return"mark"}};var oA=S(Fe());var q0=S(R()),oF=({inputElement:e,children:t})=>{let n=F("TabCompletion",ro),[r,o]=dm(e);return(0,q0.jsx)("mark",{ref:r,className:(0,oA.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},ym=class extends qr{match(t){let n=t.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(t,n){return(0,q0.jsx)(oF,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var xm=S(Fe());var Gt=S($());var G0=S(R()),iA=()=>(0,G0.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,G0.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 Cr=S($());var aA=S(Tv());var sA={root:"dd-ky-Bv",content:"dd-kV5e1"};function vm(e,t,n){var o;let r=((o=e.imageSizes)==null?void 0:o[t])||e.image||n;if(!r)return null;try{return new URL(r).toString()}catch(i){return null}}function Y0(e){return e.replace("https://www.","").replace("https://","")}var _n=S(R()),iF=3,sF=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),aF=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=iF})=>{let i=F("LinkSearch",sA),[s,a]=(0,Cr.useState)(""),l=he(),u=K(fP("url")),c=K(jT("URL")),f=(0,Cr.useMemo)(()=>c.map(sF),[c]),[d,p]=(0,Cr.useState)(f.length-1),y=J("fallbackImage"),h=x=>{let w=x.target;a(w.value)},g=(x,w)=>{x.stopPropagation(),x.preventDefault(),window.open(w,"_blank")},m=x=>{var E;let w=d-1<0?f.length-1:d-1,C=d+1===f.length?0:d+1;x.code==="Escape"&&(a(""),t()),x.code==="ArrowUp"&&p(w),x.code==="ArrowDown"&&p(C),x.code==="Enter"&&e(((E=f[d])==null?void 0:E.text)||s)},v=(0,Cr.useCallback)((0,aA.default)(x=>{l(Ei({query:x,type:"URL",tags:["link-search"]}))},300),[]);return(0,Cr.useEffect)(()=>{s&&v(s)},[s]),(0,Cr.useEffect)(()=>()=>{l(Kf())},[]),(0,_n.jsxs)("div",{className:i.root,children:[(0,_n.jsx)(Zt,{withDivider:!0,children:(s?f:u).slice(0,o).map((x,w)=>(0,_n.jsx)(Ee,{selected:d===w,onClick:()=>e(x.text),"data-testid":"linksearch-suggestion",children:(0,_n.jsxs)(Oe,{children:[(0,_n.jsx)(Oe.Image,{src:vm(x,"small",y||void 0),title:x.title||x.text}),(0,_n.jsxs)(Oe.Content,{className:i.content,cropText:!0,children:[(0,_n.jsx)(Oe.Title,{children:x.title||Y0(x.text)}),x.title&&Y0(x.text)]}),(0,_n.jsx)(Ee.Actions,{children:(0,_n.jsx)(Ee.ActionButton,{label:r,onClick:C=>g(C,x.text)})})]})},x.text))}),(0,_n.jsx)(wu,{value:s,onChange:h,autoFocus:!0,placeholder:n,onKeyUp:m})]})},lA=aF;var X0={};bt(X0,{enUS:()=>lF,nlNL:()=>uF});var lF={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},uF={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var qt=S(R()),cF=(0,Gt.forwardRef)((e,t)=>{let n=F("TabCompletion",ro);return(0,qt.jsx)("mark",{ref:t,className:(0,xm.default)(n.matchSelection)},"selection-start")}),dF=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=ue(X0),s=F("TabCompletion",ro),a=(0,Gt.useRef)(null),l=(0,Gt.useRef)(null),[u,c]=(0,Gt.useState)(null),f=he(),d=qp(document.activeElement===r),[p]=(0,Gt.useState)(()=>document.createRange());d.triggerRef.current=p,(0,Gt.useEffect)(()=>()=>p.detach(),[]),(0,Gt.useEffect)(()=>{let h=e.current,g=a.current;!h||!g||(p.setStart(h,0),p.setEnd(g,0))},[e.current,a.current]),$o(()=>{d.close()});let y=(0,Gt.useCallback)(h=>{let g=p.toString(),m=/^http(s?):\/\//.test(h)?h:`https://${h}`;f(zf({text:`[${g}](${m})`,replace:"selection"}))},[]);return(0,qt.jsxs)("span",{children:[(0,qt.jsx)("mark",{ref:a,className:(0,xm.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,qt.jsx)(Aa,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,qt.jsxs)(mm,{style:n,ref:l,children:[(0,qt.jsx)("div",{className:(0,xm.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,qt.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,qt.jsx)(iA,{}),(0,qt.jsx)("span",{children:"\xA0"}),(0,qt.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,qt.jsx)(lA,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:y,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},wm=class extends qr{constructor(){super(...arguments);this.charCount=0;this.foundIndex=0;this.startRef=null}onBeforeParse(n,r){return this.props=r,this.charCount=0,this.startRef=(0,Gt.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[r,o]=this.props.selection;if(r===o)return null;let i=this.foundIndex===0?r:o,s=i>=this.charCount&&i<=this.charCount+n.length?{index:i-this.charCount,length:0,match:"",valid:!0}:null;s&&this.foundIndex++;let a=this.foundIndex===1;return s&&a?this.charCount+=i-this.charCount:this.charCount+=n.length,s?b({isStart:a},s):null}replaceWith(n,r){return r.isStart?(0,qt.jsx)(cF,{ref:this.startRef}):(0,qt.jsx)(dF,{inputElement:r.inputElement,startRef:this.startRef,boundaryRef:r.boundaryRef,inputStyle:r.inputStyle})}asTag(){return"mark"}};var oo=S(R()),fF=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=F("TabCompletion",ZP),c=J("insertLink"),f=J("showMidSentenceSuggestions"),d=J("inlineSuggestions"),p=YP(a),y=(0,io.useRef)(null),h=K(zt);(0,io.useEffect)(()=>{Zi(a)&&p&&XP(a,p)},[p]);let g=(0,io.useCallback)(x=>{if(!o||!n)return x;let w=[(0,oo.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,oo.jsx)("span",{"data-testid":"tab-completion",className:(0,Sm.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&w.push((0,oo.jsx)("span",{className:(0,Sm.default)(u.hint,u.resetIndent),children:(0,oo.jsx)(_c,{keyCode:"tab"},"tabHint")})),K0(x,w)},[o,n,r]),m=(0,io.useMemo)(()=>{let x=[];return c&&x.push(new wm("selection")),x.push(new ym("placeholders")),i&&x.push(new gm("keywords")),x},[d,c,i]),v=(0,io.useMemo)(()=>{let x=window.getComputedStyle(a);return{"--dd-color":x.color,"--dd-font-size":x.fontSize,"--dd-font-family":x.fontFamily,"--dd-font-variant":x.fontVariant}},[]);return!e||!h?null:(0,oo.jsxs)("div",{ref:x=>{x!=null&&x.parentElement&&(y.current=x==null?void 0:x.parentElement)},className:u.root,style:v,children:[(0,oo.jsx)(Oi,{tagName:"span",containerTagName:"div",className:(0,Sm.default)(u.container,u.agentText),disableLineBreaks:Zi(a),content:t||"\u200B",onAfterParse:g,matchers:m,selection:p,keywordMatches:s,inputElement:a,inputStyle:v,boundaryRef:y,inlineSuggestionsOnlyAtEnd:!f}),(0,oo.jsx)("br",{})]})},pF=e=>{var g,m,v;let{input:t,ui:n,settings:r,styleSuggestions:o,conversation:i}=e,s=sa({input:t}),a=(s==null?void 0:s.text)||"",l=(s==null?void 0:s.source)||"",u=(g=t.html)!=null?g:ca(t.text),c=a.indexOf(t.text)===0?a.slice(t.text.length):"",{showTabHint:f}=n,{isSupported:d}=i,{showTabCompletion:p,visible:y,showStyleSuggestions:h}=r;return{showTabHint:f,showStyleSuggestions:h,showTabCompletion:p&&Tr(e),content:u,tabText:c,source:l,keywordMatches:(v=(m=o.list)==null?void 0:m.keywordMatches)!=null?v:[],enabled:y&&d!==!1}},uA=wi(pF)(fF);var Ha=S($());var mF={token:null,interval:null},Q0=ge("passwordlessToken/getTemporaryPasswordlessToken",(e,t)=>A(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return{token:yield n.requestPasswordlessToken()}})),Z0=ge("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(Q0()),setInterval(()=>r(Q0()),n)}),cA=Ce({name:"passwordlessToken",initialState:mF,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(Q0.fulfilled,(t,n)=>{t.token=n.payload.token}),e.addCase(Z0.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:dA}=cA.actions,fA=cA.reducer;function gF(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}var pA=Un([pC],e=>e.map(n=>({text:n.response,title:n.name,callToAction:n.callToAction,isLoading:n.isLoading,specialType:n.specialType,rule:{id:gF(n.code),label:n.code,name:n.name,description:n.name}})));var bm=S($());var ex=S(Fe());var J0=S(R()),dc=()=>(0,J0.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,J0.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 mA={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var kr=S(R()),hF=({entities:e})=>{let t=F("EntitiesWidgetList",mA),[n,r]=(0,bm.useState)(void 0),o=he(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),xr(a.text),o(Wr({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,bm.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,kr.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,kr.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,kr.jsx)("span",{className:t.entityText,children:a.text}),(0,kr.jsxs)("span",{className:t.iconWrapper,children:[(0,kr.jsx)("span",{className:(0,ex.default)(t.icon),children:(0,kr.jsx)(dc,{})}),(0,kr.jsx)("span",{className:(0,ex.default)(t.icon,n===l&&t.iconClicked),children:(0,kr.jsx)(dc,{})})]})]},a.text))})},gA=hF;var tx=S(R()),hA=()=>(0,tx.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,tx.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 nx=S(R()),yA=()=>(0,nx.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,nx.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 rx=S(R()),vA=()=>(0,rx.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,rx.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 xA={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var wA={root:"dd-nazq3",rotation:"dd-3EHTv"};var bA=S(R()),yF=({size:e=12})=>{let t=F("LoadingSpinner",wA);return(0,bA.jsx)("span",{"data-testid":"loading-spinner",style:{width:`${e}px`,height:`${e}px`},className:t.root})},SA=yF;var ox=S(R()),EA=()=>(0,ox.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512",fill:"currentColor",children:(0,ox.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 fc=S(R()),TA=e=>(0,fc.jsxs)("svg",P(b({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 448 512","aria-labelledby":"checkTitle"},e),{children:[(0,fc.jsx)("title",{id:"checkTitle",children:"Check"}),(0,fc.jsx)("path",{fill:"#666",d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"})]}));var ix={};bt(ix,{enUS:()=>vF,nlNL:()=>xF});var vF={error:[{type:0,value:"Something went wrong"}]},xF={error:[{type:0,value:"Er ging iets fout"}]};var hn=S(R()),CA,wF=3e3,SF=()=>{let e=F("OnDemandAssistants",xA),t=ue(ix),n=Zr(Kn),r=Zr(Wn),o=K(xC),i=K(wC),s=at(),a=i.filter(c=>c.isPinned),l=i.filter(c=>!c.isPinned),u=c=>A(void 0,null,function*(){if(clearTimeout(CA),s("trigger on demand assistant",{assistantCode:c}),c===o){r.call({transcript:"in-memory-transcript"});return}n.call({assistantCode:c,expectFormat:"json-schema:cues",transcript:"in-memory-transcript"}),CA=setTimeout(()=>n.reset(),wF)});return i.length===0?null:(0,hn.jsxs)("div",{className:e.root,children:[a.map(({assistant:c,assistantName:f})=>(0,hn.jsx)("button",{type:"button",className:e.button,disabled:n.state==="loading",onClick:()=>u(c),children:f},c)),n.state==="loading"&&(0,hn.jsx)(SA,{}),n.state==="done"&&(0,hn.jsx)(TA,{"data-testid":"trigger-done"}),n.state==="error"&&(0,hn.jsx)(iR,{trigger:(0,hn.jsx)(EA,{}),children:t("error")}),l.length>0&&n.state==="idle"&&(0,hn.jsxs)(pt,{placement:"top-end",children:[(0,hn.jsx)(pt.Trigger,{className:e.trigger,children:(0,hn.jsx)(Zp,{"data-testid":"trigger"})}),(0,hn.jsx)(pt.Content,{className:e.nav,"data-testid":"popover",children:l.map(({assistant:c,assistantName:f})=>(0,hn.jsx)(pt.Button,{className:e.item,disabled:n.state==="loading",onClick:()=>u(c),children:f},c))})]})]})},kA=SF;var AA=S($());var RA={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};var PA=S(R()),bF=({width:e})=>{let t=F("LoadingProgressBar",RA);return(0,PA.jsx)("div",{className:t.loadingBar,style:{width:e}})},Em=bF;var so=S(R()),Tm=({title:e})=>{let t=(0,AA.useRef)(null);return Tw(t),(0,so.jsx)(Ee,{ref:t,children:(0,so.jsx)(Oe,{children:(0,so.jsxs)(Oe.Content,{children:[(0,so.jsx)(Oe.Title,{children:e}),(0,so.jsx)(Em,{width:"60%"}),(0,so.jsx)(Em,{width:"90%"}),(0,so.jsx)(Em,{width:"50%"})]})})})};var pc={};bt(pc,{enUS:()=>EF,nlNL:()=>TF});var EF={useCue:[{type:0,value:"Add to message"}],__summarizerAssistant__:[{type:0,value:"Summary"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},TF={useCue:[{type:0,value:"Voeg toe aan bericht"}],__summarizerAssistant__:[{type:0,value:"Samenvatting"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var Ji=S($());var sx={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",actions:"dd-9Iqn9",thumbsUp:"dd-6QwVx",thumbsDown:"dd-d3E8l",form:"dd-sPNU2",formInput:"dd-F3E4I",formSubmit:"dd-vw5S0",actionButton:"dd-cCWyJ",editableCue:"dd-nWSD-",inputSpace:"dd-DGYB1"};var Mt=S(R()),CF=500,kF=100,RF=({content:e,onChange:t,onCopy:n})=>{let r=(0,Ji.useRef)(null),o=F("WidgetCue",sx);return(0,Ji.useEffect)(()=>{let i=r.current;if(!i)return;i.style.setProperty("height","0px");let s=Math.min(Math.max(i.scrollHeight,kF),CF);i.style.setProperty("height",`${s}px`)},[e]),(0,Mt.jsx)("textarea",{ref:r,className:o.editableCue,onCopy:n,onChange:t,value:e})},PF=({cue:e,onCallToAction:t,onRemove:n,onCopy:r,onUse:o})=>{var h;let i=F("WidgetCue",sx),s=ue(pc),a=at(),l=J("hasKeyboardInput"),[u,c]=(0,Ji.useState)(e.text),f=()=>{t&&t(e),n(e)},d=g=>{r&&r(g,e)},p=g=>{o&&o(g,e)},y=g=>{g.preventDefault(),g.stopPropagation(),n(e)};return(0,Ji.useEffect)(()=>{a("Assistant response displayed",{name:e.rule.name,description:e.rule.description,group:e.rule.label,cueText:e.text})},[]),(0,Mt.jsxs)(Ee,{"data-testid":"cue",children:[(0,Mt.jsx)(Oe,{children:(0,Mt.jsxs)(Oe.Content,{children:[e.title&&(0,Mt.jsx)(Oe.Title,{className:i.title,"data-testid":"widget-cue-title",children:e.rule.label.startsWith("__")?s(e.rule.label):e.title}),e.specialType==="summary"?(0,Mt.jsx)(RF,{content:u,onCopy:()=>{let g=document.getSelection();g&&d(g.toString())},onChange:g=>{var m;return c((m=g.target.value)!=null?m:"")}}):(0,Mt.jsx)($i,{content:e.text,useLabel:s("useCue"),copyLabel:s("copyCue"),onCopy:d,onUse:l?p:void 0})]})}),(0,Mt.jsxs)(Ee.ButtonsContainer,{children:[(0,Mt.jsxs)("div",{className:i.actions,children:[e.specialType==="summary"&&(0,Mt.jsx)(Ee.Button,{onClick:()=>d(u),children:s("copyCue")}),e.callToAction&&(0,Mt.jsx)(Ee.Button,{onClick:f,children:e.callToAction.label}),(0,Mt.jsx)(Ee.Button,{onClick:y,children:s("removeCue")})]}),e.specialType==="summary"?(0,Mt.jsx)(Bi,{eventName:"summary feedback",feedbackText:(h=e.text)!=null?h:"",feedbackType:"summary",eventData:{summary:e.text}}):(0,Mt.jsx)(Bi,{eventName:"Assistant response feedback",eventData:{name:e.rule.name,group:e.rule.label,description:e.rule.description,cueText:e.text},feedbackText:e.text,feedbackType:"assistant"})]})]})},IA=PF;var _a=S(R()),AF=({cues:e})=>{let t=he(),n=on(),r=ue(pc),o=at(),i=u=>{t(gC({code:u.rule.label})),o("Assistant response closed",{name:u.rule.name,group:u.rule.label,description:u.rule.description,cueText:u.text})},s=(u,c)=>{switch(xr(u),c.specialType){case"summary":o("summary copied to clipboard",{originalText:c.text,finalText:u,assistant:c.rule.label});break;default:o("Assistant response copied",{name:c.rule.name,group:c.rule.label,description:c.rule.description,copiedText:u})}},a=u=>{u.callToAction&&(t(rp(u)),o("Assistant call to action",{name:u.rule.name,group:u.rule.label,description:u.rule.description,eventName:u.callToAction.event,value:u.callToAction.value}))},l=(u,c)=>{n.send(vr,{text:u,suggestion:{source:"cue",sourceText:u}}),o("Assistant response used",{name:c.rule.name,group:c.rule.label,description:c.rule.description,usedText:u})};return(0,_a.jsx)(_a.Fragment,{children:e.map(u=>u.isLoading?(0,_a.jsx)(Tm,{title:u.rule.label.startsWith("__")?r(u.rule.label):u.title},u.rule.id):(0,_a.jsx)(IA,{cue:u,onCallToAction:a,onRemove:i,onCopy:s,onUse:l},u.rule.id))})},LA=AF;var Cm=S($());var OA={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var or=S(R());function IF(e,t){return t.split(".").reduce((n,r)=>!n||typeof n!="object"||!(r in n)?null:n[r],e)}var MA=({data:e,schema:t})=>{let n=F("WidgetCustomData",OA),r=o=>{xr(o)};return(0,Cm.useEffect)(()=>{ee.info("Custom data",e,t)},[e]),(0,or.jsx)("dl",{className:n.root,children:t.map(o=>{let i=IF(e,o.path);return(0,or.jsxs)(Cm.Fragment,{children:[(0,or.jsx)("dt",{className:n.label,children:o.label}),(0,or.jsx)("dd",{className:n.value,children:o.type==="boolean"&&i?(0,or.jsx)("span",{className:n.isTrue,children:o.trueValue}):o.type==="boolean"&&!i?(0,or.jsx)("span",{className:n.isFalse,children:o.falseValue}):i?(0,or.jsxs)("button",{type:"button",onClick:()=>r(i),className:n.copyButton,children:[(0,or.jsx)("span",{className:n.copyButtonText,children:i}),(0,or.jsx)(dc,{})]}):"-"})]},o.label)})})};var xt=S($());var ax=S(R()),NA=()=>(0,ax.jsx)("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"ReplayIcon",children:(0,ax.jsx)("path",{d:"M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8"})});var Da={};bt(Da,{enUS:()=>LF,nlNL:()=>OF});var LF={titleKnowledgeAssistant:[{type:0,value:"Knowledge Assistant"}],inputPlaceholder:[{type:0,value:"What is your question?"}],useCue:[{type:0,value:"Add to message"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Submit"}],resetLabel:[{type:0,value:"Reset"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},OF={titleKnowledgeAssistant:[{type:0,value:"Knowledge Assistant"}],inputPlaceholder:[{type:0,value:"Wat is je vraag?"}],useCue:[{type:0,value:"Voeg toe aan bericht"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Verzend"}],resetLabel:[{type:0,value:"Reset"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var lx={form:"dd-pleCH",formInput:"dd-pGJMY",formSubmit:"dd--gkRg",actionButton:"dd-I2NEH",sources:"dd-xf9c6",source:"dd-a-vyX",tooltip:"dd-EsgcZ",linkContent:"dd-gARDA",showMoreSources:"dd-uDGi-"};var xe=S(R()),MF=3,NF=({sources:e,onClick:t})=>{let n=ue(Da),r=F("WidgetKnowledgeAssistant",lx),[o,i]=(0,xt.useState)(!1),s=o?e:e.slice(0,MF);return s.length===0?null:(0,xe.jsxs)("ul",{className:r.sources,children:[s.map(a=>(0,xe.jsx)("li",{className:r.source,"data-testid":"knowledge-assist-source",children:(0,xe.jsxs)(pt,{tooltip:!0,placement:"top-start",children:[(0,xe.jsx)(pt.Trigger,{as:"a",rel:"noreferrer",target:"_blank",href:a.url,onClick:l=>{l.stopPropagation(),t(a)},children:(0,xe.jsx)("span",{className:r.linkContent,children:a.name})}),a.url&&(0,xe.jsx)(pt.Content,{className:r.tooltip,children:decodeURIComponent(a.url)})]})},a.name)),s<e&&(0,xe.jsx)("button",{type:"button",className:r.showMoreSources,onClick:()=>i(!0),children:n("showMore",{amount:e.length-s.length})})]})},_F=({title:e,description:t})=>(0,xe.jsx)(Ee,{"data-testid":"knowledge-assist-empty-state",children:(0,xe.jsx)(Oe,{children:(0,xe.jsxs)(Oe.Content,{children:[(0,xe.jsx)(Oe.Title,{children:e}),(0,xe.jsx)($i,{content:t})]})})}),DF=({innerRef:e,item:t,index:n,hasKeyboardInput:r,onCopy:o,onUse:i,onSourceClick:s})=>{var l;let a=ue(Da);return(0,xe.jsxs)(Ee,{"data-testid":"knowledge-assist-answer",ref:e,children:[(0,xe.jsx)(Oe,{children:(0,xe.jsxs)(Oe.Content,{children:[(0,xe.jsx)(Oe.Title,{children:t.question}),(0,xe.jsx)($i,{content:t.answer.answer,useLabel:a("useCue"),copyLabel:a("copyCue"),onCopy:o,onUse:r?i:void 0}),(0,xe.jsx)(NF,{sources:(l=t.answer.sources)!=null?l:[],onClick:u=>s(u,t.question)})]})}),(0,xe.jsxs)(Ee.ButtonsContainer,{children:[(0,xe.jsx)("div",{}),(0,xe.jsx)(Bi,{eventName:"knowledge assist feedback",eventData:{question:t.question,isFollowUpQuestion:n>0,isAgent:!0,answer:t.answer.answer},feedbackText:t.answer.answer,feedbackType:"assistant"})]})]})},ux=(0,xt.createContext)(null),km=({assistantCode:e,evaluateKnowledgeAssistFn:t,initialQuestion:n,children:r})=>{let[o,i]=(0,xt.useState)(null),[s,a]=(0,xt.useState)(!1),[l,u]=(0,xt.useState)(!!n),[c,f]=(0,xt.useState)(null),d=he(),p=at(),y=Zr(m=>{if(!e)throw new Error("No knowledge assistant was defined");return t({assistantCode:e,input:m,threadId:o,onNewThreadId(v){i(v)}})},{onSuccess(m){var v;p("knowledge assist question answered",{question:m.question,answer:m.answer.answer,sources:(v=m.answer.sources)!=null?v:[],isFollowUpQuestion:m.threadId===o,isAutoInitiated:l}),u(!1)}}),h=m=>A(void 0,null,function*(){a(!0),f(m),yield y.call(m),a(!1),f(null)}),g={isEnabled:!!e,isSubmitting:s,threadId:o,pendingInput:c,onSubmit:h,onReset(){o&&d(ua(o)),i(null)}};return(0,xt.useEffect)(()=>{n&&h(n)},[n]),(0,xe.jsx)(ux.Provider,{value:g,children:r})},Rm=()=>{let e=ue(Da),t=F("WidgetKnowledgeAssistant",lx),n=(0,xt.useContext)(ux),r=(0,xt.useRef)(null),[o,i]=(0,xt.useState)(""),s=u=>{i(u.target.value)},a=u=>{u.preventDefault(),n.onSubmit(o).then(()=>{var c;r.current&&((c=r.current)==null||c.focus(),i(""))})},l=u=>{u.preventDefault(),n.onReset()};return n.isEnabled?(0,xe.jsxs)("form",{className:t.form,onSubmit:a,children:[(0,xe.jsx)("input",{ref:r,className:t.formInput,placeholder:e("inputPlaceholder"),type:"text",disabled:n.isSubmitting,value:o,onChange:s}),(0,xe.jsx)("button",{type:"submit",disabled:n.isSubmitting||o==="",className:t.formSubmit,children:e("submitLabel")}),(0,xe.jsx)("button",{type:"button",title:e("resetLabel"),disabled:n.threadId===null||n.isSubmitting,onClick:l,className:t.actionButton,children:(0,xe.jsx)(NA,{})})]}):null},Pm=({emptyState:e})=>{var f,d;let t=ue(Da),n=at(),r=(0,xt.useRef)(null),o=(0,xt.useContext)(ux),i=(d=K(bu((f=o.threadId)!=null?f:-1)))!=null?d:[],s=J("hasKeyboardInput"),a=on(),l=p=>{xr(p),n("Assistant response copied",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",copiedText:p})},u=(p,y)=>{n("knowledge assist source viewed",{question:y,sourceViewed:p.url||p.name})},c=p=>{a.send(vr,{text:p,suggestion:{source:"cue",sourceText:p}}),n("Assistant response used",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",usedText:p})};return!o.isEnabled||(i==null?void 0:i.length)===0&&!o.isSubmitting&&!e?null:(0,xe.jsx)(lr,{type:"knowledge",title:t("titleKnowledgeAssistant"),"data-testid":"knowledge",children:(0,xe.jsxs)(Zt,{withDivider:!0,children:[e&&i.length===0&&!o.pendingInput&&(0,xe.jsx)(_F,b({},e)),i.map((p,y)=>(0,xe.jsx)(DF,{innerRef:y===i.length-1?r:void 0,item:p,index:y,hasKeyboardInput:s,onCopy:l,onUse:c,onSourceClick:u},`${p.question}_${p.answer}_${y}`)),o.pendingInput&&(0,xe.jsx)(Tm,{title:o.pendingInput})]})})};var FA=S($());var FF=/(https?:\/\/[^\s]+)/,DA=e=>e.split(" ").find(t=>FF.test(t));var Dn=S(R()),HF=({suggestion:e,lines:t,onUse:n})=>{var f;let r=e.text||e.url||e.message,o=DA(r),i=ue(rc),s=J("showImages"),a=J("fallbackImage"),l=J("hasKeyboardInput"),u=d=>{d.preventDefault(),d.stopPropagation(),l&&n(r)},c=(0,FA.useCallback)(d=>{window.open(o,"_blank"),d.stopPropagation(),d.preventDefault()},[o]);return(0,Dn.jsxs)(Ee,{onClick:l?u:void 0,"data-testid":"edit-suggestion",children:[(0,Dn.jsxs)(Oe,{children:[s&&e.image&&(0,Dn.jsx)(Oe.Image,{src:vm(e,"small",a||void 0),title:e.title}),(0,Dn.jsxs)(Oe.Content,{children:[e.title&&(0,Dn.jsx)(Oe.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((f=e.searchKeywords)==null?void 0:f.length)>0&&(0,Dn.jsx)(Ee.Labels,{labels:e.searchKeywords}),(0,Dn.jsx)(Oe.Content,{cropText:t==="single",lineClamp:t==="multiple",children:r})]})]}),(0,Dn.jsxs)(Ee.Actions,{children:[o&&(0,Dn.jsx)(Ee.ActionButton,{onClick:c,label:i("visitUrl")}),l&&(0,Dn.jsx)(Ee.ActionButton,{primary:!0,onClick:u,label:i("useSuggestion")})]})]})},HA=HF;var mc=S(R()),zF=({lines:e,suggestions:t})=>{let n=on(),r=(o,i)=>{n.send(vr,{text:o,suggestion:P(b({},i),{source:i.source,sourceText:i.text})})};return(0,mc.jsx)(mc.Fragment,{children:t.map(o=>(0,mc.jsx)(HA,{suggestion:o,lines:e,onUse:i=>r(i,o)},o.text||o.url||o.message))})},zA=zF;var Am={};bt(Am,{enUS:()=>BF,nlNL:()=>UF});var BF={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},UF={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Fa={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",footer:"dd-tvofr",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",footerShortcut:"dd-dH7XJ",link:"dd-DRo0x"};var de=S(R()),UA=(e,t)=>{let n=K(zt);(0,Ha.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},jF=({onLogIn:e})=>{let t=F("Widget",Fa),n=J("isEmbedded"),r=J("adminUrl");return(0,de.jsx)("div",{className:t.loginText,children:(0,de.jsx)("div",{children:(0,de.jsx)(lm,{isEmbedded:n,loginUrl:r,onLogIn:e})})},"login")},BA=({text:e})=>{let t=F("Widget",Fa);return(0,de.jsx)("div",{className:t.stateText,children:(0,de.jsx)("div",{children:(0,de.jsx)("p",{children:e})})},"notification")},VF=()=>{let e=ue(Am),t=he(),n=F("Widget",Fa),r=J("showSearch"),o=J("showSummaryCommand"),i=J("showKnowledgeSearch"),s=K(Cv("knowledge-assist")),a=J("isEmbedded"),l=K(Ra("/admin/")),u=on(),c=J("productName"),f=J("hasKeyboardInput"),d=Zr(()=>Wn({})),p=at(),y=r||o||i||l;return UA(()=>{if(a)return t(Z0()),()=>{t(dA())}},[t,a]),!y||!f?null:(0,de.jsx)(lr,{title:e("actions"),type:"shortcuts",children:(0,de.jsxs)("div",{className:n.shortcutList,children:[r&&(0,de.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-search","aria-label":e("linkSearch"),onClick:()=>{u.send("ShowCommandPalette",{isOpen:!0}),p("open search",{via:"widget-shortcut"})},children:[(0,de.jsx)(Ea,{}),e("linkSearch")]}),o&&!s&&(0,de.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-summary","aria-label":e("linkSummary"),disabled:d.state==="loading",onClick:()=>d.call(),children:[(0,de.jsx)(vA,{}),e("linkSummary")]}),i&&!s&&(0,de.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-knowledge-assist","aria-label":e("linkKnowledgeSearch"),onClick:()=>{u.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),p("open knowledge assistant",{via:"widget-shortcut"})},children:[(0,de.jsx)(yA,{}),e("linkKnowledgeSearch")]}),l&&(0,de.jsxs)("a",{className:n.shortcut,target:"_blank",href:l,"data-testid":"shortcut-studio-login","aria-label":e("linkStudioLogin",{productName:c}),rel:"noreferrer",onClick:()=>{p("open my deepdesk",{via:"widget-shortcut"})},children:[(0,de.jsx)(hA,{}),e("linkStudioLogin",{productName:c})]})]})})},WF=()=>{let e=he(),t=K(Cu),n=K(SC),r=K(pA),o=K(MT),i=K(Bp),s=K(tm),a=K(Ri),l=K(yr);return(0,Ha.useEffect)(()=>{!!o&&!n&&ee.warn("Custom data provided, but no schema.")},[o,n]),UA(()=>{t.forEach(({type:u})=>{u==="entities"?e(Zn()):Hc.includes(u)||e(rr(u))})},[e,l,a]),(0,Ha.useEffect)(()=>{r.length>0&&!t.some(u=>u.type==="cues")&&ee.warn("Received cues, but cues are not configured in widget.")},[t,r]),(0,de.jsx)(Ha.Fragment,{children:t.map(({type:u,title:c,amount:f,lines:d,schema:p})=>{var y,h;switch(u){case"entities":return i&&i.length>0&&(0,de.jsx)(lr,{type:u,title:c,"data-testid":`type-${u}`,children:(0,de.jsx)(gA,{entities:i})},u);case"cues":return r&&r.length>0&&(0,de.jsx)(lr,{type:u,title:c,"data-testid":`type-${u}`,children:(0,de.jsx)(Zt,{withDivider:!0,children:(0,de.jsx)(LA,{cues:r})})},u);case"custom-data":return o&&p&&(0,de.jsx)(lr,{type:u,title:c,"data-testid":`type-${u}`,children:(0,de.jsx)(Zt,{withDivider:!0,children:(0,de.jsx)(MA,{data:o,schema:p})})},u);default:return((h=(y=s[u])==null?void 0:y.suggestions)==null?void 0:h.length)>0&&(0,de.jsx)(lr,{type:u,title:c,"data-testid":`type-${u}`,children:(0,de.jsx)(Zt,{withDivider:!0,children:(0,de.jsx)(zA,{lines:d,contentType:u,suggestions:s[u].suggestions.slice(0,f)||[]})})},u)}})})},cx=({children:e})=>{let t=F("Widget",Fa);return(0,de.jsx)("div",{className:t.footer,children:e})},dx=({children:e})=>{let t=F("Widget",Fa);return(0,de.jsx)("div",{className:t.root,"data-testid":"widget",children:e})},KF=({onLogIn:e,knowledgeAssistOptions:t={}})=>{let n=ue(Am),r=K(oa),o=K(zt),i=K(yT),s=K(Ri),a=K(Cv("knowledge-assist")),l=K(op),u=K(ip);return r===!1?(0,de.jsx)(BA,{text:n("notSupported")}):o===!1?(0,de.jsx)(jF,{onLogIn:e}):!s||!i||o===null?(0,de.jsx)(BA,{text:n("waiting")}):(0,de.jsx)(dx,{children:(0,de.jsxs)(km,{initialQuestion:t.initialQuestion,assistantCode:l!=null?l:u,evaluateKnowledgeAssistFn:u?Ci:ki,children:[(0,de.jsxs)(fs,{children:[(0,de.jsx)(VF,{}),(0,de.jsx)(WF,{}),a&&(0,de.jsx)(Pm,{emptyState:t.emptyState})]}),(0,de.jsxs)(cx,{children:[a&&(0,de.jsx)(Rm,{}),(0,de.jsx)(kA,{})]})]})})},jA=KF;function za(e){let t=new Range;return t.selectNodeContents(e),t}function VA(e,t,n){try{return Zo(e,t,n),!0}catch(r){return!1}}function Im(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function Lm(e){return"tagName"in e&&e.tagName==="BR"}var gc=/[\u200B-\u200D\uFEFF]/g;function Zo(e,t,n){let r=new Range;if(e.firstChild===null&&t===0&&n===0)return r.selectNodeContents(e),r;let o=0,i=!1;function s(l,u){let c=-1,f=/[\u200B-\u200D\uFEFF]/;if(!f.test(l))return u;for(let d=0;d<=l.length;d++)if(f.test(l[d])||c++,c===u)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let u=l.textContent,c=u.replace(gc,""),f=o+c.length,d=t>=o&&t<=f,p=n>=o&&n<=f;if(d){let y=s(u,t-o);y===0&&!p?r.setStartBefore(l):r.setStart(l,y)}p&&(r.setEnd(l,s(u,n-o)),i=!0),o=f;break}case Node.ELEMENT_NODE:{if(Lm(l)&&(o===t&&r.setStartBefore(l),o++,o===n)){r.setEndAfter(l),i=!0;return}for(let c=0;c<l.childNodes.length&&(a(l.childNodes[c]),!i);c++);let u=l.lastChild;Im(l)&&u&&!Im(u)&&!Lm(u)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function hc(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a,l,u=0;function c(f){let d=f===e,p=f===n,y=f===o;switch(f.nodeType){case Node.TEXT_NODE:{let h=f.textContent;p&&(a=u+h.substring(0,r).replace(gc,"").length),y&&(l=u+h.substring(0,i).replace(gc,"").length),u+=h.replace(gc,"").length;break}case Node.ELEMENT_NODE:{if(Lm(f)&&f.nextSibling){u++;break}!d&&Im(f)&&f.previousSibling&&u++;for(let h=0;h<f.childNodes.length;h++){let g=p&&h===r,m=y&&h===i;if(g&&(a=u),m&&(l=u),l!==void 0||((!g||!s)&&c(f.childNodes[h]),y&&h===i-1&&(l=u),l!==void 0))break}y&&(l=u);break}default:break}}if(c(e),l===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:l,end:l}}function yc(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a=0,l="";function u(c){let f=c===e,d=c===n,p=c===o;switch(d&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let y=d?r:0,h=p?i:void 0;l+=c.textContent.replace(gc,"").substring(y,h);break}case Node.ELEMENT_NODE:{if(!s&&a===1&&Lm(c)&&c.nextSibling){l+=`
82
82
  `;break}!f&&!s&&a===1&&Im(c)&&c.previousSibling&&(l+=`
83
- `);let y=d?r:0,h=p?Math.min(i,c.childNodes.length):c.childNodes.length;for(let g=y;g<h&&(u(c.childNodes[g]),a!==2);g++);break}default:break}p&&(a=2)}return u(e),l}var WA=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(WA||{}),ao=class{constructor(t){this.element=t;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(t,n){let r=o=>{n(o)};this.element.addEventListener(t,r),this.disposeHandlers.push(()=>{this.element.removeEventListener(t,r)})}removeEventListener(t,n){this.element.removeEventListener(t,n)}handleInteraction(){let t=this.getText(),n=this.getHTML(),r=this.getSelection(),o=this.cachedCaretPosition===null;if(!this.isActive||(t===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),t!==this.cachedText?(this.cachedText=t,this.cachedHTML=n,o=!0,this.emit("change",{plainText:t,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,o=!0,this.emit("change",{plainText:t,rawHTML:n})),(r.start!==this.cachedSelection.start||r.end!==this.cachedSelection.end)&&(this.cachedSelection=r,o=!0,this.emit("selection",r)),!o))return;let i=this.getCaretPosition();Ho(i,this.cachedCaretPosition)||(this.cachedCaretPosition=i,this.emit("caretposition",i))}handleClick(){this.handleInteraction()}handleFocus(){let t=!this.isFocused;this.isFocused=!0,t&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let t=this.isFocused;this.isFocused=!1,t&&this.emit("blur")}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(WA).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleKeyUp(t){this.handleInteraction(),this.emit("keyup",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),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.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let t=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{t.disconnect()})}focus(){this.element.focus()}emit(t,...n){this.isDisposed||this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r(...n)})}on(t,n){this.isDisposed||(this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n))}off(t,n){if(!this.eventListeners[t])return;let r=this.eventListeners[t].indexOf(n);r!==-1&&this.eventListeners[t].splice(r,1)}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};function KA(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var es=class extends ao{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),yc(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){var s;let n=this.getRootNode();if(n.activeElement!==this.element)return null;let r="getSelection"in n?n.getSelection():window.getSelection();if(!r)return null;let o="getComposedRanges"in r&&n instanceof ShadowRoot?(s=r.getComposedRanges(n))==null?void 0:s[0]:r.rangeCount>0?r.getRangeAt(0):null;if(!o)return null;let i=this.element.ownerDocument.createRange();return i.setStart(o==null?void 0:o.startContainer,o==null?void 0:o.startOffset),i.setEnd(o==null?void 0:o.endContainer,o==null?void 0:o.endOffset),!i||!this.element.contains(i.startContainer)||!this.element.contains(i.endContainer)?null:i}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let r=n.getBoundingClientRect();return!KA(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!KA(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return hc(this.element,n);let r=this.lastKnownSelection;if(r&&VA(this.element,r.start,r.end))return r;let o=za(this.element);return o.collapse(!1),hc(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return yc(this.element,Zo(this.element,n,r))}listen(){super.listen();let n=new MutationObserver(i=>{var s,a;i.length===2&&i[0].addedNodes.length===1&&((s=i[0].addedNodes[0])==null?void 0:s.textContent)==="\u2060"&&((a=i[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let r=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==r&&(r=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}};var $F=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize"];function $A(e,t){let n="mozInnerScreenX"in window,r=document.createElement("div");r.id="input-textarea-caret-position-mirror-div";let o=r.style,i=window.getComputedStyle(e),s=e.ownerDocument.body;o.whiteSpace="pre-wrap",o.wordWrap="break-word",o.position="absolute",o.visibility="hidden",$F.forEach(c=>{o[c]=i[c]}),n?e.scrollHeight>Number.parseInt(i.height)&&(o.overflowY="scroll"):o.overflow="hidden",r.textContent=e.value.substring(0,t);let a=document.createElement("span");a.textContent=e.value.substring(t)||".",r.appendChild(a),s.appendChild(r);let l=e.getBoundingClientRect(),u={top:l.top-e.scrollTop+a.offsetTop+Number.parseInt(i.borderTopWidth)+a.offsetHeight,left:l.left-e.scrollLeft+a.offsetLeft+Number.parseInt(i.borderLeftWidth)};return s.removeChild(r),u}var ts=class extends ao{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:r}=this.element;return{start:n,end:r}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return $A(this.element,this.element.selectionEnd)}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var i;return(i=n==null?void 0:n.get)==null?void 0:i.call(this.element)},set:i=>{var s;(s=n==null?void 0:n.set)==null||s.call(this.element,i),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let r=this.element.disabled,o=new MutationObserver(()=>{this.element.disabled!==r&&(r=this.element.disabled,this.emit(r?"disabled":"enabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>o.disconnect())}};function qA(e,t,n){let r=`deepdesk-iframe-${e}`,o=document.getElementById(r);if(o)return o;let i=document.createElement("iframe"),s=new URL(t);return Object.entries(n).forEach(([a,l])=>{s.searchParams.append(a,l)}),i.style.position="absolute",i.style.left="-999em",i.style.width="0px",i.style.height="0px",i.tabIndex=-1,i.id=r,i.title=`iframe-${e}`,i.src=s.toString(),window.document.body.appendChild(i),i}function qF(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var fx=class{constructor(t){this.name=t;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(t)}onMessage(t){this.broadcastChannel.addEventListener("message",t),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",t)})}postMessage(t){this.broadcastChannel.postMessage(JSON.stringify(t))}close(){this.disposeHandlers.forEach(t=>t()),this.broadcastChannel.close()}},px=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=qA(t,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(t){window.addEventListener("message",t),this.disposeHandlers.push(()=>{window.removeEventListener("message",t)})}postMessage(t){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(t),this.targetOrigin)}close(){var t;this.disposeHandlers.forEach(n=>n()),(t=this.iframe)==null||t.remove()}},mx=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(t){this.sessionId!==t&&(this.cleanup(),ee.info("Set sessionId",t),this.sessionId=t,this.channel=this.createChannel(t))}createChannel(t){let n=this.params.createCustomChannel?this.params.createCustomChannel(t):this.isCrossOrigin?new px(t,this.deepdeskUrl,{debug:!0}):new fx(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=qF(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(ee.info("Received broadcast event",this.sessionId,o),(a=(s=this.eventMap)[i.name])==null||a.call(s,i.payload))};return n.onMessage(r),n}send(t,n,r){var s,a;ee.info("Broadcast event",{sessionId:this.sessionId,name:t,payload:n});let o={type:"event",name:t,payload:n};r!==!1&&((a=(s=this.eventMap)[t])==null||a.call(s,n));let i=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;i==null||i.postMessage(P(b({},o),{channel:this.sessionId}))}cleanup(t=!1){var n,r;(n=this.channel)==null||n.close(),this.channel=void 0,t&&((r=this.defaultChannel)==null||r.close(),this.defaultChannel=void 0)}},GA=mx;function GF(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function $e(e){return Array.isArray(e)?e.map($e):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>P(b({},t),{[GF(n)]:$e(e[n])}),{}):e}function YF(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function wt(e){return Array.isArray(e)?e.map(wt):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>P(b({},t),{[YF(n)]:wt(e[n])}),{}):e}var Ba=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var gx=e=>new Promise(t=>{setTimeout(t,e)});var Ua=class extends Ba{constructor(){super(...arguments);this.name="ClientError"}},yx=class extends Ba{constructor(){super(...arguments);this.name="ServerError"}},hx=new Map;function XF(e){return A(this,null,function*(){if(e.status===204)return e.text().catch(()=>{}),null;let t=e.headers.get("content-type");if(t!=null&&t.includes("application/json"))return e.json();let n=yield e.text();return n===""?null:(ee.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var Jo=class Jo{constructor(t="",n={}){this.baseUrl=t;this.options=n;this.latestRequestByUrl={};this.fetch=window.fetch.bind(window);n.fetch&&(this.fetch=n.fetch)}patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let i={isAborted:!1,reject:o},s=`${this.baseUrl}${t}`,a=this.fetch,l=n.method===void 0||n.method.toLowerCase()==="get",E=n,{useCache:u=!1,abortLatest:c=!1,attempts:f=1,retryDelay:d=500,refreshTokenOn401:p=!0,retryOnError:y=k=>k instanceof TypeError,retryOnResponse:h=k=>k.status>=500,version:g=null}=E,m=se(E,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(u){if(!l)throw new Error(`Can't use 'useCache' for ${n.method}`);if(hx.has(s)){r(hx.get(s));return}}let v=P(b({credentials:"include"},m),{headers:b({Accept:"application/json","Content-Type":"application/json"},m.headers)});!l&&this.csrfToken&&(v.headers=P(b({},v.headers),{"X-CSRFToken":this.csrfToken})),typeof g=="string"&&(v.headers=P(b({},v.headers),{"X-Deepdesk-API-Version":g}));let x=f,w=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&c&&(this.latestRequestByUrl[s].isAborted=!0,this.latestRequestByUrl[s].reject(new Error("Aborted"))),this.latestRequestByUrl[s]=i;let C=()=>A(this,null,function*(){return x--,a(s,v).then(k=>A(this,null,function*(){return h(k)&&!i.isAborted&&x>0?(yield gx(d),C()):k.status===401&&p===!0&&w===!1?(w=!0,yield this.refreshToken(),C()):k})).catch(k=>A(this,null,function*(){if(y(k)&&!i.isAborted&&x>0)return yield gx(d),C();throw k}))});C().then(k=>A(this,null,function*(){let I=yield XF(k);if(delete this.latestRequestByUrl[s],k.status>=500){o(new yx("Server Error",I));return}if(k.status===401){o(new Ua("Unauthorized",I));return}if(k.status===403){o(new Ua("Forbidden",I));return}if(k.status===404){o(new Ua("Not Found",I));return}if(k.status>=400){o(new Ua("Bad Request",I));return}u&&hx.set(s,I),r(I)})).catch(k=>{o(k)})})}validateToken(){return A(this,null,function*(){let{has_valid_access_token:t}=yield this.get("/auth/validate");if(!t)try{yield this.refreshToken()}catch(r){return!1}let{is_logged_in:n}=yield this.get("/apis/admin/session/validate/");return!!n})}refreshToken(){return Jo.refreshingToken||(Jo.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{Jo.refreshingToken=null},1e3*60)})),Jo.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,b({method:"POST",body:JSON.stringify(n)},r))}patch(t,n,r){return this.request(t,b({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,b({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,b({method:"DELETE"},n))}};Jo.refreshingToken=null;var ns=Jo;var YA;(t=>{let e;(s=>(s.SEND_MESSAGE="Send Message",s.HANDLING_TIME="Handling Time",s.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",s.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(e=t.EventType||(t.EventType={}))})(YA||(YA={}));function Om(e){return P(b({},$e(e)),{tags:e.tags})}var rs=class rs{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new ns(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,i)=>A(this,null,function*(){let s=yield r(o,i);return this.handleDeepdeskVersionHeaders(s),s}))}preflight(){return A(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(rs.exchangeTokenPromise||(rs.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),rs.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return A(this,null,function*(){yield this.preflight(),ee.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=yield this.client.post("/api/conversations",P(b({},wt(t)),{tags:t.tags}),{version:"v2"});return Om(n)})}getMe(){return A(this,null,function*(){let t=yield this.client.get("/apis/admin/session/me/");return $e(t)})}postIdentity(t){return A(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",wt(t))})}patchMe(t){return A(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",wt(t));return $e(n)})}getProfile(t){return A(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{useCache:!0});return $e(n)})}getKnowledgeAssistant(t){return A(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{useCache:!0});return $e(n)})}getContentTypes(){return A(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return $e(t)})}getAccount(){return A(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{useCache:!0});return $e(t)})}getPlatformConfig(t){return A(this,null,function*(){let n=t!==void 0?`/platform/config/${t}/`:"/platform/config/",{config:r}=yield this.client.get(n,{useCache:!0});return $e(r)})}checkUserExists(t){return A(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`,{version:"v1"});return n})}getConversationBySessionId(r){return A(this,arguments,function*(t,n={}){yield this.preflight(),ee.info(`Getting conversation for session ${t}`);let{attempts:o=1,retryDelay:i=1e3}=n,s=yield this.client.get(`/api/conversations/by_session_id/${t}`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return ee.info(`Successfully retrieved conversation ${s.id} for session ${t}`),Om(s)})}isConversationSupported(r){return A(this,arguments,function*(t,n={}){ee.info(`Check if conversation for session ${t} is supported`);let{attempts:o=1,retryDelay:i=1e3}=n;return(yield this.client.get(`/api/conversations/by_session_id/${t}/active_profile`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"})).has_active_profile})}updateConversation(t,n){return A(this,null,function*(){yield this.preflight();let r=wt(n);n.tags&&(r.tags=n.tags);let o=yield this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return Om(o)})}postMessages(t,n){return A(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/conversations/${t}/messages`,n.map(o=>P(b({},wt(o)),{tags:o.tags})),{version:"v2"})).map(o=>Om(o))})}sendEvent(t,n){return A(this,null,function*(){yield this.preflight();let s=n,{data:r}=s,o=se(s,["data"]),i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((a,[l,u])=>P(b({},a),{[l]:u}),{});return this.client.post("/api/events",wt(P(b(b({},i),o),{data:r,name:t})),{version:"v2"})})}sendEventV1(t,n){return A(this,null,function*(){yield this.preflight();let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>P(b({},o),{[i]:s}),{});return this.client.post("/api/events",{event:t,data:wt(b(b({},n),r))},{version:"v1"})})}getEntities(t){return A(this,null,function*(){return yield this.preflight(),(yield this.client.post("/api/entities",{messages:t.filter(r=>r.text)},{version:"v1"})).entities})}getTemporaryExchangeToken(){return A(this,null,function*(){return(yield this.client.get("/auth/exchange-token")).jwt})}exchangeTokenForAccessCookie(t){return A(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t}).catch(n=>{throw ee.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return A(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",wt(n),{refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return A(this,arguments,function*(t,n={},r){return yield this.preflight(),r==="sticky-messages"?this.getPinnedMessages(t):(yield this.client.post(`/api/conversations/${t}/recommend/${r}`,wt(n),{abortLatest:!0,version:"v1"})).map(s=>P(b({},$e(s)),{text:s.text||s.url||s.message,source:r,type:r})).filter((s,a,l)=>a===l.findIndex(u=>u.text===s.text))})}isLoggedIn(){return A(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return A(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/conversations/${t}/autocomplete`,wt(n),{abortLatest:!0,version:"v1"})).map(o=>({score:1,source:o.source,sourceText:o.source_text,text:o.label,trainingJobs:o.training_jobs,searchKeywords:o.search_keywords,type:o.source})).filter((o,i,s)=>i===s.findIndex(a=>a.text===o.text))})}getPinnedMessages(t){return A(this,null,function*(){let n=yield this.client.get(`/api/conversations/${t}/sticky-messages`,{abortLatest:!0,version:"v1"});return $e(n).map(r=>P(b({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return A(this,null,function*(){let n=yield this.client.post("/api/style-suggestions",wt(t),{abortLatest:!0,version:"v1"});return $e(n)})}search(t){return A(this,null,function*(){let n=yield this.client.post(`/api/profiles/${t.profile}/search`,wt(t),{version:"v2"});return $e(n)})}knowledgeAssist(i,s,a){return A(this,arguments,function*(t,n,r,o={}){yield this.preflight();let l=yield this.client.post(`/api/knowledge-assist/assistants/${r}/search`,wt({question:t.question,doNotKnowAnswer:t.doNotKnowAnswer,customerInstruction:t.customerInstruction,chatHistory:n.map(u=>({question:u.question,answer:u.answer.answer})),agentId:o.agentId,conversationId:o.conversationId}),{version:"v2"});return $e(l)})}requestLoginByEmail(t){return A(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t});return $e(n)})}requestPasswordlessToken(){return A(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/");return $e(t.token)})}getCsrfToken(){return A(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/");return t})}verifyLoginToken(t){return A(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t});return $e(n)})}getSummary(r){return A(this,arguments,function*(t,n={}){yield this.preflight();let o=yield this.client.post("/api/summary",{conversation:{messages:t.filter(i=>i.text&&i.source),agent_id:n.agentId,id:n.externalConversationId},prompt_instruction:n.promptInstruction,model:n.model},{version:"v1"});return $e(o)})}evaluateAssistant(t,n){return A(this,null,function*(){var a;yield this.preflight();let r=new URLSearchParams,{expectFormat:o="text"}=n||{};if(o.startsWith("json-schema:")){let l=o.replace("json-schema:","");r.append("expect_response_format","json-schema"),r.append("expect_response_format_schema",l)}else r.append("expect_response_format",o);n!=null&&n.externalConversationId&&r.append("external_conversation_id",n.externalConversationId);let i=n!=null&&n.threadId?`/api/v2/assistants/${t}/threads/${n==null?void 0:n.threadId}/evaluate?${r.toString()}`:`/api/v2/assistants/${t}/evaluate?${r.toString()}`,s=yield this.client.post(i,{input:(a=n==null?void 0:n.input)!=null?a:{},conversation:n==null?void 0:n.transcript});return $e(s.output)})}createAssistantThread(t){return A(this,null,function*(){yield this.preflight();let{assistantCode:n}=t,r=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return $e(r)})}postMessageToAssistantThread(t){return A(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:r,message:o}=t,i=yield this.client.post(`/apis/admin/assistants/${n}/threads/${r}/messages/`,{content:o,role:"user"});return $e(i)})}translateMessages(t){return A(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/translate",wt(t),{version:"v2"});return $e(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(_w);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&ee.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};rs.exchangeTokenPromise=null;var lo=rs;var XA={startTime:null,stopTime:null},QA=e=>e.handlingTime,ZA=Ce({name:"handlingTime",initialState:XA,reducers:{handlingTimeStart(e){if(e.startTime&&!e.stopTime)throw new Error("Timing already started");e.startTime=new Date,e.stopTime=null},handlingTimeStop(e){if(!e.startTime)throw new Error("Timing not started");e.stopTime=new Date},handlingTimeReset(e){e.startTime=null,e.stopTime=null}},extraReducers:e=>{e.addCase(it,()=>XA)}}),{handlingTimeStart:JA,handlingTimeStop:Mm,handlingTimeReset:eI}=ZA.actions,tI=ZA.reducer;var nI=(e={})=>{let t=b({onAuthError:ra(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var Nm={list:{keywordMatches:[]},fetchState:"idle"};var os=ge("styleSuggestions/getAll",(n,r)=>A(void 0,[n,r],function*({text:e},t){var l;let{deepdeskAPI:o}=t.extra,i=t.getState(),{showStyleSuggestions:s}=i.settings,a=(l=i.conversation.current)==null?void 0:l.profileCode;if(!s)return Nm.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),QF=Ce({name:"styleSuggestions",initialState:Nm,reducers:{},extraReducers:e=>{e.addCase(os.pending,t=>{t.fetchState="loading"}).addCase(os.rejected,t=>{t.fetchState="error"}).addCase(os.fulfilled,(t,n)=>{t.fetchState="done",Ho(t.list,n.payload)||(t.list=n.payload)}).addCase(bi,t=>{t.list=Nm.list}).addCase(it,()=>Nm)}}),rI=QF.reducer;var oI=(e={})=>{let t,n=!0,r=b({getStyleSuggestions:os,debounce:500},e);return o=>i=>s=>{var p;let a=o.getState().input.text,l=i(s),u=o.getState();if(u.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:c}=u.settings;if(!((p=u.conversation.current)==null?void 0:p.id)||!c)return l;let{text:d}=u.input;return d===a&&!n||(clearTimeout(t),d==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:d}))},e.debounce)),l}};function ZF(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var iI=(e={})=>{let t=b({getTextSuggestions:rr,getAutocompleteSuggestions:ic,debounce:200,check:Tr},e),n;return r=>o=>i=>{var h;let{input:s}=r.getState(),a=o(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:u,showTabCompletion:c}=l.settings,f=(h=l.conversation.current)==null?void 0:h.id,d=i.type===nm.toString();if(!f||!u&&!c)return a;let{input:p}=l;return ZF(p,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let g=ia(l);g===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(g))},d?0:t.debounce)),a}};var sI=os.fulfilled.toString();function JF(e,t){let n=new Set([...t.keywordMatches.map(o=>o.keyword)]),r=[];return n.forEach(o=>{let i=e.keywordMatches.filter(l=>l.keyword===o),s=t.keywordMatches.filter(l=>l.keyword===o),a=s.length-i.length;a<=0||r.push(...s.slice(0,a))}),r}var aI=e=>t=>n=>r=>{var u;if(r.type!==sI){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let i=t.getState(),s=i.styleSuggestions.list,a=(u=i.conversation)==null?void 0:u.current;if(o===s)return;let l=JF(o,s);r.type===sI&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var e5=nf({assistants:hC,auth:aT,conversation:vT,contentTypes:vC,passwordlessToken:fA,entities:mR,handlingTime:tI,info:HT,input:IT,settings:eT,profile:bC,search:WT,styleSuggestions:rI,ui:IP,textSuggestions:gP});function lI(e){return sE({reducer:e5,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI}},serializableCheck:!1}),nI(),iI({debounce:200}),oI({debounce:500}),aI(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var t5=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},n5=e=>t=>n=>r=>{var a,l,u,c,f,d;let o=t.getState(),i=ru("inlineSuggestions")(o);switch(r.type){case ra.toString():{!r.payload&&e.emit("logout",void 0);break}case Zn.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:(a=o.conversation.current)==null?void 0:a.id,data:{entities:r.payload}});break;case Wr.toString():e.sendEvent(r.payload.name,{conversationId:((l=r.payload.options)==null?void 0:l.includeConversationData)&&((u=o.conversation.current)==null?void 0:u.id),data:r.payload.data});break;case bi.toString():e.logSendMessage(r.payload);break;case rp.toString():e.emit("call-to-action",{cue:r.payload});break;case Kn.fulfilled.toString():r.isBroadcasted||e.broadcast(uv,r,!1);break;default:break}let s=n(r);switch(r.type){case bi.toString():e.handleAfterSendMessage(r.payload);break;case ac.toString():e.onUpdateShowTabHint(r.payload);break;case Mm.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case zf.toString():{let{start:p,end:y}=o.input.selection;e.emit("replace",P(b({},r.payload),{replace:r.payload.replace==="selection"?{start:p,end:y}:{start:0,end:y}}));break}case jn.toString():{let{start:p,end:y}=o.input.selection;e.emit("select-suggestion",P(b({type:t5(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:p,end:y}:{start:0,end:y}})),i&&t.dispatch(zo([]));break}case Bf.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(c=o.conversation.current)==null?void 0:c.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case zo.toString():{i&&r.payload.length>0&&t.dispatch(Uf(0));break}case Wn.fulfilled.toString():{e.sendEvent("conversation summarized",{conversationId:(f=o.conversation.current)==null?void 0:f.id,data:{summary:r.payload,assistant:(d=t.getState().profile.data)==null?void 0:d.summarizerAssistantNew}}),e.emit("summary-generated",{summary:r.payload});break}default:break}return s},uI=n5;function vx(e){return e.toISOString().replace("T"," ").replace("Z","")}var r5=(e,t)=>t.version,cI=Un([aa,yr,QA,r5],(e,t,n,r)=>{if(!t)return ee.warn("No conversationId for handling time metrics"),null;let{startTime:o,stopTime:i}=n;return!o||!i?(ee.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:t,clientVersion:r,agentId:e==null?void 0:e.agentId,agentName:e==null?void 0:e.agentName,agentEmail:e==null?void 0:e.agentEmail,timeStart:vx(o),timeStop:vx(i)}});function dI(e,t,n){var I,L,G,D;let r=(I=t.conversation.current)==null?void 0:I.id;if(!r)return ee.warn("No conversationId for send message metrics"),null;let{text:o,metrics:{numCharsTyped:i,numCharsPasted:s,numCharsCut:a,numCharsDeleted:l,numPaste:u,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:f,pastes:d,cuts:p,deletions:y,textSuggestions:h,offeredTextSuggestions:g}}=t[e],m=o.length,x=h.reduce((j,{text:M,searchTerm:_})=>j+M.length-(_?_.length:0),0),w=c!=null?c:Date.now(),C=(Date.now()-w)/1e3+(f||0),E=i/C,k=h.reduce((j,{searchTerm:M})=>j+(M?M.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:d,cuts:p,deletions:y,lenTextTyped:i+k,lenTextTotal:m,lenTextAssisted:x,lenTextPasted:s,lenTextCut:a,lenTextDeleted:l,timeTotalSeconds:C,charsPerSecond:E,numPastes:u,textSuggestionsV2:h,suggestionsCounters:[{source:"gpt",countOffered:g.filter(j=>j.source==="gpt").length}],agentId:(L=t.info.agentInfo)==null?void 0:L.agentId,agentName:(G=t.info.agentInfo)==null?void 0:G.agentName,agentEmail:(D=t.info.agentInfo)==null?void 0:D.agentEmail}}function xx(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return xx(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?xx(o,t):null}function wx(e,t){return xx(e,t)}function fI(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function o5(e){return typeof e=="object"&&e!==null&&"tagName"in e}function _m(e){return o5(e)&&(Zi(e)||cm(e))}var mI,Rr=new Map,i5=["bottom","height","left","right","top","width"],pI=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:i5.some(n=>e[n]!==t[n]);function gI(e){var n,r,o;if(e.ownerDocument===document)return[];let t=(o=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)!=null?o:null;return t?[t,...gI(t)]:[]}function hI(e,t){return!e||!t?null:P(b({},e),{top:e.top+t.top,left:e.left+t.left})}var Dm=!1,yI=()=>{Dm=!0;let e=[];if(Rr.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Rr.delete(n);return}let r=n.getBoundingClientRect();pI(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(hI,t.rect):t.rect;pI(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Rr.size===0){Dm=!1;return}mI=window.requestAnimationFrame(yI)};function Sx(e,t){let n=gI(e),r=[],o=n.map((i,s)=>Sx(i,a=>{r[s]=a;let l=Rr.get(e);if(!l)return;let u=r.reduce(hI,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),Rr.has(e)){let s=Rr.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else Rr.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Dm&&yI()},unobserve(){o.forEach(s=>s.unobserve());let i=Rr.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||Rr.delete(e),Rr.size||(cancelAnimationFrame(mI),Dm=!1)}}}}var vI,Pr=new Map,xI=()=>{Pr.forEach((e,t)=>{if(!t.isConnected){Pr.delete(t);return}let{clientHeight:n,scrollHeight:r}=t,o=r>n;e.visible!==o&&(e.visible=o,e.callbacks.forEach(i=>i(e.visible)))}),Pr.size!==0&&(vI=window.requestAnimationFrame(xI))};function wI(e,t){return{observe(){let n=Pr.size===0;Pr.has(e)?Pr.get(e).callbacks.push(t):Pr.set(e,{visible:void 0,callbacks:[t]}),n&&xI()},unobserve(){let n=Pr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Pr.delete(e),Pr.size||cancelAnimationFrame(vI)}}}}var bx=["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 Ex(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function ja(e){return Number.parseFloat(e)}function Fm(e){return Math.round(e*1e6)}function SI(e){return e/1e6}function Tx(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=ja(e.width),i=ja(e.borderLeftWidth),s=ja(e.borderRightWidth),a=ja(e.paddingRight),l=SI(Fm(o)-Fm(i)-Fm(s)),u=SI(Fm(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function vc(e,t={}){var c,f;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(c=t.position)!=null?c:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",ji(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};Ex(r,n,bx),Tx(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=wI(e,()=>{Ex(r,n,bx),Tx(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=Sx(e,d=>{if(d===null){t.onRemove&&t.onRemove(),n.remove();return}if(!l&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(Ex(r,n,bx),Tx(r,e,n),i(),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let p=t.closestScrollElement.getBoundingClientRect(),y=window.getComputedStyle(t.closestScrollElement),h=ja(y.borderTopWidth),g=ja(y.borderBottomWidth),m=p.top+h-d.top,v=d.top+d.height+-(p.top+p.height-g);n.style.clipPath=`inset(${m}px 0px ${v}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(f=e.parentElement)==null||f.appendChild(n),u.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),u.unobserve(),s.unobserve()}]}var bI=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch(r){return t}}catch(n){return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch(r){ee.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function s5(e){return e.offsetParent!==null}function EI(e){if(!s5(e))return!1;let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}function Hm(e,t,n=100){let r=EI(e);t({isVisible:r});let o=setInterval(()=>{let i=EI(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var Me=S(R());var TI=bI("showTabHint",!0),Va=class Va{constructor({deepdeskUrl:t,version:n=Va.version||"unknown",locale:r="en-US",token:o,fetch:i,productName:s,createCustomChannel:a}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.inlineSuggestions=null;this.aboveSuggestions=null;this.floatingMenu=null;this.widgetRoot=null;this.dynamicThunkObject={};this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let l=t.replace(/\/api$/,"");this.deepdeskApi=new lo(l,{token:o,fetch:i}),this.version=n,this.instanceId=Va.count++;let u={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[uI({broadcast:(c,f,d)=>{this.broadcastEvents.send(c,f,d)},emit:(c,f)=>this.emit(c,f),handleAfterSendMessage:c=>this.handleAfterSendMessage(c),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:c=>this.logSendMessage(c),onUpdateShowTabHint:c=>TI.update(c),sendEvent:(c,f)=>this.deepdeskApi.sendEvent(c,f)})]};this.store=lI(u),this.broadcastEvents=new GA({debug:!0,deepdeskUrl:l,eventMap:KT(this.store),createCustomChannel:a}),this.store.dispatch(ac(TI.value())),this.store.dispatch(Mf({locale:r,adminUrl:l,productName:s}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var t;return(t=this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex])!=null?t: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?(ee.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(ee.warn("Profile has not been loaded (yet)"),!0):(ee.warn("No conversation loaded (yet)"),!0)}login(){this.store.dispatch(ra(null)),this.store.dispatch(jr());let t=n=>zt(n)&&tT(n)!=="loading";return new Promise(n=>{let r=this.subscribe(t,o=>{o&&(r(),n())});this.unmountHandlers.push(()=>{r()})})}isLoggedIn(){return A(this,null,function*(){return(yield this.store.dispatch(jr())).payload})}isConversationSupported(t,n){return A(this,null,function*(){return(yield this.store.dispatch(rv({sessionId:t,options:n}))).payload})}createConversation(t){return A(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(_f(t))).payload})}getConversationBySessionId(t,n){return A(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(yield this.store.dispatch(Df({sessionId:t,options:n}))).payload})}upsertConversation(t){return A(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(ov(t))).payload})}postMessages(t){return A(this,null,function*(){return(yield this.store.dispatch(Hf(t))).payload})}updateConversation(t){return A(this,null,function*(){return(yield this.store.dispatch(Ff(t))).payload})}resetConversation(){this.store.dispatch(it()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(t){this.store.dispatch(Mf(t))}setVisitorInfo(t){this.store.dispatch(_T(t))}setCustomData(t){this.store.dispatch(DT(t))}setAgentInfo(t,n){return A(this,null,function*(){yield this.store.dispatch(su(b(b({},t),n)))})}setAgentSettings(t){return A(this,null,function*(){yield this.store.dispatch(sv(t))})}getAgentSettings(){return A(this,null,function*(){return(yield this.store.dispatch(av())).payload})}refresh(){return A(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(jf({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let t=[];return this.store.dispatch(nm()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}notifyExternalSuggestion(t){this.store.dispatch(jn(t))}evaluateAssistant(t,n){return A(this,null,function*(){let c=n||{},{input:r={},transcript:o,showCuesInWidget:i=!0,includeTags:s,expectFormat:a}=c,l=se(c,["input","transcript","showCuesInWidget","includeTags","expectFormat"]);Object.assign(r,l);let u=yield this.store.dispatch(Kn({assistantCode:t,expectFormat:a||"json-schema:cues",transcript:o,includeTags:s,input:r,skipState:!i}));if(u.error)throw new Error(u.error.message);return u.payload})}evaluateConversationAssistant(t,n){return A(this,null,function*(){yield this.loadProfileConfig();let r={accepted:"conversationAcceptedAssistant","new-message":"conversationNewMessageAssistant",ended:"conversationEndedAssistant"},o=this.state.profile.data[r[t]];if(!o){ee.warn(`No assistant set in profile for conversation event "${t}"`);return}yield this.evaluateAssistant(o,b({transcript:"stored-transcript",includeTags:!0},n))})}getSummary(){return A(this,null,function*(){var n;if(!this.hasConversation())return ee.warn("No conversation to create summary for."),null;(n=this.state.profile.data)!=null&&n.summarizerAssistantNew||ee.warn("No profile loaded yet, or no summarizer assistant set in profile");let t=yield this.store.dispatch(Wn({}));if(t.error)throw new Error(t.error.message);return t.payload})}handleKeyDown(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:i,selection:s}=this.state.input,{inlineSuggestions:a,showTextSuggestions:l}=this.settings,u=a?"below":"above",c=o.length>0;if(this.store.dispatch(ET(iv(t))),!Tr(this.state)||t.key!=="Tab"&&!l)return;let f=()=>{n||!c||s&&(t.shiftKey||(this.store.dispatch(kT()),t.preventDefault()))},d=()=>{n||!c||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(RT()),t.preventDefault()))};switch(t.key){case"ArrowUp":u==="below"?d():f();break;case"ArrowDown":{u==="below"?f():d();break}case"Escape":{n||(this.store.dispatch(Uf(-1)),this.store.dispatch(qo({collapse:!0})),this.store.dispatch(PP(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let p=sa(this.state);if(!p)return;this.store.dispatch(ac(!1)),this.store.dispatch(jn({text:p.text,suggestion:p,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let p=sa(this.state);if(!p)return;this.store.dispatch(jn({text:p.text,suggestion:p,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.settings.inlineSuggestions||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let p=sa(this.state);if(!p)return;this.store.dispatch(jn({text:p.text,suggestion:p,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(qo({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(zo([]))}handlingTimeStart(){this.state.handlingTime.startTime||(ee.info("Start handling time"),this.store.dispatch(JA()))}handlingTimeStop(){this.state.handlingTime.startTime&&(ee.info("Stop handling time"),this.store.dispatch(Mm()))}logSendMessage(t){let n=dI("input",this.state,{version:this.version});n&&(t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n))}logHandlingTime(){let t=cI(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(eI()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(bi((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(AT()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(i){ee.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),ee.error(i)}})}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),()=>{this.off(t,n)}}off(t,n){if(!t&&!n){this.eventListeners={};return}let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}setConversationQuery(t){this.dynamicThunkObject.conversationQuery=t}setPlatformVariables(t){this.store.dispatch(FT(t))}whenConversationLoaded(t){let n=o=>{var i;return(i=o.conversation.current)==null?void 0:i.id},r=()=>this.loadProfileConfig().then(()=>t());n(this.state)&&r(),this.subscribe(n,o=>{o&&r()})}overlayContainerFactory(t,n,r,o){let[i,s]=vc(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,lt.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var a;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let i=(a=t.ownerDocument.defaultView)==null?void 0:a.frameElement,s=i?i.ownerDocument.defaultView:null;if(i&&(s===window||(s==null?void 0:s.parent)===window)){let[l,u]=vc(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{(0,lt.unmountComponentAtNode)(o),u()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return ji(o),o.dataset.testid=t,o.style.color=r.color,o.style.fontSize=r.fontSize,o.style.fontFamily=r.fontFamily,o.style.fontVariant=r.fontVariant,o.setAttribute("translate","no"),n.appendChild(o),this.unmountHandlers.push(()=>{(0,lt.unmountComponentAtNode)(o),o.remove()}),o}storeMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(t,n),ee.info(`Stored analytics for ${this.conversationId()}`)}catch(t){}}restoreMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(t);if(!n)return;let r=JSON.parse(n);r.text.trim()===this.state.input.text.trim()?(ee.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(PT(r.metrics))):ee.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch(t){}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!_m(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let d=n,{customStyles:r,closestScrollSelector:o,floatingMenuParent:i,appendOverlayTo:s,inputMediator:a}=d,l=se(d,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),u={customStyles:r,closestScrollSelector:o,floatingMenuParent:i,appendOverlayTo:s};this.configure(l),this.settings.automaticHandlingTime&&this.setupHandlingTime(t),ji(t),this.inputMediator=a||(Zi(t)?new ts(t):new es(t)),this.inputMediator.on("change",({plainText:p,rawHTML:y})=>{this.store.dispatch(jf({text:p,html:y}))}),this.inputMediator.on("keyup",p=>{this.store.dispatch(TT(iv(p)))}),this.inputMediator.on("keydown",p=>{this.handleKeyDown(p)}),this.inputMediator.on("paste",({pastedText:p,selectionText:y})=>{this.store.dispatch(CT({text:p,selectionText:y}))}),this.inputMediator.on("cut",({selectionText:p})=>{this.store.dispatch(bT(p))});let c;this.inputMediator.on("selection",p=>{clearTimeout(c),p===null?c=setTimeout(()=>{p!==null&&this.store.dispatch(Vf(p))},500):this.store.dispatch(Vf(p))}),this.inputMediator.on("disabled",()=>{var p;(p=this.inputMediator)==null||p.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{this.settings.detectSubmit&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(im(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(im(!0))}),this.renderSuggestions(t,u),this.subscribe(ru("inlineSuggestions"),()=>{this.renderSuggestions(t,u)});let f=this.renderOverlays(n);this.unmountHandlers.push(()=>{f.unmount()}),this.store.dispatch(jf({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(Vf(this.inputMediator.getSelection())),this.store.dispatch(im(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{var p;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((p=this.state.conversation.current)==null?void 0:p.sessionId)}),this.isMounted=!0}subscribe(t,n){let r=t(this.store.getState());return this.store.subscribe(()=>{let o=t(this.store.getState());o!==r&&(r=o,n(r))})}unmount(){var t,n,r,o;(t=this.inlineSuggestions)==null||t.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(r=this.floatingMenu)==null||r.unmount(),this.unmountHandlers.forEach(i=>i()),this.unmountHandlers=[],(o=this.inputMediator)==null||o.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderSuggestions(t,n){var r,o,i;(r=this.floatingMenu)==null||r.unmount(),(o=this.inlineSuggestions)==null||o.unmount(),(i=this.aboveSuggestions)==null||i.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(t,n)),this.settings.inlineSuggestions?this.inlineSuggestions=this.renderInlineSuggestions(t,n):this.aboveSuggestions=this.renderAboveSuggestions(t,n)}renderInlineSuggestions(t,n){let{customStyles:r}=n,o=this.createInlineContainer(t,"deepdesk-caret");(0,lt.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(HP,{})})}),o);let i=s=>{s?(o.style.display="block",o.style.top=`${s.top}px`,o.style.left=`${s.left}px`):o.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var s;(0,lt.unmountComponentAtNode)(o),(s=this.inputMediator)==null||s.off("caretposition",i),o.remove()}}}renderAboveSuggestions(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:i}=n,s=o&&wx(t,o)||void 0,a=this.overlayContainerFactory("deepdesk-tab-completion",s||t,{appendTo:i,closestScrollElement:s,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),l=this.overlayContainerFactory("deepdesk-suggestions-overlay",s||t,{appendTo:i},r==null?void 0:r.suggestionsRootNode);return(0,lt.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(uA,{inputElement:t})})}),a),(0,lt.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(qP,{onLogIn:()=>this.loginViaPopup().catch(u=>ee.warn(u.message))})})}),l),{unmount(){(0,lt.unmountComponentAtNode)(a),(0,lt.unmountComponentAtNode)(l),a.remove(),l.remove()}}}renderFloatingMenu(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:i,floatingMenuParent:s}=n,a=o&&wx(t,o)||void 0,l=this.overlayContainerFactory("floating-menu",a||t,{appendTo:s!=null?s:i},r==null?void 0:r.floatingMenuParent);return(0,lt.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(kP,{onLogIn:()=>this.loginViaPopup().catch(u=>ee.warn(u.message))})})}),l),{unmount(){(0,lt.unmountComponentAtNode)(l),l.remove()}}}renderOverlays(t){let{customStyles:n}=t,r=this.createContainer("deepdesk-overlays");return(0,lt.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:n,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(SP,{})})}),r),{unmount(){(0,lt.unmountComponentAtNode)(r),r.remove()}}}renderWidget(t,n={}){if(this.widgetRoot&&ee.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,isEmbedded:i}=n;this.widgetRoot=t,this.configure({showImages:o,isEmbedded:i}),(0,lt.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(jA,{knowledgeAssistOptions:n.knowledgeAssist,onLogIn:()=>this.loginViaPopup().catch(s=>ee.warn(s.message))})})}),t),this.whenConversationLoaded(()=>{var s;this.broadcastEvents.setSessionId((s=this.state.conversation.current)==null?void 0:s.sessionId)})}unmountWidget(){this.widgetRoot&&(0,lt.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}renderKnowledgeAssistantWidget(t,n,r={}){let{customStyles:o,initialQuestion:i}=r;return(0,lt.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:o,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(dx,{children:(0,Me.jsxs)(km,{assistantCode:t,initialQuestion:i,evaluateKnowledgeAssistFn:r.isLegacyKnowledgeAssist?Ci:ki,children:[(0,Me.jsx)(fs,{children:(0,Me.jsx)(Pm,{emptyState:r.emptyState})}),(0,Me.jsx)(cx,{children:(0,Me.jsx)(Rm,{})})]})})})}),n),{unmount(){(0,lt.unmountComponentAtNode)(n),n.remove()}}}setupHandlingTime(t){let n=Hm(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){fI(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>A(this,null,function*(){yield this.store.dispatch(Tu());let t=Ri(this.state);t&&this.store.dispatch(Mf({showSearch:t.search,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:!!t.summarizerAssistantNew||t.summarizer,showKnowledgeSearch:!!t.knowledgeAssistantNew||!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions}))})),this.loadProfileConfigPromise)}loginViaPopup(t){return A(this,null,function*(){return new Promise((n,r)=>{let o=new MessageChannel,i=o.port1,s=this.settings.adminUrl,a=new URL(t!=null&&t.url?t==null?void 0:t.url:`${s}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,u=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",f),clearInterval(d)};i.onmessage=p=>A(this,null,function*(){var y,h;if((y=p.data)!=null&&y.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((h=p.data)==null?void 0:h.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(lu),l=!0,o.port1.close(),n()}catch(g){console.error(g),r(g)}finally{l=!0,u()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&r(new Error("Popup blocked by browser"));let f=p=>A(this,null,function*(){var y;if(p.origin===a.origin)switch((y=p.data)==null?void 0:y.type){case"deepdesk-popup-loaded":{try{let h=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(h,a.origin,[o.port2])}catch(h){ee.error("Error posting message to popup",h),r(h)}break}case"deepdesk-popup-error":{u(),p.data.message==="Timeout"&&ee.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(p.data.message));break}}});window.addEventListener("message",f);let d=setInterval(()=>{c&&!c.closed||(u(),l||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(u)})})}translateMessages(t){return this.deepdeskApi.translateMessages(t)}checkForTrialMode(t){return A(this,null,function*(){try{let{account:n}=yield this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(ee.info("Trial is active"),!(yield this.deepdeskApi.checkUserExists(t)))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:r}=n;ee.info(r),this.shouldRender=!1}})}refreshWidgetSuggestions(){return A(this,null,function*(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=Cu(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(Zn()):Hc.includes(r)||this.store.dispatch(rr(r))})}catch(r){this.handleError(r)}})}};Va.version="16.0.2-beta.2",Va.count=0;var xc=Va;function a5(e){return A(this,null,function*(){var o,i,s;let n=yield((o=e.fetch)!=null?o:window.fetch)(e.url),r=yield n.blob();return new File([r],e.name,{type:(s=(i=e.mimeType)!=null?i:n.headers.get("Content-Type"))!=null?s:"image/jpeg"})})}function CI(e,t){return A(this,null,function*(){let n=yield a5(t),r=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(e,"files",{configurable:!0,get:()=>[n]}),e.dispatchEvent(r)}finally{Object.hasOwn(e,"files")&&delete e.files}})}function kI(e,t,n){return A(this,null,function*(){yield new lo(e).authenticateWithKey(t,n)})}function RI(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function PI(r,o){return A(this,arguments,function*(e,t,n={}){var f,d;let{value:i}=e,{start:s,end:a}=(f=n.replace)!=null?f:{start:0,end:i.length},l=`${i.slice(0,s)}${t}${i.slice(a)}`,u=(d=n.selectionAfter)!=null?d:{start:s+t.length,end:s+t.length},c=()=>{if(n.setValue)return n.setValue(l);e.value=l};return Promise.resolve(c()).then(()=>{e.selectionStart=u.start,e.selectionEnd=u.end,e.blur(),e.focus()})})}function AI(r,o){return A(this,arguments,function*(e,t,n={}){let i=n.replace?Zo(e,n.replace.start,n.replace.end):za(e),s,a=()=>{if(n.setRange)return n.setRange(i.cloneRange());i.deleteContents(),s=document.createElement("span"),i.insertNode(s),n.insertBRs!==!1?t.split(`
83
+ `);let y=d?r:0,h=p?Math.min(i,c.childNodes.length):c.childNodes.length;for(let g=y;g<h&&(u(c.childNodes[g]),a!==2);g++);break}default:break}p&&(a=2)}return u(e),l}var WA=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(WA||{}),ao=class{constructor(t){this.element=t;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(t,n){let r=o=>{n(o)};this.element.addEventListener(t,r),this.disposeHandlers.push(()=>{this.element.removeEventListener(t,r)})}removeEventListener(t,n){this.element.removeEventListener(t,n)}handleInteraction(){let t=this.getText(),n=this.getHTML(),r=this.getSelection(),o=this.cachedCaretPosition===null;if(!this.isActive||(t===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),t!==this.cachedText?(this.cachedText=t,this.cachedHTML=n,o=!0,this.emit("change",{plainText:t,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,o=!0,this.emit("change",{plainText:t,rawHTML:n})),(r.start!==this.cachedSelection.start||r.end!==this.cachedSelection.end)&&(this.cachedSelection=r,o=!0,this.emit("selection",r)),!o))return;let i=this.getCaretPosition();Ho(i,this.cachedCaretPosition)||(this.cachedCaretPosition=i,this.emit("caretposition",i))}handleClick(){this.handleInteraction()}handleFocus(){let t=!this.isFocused;this.isFocused=!0,t&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let t=this.isFocused;this.isFocused=!1,t&&this.emit("blur")}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(WA).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleKeyUp(t){this.handleInteraction(),this.emit("keyup",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),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.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let t=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{t.disconnect()})}focus(){this.element.focus()}emit(t,...n){this.isDisposed||this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r(...n)})}on(t,n){this.isDisposed||(this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n))}off(t,n){if(!this.eventListeners[t])return;let r=this.eventListeners[t].indexOf(n);r!==-1&&this.eventListeners[t].splice(r,1)}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};function KA(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var es=class extends ao{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),yc(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){var s;let n=this.getRootNode();if(n.activeElement!==this.element)return null;let r="getSelection"in n?n.getSelection():window.getSelection();if(!r)return null;let o="getComposedRanges"in r&&n instanceof ShadowRoot?(s=r.getComposedRanges(n))==null?void 0:s[0]:r.rangeCount>0?r.getRangeAt(0):null;if(!o)return null;let i=this.element.ownerDocument.createRange();return i.setStart(o==null?void 0:o.startContainer,o==null?void 0:o.startOffset),i.setEnd(o==null?void 0:o.endContainer,o==null?void 0:o.endOffset),!i||!this.element.contains(i.startContainer)||!this.element.contains(i.endContainer)?null:i}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let r=n.getBoundingClientRect();return!KA(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!KA(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return hc(this.element,n);let r=this.lastKnownSelection;if(r&&VA(this.element,r.start,r.end))return r;let o=za(this.element);return o.collapse(!1),hc(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return yc(this.element,Zo(this.element,n,r))}listen(){super.listen();let n=new MutationObserver(i=>{var s,a;i.length===2&&i[0].addedNodes.length===1&&((s=i[0].addedNodes[0])==null?void 0:s.textContent)==="\u2060"&&((a=i[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let r=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==r&&(r=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}};var $F=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize"];function $A(e,t){let n="mozInnerScreenX"in window,r=document.createElement("div");r.id="input-textarea-caret-position-mirror-div";let o=r.style,i=window.getComputedStyle(e),s=e.ownerDocument.body;o.whiteSpace="pre-wrap",o.wordWrap="break-word",o.position="absolute",o.visibility="hidden",$F.forEach(c=>{o[c]=i[c]}),n?e.scrollHeight>Number.parseInt(i.height)&&(o.overflowY="scroll"):o.overflow="hidden",r.textContent=e.value.substring(0,t);let a=document.createElement("span");a.textContent=e.value.substring(t)||".",r.appendChild(a),s.appendChild(r);let l=e.getBoundingClientRect(),u={top:l.top-e.scrollTop+a.offsetTop+Number.parseInt(i.borderTopWidth)+a.offsetHeight,left:l.left-e.scrollLeft+a.offsetLeft+Number.parseInt(i.borderLeftWidth)};return s.removeChild(r),u}var ts=class extends ao{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:r}=this.element;return{start:n,end:r}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return $A(this.element,this.element.selectionEnd)}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var i;return(i=n==null?void 0:n.get)==null?void 0:i.call(this.element)},set:i=>{var s;(s=n==null?void 0:n.set)==null||s.call(this.element,i),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let r=this.element.disabled,o=new MutationObserver(()=>{this.element.disabled!==r&&(r=this.element.disabled,this.emit(r?"disabled":"enabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>o.disconnect())}};function qA(e,t,n){let r=`deepdesk-iframe-${e}`,o=document.getElementById(r);if(o)return o;let i=document.createElement("iframe"),s=new URL(t);return Object.entries(n).forEach(([a,l])=>{s.searchParams.append(a,l)}),i.style.position="absolute",i.style.left="-999em",i.style.width="0px",i.style.height="0px",i.tabIndex=-1,i.id=r,i.title=`iframe-${e}`,i.src=s.toString(),window.document.body.appendChild(i),i}function qF(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var fx=class{constructor(t){this.name=t;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(t)}onMessage(t){this.broadcastChannel.addEventListener("message",t),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",t)})}postMessage(t){this.broadcastChannel.postMessage(JSON.stringify(t))}close(){this.disposeHandlers.forEach(t=>t()),this.broadcastChannel.close()}},px=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=qA(t,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(t){window.addEventListener("message",t),this.disposeHandlers.push(()=>{window.removeEventListener("message",t)})}postMessage(t){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(t),this.targetOrigin)}close(){var t;this.disposeHandlers.forEach(n=>n()),(t=this.iframe)==null||t.remove()}},mx=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.externalId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setExternalId(t){this.externalId!==t&&(this.cleanup(),ee.info("Set externalId",t),this.externalId=t,this.channel=this.createChannel(t))}createChannel(t){let n=this.params.createCustomChannel?this.params.createCustomChannel(t):this.isCrossOrigin?new px(t,this.deepdeskUrl,{debug:!0}):new fx(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=qF(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(ee.info("Received broadcast event",this.externalId,o),(a=(s=this.eventMap)[i.name])==null||a.call(s,i.payload))};return n.onMessage(r),n}send(t,n,r){var s,a;ee.info("Broadcast event",{externalId:this.externalId,name:t,payload:n});let o={type:"event",name:t,payload:n};r!==!1&&((a=(s=this.eventMap)[t])==null||a.call(s,n));let i=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;i==null||i.postMessage(P(b({},o),{channel:this.externalId}))}cleanup(t=!1){var n,r;(n=this.channel)==null||n.close(),this.channel=void 0,t&&((r=this.defaultChannel)==null||r.close(),this.defaultChannel=void 0)}},GA=mx;function GF(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function $e(e){return Array.isArray(e)?e.map($e):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>P(b({},t),{[GF(n)]:$e(e[n])}),{}):e}function YF(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function wt(e){return Array.isArray(e)?e.map(wt):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>P(b({},t),{[YF(n)]:wt(e[n])}),{}):e}var Ba=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var gx=e=>new Promise(t=>{setTimeout(t,e)});var Ua=class extends Ba{constructor(){super(...arguments);this.name="ClientError"}},yx=class extends Ba{constructor(){super(...arguments);this.name="ServerError"}},hx=new Map;function XF(e){return A(this,null,function*(){if(e.status===204)return e.text().catch(()=>{}),null;let t=e.headers.get("content-type");if(t!=null&&t.includes("application/json"))return e.json();let n=yield e.text();return n===""?null:(ee.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var Jo=class Jo{constructor(t="",n={}){this.baseUrl=t;this.options=n;this.latestRequestByUrl={};this.fetch=window.fetch.bind(window);n.fetch&&(this.fetch=n.fetch)}patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let i={isAborted:!1,reject:o},s=`${this.baseUrl}${t}`,a=this.fetch,l=n.method===void 0||n.method.toLowerCase()==="get",E=n,{useCache:u=!1,abortLatest:c=!1,attempts:f=1,retryDelay:d=500,refreshTokenOn401:p=!0,retryOnError:y=k=>k instanceof TypeError,retryOnResponse:h=k=>k.status>=500,version:g=null}=E,m=se(E,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(u){if(!l)throw new Error(`Can't use 'useCache' for ${n.method}`);if(hx.has(s)){r(hx.get(s));return}}let v=P(b({credentials:"include"},m),{headers:b({Accept:"application/json","Content-Type":"application/json"},m.headers)});!l&&this.csrfToken&&(v.headers=P(b({},v.headers),{"X-CSRFToken":this.csrfToken})),typeof g=="string"&&(v.headers=P(b({},v.headers),{"X-Deepdesk-API-Version":g}));let x=f,w=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&c&&(this.latestRequestByUrl[s].isAborted=!0,this.latestRequestByUrl[s].reject(new Error("Aborted"))),this.latestRequestByUrl[s]=i;let C=()=>A(this,null,function*(){return x--,a(s,v).then(k=>A(this,null,function*(){return h(k)&&!i.isAborted&&x>0?(yield gx(d),C()):k.status===401&&p===!0&&w===!1?(w=!0,yield this.refreshToken(),C()):k})).catch(k=>A(this,null,function*(){if(y(k)&&!i.isAborted&&x>0)return yield gx(d),C();throw k}))});C().then(k=>A(this,null,function*(){let I=yield XF(k);if(delete this.latestRequestByUrl[s],k.status>=500){o(new yx("Server Error",I));return}if(k.status===401){o(new Ua("Unauthorized",I));return}if(k.status===403){o(new Ua("Forbidden",I));return}if(k.status===404){o(new Ua("Not Found",I));return}if(k.status>=400){o(new Ua("Bad Request",I));return}u&&hx.set(s,I),r(I)})).catch(k=>{o(k)})})}validateToken(){return A(this,null,function*(){let{has_valid_access_token:t}=yield this.get("/auth/validate");if(!t)try{yield this.refreshToken()}catch(r){return!1}let{is_logged_in:n}=yield this.get("/apis/admin/session/validate/");return!!n})}refreshToken(){return Jo.refreshingToken||(Jo.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{Jo.refreshingToken=null},1e3*60)})),Jo.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,b({method:"POST",body:JSON.stringify(n)},r))}patch(t,n,r){return this.request(t,b({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,b({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,b({method:"DELETE"},n))}};Jo.refreshingToken=null;var ns=Jo;var YA;(t=>{let e;(s=>(s.SEND_MESSAGE="Send Message",s.HANDLING_TIME="Handling Time",s.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",s.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(e=t.EventType||(t.EventType={}))})(YA||(YA={}));function Om(e){return P(b({},$e(e)),{metadata:e.metadata})}var rs=class rs{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new ns(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,i)=>A(this,null,function*(){let s=yield r(o,i);return this.handleDeepdeskVersionHeaders(s),s}))}preflight(){return A(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(rs.exchangeTokenPromise||(rs.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),rs.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return A(this,null,function*(){var r;yield this.preflight(),ee.info(`Creating conversation for session ${t.externalId} and agent ${t.agentId}`);let n=yield this.client.post("/api/v2/conversations",P(b({chat_start_time:new Date().toISOString()},wt(t)),{metadata:(r=t.metadata)!=null?r:{}}));return Om(n)})}getMe(){return A(this,null,function*(){let t=yield this.client.get("/apis/admin/session/me/");return $e(t)})}postIdentity(t){return A(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",wt(t))})}patchMe(t){return A(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",wt(t));return $e(n)})}getProfile(t){return A(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{useCache:!0});return $e(n)})}getKnowledgeAssistant(t){return A(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{useCache:!0});return $e(n)})}getContentTypes(){return A(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return $e(t)})}getAccount(){return A(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{useCache:!0});return $e(t)})}getPlatformConfig(t){return A(this,null,function*(){let n=t!==void 0?`/platform/config/${t}/`:"/platform/config/",{config:r}=yield this.client.get(n,{useCache:!0});return $e(r)})}checkUserExists(t){return A(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`,{version:"v1"});return n})}getConversationByExternalId(r){return A(this,arguments,function*(t,n={}){yield this.preflight(),ee.info(`Getting conversation for session ${t}`);let{attempts:o=1,retryDelay:i=1e3}=n,s=yield this.client.get(`/api/v2/conversations?external_id=${t}`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return ee.info(`Successfully retrieved conversation ${s.id} for session ${t}`),Om(s)})}isConversationSupported(r){return A(this,arguments,function*(t,n={}){ee.info(`Check if conversation for session ${t} is supported`);let{attempts:o=1,retryDelay:i=1e3}=n;return(yield this.client.get(`/api/v2/conversations/active_profile?external_id=${t}`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500})).has_active_profile})}updateConversation(t,n){return A(this,null,function*(){var i;yield this.preflight();let r=wt(n);n.metadata&&(r.metadata=(i=n.metadata)!=null?i:{});let o=yield this.client.put(`/api/v2/conversations/${t}`,r);return Om(o)})}postMessages(t,n){return A(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${t}/messages`,n.map(o=>P(b({},wt(o)),{metadata:o.metadata})))).map(o=>Om(o))})}sendEvent(t,n){return A(this,null,function*(){yield this.preflight();let s=n,{data:r}=s,o=se(s,["data"]),i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((a,[l,u])=>P(b({},a),{[l]:u}),{});return this.client.post("/api/events",wt(P(b(b({},i),o),{data:r,name:t})),{version:"v2"})})}sendEventV1(t,n){return A(this,null,function*(){yield this.preflight();let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>P(b({},o),{[i]:s}),{});return this.client.post("/api/events",{event:t,data:wt(b(b({},n),r))},{version:"v1"})})}getEntities(t){return A(this,null,function*(){return yield this.preflight(),(yield this.client.post("/api/entities",{messages:t.filter(r=>r.text)},{version:"v1"})).entities})}getTemporaryExchangeToken(){return A(this,null,function*(){return(yield this.client.get("/auth/exchange-token")).jwt})}exchangeTokenForAccessCookie(t){return A(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t}).catch(n=>{throw ee.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return A(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",wt(n),{refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return A(this,arguments,function*(t,n={},r){if(yield this.preflight(),r==="sticky-messages")throw new Error("Use getPinnedMessages instead");return(yield this.client.post(`/api/v2/conversations/${t}/recommend/${r}`,wt(n),{abortLatest:!0})).map(s=>P(b({},$e(s)),{text:s.text||s.url||s.message,source:r,type:r})).filter((s,a,l)=>a===l.findIndex(u=>u.text===s.text))})}isLoggedIn(){return A(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return A(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${t}/autocomplete`,wt(n),{abortLatest:!0})).map(o=>({score:1,source:o.source,sourceText:o.source_text,text:o.label,trainingJobs:o.training_jobs,searchKeywords:o.search_keywords,type:o.source})).filter((o,i,s)=>i===s.findIndex(a=>a.text===o.text))})}getPinnedMessages(t){return A(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${t}/pinned-messages`,{abortLatest:!0});return $e(n).map(r=>P(b({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return A(this,null,function*(){let n=yield this.client.post("/api/style-suggestions",wt(t),{abortLatest:!0,version:"v1"});return $e(n)})}search(t){return A(this,null,function*(){let n=yield this.client.post(`/api/profiles/${t.profile}/search`,wt(t),{version:"v2"});return $e(n)})}knowledgeAssist(i,s,a){return A(this,arguments,function*(t,n,r,o={}){yield this.preflight();let l=yield this.client.post(`/api/knowledge-assist/assistants/${r}/search`,wt({question:t.question,doNotKnowAnswer:t.doNotKnowAnswer,customerInstruction:t.customerInstruction,chatHistory:n.map(u=>({question:u.question,answer:u.answer.answer})),agentId:o.agentId,conversationId:o.conversationId}),{version:"v2"});return $e(l)})}requestLoginByEmail(t){return A(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t});return $e(n)})}requestPasswordlessToken(){return A(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/");return $e(t.token)})}getCsrfToken(){return A(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/");return t})}verifyLoginToken(t){return A(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t});return $e(n)})}getSummary(r){return A(this,arguments,function*(t,n={}){yield this.preflight();let o=yield this.client.post("/api/summary",{conversation:{messages:t.filter(i=>i.text&&i.source),agent_id:n.agentId,id:n.externalConversationId},prompt_instruction:n.promptInstruction,model:n.model},{version:"v1"});return $e(o)})}evaluateAssistant(t,n){return A(this,null,function*(){var a;yield this.preflight();let r=new URLSearchParams,{expectFormat:o="text"}=n||{};if(o.startsWith("json-schema:")){let l=o.replace("json-schema:","");r.append("expect_response_format","json-schema"),r.append("expect_response_format_schema",l)}else r.append("expect_response_format",o);n!=null&&n.externalConversationId&&r.append("external_conversation_id",n.externalConversationId);let i=n!=null&&n.threadId?`/api/v2/assistants/${t}/threads/${n==null?void 0:n.threadId}/evaluate?${r.toString()}`:`/api/v2/assistants/${t}/evaluate?${r.toString()}`,s=yield this.client.post(i,{input:(a=n==null?void 0:n.input)!=null?a:{},conversation:n==null?void 0:n.transcript});return $e(s.output)})}createAssistantThread(t){return A(this,null,function*(){yield this.preflight();let{assistantCode:n}=t,r=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return $e(r)})}postMessageToAssistantThread(t){return A(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:r,message:o}=t,i=yield this.client.post(`/apis/admin/assistants/${n}/threads/${r}/messages/`,{content:o,role:"user"});return $e(i)})}translateMessages(t){return A(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/translate",wt(t),{version:"v2"});return $e(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(_w);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&ee.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};rs.exchangeTokenPromise=null;var lo=rs;var XA={startTime:null,stopTime:null},QA=e=>e.handlingTime,ZA=Ce({name:"handlingTime",initialState:XA,reducers:{handlingTimeStart(e){if(e.startTime&&!e.stopTime)throw new Error("Timing already started");e.startTime=new Date,e.stopTime=null},handlingTimeStop(e){if(!e.startTime)throw new Error("Timing not started");e.stopTime=new Date},handlingTimeReset(e){e.startTime=null,e.stopTime=null}},extraReducers:e=>{e.addCase(it,()=>XA)}}),{handlingTimeStart:JA,handlingTimeStop:Mm,handlingTimeReset:eI}=ZA.actions,tI=ZA.reducer;var nI=(e={})=>{let t=b({onAuthError:ra(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var Nm={list:{keywordMatches:[]},fetchState:"idle"};var os=ge("styleSuggestions/getAll",(n,r)=>A(void 0,[n,r],function*({text:e},t){var l;let{deepdeskAPI:o}=t.extra,i=t.getState(),{showStyleSuggestions:s}=i.settings,a=(l=i.conversation.current)==null?void 0:l.profileCode;if(!s)return Nm.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),QF=Ce({name:"styleSuggestions",initialState:Nm,reducers:{},extraReducers:e=>{e.addCase(os.pending,t=>{t.fetchState="loading"}).addCase(os.rejected,t=>{t.fetchState="error"}).addCase(os.fulfilled,(t,n)=>{t.fetchState="done",Ho(t.list,n.payload)||(t.list=n.payload)}).addCase(bi,t=>{t.list=Nm.list}).addCase(it,()=>Nm)}}),rI=QF.reducer;var oI=(e={})=>{let t,n=!0,r=b({getStyleSuggestions:os,debounce:500},e);return o=>i=>s=>{var p;let a=o.getState().input.text,l=i(s),u=o.getState();if(u.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:c}=u.settings;if(!((p=u.conversation.current)==null?void 0:p.id)||!c)return l;let{text:d}=u.input;return d===a&&!n||(clearTimeout(t),d==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:d}))},e.debounce)),l}};function ZF(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var iI=(e={})=>{let t=b({getTextSuggestions:rr,getAutocompleteSuggestions:ic,debounce:200,check:Tr},e),n;return r=>o=>i=>{var h;let{input:s}=r.getState(),a=o(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:u,showTabCompletion:c}=l.settings,f=(h=l.conversation.current)==null?void 0:h.id,d=i.type===nm.toString();if(!f||!u&&!c)return a;let{input:p}=l;return ZF(p,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let g=ia(l);g===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(g))},d?0:t.debounce)),a}};var sI=os.fulfilled.toString();function JF(e,t){let n=new Set([...t.keywordMatches.map(o=>o.keyword)]),r=[];return n.forEach(o=>{let i=e.keywordMatches.filter(l=>l.keyword===o),s=t.keywordMatches.filter(l=>l.keyword===o),a=s.length-i.length;a<=0||r.push(...s.slice(0,a))}),r}var aI=e=>t=>n=>r=>{var u;if(r.type!==sI){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let i=t.getState(),s=i.styleSuggestions.list,a=(u=i.conversation)==null?void 0:u.current;if(o===s)return;let l=JF(o,s);r.type===sI&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var e5=nf({assistants:hC,auth:aT,conversation:vT,contentTypes:vC,passwordlessToken:fA,entities:mR,handlingTime:tI,info:HT,input:IT,settings:eT,profile:bC,search:WT,styleSuggestions:rI,ui:IP,textSuggestions:gP});function lI(e){return sE({reducer:e5,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI}},serializableCheck:!1}),nI(),iI({debounce:200}),oI({debounce:500}),aI(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var t5=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},n5=e=>t=>n=>r=>{var a,l,u,c,f,d;let o=t.getState(),i=ru("inlineSuggestions")(o);switch(r.type){case ra.toString():{!r.payload&&e.emit("logout",void 0);break}case Zn.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:(a=o.conversation.current)==null?void 0:a.id,data:{entities:r.payload}});break;case Wr.toString():e.sendEvent(r.payload.name,{conversationId:((l=r.payload.options)==null?void 0:l.includeConversationData)&&((u=o.conversation.current)==null?void 0:u.id),data:r.payload.data});break;case bi.toString():e.logSendMessage(r.payload);break;case rp.toString():e.emit("call-to-action",{cue:r.payload});break;case Kn.fulfilled.toString():r.isBroadcasted||e.broadcast(uv,r,!1);break;default:break}let s=n(r);switch(r.type){case bi.toString():e.handleAfterSendMessage(r.payload);break;case ac.toString():e.onUpdateShowTabHint(r.payload);break;case Mm.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case zf.toString():{let{start:p,end:y}=o.input.selection;e.emit("replace",P(b({},r.payload),{replace:r.payload.replace==="selection"?{start:p,end:y}:{start:0,end:y}}));break}case jn.toString():{let{start:p,end:y}=o.input.selection;e.emit("select-suggestion",P(b({type:t5(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:p,end:y}:{start:0,end:y}})),i&&t.dispatch(zo([]));break}case Bf.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(c=o.conversation.current)==null?void 0:c.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case zo.toString():{i&&r.payload.length>0&&t.dispatch(Uf(0));break}case Wn.fulfilled.toString():{e.sendEvent("conversation summarized",{conversationId:(f=o.conversation.current)==null?void 0:f.id,data:{summary:r.payload,assistant:(d=t.getState().profile.data)==null?void 0:d.summarizerAssistantNew}}),e.emit("summary-generated",{summary:r.payload});break}default:break}return s},uI=n5;function vx(e){return e.toISOString().replace("T"," ").replace("Z","")}var r5=(e,t)=>t.version,cI=Un([aa,yr,QA,r5],(e,t,n,r)=>{if(!t)return ee.warn("No conversationId for handling time metrics"),null;let{startTime:o,stopTime:i}=n;return!o||!i?(ee.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:t,clientVersion:r,agentId:e==null?void 0:e.agentId,agentName:e==null?void 0:e.agentName,agentEmail:e==null?void 0:e.agentEmail,timeStart:vx(o),timeStop:vx(i)}});function dI(e,t,n){var I,L,G,D;let r=(I=t.conversation.current)==null?void 0:I.id;if(!r)return ee.warn("No conversationId for send message metrics"),null;let{text:o,metrics:{numCharsTyped:i,numCharsPasted:s,numCharsCut:a,numCharsDeleted:l,numPaste:u,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:f,pastes:d,cuts:p,deletions:y,textSuggestions:h,offeredTextSuggestions:g}}=t[e],m=o.length,x=h.reduce((j,{text:M,searchTerm:_})=>j+M.length-(_?_.length:0),0),w=c!=null?c:Date.now(),C=(Date.now()-w)/1e3+(f||0),E=i/C,k=h.reduce((j,{searchTerm:M})=>j+(M?M.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:d,cuts:p,deletions:y,lenTextTyped:i+k,lenTextTotal:m,lenTextAssisted:x,lenTextPasted:s,lenTextCut:a,lenTextDeleted:l,timeTotalSeconds:C,charsPerSecond:E,numPastes:u,textSuggestionsV2:h,suggestionsCounters:[{source:"gpt",countOffered:g.filter(j=>j.source==="gpt").length}],agentId:(L=t.info.agentInfo)==null?void 0:L.agentId,agentName:(G=t.info.agentInfo)==null?void 0:G.agentName,agentEmail:(D=t.info.agentInfo)==null?void 0:D.agentEmail}}function xx(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return xx(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?xx(o,t):null}function wx(e,t){return xx(e,t)}function fI(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function o5(e){return typeof e=="object"&&e!==null&&"tagName"in e}function _m(e){return o5(e)&&(Zi(e)||cm(e))}var mI,Rr=new Map,i5=["bottom","height","left","right","top","width"],pI=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:i5.some(n=>e[n]!==t[n]);function gI(e){var n,r,o;if(e.ownerDocument===document)return[];let t=(o=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)!=null?o:null;return t?[t,...gI(t)]:[]}function hI(e,t){return!e||!t?null:P(b({},e),{top:e.top+t.top,left:e.left+t.left})}var Dm=!1,yI=()=>{Dm=!0;let e=[];if(Rr.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Rr.delete(n);return}let r=n.getBoundingClientRect();pI(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(hI,t.rect):t.rect;pI(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Rr.size===0){Dm=!1;return}mI=window.requestAnimationFrame(yI)};function Sx(e,t){let n=gI(e),r=[],o=n.map((i,s)=>Sx(i,a=>{r[s]=a;let l=Rr.get(e);if(!l)return;let u=r.reduce(hI,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),Rr.has(e)){let s=Rr.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else Rr.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Dm&&yI()},unobserve(){o.forEach(s=>s.unobserve());let i=Rr.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||Rr.delete(e),Rr.size||(cancelAnimationFrame(mI),Dm=!1)}}}}var vI,Pr=new Map,xI=()=>{Pr.forEach((e,t)=>{if(!t.isConnected){Pr.delete(t);return}let{clientHeight:n,scrollHeight:r}=t,o=r>n;e.visible!==o&&(e.visible=o,e.callbacks.forEach(i=>i(e.visible)))}),Pr.size!==0&&(vI=window.requestAnimationFrame(xI))};function wI(e,t){return{observe(){let n=Pr.size===0;Pr.has(e)?Pr.get(e).callbacks.push(t):Pr.set(e,{visible:void 0,callbacks:[t]}),n&&xI()},unobserve(){let n=Pr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Pr.delete(e),Pr.size||cancelAnimationFrame(vI)}}}}var bx=["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 Ex(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function ja(e){return Number.parseFloat(e)}function Fm(e){return Math.round(e*1e6)}function SI(e){return e/1e6}function Tx(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=ja(e.width),i=ja(e.borderLeftWidth),s=ja(e.borderRightWidth),a=ja(e.paddingRight),l=SI(Fm(o)-Fm(i)-Fm(s)),u=SI(Fm(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function vc(e,t={}){var c,f;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(c=t.position)!=null?c:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",ji(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};Ex(r,n,bx),Tx(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=wI(e,()=>{Ex(r,n,bx),Tx(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=Sx(e,d=>{if(d===null){t.onRemove&&t.onRemove(),n.remove();return}if(!l&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(Ex(r,n,bx),Tx(r,e,n),i(),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let p=t.closestScrollElement.getBoundingClientRect(),y=window.getComputedStyle(t.closestScrollElement),h=ja(y.borderTopWidth),g=ja(y.borderBottomWidth),m=p.top+h-d.top,v=d.top+d.height+-(p.top+p.height-g);n.style.clipPath=`inset(${m}px 0px ${v}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(f=e.parentElement)==null||f.appendChild(n),u.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),u.unobserve(),s.unobserve()}]}var bI=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch(r){return t}}catch(n){return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch(r){ee.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function s5(e){return e.offsetParent!==null}function EI(e){if(!s5(e))return!1;let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}function Hm(e,t,n=100){let r=EI(e);t({isVisible:r});let o=setInterval(()=>{let i=EI(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var Me=S(R());var TI=bI("showTabHint",!0),Va=class Va{constructor({deepdeskUrl:t,version:n=Va.version||"unknown",locale:r="en-US",token:o,fetch:i,productName:s,createCustomChannel:a}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.inlineSuggestions=null;this.aboveSuggestions=null;this.floatingMenu=null;this.widgetRoot=null;this.dynamicThunkObject={};this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let l=t.replace(/\/api$/,"");this.deepdeskApi=new lo(l,{token:o,fetch:i}),this.version=n,this.instanceId=Va.count++;let u={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[uI({broadcast:(c,f,d)=>{this.broadcastEvents.send(c,f,d)},emit:(c,f)=>this.emit(c,f),handleAfterSendMessage:c=>this.handleAfterSendMessage(c),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:c=>this.logSendMessage(c),onUpdateShowTabHint:c=>TI.update(c),sendEvent:(c,f)=>this.deepdeskApi.sendEvent(c,f)})]};this.store=lI(u),this.broadcastEvents=new GA({debug:!0,deepdeskUrl:l,eventMap:KT(this.store),createCustomChannel:a}),this.store.dispatch(ac(TI.value())),this.store.dispatch(Mf({locale:r,adminUrl:l,productName:s}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var t;return(t=this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex])!=null?t:null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}externalId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.externalId}shouldAbort(){return this.state.conversation.isSupported===!1?(ee.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(ee.warn("Profile has not been loaded (yet)"),!0):(ee.warn("No conversation loaded (yet)"),!0)}login(){this.store.dispatch(ra(null)),this.store.dispatch(jr());let t=n=>zt(n)&&tT(n)!=="loading";return new Promise(n=>{let r=this.subscribe(t,o=>{o&&(r(),n())});this.unmountHandlers.push(()=>{r()})})}isLoggedIn(){return A(this,null,function*(){return(yield this.store.dispatch(jr())).payload})}isConversationSupported(t,n){return A(this,null,function*(){return(yield this.store.dispatch(rv({externalId:t,options:n}))).payload})}createConversation(t){return A(this,null,function*(){var r;return this.hasConversation()&&this.externalId()!==t.externalId&&this.resetConversation(),(yield this.store.dispatch(_f(P(b({},t),{metadata:(r=t.metadata)!=null?r:{}})))).payload})}getConversationByExternalId(t,n){return A(this,null,function*(){return this.hasConversation()&&this.externalId()!==t&&this.resetConversation(),(yield this.store.dispatch(Df({externalId:t,options:n}))).payload})}upsertConversation(t){return A(this,null,function*(){var r;return this.hasConversation()&&this.externalId()!==t.externalId&&this.resetConversation(),(yield this.store.dispatch(ov(P(b({},t),{metadata:(r=t.metadata)!=null?r:{}})))).payload})}postMessages(t){return A(this,null,function*(){return(yield this.store.dispatch(Hf(t))).payload})}updateConversation(t){return A(this,null,function*(){return(yield this.store.dispatch(Ff(t))).payload})}resetConversation(){this.store.dispatch(it()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(t){this.store.dispatch(Mf(t))}setVisitorInfo(t){this.store.dispatch(_T(t))}setCustomData(t){this.store.dispatch(DT(t))}setAgentInfo(t,n){return A(this,null,function*(){yield this.store.dispatch(su(b(b({},t),n)))})}setAgentSettings(t){return A(this,null,function*(){yield this.store.dispatch(sv(t))})}getAgentSettings(){return A(this,null,function*(){return(yield this.store.dispatch(av())).payload})}refresh(){return A(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(jf({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let t=[];return this.store.dispatch(nm()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}notifyExternalSuggestion(t){this.store.dispatch(jn(t))}evaluateAssistant(t,n){return A(this,null,function*(){let c=n||{},{input:r={},transcript:o,showCuesInWidget:i=!0,includeMetadata:s,expectFormat:a}=c,l=se(c,["input","transcript","showCuesInWidget","includeMetadata","expectFormat"]);Object.assign(r,l);let u=yield this.store.dispatch(Kn({assistantCode:t,expectFormat:a||"json-schema:cues",transcript:o,includeMetadata:s,input:r,skipState:!i}));if(u.error)throw new Error(u.error.message);return u.payload})}evaluateConversationAssistant(t,n){return A(this,null,function*(){yield this.loadProfileConfig();let r=this.state.profile.data;if(!r){ee.warn("Can't evaluate assistant when profile is not loaded yet.");return}let i=r[{accepted:"conversationAcceptedAssistant","new-message":"conversationNewMessageAssistant",ended:"conversationEndedAssistant"}[t]];if(!i){ee.warn(`No assistant set in profile for conversation event "${t}"`);return}yield this.evaluateAssistant(i,b({transcript:"stored-transcript",includeMetadata:!0},n))})}getSummary(){return A(this,null,function*(){var n;if(!this.hasConversation())return ee.warn("No conversation to create summary for."),null;(n=this.state.profile.data)!=null&&n.summarizerAssistantNew||ee.warn("No profile loaded yet, or no summarizer assistant set in profile");let t=yield this.store.dispatch(Wn({}));if(t.error)throw new Error(t.error.message);return t.payload})}handleKeyDown(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:i,selection:s}=this.state.input,{inlineSuggestions:a,showTextSuggestions:l}=this.settings,u=a?"below":"above",c=o.length>0;if(this.store.dispatch(ET(iv(t))),!Tr(this.state)||t.key!=="Tab"&&!l)return;let f=()=>{n||!c||s&&(t.shiftKey||(this.store.dispatch(kT()),t.preventDefault()))},d=()=>{n||!c||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(RT()),t.preventDefault()))};switch(t.key){case"ArrowUp":u==="below"?d():f();break;case"ArrowDown":{u==="below"?f():d();break}case"Escape":{n||(this.store.dispatch(Uf(-1)),this.store.dispatch(qo({collapse:!0})),this.store.dispatch(PP(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let p=sa(this.state);if(!p)return;this.store.dispatch(ac(!1)),this.store.dispatch(jn({text:p.text,suggestion:p,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let p=sa(this.state);if(!p)return;this.store.dispatch(jn({text:p.text,suggestion:p,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.settings.inlineSuggestions||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let p=sa(this.state);if(!p)return;this.store.dispatch(jn({text:p.text,suggestion:p,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(qo({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(zo([]))}handlingTimeStart(){this.state.handlingTime.startTime||(ee.info("Start handling time"),this.store.dispatch(JA()))}handlingTimeStop(){this.state.handlingTime.startTime&&(ee.info("Stop handling time"),this.store.dispatch(Mm()))}logSendMessage(t){let n=dI("input",this.state,{version:this.version});n&&(t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n))}logHandlingTime(){let t=cI(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(eI()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(bi((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(AT()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(i){ee.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),ee.error(i)}})}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),()=>{this.off(t,n)}}off(t,n){if(!t&&!n){this.eventListeners={};return}let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}setConversationQuery(t){this.dynamicThunkObject.conversationQuery=t}setPlatformVariables(t){this.store.dispatch(FT(t))}whenConversationLoaded(t){let n=o=>{var i;return(i=o.conversation.current)==null?void 0:i.id},r=()=>this.loadProfileConfig().then(()=>t());n(this.state)&&r(),this.subscribe(n,o=>{o&&r()})}overlayContainerFactory(t,n,r,o){let[i,s]=vc(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,lt.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var a;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let i=(a=t.ownerDocument.defaultView)==null?void 0:a.frameElement,s=i?i.ownerDocument.defaultView:null;if(i&&(s===window||(s==null?void 0:s.parent)===window)){let[l,u]=vc(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{(0,lt.unmountComponentAtNode)(o),u()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return ji(o),o.dataset.testid=t,o.style.color=r.color,o.style.fontSize=r.fontSize,o.style.fontFamily=r.fontFamily,o.style.fontVariant=r.fontVariant,o.setAttribute("translate","no"),n.appendChild(o),this.unmountHandlers.push(()=>{(0,lt.unmountComponentAtNode)(o),o.remove()}),o}storeMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(t,n),ee.info(`Stored analytics for ${this.conversationId()}`)}catch(t){}}restoreMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(t);if(!n)return;let r=JSON.parse(n);r.text.trim()===this.state.input.text.trim()?(ee.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(PT(r.metrics))):ee.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch(t){}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!_m(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let d=n,{customStyles:r,closestScrollSelector:o,floatingMenuParent:i,appendOverlayTo:s,inputMediator:a}=d,l=se(d,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),u={customStyles:r,closestScrollSelector:o,floatingMenuParent:i,appendOverlayTo:s};this.configure(l),this.settings.automaticHandlingTime&&this.setupHandlingTime(t),ji(t),this.inputMediator=a||(Zi(t)?new ts(t):new es(t)),this.inputMediator.on("change",({plainText:p,rawHTML:y})=>{this.store.dispatch(jf({text:p,html:y}))}),this.inputMediator.on("keyup",p=>{this.store.dispatch(TT(iv(p)))}),this.inputMediator.on("keydown",p=>{this.handleKeyDown(p)}),this.inputMediator.on("paste",({pastedText:p,selectionText:y})=>{this.store.dispatch(CT({text:p,selectionText:y}))}),this.inputMediator.on("cut",({selectionText:p})=>{this.store.dispatch(bT(p))});let c;this.inputMediator.on("selection",p=>{clearTimeout(c),p===null?c=setTimeout(()=>{p!==null&&this.store.dispatch(Vf(p))},500):this.store.dispatch(Vf(p))}),this.inputMediator.on("disabled",()=>{var p;(p=this.inputMediator)==null||p.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{this.settings.detectSubmit&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(im(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(im(!0))}),this.renderSuggestions(t,u),this.subscribe(ru("inlineSuggestions"),()=>{this.renderSuggestions(t,u)});let f=this.renderOverlays(n);this.unmountHandlers.push(()=>{f.unmount()}),this.store.dispatch(jf({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(Vf(this.inputMediator.getSelection())),this.store.dispatch(im(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{var p;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setExternalId((p=this.state.conversation.current)==null?void 0:p.externalId)}),this.isMounted=!0}subscribe(t,n){let r=t(this.store.getState());return this.store.subscribe(()=>{let o=t(this.store.getState());o!==r&&(r=o,n(r))})}unmount(){var t,n,r,o;(t=this.inlineSuggestions)==null||t.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(r=this.floatingMenu)==null||r.unmount(),this.unmountHandlers.forEach(i=>i()),this.unmountHandlers=[],(o=this.inputMediator)==null||o.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderSuggestions(t,n){var r,o,i;(r=this.floatingMenu)==null||r.unmount(),(o=this.inlineSuggestions)==null||o.unmount(),(i=this.aboveSuggestions)==null||i.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(t,n)),this.settings.inlineSuggestions?this.inlineSuggestions=this.renderInlineSuggestions(t,n):this.aboveSuggestions=this.renderAboveSuggestions(t,n)}renderInlineSuggestions(t,n){let{customStyles:r}=n,o=this.createInlineContainer(t,"deepdesk-caret");(0,lt.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(HP,{})})}),o);let i=s=>{s?(o.style.display="block",o.style.top=`${s.top}px`,o.style.left=`${s.left}px`):o.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var s;(0,lt.unmountComponentAtNode)(o),(s=this.inputMediator)==null||s.off("caretposition",i),o.remove()}}}renderAboveSuggestions(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:i}=n,s=o&&wx(t,o)||void 0,a=this.overlayContainerFactory("deepdesk-tab-completion",s||t,{appendTo:i,closestScrollElement:s,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),l=this.overlayContainerFactory("deepdesk-suggestions-overlay",s||t,{appendTo:i},r==null?void 0:r.suggestionsRootNode);return(0,lt.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(uA,{inputElement:t})})}),a),(0,lt.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(qP,{onLogIn:()=>this.loginViaPopup().catch(u=>ee.warn(u.message))})})}),l),{unmount(){(0,lt.unmountComponentAtNode)(a),(0,lt.unmountComponentAtNode)(l),a.remove(),l.remove()}}}renderFloatingMenu(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:i,floatingMenuParent:s}=n,a=o&&wx(t,o)||void 0,l=this.overlayContainerFactory("floating-menu",a||t,{appendTo:s!=null?s:i},r==null?void 0:r.floatingMenuParent);return(0,lt.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(kP,{onLogIn:()=>this.loginViaPopup().catch(u=>ee.warn(u.message))})})}),l),{unmount(){(0,lt.unmountComponentAtNode)(l),l.remove()}}}renderOverlays(t){let{customStyles:n}=t,r=this.createContainer("deepdesk-overlays");return(0,lt.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:n,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(SP,{})})}),r),{unmount(){(0,lt.unmountComponentAtNode)(r),r.remove()}}}renderWidget(t,n={}){if(this.widgetRoot&&ee.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,isEmbedded:i}=n;this.widgetRoot=t,this.configure({showImages:o,isEmbedded:i}),(0,lt.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(jA,{knowledgeAssistOptions:n.knowledgeAssist,onLogIn:()=>this.loginViaPopup().catch(s=>ee.warn(s.message))})})}),t),this.whenConversationLoaded(()=>{var s;this.broadcastEvents.setExternalId((s=this.state.conversation.current)==null?void 0:s.externalId)})}unmountWidget(){this.widgetRoot&&(0,lt.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}renderKnowledgeAssistantWidget(t,n,r={}){let{customStyles:o,initialQuestion:i}=r;return(0,lt.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:o,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(dx,{children:(0,Me.jsxs)(km,{assistantCode:t,initialQuestion:i,evaluateKnowledgeAssistFn:r.isLegacyKnowledgeAssist?Ci:ki,children:[(0,Me.jsx)(fs,{children:(0,Me.jsx)(Pm,{emptyState:r.emptyState})}),(0,Me.jsx)(cx,{children:(0,Me.jsx)(Rm,{})})]})})})}),n),{unmount(){(0,lt.unmountComponentAtNode)(n),n.remove()}}}setupHandlingTime(t){let n=Hm(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){fI(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>A(this,null,function*(){yield this.store.dispatch(Tu());let t=Ri(this.state);t&&this.store.dispatch(Mf({showSearch:t.search,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:!!t.summarizerAssistantNew||t.summarizer,showKnowledgeSearch:!!t.knowledgeAssistantNew||!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions}))})),this.loadProfileConfigPromise)}loginViaPopup(t){return A(this,null,function*(){return new Promise((n,r)=>{let o=new MessageChannel,i=o.port1,s=this.settings.adminUrl,a=new URL(t!=null&&t.url?t==null?void 0:t.url:`${s}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,u=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",f),clearInterval(d)};i.onmessage=p=>A(this,null,function*(){var y,h;if((y=p.data)!=null&&y.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((h=p.data)==null?void 0:h.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(lu),l=!0,o.port1.close(),n()}catch(g){console.error(g),r(g)}finally{l=!0,u()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&r(new Error("Popup blocked by browser"));let f=p=>A(this,null,function*(){var y;if(p.origin===a.origin)switch((y=p.data)==null?void 0:y.type){case"deepdesk-popup-loaded":{try{let h=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(h,a.origin,[o.port2])}catch(h){ee.error("Error posting message to popup",h),r(h)}break}case"deepdesk-popup-error":{u(),p.data.message==="Timeout"&&ee.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(p.data.message));break}}});window.addEventListener("message",f);let d=setInterval(()=>{c&&!c.closed||(u(),l||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(u)})})}translateMessages(t){return this.deepdeskApi.translateMessages(t)}checkForTrialMode(t){return A(this,null,function*(){try{let{account:n}=yield this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(ee.info("Trial is active"),!(yield this.deepdeskApi.checkUserExists(t)))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:r}=n;ee.info(r),this.shouldRender=!1}})}refreshWidgetSuggestions(){return A(this,null,function*(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=Cu(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(Zn()):Hc.includes(r)||this.store.dispatch(rr(r))})}catch(r){this.handleError(r)}})}};Va.version="16.0.2-beta.3",Va.count=0;var xc=Va;function a5(e){return A(this,null,function*(){var o,i,s;let n=yield((o=e.fetch)!=null?o:window.fetch)(e.url),r=yield n.blob();return new File([r],e.name,{type:(s=(i=e.mimeType)!=null?i:n.headers.get("Content-Type"))!=null?s:"image/jpeg"})})}function CI(e,t){return A(this,null,function*(){let n=yield a5(t),r=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(e,"files",{configurable:!0,get:()=>[n]}),e.dispatchEvent(r)}finally{Object.hasOwn(e,"files")&&delete e.files}})}function kI(e,t,n){return A(this,null,function*(){yield new lo(e).authenticateWithKey(t,n)})}function RI(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function PI(r,o){return A(this,arguments,function*(e,t,n={}){var f,d;let{value:i}=e,{start:s,end:a}=(f=n.replace)!=null?f:{start:0,end:i.length},l=`${i.slice(0,s)}${t}${i.slice(a)}`,u=(d=n.selectionAfter)!=null?d:{start:s+t.length,end:s+t.length},c=()=>{if(n.setValue)return n.setValue(l);e.value=l};return Promise.resolve(c()).then(()=>{e.selectionStart=u.start,e.selectionEnd=u.end,e.blur(),e.focus()})})}function AI(r,o){return A(this,arguments,function*(e,t,n={}){let i=n.replace?Zo(e,n.replace.start,n.replace.end):za(e),s,a=()=>{if(n.setRange)return n.setRange(i.cloneRange());i.deleteContents(),s=document.createElement("span"),i.insertNode(s),n.insertBRs!==!1?t.split(`
84
84
  `).reverse().forEach((l,u)=>{u>0&&i.insertNode(document.createElement("br")),i.insertNode(document.createTextNode(l))}):i.insertNode(document.createTextNode(t))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){e.focus();let l=n.selectionAfter?Zo(e,n.selectionAfter.start,n.selectionAfter.end):(i.collapse(!1),i),u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(l)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})})}function l5(e){let t=document.createElement("template");return t.innerHTML=e.replace(/(\[([^\]]+)])\(([^)]+)\)/g,'<a href="$3" target="_blank" rel="noopener noreferrer">$2</a>'),t.content}function u5(e){let t=document.createDocumentFragment();return e.split(`
85
85
  `).forEach((n,r)=>{r>0&&t.appendChild(document.createElement("br"));let o={index:0},i=0;for(;o=n.slice(i).match(/(\[([^\]]+)])\(([^)]+)\)/);){let s=document.createElement("a");s.href=o[3],s.setAttribute("target","_blank"),s.setAttribute("rel","noopener noreferrer"),s.appendChild(document.createTextNode(o[2])),t.appendChild(document.createTextNode(n.slice(i,i+o.index))),t.appendChild(s),i=i+o.index+o[0].length}t.appendChild(document.createTextNode(n.slice(i)))}),t}function II(e,t){let n=e.parentElement;if(!n){console.warn("No insert point found");return}let{display:r}=window.getComputedStyle(n);r.includes("block")||r==="table-cell"?n==null||n.insertBefore(t,e.nextSibling):II(n,t)}function LI(o,i){return A(this,arguments,function*(e,t,{isBlock:n,isHTML:r}={}){let s;e.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0}));let a=()=>{var d;let l=(d=e.ownerDocument.defaultView)!=null?d:window,u=l.getSelection();if((!u||u.rangeCount===0)&&(e.focus(),u=l.getSelection()),!u||u.rangeCount===0)return;let c=u.getRangeAt(0);if(!c)return;s=document.createElement("span"),c.insertNode(s);let f=r?l5(t):u5(t);n?II(c.startContainer,f):(c.insertNode(f),c.collapse(!1))};return Promise.resolve(a()).then(()=>{if(e.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0})),e.focus(),!!s)try{s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})})}return KI(c5);})();
86
86
  /*! Bundled license information: