@deepdesk/deepdesk-sdk 17.0.0-rc.12 → 17.0.0-rc.13
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 +2 -2
- package/dist/index.d.mts +6 -16
- package/dist/index.d.ts +6 -16
- package/dist/index.esm.js +2 -2
- package/dist/index.iife.js +2 -2
- package/package.json +1 -1
- package/styles/index.js +1 -1
- package/styles.css +1 -1
- package/widget.css +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -12,7 +12,7 @@ ${be.current.stack}
|
|
|
12
12
|
`),Q}cf(()=>{be.current=void 0,H.current=void 0,$.current=Ce});let rt=le.useMemo(()=>le.createElement(x,P(S({},Ce),{ref:F})),[F,x,Ce]);return le.useMemo(()=>v?le.createElement(O.Provider,{value:G},rt):rt,[O,rt,G])}let C=le.memo(w);if(C.WrappedComponent=x,C.displayName=w.displayName=g,l){let A=le.forwardRef(function(N,O){return le.createElement(C,P(S({},N),{reactReduxForwardedRef:O}))});return A.displayName=g,A.WrappedComponent=x,fy(A,x)}return fy(C,x)}}var oa=PN;function AN(e){let{children:t,context:n,serverState:r,store:o}=e,i=le.useMemo(()=>{let l=t1(o);return{store:o,subscription:l,getServerState:r?()=>r:void 0}},[o,r]),s=le.useMemo(()=>o.getState(),[o]);return cf(()=>{let{subscription:l}=i;return l.onStateChange=l.notifyNestedSubs,l.trySubscribe(),s!==o.getState()&&l.notifyNestedSubs(),()=>{l.tryUnsubscribe(),l.onStateChange=void 0}},[i,s]),le.createElement((n||eo).Provider,{value:i},t)}var r1=AN;function gy(e=eo){return function(){return le.useContext(e)}}var o1=gy();function i1(e=eo){let t=e===eo?o1:gy(e),n=()=>{let{store:r}=t();return r};return Object.assign(n,{withTypes:()=>n}),n}var IN=i1();function LN(e=eo){let t=e===eo?IN:i1(e),n=()=>t().dispatch;return Object.assign(n,{withTypes:()=>n}),n}var ve=LN(),_N=(e,t)=>e===t;function ON(e=eo){let t=e===eo?o1:gy(e),n=(r,o={})=>{let{equalityFn:i=_N}=typeof o=="function"?{equalityFn:o}:o,s=t(),{store:a,subscription:l,getServerState:c}=s,u=le.useRef(!0),d=le.useCallback({[r.name](p){return r(p)}}[r.name],[r]),f=(0,s1.useSyncExternalStoreWithSelector)(l.addNestedSub,a.getState,c||a.getState,d,i);return le.useDebugValue(f),f};return Object.assign(n,{withTypes:()=>n}),n}var j=ON();var Kl=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(Kl||{});var NN={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},a1=ke({name:"settings",initialState:NN,reducers:{set(e,t){Object.entries(t.payload).forEach(n=>{let[r,o]=n;typeof o!="undefined"&&(e[r]=o)})}}}),{set:uf}=a1.actions,Gl=e=>t=>t.settings[e],te=e=>j(Gl(e)),l1=a1.reducer;var MN={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},$t=e=>e.auth.isLoggedIn,c1=e=>e.auth.loginFetchState,u1=e=>e.auth.verifyFetchState,d1=e=>e.auth.showLoginOverlay,to=ge("auth/validate",(e,t)=>I(void 0,null,function*(){return t.extra.deepdeskAPI.isLoggedIn()})),f1=ge("auth/requestLogin",(n,r)=>I(void 0,[n,r],function*({email:e},t){let{deepdeskAPI:o}=t.extra;return o.requestLoginByEmail(e)})),ql=ge("auth/verifyLoginToken",(n,r)=>I(void 0,[n,r],function*({token:e},t){let{deepdeskAPI:o}=t.extra;return o.verifyLoginToken(e)})),p1=ke({name:"auth",initialState:MN,reducers:{setIsLoggedIn(e,t){e.isLoggedIn=t.payload},setShowLoginOverlay(e,t){e.showLoginOverlay=t.payload}},extraReducers:e=>{e.addCase(to.pending,t=>{t.loginFetchState="loading"}),e.addCase(to.fulfilled,(t,{payload:n})=>{t.isLoggedIn=n,t.loginFetchState="done"}),e.addCase(to.rejected,t=>{t.loginFetchState="error",t.isLoggedIn=!1}),e.addCase(ql.pending,t=>{t.verifyFetchState="loading"}),e.addCase(ql.rejected,t=>{t.verifyFetchState="error"}),e.addCase(ql.fulfilled,(t,n)=>{n.payload.isLoggedIn?t.verifyFetchState="done":t.verifyFetchState="error"})}}),{setIsLoggedIn:ia,setShowLoginOverlay:m1}=p1.actions,g1=p1.reducer;function no(){}no.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,c=t.length,u=1,d=l+c;o.maxEditLength&&(d=Math.min(d,o.maxEditLength));var f=(r=o.timeout)!==null&&r!==void 0?r:1/0,p=Date.now()+f,v=[{oldPos:-1,lastComponent:void 0}],m=this.extractCommon(v[0],n,t,0);if(v[0].oldPos+1>=c&&m+1>=l)return a([{value:this.join(n),count:n.length}]);var x=-1/0,y=1/0;function g(){for(var w=Math.max(x,-u);w<=Math.min(y,u);w+=2){var E=void 0,C=v[w-1],k=v[w+1];C&&(v[w-1]=void 0);var A=!1;if(k){var F=k.oldPos-w;A=k&&0<=F&&F<l}var N=C&&C.oldPos+1<c;if(!A&&!N){v[w]=void 0;continue}if(!N||A&&C.oldPos+1<k.oldPos?E=s.addToPath(k,!0,void 0,0):E=s.addToPath(C,void 0,!0,1),m=s.extractCommon(E,n,t,w),E.oldPos+1>=c&&m+1>=l)return a(DN(s,E.lastComponent,n,t,s.useLongestToken));v[w]=E,E.oldPos+1>=c&&(y=Math.min(y,w-1)),m+1>=l&&(x=Math.max(x,w+1))}u++}if(i)(function w(){setTimeout(function(){if(u>d||Date.now()>p)return i();g()||w()},0)})();else for(;u<=d&&Date.now()<=p;){var h=g();if(h)return h}},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,c=0;l+1<i&&a+1<s&&this.equals(n[l+1],r[a+1]);)l++,a++,c++;return c&&(t.lastComponent={count:c,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 DN(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,c=0,u=0;a<l;a++){var d=i[a];if(d.removed){if(d.value=e.join(r.slice(u,u+d.count)),u+=d.count,a&&i[a-1].added){var p=i[a-1];i[a-1]=i[a],i[a]=p}}else{if(!d.added&&o){var f=n.slice(c,c+d.count);f=f.map(function(m,x){var y=r[u+x];return y.length>m.length?y:m}),d.value=e.join(f)}else d.value=e.join(n.slice(c,c+d.count));c+=d.count,d.added||(u+=d.count)}}var v=i[l-1];return l>1&&typeof v.value=="string"&&(v.added||v.removed)&&e.equals("",v.value)&&(i[l-2].value+=v.value,i.pop()),i}var FN=new no;function v1(e,t,n){return FN.diff(e,t,n)}var h1=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,y1=/\S/,x1=new no;x1.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!y1.test(e)&&!y1.test(t)};x1.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]&&h1.test(t[n])&&h1.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var w1=new no;w1.tokenize=function(e){this.options.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
13
13
|
`));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 zN=new no;zN.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var HN=new no;HN.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function df(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?df=function(t){return typeof t}:df=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},df(e)}var BN=Object.prototype.toString,Yl=new no;Yl.useLongestToken=!0;Yl.tokenize=w1.tokenize;Yl.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(hy(e,null,null,o),o," ")};Yl.equals=function(e,t){return no.prototype.equals.call(Yl,e.replace(/,([\r\n])/g,"$1"),t.replace(/,([\r\n])/g,"$1"))};function hy(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(BN.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]=hy(e[i],t,n,r,o);return t.pop(),n.pop(),s}if(e&&e.toJSON&&(e=e.toJSON()),df(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]=hy(e[l],t,n,r,l);t.pop(),n.pop()}else s=e;return s}var yy=new no;yy.tokenize=function(e){return e.slice()};yy.join=yy.removeEmpty=function(e){return e};function S1(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function Yo(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)=>Yo(i,t[s],n-1)):S1(e)&&S1(t)?Object.keys(e).length!==Object.keys(t).length?!1:Object.keys(e).every(s=>Yo(e[s],t[s],n-1)):!1}function UN(e){return Math.max(...e.map(t=>t.length))}function VN(e,t){let n=e.reduce((r,o)=>{if(o){let i=r[o]?r[o]+1:1;return P(S({},r),{[o]:i})}return r},{});return Object.keys(n).reduce((r,o)=>(n[o]<t&&r.push(o),r),[])}function b1(e,t){let r=[...e.map(({text:o})=>o.split(/\b(\w+)\b/))];for(let o=0;o<UN(r);o++){let i=VN(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 $N=2;function E1(e,t=""){if(e.length===0)return;if(e.length===1)return e[0];let n=b1(e,$N);return n&&n.text!==t?n:e[0]}var jN={info(...e){console.info("[Deepdesk]",...e)},warn(...e){console.warn("[Deepdesk]",...e)},error(...e){console.error("[Deepdesk]",...e)}},J=jN;var T1={current:null,isSupported:null},at=st("resetConversation"),C1=e=>{let{current:t}=e.conversation;return(t==null?void 0:t.externalId)||null},Rr=e=>{let{current:t}=e.conversation;return(t==null?void 0:t.id)||null},sa=e=>e.conversation.isSupported,vy=ge("conversation/isSupported",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.isConversationSupported(e.externalId,e.options)}),ff=ge("conversation/create",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.createConversation(e)}),pf=ge("conversation/byExternalId",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.getConversationByExternalId(e.externalId,e.options)}),mf=ge("conversation/update",(e,t)=>{let{deepdeskAPI:n}=t.extra,r=Rr(t.getState());if(!r)throw new Error("No current conversation to update");return n.updateConversation(r,e)}),xy=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})})}),wy=ge("conversation/postMessages",(e,t)=>{let{deepdeskAPI:n}=t.extra,r=Rr(t.getState());if(!r)throw new Error("No current conversation to update messages");return n.postMessages(r,e.map(o=>S({},o)))}),WN=[ff.rejected,pf.rejected,mf.rejected,wy.rejected].map(e=>e==null?void 0:e.toString());function KN(e){return WN.includes(e.type)}var GN=ke({name:"conversation",initialState:T1,reducers:{},extraReducers:e=>{e.addCase(vy.fulfilled,(t,n)=>{t.isSupported=n.payload}).addCase(ff.fulfilled,(t,n)=>{var r;t.current=n.payload,t.isSupported=!!((r=n.payload)!=null&&r.profileCode)}).addCase(pf.fulfilled,(t,n)=>{var r;t.current=n.payload,t.isSupported=!!((r=n.payload)!=null&&r.profileCode)}).addCase(xy.fulfilled,(t,n)=>{var r;t.current=n.payload,t.isSupported=!!((r=n.payload)!=null&&r.profileCode)}).addCase(mf.fulfilled,(t,n)=>{var r;t.current=n.payload,t.isSupported=!!((r=n.payload)!=null&&r.profileCode)}).addCase(at,()=>T1).addMatcher(KN,(t,n)=>{var r;throw J.info("Conversation action rejected",n.type,((r=n.error)==null?void 0:r.message)||"No message"),new Error(n.error.message)})}}),k1=GN.reducer;var Mi={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 Sy(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 gf=st("input/replaceText"),Di=st("input/sendMessage"),hf=st("input/applyImageSuggestion"),ro=st("input/sendEvent"),R1=ke({name:"input",initialState:Mi,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=Mi.metrics,e.textSuggestions=[],e.mixedSuggestion=null;else if(n!==null&&e.text!==n.text){let{key:a,shiftKey:l,ctrlKey:c,metaKey:u,altKey:d}=n.keyDown;switch(a){case"Enter":l&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:f}=e,p=v1(n.text,f);n.text.length-f.length>1&&e.metrics.deletions.push(...p.filter(v=>v.removed).map(v=>v.value)),e.metrics.numCharsDeleted+=n.text.length-f.length;break}case"Shift":case"Meta":case"Tab":break;case"C":case"V":case"X":case"c":case"v":case"x":if(c||u)break;default:if(!c&&!u&&!d){e.metrics.numCharsTyped+=1;let f=((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;f&&f.length>0&&(e.metrics.numCharsDeleted+=f.length,e.metrics.deletions.push(f))}}e.metrics.agentStartedTypingTimestamp||(e.metrics.agentStartedTypingTimestamp=Date.now())}e.beforeInputChange=null},setSelection(e,t){t.payload!==null&&(Yo(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:c,text:u},eventMetrics:{inputType:d},replace:f}=n,p=o==="search"||o==="personal-collection-search",v=r.slice(e.text.substring(0,e.selection.start).length);(p||f==="selection")&&(v=r),n.suggestion.source==="search-overlay"&&(v=u),e.metrics.textSuggestions.push({text:v,source:o,abVariant:i,abTestName:s,inputType:d,sourceText:l,trainingJobs:a||[],searchTerm:p?e.text:c}),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(S({},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(S({},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=E1(t.payload,n);e.mixedSuggestion=r!=null&&r.text.includes(n)?r:null},setMetrics(e,{payload:t}){e.metrics=t},resetMetrics(e){e.metrics=Mi.metrics}},extraReducers:e=>{e.addCase(at,t=>{t.mixedSuggestion=Mi.mixedSuggestion,t.textSuggestions=Mi.textSuggestions,t.selectedSuggestionIndex=Mi.selectedSuggestionIndex,t.metrics=Mi.metrics})}}),aa=e=>e.input.text.substring(0,e.input.selection.end),qN=e=>e.input.selection,la=e=>{let{mixedSuggestion:t,selectedSuggestionIndex:n,textSuggestions:r}=e.input;return n>-1?r[n]:t},P1=()=>j(qN),{commitSuggestion:er,offeredTextSuggestion:A1,registerCut:I1,registerKeyDown:L1,registerKeyUp:_1,registerPaste:O1,selectNextTextSuggestion:N1,selectPreviousTextSuggestion:M1,selectTextSuggestionByIndex:yf,setInput:vf,setMetrics:D1,setSelection:xf,setTextSuggestions:Xo,resetMetrics:F1}=R1.actions,z1=R1.reducer;function H1(e){try{return Intl.DateTimeFormat(void 0,{timeZone:e}),!0}catch(t){return!1}}var YN={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,platformVariables:void 0,fetchState:"idle"},ca=e=>{var t;return(t=e.info.agentInfo)!=null?t:null},B1=e=>{var t;return(t=e.info.visitorInfo)!=null?t:null},U1=e=>{var t;return(t=e.info.customData)!=null?t:null},Ql=({info:{visitorInfo:e,agentInfo:t}})=>{var n,r;return{timezone:e!=null&&e.visitorTimeZone&&H1(e.visitorTimeZone)?e.visitorTimeZone:$x,agentName:(n=t==null?void 0:t.agentNickname)!=null?n:"",visitorName:(r=e==null?void 0:e.visitorName)!=null?r:""}},XN=[["agentNickname","nickname"],["agentDefaultLocale","defaultLocale"],["agentEmail","email"]],Xl=ge("info/setAgentInfo",(e,t)=>I(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=XN.reduce((c,[u,d])=>!r[d]&&u in e?P(S({},c),{[d]:e[u]}):c,{});Object.keys(l).length>0&&o.push(n.patchMe(l).then(c=>r=c))}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}})),by=ge("info/setAgentSettings",(e,t)=>I(void 0,null,function*(){let{deepdeskAPI:n}=t.extra,r=yield n.getMe(),o=S(S({},typeof r.uiConfig=="object"?r.uiConfig:{}),e);return yield n.patchMe({uiConfig:o}),o})),Ey=ge("info/getAgentSettings",(e,t)=>I(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return(yield n.getMe()).uiConfig})),V1=ke({name:"info",initialState:YN,reducers:{setVisitorInfo(e,t){e.visitorInfo=S(S({},e.visitorInfo),t.payload)},setCustomData(e,t){e.customData=t.payload},setPlatformVariables(e,t){e.platformVariables=t.payload}},extraReducers:e=>{e.addCase(Xl.pending,(t,n)=>{t.fetchState="loading",t.agentInfo=S(S({},t.agentInfo),n.meta.arg)}).addCase(Xl.rejected,t=>{t.fetchState="error"}).addCase(Xl.fulfilled,(t,n)=>{t.fetchState="done",t.agentInfo=n.payload}).addCase(by.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(Ey.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(at,t=>{t.visitorInfo=void 0})}}),{setVisitorInfo:$1,setCustomData:j1,setPlatformVariables:W1}=V1.actions,K1=V1.reducer;function cn(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:{}},G1=e=>e.search.isOpen,q1=e=>e.search.page,Ty=e=>e.search.list,Y1=e=>e.search.aggregates,QN=Dn([Ty,(e,t)=>t],(e,t)=>e.filter(n=>n.type===t)),X1=e=>t=>QN(t,e),Fi=ge("search/getAll",(e,t)=>I(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:Ql(r)});return{results:s.map(c=>P(S(S({},c),c.title&&i?{title:cn(c.title,i)}:{}),{text:cn(c.text,i!=null?i:{}),source:`search-${c.type.toLowerCase()}`,searchTerm:e.query})),aggregates:a}})),Q1=ke({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(Fi.pending,t=>{t.fetchState="loading"}).addCase(Fi.rejected,(t,n)=>{t.fetchState="error",J.error(n.error)}).addCase(Fi.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload.results,t.aggregates=n.payload.aggregates||{}}).addCase(at,()=>wf)}}),{resetSearch:Sf,setIsOpen:Fn,setPage:oo}=Q1.actions,Z1=Q1.reducer;var Cy="SetOutputs",ua="ShowLoginOverlay",Zl="UserLoggedIn",ZN="UserLoggedOut",Pr="ApplySuggestion",ky="ApplyImageSuggestion",JN="ShowCommandPalette",eM=e=>({[Cy]:t=>{e.dispatch(P(S({},t),{isBroadcasted:!0}))},[JN]:t=>{e.dispatch(Fn(t.isOpen)),t.page&&e.dispatch(oo(t.page))},[ua]:t=>{e.dispatch(m1(t))},[Zl]:()=>{e.dispatch(to())},[ZN]:()=>{e.dispatch(to())},[ky]:t=>{e.dispatch(hf({suggestion:t.suggestion}))},[Pr]:t=>{e.dispatch(er(P(S({},t),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),J1=eM;var Jl=b(Z()),tT=b(R()),eT=Jl.default.createContext(null),Qo=({broadcastEvents:e,children:t})=>{let n=Jl.default.useMemo(()=>e,[]);return(0,tT.jsx)(eT.Provider,{value:n,children:t})},un=()=>{let e=(0,Jl.useContext)(eT);if(!e)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return e};var _f=b(Ne()),tr=b(Z());var Af=b(Z());var Ry=function(e,t){return Ry=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])},Ry(e,t)};function ec(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Ry(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var En=function(){return En=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},En.apply(this,arguments)};function nT(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 bf(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 Ef(e,t){var n=t&&t.cache?t.cache:aM,r=t&&t.serializer?t.serializer:iM,o=t&&t.strategy?t.strategy:nM;return o(e,{cache:n,serializer:r})}function tM(e){return e==null||typeof e=="number"||typeof e=="boolean"}function rT(e,t,n,r){var o=tM(r)?r:n(r),i=t.get(o);return typeof i=="undefined"&&(i=e.call(this,r),t.set(o,i)),i}function oT(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 Py(e,t,n,r,o){return n.bind(t,e,r,o)}function nM(e,t){var n=e.length===1?rT:oT;return Py(e,this,n,t.cache.create(),t.serializer)}function rM(e,t){return Py(e,this,oT,t.cache.create(),t.serializer)}function oM(e,t){return Py(e,this,rT,t.cache.create(),t.serializer)}var iM=function(){return JSON.stringify(arguments)},sM=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}(),aM={create:function(){return new sM}},Tf={variadic:rM,monadic:oM};var Cf;(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"})(Cf||(Cf={}));var kf=class{constructor(t){console.warn(`[vite-messages-plugin]: Message "${t}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var zn;(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"})(zn||(zn={}));var Rf;(function(e){e[e.number=0]="number",e[e.dateTime=1]="dateTime"})(Rf||(Rf={}));function Ay(e){return e.type===zn.literal}function Iy(e){return e.type===zn.argument}function tc(e){return e.type===zn.number}function nc(e){return e.type===zn.date}function rc(e){return e.type===zn.time}function oc(e){return e.type===zn.select}function ic(e){return e.type===zn.plural}function iT(e){return e.type===zn.pound}function sc(e){return e.type===zn.tag}function Pf(e){return!!(e&&typeof e=="object"&&e.type===Rf.number)}function ac(e){return!!(e&&typeof e=="object"&&e.type===Rf.dateTime)}function Ly(e){e.forEach(function(t){if(delete t.location,oc(t)||ic(t))for(var n in t.options)delete t.options[n].location,Ly(t.options[n].value);else tc(t)&&Pf(t.style)||(nc(t)||rc(t))&&ac(t.style)?delete t.style.location:sc(t)&&Ly(t.children)})}function sT(e,t){t===void 0&&(t={}),t=En({shouldParseSkeletons:!0,requiresOtherClause:!0},t);var n=new kf(e,t).parse();if(n.err){var r=SyntaxError(Cf[n.err.kind]);throw r.location=n.err.location,r.originalMessage=n.err.message,r}return t!=null&&t.captureLocation||Ly(n.val),n.val}var zi;(function(e){e.MISSING_VALUE="MISSING_VALUE",e.INVALID_VALUE="INVALID_VALUE",e.MISSING_INTL_API="MISSING_INTL_API"})(zi||(zi={}));var lc=function(e){ec(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 _y=function(e){ec(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('", "'),'"'),zi.INVALID_VALUE,i)||this}return t}(lc);var aT=function(e){ec(t,e);function t(n,r,o){return e.call(this,'Value for "'.concat(n,'" must be of type ').concat(r),zi.INVALID_VALUE,o)||this}return t}(lc);var lT=function(e){ec(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,'"'),zi.MISSING_VALUE,r)||this}return t}(lc);var Ot;(function(e){e[e.literal=0]="literal",e[e.object=1]="object"})(Ot||(Ot={}));function lM(e){return e.length<2?e:e.reduce(function(t,n){var r=t[t.length-1];return!r||r.type!==Ot.literal||n.type!==Ot.literal?t.push(n):r.value+=n.value,t},[])}function cM(e){return typeof e=="function"}function cc(e,t,n,r,o,i,s){if(e.length===1&&Ay(e[0]))return[{type:Ot.literal,value:e[0].value}];for(var a=[],l=0,c=e;l<c.length;l++){var u=c[l];if(Ay(u)){a.push({type:Ot.literal,value:u.value});continue}if(iT(u)){typeof i=="number"&&a.push({type:Ot.literal,value:n.getNumberFormat(t).format(i)});continue}var d=u.value;if(!(o&&d in o))throw new lT(d,s);var f=o[d];if(Iy(u)){(!f||typeof f=="string"||typeof f=="number")&&(f=typeof f=="string"||typeof f=="number"?String(f):""),a.push({type:typeof f=="string"?Ot.literal:Ot.object,value:f});continue}if(nc(u)){var p=typeof u.style=="string"?r.date[u.style]:ac(u.style)?u.style.parsedOptions:void 0;a.push({type:Ot.literal,value:n.getDateTimeFormat(t,p).format(f)});continue}if(rc(u)){var p=typeof u.style=="string"?r.time[u.style]:ac(u.style)?u.style.parsedOptions:r.time.medium;a.push({type:Ot.literal,value:n.getDateTimeFormat(t,p).format(f)});continue}if(tc(u)){var p=typeof u.style=="string"?r.number[u.style]:Pf(u.style)?u.style.parsedOptions:void 0;p&&p.scale&&(f=f*(p.scale||1)),a.push({type:Ot.literal,value:n.getNumberFormat(t,p).format(f)});continue}if(sc(u)){var v=u.children,m=u.value,x=o[m];if(!cM(x))throw new aT(m,"function",s);var y=cc(v,t,n,r,o,i),g=x(y.map(function(E){return E.value}));Array.isArray(g)||(g=[g]),a.push.apply(a,g.map(function(E){return{type:typeof E=="string"?Ot.literal:Ot.object,value:E}}))}if(oc(u)){var h=u.options[f]||u.options.other;if(!h)throw new _y(u.value,f,Object.keys(u.options),s);a.push.apply(a,cc(h.value,t,n,r,o));continue}if(ic(u)){var h=u.options["=".concat(f)];if(!h){if(!Intl.PluralRules)throw new lc(`Intl.PluralRules is not available in this environment.
|
|
14
14
|
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
15
|
-
`,zi.MISSING_INTL_API,s);var w=n.getPluralRules(t,{type:u.pluralType}).select(f-(u.offset||0));h=u.options[w]||u.options.other}if(!h)throw new _y(u.value,f,Object.keys(u.options),s);a.push.apply(a,cc(h.value,t,n,r,o,f-(u.offset||0)));continue}}return lM(a)}function uM(e,t){return t?En(En(En({},e||{}),t||{}),Object.keys(e).reduce(function(n,r){return n[r]=En(En({},e[r]),t[r]||{}),n},{})):e}function dM(e,t){return t?Object.keys(e).reduce(function(n,r){return n[r]=uM(e[r],t[r]),n},En({},e)):e}function Oy(e){return{create:function(){return{get:function(t){return e[t]},set:function(t,n){e[t]=n}}}}}function fM(e){return e===void 0&&(e={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Ef(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.NumberFormat).bind.apply(t,bf([void 0],n,!1)))},{cache:Oy(e.number),strategy:Tf.variadic}),getDateTimeFormat:Ef(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.DateTimeFormat).bind.apply(t,bf([void 0],n,!1)))},{cache:Oy(e.dateTime),strategy:Tf.variadic}),getPluralRules:Ef(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.PluralRules).bind.apply(t,bf([void 0],n,!1)))},{cache:Oy(e.pluralRules),strategy:Tf.variadic})}}var Ny=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(c){var u=i.formatToParts(c);if(u.length===1)return u[0].value;var d=u.reduce(function(f,p){return!f.length||p.type!==Ot.literal||typeof f[f.length-1]!="string"?f.push(p.value):f[f.length-1]+=p.value,f},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return cc(i.ast,i.locales,i.formatters,i.formats,c,void 0,i.message)},this.resolvedOptions=function(){var c;return{locale:((c=i.resolvedLocale)===null||c===void 0?void 0:c.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=nT(s,["formatters"]);this.ast=e.__parse(t,En(En({},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=dM(e.formats,r),this.formatters=o&&o.formatters||fM(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=sT,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 pM(e,t){return t.split(".").reduce((n,r)=>n?n[r]:void 0,e)}var mM="dummy",My=(0,Af.createContext)(null);function ue(e){var r;let t=(0,Af.useContext)(My);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=pM(n,o);return s?new Ny(s).format(i):(t!==mM&&console.warn(`${o} does not exist in messages of ${t}`),`[${o}]`)}}var If=b(Z());var cT={root:"dd-tvkOF",content:"dd-eXA1D"};var Dy=b(R()),gM=({isOpen:e,autoFocus:t,children:n,onClose:r,onBack:o,onKeyDown:i,overlayAriaLabel:s,contentAriaLabel:a})=>{let l=(0,If.useRef)(null),c=M("Dialog",cT),u=f=>{if(f.key==="Escape"){f.preventDefault(),f.stopPropagation(),o();return}i&&i(f)},d=f=>{f.target===l.current&&e&&r()};return(0,If.useEffect)(()=>{var f,p;!l.current||!e||!t||(p=(f=l.current)==null?void 0:f.querySelector("input, textarea"))==null||p.focus()},[e,t,l]),e?(0,Dy.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":s,ref:l,onKeyDown:u,onMouseDown:d,children:(0,Dy.jsx)("div",{"data-testid":"dialog-content",className:c.content,"aria-label":a,children:n})}):null},Lf=gM;var dT=b(Ne());var uT={root:"dd-ranhW"};var fT=b(R()),hM=r=>{var o=r,{className:e,value:t}=o,n=oe(o,["className","value"]);let i=M("TextInput",uT);return(0,fT.jsx)("input",S({className:(0,dT.default)(e,i.root),type:"text",value:t},n))},uc=hM;var Fy={};Rt(Fy,{enUS:()=>yM,nlNL:()=>vM});var yM={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"}]},vM={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 pT={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 tt=b(R());var xM=e=>{try{let t=new URL(e);return new URLSearchParams(t.search).get("token")||void 0}catch(t){return e}},wM=({agentEmail:e,isOpen:t,origin:n="",onSuccess:r,onDismiss:o})=>{let i=ue(Fy),s=M("LoginTokenDialog",pT),a=j(u1),l=ve(),c=te("productName"),[u,d]=(0,tr.useState)(e||""),[f,p]=(0,tr.useState)(0),[v,m]=(0,tr.useState)(""),x=(0,tr.useCallback)(w=>I(void 0,null,function*(){w.preventDefault(),l(f1({email:u})),p(1)}),[n,u]),y=()=>{m(""),p(0)},g=(0,tr.useCallback)(w=>I(void 0,null,function*(){w.preventDefault();let E=xM(w.target.elements.token.value);if(!E){m(i("verifyCodeError",{login:h}));return}l(ql({token:E}))}),[n]),h=(0,tr.useMemo)(()=>w=>(0,tt.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:s.anchorButton,onClick:y,children:w},"back-button"),[]);return(0,tr.useEffect)(()=>{a==="error"&&m(i("verifyCodeError",{login:h})),a==="done"&&r()},[a]),(0,tt.jsx)(Lf,{autoFocus:!0,isOpen:t,contentAriaLabel:i("promptTitle",{productName:c}),overlayAriaLabel:i("promptTitle",{productName:c}),onClose:o,onBack:o,children:(0,tt.jsxs)("div",{className:s.root,children:[(0,tt.jsx)("h1",{className:s.title,children:i("promptTitle",{productName:c})}),f===0&&(0,tt.jsxs)("form",{onSubmit:x,children:[(0,tt.jsx)("h2",{className:s.subtitle,children:i("requestCodeTitle")}),(0,tt.jsx)("p",{className:s.text,children:i("requestCodeBody",{productName:c})}),(0,tt.jsx)(uc,{className:s.input,name:"email",placeholder:i("requestCodeInputPlaceholder"),value:u,onChange:w=>d(w.target.value)}),(0,tt.jsx)("div",{className:s.actions,children:(0,tt.jsx)("button",{type:"submit",className:(0,_f.default)(s.button,s.primaryButton),children:i("requestCodeSubmitLabel")})})]}),f===1&&(0,tt.jsxs)("form",{onSubmit:g,children:[(0,tt.jsx)("h2",{className:s.subtitle,children:i("verifyCodeTitle")}),(0,tt.jsx)("p",{className:s.text,children:i("verifyCodeBody")}),(0,tt.jsx)(uc,{className:s.input,name:"token",placeholder:i("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),v&&(0,tt.jsx)("div",{className:s.errorMessage,children:v}),(0,tt.jsxs)("div",{className:s.actions,children:[(0,tt.jsx)("button",{type:"button",className:(0,_f.default)(s.button),onClick:y,children:i("back")}),(0,tt.jsx)("button",{type:"submit",className:(0,_f.default)(s.button,s.primaryButton),disabled:["loading","done"].includes(a),children:i("verifyCodeSubmitLabel")})]})]})]})})},mT=wM;var hT=b(R()),SM=()=>{let e=j(d1),t=j(ca),n=te("adminUrl"),r=un(),o=()=>r.send(ua,!1),i=()=>{r.send(ua,!1),r.send(Zl)};return(0,hT.jsx)(mT,{isOpen:e,agentEmail:t==null?void 0:t.agentEmail,origin:n,onDismiss:o,onSuccess:i})},gT=SM;var CR=b(By()),Xt=b(Z());var dc="__summarizerAssistant__",wT={cues:[],threads:{},pending:[]},ST=e=>{var t;return(t=e.assistants)==null?void 0:t.cues};var fc=e=>t=>{var n,r;return(r=(n=t.assistants)==null?void 0:n.threads[e])!=null?r:null},Of=st("assistants/callToAction"),io=ge("assistants/evaluateSummaryAssistant",(e,t)=>I(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(nr(S({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 J.warn("Unexpected summary output",i),new Error("Unexpected summary output");return i.payload})),HM=1,Hi=ge("assistants/evaluateKnowledgeAssistantLegacy",(e,t)=>I(void 0,null,function*(){var p,v,m,x;let{threadId:n}=e,{onNewThreadId:r,input:o}=e,{deepdeskAPI:i}=t.extra,s=t.getState(),{platformVariables:a}=s.info;n||(n=HM++,r&&r(n));let l=(p=fc(n)(s))!=null?p:[],c=yield i.getKnowledgeAssistant(e.assistantCode),u=(v=s.conversation.current)==null?void 0:v.externalId,d=(x=(m=s.info)==null?void 0:m.agentInfo)==null?void 0:x.agentId;if(!c)throw new Error("KnowledgeAssistant is not found");let f=yield i.knowledgeAssist({customerInstruction:c.customerInstruction,doNotKnowAnswer:c.doNotKnowAnswer,question:o},l,c.code,{agentId:d,conversationId:u});return a&&(f.answer=cn(f.answer,a)),{threadId:n,question:o,answer:f}})),Bi=ge("assistants/evaluateKnowledgeAssistant",(e,t)=>I(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(nr(P(S({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:cn(l.response,s!=null?s:{}),sources:l.sources}}})),nr=ge("assistants/evaluate",(e,t)=>I(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:c}=l.info,u=(p=l.conversation.current)==null?void 0:p.externalId,d;if(o==="in-memory-transcript"){if(!r.conversationQuery)throw new Error("Can't include in-memory-transcript, setConversationQuery is not defined");d=yield r.conversationQuery()}else Array.isArray(o)&&(d=o);if(e.includeMetadata){if(!l.conversation.current)throw new Error("Can't include metadata, no current conversation");let{metadata:v}=l.conversation.current;Object.assign(i,{metadata:v})}let f=yield n.evaluateAssistant(e.assistantCode,{expectFormat:s,input:i,transcript:d,externalConversationId:u,threadId:a});switch(s){case"text":return cn(f,c);case"json-schema:cues":return Array.isArray(f)?f.map(v=>P(S({},v),{name:cn(v.name,c),response:cn(v.response,c)})):[];case"json-schema:knowledge-assist":{let v=f;return P(S({},v),{answer:cn(v.response,c)})}default:return f}})),bT=ke({name:"assistants",initialState:wT,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(nr.pending,(t,n)=>{t.pending.includes(n.meta.arg.assistantCode)&&J.warn(`Assistant ${n.meta.arg.assistantCode} already evaluating`),t.pending.push(n.meta.arg.assistantCode)}).addCase(nr.rejected,(t,n)=>{var o;J.warn((o=n.error)==null?void 0:o.message);let r=t.pending.indexOf(n.meta.arg.assistantCode);r!==-1&&t.pending.splice(r,1)}).addCase(nr.fulfilled,(t,n)=>{let r=t.pending.indexOf(n.meta.arg.assistantCode);if(r!==-1&&t.pending.splice(r,1),!n.meta.arg.skipState)switch(n.meta.arg.expectFormat){case"json-schema:cues":{let o=n.payload,i=o.map(a=>a.code),s=t.cues.filter(a=>!i.includes(a.code));t.cues=[...s,...o];break}}}).addCase(Bi.fulfilled,(t,n)=>{let i=n.payload,{threadId:r}=i,o=oe(i,["threadId"]);t.threads[r]=[...t.threads[r]||[],o]}).addCase(Hi.fulfilled,(t,n)=>{let i=n.payload,{threadId:r}=i,o=oe(i,["threadId"]);t.threads[r]=[...t.threads[r]||[],o]}).addCase(io.pending,t=>{let n={code:dc,name:"Summary",response:"",isLoading:!0},r=t.cues.filter(o=>o.code!==dc);t.cues=[...r,n]}).addCase(io.rejected,t=>{let n=t.cues.filter(r=>r.code!==dc);t.cues=n}).addCase(io.fulfilled,(t,n)=>{let r={code:dc,name:"Summary",response:n.payload,specialType:"summary"},o=t.cues.filter(i=>i.code!==dc);t.cues=[...o,r]}).addCase(at,()=>wT)}}),{removeCueByCode:ET,resetCues:aH,removeThreadById:da}=bT.actions,TT=bT.reducer;var BM={data:null,fetchState:"idle"},CT=e=>e.contentTypes.data,pc=ge("contentTypes/getContentTypes",(e,t)=>I(void 0,null,function*(){return t.extra.deepdeskAPI.getContentTypes()})),UM=ke({name:"contentTypes",initialState:BM,reducers:{},extraReducers:e=>{e.addCase(pc.pending,t=>{t.fetchState="loading"}).addCase(pc.rejected,t=>{t.fetchState="error"}).addCase(pc.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),kT=UM.reducer;var VM={data:null,fetchState:"idle"},$M=[],Ui=e=>e.profile.data,jM=e=>e.profile.data?e.profile.data.uiConfig.widget.types:$M,gc=Dn([jM],e=>e.filter(t=>t.isActive)),RT=e=>{var t;return(t=e.profile.data)==null?void 0:t.summarizerAssistantNew},PT=e=>{var t;return((t=e.profile.data)==null?void 0:t.onDemandAssistants)||[]},AT=e=>t=>gc(t).find(n=>n.type===e),IT=e=>e.profile.data?!!e.profile.data.uiConfig.widget.types.find(t=>t.type==="custom-data"):!1,Nf=e=>{var t;return(t=e.profile.data)==null?void 0:t.knowledgeAssistantNew},Mf=e=>{var t;return(t=e.profile.data)==null?void 0:t.knowledgeAssistant},mc=ge("profile/getProfile",(e,t)=>I(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)})),WM=ke({name:"profile",initialState:VM,reducers:{},extraReducers:e=>{e.addCase(mc.pending,t=>{t.fetchState="loading"}).addCase(mc.rejected,t=>{t.fetchState="error"}).addCase(mc.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),LT=WM.reducer;function Ar(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 fo=b(Z());var _T=b(Z()),Df=b(Ne());var Tn={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 so={};Rt(so,{enUS:()=>KM,nlNL:()=>GM});var KM={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"}]},GM={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 Zo=b(R()),qM=({src:e,title:t})=>{let n=M("CommandPalette",Tn),[r,o]=(0,_T.useState)("loading"),i=ue(so);return(0,Zo.jsxs)("div",{className:n.image,children:[(0,Zo.jsx)("img",{src:e,alt:t,onLoad:()=>o("done"),onError:()=>o("error"),className:(0,Df.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(r)})}),r==="loading"&&(0,Zo.jsx)("span",{className:(0,Df.default)(n.imageSrc,n.imageSrcStatus),children:i("loading")}),r==="error"&&(0,Zo.jsx)("span",{className:(0,Df.default)(n.imageSrc,n.imageSrcStatus),children:(0,Zo.jsx)(Eu,{})}),t&&(0,Zo.jsx)("span",{className:n.imageTitle,children:t})]})},OT=qM;var NT=b(Z()),MT=b(Ne());var Vi=b(R());function Uy({children:e,heading:t,orientation:n,hasMore:r,onShowAll:o}){let i=ue(so),s=M("CommandPalette",Tn);return NT.default.Children.count(e)===0?null:(0,Vi.jsxs)("div",{"data-testid":"commandpalette-list",className:s.list,children:[(t||r)&&(0,Vi.jsxs)("div",{className:s.listHeader,children:[t&&(0,Vi.jsx)("h4",{className:s.listHeading,children:t}),r&&o&&(0,Vi.jsx)("button",{onClick:o,className:s.listMoreButton,type:"button",children:i("showAll")})]}),(0,Vi.jsx)("div",{className:(0,MT.default)(s.listWrapper,n==="horizontal"&&s.listHorizontal),children:e})]})}var Ac=b(Ne());var Ff=b(Z());function hc(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Re=1,$y=2,jy=4,lt=8,zf=16,yc=32,rr=64,Vy={a:{content:Re|lt,self:!1,type:Re|lt|yc|rr},address:{invalid:["h1","h2","h3","h4","h5","h6","address","article","aside","section","div","header","footer"],self:!1},audio:{children:["track","source"]},br:{type:Re|lt,void:!0},body:{content:Re|$y|jy|lt|zf|yc|rr},button:{content:lt,type:Re|lt|yc|rr},caption:{content:Re,parent:["table"]},col:{parent:["colgroup"],void:!0},colgroup:{children:["col"],parent:["table"]},details:{children:["summary"],type:Re|yc|rr},dd:{content:Re,parent:["dl"]},dl:{children:["dt","dd"],type:Re},dt:{content:Re,invalid:["footer","header"],parent:["dl"]},figcaption:{content:Re,parent:["figure"]},footer:{invalid:["footer","header"]},header:{invalid:["footer","header"]},hr:{type:Re,void:!0},img:{void:!0},li:{content:Re,parent:["ul","ol","menu"]},main:{self:!1},ol:{children:["li"],type:Re},picture:{children:["source","img"],type:Re|lt|zf},rb:{parent:["ruby","rtc"]},rp:{parent:["ruby","rtc"]},rt:{content:lt,parent:["ruby","rtc"]},rtc:{content:lt,parent:["ruby"]},ruby:{children:["rb","rp","rt","rtc"]},source:{parent:["audio","video","picture"],void:!0},summary:{content:lt,parent:["details"]},table:{children:["caption","colgroup","thead","tbody","tfoot","tr"],type:Re},tbody:{parent:["table"],children:["tr"]},td:{content:Re,parent:["tr"]},tfoot:{parent:["table"],children:["tr"]},th:{content:Re,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:Re},video:{children:["track","source"]},wbr:{type:Re|lt,void:!0}};function ji(e){return t=>{Vy[t]=S(S({},e),Vy[t])}}["address","main","div","figure","p","pre"].forEach(ji({content:Re,type:Re|rr}));["abbr","b","bdi","bdo","cite","code","data","dfn","em","i","kbd","mark","q","ruby","samp","strong","sub","sup","time","u","var"].forEach(ji({content:lt,type:Re|lt|rr}));["p","pre"].forEach(ji({content:lt,type:Re|rr}));["s","small","span","del","ins"].forEach(ji({content:lt,type:Re|lt}));["article","aside","footer","header","nav","section","blockquote"].forEach(ji({content:Re,type:Re|$y|rr}));["h1","h2","h3","h4","h5","h6"].forEach(ji({content:lt,type:Re|jy|rr}));["audio","canvas","iframe","img","video"].forEach(ji({type:Re|lt|zf|rr}));var xc=Object.freeze(Vy),Wy=["applet","base","body","command","embed","frame","frameset","head","html","link","meta","noscript","object","script","style","title"],Ky=Object.keys(xc).filter(e=>e!=="canvas"&&e!=="iframe"),_e=1,Gy=2,$i=3,Jo=4,Bf=5,Uf=Object.freeze({alt:_e,cite:_e,class:_e,colspan:$i,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:$i,scope:_e,sizes:_e,span:$i,start:$i,style:Bf,src:_e,srclang:_e,srcset:_e,tabindex:_e,target:_e,title:_e,type:_e,width:_e}),qy=Object.freeze({class:"className",colspan:"colSpan",datetime:"dateTime",rowspan:"rowSpan",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex"});function Hf(){return Hf=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},Hf.apply(this,arguments)}function Vf({attributes:e={},className:t,children:n=null,selfClose:r=!1,tagName:o}){let i=o;return r?Ff.default.createElement(i,Hf({className:t},e)):Ff.default.createElement(i,Hf({className:t},e),n)}var vc=class{attribute(t,n){return n}node(t,n){return n}};function DT(e,t,n,r=!1){let o=e.match(t instanceof RegExp?t:new RegExp(t,"i"));return o?P(S({match:o[0],void:r},n(o)),{index:o.index,length:o[0].length,valid:!0}):null}var ao=class{constructor(t,n,r){hc(this,"greedy",!1),hc(this,"options",void 0),hc(this,"propName",void 0),hc(this,"inverseName",void 0),hc(this,"factory",void 0),this.options=S({},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?Ff.default.createElement(this.factory,n,t):this.replaceWith(t,n)}doMatch(t,n,r,o=!1){return DT(t,n,r,o)}onBeforeParse(t,n){return t}onAfterParse(t,n){return t}};var Wi=b(Z()),BT=b(zT());function lo(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var QM=/(url|image|image-set)\(/i,Yy=class extends vc{attribute(t,n){return t==="style"&&Object.keys(n).forEach(r=>{String(n[r]).match(QM)&&delete n[r]}),n}},HT=1,ZM=3,JM=/^<(!doctype|(html|head|body)(\s|>))/i,e2=/^(aria-|data-|\w+:)/iu,t2=/{{{(\w+)\/?}}}/;function n2(){if(!(typeof window=="undefined"||typeof document=="undefined"))return document.implementation.createHTMLDocument("Interweave")}var $f=class{constructor(t,n={},r=[],o=[]){var i;lo(this,"allowed",void 0),lo(this,"banned",void 0),lo(this,"blocked",void 0),lo(this,"container",void 0),lo(this,"content",[]),lo(this,"props",void 0),lo(this,"matchers",void 0),lo(this,"filters",void 0),lo(this,"keyIndex",void 0),this.props=n,this.matchers=r,this.filters=[...o,new Yy],this.keyIndex=-1,this.container=this.createContainer(t||""),this.allowed=new Set((i=n.allowList)!==null&&i!==void 0?i:Ky),this.banned=new Set(Wy),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 c=l.asTag().toLowerCase(),u=this.getTagConfig(c);if(o[l.inverseName]||!this.isTagAllowed(c)||!this.canRenderChild(n,u))return;let d="";for(;i&&(a=l.match(i));){let f=a,{index:p,length:v,match:m,valid:x,void:y}=f,g=oe(f,["index","length","match","valid","void"]),h=l.propName+String(s);p>0&&(d+=i.slice(0,p)),x?(d+=y?`{{{${h}/}}}`:`{{{${h}}}}${m}{{{/${h}}}}`,this.keyIndex+=1,s+=1,r[h]={children:m,matcher:l,props:P(S(S({},o),g),{key:this.keyIndex})}):d+=m,l.greedy?(i=d+i.slice(p+v),d=""):i=i.slice(p+(v||m.length))}l.greedy||(i=d+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,`
|
|
15
|
+
`,zi.MISSING_INTL_API,s);var w=n.getPluralRules(t,{type:u.pluralType}).select(f-(u.offset||0));h=u.options[w]||u.options.other}if(!h)throw new _y(u.value,f,Object.keys(u.options),s);a.push.apply(a,cc(h.value,t,n,r,o,f-(u.offset||0)));continue}}return lM(a)}function uM(e,t){return t?En(En(En({},e||{}),t||{}),Object.keys(e).reduce(function(n,r){return n[r]=En(En({},e[r]),t[r]||{}),n},{})):e}function dM(e,t){return t?Object.keys(e).reduce(function(n,r){return n[r]=uM(e[r],t[r]),n},En({},e)):e}function Oy(e){return{create:function(){return{get:function(t){return e[t]},set:function(t,n){e[t]=n}}}}}function fM(e){return e===void 0&&(e={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Ef(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.NumberFormat).bind.apply(t,bf([void 0],n,!1)))},{cache:Oy(e.number),strategy:Tf.variadic}),getDateTimeFormat:Ef(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.DateTimeFormat).bind.apply(t,bf([void 0],n,!1)))},{cache:Oy(e.dateTime),strategy:Tf.variadic}),getPluralRules:Ef(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.PluralRules).bind.apply(t,bf([void 0],n,!1)))},{cache:Oy(e.pluralRules),strategy:Tf.variadic})}}var Ny=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(c){var u=i.formatToParts(c);if(u.length===1)return u[0].value;var d=u.reduce(function(f,p){return!f.length||p.type!==Ot.literal||typeof f[f.length-1]!="string"?f.push(p.value):f[f.length-1]+=p.value,f},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return cc(i.ast,i.locales,i.formatters,i.formats,c,void 0,i.message)},this.resolvedOptions=function(){var c;return{locale:((c=i.resolvedLocale)===null||c===void 0?void 0:c.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=nT(s,["formatters"]);this.ast=e.__parse(t,En(En({},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=dM(e.formats,r),this.formatters=o&&o.formatters||fM(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=sT,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 pM(e,t){return t.split(".").reduce((n,r)=>n?n[r]:void 0,e)}var mM="dummy",My=(0,Af.createContext)(null);function ue(e){var r;let t=(0,Af.useContext)(My);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=pM(n,o);return s?new Ny(s).format(i):(t!==mM&&console.warn(`${o} does not exist in messages of ${t}`),`[${o}]`)}}var If=b(Z());var cT={root:"dd-tvkOF",content:"dd-eXA1D"};var Dy=b(R()),gM=({isOpen:e,autoFocus:t,children:n,onClose:r,onBack:o,onKeyDown:i,overlayAriaLabel:s,contentAriaLabel:a})=>{let l=(0,If.useRef)(null),c=M("Dialog",cT),u=f=>{if(f.key==="Escape"){f.preventDefault(),f.stopPropagation(),o();return}i&&i(f)},d=f=>{f.target===l.current&&e&&r()};return(0,If.useEffect)(()=>{var f,p;!l.current||!e||!t||(p=(f=l.current)==null?void 0:f.querySelector("input, textarea"))==null||p.focus()},[e,t,l]),e?(0,Dy.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":s,ref:l,onKeyDown:u,onMouseDown:d,children:(0,Dy.jsx)("div",{"data-testid":"dialog-content",className:c.content,"aria-label":a,children:n})}):null},Lf=gM;var dT=b(Ne());var uT={root:"dd-ranhW"};var fT=b(R()),hM=r=>{var o=r,{className:e,value:t}=o,n=oe(o,["className","value"]);let i=M("TextInput",uT);return(0,fT.jsx)("input",S({className:(0,dT.default)(e,i.root),type:"text",value:t},n))},uc=hM;var Fy={};Rt(Fy,{enUS:()=>yM,nlNL:()=>vM});var yM={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"}]},vM={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 pT={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 tt=b(R());var xM=e=>{try{let t=new URL(e);return new URLSearchParams(t.search).get("token")||void 0}catch(t){return e}},wM=({agentEmail:e,isOpen:t,origin:n="",onSuccess:r,onDismiss:o})=>{let i=ue(Fy),s=M("LoginTokenDialog",pT),a=j(u1),l=ve(),c=te("productName"),[u,d]=(0,tr.useState)(e||""),[f,p]=(0,tr.useState)(0),[v,m]=(0,tr.useState)(""),x=(0,tr.useCallback)(w=>I(void 0,null,function*(){w.preventDefault(),l(f1({email:u})),p(1)}),[n,u]),y=()=>{m(""),p(0)},g=(0,tr.useCallback)(w=>I(void 0,null,function*(){w.preventDefault();let E=xM(w.target.elements.token.value);if(!E){m(i("verifyCodeError",{login:h}));return}l(ql({token:E}))}),[n]),h=(0,tr.useMemo)(()=>w=>(0,tt.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:s.anchorButton,onClick:y,children:w},"back-button"),[]);return(0,tr.useEffect)(()=>{a==="error"&&m(i("verifyCodeError",{login:h})),a==="done"&&r()},[a]),(0,tt.jsx)(Lf,{autoFocus:!0,isOpen:t,contentAriaLabel:i("promptTitle",{productName:c}),overlayAriaLabel:i("promptTitle",{productName:c}),onClose:o,onBack:o,children:(0,tt.jsxs)("div",{className:s.root,children:[(0,tt.jsx)("h1",{className:s.title,children:i("promptTitle",{productName:c})}),f===0&&(0,tt.jsxs)("form",{onSubmit:x,children:[(0,tt.jsx)("h2",{className:s.subtitle,children:i("requestCodeTitle")}),(0,tt.jsx)("p",{className:s.text,children:i("requestCodeBody",{productName:c})}),(0,tt.jsx)(uc,{className:s.input,name:"email",placeholder:i("requestCodeInputPlaceholder"),value:u,onChange:w=>d(w.target.value)}),(0,tt.jsx)("div",{className:s.actions,children:(0,tt.jsx)("button",{type:"submit",className:(0,_f.default)(s.button,s.primaryButton),children:i("requestCodeSubmitLabel")})})]}),f===1&&(0,tt.jsxs)("form",{onSubmit:g,children:[(0,tt.jsx)("h2",{className:s.subtitle,children:i("verifyCodeTitle")}),(0,tt.jsx)("p",{className:s.text,children:i("verifyCodeBody")}),(0,tt.jsx)(uc,{className:s.input,name:"token",placeholder:i("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),v&&(0,tt.jsx)("div",{className:s.errorMessage,children:v}),(0,tt.jsxs)("div",{className:s.actions,children:[(0,tt.jsx)("button",{type:"button",className:(0,_f.default)(s.button),onClick:y,children:i("back")}),(0,tt.jsx)("button",{type:"submit",className:(0,_f.default)(s.button,s.primaryButton),disabled:["loading","done"].includes(a),children:i("verifyCodeSubmitLabel")})]})]})]})})},mT=wM;var hT=b(R()),SM=()=>{let e=j(d1),t=j(ca),n=te("adminUrl"),r=un(),o=()=>r.send(ua,!1),i=()=>{r.send(ua,!1),r.send(Zl)};return(0,hT.jsx)(mT,{isOpen:e,agentEmail:t==null?void 0:t.agentEmail,origin:n,onDismiss:o,onSuccess:i})},gT=SM;var CR=b(By()),Xt=b(Z());var dc="__summarizerAssistant__",wT={cues:[],threads:{},pending:[]},ST=e=>{var t;return(t=e.assistants)==null?void 0:t.cues};var fc=e=>t=>{var n,r;return(r=(n=t.assistants)==null?void 0:n.threads[e])!=null?r:null},Of=st("assistants/callToAction"),io=ge("assistants/evaluateSummaryAssistant",(e,t)=>I(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(nr(S({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 J.warn("Unexpected summary output",i),new Error("Unexpected summary output");return i.payload})),HM=1,Hi=ge("assistants/evaluateKnowledgeAssistantLegacy",(e,t)=>I(void 0,null,function*(){var p,v,m,x;let{threadId:n}=e,{onNewThreadId:r,input:o}=e,{deepdeskAPI:i}=t.extra,s=t.getState(),{platformVariables:a}=s.info;n||(n=HM++,r&&r(n));let l=(p=fc(n)(s))!=null?p:[],c=yield i.getKnowledgeAssistant(e.assistantCode),u=(v=s.conversation.current)==null?void 0:v.externalId,d=(x=(m=s.info)==null?void 0:m.agentInfo)==null?void 0:x.agentId;if(!c)throw new Error("KnowledgeAssistant is not found");let f=yield i.knowledgeAssist({customerInstruction:c.customerInstruction,doNotKnowAnswer:c.doNotKnowAnswer,question:o},l,c.code,{agentId:d,conversationId:u});return a&&(f.answer=cn(f.answer,a)),{threadId:n,question:o,answer:f}})),Bi=ge("assistants/evaluateKnowledgeAssistant",(e,t)=>I(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(nr(P(S({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:cn(l.response,s!=null?s:{}),sources:l.sources}}})),nr=ge("assistants/evaluate",(e,t)=>I(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:c}=l.info,u=(p=l.conversation.current)==null?void 0:p.externalId,d;if(o==="in-memory-transcript"){if(!r.conversationQuery)throw new Error("Can't include in-memory-transcript, setConversationQuery is not defined");d=yield r.conversationQuery()}else Array.isArray(o)&&(d=o);if(e.includeMetadata){if(!l.conversation.current)throw new Error("Can't include metadata, no current conversation");let{metadata:v}=l.conversation.current;Object.assign(i,{metadata:v})}let f=yield n.evaluateAssistant(e.assistantCode,{expectFormat:s,input:i,transcript:d,externalConversationId:u,threadId:a});switch(s){case"text":return cn(f,c);case"json-schema:cues":return Array.isArray(f)?f.map(v=>P(S({},v),{name:cn(v.name,c),response:cn(v.response,c)})):[];case"json-schema:knowledge-assist":{let v=f;return P(S({},v),{answer:cn(v.response,c)})}default:return f}})),bT=ke({name:"assistants",initialState:wT,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(nr.pending,(t,n)=>{t.pending.includes(n.meta.arg.assistantCode)&&J.warn(`Assistant ${n.meta.arg.assistantCode} already evaluating`),t.pending.push(n.meta.arg.assistantCode)}).addCase(nr.rejected,(t,n)=>{var o;J.warn((o=n.error)==null?void 0:o.message);let r=t.pending.indexOf(n.meta.arg.assistantCode);r!==-1&&t.pending.splice(r,1)}).addCase(nr.fulfilled,(t,n)=>{let r=t.pending.indexOf(n.meta.arg.assistantCode);if(r!==-1&&t.pending.splice(r,1),!n.meta.arg.skipState)switch(n.meta.arg.expectFormat){case"json-schema:cues":{let o=n.payload,i=o.map(a=>a.code),s=t.cues.filter(a=>!i.includes(a.code));t.cues=[...s,...o];break}}}).addCase(Bi.fulfilled,(t,n)=>{let i=n.payload,{threadId:r}=i,o=oe(i,["threadId"]);t.threads[r]=[...t.threads[r]||[],o]}).addCase(Hi.fulfilled,(t,n)=>{let i=n.payload,{threadId:r}=i,o=oe(i,["threadId"]);t.threads[r]=[...t.threads[r]||[],o]}).addCase(io.pending,t=>{let n={code:dc,name:"Summary",response:"",isLoading:!0},r=t.cues.filter(o=>o.code!==dc);t.cues=[...r,n]}).addCase(io.rejected,t=>{let n=t.cues.filter(r=>r.code!==dc);t.cues=n}).addCase(io.fulfilled,(t,n)=>{let r={code:dc,name:"Summary",response:n.payload,specialType:"summary"},o=t.cues.filter(i=>i.code!==dc);t.cues=[...o,r]}).addCase(at,()=>wT)}}),{removeCueByCode:ET,resetCues:aH,removeThreadById:da}=bT.actions,TT=bT.reducer;var BM={data:null,fetchState:"idle"},CT=e=>e.contentTypes.data,pc=ge("contentTypes/getContentTypes",(e,t)=>I(void 0,null,function*(){return t.extra.deepdeskAPI.getContentTypes()})),UM=ke({name:"contentTypes",initialState:BM,reducers:{},extraReducers:e=>{e.addCase(pc.pending,t=>{t.fetchState="loading"}).addCase(pc.rejected,t=>{t.fetchState="error"}).addCase(pc.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),kT=UM.reducer;var VM={data:null,fetchState:"idle"},$M=[],Ui=e=>e.profile.data,jM=e=>e.profile.data?e.profile.data.uiConfig.widget.types:$M,gc=Dn([jM],e=>e.filter(t=>t.isActive)),RT=e=>{var t,n;return(n=(t=e.profile.data)==null?void 0:t.summarizerAssistantNew)!=null?n:null},PT=e=>{var t;return((t=e.profile.data)==null?void 0:t.onDemandAssistants)||[]},AT=e=>t=>gc(t).find(n=>n.type===e),IT=e=>e.profile.data?!!e.profile.data.uiConfig.widget.types.find(t=>t.type==="custom-data"):!1,Nf=e=>{var t,n;return(n=(t=e.profile.data)==null?void 0:t.knowledgeAssistantNew)!=null?n:null},Mf=e=>{var t,n;return(n=(t=e.profile.data)==null?void 0:t.knowledgeAssistant)!=null?n:null},mc=ge("profile/getProfile",(e,t)=>I(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)})),WM=ke({name:"profile",initialState:VM,reducers:{},extraReducers:e=>{e.addCase(mc.pending,t=>{t.fetchState="loading"}).addCase(mc.rejected,t=>{t.fetchState="error"}).addCase(mc.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),LT=WM.reducer;function Ar(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 fo=b(Z());var _T=b(Z()),Df=b(Ne());var Tn={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 so={};Rt(so,{enUS:()=>KM,nlNL:()=>GM});var KM={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"}]},GM={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 Zo=b(R()),qM=({src:e,title:t})=>{let n=M("CommandPalette",Tn),[r,o]=(0,_T.useState)("loading"),i=ue(so);return(0,Zo.jsxs)("div",{className:n.image,children:[(0,Zo.jsx)("img",{src:e,alt:t,onLoad:()=>o("done"),onError:()=>o("error"),className:(0,Df.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(r)})}),r==="loading"&&(0,Zo.jsx)("span",{className:(0,Df.default)(n.imageSrc,n.imageSrcStatus),children:i("loading")}),r==="error"&&(0,Zo.jsx)("span",{className:(0,Df.default)(n.imageSrc,n.imageSrcStatus),children:(0,Zo.jsx)(Eu,{})}),t&&(0,Zo.jsx)("span",{className:n.imageTitle,children:t})]})},OT=qM;var NT=b(Z()),MT=b(Ne());var Vi=b(R());function Uy({children:e,heading:t,orientation:n,hasMore:r,onShowAll:o}){let i=ue(so),s=M("CommandPalette",Tn);return NT.default.Children.count(e)===0?null:(0,Vi.jsxs)("div",{"data-testid":"commandpalette-list",className:s.list,children:[(t||r)&&(0,Vi.jsxs)("div",{className:s.listHeader,children:[t&&(0,Vi.jsx)("h4",{className:s.listHeading,children:t}),r&&o&&(0,Vi.jsx)("button",{onClick:o,className:s.listMoreButton,type:"button",children:i("showAll")})]}),(0,Vi.jsx)("div",{className:(0,MT.default)(s.listWrapper,n==="horizontal"&&s.listHorizontal),children:e})]})}var Ac=b(Ne());var Ff=b(Z());function hc(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Re=1,$y=2,jy=4,lt=8,zf=16,yc=32,rr=64,Vy={a:{content:Re|lt,self:!1,type:Re|lt|yc|rr},address:{invalid:["h1","h2","h3","h4","h5","h6","address","article","aside","section","div","header","footer"],self:!1},audio:{children:["track","source"]},br:{type:Re|lt,void:!0},body:{content:Re|$y|jy|lt|zf|yc|rr},button:{content:lt,type:Re|lt|yc|rr},caption:{content:Re,parent:["table"]},col:{parent:["colgroup"],void:!0},colgroup:{children:["col"],parent:["table"]},details:{children:["summary"],type:Re|yc|rr},dd:{content:Re,parent:["dl"]},dl:{children:["dt","dd"],type:Re},dt:{content:Re,invalid:["footer","header"],parent:["dl"]},figcaption:{content:Re,parent:["figure"]},footer:{invalid:["footer","header"]},header:{invalid:["footer","header"]},hr:{type:Re,void:!0},img:{void:!0},li:{content:Re,parent:["ul","ol","menu"]},main:{self:!1},ol:{children:["li"],type:Re},picture:{children:["source","img"],type:Re|lt|zf},rb:{parent:["ruby","rtc"]},rp:{parent:["ruby","rtc"]},rt:{content:lt,parent:["ruby","rtc"]},rtc:{content:lt,parent:["ruby"]},ruby:{children:["rb","rp","rt","rtc"]},source:{parent:["audio","video","picture"],void:!0},summary:{content:lt,parent:["details"]},table:{children:["caption","colgroup","thead","tbody","tfoot","tr"],type:Re},tbody:{parent:["table"],children:["tr"]},td:{content:Re,parent:["tr"]},tfoot:{parent:["table"],children:["tr"]},th:{content:Re,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:Re},video:{children:["track","source"]},wbr:{type:Re|lt,void:!0}};function ji(e){return t=>{Vy[t]=S(S({},e),Vy[t])}}["address","main","div","figure","p","pre"].forEach(ji({content:Re,type:Re|rr}));["abbr","b","bdi","bdo","cite","code","data","dfn","em","i","kbd","mark","q","ruby","samp","strong","sub","sup","time","u","var"].forEach(ji({content:lt,type:Re|lt|rr}));["p","pre"].forEach(ji({content:lt,type:Re|rr}));["s","small","span","del","ins"].forEach(ji({content:lt,type:Re|lt}));["article","aside","footer","header","nav","section","blockquote"].forEach(ji({content:Re,type:Re|$y|rr}));["h1","h2","h3","h4","h5","h6"].forEach(ji({content:lt,type:Re|jy|rr}));["audio","canvas","iframe","img","video"].forEach(ji({type:Re|lt|zf|rr}));var xc=Object.freeze(Vy),Wy=["applet","base","body","command","embed","frame","frameset","head","html","link","meta","noscript","object","script","style","title"],Ky=Object.keys(xc).filter(e=>e!=="canvas"&&e!=="iframe"),_e=1,Gy=2,$i=3,Jo=4,Bf=5,Uf=Object.freeze({alt:_e,cite:_e,class:_e,colspan:$i,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:$i,scope:_e,sizes:_e,span:$i,start:$i,style:Bf,src:_e,srclang:_e,srcset:_e,tabindex:_e,target:_e,title:_e,type:_e,width:_e}),qy=Object.freeze({class:"className",colspan:"colSpan",datetime:"dateTime",rowspan:"rowSpan",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex"});function Hf(){return Hf=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},Hf.apply(this,arguments)}function Vf({attributes:e={},className:t,children:n=null,selfClose:r=!1,tagName:o}){let i=o;return r?Ff.default.createElement(i,Hf({className:t},e)):Ff.default.createElement(i,Hf({className:t},e),n)}var vc=class{attribute(t,n){return n}node(t,n){return n}};function DT(e,t,n,r=!1){let o=e.match(t instanceof RegExp?t:new RegExp(t,"i"));return o?P(S({match:o[0],void:r},n(o)),{index:o.index,length:o[0].length,valid:!0}):null}var ao=class{constructor(t,n,r){hc(this,"greedy",!1),hc(this,"options",void 0),hc(this,"propName",void 0),hc(this,"inverseName",void 0),hc(this,"factory",void 0),this.options=S({},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?Ff.default.createElement(this.factory,n,t):this.replaceWith(t,n)}doMatch(t,n,r,o=!1){return DT(t,n,r,o)}onBeforeParse(t,n){return t}onAfterParse(t,n){return t}};var Wi=b(Z()),BT=b(zT());function lo(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var QM=/(url|image|image-set)\(/i,Yy=class extends vc{attribute(t,n){return t==="style"&&Object.keys(n).forEach(r=>{String(n[r]).match(QM)&&delete n[r]}),n}},HT=1,ZM=3,JM=/^<(!doctype|(html|head|body)(\s|>))/i,e2=/^(aria-|data-|\w+:)/iu,t2=/{{{(\w+)\/?}}}/;function n2(){if(!(typeof window=="undefined"||typeof document=="undefined"))return document.implementation.createHTMLDocument("Interweave")}var $f=class{constructor(t,n={},r=[],o=[]){var i;lo(this,"allowed",void 0),lo(this,"banned",void 0),lo(this,"blocked",void 0),lo(this,"container",void 0),lo(this,"content",[]),lo(this,"props",void 0),lo(this,"matchers",void 0),lo(this,"filters",void 0),lo(this,"keyIndex",void 0),this.props=n,this.matchers=r,this.filters=[...o,new Yy],this.keyIndex=-1,this.container=this.createContainer(t||""),this.allowed=new Set((i=n.allowList)!==null&&i!==void 0?i:Ky),this.banned=new Set(Wy),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 c=l.asTag().toLowerCase(),u=this.getTagConfig(c);if(o[l.inverseName]||!this.isTagAllowed(c)||!this.canRenderChild(n,u))return;let d="";for(;i&&(a=l.match(i));){let f=a,{index:p,length:v,match:m,valid:x,void:y}=f,g=oe(f,["index","length","match","valid","void"]),h=l.propName+String(s);p>0&&(d+=i.slice(0,p)),x?(d+=y?`{{{${h}/}}}`:`{{{${h}}}}${m}{{{/${h}}}}`,this.keyIndex+=1,s+=1,r[h]={children:m,matcher:l,props:P(S(S({},o),g),{key:this.keyIndex})}):d+=m,l.greedy?(i=d+i.slice(p+v),d=""):i=i.slice(p+(v||m.length))}l.greedy||(i=d+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
16
|
`);return o=o.replace(/\n{3,}/g,`
|
|
17
17
|
|
|
18
18
|
|
|
@@ -79,7 +79,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let o="<p>An error
|
|
|
79
79
|
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
|
|
80
80
|
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 r0=b(R()),g4={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},IR=({className:e,color:t})=>(0,r0.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,r0.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:g4[t||"pink"]})});var LR={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var o0={};Rt(o0,{enUS:()=>h4,nlNL:()=>y4});var h4={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},y4={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var us=b(R()),OR=({onLogIn:e})=>{let t=ue(o0),n=te("floatingMenu"),r=te("productName"),o=ve(),i=j($t),s=M("FloatingMenu",LR);if(i===null||n===!1)return null;let a=()=>{i===!0?o(Fn(!0)):e()};return(0,us.jsxs)("button",{type:"button",className:(0,_R.default)(s.root,{[s.isLoggedIn]:i,[s.isLoggedOut]:!i}),onClick:a,children:[(0,us.jsx)("div",{className:s.text,children:t(i?"search":"signin",{productName:r})}),(0,us.jsxs)("div",{className:s.icon,children:[(0,us.jsx)(IR,{className:s.logo,color:"pink"}),i===!1&&(0,us.jsx)(AR,{className:s.lock})]})]})};var Fp=b(Z());function Nr(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 v4={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Np=({ui:e})=>e.overlayCollapsed,NR=ke({name:"ui",initialState:v4,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:Xc,setInputFocus:Mp,setOverlayCollapsed:oi,setOpenOverlayWhenTyping:MR,setOverlayCollapsedUserOverwrite:DR}=NR.actions,FR=NR.reducer;var VR=b(Z());var ii=b(Z());var zR=b(Z());function HR(e,t,n){(0,zR.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var BR={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var ds=b(R()),w4=["search","personal-collection-search","search-autocomplete"];function S4(e,t,n,r={}){var i;let o="";return w4.includes(t)?o=UT(Xy(e,n,{stripAgentPart:!0}),(i=r.searchKeywords)!=null?i:[n]):o=Xy(e,n,r),r.placeholders===!0&&(o=VT(o)),o}var b4=()=>{},E4=({selected:e,suggestion:t})=>{let n=te("inlineSuggestions"),r=j(aa),[o,i]=(0,ii.useState)(!1),s=te("enableSuggestionFeedback"),a=j(f=>f.input.text),l=ve(),c=M("TextSuggestion",BR),u=(0,ii.useRef)(null);(0,ii.useEffect)(()=>{let f=setTimeout(()=>{l(A1({text:t.text,suggestion:t}))},500);return()=>{clearTimeout(f)}},[t]),HR(u,"click",()=>{l(er({suggestion:t,text:t.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let d=(0,ii.useMemo)(()=>S4(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,ds.jsxs)("div",{className:c.root,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[(0,ds.jsx)(ye,{ref:u,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:b4,children:(0,ds.jsx)(Ki,{containerTagName:"div",noWrap:!1,tagName:"span",className:c.formattedText,content:d})}),s&&o&&(0,ds.jsx)("div",{className:c.actions,children:(0,ds.jsx)(Ip,{source:"overlay",context:a,suggestion:t})})]})},UR=E4;var $R=b(R()),T4=({suggestions:e,selectedIndex:t,reverse:n})=>(0,VR.useMemo)(()=>{let o=e.map((i,s)=>(0,$R.jsx)(UR,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]),Dp=T4;var jR={root:"dd-PfvRI",paper:"dd-HYlyY"};var Qc=b(R()),C4=({textSuggestions:e,selectedIndex:t})=>{let n=(0,Fp.useRef)(null),r=M("InlineSuggestionsOverlay",jR),o=j(Nr),i=ve(),s=j($t),a=j(sa),l=j(Np),c=te("showTextSuggestions");return ri(()=>{setTimeout(()=>{i(oi({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Fp.useEffect)(()=>{let u=n.current;if(!u||!u.parentElement)return;u.parentElement.style.left="0px";let d=u.getBoundingClientRect();u.parentElement.style.left=`${Math.min(window.innerWidth-4-d.right,0)}px`}),l||!o||!c||e.length===0||s!==!0||a===!1?null:(0,Qc.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,Qc.jsx)("div",{ref:n,className:r.paper,children:(0,Qc.jsx)(Ht,{children:(0,Qc.jsx)(Dp,{suggestions:e,selectedIndex:t})})})})},k4=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),WR=oa(k4)(C4);var Zc=b(R()),R4=({children:e})=>{let n=te("locale").replace("-","");return(0,Zc.jsx)(My.Provider,{value:n,children:e})},P4=({store:e,customStyles:t={},children:n})=>(0,Zc.jsx)(r1,{store:e,children:(0,Zc.jsx)(R4,{children:(0,Zc.jsx)(Ya.Provider,{value:t,children:n})})}),si=P4;var Hp=b(Ne()),Na=b(Z());var KR=b(Z());function GR(e,t){let[n,r]=(0,KR.useState)(()=>{if(typeof window=="undefined")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return J.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){J.error(s)}}]}var qR=()=>/Mac/i.test(navigator.platform);var XR=b(Ne()),yo=b(Z());var i0={};Rt(i0,{enUS:()=>A4,nlNL:()=>I4});var A4={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"}]}]},I4={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 YR={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var ai=b(R()),s0=(e,t,n)=>r=>(0,ai.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),L4=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=ue(i0),s=un(),a=M("Login",YR),l=te("productName"),c=(0,yo.useCallback)(x=>{x.preventDefault(),r&&r(Number.parseInt(x.target.value,10))},[]),u=(0,yo.useCallback)(x=>{x.preventDefault(),s.send(ua,!0)},[t]),d=(0,yo.useMemo)(()=>x=>(0,ai.jsx)("a",{onClick:g=>{g.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:x},"login"),[t]),f=(0,yo.useCallback)(x=>(0,ai.jsx)("button",{type:"button",className:a.anchorButton,onClick:u,children:x},"prompt"),[u]),{min:p,hour:v,day:m}=(0,yo.useMemo)(()=>({min:s0(a,60*10,c),hour:s0(a,60*60,c),day:s0(a,60*60*12,c)}),[]);return(0,ai.jsxs)("div",{className:(0,XR.default)(e,a.root),children:[i("loginPlease",{login:n?f:d,productName:l}),r&&(0,ai.jsxs)(yo.Fragment,{children:[(0,ai.jsx)("br",{}),i("snooze",{min:p,hour:v,day:m})]})]})},zp=L4;var QR={root:"dd-DoQhb",text:"dd-Jwnev"};var Jc=b(R()),_4=({title:e})=>{let t=M("SearchTrigger",QR),n=ve(),r=ct();return(0,Jc.jsxs)("button",{type:"button",className:t.root,onClick:()=>{n(Fn(!0)),r("open search",{via:"autocomplete-overlay"})},children:[(0,Jc.jsx)(Ca,{}),(0,Jc.jsx)("span",{className:t.text,children:e})]})},ZR=_4;var a0={};Rt(a0,{enUS:()=>O4,nlNL:()=>N4});var O4={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"}]},N4={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 JR={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 Ve=b(R()),M4=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=M("SuggestionsOverlay",JR),o=ue(a0),i=j(Nr),s=P1(),a=ve(),l=(0,Na.useRef)(null),c=te("searchTriggerKey"),u=te("productName"),d=j(Np),f=j($t),p=j(sa),[v,m]=(0,Na.useState)(null),x=te("showSearch"),y=te("showTextSuggestions"),g=te("adminUrl"),h=te("isEmbedded"),[w,E]=GR("dd-snooze-until-ms",0),C=d||w>Date.now(),k=e.filter(N=>N.source!=="gpt").length,A=()=>{C&&E(0),a(DR(!C))},F=N=>{let O=Date.now()+N*1e3;E(O),J.info(`Snooze until: ${new Date(O)}`),a(oi({collapse:!0}))};return(0,Na.useEffect)(()=>{k===0&&m(null)},[e,k]),ri(()=>{a(oi({collapse:!0,skipWhenInputFocus:!0}))}),f===null||p===!1?null:f===!1?(0,Ve.jsxs)("div",{ref:l,className:(0,Hp.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,Ve.jsxs)("div",{className:r.triggers,children:[(0,Ve.jsx)("div",{style:{flex:1}}),(0,Ve.jsx)("div",{className:r.triggersRight,children:(0,Ve.jsx)(yi,{className:r.toggleButton,title:o("collapse"),onClick:A,isCollapsed:!1})})]}),(0,Ve.jsx)("div",{className:r.toggleButtonWrapper,children:(0,Ve.jsx)(yi,{className:r.toggleButton,title:o("open",{productName:u}),onClick:A,isCollapsed:!0})}),(0,Ve.jsx)("div",{className:r.collapsible,children:(0,Ve.jsx)(zp,{loginUrl:g,isEmbedded:h,onLogIn:n,onSnooze:F})})]}):!s||!i?null:(0,Ve.jsxs)("div",{ref:l,className:(0,Hp.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,Ve.jsxs)("div",{className:r.triggers,children:[(0,Ve.jsx)("div",{style:{flex:1},children:x&&(0,Ve.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>m(o(qR()?"searchHintMac":"searchHintWindows",{searchTriggerKey:c.toUpperCase()})),onMouseLeave:()=>m(null),children:(0,Ve.jsx)(ZR,{title:o("search")})})}),(0,Ve.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,Ve.jsx)("div",{className:(0,Hp.default)(!v&&r.hintsHidden,r.hints),children:v}),(0,Ve.jsx)(yi,{className:r.toggleButton,title:o("collapse"),onClick:A,isCollapsed:!1})]})]}),(0,Ve.jsx)("div",{className:r.toggleButtonWrapper,children:(0,Ve.jsx)(yi,{className:r.toggleButton,title:o("open",{productName:u}),onClick:A,isCollapsed:!0})}),k>0&&y&&(0,Ve.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,Ve.jsx)(Ht,{children:(0,Ve.jsx)(Dp,{suggestions:e,selectedIndex:t,reverse:!0})})})]})},D4=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),eP=oa(D4)(M4);var Qp=b(Ne());var wo=b(Z());var Ma=b(Z());function Bp(e){return e.contentEditable==="true"}function F4(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 tP(e){let{selectionStart:t,selectionEnd:n}=Bp(e)?F4(e):e;return[t,n]}function nP(e){let[,t]=(0,Ma.useState)(),n=(0,Ma.useRef)(null);return n.current=tP(e),(0,Ma.useEffect)(()=>{let r=()=>{var a;let[o,i]=(a=n.current)!=null?a:[],s=tP(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 rP(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(Pu);if(!s||s.length===0)return;let a=0;s.find(l=>{let c=r.indexOf(l,a);return o>c&&i<c+l.length?(n.selectionStart=c,n.selectionEnd=c+l.length,!0):(a=c+l.length,!1)})}var oP=b(Z()),z4=["div","span","mark","strong","b","i","u","em"];function l0(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,oP.cloneElement)(r,{children:l0(s,t,n+1)})]}return[...e,...t]}function fs(e){return e.tagName.toLowerCase()==="textarea"}var iP={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 uP=b(Ne());var Kp=b(Z());var Da=b(Z());function sP(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function Up(e){let t=(0,Da.useRef)(null),[n,r]=(0,Da.useState)(!1);return(0,Da.useEffect)(()=>{var u;let o=!1,i=Number.parseFloat((u=window.getComputedStyle(document.body).zoom)!=null?u:"1"),[s,a]=sP((d,f)=>{let p=t.current;if(!p)return;let v=d/i,m=f/i,x=p.getBoundingClientRect(),y=v>x.x&&v<x.x+x.width&&m>x.y&&m<x.y+x.height;y&&!o?(o=!0,r(!0)):!y&&o&&(o=!1,r(!1))},({clientX:d,clientY:f})=>[d,f]),[l,c]=sP(()=>{o=!1,r(!1)});return e.addEventListener("mousemove",s),e.addEventListener("mouseleave",l),()=>{a(),c(),e.removeEventListener("mousemove",s),e.removeEventListener("mouseleave",l)}},[t]),[t,n]}function aP(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Vp(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function lP(e){return e!=null}var cP=b(Ne()),$p=b(Z());var vo={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 c0=b(R()),jp=(0,$p.forwardRef)((o,r)=>{var i=o,{className:e,children:t}=i,n=oe(i,["className","children"]);let s=(0,$p.useRef)(null),a=M("TabCompletion",vo);return(0,c0.jsx)("div",P(S({ref:Vp([s,r]),className:(0,cP.default)(e,a.popoverContentContainer)},n),{children:(0,c0.jsx)("div",{className:a.popoverContent,children:t})}))});var li=b(R()),H4=e=>t=>{let n=$v(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},B4=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=M("TabCompletion",vo),s=Ep(),a=(0,Kp.useMemo)(()=>H4(e.getBoundingClientRect()),[e]),[l,c]=Up(e);return(0,Kp.useEffect)(()=>{c?s.open():s.close()},[c]),(0,li.jsxs)("span",{children:[(0,li.jsx)("mark",{ref:Vp([l,s.triggerRef]),className:(0,uP.default)(i.matchKeyword,{[i.hover]:c}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,li.jsx)(La,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,li.jsx)(jp,{style:n,children:(0,li.jsx)("div",{className:i.hintText,children:o})})})]})},Wp=class extends ao{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(S({},o),{keywordRegex:new RegExp(`\\b${aP(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(lP);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,li.jsx)(B4,{inputElement:r.inputElement,suggestion:r.suggestion,inputStyle:r.inputStyle,boundaryRef:r.boundaryRef,children:n},`keyword_${r.matchString}_${r.key}`)}asTag(){return"mark"}};var dP=b(Ne());var u0=b(R()),U4=({inputElement:e,children:t})=>{let n=M("TabCompletion",vo),[r,o]=Up(e);return(0,u0.jsx)("mark",{ref:r,className:(0,dP.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},Gp=class extends ao{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,u0.jsx)(U4,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var Yp=b(Ne());var Zt=b(Z());var d0=b(R()),fP=()=>(0,d0.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,d0.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 Mr=b(Z());var mP=b(By());var pP={root:"dd-ky-Bv",content:"dd-kV5e1"};function qp(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 f0(e){return e.replace("https://www.","").replace("https://","")}var Vn=b(R()),V4=3,$4=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),j4=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=V4})=>{let i=M("LinkSearch",pP),[s,a]=(0,Mr.useState)(""),l=ve(),c=j(xR("url")),u=j(X1("URL")),d=(0,Mr.useMemo)(()=>u.map($4),[u]),[f,p]=(0,Mr.useState)(d.length-1),v=te("fallbackImage"),m=h=>{let w=h.target;a(w.value)},x=(h,w)=>{h.stopPropagation(),h.preventDefault(),window.open(w,"_blank")},y=h=>{var C;let w=f-1<0?d.length-1:f-1,E=f+1===d.length?0:f+1;h.code==="Escape"&&(a(""),t()),h.code==="ArrowUp"&&p(w),h.code==="ArrowDown"&&p(E),h.code==="Enter"&&e(((C=d[f])==null?void 0:C.text)||s)},g=(0,Mr.useCallback)((0,mP.default)(h=>{l(Fi({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,Mr.useEffect)(()=>{s&&g(s)},[s]),(0,Mr.useEffect)(()=>()=>{l(Sf())},[]),(0,Vn.jsxs)("div",{className:i.root,children:[(0,Vn.jsx)(Ht,{withDivider:!0,children:(s?d:c).slice(0,o).map((h,w)=>(0,Vn.jsx)(ye,{selected:f===w,onClick:()=>e(h.text),"data-testid":"linksearch-suggestion",children:(0,Vn.jsxs)(Te,{children:[(0,Vn.jsx)(Te.Image,{src:qp(h,"small",v||void 0),title:h.title||h.text}),(0,Vn.jsxs)(Te.Content,{className:i.content,cropText:!0,children:[(0,Vn.jsx)(Te.Title,{children:h.title||f0(h.text)}),h.title&&f0(h.text)]}),(0,Vn.jsx)(ye.Actions,{children:(0,Vn.jsx)(ye.ActionButton,{label:r,onClick:E=>x(E,h.text)})})]})},h.text))}),(0,Vn.jsx)(uc,{value:s,onChange:m,autoFocus:!0,placeholder:n,onKeyUp:y})]})},gP=j4;var p0={};Rt(p0,{enUS:()=>W4,nlNL:()=>K4});var W4={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},K4={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var Qt=b(R()),G4=(0,Zt.forwardRef)((e,t)=>{let n=M("TabCompletion",vo);return(0,Qt.jsx)("mark",{ref:t,className:(0,Yp.default)(n.matchSelection)},"selection-start")}),q4=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=ue(p0),s=M("TabCompletion",vo),a=(0,Zt.useRef)(null),l=(0,Zt.useRef)(null),[c,u]=(0,Zt.useState)(null),d=ve(),f=Ep(document.activeElement===r),[p]=(0,Zt.useState)(()=>document.createRange());f.triggerRef.current=p,(0,Zt.useEffect)(()=>()=>p.detach(),[]),(0,Zt.useEffect)(()=>{let m=e.current,x=a.current;!m||!x||(p.setStart(m,0),p.setEnd(x,0))},[e.current,a.current]),ri(()=>{f.close()});let v=(0,Zt.useCallback)(m=>{let x=p.toString(),y=/^http(s?):\/\//.test(m)?m:`https://${m}`;d(gf({text:`[${x}](${y})`,replace:"selection"}))},[]);return(0,Qt.jsxs)("span",{children:[(0,Qt.jsx)("mark",{ref:a,className:(0,Yp.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":f.opened?"true":"false",children:o}),f.opened&&(0,Qt.jsx)(La,{className:s.popoverRoot,triggerRef:f.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,Qt.jsxs)(jp,{style:n,ref:l,children:[(0,Qt.jsx)("div",{className:(0,Yp.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:c!==null}),children:(0,Qt.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>u("insertLink"),children:[(0,Qt.jsx)(fP,{}),(0,Qt.jsx)("span",{children:"\xA0"}),(0,Qt.jsx)("span",{children:i("insertLink")})]})}),c==="insertLink"&&(0,Qt.jsx)(gP,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:v,onDismiss:()=>{u(null),f.close()}})]})})]},"selection-end")},Xp=class extends ao{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,Zt.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?S({isStart:a},s):null}replaceWith(n,r){return r.isStart?(0,Qt.jsx)(G4,{ref:this.startRef}):(0,Qt.jsx)(q4,{inputElement:r.inputElement,startRef:this.startRef,boundaryRef:r.boundaryRef,inputStyle:r.inputStyle})}asTag(){return"mark"}};var xo=b(R()),Y4=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let c=M("TabCompletion",iP),u=te("insertLink"),d=te("showMidSentenceSuggestions"),f=te("inlineSuggestions"),p=nP(a),v=(0,wo.useRef)(null),m=j($t);(0,wo.useEffect)(()=>{fs(a)&&p&&rP(a,p)},[p]);let x=(0,wo.useCallback)(h=>{if(!o||!n)return h;let w=[(0,xo.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,xo.jsx)("span",{"data-testid":"tab-completion",className:(0,Qp.default)(c.tabText,c.resetIndent),"data-source":l,children:n},"tabText")];return r&&w.push((0,xo.jsx)("span",{className:(0,Qp.default)(c.hint,c.resetIndent),children:(0,xo.jsx)(ku,{keyCode:"tab"},"tabHint")})),l0(h,w)},[o,n,r]),y=(0,wo.useMemo)(()=>{let h=[];return u&&h.push(new Xp("selection")),h.push(new Gp("placeholders")),i&&h.push(new Wp("keywords")),h},[f,u,i]),g=(0,wo.useMemo)(()=>{let h=window.getComputedStyle(a);return{"--dd-color":h.color,"--dd-font-size":h.fontSize,"--dd-font-family":h.fontFamily,"--dd-font-variant":h.fontVariant}},[]);return!e||!m?null:(0,xo.jsxs)("div",{ref:h=>{h!=null&&h.parentElement&&(v.current=h==null?void 0:h.parentElement)},className:c.root,style:g,children:[(0,xo.jsx)(Ki,{tagName:"span",containerTagName:"div",className:(0,Qp.default)(c.container,c.agentText),disableLineBreaks:fs(a),content:t||"\u200B",onAfterParse:x,matchers:y,selection:p,keywordMatches:s,inputElement:a,inputStyle:g,boundaryRef:v,inlineSuggestionsOnlyAtEnd:!d}),(0,xo.jsx)("br",{})]})},X4=e=>{var x,y,g;let{input:t,ui:n,settings:r,styleSuggestions:o,conversation:i}=e,s=la({input:t}),a=(s==null?void 0:s.text)||"",l=(s==null?void 0:s.source)||"",c=(x=t.html)!=null?x:fa(t.text),u=a.indexOf(t.text)===0?a.slice(t.text.length):"",{showTabHint:d}=n,{isSupported:f}=i,{showTabCompletion:p,visible:v,showStyleSuggestions:m}=r;return{showTabHint:d,showStyleSuggestions:m,showTabCompletion:p&&Nr(e),content:c,tabText:u,source:l,keywordMatches:(g=(y=o.list)==null?void 0:y.keywordMatches)!=null?g:[],enabled:v&&f!==!1}},hP=oa(X4)(Y4);var ci=b(Z());var Q4={token:null,interval:null},m0=ge("passwordlessToken/getTemporaryPasswordlessToken",(e,t)=>I(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return{token:yield n.requestPasswordlessToken()}})),g0=ge("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(m0()),setInterval(()=>r(m0()),n)}),yP=ke({name:"passwordlessToken",initialState:Q4,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(m0.fulfilled,(t,n)=>{t.token=n.payload.token}),e.addCase(g0.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:vP}=yP.actions,xP=yP.reducer;function Z4(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}var wP=Dn([ST],e=>e.map(n=>({text:n.response,title:n.name,callToAction:n.callToAction,isLoading:n.isLoading,specialType:n.specialType,rule:{id:Z4(n.code),label:n.code,name:n.name,description:n.name}})));var Zp=b(Z());var y0=b(Ne());var h0=b(R()),eu=()=>(0,h0.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,h0.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 SP={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var Dr=b(R()),J4=({entities:e})=>{let t=M("EntitiesWidgetList",SP),[n,r]=(0,Zp.useState)(void 0),o=ve(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),Ar(a.text),o(ro({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Zp.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,Dr.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,Dr.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,Dr.jsx)("span",{className:t.entityText,children:a.text}),(0,Dr.jsxs)("span",{className:t.iconWrapper,children:[(0,Dr.jsx)("span",{className:(0,y0.default)(t.icon),children:(0,Dr.jsx)(eu,{})}),(0,Dr.jsx)("span",{className:(0,y0.default)(t.icon,n===l&&t.iconClicked),children:(0,Dr.jsx)(eu,{})})]})]},a.text))})},bP=J4;var v0=b(R()),EP=()=>(0,v0.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,v0.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 TP={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var CP={root:"dd-nazq3",rotation:"dd-3EHTv"};var RP=b(R()),eF=({size:e=12})=>{let t=M("LoadingSpinner",CP);return(0,RP.jsx)("span",{"data-testid":"loading-spinner",style:{width:`${e}px`,height:`${e}px`},className:t.root})},kP=eF;var x0=b(R()),PP=()=>(0,x0.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512",fill:"currentColor",children:(0,x0.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 tu=b(R()),AP=e=>(0,tu.jsxs)("svg",P(S({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 448 512","aria-labelledby":"checkTitle"},e),{children:[(0,tu.jsx)("title",{id:"checkTitle",children:"Check"}),(0,tu.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 w0={};Rt(w0,{enUS:()=>tF,nlNL:()=>nF});var tF={error:[{type:0,value:"Something went wrong"}]},nF={error:[{type:0,value:"Er ging iets fout"}]};var Rn=b(R()),IP,rF=3e3,oF=({assistantOptions:e})=>{let t=M("OnDemandAssistants",TP),n=ue(w0),r=es(nr),o=es(io),i=j(RT),s=j(PT),a=ct(),l=s.filter(d=>d.isPinned),c=s.filter(d=>!d.isPinned),u=d=>I(void 0,null,function*(){if(clearTimeout(IP),a("trigger on demand assistant",{assistantCode:d}),d===i){o.call({transcript:e.transcript});return}r.call(P(S({},e),{assistantCode:d})),IP=setTimeout(()=>r.reset(),rF)});return s.length===0?null:(0,Rn.jsxs)("div",{className:t.root,children:[l.map(({assistant:d,assistantName:f})=>(0,Rn.jsx)("button",{type:"button",className:t.button,disabled:r.state==="loading",onClick:()=>u(d),children:f},d)),r.state==="loading"&&(0,Rn.jsx)(kP,{}),r.state==="done"&&(0,Rn.jsx)(AP,{"data-testid":"trigger-done"}),r.state==="error"&&(0,Rn.jsx)(fk,{trigger:(0,Rn.jsx)(PP,{}),children:n("error")}),c.length>0&&r.state==="idle"&&(0,Rn.jsxs)(yt,{placement:"top-end",children:[(0,Rn.jsx)(yt.Trigger,{className:t.trigger,children:(0,Rn.jsx)(Pp,{"data-testid":"trigger"})}),(0,Rn.jsx)(yt.Content,{className:t.nav,"data-testid":"popover",children:c.map(({assistant:d,assistantName:f})=>(0,Rn.jsx)(yt.Button,{className:t.item,disabled:r.state==="loading",onClick:()=>u(d),children:f},d))})]})]})},LP=oF;var NP=b(Z());var _P={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};var OP=b(R()),iF=({width:e})=>{let t=M("LoadingProgressBar",_P);return(0,OP.jsx)("div",{className:t.loadingBar,style:{width:e}})},Jp=iF;var So=b(R()),em=({title:e})=>{let t=(0,NP.useRef)(null);return Lx(t),(0,So.jsx)(ye,{ref:t,children:(0,So.jsx)(Te,{children:(0,So.jsxs)(Te.Content,{children:[(0,So.jsx)(Te.Title,{children:e}),(0,So.jsx)(Jp,{width:"60%"}),(0,So.jsx)(Jp,{width:"90%"}),(0,So.jsx)(Jp,{width:"50%"})]})})})};var nu={};Rt(nu,{enUS:()=>sF,nlNL:()=>aF});var sF={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"}]},aF={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 ps=b(Z());var S0={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=b(R()),lF=500,cF=100,uF=({content:e,onChange:t,onCopy:n})=>{let r=(0,ps.useRef)(null),o=M("WidgetCue",S0);return(0,ps.useEffect)(()=>{let i=r.current;if(!i)return;i.style.setProperty("height","0px");let s=Math.min(Math.max(i.scrollHeight,cF),lF);i.style.setProperty("height",`${s}px`)},[e]),(0,Mt.jsx)("textarea",{ref:r,className:o.editableCue,onCopy:n,onChange:t,value:e})},dF=({cue:e,onCallToAction:t,onRemove:n,onCopy:r,onUse:o})=>{var m;let i=M("WidgetCue",S0),s=ue(nu),a=ct(),l=te("hasKeyboardInput"),[c,u]=(0,ps.useState)(e.text),d=()=>{t&&t(e),n(e)},f=x=>{r&&r(x,e)},p=x=>{o&&o(x,e)},v=x=>{x.preventDefault(),x.stopPropagation(),n(e)};return(0,ps.useEffect)(()=>{a("Assistant response displayed",{name:e.rule.name,description:e.rule.description,group:e.rule.label,cueText:e.text})},[]),(0,Mt.jsxs)(ye,{"data-testid":"cue",children:[(0,Mt.jsx)(Te,{children:(0,Mt.jsxs)(Te.Content,{children:[e.title&&(0,Mt.jsx)(Te.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)(uF,{content:c,onCopy:()=>{let x=document.getSelection();x&&f(x.toString())},onChange:x=>{var y;return u((y=x.target.value)!=null?y:"")}}):(0,Mt.jsx)(ho,{content:e.text,useLabel:s("useCue"),copyLabel:s("copyCue"),onCopy:f,onUse:l?p:void 0})]})}),(0,Mt.jsxs)(ye.ButtonsContainer,{children:[(0,Mt.jsxs)("div",{className:i.actions,children:[e.specialType==="summary"&&(0,Mt.jsx)(ye.Button,{onClick:()=>f(c),children:s("copyCue")}),e.callToAction&&(0,Mt.jsx)(ye.Button,{onClick:d,children:e.callToAction.label}),(0,Mt.jsx)(ye.Button,{onClick:v,children:s("removeCue")})]}),e.specialType==="summary"?(0,Mt.jsx)(ts,{eventName:"summary feedback",feedbackText:(m=e.text)!=null?m:"",feedbackType:"summary",eventData:{summary:e.text}}):(0,Mt.jsx)(ts,{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"})]})]})},MP=dF;var Fa=b(R()),fF=({cues:e})=>{let t=ve(),n=un(),r=ue(nu),o=ct(),i=c=>{t(ET({code:c.rule.label})),o("Assistant response closed",{name:c.rule.name,group:c.rule.label,description:c.rule.description,cueText:c.text})},s=(c,u)=>{switch(Ar(c),u.specialType){case"summary":o("summary copied to clipboard",{originalText:u.text,finalText:c,assistant:u.rule.label});break;default:o("Assistant response copied",{name:u.rule.name,group:u.rule.label,description:u.rule.description,copiedText:c})}},a=c=>{c.callToAction&&(t(Of(c)),o("Assistant call to action",{name:c.rule.name,group:c.rule.label,description:c.rule.description,eventName:c.callToAction.event,value:c.callToAction.value}))},l=(c,u)=>{n.send(Pr,{text:c,suggestion:{source:"cue",sourceText:c}}),o("Assistant response used",{name:u.rule.name,group:u.rule.label,description:u.rule.description,usedText:c})};return(0,Fa.jsx)(Fa.Fragment,{children:e.map(c=>c.isLoading?(0,Fa.jsx)(em,{title:c.rule.label.startsWith("__")?r(c.rule.label):c.title},c.rule.id):(0,Fa.jsx)(MP,{cue:c,onCallToAction:a,onRemove:i,onCopy:s,onUse:l},c.rule.id))})},DP=fF;var tm=b(Z());var FP={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var hr=b(R());function pF(e,t){return t.split(".").reduce((n,r)=>!n||typeof n!="object"||!(r in n)?null:n[r],e)}var zP=({data:e,schema:t})=>{let n=M("WidgetCustomData",FP),r=o=>{Ar(o)};return(0,tm.useEffect)(()=>{J.info("Custom data",e,t)},[e]),(0,hr.jsx)("dl",{className:n.root,children:t.map(o=>{let i=pF(e,o.path);return(0,hr.jsxs)(tm.Fragment,{children:[(0,hr.jsx)("dt",{className:n.label,children:o.label}),(0,hr.jsx)("dd",{className:n.value,children:o.type==="boolean"&&i?(0,hr.jsx)("span",{className:n.isTrue,children:o.trueValue}):o.type==="boolean"&&!i?(0,hr.jsx)("span",{className:n.isFalse,children:o.falseValue}):typeof i=="string"||typeof i=="number"?(0,hr.jsxs)("button",{type:"button",onClick:()=>r(`${i}`),className:n.copyButton,children:[(0,hr.jsx)("span",{className:n.copyButtonText,children:i}),(0,hr.jsx)(eu,{})]}):"-"})]},o.label)})})};var ut=b(Z());var za={};Rt(za,{enUS:()=>mF,nlNL:()=>gF});var mF={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"}]},gF={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 nm={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 we=b(R()),hF=3,yF=({sources:e,onClick:t})=>{let n=ue(za),r=M("WidgetKnowledgeAssistant",nm),[o,i]=(0,ut.useState)(!1),s=o?e:e.slice(0,hF);return s.length===0?null:(0,we.jsxs)("ul",{className:r.sources,children:[s.map(a=>(0,we.jsx)("li",{className:r.source,"data-testid":"knowledge-assist-source",children:(0,we.jsxs)(yt,{tooltip:!0,placement:"top-start",children:[(0,we.jsx)(yt.Trigger,{as:"a",rel:"noreferrer",target:"_blank",href:a.url,onClick:l=>{l.stopPropagation(),t(a)},children:(0,we.jsx)("span",{className:r.linkContent,children:a.name})}),a.url&&(0,we.jsx)(yt.Content,{className:r.tooltip,children:decodeURIComponent(a.url)})]})},a.name)),s<e&&(0,we.jsx)("button",{type:"button",className:r.showMoreSources,onClick:()=>i(!0),children:n("showMore",{amount:e.length-s.length})})]})},vF=({title:e,description:t})=>(0,we.jsx)(ye,{"data-testid":"knowledge-assist-empty-state",children:(0,we.jsx)(Te,{children:(0,we.jsxs)(Te.Content,{children:[(0,we.jsx)(Te.Title,{children:e}),(0,we.jsx)(ho,{content:t})]})})}),xF=({innerRef:e,item:t,index:n,hasKeyboardInput:r,onCopy:o,onUse:i,onSourceClick:s})=>{var l;let a=ue(za);return(0,we.jsxs)(ye,{"data-testid":"knowledge-assist-answer",ref:e,children:[(0,we.jsx)(Te,{children:(0,we.jsxs)(Te.Content,{children:[(0,we.jsx)(Te.Title,{children:t.question}),(0,we.jsx)(ho,{content:t.answer.answer,useLabel:a("useCue"),copyLabel:a("copyCue"),onCopy:o,onUse:r?i:void 0}),(0,we.jsx)(yF,{sources:(l=t.answer.sources)!=null?l:[],onClick:c=>s(c,t.question)})]})}),(0,we.jsxs)(ye.ButtonsContainer,{children:[(0,we.jsx)("div",{}),(0,we.jsx)(ts,{eventName:"knowledge assist feedback",eventData:{question:t.question,isFollowUpQuestion:n>0,isAgent:!0,answer:t.answer.answer},feedbackText:t.answer.answer,feedbackType:"assistant"})]})]})},b0=(0,ut.createContext)(null),rm=({assistantCode:e,evaluateKnowledgeAssistFn:t,initialQuestion:n,children:r})=>{let[o,i]=(0,ut.useState)(null),[s,a]=(0,ut.useState)(!1),[l,c]=(0,ut.useState)(!!n),[u,d]=(0,ut.useState)(null),f=ve(),p=ct(),v=es(y=>{if(!e)throw new Error("No knowledge assistant was defined");return t({assistantCode:e,input:y,threadId:o,onNewThreadId(g){i(g)}})},{onSuccess(y){var g;p("knowledge assist question answered",{question:y.question,answer:y.answer.answer,sources:(g=y.answer.sources)!=null?g:[],isFollowUpQuestion:y.threadId===o,isAutoInitiated:l}),c(!1)}}),m=y=>I(void 0,null,function*(){a(!0),d(y),yield v.call(y),a(!1),d(null)}),x={isEnabled:!!e,isSubmitting:s,threadId:o,pendingInput:u,onSubmit:m,onReset(){o&&f(da(o)),i(null)}};return(0,ut.useEffect)(()=>{n&&m(n)},[n]),(0,we.jsx)(b0.Provider,{value:x,children:r})},om=()=>{let e=ue(za),t=M("WidgetKnowledgeAssistant",nm),n=(0,ut.useContext)(b0),r=(0,ut.useRef)(null),[o,i]=(0,ut.useState)(""),s=l=>{i(l.target.value)},a=l=>{l.preventDefault(),n.onSubmit(o).then(()=>{var c;r.current&&((c=r.current)==null||c.focus(),i(""))})};return n.isEnabled?(0,we.jsxs)("form",{className:t.form,onSubmit:a,children:[(0,we.jsx)("input",{ref:r,className:t.formInput,placeholder:e("inputPlaceholder"),type:"text",disabled:n.isSubmitting,value:o,onChange:s}),(0,we.jsx)("button",{type:"submit",disabled:n.isSubmitting||o==="",className:t.formSubmit,children:e("submitLabel")})]}):null},im=({title:e,emptyState:t})=>{var v,m;let n=ue(za),r=ct(),o=M("WidgetKnowledgeAssistant",nm),i=(0,ut.useRef)(null),s=(0,ut.useContext)(b0),a=(m=j(fc((v=s.threadId)!=null?v:-1)))!=null?m:[],l=te("hasKeyboardInput"),c=un(),u=x=>{Ar(x),r("Assistant response copied",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",copiedText:x})},d=(x,y)=>{r("knowledge assist source viewed",{question:y,sourceViewed:x.url||x.name})},f=x=>{var y;x.preventDefault(),s.onReset(),r("knowledge assist reset",{threadId:(y=s.threadId)!=null?y:void 0})},p=x=>{c.send(Pr,{text:x,suggestion:{source:"cue",sourceText:x}}),r("Assistant response used",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",usedText:x})};return!s.isEnabled||(a==null?void 0:a.length)===0&&!s.isSubmitting&&!t?null:(0,we.jsxs)(ut.Fragment,{children:[(0,we.jsx)(wr,{type:"knowledge",title:e,"data-testid":"knowledge",children:(0,we.jsxs)(Ht,{withDivider:!0,children:[t&&a.length===0&&!s.pendingInput&&(0,we.jsx)(vF,S({},t)),a.map((x,y)=>(0,we.jsx)(xF,{innerRef:y===a.length-1?i:void 0,item:x,index:y,hasKeyboardInput:l,onCopy:u,onUse:p,onSourceClick:d},`${x.question}_${x.answer}_${y}`)),s.pendingInput&&(0,we.jsx)(em,{title:s.pendingInput})]})}),a.length>0&&(0,we.jsx)("div",{className:o.resetContainer,children:(0,we.jsx)(ye.Button,{disabled:s.threadId===null||s.isSubmitting,onClick:f,children:n("resetLabel")})})]})};var UP=b(Z());var wF=/(https?:\/\/[^\s]+)/,BP=e=>e.split(" ").find(t=>wF.test(t));var $n=b(R()),SF=({suggestion:e,lines:t,onUse:n})=>{var d;let r=e.text||e.url||e.message,o=BP(r),i=ue(Kc),s=te("showImages"),a=te("fallbackImage"),l=te("hasKeyboardInput"),c=f=>{f.preventDefault(),f.stopPropagation(),l&&n(r)},u=(0,UP.useCallback)(f=>{window.open(o,"_blank"),f.stopPropagation(),f.preventDefault()},[o]);return(0,$n.jsxs)(ye,{onClick:l?c:void 0,"data-testid":"edit-suggestion",children:[(0,$n.jsxs)(Te,{children:[s&&e.image&&(0,$n.jsx)(Te.Image,{src:qp(e,"small",a||void 0),title:e.title}),(0,$n.jsxs)(Te.Content,{children:[e.title&&(0,$n.jsx)(Te.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((d=e.searchKeywords)==null?void 0:d.length)>0&&(0,$n.jsx)(ye.Labels,{labels:e.searchKeywords}),(0,$n.jsx)(Te.Content,{cropText:t==="single",lineClamp:t==="multiple",children:r})]})]}),(0,$n.jsxs)(ye.Actions,{children:[o&&(0,$n.jsx)(ye.ActionButton,{onClick:u,label:i("visitUrl")}),l&&(0,$n.jsx)(ye.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},VP=SF;var ru=b(R()),bF=({lines:e,suggestions:t})=>{let n=un(),r=(o,i)=>{n.send(Pr,{text:o,suggestion:P(S({},i),{source:i.source,sourceText:i.text})})};return(0,ru.jsx)(ru.Fragment,{children:t.map(o=>(0,ru.jsx)(VP,{suggestion:o,lines:e,onUse:i=>r(i,o)},o.text||o.url||o.message))})},$P=bF;var ou={};Rt(ou,{enUS:()=>EF,nlNL:()=>TF});var EF={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"}],close:[{type:0,value:"Close"}]},TF={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"}],close:[{type:0,value:"Sluiten"}]};var Ha={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 ce=b(R()),WP=(e,t)=>{let n=j($t);(0,ci.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},CF=({onLogIn:e})=>{let t=M("Widget",Ha),n=te("isEmbedded"),r=te("adminUrl");return(0,ce.jsx)("div",{className:t.loginText,children:(0,ce.jsx)("div",{children:(0,ce.jsx)(zp,{isEmbedded:n,loginUrl:r,onLogIn:e})})},"login")},jP=({text:e})=>{let t=M("Widget",Ha);return(0,ce.jsx)("div",{className:t.stateText,children:(0,ce.jsx)("div",{children:(0,ce.jsx)("p",{children:e})})},"notification")},kF=()=>{let e=ue(ou),t=ve(),n=M("Widget",Ha),r=te("showSearch"),o=te("isEmbedded"),i=j(Aa("/admin/")),s=un(),a=te("productName"),l=ct();return WP(()=>{if(o)return t(g0()),()=>{t(vP())}},[t,o]),!r&&!i?null:(0,ce.jsxs)("div",{className:n.shortcutList,children:[r&&(0,ce.jsx)(ye.Button,{"data-testid":"shortcut-search","aria-label":e("linkSearch"),className:n.shortcut,icon:(0,ce.jsx)(Ca,{}),onClick:()=>{s.send("ShowCommandPalette",{isOpen:!0}),l("open search",{via:"widget-shortcut"})},children:e("linkSearch")}),i&&(0,ce.jsx)(ye.Button,{as:"a",target:"_blank",icon:(0,ce.jsx)(EP,{}),href:i,"data-testid":"shortcut-studio-login","aria-label":e("linkStudioLogin",{productName:a}),className:n.shortcut,rel:"noreferrer",onClick:()=>{l("open my deepdesk",{via:"widget-shortcut"})},children:e("linkStudioLogin",{productName:a})})]})},RF=({title:e,content:t})=>{let n=ue(ou),[r,o]=(0,ci.useState)(!0);return r?(0,ce.jsx)(wr,{"data-testid":"custom-data-banner",type:"custom-data-banner",title:e,children:(0,ce.jsx)(Ht,{withDivider:!0,children:(0,ce.jsxs)(ye,{children:[(0,ce.jsx)(Te,{children:(0,ce.jsx)(Te.Content,{children:(0,ce.jsx)(ho,{content:t})})}),(0,ce.jsx)(ye.ButtonsContainer,{children:(0,ce.jsx)(ye.Button,{onClick:()=>o(!1),children:n("close")})})]})})}):null},PF=()=>{let e=ve(),t=j(gc),n=j(IT),r=j(wP),o=j(U1),i=j(hp),s=j(Lp),a=j(Ui),l=j(Rr);return(0,ci.useEffect)(()=>{!!o&&!n&&J.warn("Custom data provided, but no schema.")},[o,n]),WP(()=>{t.forEach(({type:c})=>{c==="entities"?e(ur()):Au.includes(c)||e(gr(c))})},[e,l,a]),(0,ci.useEffect)(()=>{r.length>0&&!t.some(c=>c.type==="cues")&&J.warn("Received cues, but cues are not configured in widget.")},[t,r]),(0,ce.jsx)(ci.Fragment,{children:t.map(({type:c,title:u,amount:d,lines:f,schema:p,property:v})=>{var m,x;switch(c){case"entities":return i&&i.length>0&&(0,ce.jsx)(wr,{type:c,title:u,"data-testid":`type-${c}`,children:(0,ce.jsx)(bP,{entities:i})},c);case"cues":return r&&r.length>0&&(0,ce.jsx)(wr,{type:c,title:u,"data-testid":`type-${c}`,children:(0,ce.jsx)(Ht,{withDivider:!0,children:(0,ce.jsx)(DP,{cues:r})})},c);case"custom-data-banner":return o&&v&&o[v]&&(0,ce.jsx)(RF,{title:u,content:String(o[v])});case"custom-data":return o&&p&&(0,ce.jsx)(wr,{type:c,title:u,"data-testid":`type-${c}`,children:(0,ce.jsx)(Ht,{withDivider:!0,children:(0,ce.jsx)(zP,{data:o,schema:p})})},c);default:return((x=(m=s[c])==null?void 0:m.suggestions)==null?void 0:x.length)>0&&(0,ce.jsx)(wr,{type:c,title:u,"data-testid":`type-${c}`,children:(0,ce.jsx)(Ht,{withDivider:!0,children:(0,ce.jsx)($P,{lines:f,contentType:c,suggestions:s[c].suggestions.slice(0,d)||[]})})},c)}})})},E0=({children:e})=>{let t=M("Widget",Ha);return(0,ce.jsx)("div",{className:t.footer,children:e})},T0=({children:e})=>{let t=M("Widget",Ha);return(0,ce.jsx)("div",{className:t.root,"data-testid":"widget",children:e})},AF=({onLogIn:e,knowledgeAssistOptions:t={},assistantOptions:n={transcript:"in-memory-transcript",expectFormat:"json-schema:cues"}})=>{let r=ue(ou),o=j(sa),i=j($t),s=j(C1),a=j(Ui),l=j(AT("knowledge-assist")),c=j(Nf),u=j(Mf);return o===!1?(0,ce.jsx)(jP,{text:r("notSupported")}):i===!1?(0,ce.jsx)(CF,{onLogIn:e}):!a||!s||i===null?(0,ce.jsx)(jP,{text:r("waiting")}):(0,ce.jsx)(T0,{children:(0,ce.jsxs)(rm,{initialQuestion:t.initialQuestion,assistantCode:c!=null?c:u,evaluateKnowledgeAssistFn:u?Hi:Bi,children:[(0,ce.jsxs)(Ts,{children:[(0,ce.jsx)(kF,{}),(0,ce.jsx)(PF,{}),l&&(0,ce.jsx)(im,{title:l.title,emptyState:t.emptyState})]}),(0,ce.jsxs)(E0,{children:[l&&(0,ce.jsx)(om,{}),(0,ce.jsx)(LP,{assistantOptions:n})]})]})})},KP=AF;function Ba(e){let t=new Range;return t.selectNodeContents(e),t}function GP(e,t,n){try{return ui(e,t,n),!0}catch(r){return!1}}function sm(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function am(e){return"tagName"in e&&e.tagName==="BR"}var iu=/[\u200B-\u200D\uFEFF]/g;function ui(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,c){let u=-1,d=/[\u200B-\u200D\uFEFF]/;if(!d.test(l))return c;for(let f=0;f<=l.length;f++)if(d.test(l[f])||u++,u===c)return f;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,u=c.replace(iu,""),d=o+u.length,f=t>=o&&t<=d,p=n>=o&&n<=d;if(f){let v=s(c,t-o);v===0&&!p?r.setStartBefore(l):r.setStart(l,v)}p&&(r.setEnd(l,s(c,n-o)),i=!0),o=d;break}case Node.ELEMENT_NODE:{if(am(l)&&(o===t&&r.setStartBefore(l),o++,o===n)){r.setEndAfter(l),i=!0;return}for(let u=0;u<l.childNodes.length&&(a(l.childNodes[u]),!i);u++);let c=l.lastChild;sm(l)&&c&&!sm(c)&&!am(c)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function su(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,c=0;function u(d){let f=d===e,p=d===n,v=d===o;switch(d.nodeType){case Node.TEXT_NODE:{let m=d.textContent;p&&(a=c+m.substring(0,r).replace(iu,"").length),v&&(l=c+m.substring(0,i).replace(iu,"").length),c+=m.replace(iu,"").length;break}case Node.ELEMENT_NODE:{if(am(d)&&d.nextSibling){c++;break}!f&&sm(d)&&d.previousSibling&&c++;for(let m=0;m<d.childNodes.length;m++){let x=p&&m===r,y=v&&m===i;if(x&&(a=c),y&&(l=c),l!==void 0||((!x||!s)&&u(d.childNodes[m]),v&&m===i-1&&(l=c),l!==void 0))break}v&&(l=c);break}default:break}}if(u(e),l===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:l,end:l}}function au(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 c(u){let d=u===e,f=u===n,p=u===o;switch(f&&(a=1),u.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let v=f?r:0,m=p?i:void 0;l+=u.textContent.replace(iu,"").substring(v,m);break}case Node.ELEMENT_NODE:{if(!s&&a===1&&am(u)&&u.nextSibling){l+=`
|
|
81
81
|
`;break}!d&&!s&&a===1&&sm(u)&&u.previousSibling&&(l+=`
|
|
82
|
-
`);let v=f?r:0,m=p?Math.min(i,u.childNodes.length):u.childNodes.length;for(let x=v;x<m&&(c(u.childNodes[x]),a!==2);x++);break}default:break}p&&(a=2)}return c(e),l}var qP=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(qP||{}),bo=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();Yo(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(qP).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 YP(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var ms=class extends bo{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),au(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!YP(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!YP(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return su(this.element,n);let r=this.lastKnownSelection;if(r&&GP(this.element,r.start,r.end))return r;let o=Ba(this.element);return o.collapse(!1),su(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return au(this.element,ui(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 IF=["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 XP(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",IF.forEach(u=>{o[u]=i[u]}),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(),c={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),c}var gs=class extends bo{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 XP(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 QP(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 LF(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var C0=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()}},k0=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=QP(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()}},R0=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(),J.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 k0(t,this.deepdeskUrl,{debug:!0}):new C0(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=LF(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(J.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;J.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(S({},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)}},ZP=R0;function _F(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(S({},t),{[_F(n)]:$e(e[n])}),{}):e}function OF(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Ct(e){return Array.isArray(e)?e.map(Ct):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>P(S({},t),{[OF(n)]:Ct(e[n])}),{}):e}var Ua=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var P0=e=>new Promise(t=>{setTimeout(t,e)});var Va=class extends Ua{constructor(){super(...arguments);this.name="ClientError"}},I0=class extends Ua{constructor(){super(...arguments);this.name="ServerError"}},A0=new Map;function NF(e){return I(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:(J.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var di=class di{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",C=n,{useCache:c=!1,abortLatest:u=!1,attempts:d=1,retryDelay:f=500,refreshTokenOn401:p=!0,retryOnError:v=k=>k instanceof TypeError,retryOnResponse:m=k=>k.status>=500,version:x=null}=C,y=oe(C,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(c){if(!l)throw new Error(`Can't use 'useCache' for ${n.method}`);if(A0.has(s)){r(A0.get(s));return}}let g=P(S({credentials:"include"},y),{headers:S({Accept:"application/json","Content-Type":"application/json"},y.headers)});!l&&this.csrfToken&&(g.headers=P(S({},g.headers),{"X-CSRFToken":this.csrfToken})),typeof x=="string"&&(g.headers=P(S({},g.headers),{"X-Deepdesk-API-Version":x}));let h=d,w=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&u&&(this.latestRequestByUrl[s].isAborted=!0,this.latestRequestByUrl[s].reject(new Error("Aborted"))),this.latestRequestByUrl[s]=i;let E=()=>I(this,null,function*(){return h--,a(s,g).then(k=>I(this,null,function*(){return m(k)&&!i.isAborted&&h>0?(yield P0(f),E()):k.status===401&&p===!0&&w===!1?(w=!0,yield this.refreshToken(),E()):k})).catch(k=>I(this,null,function*(){if(v(k)&&!i.isAborted&&h>0)return yield P0(f),E();throw k}))});E().then(k=>I(this,null,function*(){let A=yield NF(k);if(delete this.latestRequestByUrl[s],k.status>=500){o(new I0("Server Error",A));return}if(k.status===401){o(new Va("Unauthorized",A));return}if(k.status===403){o(new Va("Forbidden",A));return}if(k.status===404){o(new Va("Not Found",A));return}if(k.status>=400){o(new Va("Bad Request",A));return}c&&A0.set(s,A),r(A)})).catch(k=>{o(k)})})}validateToken(){return I(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 di.refreshingToken||(di.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{di.refreshingToken=null},1e3*60)})),di.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,S({method:"POST",body:JSON.stringify(n)},r))}patch(t,n,r){return this.request(t,S({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,S({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,S({method:"DELETE"},n))}};di.refreshingToken=null;var hs=di;var JP;(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={}))})(JP||(JP={}));function L0(e){return P(S({},$e(e)),{metadata:e.metadata})}var ys=class ys{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new hs(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,i)=>I(this,null,function*(){let s=yield r(o,i);return this.handleDeepdeskVersionHeaders(s),s}))}preflight(){return I(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(ys.exchangeTokenPromise||(ys.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),ys.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return I(this,null,function*(){var r;yield this.preflight(),J.info(`Creating conversation for session ${t.externalId} and agent ${t.agentId}`);let n=yield this.client.post("/api/v2/conversations",P(S({chat_start_time:new Date().toISOString()},Ct(t)),{metadata:(r=t.metadata)!=null?r:{}}));return L0(n)})}getMe(){return I(this,null,function*(){let t=yield this.client.get("/apis/admin/session/me/");return $e(t)})}postIdentity(t){return I(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",Ct(t))})}patchMe(t){return I(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",Ct(t));return $e(n)})}getProfile(t){return I(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{useCache:!0});return $e(n)})}getKnowledgeAssistant(t){return I(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{useCache:!0});return $e(n)})}getContentTypes(){return I(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return $e(t)})}getAccount(){return I(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{useCache:!0});return $e(t)})}getPlatformConfig(t){return I(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 I(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`,{version:"v1"});return n})}getConversationByExternalId(r){return I(this,arguments,function*(t,n={}){yield this.preflight(),J.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 J.info(`Successfully retrieved conversation ${s.id} for session ${t}`),L0(s)})}isConversationSupported(r){return I(this,arguments,function*(t,n={}){J.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 I(this,null,function*(){var i;yield this.preflight();let r=Ct(n);n.metadata&&(r.metadata=(i=n.metadata)!=null?i:{});let o=yield this.client.put(`/api/v2/conversations/${t}`,r);return L0(o)})}postMessages(t,n){return I(this,null,function*(){yield this.preflight(),yield this.client.post(`/api/v2/conversations/${t}/messages`,n.map(r=>P(S({},Ct(r)),{metadata:r.metadata})))})}sendEvent(t,n){return I(this,null,function*(){yield this.preflight();let s=n,{data:r}=s,o=oe(s,["data"]),i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((a,[l,c])=>P(S({},a),{[l]:c}),{});return this.client.post("/api/events",Ct(P(S(S({},i),o),{data:r,name:t})),{version:"v2"})})}sendEventV1(t,n){return I(this,null,function*(){yield this.preflight();let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>P(S({},o),{[i]:s}),{});return this.client.post("/api/events",{event:t,data:Ct(S(S({},n),r))},{version:"v1"})})}getEntities(t){return I(this,null,function*(){return yield this.preflight(),(yield this.client.post("/api/entities",{messages:t.filter(r=>r.text)},{version:"v1"})).entities})}getTemporaryExchangeToken(){return I(this,null,function*(){return(yield this.client.get("/auth/exchange-token")).jwt})}exchangeTokenForAccessCookie(t){return I(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t}).catch(n=>{throw J.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return I(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Ct(n),{refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return I(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}`,Ct(n),{abortLatest:!0})).map(s=>P(S({},$e(s)),{text:s.text||s.url||s.message,source:r,type:r})).filter((s,a,l)=>a===l.findIndex(c=>c.text===s.text))})}isLoggedIn(){return I(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return I(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${t}/autocomplete`,Ct(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 I(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${t}/pinned-messages`,{abortLatest:!0});return $e(n).map(r=>P(S({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return I(this,null,function*(){let n=yield this.client.post("/api/style-suggestions",Ct(t),{abortLatest:!0,version:"v1"});return $e(n)})}search(t){return I(this,null,function*(){let n=yield this.client.post(`/api/profiles/${t.profile}/search`,Ct(t),{version:"v2"});return $e(n)})}knowledgeAssist(i,s,a){return I(this,arguments,function*(t,n,r,o={}){yield this.preflight();let l=yield this.client.post(`/api/knowledge-assist/assistants/${r}/search`,Ct({question:t.question,doNotKnowAnswer:t.doNotKnowAnswer,customerInstruction:t.customerInstruction,chatHistory:n.map(c=>({question:c.question,answer:c.answer.answer})),agentId:o.agentId,conversationId:o.conversationId}),{version:"v2"});return $e(l)})}requestLoginByEmail(t){return I(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t});return $e(n)})}requestPasswordlessToken(){return I(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/");return $e(t.token)})}getCsrfToken(){return I(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/");return t})}verifyLoginToken(t){return I(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t});return $e(n)})}getSummary(r){return I(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 I(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 I(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 I(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 I(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/translate",Ct(t),{version:"v2"});return $e(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(Vx);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&J.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};ys.exchangeTokenPromise=null;var Eo=ys;var eA={startTime:null,stopTime:null},tA=e=>e.handlingTime,nA=ke({name:"handlingTime",initialState:eA,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(at,()=>eA)}}),{handlingTimeStart:rA,handlingTimeStop:lm,handlingTimeReset:oA}=nA.actions,iA=nA.reducer;var sA=(e={})=>{let t=S({onAuthError:ia(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var cm={list:{keywordMatches:[]},fetchState:"idle"};var vs=ge("styleSuggestions/getAll",(n,r)=>I(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 cm.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),MF=ke({name:"styleSuggestions",initialState:cm,reducers:{},extraReducers:e=>{e.addCase(vs.pending,t=>{t.fetchState="loading"}).addCase(vs.rejected,t=>{t.fetchState="error"}).addCase(vs.fulfilled,(t,n)=>{t.fetchState="done",Yo(t.list,n.payload)||(t.list=n.payload)}).addCase(Di,t=>{t.list=cm.list}).addCase(at,()=>cm)}}),aA=MF.reducer;var lA=(e={})=>{let t,n=!0,r=S({getStyleSuggestions:vs,debounce:500},e);return o=>i=>s=>{var p;let a=o.getState().input.text,l=i(s),c=o.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:u}=c.settings;if(!((p=c.conversation.current)==null?void 0:p.id)||!u)return l;let{text:f}=c.input;return f===a&&!n||(clearTimeout(t),f==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:f}))},e.debounce)),l}};function DF(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var cA=(e={})=>{let t=S({getTextSuggestions:gr,getAutocompleteSuggestions:qc,debounce:200,check:Nr},e),n;return r=>o=>i=>{var m;let{input:s}=r.getState(),a=o(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:u}=l.settings,d=(m=l.conversation.current)==null?void 0:m.id,f=i.type===_p.toString();if(!d||!c&&!u)return a;let{input:p}=l;return DF(p,s)&&!f||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let x=aa(l);x===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(x))},f?0:t.debounce)),a}};var uA=vs.fulfilled.toString();function FF(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 dA=e=>t=>n=>r=>{var c;if(r.type!==uA){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let i=t.getState(),s=i.styleSuggestions.list,a=(c=i.conversation)==null?void 0:c.current;if(o===s)return;let l=FF(o,s);r.type===uA&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var zF=Qd({assistants:TT,auth:g1,conversation:k1,contentTypes:kT,passwordlessToken:xP,entities:Sk,handlingTime:iA,info:K1,input:z1,settings:l1,profile:LT,search:Z1,styleSuggestions:aA,ui:FR,textSuggestions:bR});function fA(e){return DE({reducer:zF,middleware:t=>{var r;let n=t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI}},serializableCheck:!1}).concat(sA()).concat(cA({debounce:200})).concat(lA({debounce:500})).concat(dA(e.deepdeskAPI));return((r=e.middleware)!=null?r:[]).reduce((o,i)=>o.concat(i),n)},preloadedState:e.preloadedState})}var HF=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},BF=e=>t=>n=>r=>{var a,l,c,u,d,f;let o=t.getState(),i=Gl("inlineSuggestions")(o);switch(r.type){case ia.toString():{!r.payload&&e.emit("logout",void 0);break}case ur.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 ro.toString():e.sendEvent(r.payload.name,{conversationId:((l=r.payload.options)==null?void 0:l.includeConversationData)&&((c=o.conversation.current)==null?void 0:c.id),data:r.payload.data});break;case Di.toString():e.logSendMessage(r.payload);break;case Of.toString():e.emit("call-to-action",{cue:r.payload});break;case nr.fulfilled.toString():r.isBroadcasted||e.broadcast(Cy,r,!1);break;default:break}let s=n(r);switch(r.type){case Di.toString():e.handleAfterSendMessage(r.payload);break;case Xc.toString():e.onUpdateShowTabHint(r.payload);break;case lm.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case gf.toString():{let{start:p,end:v}=o.input.selection;e.emit("replace",P(S({},r.payload),{replace:r.payload.replace==="selection"?{start:p,end:v}:{start:0,end:v}}));break}case er.toString():{let{start:p,end:v}=o.input.selection;e.emit("select-suggestion",P(S({type:HF(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:p,end:v}:{start:0,end:v}})),i&&t.dispatch(Xo([]));break}case hf.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(u=o.conversation.current)==null?void 0:u.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case Xo.toString():{i&&r.payload.length>0&&t.dispatch(yf(0));break}case io.fulfilled.toString():{e.sendEvent("conversation summarized",{conversationId:(d=o.conversation.current)==null?void 0:d.id,data:{summary:r.payload,assistant:(f=t.getState().profile.data)==null?void 0:f.summarizerAssistantNew}}),e.emit("summary-generated",{summary:r.payload});break}default:break}return s},pA=BF;function _0(e){return e.toISOString().replace("T"," ").replace("Z","")}var UF=(e,t)=>t.version,mA=Dn([ca,Rr,tA,UF],(e,t,n,r)=>{if(!t)return J.warn("No conversationId for handling time metrics"),null;let{startTime:o,stopTime:i}=n;return!o||!i?(J.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:_0(o),timeStop:_0(i)}});function gA(e,t,n){var A,F,N,O;let r=(A=t.conversation.current)==null?void 0:A.id;if(!r)return J.warn("No conversationId for send message metrics"),null;let{text:o,metrics:{numCharsTyped:i,numCharsPasted:s,numCharsCut:a,numCharsDeleted:l,numPaste:c,agentStartedTypingTimestamp:u,externalTimeTotalSeconds:d,pastes:f,cuts:p,deletions:v,textSuggestions:m,offeredTextSuggestions:x}}=t[e],y=o.length,h=m.reduce((q,{text:K,searchTerm:L})=>q+K.length-(L?L.length:0),0),w=u!=null?u:Date.now(),E=(Date.now()-w)/1e3+(d||0),C=i/E,k=m.reduce((q,{searchTerm:K})=>q+(K?K.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:f,cuts:p,deletions:v,lenTextTyped:i+k,lenTextTotal:y,lenTextAssisted:h,lenTextPasted:s,lenTextCut:a,lenTextDeleted:l,timeTotalSeconds:E,charsPerSecond:C,numPastes:c,textSuggestionsV2:m,suggestionsCounters:[{source:"gpt",countOffered:x.filter(q=>q.source==="gpt").length}],agentId:(F=t.info.agentInfo)==null?void 0:F.agentId,agentName:(N=t.info.agentInfo)==null?void 0:N.agentName,agentEmail:(O=t.info.agentInfo)==null?void 0:O.agentEmail}}function O0(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return O0(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?O0(o,t):null}function N0(e,t){return O0(e,t)}function hA(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function VF(e){return typeof e=="object"&&e!==null&&"tagName"in e}function um(e){return VF(e)&&(fs(e)||Bp(e))}var vA,Fr=new Map,$F=["bottom","height","left","right","top","width"],yA=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:$F.some(n=>e[n]!==t[n]);function xA(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,...xA(t)]:[]}function wA(e,t){return!e||!t?null:P(S({},e),{top:e.top+t.top,left:e.left+t.left})}var dm=!1,SA=()=>{dm=!0;let e=[];if(Fr.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Fr.delete(n);return}let r=n.getBoundingClientRect();yA(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(wA,t.rect):t.rect;yA(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Fr.size===0){dm=!1;return}vA=window.requestAnimationFrame(SA)};function M0(e,t){let n=xA(e),r=[],o=n.map((i,s)=>M0(i,a=>{r[s]=a;let l=Fr.get(e);if(!l)return;let c=r.reduce(wA,l.rect);l.callbacks.forEach(u=>u(c))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),Fr.has(e)){let s=Fr.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else Fr.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!dm&&SA()},unobserve(){o.forEach(s=>s.unobserve());let i=Fr.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||Fr.delete(e),Fr.size||(cancelAnimationFrame(vA),dm=!1)}}}}var bA,zr=new Map,EA=()=>{zr.forEach((e,t)=>{if(!t.isConnected){zr.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)))}),zr.size!==0&&(bA=window.requestAnimationFrame(EA))};function TA(e,t){return{observe(){let n=zr.size===0;zr.has(e)?zr.get(e).callbacks.push(t):zr.set(e,{visible:void 0,callbacks:[t]}),n&&EA()},unobserve(){let n=zr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||zr.delete(e),zr.size||cancelAnimationFrame(bA)}}}}var D0=["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 F0(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function $a(e){return Number.parseFloat(e)}function fm(e){return Math.round(e*1e6)}function CA(e){return e/1e6}function z0(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=$a(e.width),i=$a(e.borderLeftWidth),s=$a(e.borderRightWidth),a=$a(e.paddingRight),l=CA(fm(o)-fm(i)-fm(s)),c=CA(fm(r));if(l-c>2){let u=l-c;n.style.paddingRight=`${a+u}px`}}function lu(e,t={}){var u,d;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(u=t.position)!=null?u:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",rs(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};F0(r,n,D0),z0(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=TA(e,()=>{F0(r,n,D0),z0(r,e,n),i(),setTimeout(i,0)}),a,l=!0,c=M0(e,f=>{if(f===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),f.height===0&&f.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(F0(r,n,D0),z0(r,e,n),i(),n.style.top=`${f.top}px`,n.style.left=`${f.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let p=t.closestScrollElement.getBoundingClientRect(),v=window.getComputedStyle(t.closestScrollElement),m=$a(v.borderTopWidth),x=$a(v.borderBottomWidth),y=p.top+m-f.top,g=f.top+f.height+-(p.top+p.height-x);n.style.clipPath=`inset(${y}px 0px ${g}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(d=e.parentElement)==null||d.appendChild(n),c.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),c.unobserve(),s.unobserve(),n.remove()}]}var kA=(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){J.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function jF(e){return e.offsetParent!==null}function RA(e){if(!jF(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 pm(e,t,n=100){let r=RA(e);t({isVisible:r});let o=setInterval(()=>{let i=RA(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var cu=class extends Error{},mm=class{constructor(){this.queues={}}push(t,n){if(!this.queues[t]){let o=n();this.queues[t]=[o,null];let i=()=>{let s=this.queues[t][1];s?(this.queues[t]=[s.promise,null],s.resolve()):delete this.queues[t]};return o.then(i).catch(i),o}this.queues[t][1]&&this.queues[t][1].reject(new cu("Queued async function is outdated"));let r=Promise.withResolvers();return this.queues[t][1]=r,r.promise.then(()=>n())}};var Le=b(R());var PA=kA("showTabHint",!0),ja=class ja{constructor({deepdeskUrl:t,version:n=ja.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.widgetElement=null;this.widgetRoot=null;this.dynamicThunkObject={};this.queues=new mm;this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let l=t.replace(/\/api$/,"");this.deepdeskApi=new Eo(l,{token:o,fetch:i}),this.version=n,this.instanceId=ja.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[pA({broadcast:(u,d,f)=>{this.broadcastEvents.send(u,d,f)},emit:(u,d)=>this.emit(u,d),handleAfterSendMessage:u=>this.handleAfterSendMessage(u),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:u=>this.logSendMessage(u),onUpdateShowTabHint:u=>PA.update(u),sendEvent:(u,d)=>this.deepdeskApi.sendEvent(u,d)})]};this.store=fA(c),this.broadcastEvents=new ZP({debug:!0,deepdeskUrl:l,eventMap:J1(this.store),createCustomChannel:a}),this.store.dispatch(Xc(PA.value())),this.store.dispatch(uf({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?(J.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(J.warn("Profile has not been loaded (yet)"),!0):(J.warn("No conversation loaded (yet)"),!0)}login(){this.store.dispatch(ia(null)),this.store.dispatch(to());let t=n=>$t(n)&&c1(n)!=="loading";return new Promise(n=>{let r=this.subscribe(t,o=>{o&&(r(),n())});this.unmountHandlers.push(()=>{r()})})}isLoggedIn(){return I(this,null,function*(){return(yield this.store.dispatch(to())).payload})}isConversationSupported(t,n){return I(this,null,function*(){return(yield this.store.dispatch(vy({externalId:t,options:n}))).payload})}createConversation(t){return I(this,null,function*(){var r;return this.hasConversation()&&this.externalId()!==t.externalId&&this.resetConversation(),(yield this.store.dispatch(ff(P(S({},t),{metadata:(r=t.metadata)!=null?r:{}})))).payload})}getConversationByExternalId(t,n){return I(this,null,function*(){return this.hasConversation()&&this.externalId()!==t&&this.resetConversation(),(yield this.store.dispatch(pf({externalId:t,options:n}))).payload})}upsertConversation(t){return I(this,null,function*(){var r;return this.hasConversation()&&this.externalId()!==t.externalId&&this.resetConversation(),(yield this.store.dispatch(xy(P(S({},t),{metadata:(r=t.metadata)!=null?r:{}})))).payload})}postMessages(t){return I(this,null,function*(){yield this.store.dispatch(wy(t))})}updateConversation(t){return I(this,null,function*(){return(yield this.store.dispatch(mf(t))).payload})}resetConversation(){this.store.dispatch(at()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(t){this.store.dispatch(uf(t))}setVisitorInfo(t){this.store.dispatch($1(t))}setCustomData(t){this.store.dispatch(j1(t))}setAgentInfo(t,n){return I(this,null,function*(){yield this.store.dispatch(Xl(S(S({},t),n)))})}setAgentSettings(t){return I(this,null,function*(){yield this.store.dispatch(by(t))})}getAgentSettings(){return I(this,null,function*(){return(yield this.store.dispatch(Ey())).payload})}refresh(){return I(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(vf({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let t=[];return this.store.dispatch(_p()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}notifyExternalSuggestion(t){this.store.dispatch(er(t))}evaluateAssistant(t,n){return I(this,null,function*(){let u=n||{},{input:r={},transcript:o,showCuesInWidget:i=!0,includeMetadata:s,expectFormat:a}=u,l=oe(u,["input","transcript","showCuesInWidget","includeMetadata","expectFormat"]);Object.assign(r,l);let c=yield this.store.dispatch(nr({assistantCode:t,expectFormat:a||"json-schema:cues",transcript:o,includeMetadata:s,input:r,skipState:!i}));if(c.error)throw new Error(c.error.message);return c.payload})}evaluateConversationAssistant(t,n){return I(this,null,function*(){yield this.loadProfileConfig();let r=this.state.profile.data;if(!r){J.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){J.warn(`No assistant set in profile for conversation event "${t}"`);return}return this.queues.push(i,()=>I(this,null,function*(){yield this.evaluateAssistant(i,S({includeMetadata:!0},n))})).catch(a=>{if(J.error(a),!(a instanceof cu))throw a})})}getSummary(){return I(this,arguments,function*(t={}){var r;if(!this.hasConversation())return J.warn("No conversation to create summary for."),null;(r=this.state.profile.data)!=null&&r.summarizerAssistantNew||J.warn("No profile loaded yet, or no summarizer assistant set in profile");let n=yield this.store.dispatch(io(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,c=a?"below":"above",u=o.length>0;if(this.store.dispatch(L1(Sy(t))),!Nr(this.state)||t.key!=="Tab"&&!l)return;let d=()=>{n||!u||s&&(t.shiftKey||(this.store.dispatch(N1()),t.preventDefault()))},f=()=>{n||!u||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(M1()),t.preventDefault()))};switch(t.key){case"ArrowUp":c==="below"?f():d();break;case"ArrowDown":{c==="below"?d():f();break}case"Escape":{n||(this.store.dispatch(yf(-1)),this.store.dispatch(oi({collapse:!0})),this.store.dispatch(MR(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let p=la(this.state);if(!p)return;this.store.dispatch(Xc(!1)),this.store.dispatch(er({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=la(this.state);if(!p)return;this.store.dispatch(er({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=la(this.state);if(!p)return;this.store.dispatch(er({text:p.text,suggestion:p,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(oi({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(Xo([]))}handlingTimeStart(){this.state.handlingTime.startTime||(J.info("Start handling time"),this.store.dispatch(rA()))}handlingTimeStop(){this.state.handlingTime.startTime&&(J.info("Stop handling time"),this.store.dispatch(lm()))}logSendMessage(t){let n=gA("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=mA(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(oA()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(Di((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(F1()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(i){J.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),J.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(W1(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]=lu(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),[i,s]}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,c]=lu(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{c()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return rs(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),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),J.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()?(J.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(D1(r.metrics))):J.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(!um(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let f=n,{customStyles:r,closestScrollSelector:o,floatingMenuParent:i,appendOverlayTo:s,inputMediator:a}=f,l=oe(f,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),c={customStyles:r,closestScrollSelector:o,floatingMenuParent:i,appendOverlayTo:s};this.configure(l),this.settings.automaticHandlingTime&&this.setupHandlingTime(t),rs(t),this.inputMediator=a||(fs(t)?new gs(t):new ms(t)),this.inputMediator.on("change",({plainText:p,rawHTML:v})=>{this.store.dispatch(vf({text:p,html:v}))}),this.inputMediator.on("keyup",p=>{this.store.dispatch(_1(Sy(p)))}),this.inputMediator.on("keydown",p=>{this.handleKeyDown(p)}),this.inputMediator.on("paste",({pastedText:p,selectionText:v})=>{this.store.dispatch(O1({text:p,selectionText:v}))}),this.inputMediator.on("cut",({selectionText:p})=>{this.store.dispatch(I1(p))});let u;this.inputMediator.on("selection",p=>{clearTimeout(u),p===null?u=setTimeout(()=>{p!==null&&this.store.dispatch(xf(p))},500):this.store.dispatch(xf(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(Mp(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(Mp(!0))}),this.renderSuggestions(t,c),this.subscribe(Gl("inlineSuggestions"),()=>{this.renderSuggestions(t,c)});let d=this.renderOverlays(n);this.unmountHandlers.push(()=>{d.unmount()}),this.store.dispatch(vf({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(xf(this.inputMediator.getSelection())),this.store.dispatch(Mp(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"),i=(0,fi.createRoot)(o);i.render((0,Le.jsx)(si,{store:this.store,customStyles:r,children:(0,Le.jsx)(Qo,{broadcastEvents:this.broadcastEvents,children:(0,Le.jsx)(WR,{})})}));let s=a=>{a?(o.style.display="block",o.style.top=`${a.top}px`,o.style.left=`${a.left}px`):o.style.display="none"};return this.inputMediator.on("caretposition",s),{unmount:()=>{var a;(a=this.inputMediator)==null||a.off("caretposition",s),i.unmount(),o.remove()}}}renderAboveSuggestions(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:i}=n,s=o&&N0(t,o)||void 0,[a,l]=this.overlayContainerFactory("deepdesk-tab-completion",s||t,{appendTo:i,closestScrollElement:s,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),[c,u]=this.overlayContainerFactory("deepdesk-suggestions-overlay",s||t,{appendTo:i},r==null?void 0:r.suggestionsRootNode),d=(0,fi.createRoot)(a);d.render((0,Le.jsx)(si,{store:this.store,customStyles:r,children:(0,Le.jsx)(Qo,{broadcastEvents:this.broadcastEvents,children:(0,Le.jsx)(hP,{inputElement:t})})}));let f=(0,fi.createRoot)(c);return f.render((0,Le.jsx)(si,{store:this.store,customStyles:r,children:(0,Le.jsx)(Qo,{broadcastEvents:this.broadcastEvents,children:(0,Le.jsx)(eP,{onLogIn:()=>this.loginViaPopup().catch(p=>J.warn(p.message))})})})),{unmount(){d.unmount(),f.unmount(),l(),u()}}}renderFloatingMenu(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:i,floatingMenuParent:s}=n,a=o&&N0(t,o)||void 0,[l,c]=this.overlayContainerFactory("floating-menu",a||t,{appendTo:s!=null?s:i},r==null?void 0:r.floatingMenuParent),u=(0,fi.createRoot)(l);return u.render((0,Le.jsx)(si,{store:this.store,customStyles:r,children:(0,Le.jsx)(Qo,{broadcastEvents:this.broadcastEvents,children:(0,Le.jsx)(OR,{onLogIn:()=>this.loginViaPopup().catch(d=>J.warn(d.message))})})})),{unmount(){u.unmount(),c()}}}renderOverlays(t){let{customStyles:n}=t,r=this.createContainer("deepdesk-overlays"),o=(0,fi.createRoot)(r);return o.render((0,Le.jsx)(si,{store:this.store,customStyles:n,children:(0,Le.jsx)(Qo,{broadcastEvents:this.broadcastEvents,children:(0,Le.jsx)(PR,{})})})),{unmount(){o.unmount(),r.remove()}}}renderWidget(t,n={}){if(this.widgetElement&&J.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.widgetElement=t,this.configure({showImages:o,isEmbedded:i}),this.widgetRoot=(0,fi.createRoot)(t),this.widgetRoot.render((0,Le.jsx)(si,{store:this.store,customStyles:r,children:(0,Le.jsx)(Qo,{broadcastEvents:this.broadcastEvents,children:(0,Le.jsx)(KP,{assistantOptions:n.assistantOptions,knowledgeAssistOptions:n.knowledgeAssist,onLogIn:()=>this.loginViaPopup().catch(s=>J.warn(s.message))})})})),this.whenConversationLoaded(()=>{var s;this.broadcastEvents.setExternalId((s=this.state.conversation.current)==null?void 0:s.externalId)})}unmountWidget(){var t,n;(t=this.widgetRoot)==null||t.unmount(),this.widgetRoot=null,(n=this.widgetElement)==null||n.remove(),this.widgetElement=null}renderKnowledgeAssistantWidget(t,n,r={}){let{customStyles:o,initialQuestion:i}=r,s=(0,fi.createRoot)(n);return s.render((0,Le.jsx)(si,{store:this.store,customStyles:o,children:(0,Le.jsx)(Qo,{broadcastEvents:this.broadcastEvents,children:(0,Le.jsx)(T0,{children:(0,Le.jsxs)(rm,{assistantCode:t,initialQuestion:i,evaluateKnowledgeAssistFn:r.isLegacyKnowledgeAssist?Hi:Bi,children:[(0,Le.jsx)(Ts,{children:(0,Le.jsx)(im,{emptyState:r.emptyState})}),(0,Le.jsx)(E0,{children:(0,Le.jsx)(om,{})})]})})})})),{unmount(){s.unmount()}}}setupHandlingTime(t){let n=pm(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){hA(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>I(this,null,function*(){yield this.store.dispatch(mc());let t=Ui(this.state);t&&this.store.dispatch(uf({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 I(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,c=()=>{u&&!u.closed&&u.close(),window.removeEventListener("message",d),clearInterval(f)};i.onmessage=p=>I(this,null,function*(){var v,m;if((v=p.data)!=null&&v.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((m=p.data)==null?void 0:m.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(Zl),l=!0,o.port1.close(),n()}catch(x){console.error(x),r(x)}finally{l=!0,c()}});let u=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");u===null&&r(new Error("Popup blocked by browser"));let d=p=>I(this,null,function*(){var v;if(p.origin===a.origin)switch((v=p.data)==null?void 0:v.type){case"deepdesk-popup-loaded":{try{let m=JSON.stringify({type:"deepdesk-popup-create-channel"});u==null||u.postMessage(m,a.origin,[o.port2])}catch(m){J.error("Error posting message to popup",m),r(m)}break}case"deepdesk-popup-error":{c(),p.data.message==="Timeout"&&J.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(p.data.message));break}}});window.addEventListener("message",d);let f=setInterval(()=>{u&&!u.closed||(c(),l||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(c)})})}translateMessages(t){return this.deepdeskApi.translateMessages(t)}checkForTrialMode(t){return I(this,null,function*(){try{let{account:n}=yield this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(J.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;J.info(r),this.shouldRender=!1}})}refreshWidgetSuggestions(){return I(this,null,function*(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=gc(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(ur()):Au.includes(r)||this.store.dispatch(gr(r))})}catch(r){this.handleError(r)}})}};ja.version="17.0.0-rc.12",ja.count=0;var uu=ja;function WF(e){return I(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 AA(e,t){return I(this,null,function*(){let n=yield WF(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 IA(e,t,n){return I(this,null,function*(){yield new Eo(e).authenticateWithKey(t,n)})}function LA(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function _A(r,o){return I(this,arguments,function*(e,t,n={}){var d,f;let{value:i}=e,{start:s,end:a}=(d=n.replace)!=null?d:{start:0,end:i.length},l=`${i.slice(0,s)}${t}${i.slice(a)}`,c=(f=n.selectionAfter)!=null?f:{start:s+t.length,end:s+t.length},u=()=>{if(n.setValue)return n.setValue(l);e.value=l};return Promise.resolve(u()).then(()=>{e.selectionStart=c.start,e.selectionEnd=c.end,e.blur(),e.focus()})})}function OA(r,o){return I(this,arguments,function*(e,t,n={}){let i=n.replace?ui(e,n.replace.start,n.replace.end):Ba(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(`
|
|
82
|
+
`);let v=f?r:0,m=p?Math.min(i,u.childNodes.length):u.childNodes.length;for(let x=v;x<m&&(c(u.childNodes[x]),a!==2);x++);break}default:break}p&&(a=2)}return c(e),l}var qP=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(qP||{}),bo=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();Yo(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(qP).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 YP(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var ms=class extends bo{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),au(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!YP(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!YP(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return su(this.element,n);let r=this.lastKnownSelection;if(r&&GP(this.element,r.start,r.end))return r;let o=Ba(this.element);return o.collapse(!1),su(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return au(this.element,ui(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 IF=["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 XP(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",IF.forEach(u=>{o[u]=i[u]}),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(),c={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),c}var gs=class extends bo{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 XP(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 QP(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 LF(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var C0=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()}},k0=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=QP(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()}},R0=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(),J.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 k0(t,this.deepdeskUrl,{debug:!0}):new C0(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=LF(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(J.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;J.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(S({},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)}},ZP=R0;function _F(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(S({},t),{[_F(n)]:$e(e[n])}),{}):e}function OF(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Ct(e){return Array.isArray(e)?e.map(Ct):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>P(S({},t),{[OF(n)]:Ct(e[n])}),{}):e}var Ua=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var P0=e=>new Promise(t=>{setTimeout(t,e)});var Va=class extends Ua{constructor(){super(...arguments);this.name="ClientError"}},I0=class extends Ua{constructor(){super(...arguments);this.name="ServerError"}},A0=new Map;function NF(e){return I(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:(J.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var di=class di{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",C=n,{useCache:c=!1,abortLatest:u=!1,attempts:d=1,retryDelay:f=500,refreshTokenOn401:p=!0,retryOnError:v=k=>k instanceof TypeError,retryOnResponse:m=k=>k.status>=500,version:x=null}=C,y=oe(C,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(c){if(!l)throw new Error(`Can't use 'useCache' for ${n.method}`);if(A0.has(s)){r(A0.get(s));return}}let g=P(S({credentials:"include"},y),{headers:S({Accept:"application/json","Content-Type":"application/json"},y.headers)});!l&&this.csrfToken&&(g.headers=P(S({},g.headers),{"X-CSRFToken":this.csrfToken})),typeof x=="string"&&(g.headers=P(S({},g.headers),{"X-Deepdesk-API-Version":x}));let h=d,w=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&u&&(this.latestRequestByUrl[s].isAborted=!0,this.latestRequestByUrl[s].reject(new Error("Aborted"))),this.latestRequestByUrl[s]=i;let E=()=>I(this,null,function*(){return h--,a(s,g).then(k=>I(this,null,function*(){return m(k)&&!i.isAborted&&h>0?(yield P0(f),E()):k.status===401&&p===!0&&w===!1?(w=!0,yield this.refreshToken(),E()):k})).catch(k=>I(this,null,function*(){if(v(k)&&!i.isAborted&&h>0)return yield P0(f),E();throw k}))});E().then(k=>I(this,null,function*(){let A=yield NF(k);if(delete this.latestRequestByUrl[s],k.status>=500){o(new I0("Server Error",A));return}if(k.status===401){o(new Va("Unauthorized",A));return}if(k.status===403){o(new Va("Forbidden",A));return}if(k.status===404){o(new Va("Not Found",A));return}if(k.status>=400){o(new Va("Bad Request",A));return}c&&A0.set(s,A),r(A)})).catch(k=>{o(k)})})}validateToken(){return I(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 di.refreshingToken||(di.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{di.refreshingToken=null},1e3*60)})),di.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,S({method:"POST",body:JSON.stringify(n)},r))}patch(t,n,r){return this.request(t,S({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,S({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,S({method:"DELETE"},n))}};di.refreshingToken=null;var hs=di;var JP;(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={}))})(JP||(JP={}));function L0(e){return P(S({},$e(e)),{metadata:e.metadata})}var ys=class ys{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new hs(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,i)=>I(this,null,function*(){let s=yield r(o,i);return this.handleDeepdeskVersionHeaders(s),s}))}preflight(){return I(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(ys.exchangeTokenPromise||(ys.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),ys.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return I(this,null,function*(){var r;yield this.preflight(),J.info(`Creating conversation for session ${t.externalId} and agent ${t.agentId}`);let n=yield this.client.post("/api/v2/conversations",P(S({chat_start_time:new Date().toISOString()},Ct(t)),{metadata:(r=t.metadata)!=null?r:{}}));return L0(n)})}getMe(){return I(this,null,function*(){let t=yield this.client.get("/apis/admin/session/me/");return $e(t)})}postIdentity(t){return I(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",Ct(t))})}patchMe(t){return I(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",Ct(t));return $e(n)})}getProfile(t){return I(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{useCache:!0});return $e(n)})}getKnowledgeAssistant(t){return I(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{useCache:!0});return $e(n)})}getContentTypes(){return I(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return $e(t)})}getAccount(){return I(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{useCache:!0});return $e(t)})}getPlatformConfig(t){return I(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 I(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`,{version:"v1"});return n})}getConversationByExternalId(r){return I(this,arguments,function*(t,n={}){yield this.preflight(),J.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 J.info(`Successfully retrieved conversation ${s.id} for session ${t}`),L0(s)})}isConversationSupported(r){return I(this,arguments,function*(t,n={}){J.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 I(this,null,function*(){var i;yield this.preflight();let r=Ct(n);n.metadata&&(r.metadata=(i=n.metadata)!=null?i:{});let o=yield this.client.put(`/api/v2/conversations/${t}`,r);return L0(o)})}postMessages(t,n){return I(this,null,function*(){yield this.preflight(),yield this.client.post(`/api/v2/conversations/${t}/messages`,n.map(r=>P(S({},Ct(r)),{metadata:r.metadata})))})}sendEvent(t,n){return I(this,null,function*(){yield this.preflight();let s=n,{data:r}=s,o=oe(s,["data"]),i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((a,[l,c])=>P(S({},a),{[l]:c}),{});return this.client.post("/api/events",Ct(P(S(S({},i),o),{data:r,name:t})),{version:"v2"})})}sendEventV1(t,n){return I(this,null,function*(){yield this.preflight();let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>P(S({},o),{[i]:s}),{});return this.client.post("/api/events",{event:t,data:Ct(S(S({},n),r))},{version:"v1"})})}getEntities(t){return I(this,null,function*(){return yield this.preflight(),(yield this.client.post("/api/entities",{messages:t.filter(r=>r.text)},{version:"v1"})).entities})}getTemporaryExchangeToken(){return I(this,null,function*(){return(yield this.client.get("/auth/exchange-token")).jwt})}exchangeTokenForAccessCookie(t){return I(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t}).catch(n=>{throw J.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return I(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Ct(n),{refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return I(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}`,Ct(n),{abortLatest:!0})).map(s=>P(S({},$e(s)),{text:s.text||s.url||s.message,source:r,type:r})).filter((s,a,l)=>a===l.findIndex(c=>c.text===s.text))})}isLoggedIn(){return I(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return I(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${t}/autocomplete`,Ct(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 I(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${t}/pinned-messages`,{abortLatest:!0});return $e(n).map(r=>P(S({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return I(this,null,function*(){let n=yield this.client.post("/api/style-suggestions",Ct(t),{abortLatest:!0,version:"v1"});return $e(n)})}search(t){return I(this,null,function*(){let n=yield this.client.post(`/api/profiles/${t.profile}/search`,Ct(t),{version:"v2"});return $e(n)})}knowledgeAssist(i,s,a){return I(this,arguments,function*(t,n,r,o={}){yield this.preflight();let l=yield this.client.post(`/api/knowledge-assist/assistants/${r}/search`,Ct({question:t.question,doNotKnowAnswer:t.doNotKnowAnswer,customerInstruction:t.customerInstruction,chatHistory:n.map(c=>({question:c.question,answer:c.answer.answer})),agentId:o.agentId,conversationId:o.conversationId}),{version:"v2"});return $e(l)})}requestLoginByEmail(t){return I(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t});return $e(n)})}requestPasswordlessToken(){return I(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/");return $e(t.token)})}getCsrfToken(){return I(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/");return t})}verifyLoginToken(t){return I(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t});return $e(n)})}getSummary(r){return I(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 I(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 I(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 I(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 I(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/translate",Ct(t),{version:"v2"});return $e(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(Vx);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&J.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};ys.exchangeTokenPromise=null;var Eo=ys;var eA={startTime:null,stopTime:null},tA=e=>e.handlingTime,nA=ke({name:"handlingTime",initialState:eA,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(at,()=>eA)}}),{handlingTimeStart:rA,handlingTimeStop:lm,handlingTimeReset:oA}=nA.actions,iA=nA.reducer;var sA=(e={})=>{let t=S({onAuthError:ia(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var cm={list:{keywordMatches:[]},fetchState:"idle"};var vs=ge("styleSuggestions/getAll",(n,r)=>I(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 cm.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),MF=ke({name:"styleSuggestions",initialState:cm,reducers:{},extraReducers:e=>{e.addCase(vs.pending,t=>{t.fetchState="loading"}).addCase(vs.rejected,t=>{t.fetchState="error"}).addCase(vs.fulfilled,(t,n)=>{t.fetchState="done",Yo(t.list,n.payload)||(t.list=n.payload)}).addCase(Di,t=>{t.list=cm.list}).addCase(at,()=>cm)}}),aA=MF.reducer;var lA=(e={})=>{let t,n=!0,r=S({getStyleSuggestions:vs,debounce:500},e);return o=>i=>s=>{var p;let a=o.getState().input.text,l=i(s),c=o.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:u}=c.settings;if(!((p=c.conversation.current)==null?void 0:p.id)||!u)return l;let{text:f}=c.input;return f===a&&!n||(clearTimeout(t),f==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:f}))},e.debounce)),l}};function DF(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var cA=(e={})=>{let t=S({getTextSuggestions:gr,getAutocompleteSuggestions:qc,debounce:200,check:Nr},e),n;return r=>o=>i=>{var m;let{input:s}=r.getState(),a=o(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:u}=l.settings,d=(m=l.conversation.current)==null?void 0:m.id,f=i.type===_p.toString();if(!d||!c&&!u)return a;let{input:p}=l;return DF(p,s)&&!f||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let x=aa(l);x===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(x))},f?0:t.debounce)),a}};var uA=vs.fulfilled.toString();function FF(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 dA=e=>t=>n=>r=>{var c;if(r.type!==uA){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let i=t.getState(),s=i.styleSuggestions.list,a=(c=i.conversation)==null?void 0:c.current;if(o===s)return;let l=FF(o,s);r.type===uA&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var zF=Qd({assistants:TT,auth:g1,conversation:k1,contentTypes:kT,passwordlessToken:xP,entities:Sk,handlingTime:iA,info:K1,input:z1,settings:l1,profile:LT,search:Z1,styleSuggestions:aA,ui:FR,textSuggestions:bR});function fA(e){return DE({reducer:zF,middleware:t=>{var r;let n=t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI}},serializableCheck:!1}).concat(sA()).concat(cA({debounce:200})).concat(lA({debounce:500})).concat(dA(e.deepdeskAPI));return((r=e.middleware)!=null?r:[]).reduce((o,i)=>o.concat(i),n)},preloadedState:e.preloadedState})}var HF=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},BF=e=>t=>n=>r=>{var a,l,c,u,d,f;let o=t.getState(),i=Gl("inlineSuggestions")(o);switch(r.type){case ia.toString():{!r.payload&&e.emit("logout",void 0);break}case ur.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 ro.toString():e.sendEvent(r.payload.name,{conversationId:((l=r.payload.options)==null?void 0:l.includeConversationData)&&((c=o.conversation.current)==null?void 0:c.id),data:r.payload.data});break;case Di.toString():e.logSendMessage(r.payload);break;case Of.toString():e.emit("call-to-action",{cue:r.payload});break;case nr.fulfilled.toString():r.isBroadcasted||e.broadcast(Cy,r,!1);break;default:break}let s=n(r);switch(r.type){case Di.toString():e.handleAfterSendMessage(r.payload);break;case Xc.toString():e.onUpdateShowTabHint(r.payload);break;case lm.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case gf.toString():{let{start:p,end:v}=o.input.selection;e.emit("replace",P(S({},r.payload),{replace:r.payload.replace==="selection"?{start:p,end:v}:{start:0,end:v}}));break}case er.toString():{let{start:p,end:v}=o.input.selection;e.emit("select-suggestion",P(S({type:HF(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:p,end:v}:{start:0,end:v}})),i&&t.dispatch(Xo([]));break}case hf.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(u=o.conversation.current)==null?void 0:u.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case Xo.toString():{i&&r.payload.length>0&&t.dispatch(yf(0));break}case io.fulfilled.toString():{e.sendEvent("conversation summarized",{conversationId:(d=o.conversation.current)==null?void 0:d.id,data:{summary:r.payload,assistant:(f=t.getState().profile.data)==null?void 0:f.summarizerAssistantNew}}),e.emit("summary-generated",{summary:r.payload});break}default:break}return s},pA=BF;function _0(e){return e.toISOString().replace("T"," ").replace("Z","")}var UF=(e,t)=>t.version,mA=Dn([ca,Rr,tA,UF],(e,t,n,r)=>{if(!t)return J.warn("No conversationId for handling time metrics"),null;let{startTime:o,stopTime:i}=n;return!o||!i?(J.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:_0(o),timeStop:_0(i)}});function gA(e,t,n){var A,F,N,O;let r=(A=t.conversation.current)==null?void 0:A.id;if(!r)return J.warn("No conversationId for send message metrics"),null;let{text:o,metrics:{numCharsTyped:i,numCharsPasted:s,numCharsCut:a,numCharsDeleted:l,numPaste:c,agentStartedTypingTimestamp:u,externalTimeTotalSeconds:d,pastes:f,cuts:p,deletions:v,textSuggestions:m,offeredTextSuggestions:x}}=t[e],y=o.length,h=m.reduce((q,{text:K,searchTerm:L})=>q+K.length-(L?L.length:0),0),w=u!=null?u:Date.now(),E=(Date.now()-w)/1e3+(d||0),C=i/E,k=m.reduce((q,{searchTerm:K})=>q+(K?K.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:f,cuts:p,deletions:v,lenTextTyped:i+k,lenTextTotal:y,lenTextAssisted:h,lenTextPasted:s,lenTextCut:a,lenTextDeleted:l,timeTotalSeconds:E,charsPerSecond:C,numPastes:c,textSuggestionsV2:m,suggestionsCounters:[{source:"gpt",countOffered:x.filter(q=>q.source==="gpt").length}],agentId:(F=t.info.agentInfo)==null?void 0:F.agentId,agentName:(N=t.info.agentInfo)==null?void 0:N.agentName,agentEmail:(O=t.info.agentInfo)==null?void 0:O.agentEmail}}function O0(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return O0(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?O0(o,t):null}function N0(e,t){return O0(e,t)}function hA(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function VF(e){return typeof e=="object"&&e!==null&&"tagName"in e}function um(e){return VF(e)&&(fs(e)||Bp(e))}var vA,Fr=new Map,$F=["bottom","height","left","right","top","width"],yA=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:$F.some(n=>e[n]!==t[n]);function xA(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,...xA(t)]:[]}function wA(e,t){return!e||!t?null:P(S({},e),{top:e.top+t.top,left:e.left+t.left})}var dm=!1,SA=()=>{dm=!0;let e=[];if(Fr.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Fr.delete(n);return}let r=n.getBoundingClientRect();yA(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(wA,t.rect):t.rect;yA(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Fr.size===0){dm=!1;return}vA=window.requestAnimationFrame(SA)};function M0(e,t){let n=xA(e),r=[],o=n.map((i,s)=>M0(i,a=>{r[s]=a;let l=Fr.get(e);if(!l)return;let c=r.reduce(wA,l.rect);l.callbacks.forEach(u=>u(c))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),Fr.has(e)){let s=Fr.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else Fr.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!dm&&SA()},unobserve(){o.forEach(s=>s.unobserve());let i=Fr.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||Fr.delete(e),Fr.size||(cancelAnimationFrame(vA),dm=!1)}}}}var bA,zr=new Map,EA=()=>{zr.forEach((e,t)=>{if(!t.isConnected){zr.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)))}),zr.size!==0&&(bA=window.requestAnimationFrame(EA))};function TA(e,t){return{observe(){let n=zr.size===0;zr.has(e)?zr.get(e).callbacks.push(t):zr.set(e,{visible:void 0,callbacks:[t]}),n&&EA()},unobserve(){let n=zr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||zr.delete(e),zr.size||cancelAnimationFrame(bA)}}}}var D0=["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 F0(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function $a(e){return Number.parseFloat(e)}function fm(e){return Math.round(e*1e6)}function CA(e){return e/1e6}function z0(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=$a(e.width),i=$a(e.borderLeftWidth),s=$a(e.borderRightWidth),a=$a(e.paddingRight),l=CA(fm(o)-fm(i)-fm(s)),c=CA(fm(r));if(l-c>2){let u=l-c;n.style.paddingRight=`${a+u}px`}}function lu(e,t={}){var u,d;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(u=t.position)!=null?u:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",rs(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};F0(r,n,D0),z0(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=TA(e,()=>{F0(r,n,D0),z0(r,e,n),i(),setTimeout(i,0)}),a,l=!0,c=M0(e,f=>{if(f===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),f.height===0&&f.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(F0(r,n,D0),z0(r,e,n),i(),n.style.top=`${f.top}px`,n.style.left=`${f.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let p=t.closestScrollElement.getBoundingClientRect(),v=window.getComputedStyle(t.closestScrollElement),m=$a(v.borderTopWidth),x=$a(v.borderBottomWidth),y=p.top+m-f.top,g=f.top+f.height+-(p.top+p.height-x);n.style.clipPath=`inset(${y}px 0px ${g}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(d=e.parentElement)==null||d.appendChild(n),c.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),c.unobserve(),s.unobserve(),n.remove()}]}var kA=(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){J.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function jF(e){return e.offsetParent!==null}function RA(e){if(!jF(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 pm(e,t,n=100){let r=RA(e);t({isVisible:r});let o=setInterval(()=>{let i=RA(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var cu=class extends Error{},mm=class{constructor(){this.queues={}}push(t,n){if(!this.queues[t]){let o=n();this.queues[t]=[o,null];let i=()=>{let s=this.queues[t][1];s?(this.queues[t]=[s.promise,null],s.resolve()):delete this.queues[t]};return o.then(i).catch(i),o}this.queues[t][1]&&this.queues[t][1].reject(new cu("Queued async function is outdated"));let r=Promise.withResolvers();return this.queues[t][1]=r,r.promise.then(()=>n())}};var Le=b(R());var PA=kA("showTabHint",!0),ja=class ja{constructor({deepdeskUrl:t,version:n=ja.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.widgetElement=null;this.widgetRoot=null;this.dynamicThunkObject={};this.queues=new mm;this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let l=t.replace(/\/api$/,"");this.deepdeskApi=new Eo(l,{token:o,fetch:i}),this.version=n,this.instanceId=ja.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[pA({broadcast:(u,d,f)=>{this.broadcastEvents.send(u,d,f)},emit:(u,d)=>this.emit(u,d),handleAfterSendMessage:u=>this.handleAfterSendMessage(u),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:u=>this.logSendMessage(u),onUpdateShowTabHint:u=>PA.update(u),sendEvent:(u,d)=>this.deepdeskApi.sendEvent(u,d)})]};this.store=fA(c),this.broadcastEvents=new ZP({debug:!0,deepdeskUrl:l,eventMap:J1(this.store),createCustomChannel:a}),this.store.dispatch(Xc(PA.value())),this.store.dispatch(uf({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?(J.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(J.warn("Profile has not been loaded (yet)"),!0):(J.warn("No conversation loaded (yet)"),!0)}login(){this.store.dispatch(ia(null)),this.store.dispatch(to());let t=n=>$t(n)&&c1(n)!=="loading";return new Promise(n=>{let r=this.subscribe(t,o=>{o&&(r(),n())});this.unmountHandlers.push(()=>{r()})})}isLoggedIn(){return I(this,null,function*(){return(yield this.store.dispatch(to())).payload})}isConversationSupported(t,n){return I(this,null,function*(){return(yield this.store.dispatch(vy({externalId:t,options:n}))).payload})}createConversation(t){return I(this,null,function*(){var r;return this.hasConversation()&&this.externalId()!==t.externalId&&this.resetConversation(),(yield this.store.dispatch(ff(P(S({},t),{metadata:(r=t.metadata)!=null?r:{}})))).payload})}getConversationByExternalId(t,n){return I(this,null,function*(){return this.hasConversation()&&this.externalId()!==t&&this.resetConversation(),(yield this.store.dispatch(pf({externalId:t,options:n}))).payload})}upsertConversation(t){return I(this,null,function*(){var r;return this.hasConversation()&&this.externalId()!==t.externalId&&this.resetConversation(),(yield this.store.dispatch(xy(P(S({},t),{metadata:(r=t.metadata)!=null?r:{}})))).payload})}postMessages(t){return I(this,null,function*(){yield this.store.dispatch(wy(t))})}updateConversation(t){return I(this,null,function*(){return(yield this.store.dispatch(mf(t))).payload})}resetConversation(){this.store.dispatch(at()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(t){this.store.dispatch(uf(t))}setVisitorInfo(t){this.store.dispatch($1(t))}setCustomData(t){this.store.dispatch(j1(t))}setAgentInfo(t,n){return I(this,null,function*(){yield this.store.dispatch(Xl(S(S({},t),n)))})}setAgentSettings(t){return I(this,null,function*(){yield this.store.dispatch(by(t))})}getAgentSettings(){return I(this,null,function*(){return(yield this.store.dispatch(Ey())).payload})}refresh(){return I(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(vf({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let t=[];return this.store.dispatch(_p()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}notifyExternalSuggestion(t){this.store.dispatch(er(t))}evaluateAssistant(t,n){return I(this,null,function*(){let u=n||{},{input:r={},transcript:o,showCuesInWidget:i=!0,includeMetadata:s,expectFormat:a}=u,l=oe(u,["input","transcript","showCuesInWidget","includeMetadata","expectFormat"]);Object.assign(r,l);let c=yield this.store.dispatch(nr({assistantCode:t,expectFormat:a||"json-schema:cues",transcript:o,includeMetadata:s,input:r,skipState:!i}));if(c.error)throw new Error(c.error.message);return c.payload})}evaluateConversationAssistant(t,n){return I(this,null,function*(){yield this.loadProfileConfig();let r=this.state.profile.data;if(!r){J.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){J.warn(`No assistant set in profile for conversation event "${t}"`);return}return this.queues.push(i,()=>I(this,null,function*(){yield this.evaluateAssistant(i,S({includeMetadata:!0},n))})).catch(a=>{if(a instanceof cu){J.warn(`Queued assistant "${i}" was outdated and dropped`);return}throw a})})}getSummary(){return I(this,arguments,function*(t={}){var r;if(!this.hasConversation())return J.warn("No conversation to create summary for."),null;(r=this.state.profile.data)!=null&&r.summarizerAssistantNew||J.warn("No profile loaded yet, or no summarizer assistant set in profile");let n=yield this.store.dispatch(io(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,c=a?"below":"above",u=o.length>0;if(this.store.dispatch(L1(Sy(t))),!Nr(this.state)||t.key!=="Tab"&&!l)return;let d=()=>{n||!u||s&&(t.shiftKey||(this.store.dispatch(N1()),t.preventDefault()))},f=()=>{n||!u||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(M1()),t.preventDefault()))};switch(t.key){case"ArrowUp":c==="below"?f():d();break;case"ArrowDown":{c==="below"?d():f();break}case"Escape":{n||(this.store.dispatch(yf(-1)),this.store.dispatch(oi({collapse:!0})),this.store.dispatch(MR(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let p=la(this.state);if(!p)return;this.store.dispatch(Xc(!1)),this.store.dispatch(er({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=la(this.state);if(!p)return;this.store.dispatch(er({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=la(this.state);if(!p)return;this.store.dispatch(er({text:p.text,suggestion:p,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(oi({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(Xo([]))}handlingTimeStart(){this.state.handlingTime.startTime||(J.info("Start handling time"),this.store.dispatch(rA()))}handlingTimeStop(){this.state.handlingTime.startTime&&(J.info("Stop handling time"),this.store.dispatch(lm()))}logSendMessage(t){let n=gA("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=mA(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(oA()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(Di((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(F1()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(i){J.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),J.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(W1(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]=lu(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),[i,s]}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,c]=lu(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{c()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return rs(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),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),J.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()?(J.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(D1(r.metrics))):J.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(!um(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let f=n,{customStyles:r,closestScrollSelector:o,floatingMenuParent:i,appendOverlayTo:s,inputMediator:a}=f,l=oe(f,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),c={customStyles:r,closestScrollSelector:o,floatingMenuParent:i,appendOverlayTo:s};this.configure(l),this.settings.automaticHandlingTime&&this.setupHandlingTime(t),rs(t),this.inputMediator=a||(fs(t)?new gs(t):new ms(t)),this.inputMediator.on("change",({plainText:p,rawHTML:v})=>{this.store.dispatch(vf({text:p,html:v}))}),this.inputMediator.on("keyup",p=>{this.store.dispatch(_1(Sy(p)))}),this.inputMediator.on("keydown",p=>{this.handleKeyDown(p)}),this.inputMediator.on("paste",({pastedText:p,selectionText:v})=>{this.store.dispatch(O1({text:p,selectionText:v}))}),this.inputMediator.on("cut",({selectionText:p})=>{this.store.dispatch(I1(p))});let u;this.inputMediator.on("selection",p=>{clearTimeout(u),p===null?u=setTimeout(()=>{p!==null&&this.store.dispatch(xf(p))},500):this.store.dispatch(xf(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(Mp(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(Mp(!0))}),this.renderSuggestions(t,c),this.subscribe(Gl("inlineSuggestions"),()=>{this.renderSuggestions(t,c)});let d=this.renderOverlays(n);this.unmountHandlers.push(()=>{d.unmount()}),this.store.dispatch(vf({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(xf(this.inputMediator.getSelection())),this.store.dispatch(Mp(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"),i=(0,fi.createRoot)(o);i.render((0,Le.jsx)(si,{store:this.store,customStyles:r,children:(0,Le.jsx)(Qo,{broadcastEvents:this.broadcastEvents,children:(0,Le.jsx)(WR,{})})}));let s=a=>{a?(o.style.display="block",o.style.top=`${a.top}px`,o.style.left=`${a.left}px`):o.style.display="none"};return this.inputMediator.on("caretposition",s),{unmount:()=>{var a;(a=this.inputMediator)==null||a.off("caretposition",s),i.unmount(),o.remove()}}}renderAboveSuggestions(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:i}=n,s=o&&N0(t,o)||void 0,[a,l]=this.overlayContainerFactory("deepdesk-tab-completion",s||t,{appendTo:i,closestScrollElement:s,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),[c,u]=this.overlayContainerFactory("deepdesk-suggestions-overlay",s||t,{appendTo:i},r==null?void 0:r.suggestionsRootNode),d=(0,fi.createRoot)(a);d.render((0,Le.jsx)(si,{store:this.store,customStyles:r,children:(0,Le.jsx)(Qo,{broadcastEvents:this.broadcastEvents,children:(0,Le.jsx)(hP,{inputElement:t})})}));let f=(0,fi.createRoot)(c);return f.render((0,Le.jsx)(si,{store:this.store,customStyles:r,children:(0,Le.jsx)(Qo,{broadcastEvents:this.broadcastEvents,children:(0,Le.jsx)(eP,{onLogIn:()=>this.loginViaPopup().catch(p=>J.warn(p.message))})})})),{unmount(){d.unmount(),f.unmount(),l(),u()}}}renderFloatingMenu(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:i,floatingMenuParent:s}=n,a=o&&N0(t,o)||void 0,[l,c]=this.overlayContainerFactory("floating-menu",a||t,{appendTo:s!=null?s:i},r==null?void 0:r.floatingMenuParent),u=(0,fi.createRoot)(l);return u.render((0,Le.jsx)(si,{store:this.store,customStyles:r,children:(0,Le.jsx)(Qo,{broadcastEvents:this.broadcastEvents,children:(0,Le.jsx)(OR,{onLogIn:()=>this.loginViaPopup().catch(d=>J.warn(d.message))})})})),{unmount(){u.unmount(),c()}}}renderOverlays(t){let{customStyles:n}=t,r=this.createContainer("deepdesk-overlays"),o=(0,fi.createRoot)(r);return o.render((0,Le.jsx)(si,{store:this.store,customStyles:n,children:(0,Le.jsx)(Qo,{broadcastEvents:this.broadcastEvents,children:(0,Le.jsx)(PR,{})})})),{unmount(){o.unmount(),r.remove()}}}renderWidget(t,n={}){if(this.widgetElement&&J.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.widgetElement=t,this.configure({showImages:o,isEmbedded:i}),this.widgetRoot=(0,fi.createRoot)(t),this.widgetRoot.render((0,Le.jsx)(si,{store:this.store,customStyles:r,children:(0,Le.jsx)(Qo,{broadcastEvents:this.broadcastEvents,children:(0,Le.jsx)(KP,{assistantOptions:n.assistantOptions,knowledgeAssistOptions:n.knowledgeAssist,onLogIn:()=>this.loginViaPopup().catch(s=>J.warn(s.message))})})})),this.whenConversationLoaded(()=>{var s;this.broadcastEvents.setExternalId((s=this.state.conversation.current)==null?void 0:s.externalId)})}unmountWidget(){var t,n;(t=this.widgetRoot)==null||t.unmount(),this.widgetRoot=null,(n=this.widgetElement)==null||n.remove(),this.widgetElement=null}renderKnowledgeAssistantWidget(t,n,r={}){let{customStyles:o,initialQuestion:i}=r,s=(0,fi.createRoot)(n);return s.render((0,Le.jsx)(si,{store:this.store,customStyles:o,children:(0,Le.jsx)(Qo,{broadcastEvents:this.broadcastEvents,children:(0,Le.jsx)(T0,{children:(0,Le.jsxs)(rm,{assistantCode:t,initialQuestion:i,evaluateKnowledgeAssistFn:r.isLegacyKnowledgeAssist?Hi:Bi,children:[(0,Le.jsx)(Ts,{children:(0,Le.jsx)(im,{emptyState:r.emptyState})}),(0,Le.jsx)(E0,{children:(0,Le.jsx)(om,{})})]})})})})),{unmount(){s.unmount()}}}setupHandlingTime(t){let n=pm(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){hA(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>I(this,null,function*(){yield this.store.dispatch(mc());let t=Ui(this.state);t&&this.store.dispatch(uf({showSearch:t.search,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:!!t.summarizerAssistantNew,showKnowledgeSearch:!!t.knowledgeAssistantNew||!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions}))})),this.loadProfileConfigPromise)}loginViaPopup(t){return I(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,c=()=>{u&&!u.closed&&u.close(),window.removeEventListener("message",d),clearInterval(f)};i.onmessage=p=>I(this,null,function*(){var v,m;if((v=p.data)!=null&&v.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((m=p.data)==null?void 0:m.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(Zl),l=!0,o.port1.close(),n()}catch(x){console.error(x),r(x)}finally{l=!0,c()}});let u=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");u===null&&r(new Error("Popup blocked by browser"));let d=p=>I(this,null,function*(){var v;if(p.origin===a.origin)switch((v=p.data)==null?void 0:v.type){case"deepdesk-popup-loaded":{try{let m=JSON.stringify({type:"deepdesk-popup-create-channel"});u==null||u.postMessage(m,a.origin,[o.port2])}catch(m){J.error("Error posting message to popup",m),r(m)}break}case"deepdesk-popup-error":{c(),p.data.message==="Timeout"&&J.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(p.data.message));break}}});window.addEventListener("message",d);let f=setInterval(()=>{u&&!u.closed||(c(),l||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(c)})})}translateMessages(t){return this.deepdeskApi.translateMessages(t)}checkForTrialMode(t){return I(this,null,function*(){try{let{account:n}=yield this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(J.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;J.info(r),this.shouldRender=!1}})}refreshWidgetSuggestions(){return I(this,null,function*(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=gc(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(ur()):Au.includes(r)||this.store.dispatch(gr(r))})}catch(r){this.handleError(r)}})}};ja.version="17.0.0-rc.13",ja.count=0;var uu=ja;function WF(e){return I(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 AA(e,t){return I(this,null,function*(){let n=yield WF(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 IA(e,t,n){return I(this,null,function*(){yield new Eo(e).authenticateWithKey(t,n)})}function LA(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function _A(r,o){return I(this,arguments,function*(e,t,n={}){var d,f;let{value:i}=e,{start:s,end:a}=(d=n.replace)!=null?d:{start:0,end:i.length},l=`${i.slice(0,s)}${t}${i.slice(a)}`,c=(f=n.selectionAfter)!=null?f:{start:s+t.length,end:s+t.length},u=()=>{if(n.setValue)return n.setValue(l);e.value=l};return Promise.resolve(u()).then(()=>{e.selectionStart=c.start,e.selectionEnd=c.end,e.blur(),e.focus()})})}function OA(r,o){return I(this,arguments,function*(e,t,n={}){let i=n.replace?ui(e,n.replace.start,n.replace.end):Ba(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
83
|
`).reverse().forEach((l,c)=>{c>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?ui(e,n.selectionAfter.start,n.selectionAfter.end):(i.collapse(!1),i),c=window.getSelection();c==null||c.removeAllRanges(),c==null||c.addRange(l)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})})}function KF(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 GF(e){let t=document.createDocumentFragment();return e.split(`
|
|
84
84
|
`).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 NA(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):NA(n,t)}function MA(o,i){return I(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 f;let l=(f=e.ownerDocument.defaultView)!=null?f:window,c=l.getSelection();if((!c||c.rangeCount===0)&&(e.focus(),c=l.getSelection()),!c||c.rangeCount===0)return;let u=c.getRangeAt(0);if(!u)return;s=document.createElement("span"),u.insertNode(s);let d=r?KF(t):GF(t);n?NA(u.startContainer,d):(u.insertNode(d),u.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 YA(qF);})();
|
|
85
85
|
/*! Bundled license information:
|