@deepdesk/deepdesk-sdk 17.0.0-rc.6 → 17.0.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +3 -3
- package/dist/index.esm.js +3 -3
- package/dist/index.iife.js +3 -3
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -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(F.Provider,{value:N},oe):oe,[F,oe,N])}let E=Ie.memo(w);if(E.WrappedComponent=g,E.displayName=w.displayName=v,l){let I=Ie.forwardRef(function(G,F){return Ie.createElement(E,Fo({},G,{reactReduxForwardedRef:F}))});return I.displayName=v,I.WrappedComponent=g,(0,Zy.default)(I,g)}return(0,Zy.default)(E,g)}}var wi=XN;var tu=S($());function QN({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=QN;function Of(e=At){let t=e===At?sf:Jl(e);return function(){let{store:r}=t();return r}}var ev=Of();function YE(e=At){let t=e===At?ev:Of(e);return function(){return t().dispatch}}var he=YE();EE(QE.useSyncExternalStoreWithSelector);GE(XE.useSyncExternalStore);yE(jy.unstable_batchedUpdates);var nu=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(nu||{});var ZN={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},ZE=Ce({name:"settings",initialState:ZN,reducers:{set(e,t){Object.entries(t.payload).forEach(n=>{let[r,o]=n;typeof o!="undefined"&&(e[r]=o)})}}}),{set:Mf}=ZE.actions,ru=e=>t=>t.settings[e],J=e=>K(ru(e)),JE=ZE.reducer;var JN={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},zt=e=>e.auth.isLoggedIn,eT=e=>e.auth.loginFetchState,tT=e=>e.auth.verifyFetchState,nT=e=>e.auth.showLoginOverlay,jr=ge("auth/validate",(e,t)=>A(void 0,null,function*(){return t.extra.deepdeskAPI.isLoggedIn()})),rT=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)})),oT=Ce({name:"auth",initialState:JN,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:iT}=oT.actions,sT=oT.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(e2(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 e2(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 t2=new Vr;function uT(e,t,n){return t2.diff(e,t,n)}var aT=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,lT=/\S/,cT=new Vr;cT.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!lT.test(e)&&!lT.test(t)};cT.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]&&aT.test(t[n])&&aT.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var dT=new Vr;dT.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 n2=new Vr;n2.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var r2=new Vr;r2.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 o2=Object.prototype.toString,iu=new Vr;iu.useLongestToken=!0;iu.tokenize=dT.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(o2.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 fT(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)):fT(e)&&fT(t)?Object.keys(e).length!==Object.keys(t).length?!1:Object.keys(e).every(s=>Ho(e[s],t[s],n-1)):!1}function i2(e){return Math.max(...e.map(t=>t.length))}function s2(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 pT(e,t){let r=[...e.map(({text:o})=>o.split(/\b(\w+)\b/))];for(let o=0;o<i2(r);o++){let i=s2(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 a2=2;function mT(e,t=""){if(e.length===0)return;if(e.length===1)return e[0];let n=pT(e,a2);return n&&n.text!==t?n:e[0]}var l2={info(...e){console.info("[Deepdesk]",...e)},warn(...e){console.warn("[Deepdesk]",...e)},error(...e){console.error("[Deepdesk]",...e)}},ee=l2;var gT={current:null,isSupported:null},it=ot("resetConversation"),hT=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)))}),u2=[_f.rejected,Df.rejected,Ff.rejected,Hf.rejected].map(e=>e==null?void 0:e.toString()),c2=Ce({name:"conversation",initialState:gT,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,()=>gT).addMatcher(t=>u2.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)})}}),yT=c2.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"),vT=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=uT(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=mT(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),d2=e=>e.input.selection,sa=e=>{let{mixedSuggestion:t,selectedSuggestionIndex:n,textSuggestions:r}=e.input;return n>-1?r[n]:t},xT=()=>K(d2),{commitSuggestion:jn,offeredTextSuggestion:wT,registerCut:ST,registerKeyDown:bT,registerKeyUp:ET,registerPaste:TT,selectNextTextSuggestion:CT,selectPreviousTextSuggestion:kT,selectTextSuggestionByIndex:Uf,setInput:jf,setMetrics:RT,setSelection:Vf,setTextSuggestions:zo,resetMetrics:PT}=vT.actions,AT=vT.reducer;function IT(e){try{return Intl.DateTimeFormat(void 0,{timeZone:e}),!0}catch(t){return!1}}var f2={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},LT=e=>{var t;return(t=e.info.visitorInfo)!=null?t:null},OT=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&&IT(e.visitorTimeZone)?e.visitorTimeZone:Nw,agentName:(n=t==null?void 0:t.agentNickname)!=null?n:"",visitorName:(r=e==null?void 0:e.visitorName)!=null?r:""}},p2=[["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=p2.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})),MT=Ce({name:"info",initialState:f2,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:NT,setCustomData:_T,setPlatformVariables:DT}=MT.actions,FT=MT.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:{}},HT=e=>e.search.isOpen,zT=e=>e.search.page,lv=e=>e.search.list,BT=e=>e.search.aggregates,m2=Un([lv,(e,t)=>t],(e,t)=>e.filter(n=>n.type===t)),UT=e=>t=>m2(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}})),jT=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}=jT.actions,VT=jT.reducer;var uv="SetOutputs",la="ShowLoginOverlay",lu="UserLoggedIn",g2="UserLoggedOut",vr="ApplySuggestion",cv="ApplyImageSuggestion",h2="ShowCommandPalette",y2=e=>({[uv]:t=>{e.dispatch(P(b({},t),{isBroadcasted:!0}))},[h2]:t=>{e.dispatch(An(t.isOpen)),t.page&&e.dispatch(Kr(t.page))},[la]:t=>{e.dispatch(iT(t))},[lu]:()=>{e.dispatch(jr())},[g2]:()=>{e.dispatch(jr())},[cv]:t=>{e.dispatch(Bf({suggestion:t.suggestion}))},[vr]:t=>{e.dispatch(jn(P(b({},t),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),WT=y2;var uu=S($()),$T=S(R()),KT=uu.default.createContext(null),Bo=({broadcastEvents:e,children:t})=>{let n=uu.default.useMemo(()=>e,[]);return(0,$T.jsx)(KT.Provider,{value:n,children:t})},on=()=>{let e=(0,uu.useContext)(KT);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 qT(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:T2,r=t&&t.serializer?t.serializer:b2,o=t&&t.strategy?t.strategy:x2;return o(e,{cache:n,serializer:r})}function v2(e){return e==null||typeof e=="number"||typeof e=="boolean"}function GT(e,t,n,r){var o=v2(r)?r:n(r),i=t.get(o);return typeof i=="undefined"&&(i=e.call(this,r),t.set(o,i)),i}function YT(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 x2(e,t){var n=e.length===1?GT:YT;return fv(e,this,n,t.cache.create(),t.serializer)}function w2(e,t){return fv(e,this,YT,t.cache.create(),t.serializer)}function S2(e,t){return fv(e,this,GT,t.cache.create(),t.serializer)}var b2=function(){return JSON.stringify(arguments)},E2=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}(),T2={create:function(){return new E2}},Gf={variadic:w2,monadic:S2};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 XT(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 QT(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 ZT=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 JT=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 C2(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 k2(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(XT(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 JT(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(!k2(g))throw new ZT(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 n2=new Vr;n2.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var r2=new Vr;r2.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 o2=Object.prototype.toString,iu=new Vr;iu.useLongestToken=!0;iu.tokenize=dT.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(o2.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 fT(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)):fT(e)&&fT(t)?Object.keys(e).length!==Object.keys(t).length?!1:Object.keys(e).every(s=>Ho(e[s],t[s],n-1)):!1}function i2(e){return Math.max(...e.map(t=>t.length))}function s2(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 pT(e,t){let r=[...e.map(({text:o})=>o.split(/\b(\w+)\b/))];for(let o=0;o<i2(r);o++){let i=s2(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 a2=2;function mT(e,t=""){if(e.length===0)return;if(e.length===1)return e[0];let n=pT(e,a2);return n&&n.text!==t?n:e[0]}var l2={info(...e){console.info("[Deepdesk]",...e)},warn(...e){console.warn("[Deepdesk]",...e)},error(...e){console.error("[Deepdesk]",...e)}},ee=l2;var gT={current:null,isSupported:null},it=ot("resetConversation"),hT=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)))}),u2=[_f.rejected,Df.rejected,Ff.rejected,Hf.rejected].map(e=>e==null?void 0:e.toString()),c2=Ce({name:"conversation",initialState:gT,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,()=>gT).addMatcher(t=>u2.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)})}}),yT=c2.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"),vT=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=uT(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=mT(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),d2=e=>e.input.selection,sa=e=>{let{mixedSuggestion:t,selectedSuggestionIndex:n,textSuggestions:r}=e.input;return n>-1?r[n]:t},xT=()=>K(d2),{commitSuggestion:jn,offeredTextSuggestion:wT,registerCut:ST,registerKeyDown:bT,registerKeyUp:ET,registerPaste:TT,selectNextTextSuggestion:CT,selectPreviousTextSuggestion:kT,selectTextSuggestionByIndex:Uf,setInput:jf,setMetrics:RT,setSelection:Vf,setTextSuggestions:zo,resetMetrics:PT}=vT.actions,AT=vT.reducer;function IT(e){try{return Intl.DateTimeFormat(void 0,{timeZone:e}),!0}catch(t){return!1}}var f2={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},LT=e=>{var t;return(t=e.info.visitorInfo)!=null?t:null},OT=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&&IT(e.visitorTimeZone)?e.visitorTimeZone:Nw,agentName:(n=t==null?void 0:t.agentNickname)!=null?n:"",visitorName:(r=e==null?void 0:e.visitorName)!=null?r:""}},p2=[["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=p2.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})),MT=Ce({name:"info",initialState:f2,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:NT,setCustomData:_T,setPlatformVariables:DT}=MT.actions,FT=MT.reducer;function rn(e,t){return t?Object.entries(t).reduce((n,[r,o])=>n.replaceAll(r,o),e):e}var Wf={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},HT=e=>e.search.isOpen,zT=e=>e.search.page,lv=e=>e.search.list,BT=e=>e.search.aggregates,m2=Un([lv,(e,t)=>t],(e,t)=>e.filter(n=>n.type===t)),UT=e=>t=>m2(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}})),jT=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}=jT.actions,VT=jT.reducer;var uv="SetOutputs",la="ShowLoginOverlay",lu="UserLoggedIn",g2="UserLoggedOut",vr="ApplySuggestion",cv="ApplyImageSuggestion",h2="ShowCommandPalette",y2=e=>({[uv]:t=>{e.dispatch(P(b({},t),{isBroadcasted:!0}))},[h2]:t=>{e.dispatch(An(t.isOpen)),t.page&&e.dispatch(Kr(t.page))},[la]:t=>{e.dispatch(iT(t))},[lu]:()=>{e.dispatch(jr())},[g2]:()=>{e.dispatch(jr())},[cv]:t=>{e.dispatch(Bf({suggestion:t.suggestion}))},[vr]:t=>{e.dispatch(jn(P(b({},t),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),WT=y2;var uu=S($()),$T=S(R()),KT=uu.default.createContext(null),Bo=({broadcastEvents:e,children:t})=>{let n=uu.default.useMemo(()=>e,[]);return(0,$T.jsx)(KT.Provider,{value:n,children:t})},on=()=>{let e=(0,uu.useContext)(KT);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 qT(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:T2,r=t&&t.serializer?t.serializer:b2,o=t&&t.strategy?t.strategy:x2;return o(e,{cache:n,serializer:r})}function v2(e){return e==null||typeof e=="number"||typeof e=="boolean"}function GT(e,t,n,r){var o=v2(r)?r:n(r),i=t.get(o);return typeof i=="undefined"&&(i=e.call(this,r),t.set(o,i)),i}function YT(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 x2(e,t){var n=e.length===1?GT:YT;return fv(e,this,n,t.cache.create(),t.serializer)}function w2(e,t){return fv(e,this,YT,t.cache.create(),t.serializer)}function S2(e,t){return fv(e,this,GT,t.cache.create(),t.serializer)}var b2=function(){return JSON.stringify(arguments)},E2=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}(),T2={create:function(){return new E2}},Gf={variadic:w2,monadic:S2};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 XT(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 QT(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 ZT=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 JT=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 C2(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 k2(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(XT(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 JT(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(!k2(g))throw new ZT(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 C2(a)}function R2(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 P2(e,t){return t?Object.keys(e).reduce(function(n,r){return n[r]=R2(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 A2(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=qT(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=P2(e.formats,r),this.formatters=o&&o.formatters||A2(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=QT,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 I2(e,t){return t.split(".").reduce((n,r)=>n?n[r]:void 0,e)}var L2="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=I2(n,o);return s?new vv(s).format(i):(t!==L2&&console.warn(`${o} does not exist in messages of ${t}`),`[${o}]`)}}var ep=S($());var eC={root:"dd-tvkOF",content:"dd-eXA1D"};var wv=S(R()),O2=({isOpen:e,autoFocus:t,children:n,onClose:r,onBack:o,onKeyDown:i,overlayAriaLabel:s,contentAriaLabel:a})=>{let l=(0,ep.useRef)(null),u=D("Dialog",eC),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=O2;var nC=S(Fe());var tC={root:"dd-ranhW"};var rC=S(R()),M2=r=>{var o=r,{className:e,value:t}=o,n=se(o,["className","value"]);let i=D("TextInput",tC);return(0,rC.jsx)("input",b({className:(0,nC.default)(e,i.root),type:"text",value:t},n))},wu=M2;var Sv={};bt(Sv,{enUS:()=>N2,nlNL:()=>_2});var N2={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"}]},_2={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 oC={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 D2=e=>{try{let t=new URL(e);return new URLSearchParams(t.search).get("token")||void 0}catch(t){return e}},F2=({agentEmail:e,isOpen:t,origin:n="",onSuccess:r,onDismiss:o})=>{let i=ue(Sv),s=D("LoginTokenDialog",oC),a=K(tT),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(rT({email:c})),p(1)}),[n,c]),m=()=>{h(""),p(0)},v=(0,Vn.useCallback)(w=>A(void 0,null,function*(){w.preventDefault();let C=D2(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")})]})]})]})})},iC=F2;var aC=S(R()),H2=()=>{let e=K(nT),t=K(aa),n=J("adminUrl"),r=on(),o=()=>r.send(la,!1),i=()=>{r.send(la,!1),r.send(lu)};return(0,aC.jsx)(iC,{isOpen:e,agentEmail:t==null?void 0:t.agentEmail,origin:n,onDismiss:o,onSuccess:i})},sC=H2;var yP=S(Tv()),$t=S($());var Su="__summarizerAssistant__",dC={cues:[],threads:{},fetchState:"idle"},fC=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})),n_=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=n_++,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 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}})),pC=Ce({name:"assistants",initialState:dC,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,()=>dC)}}),{removeCueByCode:mC,resetCues:iB,removeThreadById:ua}=pC.actions,gC=pC.reducer;var r_={data:null,fetchState:"idle"},hC=e=>e.contentTypes.data,Eu=ge("contentTypes/getContentTypes",(e,t)=>A(void 0,null,function*(){return t.extra.deepdeskAPI.getContentTypes()})),o_=Ce({name:"contentTypes",initialState:r_,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})}}),yC=o_.reducer;var i_={data:null,fetchState:"idle"},s_=[],Ri=e=>e.profile.data,a_=e=>e.profile.data?e.profile.data.uiConfig.widget.types:s_,Cu=Un([a_],e=>e.filter(t=>t.isActive)),vC=e=>{var t;return(t=e.profile.data)==null?void 0:t.summarizerAssistantNew},xC=e=>{var t;return((t=e.profile.data)==null?void 0:t.onDemandAssistants)||[]},Cv=e=>t=>Cu(t).find(n=>n.type===e),wC=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)})),l_=Ce({name:"profile",initialState:i_,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})}}),SC=l_.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 bC=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:()=>u_,nlNL:()=>c_});var u_={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"}]},c_={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()),d_=({src:e,title:t})=>{let n=D("CommandPalette",mn),[r,o]=(0,bC.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})]})},EC=d_;var TC=S($()),CC=S(Fe());var Pi=S(R());function kv({children:e,heading:t,orientation:n,hasMore:r,onShowAll:o}){let i=ue($r),s=D("CommandPalette",mn);return TC.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,CC.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 kC(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 kC(t,n,r,o)}onBeforeParse(t,n){return t}onAfterParse(t,n){return t}};var Li=S($()),IC=S(PC());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 m_=/(url|image|image-set)\(/i,Nv=class extends Pu{attribute(t,n){return t==="style"&&Object.keys(n).forEach(r=>{String(n[r]).match(m_)&&delete n[r]}),n}},AC=1,g_=3,h_=/^<(!doctype|(html|head|body)(\s|>))/i,y_=/^(aria-|data-|\w+:)/iu,v_=/{{{(\w+)\/?}}}/;function x_(){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 C2(a)}function R2(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 P2(e,t){return t?Object.keys(e).reduce(function(n,r){return n[r]=R2(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 A2(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=qT(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=P2(e.formats,r),this.formatters=o&&o.formatters||A2(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=QT,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 I2(e,t){return t.split(".").reduce((n,r)=>n?n[r]:void 0,e)}var L2="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=I2(n,o);return s?new vv(s).format(i):(t!==L2&&console.warn(`${o} does not exist in messages of ${t}`),`[${o}]`)}}var ep=S($());var eC={root:"dd-tvkOF",content:"dd-eXA1D"};var wv=S(R()),O2=({isOpen:e,autoFocus:t,children:n,onClose:r,onBack:o,onKeyDown:i,overlayAriaLabel:s,contentAriaLabel:a})=>{let l=(0,ep.useRef)(null),u=D("Dialog",eC),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=O2;var nC=S(Fe());var tC={root:"dd-ranhW"};var rC=S(R()),M2=r=>{var o=r,{className:e,value:t}=o,n=se(o,["className","value"]);let i=D("TextInput",tC);return(0,rC.jsx)("input",b({className:(0,nC.default)(e,i.root),type:"text",value:t},n))},wu=M2;var Sv={};bt(Sv,{enUS:()=>N2,nlNL:()=>_2});var N2={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"}]},_2={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 oC={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 D2=e=>{try{let t=new URL(e);return new URLSearchParams(t.search).get("token")||void 0}catch(t){return e}},F2=({agentEmail:e,isOpen:t,origin:n="",onSuccess:r,onDismiss:o})=>{let i=ue(Sv),s=D("LoginTokenDialog",oC),a=K(tT),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(rT({email:c})),p(1)}),[n,c]),m=()=>{h(""),p(0)},v=(0,Vn.useCallback)(w=>A(void 0,null,function*(){w.preventDefault();let C=D2(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")})]})]})]})})},iC=F2;var aC=S(R()),H2=()=>{let e=K(nT),t=K(aa),n=J("adminUrl"),r=on(),o=()=>r.send(la,!1),i=()=>{r.send(la,!1),r.send(lu)};return(0,aC.jsx)(iC,{isOpen:e,agentEmail:t==null?void 0:t.agentEmail,origin:n,onDismiss:o,onSuccess:i})},sC=H2;var yP=S(Tv()),$t=S($());var Su="__summarizerAssistant__",dC={cues:[],threads:{},fetchState:"idle"},fC=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})),n_=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=n_++,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 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});switch(s){case"text":return rn(d,u);case"json-schema:cues":return Array.isArray(d)?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}})),pC=Ce({name:"assistants",initialState:dC,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,()=>dC)}}),{removeCueByCode:mC,resetCues:iB,removeThreadById:ua}=pC.actions,gC=pC.reducer;var r_={data:null,fetchState:"idle"},hC=e=>e.contentTypes.data,Eu=ge("contentTypes/getContentTypes",(e,t)=>A(void 0,null,function*(){return t.extra.deepdeskAPI.getContentTypes()})),o_=Ce({name:"contentTypes",initialState:r_,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})}}),yC=o_.reducer;var i_={data:null,fetchState:"idle"},s_=[],Ri=e=>e.profile.data,a_=e=>e.profile.data?e.profile.data.uiConfig.widget.types:s_,Cu=Un([a_],e=>e.filter(t=>t.isActive)),vC=e=>{var t;return(t=e.profile.data)==null?void 0:t.summarizerAssistantNew},xC=e=>{var t;return((t=e.profile.data)==null?void 0:t.onDemandAssistants)||[]},Cv=e=>t=>Cu(t).find(n=>n.type===e),wC=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)})),l_=Ce({name:"profile",initialState:i_,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})}}),SC=l_.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 bC=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:()=>u_,nlNL:()=>c_});var u_={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"}]},c_={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()),d_=({src:e,title:t})=>{let n=D("CommandPalette",mn),[r,o]=(0,bC.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})]})},EC=d_;var TC=S($()),CC=S(Fe());var Pi=S(R());function kv({children:e,heading:t,orientation:n,hasMore:r,onShowAll:o}){let i=ue($r),s=D("CommandPalette",mn);return TC.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,CC.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 kC(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 kC(t,n,r,o)}onBeforeParse(t,n){return t}onAfterParse(t,n){return t}};var Li=S($()),IC=S(PC());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 m_=/(url|image|image-set)\(/i,Nv=class extends Pu{attribute(t,n){return t==="style"&&Object.keys(n).forEach(r=>{String(n[r]).match(m_)&&delete n[r]}),n}},AC=1,g_=3,h_=/^<(!doctype|(html|head|body)(\s|>))/i,y_=/^(aria-|data-|\w+:)/iu,v_=/{{{(\w+)\/?}}}/;function x_(){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
|
|
|
@@ -80,7 +80,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let o="<p>An error
|
|
|
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()),A4={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},bP=({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:A4[t||"pink"]})});var EP={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:()=>I4,nlNL:()=>L4});var I4={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},L4={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Xi=S(R()),CP=({onLogIn:e})=>{let t=ue(U0),n=J("floatingMenu"),r=J("productName"),o=he(),i=K(zt),s=D("FloatingMenu",EP);if(i===null||n===!1)return null;let a=()=>{i===!0?o(An(!0)):e()};return(0,Xi.jsxs)("button",{type:"button",className:(0,TP.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)(bP,{className:s.logo,color:"pink"}),i===!1&&(0,Xi.jsx)(SP,{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 O4={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},om=({ui:e})=>e.overlayCollapsed,kP=Ce({name:"ui",initialState:O4,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:RP,setOverlayCollapsedUserOverwrite:PP}=kP.actions,AP=kP.reducer;var NP=S($());var Go=S($());var IP=S($());function LP(e,t,n){(0,IP.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var OP={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var Qi=S(R()),N4=["search","personal-collection-search","search-autocomplete"];function _4(e,t,n,r={}){var i;let o="";return N4.includes(t)?o=LC(_v(e,n,{stripAgentPart:!0}),(i=r.searchKeywords)!=null?i:[n]):o=_v(e,n,r),r.placeholders===!0&&(o=OC(o)),o}var D4=()=>{},F4=({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=D("TextSuggestion",OP),c=(0,Go.useRef)(null);(0,Go.useEffect)(()=>{let d=setTimeout(()=>{l(wT({text:t.text,suggestion:t}))},500);return()=>{clearTimeout(d)}},[t]),LP(c,"click",()=>{l(jn({suggestion:t,text:t.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let f=(0,Go.useMemo)(()=>_4(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)(be,{ref:c,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:D4,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})})]})},MP=F4;var _P=S(R()),H4=({suggestions:e,selectedIndex:t,reverse:n})=>(0,NP.useMemo)(()=>{let o=e.map((i,s)=>(0,_P.jsx)(MP,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]),sm=H4;var DP={root:"dd-PfvRI",paper:"dd-HYlyY"};var lc=S(R()),z4=({textSuggestions:e,selectedIndex:t})=>{let n=(0,am.useRef)(null),r=D("InlineSuggestionsOverlay",DP),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})})})})},B4=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),FP=wi(B4)(z4);var uc=S(R()),U4=({children:e})=>{let n=J("locale").replace("-","");return(0,uc.jsx)(xv.Provider,{value:n,children:e})},j4=({store:e,customStyles:t={},children:n})=>(0,uc.jsx)(Jy,{store:e,children:(0,uc.jsx)(U4,{children:(0,uc.jsx)(Ya.Provider,{value:t,children:n})})}),Yo=j4;var um=S(Fe()),Oa=S($());var HP=S($());function zP(e,t){let[n,r]=(0,HP.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 BP=()=>/Mac/i.test(navigator.platform);var jP=S(Fe()),no=S($());var j0={};bt(j0,{enUS:()=>V4,nlNL:()=>W4});var V4={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"}]}]},W4={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 UP={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),K4=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=ue(j0),s=on(),a=D("Login",UP),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,jP.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=K4;var VP={root:"dd-DoQhb",text:"dd-Jwnev"};var cc=S(R()),$4=({title:e})=>{let t=D("SearchTrigger",VP),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})]})},WP=$4;var W0={};bt(W0,{enUS:()=>q4,nlNL:()=>G4});var q4={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"}]},G4={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 KP={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()),Y4=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=D("SuggestionsOverlay",KP),o=ue(W0),i=K(Tr),s=xT(),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]=zP("dd-snooze-until-ms",0),E=f||w>Date.now(),k=e.filter(G=>G.source!=="gpt").length,I=()=>{E&&C(0),a(PP(!E))},L=G=>{let F=Date.now()+G*1e3;C(F),ee.info(`Snooze until: ${new Date(F)}`),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(BP()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>h(null),children:(0,Ke.jsx)(WP,{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})})})]})},X4=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),$P=wi(X4)(Y4);var Sm=S(Fe());var io=S($());var Ma=S($());function cm(e){return e.contentEditable==="true"}function Q4(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 qP(e){let{selectionStart:t,selectionEnd:n}=cm(e)?Q4(e):e;return[t,n]}function GP(e){let[,t]=(0,Ma.useState)(),n=(0,Ma.useRef)(null);return n.current=qP(e),(0,Ma.useEffect)(()=>{let r=()=>{var a;let[o,i]=(a=n.current)!=null?a:[],s=qP(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 YP(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 XP=S($()),Z4=["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(Z4.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,XP.cloneElement)(r,{children:K0(s,t,n+1)})]}return[...e,...t]}function Zi(e){return e.tagName.toLowerCase()==="textarea"}var QP={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 nA=S(Fe());var hm=S($());var Na=S($());function ZP(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]=ZP((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]=ZP(()=>{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 JP(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function fm(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function eA(e){return e!=null}var tA=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=D("TabCompletion",ro);return(0,$0.jsx)("div",P(b({ref:fm([s,r]),className:(0,tA.default)(e,a.popoverContentContainer)},n),{children:(0,$0.jsx)("div",{className:a.popoverContent,children:t})}))});var Qo=S(R()),J4=e=>t=>{let n=R0(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},eF=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=D("TabCompletion",ro),s=qp(),a=(0,hm.useMemo)(()=>J4(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,nA.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${JP(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(eA);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)(eF,{inputElement:r.inputElement,suggestion:r.suggestion,inputStyle:r.inputStyle,boundaryRef:r.boundaryRef,children:n},`keyword_${r.matchString}_${r.key}`)}asTag(){return"mark"}};var rA=S(Fe());var q0=S(R()),tF=({inputElement:e,children:t})=>{let n=D("TabCompletion",ro),[r,o]=dm(e);return(0,q0.jsx)("mark",{ref:r,className:(0,rA.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)(tF,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var xm=S(Fe());var Gt=S($());var G0=S(R()),oA=()=>(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 sA=S(Tv());var iA={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()),nF=3,rF=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),oF=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=nF})=>{let i=D("LinkSearch",iA),[s,a]=(0,Cr.useState)(""),l=he(),u=K(dP("url")),c=K(UT("URL")),f=(0,Cr.useMemo)(()=>c.map(rF),[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,sA.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)(be,{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)(be.Actions,{children:(0,_n.jsx)(be.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})]})},aA=oF;var X0={};bt(X0,{enUS:()=>iF,nlNL:()=>sF});var iF={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},sF={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()),aF=(0,Gt.forwardRef)((e,t)=>{let n=D("TabCompletion",ro);return(0,qt.jsx)("mark",{ref:t,className:(0,xm.default)(n.matchSelection)},"selection-start")}),lF=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=ue(X0),s=D("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)(oA,{}),(0,qt.jsx)("span",{children:"\xA0"}),(0,qt.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,qt.jsx)(aA,{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)(aF,{ref:this.startRef}):(0,qt.jsx)(lF,{inputElement:r.inputElement,startRef:this.startRef,boundaryRef:r.boundaryRef,inputStyle:r.inputStyle})}asTag(){return"mark"}};var oo=S(R()),uF=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=D("TabCompletion",QP),c=J("insertLink"),f=J("showMidSentenceSuggestions"),d=J("inlineSuggestions"),p=GP(a),y=(0,io.useRef)(null),h=K(zt);(0,io.useEffect)(()=>{Zi(a)&&p&&YP(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",{})]})},cF=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}},lA=wi(cF)(uF);var Ha=S($());var dF={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)}),uA=Ce({name:"passwordlessToken",initialState:dF,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:cA}=uA.actions,dA=uA.reducer;function fF(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}var fA=Un([fC],e=>e.map(n=>({text:n.response,title:n.name,callToAction:n.callToAction,isLoading:n.isLoading,specialType:n.specialType,rule:{id:fF(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 pA={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var kr=S(R()),pF=({entities:e})=>{let t=D("EntitiesWidgetList",pA),[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))})},mA=pF;var tx=S(R()),gA=()=>(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()),hA=()=>(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()),yA=()=>(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 vA={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var xA={root:"dd-nazq3",rotation:"dd-3EHTv"};var SA=S(R()),mF=({size:e=12})=>{let t=D("LoadingSpinner",xA);return(0,SA.jsx)("span",{"data-testid":"loading-spinner",style:{width:`${e}px`,height:`${e}px`},className:t.root})},wA=mF;var ox=S(R()),bA=()=>(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()),EA=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:()=>gF,nlNL:()=>hF});var gF={error:[{type:0,value:"Something went wrong"}]},hF={error:[{type:0,value:"Er ging iets fout"}]};var hn=S(R()),TA,yF=3e3,vF=({assistantOptions:e})=>{let t=D("OnDemandAssistants",vA),n=ue(ix),r=Zr(Kn),o=Zr(Wn),i=K(vC),s=K(xC),a=at(),l=s.filter(f=>f.isPinned),u=s.filter(f=>!f.isPinned),c=f=>A(void 0,null,function*(){if(clearTimeout(TA),a("trigger on demand assistant",{assistantCode:f}),f===i){o.call({transcript:e.transcript});return}r.call(P(b({},e),{assistantCode:f})),TA=setTimeout(()=>r.reset(),yF)});return s.length===0?null:(0,hn.jsxs)("div",{className:t.root,children:[l.map(({assistant:f,assistantName:d})=>(0,hn.jsx)("button",{type:"button",className:t.button,disabled:r.state==="loading",onClick:()=>c(f),children:d},f)),r.state==="loading"&&(0,hn.jsx)(wA,{}),r.state==="done"&&(0,hn.jsx)(EA,{"data-testid":"trigger-done"}),r.state==="error"&&(0,hn.jsx)(oR,{trigger:(0,hn.jsx)(bA,{}),children:n("error")}),u.length>0&&r.state==="idle"&&(0,hn.jsxs)(mt,{placement:"top-end",children:[(0,hn.jsx)(mt.Trigger,{className:t.trigger,children:(0,hn.jsx)(Zp,{"data-testid":"trigger"})}),(0,hn.jsx)(mt.Content,{className:t.nav,"data-testid":"popover",children:u.map(({assistant:f,assistantName:d})=>(0,hn.jsx)(mt.Button,{className:t.item,disabled:r.state==="loading",onClick:()=>c(f),children:d},f))})]})]})},CA=vF;var PA=S($());var kA={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};var RA=S(R()),xF=({width:e})=>{let t=D("LoadingProgressBar",kA);return(0,RA.jsx)("div",{className:t.loadingBar,style:{width:e}})},Em=xF;var so=S(R()),Tm=({title:e})=>{let t=(0,PA.useRef)(null);return bw(t),(0,so.jsx)(be,{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:()=>wF,nlNL:()=>SF});var wF={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"}]},SF={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()),bF=500,EF=100,TF=({content:e,onChange:t,onCopy:n})=>{let r=(0,Ji.useRef)(null),o=D("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,EF),bF);i.style.setProperty("height",`${s}px`)},[e]),(0,Mt.jsx)("textarea",{ref:r,className:o.editableCue,onCopy:n,onChange:t,value:e})},CF=({cue:e,onCallToAction:t,onRemove:n,onCopy:r,onUse:o})=>{var h;let i=D("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)(be,{"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)(TF,{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)(be.ButtonsContainer,{children:[(0,Mt.jsxs)("div",{className:i.actions,children:[e.specialType==="summary"&&(0,Mt.jsx)(be.Button,{onClick:()=>d(u),children:s("copyCue")}),e.callToAction&&(0,Mt.jsx)(be.Button,{onClick:f,children:e.callToAction.label}),(0,Mt.jsx)(be.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"})]})]})},AA=CF;var _a=S(R()),kF=({cues:e})=>{let t=he(),n=on(),r=ue(pc),o=at(),i=u=>{t(mC({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)(AA,{cue:u,onCallToAction:a,onRemove:i,onCopy:s,onUse:l},u.rule.id))})},IA=kF;var Cm=S($());var LA={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 RF(e,t){return t.split(".").reduce((n,r)=>!n||typeof n!="object"||!(r in n)?null:n[r],e)}var OA=({data:e,schema:t})=>{let n=D("WidgetCustomData",LA),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=RF(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 lt=S($());var Da={};bt(Da,{enUS:()=>PF,nlNL:()=>AF});var PF={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"}]},AF={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:"Gesprek wissen"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var km={form:"dd-pleCH",formInput:"dd-pGJMY",formSubmit:"dd--gkRg",actionButton:"dd-I2NEH",resetContainer:"dd-qKIDX",sources:"dd-xf9c6",source:"dd-a-vyX",tooltip:"dd-EsgcZ",linkContent:"dd-gARDA",showMoreSources:"dd-uDGi-"};var xe=S(R()),IF=3,LF=({sources:e,onClick:t})=>{let n=ue(Da),r=D("WidgetKnowledgeAssistant",km),[o,i]=(0,lt.useState)(!1),s=o?e:e.slice(0,IF);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)(mt,{tooltip:!0,placement:"top-start",children:[(0,xe.jsx)(mt.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)(mt.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})})]})},OF=({title:e,description:t})=>(0,xe.jsx)(be,{"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})]})})}),MF=({innerRef:e,item:t,index:n,hasKeyboardInput:r,onCopy:o,onUse:i,onSourceClick:s})=>{var l;let a=ue(Da);return(0,xe.jsxs)(be,{"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)(LF,{sources:(l=t.answer.sources)!=null?l:[],onClick:u=>s(u,t.question)})]})}),(0,xe.jsxs)(be.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"})]})]})},ax=(0,lt.createContext)(null),Rm=({assistantCode:e,evaluateKnowledgeAssistFn:t,initialQuestion:n,children:r})=>{let[o,i]=(0,lt.useState)(null),[s,a]=(0,lt.useState)(!1),[l,u]=(0,lt.useState)(!!n),[c,f]=(0,lt.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,lt.useEffect)(()=>{n&&h(n)},[n]),(0,xe.jsx)(ax.Provider,{value:g,children:r})},Pm=()=>{let e=ue(Da),t=D("WidgetKnowledgeAssistant",km),n=(0,lt.useContext)(ax),r=(0,lt.useRef)(null),[o,i]=(0,lt.useState)(""),s=l=>{i(l.target.value)},a=l=>{l.preventDefault(),n.onSubmit(o).then(()=>{var u;r.current&&((u=r.current)==null||u.focus(),i(""))})};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")})]}):null},Am=({title:e,emptyState:t})=>{var y,h;let n=ue(Da),r=at(),o=D("WidgetKnowledgeAssistant",km),i=(0,lt.useRef)(null),s=(0,lt.useContext)(ax),a=(h=K(bu((y=s.threadId)!=null?y:-1)))!=null?h:[],l=J("hasKeyboardInput"),u=on(),c=g=>{xr(g),r("Assistant response copied",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",copiedText:g})},f=(g,m)=>{r("knowledge assist source viewed",{question:m,sourceViewed:g.url||g.name})},d=g=>{var m;g.preventDefault(),s.onReset(),r("knowledge assist reset",{threadId:(m=s.threadId)!=null?m:void 0})},p=g=>{u.send(vr,{text:g,suggestion:{source:"cue",sourceText:g}}),r("Assistant response used",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",usedText:g})};return!s.isEnabled||(a==null?void 0:a.length)===0&&!s.isSubmitting&&!t?null:(0,xe.jsxs)(lt.Fragment,{children:[(0,xe.jsx)(lr,{type:"knowledge",title:e,"data-testid":"knowledge",children:(0,xe.jsxs)(Zt,{withDivider:!0,children:[t&&a.length===0&&!s.pendingInput&&(0,xe.jsx)(OF,b({},t)),a.map((g,m)=>(0,xe.jsx)(MF,{innerRef:m===a.length-1?i:void 0,item:g,index:m,hasKeyboardInput:l,onCopy:c,onUse:p,onSourceClick:f},`${g.question}_${g.answer}_${m}`)),s.pendingInput&&(0,xe.jsx)(Tm,{title:s.pendingInput})]})}),a.length>0&&(0,xe.jsx)("div",{className:o.resetContainer,children:(0,xe.jsx)(be.Button,{disabled:s.threadId===null||s.isSubmitting,onClick:d,children:n("resetLabel")})})]})};var _A=S($());var NF=/(https?:\/\/[^\s]+)/,NA=e=>e.split(" ").find(t=>NF.test(t));var Dn=S(R()),_F=({suggestion:e,lines:t,onUse:n})=>{var f;let r=e.text||e.url||e.message,o=NA(r),i=ue(rc),s=J("showImages"),a=J("fallbackImage"),l=J("hasKeyboardInput"),u=d=>{d.preventDefault(),d.stopPropagation(),l&&n(r)},c=(0,_A.useCallback)(d=>{window.open(o,"_blank"),d.stopPropagation(),d.preventDefault()},[o]);return(0,Dn.jsxs)(be,{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)(be.Labels,{labels:e.searchKeywords}),(0,Dn.jsx)(Oe.Content,{cropText:t==="single",lineClamp:t==="multiple",children:r})]})]}),(0,Dn.jsxs)(be.Actions,{children:[o&&(0,Dn.jsx)(be.ActionButton,{onClick:c,label:i("visitUrl")}),l&&(0,Dn.jsx)(be.ActionButton,{primary:!0,onClick:u,label:i("useSuggestion")})]})]})},DA=_F;var mc=S(R()),DF=({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)(DA,{suggestion:o,lines:e,onUse:i=>r(i,o)},o.text||o.url||o.message))})},FA=DF;var Im={};bt(Im,{enUS:()=>FF,nlNL:()=>HF});var FF={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},HF={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],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()),zA=(e,t)=>{let n=K(zt);(0,Ha.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},zF=({onLogIn:e})=>{let t=D("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")},HA=({text:e})=>{let t=D("Widget",Fa);return(0,de.jsx)("div",{className:t.stateText,children:(0,de.jsx)("div",{children:(0,de.jsx)("p",{children:e})})},"notification")},BF=()=>{let e=ue(Im),t=he(),n=D("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 zA(()=>{if(a)return t(Z0()),()=>{t(cA())}},[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)(yA,{}),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)(hA,{}),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)(gA,{}),e("linkStudioLogin",{productName:c})]})]})})},UF=()=>{let e=he(),t=K(Cu),n=K(wC),r=K(fA),o=K(OT),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]),zA(()=>{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)(mA,{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)(IA,{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)(OA,{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)(FA,{lines:d,contentType:u,suggestions:s[u].suggestions.slice(0,f)||[]})})},u)}})})},lx=({children:e})=>{let t=D("Widget",Fa);return(0,de.jsx)("div",{className:t.footer,children:e})},ux=({children:e})=>{let t=D("Widget",Fa);return(0,de.jsx)("div",{className:t.root,"data-testid":"widget",children:e})},jF=({onLogIn:e,knowledgeAssistOptions:t={},assistantOptions:n={transcript:"in-memory-transcript",expectFormat:"json-schema:cues"}})=>{let r=ue(Im),o=K(oa),i=K(zt),s=K(hT),a=K(Ri),l=K(Cv("knowledge-assist")),u=K(op),c=K(ip);return o===!1?(0,de.jsx)(HA,{text:r("notSupported")}):i===!1?(0,de.jsx)(zF,{onLogIn:e}):!a||!s||i===null?(0,de.jsx)(HA,{text:r("waiting")}):(0,de.jsx)(ux,{children:(0,de.jsxs)(Rm,{initialQuestion:t.initialQuestion,assistantCode:u!=null?u:c,evaluateKnowledgeAssistFn:c?Ci:ki,children:[(0,de.jsxs)(fs,{children:[(0,de.jsx)(BF,{}),(0,de.jsx)(UF,{}),l&&(0,de.jsx)(Am,{title:l.title,emptyState:t.emptyState})]}),(0,de.jsxs)(lx,{children:[l&&(0,de.jsx)(Pm,{}),(0,de.jsx)(CA,{assistantOptions:n})]})]})})},BA=jF;function za(e){let t=new Range;return t.selectNodeContents(e),t}function UA(e,t,n){try{return Zo(e,t,n),!0}catch(r){return!1}}function Lm(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function Om(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(Om(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;Lm(l)&&u&&!Lm(u)&&!Om(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(Om(f)&&f.nextSibling){u++;break}!d&&Lm(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&&Om(c)&&c.nextSibling){l+=`
|
|
82
82
|
`;break}!f&&!s&&a===1&&Lm(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 jA=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(jA||{}),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(jA).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 VA(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!VA(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!VA(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&&UA(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 VF=["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 WA(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",VF.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 WA(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 KA(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 WF(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var cx=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()}},dx=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=KA(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()}},fx=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 dx(t,this.deepdeskUrl,{debug:!0}):new cx(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=WF(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)}},$A=fx;function KF(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),{[KF(n)]:$e(e[n])}),{}):e}function $F(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),{[$F(n)]:wt(e[n])}),{}):e}var Ba=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var px=e=>new Promise(t=>{setTimeout(t,e)});var Ua=class extends Ba{constructor(){super(...arguments);this.name="ClientError"}},gx=class extends Ba{constructor(){super(...arguments);this.name="ServerError"}},mx=new Map;function qF(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(mx.has(s)){r(mx.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 px(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 px(d),C();throw k}))});C().then(k=>A(this,null,function*(){let I=yield qF(k);if(delete this.latestRequestByUrl[s],k.status>=500){o(new gx("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&&mx.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 qA;(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={}))})(qA||(qA={}));function Mm(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 Mm(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/by_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}`),Mm(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/by_external_id/${t}/has_active_profile`,{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 Mm(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=>Mm(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(Mw);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 GA={startTime:null,stopTime:null},YA=e=>e.handlingTime,XA=Ce({name:"handlingTime",initialState:GA,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,()=>GA)}}),{handlingTimeStart:QA,handlingTimeStop:Nm,handlingTimeReset:ZA}=XA.actions,JA=XA.reducer;var eI=(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 _m={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 _m.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),GF=Ce({name:"styleSuggestions",initialState:_m,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=_m.list}).addCase(it,()=>_m)}}),tI=GF.reducer;var nI=(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 YF(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var rI=(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 YF(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 oI=os.fulfilled.toString();function XF(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 iI=e=>t=>n=>r=>{var u;if(r.type!==oI){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=XF(o,s);r.type===oI&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var QF=nf({assistants:gC,auth:sT,conversation:yT,contentTypes:yC,passwordlessToken:dA,entities:pR,handlingTime:JA,info:FT,input:AT,settings:JE,profile:SC,search:VT,styleSuggestions:tI,ui:AP,textSuggestions:mP});function sI(e){return oE({reducer:QF,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI}},serializableCheck:!1}),eI(),rI({debounce:200}),nI({debounce:500}),iI(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var ZF=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},JF=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 Nm.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:ZF(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},aI=JF;function hx(e){return e.toISOString().replace("T"," ").replace("Z","")}var e5=(e,t)=>t.version,lI=Un([aa,yr,YA,e5],(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:hx(o),timeStop:hx(i)}});function uI(e,t,n){var I,L,G,F;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:(F=t.info.agentInfo)==null?void 0:F.agentEmail}}function yx(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return yx(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?yx(o,t):null}function vx(e,t){return yx(e,t)}function cI(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function t5(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Dm(e){return t5(e)&&(Zi(e)||cm(e))}var fI,Rr=new Map,n5=["bottom","height","left","right","top","width"],dI=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:n5.some(n=>e[n]!==t[n]);function pI(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,...pI(t)]:[]}function mI(e,t){return!e||!t?null:P(b({},e),{top:e.top+t.top,left:e.left+t.left})}var Fm=!1,gI=()=>{Fm=!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();dI(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(mI,t.rect):t.rect;dI(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Rr.size===0){Fm=!1;return}fI=window.requestAnimationFrame(gI)};function xx(e,t){let n=pI(e),r=[],o=n.map((i,s)=>xx(i,a=>{r[s]=a;let l=Rr.get(e);if(!l)return;let u=r.reduce(mI,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&&!Fm&&gI()},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(fI),Fm=!1)}}}}var hI,Pr=new Map,yI=()=>{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&&(hI=window.requestAnimationFrame(yI))};function vI(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&&yI()},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(hI)}}}}var wx=["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 Sx(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function ja(e){return Number.parseFloat(e)}function Hm(e){return Math.round(e*1e6)}function xI(e){return e/1e6}function bx(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=xI(Hm(o)-Hm(i)-Hm(s)),u=xI(Hm(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};Sx(r,n,wx),bx(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=vI(e,()=>{Sx(r,n,wx),bx(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=xx(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(Sx(r,n,wx),bx(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 wI=(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 r5(e){return e.offsetParent!==null}function SI(e){if(!r5(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 zm(e,t,n=100){let r=SI(e);t({isVisible:r});let o=setInterval(()=>{let i=SI(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var Me=S(R());var bI=wI("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:[aI({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=>bI.update(c),sendEvent:(c,f)=>this.deepdeskApi.sendEvent(c,f)})]};this.store=sI(u),this.broadcastEvents=new $A({debug:!0,deepdeskUrl:l,eventMap:WT(this.store),createCustomChannel:a}),this.store.dispatch(ac(bI.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)&&eT(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(NT(t))}setCustomData(t){this.store.dispatch(_T(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({includeMetadata:!0},n))})}getSummary(){return A(this,arguments,function*(t={}){var r;if(!this.hasConversation())return ee.warn("No conversation to create summary for."),null;(r=this.state.profile.data)!=null&&r.summarizerAssistantNew||ee.warn("No profile loaded yet, or no summarizer assistant set in profile");let n=yield this.store.dispatch(Wn(t));if(n.error)throw new Error(n.error.message);return n.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(bT(iv(t))),!Tr(this.state)||t.key!=="Tab"&&!l)return;let f=()=>{n||!c||s&&(t.shiftKey||(this.store.dispatch(CT()),t.preventDefault()))},d=()=>{n||!c||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(kT()),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(RP(!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(QA()))}handlingTimeStop(){this.state.handlingTime.startTime&&(ee.info("Stop handling time"),this.store.dispatch(Nm()))}logSendMessage(t){let n=uI("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=lI(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(ZA()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(bi((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(PT()))}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(DT(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,ut.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,ut.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,ut.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(RT(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(!Dm(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(ET(iv(p)))}),this.inputMediator.on("keydown",p=>{this.handleKeyDown(p)}),this.inputMediator.on("paste",({pastedText:p,selectionText:y})=>{this.store.dispatch(TT({text:p,selectionText:y}))}),this.inputMediator.on("cut",({selectionText:p})=>{this.store.dispatch(ST(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,ut.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(FP,{})})}),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,ut.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&&vx(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,ut.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(lA,{inputElement:t})})}),a),(0,ut.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)($P,{onLogIn:()=>this.loginViaPopup().catch(u=>ee.warn(u.message))})})}),l),{unmount(){(0,ut.unmountComponentAtNode)(a),(0,ut.unmountComponentAtNode)(l),a.remove(),l.remove()}}}renderFloatingMenu(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:i,floatingMenuParent:s}=n,a=o&&vx(t,o)||void 0,l=this.overlayContainerFactory("floating-menu",a||t,{appendTo:s!=null?s:i},r==null?void 0:r.floatingMenuParent);return(0,ut.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(CP,{onLogIn:()=>this.loginViaPopup().catch(u=>ee.warn(u.message))})})}),l),{unmount(){(0,ut.unmountComponentAtNode)(l),l.remove()}}}renderOverlays(t){let{customStyles:n}=t,r=this.createContainer("deepdesk-overlays");return(0,ut.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:n,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(wP,{})})}),r),{unmount(){(0,ut.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,ut.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(BA,{assistantOptions:n.assistantOptions,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,ut.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}renderKnowledgeAssistantWidget(t,n,r={}){let{customStyles:o,initialQuestion:i}=r;return(0,ut.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:o,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(ux,{children:(0,Me.jsxs)(Rm,{assistantCode:t,initialQuestion:i,evaluateKnowledgeAssistFn:r.isLegacyKnowledgeAssist?Ci:ki,children:[(0,Me.jsx)(fs,{children:(0,Me.jsx)(Am,{emptyState:r.emptyState})}),(0,Me.jsx)(lx,{children:(0,Me.jsx)(Pm,{})})]})})})}),n),{unmount(){(0,ut.unmountComponentAtNode)(n),n.remove()}}}setupHandlingTime(t){let n=zm(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){cI(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="17.0.0-rc.6",Va.count=0;var xc=Va;function o5(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 EI(e,t){return A(this,null,function*(){let n=yield o5(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 TI(e,t,n){return A(this,null,function*(){yield new lo(e).authenticateWithKey(t,n)})}function CI(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function kI(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 RI(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 jA=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(jA||{}),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(jA).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 VA(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!VA(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!VA(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&&UA(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 VF=["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 WA(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",VF.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 WA(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 KA(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 WF(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var cx=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()}},dx=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=KA(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()}},fx=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 dx(t,this.deepdeskUrl,{debug:!0}):new cx(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=WF(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)}},$A=fx;function KF(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),{[KF(n)]:$e(e[n])}),{}):e}function $F(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),{[$F(n)]:wt(e[n])}),{}):e}var Ba=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var px=e=>new Promise(t=>{setTimeout(t,e)});var Ua=class extends Ba{constructor(){super(...arguments);this.name="ClientError"}},gx=class extends Ba{constructor(){super(...arguments);this.name="ServerError"}},mx=new Map;function qF(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(mx.has(s)){r(mx.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 px(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 px(d),C();throw k}))});C().then(k=>A(this,null,function*(){let I=yield qF(k);if(delete this.latestRequestByUrl[s],k.status>=500){o(new gx("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&&mx.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 qA;(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={}))})(qA||(qA={}));function Mm(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 Mm(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/by_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}`),Mm(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/by_external_id/${t}/has_active_profile`,{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 Mm(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=>Mm(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(Mw);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 GA={startTime:null,stopTime:null},YA=e=>e.handlingTime,XA=Ce({name:"handlingTime",initialState:GA,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,()=>GA)}}),{handlingTimeStart:QA,handlingTimeStop:Nm,handlingTimeReset:ZA}=XA.actions,JA=XA.reducer;var eI=(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 _m={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 _m.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),GF=Ce({name:"styleSuggestions",initialState:_m,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=_m.list}).addCase(it,()=>_m)}}),tI=GF.reducer;var nI=(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 YF(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var rI=(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 YF(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 oI=os.fulfilled.toString();function XF(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 iI=e=>t=>n=>r=>{var u;if(r.type!==oI){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=XF(o,s);r.type===oI&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var QF=nf({assistants:gC,auth:sT,conversation:yT,contentTypes:yC,passwordlessToken:dA,entities:pR,handlingTime:JA,info:FT,input:AT,settings:JE,profile:SC,search:VT,styleSuggestions:tI,ui:AP,textSuggestions:mP});function sI(e){return oE({reducer:QF,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI}},serializableCheck:!1}),eI(),rI({debounce:200}),nI({debounce:500}),iI(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var ZF=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},JF=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 Nm.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:ZF(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},aI=JF;function hx(e){return e.toISOString().replace("T"," ").replace("Z","")}var e5=(e,t)=>t.version,lI=Un([aa,yr,YA,e5],(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:hx(o),timeStop:hx(i)}});function uI(e,t,n){var I,L,G,F;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:(F=t.info.agentInfo)==null?void 0:F.agentEmail}}function yx(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return yx(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?yx(o,t):null}function vx(e,t){return yx(e,t)}function cI(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function t5(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Dm(e){return t5(e)&&(Zi(e)||cm(e))}var fI,Rr=new Map,n5=["bottom","height","left","right","top","width"],dI=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:n5.some(n=>e[n]!==t[n]);function pI(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,...pI(t)]:[]}function mI(e,t){return!e||!t?null:P(b({},e),{top:e.top+t.top,left:e.left+t.left})}var Fm=!1,gI=()=>{Fm=!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();dI(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(mI,t.rect):t.rect;dI(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Rr.size===0){Fm=!1;return}fI=window.requestAnimationFrame(gI)};function xx(e,t){let n=pI(e),r=[],o=n.map((i,s)=>xx(i,a=>{r[s]=a;let l=Rr.get(e);if(!l)return;let u=r.reduce(mI,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&&!Fm&&gI()},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(fI),Fm=!1)}}}}var hI,Pr=new Map,yI=()=>{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&&(hI=window.requestAnimationFrame(yI))};function vI(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&&yI()},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(hI)}}}}var wx=["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 Sx(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function ja(e){return Number.parseFloat(e)}function Hm(e){return Math.round(e*1e6)}function xI(e){return e/1e6}function bx(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=xI(Hm(o)-Hm(i)-Hm(s)),u=xI(Hm(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};Sx(r,n,wx),bx(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=vI(e,()=>{Sx(r,n,wx),bx(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=xx(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(Sx(r,n,wx),bx(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 wI=(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 r5(e){return e.offsetParent!==null}function SI(e){if(!r5(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 zm(e,t,n=100){let r=SI(e);t({isVisible:r});let o=setInterval(()=>{let i=SI(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var Me=S(R());var bI=wI("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:[aI({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=>bI.update(c),sendEvent:(c,f)=>this.deepdeskApi.sendEvent(c,f)})]};this.store=sI(u),this.broadcastEvents=new $A({debug:!0,deepdeskUrl:l,eventMap:WT(this.store),createCustomChannel:a}),this.store.dispatch(ac(bI.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)&&eT(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(NT(t))}setCustomData(t){this.store.dispatch(_T(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({includeMetadata:!0},n))})}getSummary(){return A(this,arguments,function*(t={}){var r;if(!this.hasConversation())return ee.warn("No conversation to create summary for."),null;(r=this.state.profile.data)!=null&&r.summarizerAssistantNew||ee.warn("No profile loaded yet, or no summarizer assistant set in profile");let n=yield this.store.dispatch(Wn(t));if(n.error)throw new Error(n.error.message);return n.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(bT(iv(t))),!Tr(this.state)||t.key!=="Tab"&&!l)return;let f=()=>{n||!c||s&&(t.shiftKey||(this.store.dispatch(CT()),t.preventDefault()))},d=()=>{n||!c||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(kT()),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(RP(!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(QA()))}handlingTimeStop(){this.state.handlingTime.startTime&&(ee.info("Stop handling time"),this.store.dispatch(Nm()))}logSendMessage(t){let n=uI("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=lI(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(ZA()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(bi((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(PT()))}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(DT(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,ut.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,ut.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,ut.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(RT(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(!Dm(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(ET(iv(p)))}),this.inputMediator.on("keydown",p=>{this.handleKeyDown(p)}),this.inputMediator.on("paste",({pastedText:p,selectionText:y})=>{this.store.dispatch(TT({text:p,selectionText:y}))}),this.inputMediator.on("cut",({selectionText:p})=>{this.store.dispatch(ST(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,ut.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(FP,{})})}),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,ut.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&&vx(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,ut.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(lA,{inputElement:t})})}),a),(0,ut.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)($P,{onLogIn:()=>this.loginViaPopup().catch(u=>ee.warn(u.message))})})}),l),{unmount(){(0,ut.unmountComponentAtNode)(a),(0,ut.unmountComponentAtNode)(l),a.remove(),l.remove()}}}renderFloatingMenu(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:i,floatingMenuParent:s}=n,a=o&&vx(t,o)||void 0,l=this.overlayContainerFactory("floating-menu",a||t,{appendTo:s!=null?s:i},r==null?void 0:r.floatingMenuParent);return(0,ut.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(CP,{onLogIn:()=>this.loginViaPopup().catch(u=>ee.warn(u.message))})})}),l),{unmount(){(0,ut.unmountComponentAtNode)(l),l.remove()}}}renderOverlays(t){let{customStyles:n}=t,r=this.createContainer("deepdesk-overlays");return(0,ut.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:n,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(wP,{})})}),r),{unmount(){(0,ut.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,ut.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:r,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(BA,{assistantOptions:n.assistantOptions,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,ut.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}renderKnowledgeAssistantWidget(t,n,r={}){let{customStyles:o,initialQuestion:i}=r;return(0,ut.render)((0,Me.jsx)(Yo,{store:this.store,customStyles:o,children:(0,Me.jsx)(Bo,{broadcastEvents:this.broadcastEvents,children:(0,Me.jsx)(ux,{children:(0,Me.jsxs)(Rm,{assistantCode:t,initialQuestion:i,evaluateKnowledgeAssistFn:r.isLegacyKnowledgeAssist?Ci:ki,children:[(0,Me.jsx)(fs,{children:(0,Me.jsx)(Am,{emptyState:r.emptyState})}),(0,Me.jsx)(lx,{children:(0,Me.jsx)(Pm,{})})]})})})}),n),{unmount(){(0,ut.unmountComponentAtNode)(n),n.remove()}}}setupHandlingTime(t){let n=zm(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){cI(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="17.0.0-rc.7",Va.count=0;var xc=Va;function o5(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 EI(e,t){return A(this,null,function*(){let n=yield o5(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 TI(e,t,n){return A(this,null,function*(){yield new lo(e).authenticateWithKey(t,n)})}function CI(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function kI(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 RI(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 i5(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 s5(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 PI(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):PI(n,t)}function AI(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?i5(t):s5(t);n?PI(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 VI(a5);})();
|
|
86
86
|
/*! Bundled license information:
|