@deepdesk/deepdesk-sdk 10.9.1 → 10.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +2 -2
- package/dist/index.esm.js +2 -2
- package/dist/index.iife.js +2 -2
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -16,13 +16,13 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
|
16
16
|
`);return o=o.replace(/\n{3,}/g,`
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
`),o=o.replace(/\n/g,"<br/>"),o}createContainer(t){var n;let o=(typeof global<"u"&&global.INTERWEAVE_SSR_POLYFILL||vR)();if(!o)return;let i=(n=this.props.containerTagName)!==null&&n!==void 0?n:"body",s=i==="body"||i==="fragment"?o.body:o.createElement(i);return t.match(gR)||(s.innerHTML=this.convertLineBreaks(this.props.escapeHtml?(0,E_.default)(t):t)),s}extractAttributes(t){let{allowAttributes:n}=this.props,r={},o=0;return t.nodeType!==b_||!t.attributes||([...t.attributes].forEach(i=>{let{name:s,value:a}=i,l=s.toLowerCase(),u=Oc[l]||Oc[s];if(!this.isSafe(t)||!l.match(hR)&&(!n&&(!u||u===mg)||l.startsWith("on")||a.replace(/(\s|\0|�([9AD]);)/,"").match(/(javascript|vbscript|livescript|xss):/i)))return;let c=l==="style"?this.extractStyleAttribute(t):a;u===xr?c=!0:u===to?c=Number.parseFloat(String(c)):u!==Ac&&(c=String(c)),r[gg[l]||l]=this.applyAttributeFilters(l,c),o+=1}),o===0)?null:r}extractStyleAttribute(t){let n={};return Array.from(t.style).forEach(r=>{let o=t.style[r];(typeof o=="string"||typeof o=="number")&&(n[r.replace(/-([a-z])/g,(i,s)=>String(s).toUpperCase())]=o)}),n}getTagConfig(t){let n={children:[],content:0,invalid:[],parent:[],self:!0,tagName:"",type:0,void:!1};return ma[t]?{...n,...ma[t],tagName:t}:n}isSafe(t){if(typeof HTMLAnchorElement<"u"&&t instanceof HTMLAnchorElement){let n=t.getAttribute("href");if(n!=null&&n.startsWith("#"))return!0;let r=t.protocol.toLowerCase();return r===":"||r==="http:"||r==="https:"||r==="mailto:"||r==="tel:"}return!0}isTagAllowed(t){return this.banned.has(t)||this.blocked.has(t)?!1:this.props.allowElements||this.allowed.has(t)}parse(){return this.container?this.parseNode(this.container,this.getTagConfig(this.container.nodeName.toLowerCase())):[]}parseNode(t,n){let{noHtml:r,noHtmlExceptMatchers:o,allowElements:i,transform:s,transformOnlyAllowList:a}=this.props,l=[],u="";return[...t.childNodes].forEach(c=>{if(c.nodeType===b_){let d=c.nodeName.toLowerCase(),h=this.getTagConfig(d);u&&(l.push(u),u="");let v=this.applyNodeFilters(d,c);if(!v)return;let y;if(s&&!(a&&!this.isTagAllowed(d))){this.keyIndex+=1;let m=this.keyIndex;y=this.parseNode(v,h);let g=s(v,y,h);if(g===null)return;if(typeof g<"u"){l.push(ro.default.cloneElement(g,{key:m}));return}this.keyIndex=m-1}if(this.banned.has(d))return;if(!(r||o&&d!=="br")&&this.isTagAllowed(d)&&(i||this.canRenderChild(n,h))){var p;this.keyIndex+=1;let m=this.extractAttributes(v),g={tagName:d};m&&(g.attributes=m),h.void&&(g.selfClose=h.void),l.push(ro.default.createElement(Nc,{...g,key:this.keyIndex},(p=y)!==null&&p!==void 0?p:this.parseNode(v,h)))}else l=[...l,...this.parseNode(v,h.tagName?h:n)]}else if(c.nodeType===mR){let d=r&&!o?c.textContent:this.applyMatchers(c.textContent||"",n);Array.isArray(d)?l=[...l,...d]:u+=d}}),u&&l.push(u),l}replaceTokens(t,n){if(!t.includes("{{{"))return t;let r=[],o=t,i=null;for(;i=o.match(yR);){let[s,a]=i,l=i.index,u=s.includes("/");l>0&&(r.push(o.slice(0,l)),o=o.slice(l));let{children:c,matcher:p,props:d}=n[a],h;if(u)h=s.length,r.push(p.createElement(c,d));else{let v=o.match(new RegExp(`{{{/${a}}}}`));h=v.index+v[0].length,r.push(p.createElement(this.replaceTokens(o.slice(s.length,v.index),n),d))}o=o.slice(h)}return o.length>0&&r.push(o),r.length===0?"":r.length===1&&typeof r[0]=="string"?r[0]:r}};function SR(e){var t;let{attributes:n,className:r,containerTagName:o,content:i,emptyContent:s,parsedContent:a,tagName:l,noWrap:u}=e,c=(t=o??l)!==null&&t!==void 0?t:"span",p=c==="fragment"?!0:u,d;if(a)d=a;else{let h=new Mc(i??"",e).parse();h.length>0&&(d=h)}return d||(d=s),p?ro.default.createElement(ro.default.Fragment,null,d):ro.default.createElement(Nc,{attributes:n,className:r,tagName:c},d)}function En(e){let{attributes:t,className:n,content:r="",disableFilters:o=!1,disableMatchers:i=!1,emptyContent:s=null,filters:a=[],matchers:l=[],onAfterParse:u=null,onBeforeParse:c=null,tagName:p="span",noWrap:d=!1,...h}=e,v=i?[]:l,y=o?[]:a,m=c?[c]:[],g=u?[u]:[];v.forEach(b=>{b.onBeforeParse&&m.push(b.onBeforeParse.bind(b)),b.onAfterParse&&g.push(b.onAfterParse.bind(b))});let f=m.reduce((b,E)=>E(b,e),r??""),x=new Mc(f,h,v,y),_=g.reduce((b,E)=>E(b,e),x.parse());return ro.default.createElement(SR,{attributes:t,className:n,containerTagName:e.containerTagName,emptyContent:s,noWrap:d,parsedContent:_.length===0?void 0:_,tagName:p})}var kg=S($());var yg={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};var T_=S($());var Si=S(O());function C_(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function Dc(e){let t=(0,Si.useRef)(null),[n,r]=(0,Si.useState)(!1);return(0,Si.useEffect)(()=>{let o=!1,i=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[s,a]=C_((c,p)=>{let d=t.current;if(!d)return;let h=c/i,v=p/i,y=d.getBoundingClientRect(),m=h>y.x&&h<y.x+y.width&&v>y.y&&v<y.y+y.height;m&&!o?(o=!0,r(!0)):!m&&o&&(o=!1,r(!1))},({clientX:c,clientY:p})=>[c,p]),[l,u]=C_(()=>{o=!1,r(!1)});return e.addEventListener("mousemove",s),e.addEventListener("mouseleave",l),()=>{a(),u(),e.removeEventListener("mousemove",s),e.removeEventListener("mouseleave",l)}},[t]),[t,n]}var Cn={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var vg=S(w()),xR=({inputElement:e,children:t})=>{let n=k("TabCompletion",Cn),[r,o]=Dc(e);return(0,vg.jsx)("mark",{ref:r,className:(0,T_.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},xi=class extends wn{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,vg.jsx)(xR,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var _i=S(O());function Fc(e){return e.contentEditable==="true"}function _R(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 k_(e){let{selectionStart:t,selectionEnd:n}=Fc(e)?_R(e):e;return[t,n]}function jc(e){let[,t]=(0,_i.useState)(),n=(0,_i.useRef)(null);return n.current=k_(e),(0,_i.useEffect)(()=>{let r=()=>{let[o,i]=n.current??[],s=k_(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 Bc(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(ko);if(!s||s.length===0)return;let a=0;s.find(l=>{let u=r.indexOf(l,a);return o>u&&i<u+l.length?(n.selectionStart=u,n.selectionEnd=u+l.length,!0):(a=u+l.length,!1)})}var P_=S(O());function wi(e){(0,P_.useEffect)(()=>{let t=n=>{n.isWithinRoot||e(n)};return document.body.addEventListener("mouseup",t),()=>{document.body.removeEventListener("mouseup",t)}},[e])}function oo(e){e.addEventListener("mouseup",t=>{t.isWithinRoot=!0},!0)}var R_,sn=new Map,wR=["bottom","height","left","right","top","width"],bR=(e={},t={})=>wR.some(n=>e[n]!==t[n]);function I_(e){var n,r;let t=((r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)??null;return t?[t,...I_(t)]:[]}function L_(e,t){return!e||!t?null:{...e,top:e.top+t.top,left:e.left+t.left}}var Hc=!1,A_=()=>{Hc=!0;let e=[];if(sn.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),sn.delete(n);return}let r=n.getBoundingClientRect();bR(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(L_,t.rect):t.rect;t.callbacks.forEach(r=>r(n))}),sn.size===0){Hc=!1;return}R_=window.requestAnimationFrame(A_)};function Sg(e,t){let n=I_(e),r=[],o=n.map((i,s)=>Sg(i,a=>{r[s]=a;let l=sn.get(e);if(!l)return;let u=r.reduce(L_,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),sn.has(e)){let s=sn.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else sn.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Hc&&A_()},unobserve(){o.forEach(s=>s.unobserve());let i=sn.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||sn.delete(e),sn.size||(cancelAnimationFrame(R_),Hc=!1)}}}}var O_,an=new Map,N_=()=>{an.forEach((e,t)=>{if(!t.isConnected){an.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)))}),an.size!==0&&(O_=window.requestAnimationFrame(N_))};function M_(e,t){return{observe(){let n=an.size===0;an.has(e)?an.get(e).callbacks.push(t):an.set(e,{visible:void 0,callbacks:[t]}),n&&N_()},unobserve(){let n=an.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||an.delete(e),an.size||cancelAnimationFrame(O_)}}}}var xg=["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 _g(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function bi(e){return parseFloat(e)}function Uc(e){return Math.round(e*1e6)}function D_(e){return e/1e6}function wg(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=bi(e.width),i=bi(e.borderLeftWidth),s=bi(e.borderRightWidth),a=bi(e.paddingRight),l=D_(Uc(o)-Uc(i)-Uc(s)),u=D_(Uc(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function io(e,t={}){var l;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=t.position??"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",oo(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};_g(r,n,xg),wg(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=M_(e,()=>{_g(r,n,xg),wg(r,e,n),i(),setTimeout(i,0)}),a=Sg(e,u=>{if(u===null){t.onRemove&&t.onRemove(),n.remove();return}if(u.height===0&&u.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(_g(r,n,xg),wg(r,e,n),i(),n.style.top=`${u.top}px`,n.style.left=`${u.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let c=t.closestScrollElement.getBoundingClientRect(),p=window.getComputedStyle(t.closestScrollElement),d=bi(p.borderTopWidth),h=bi(p.borderBottomWidth),v=c.top+d-u.top,y=u.top+u.height+-(c.top+c.height-h);n.style.clipPath=`inset(${v}px 0px ${y}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(l=e.parentElement)==null||l.appendChild(n),a.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),a.unobserve(),s.unobserve()}]}var bg={};ke(bg,{enUS:()=>ER,nlNL:()=>CR});var ER={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"No placeholders found"}]},one:{value:[{type:0,value:"There is one placeholder in your message"}]},other:{value:[{type:0,value:"There are "},{type:7},{type:0,value:" placeholders in your message"}]}},offset:0,pluralType:"cardinal"}]},CR={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"Alle placeholders zijn uit je bericht"}]},one:{value:[{type:0,value:"Er is 1 placeholder in jouw bericht"}]},other:{value:[{type:0,value:"Er zijn "},{type:7},{type:0,value:" placeholders in jouw bericht"}]}},offset:0,pluralType:"cardinal"}]};var ga=S(w()),F_=()=>(0,ga.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,ga.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,ga.jsx)("path",{d:"M243.8 339.8C232.9 350.7 215.1 350.7 204.2 339.8L140.2 275.8C129.3 264.9 129.3 247.1 140.2 236.2C151.1 225.3 168.9 225.3 179.8 236.2L224 280.4L332.2 172.2C343.1 161.3 360.9 161.3 371.8 172.2C382.7 183.1 382.7 200.9 371.8 211.8L243.8 339.8zM512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256zM256 48C141.1 48 48 141.1 48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48z"})]});var Eg=S(w()),j_=()=>(0,Eg.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Eg.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});function TR(e){let t=e.scrollHeight>e.clientHeight,r=window.getComputedStyle(e).overflowY.indexOf("hidden")!==-1;return t&&!r}function zc(e){return e?e instanceof ShadowRoot?zc(e.host):e===e.ownerDocument.body?e.ownerDocument:TR(e)?e:zc(e.parentNode):document.body}var B_=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(B_||{}),Tn=class{constructor(t){this.element=t;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentCaret=null;currentSelection={start:0,end:0};currentHTML="";isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(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)}triggerChange(){let t=this.getText(),n=this.getHTML(),r=t!==this.currentText;this.isActive&&(t===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&r&&!this.isSubmitting&&this.emit("change",{plainText:t}),r&&(this.currentSelection=this.getSelection()),this.currentText=t,this.isSubmitting=!1,(this.currentHTML!==n||n===null&&r)&&(this.emit("updated",{plainText:t}),this.triggerCaretPosition(),this.currentHTML=n))}triggerSelection(){let t=this.getSelection();(t.start!==this.currentSelection.start||t.end!==this.currentSelection.end)&&(this.currentSelection=t,this.emit("selection",t),this.triggerCaretPosition())}triggerCaretPosition(){let t=this.getCaretPosition();yr(t,this.currentCaret)||(this.currentCaret=t,this.emit("caret",t))}handleKeyUp(t){let{key:n,shiftKey:r}=t;(n==="Enter"&&r===!0||n==="Backspace")&&this.triggerChange(),this.triggerSelection()}handleClick(){this.triggerSelection()}handleFocus(){this.isFocused||this.emit("focus"),this.triggerSelection(),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(B_).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",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",r=>this.handleKeyDown(r)),this.addEventListener("keyup",r=>this.handleKeyUp(r)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",r=>this.handlePaste(r)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},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()});let n=zc(this.element);if(n){let r=()=>{this.currentCaret!==null&&(this.currentCaret=null,this.emit("caret",null))};n.addEventListener("scroll",r),this.disposeHandlers.push(()=>{n.removeEventListener("scroll",r)})}this.currentSelection=this.getSelection()}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))}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};var kn=class extends Tn{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:t,selectionEnd:n}=this.element;return{start:t,end:n}}getSelectedText(){let t=this.getSelection();return t?this.getText().slice(t.start,t.end):""}getCaretPosition(){return null}applyChanges(t){if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),r=t(this.element);return Promise.resolve(r).then(()=>{this.currentText=this.getText(),n!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let t=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var o;return(o=t==null?void 0:t.get)==null?void 0:o.call(this.element)},set:o=>{var i;(i=t==null?void 0:t.set)==null||i.call(this.element,o),this.triggerChange()}});let n=this.element.disabled,r=new MutationObserver(()=>{this.element.disabled!==n&&(n=this.element.disabled,this.emit(n?"disabled":"enabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>r.disconnect())}};var kR=/[.*+?^${}()|[\]\\]/g,PR=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function RR(e){return e.replace(kR,"\\$&")}function IR(e,t){let n=e.split("").findIndex((r,o)=>r!==t[o]);return n>-1?n:Math.min(e.length,t.length)}function LR(e){return e.search(PR)}function H_(e,t=[]){let n=e;return t.forEach(r=>{if(!r)return;let o=new RegExp(`\\b(${RR(r)})\\b`,"gi");n=n.replace(o,"<strong>$1</strong>")}),n}function U_(e){return e.replace(ko,'<mark data-type="placeholder">$1</mark>')}function Ei(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function AR(e,t){return e.split("").map((s,a)=>({char:s,index:a})).filter(({char:s,index:a})=>/\s/.test(s)&&a<=t).map(({index:s})=>s).reverse()[0]}function Cg(e,t,n={}){if(t){let r=IR(t.toLowerCase(),e.toLowerCase()),o=Ei(e.substring(r,e.length));if(n.stripAgentPart){let l=e.substring(0,r),u=LR(l);return`<span style="opacity: 0.5">${l.substring(u+1)}</span>${o}`}let s=t.split(Ey).length>3||t.length>30?AR(t.trim(),r):0;return`${`${s>0?"\u2026":""}${Ei(e.substring(s,r))}`}<strong>${o}</strong>`}return e}function Tg(e){return/<\/?[a-z][\s\S]*>/i.test(e)}function Vc(e){if(Tg(e)){let n=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(e);return n?n[1]:""}return e}var ze=S(w()),OR=({value:e,onUse:t,...n})=>{var p;let r=B(bg),o=z(),i=Tg(e),s=k("EditSuggestionTextInput",yg),[a,l]=(0,Rt.useState)(null),u=(0,Rt.useRef)(null),c=((p=e.match(ko))==null?void 0:p.length)||0;return(0,Rt.useEffect)(()=>{let d;return u.current&&(l(u.current),d=new kn(u.current),d.on("change",({plainText:h})=>{o(tt.actions.userInput({text:h,selection:d.getSelection()}))}),d.on("keydown",h=>{o(tt.actions.registerKeyDown(lc(h))),h.code==="Enter"&&h.shiftKey&&t(d.getText())}),d.on("paste",({pastedText:h,selectionText:v})=>{o(tt.actions.registerPaste({text:h,selectionText:v}))}),d.on("cut",({selectionText:h})=>{o(tt.actions.registerCut(h))})),()=>{o(tt.actions.reset()),d.dispose(),d.deactivate()}},[u]),(0,Rt.useEffect)(()=>{e&&u.current&&(u.current.value=e)},[e,u]),(0,Rt.useEffect)(()=>{u.current&&setTimeout(()=>{if(!u.current)return;let d=u.current.value.length;u.current.setSelectionRange(d,d),u.current.focus()},0)},[u]),i?(0,ze.jsx)("div",{className:s.textInputWrapper,children:(0,ze.jsx)(En,{className:s.textInput,tagName:"div",content:e})}):(0,ze.jsxs)("div",{className:s.textInputWrapper,children:[(0,ze.jsx)("textarea",{...n,ref:u,"data-testid":"edit-suggestion-dialog-textarea",className:s.textInput,defaultValue:e,onChange:()=>{}}),a&&(0,ze.jsx)(NR,{inputElement:u.current,value:e}),(0,ze.jsxs)("div",{className:(0,kg.default)(s.alert,c===0?s.success:s.warning),children:[(0,ze.jsx)("div",{className:s.alertText,children:r("placeholders",{placeholderSize:c})}),c===0?(0,ze.jsx)(F_,{}):(0,ze.jsx)(j_,{})]})]})},NR=({inputElement:e,value:t})=>{let n=k("EditSuggestionTextInput",yg),r=(0,Rt.useRef)(null),o=jc(e);return(0,Rt.useEffect)(()=>{Bc(e,o)},[o,e]),(0,ze.jsx)(MR,{inputElement:e,children:(0,ze.jsxs)("div",{ref:r,className:(0,kg.default)(n.root,n.agentText),children:[(0,ze.jsx)(En,{tagName:"span",disableLineBreaks:!0,content:t,matchers:[new xi("placeholders")],inputElement:e,boundaryRef:r}),(0,ze.jsx)("br",{})]})})},MR=({inputElement:e,children:t})=>{let n=(0,Rt.useRef)(null);return(0,Rt.useEffect)(()=>{if(!n.current)return()=>{};let[r,o]=io(e,{overlayContainer:n.current,mirrorOverflow:!0});return r.setAttribute("translate","no"),()=>{o()}},[n.current]),(0,ze.jsx)("div",{ref:n,children:t})},z_=OR;var ki=S(O());var V_=S(O()),Kc=S($());var nt={root:"_root_pc5uy_1",list:"_list_pc5uy_2",listWrapper:"_listWrapper_pc5uy_6",listHorizontal:"_listHorizontal_pc5uy_10",page:"_page_pc5uy_19",search:"_search_pc5uy_25",pageNav:"_pageNav_pc5uy_33",pageTitle:"_pageTitle_pc5uy_41",pageBackButton:"_pageBackButton_pc5uy_48",listHeading:"_listHeading_pc5uy_62",listItem:"_listItem_pc5uy_70",listItemContent:"_listItemContent_pc5uy_79",listItemText:"_listItemText_pc5uy_97",listItemDescription:"_listItemDescription_pc5uy_105",listItemActions:"_listItemActions_pc5uy_112",truncate:"_truncate_pc5uy_123",lineClamp:"_lineClamp_pc5uy_129",listItemTitle:"_listItemTitle_pc5uy_136",listItemAction:"_listItemAction_pc5uy_112",listItemPrimaryAction:"_listItemPrimaryAction_pc5uy_157",listItemSelected:"_listItemSelected_pc5uy_162",sources:"_sources_pc5uy_166",sourcesTitle:"_sourcesTitle_pc5uy_173",source:"_source_pc5uy_166",icon:"_icon_pc5uy_188",searchIcon:"_searchIcon_pc5uy_205",searchInputWrapper:"_searchInputWrapper_pc5uy_210",searchInput:"_searchInput_pc5uy_210",select:"_select_pc5uy_231",selectType:"_selectType_pc5uy_248",selectWrapper:"_selectWrapper_pc5uy_252",image:"_image_pc5uy_282",imageSrc:"_imageSrc_pc5uy_289",imageSrcHidden:"_imageSrcHidden_pc5uy_300",imageSrcStatus:"_imageSrcStatus_pc5uy_304",imageTitle:"_imageTitle_pc5uy_314",actions:"_actions_pc5uy_319",actionsWrapper:"_actionsWrapper_pc5uy_323",actionsBar:"_actionsBar_pc5uy_329",actionButton:"_actionButton_pc5uy_338",actionShortcut:"_actionShortcut_pc5uy_356",actionShortcutFixKerning:"_actionShortcutFixKerning_pc5uy_363"};var so={};ke(so,{enUS:()=>DR,nlNL:()=>FR});var DR={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},FR={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};var _r=S(w()),jR=({src:e,title:t})=>{let n=k("CommandPalette",nt),[r,o]=(0,V_.useState)("loading"),i=B(so);return(0,_r.jsxs)("div",{className:n.image,children:[(0,_r.jsx)("img",{src:e,alt:t,onLoad:()=>o("done"),onError:()=>o("error"),className:(0,Kc.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(r)})}),r==="loading"&&(0,_r.jsx)("span",{className:(0,Kc.default)(n.imageSrc,n.imageSrcStatus),children:i("loading")}),r==="error"&&(0,_r.jsx)("span",{className:(0,Kc.default)(n.imageSrc,n.imageSrcStatus),children:(0,_r.jsx)(Za,{})}),t&&(0,_r.jsx)("span",{className:n.imageTitle,children:t})]})},K_=jR;var W_=S(O()),$_=S($());var ha=S(w());function Pg({children:e,heading:t,orientation:n}){let r=k("CommandPalette",nt);return W_.default.Children.count(e)===0?null:(0,ha.jsxs)("div",{"data-testid":"commandpalette-list",className:r.list,children:[t&&(0,ha.jsx)("h4",{className:r.listHeading,children:t}),(0,ha.jsx)("div",{className:(0,$_.default)(r.listWrapper,n==="horizontal"&&r.listHorizontal),children:e})]})}var ya=S($());var Wc=S(O()),X_=S(w()),q_=Wc.default.createContext(void 0);function wr(){let e=Wc.default.useContext(q_);if(e===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return e}var G_=({children:e,page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i})=>{let s=Wc.default.useMemo(()=>({page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i}),[n,t,o]);return(0,X_.jsx)(q_.Provider,{value:s,children:e})};var Ae=S(O()),Q_=S($());var Rg={root:"_root_1oh4w_1",trigger:"_trigger_1oh4w_5",content:"_content_1oh4w_19",contentOpen:"_contentOpen_1oh4w_33",contentTop:"_contentTop_1oh4w_37",contentBottom:"_contentBottom_1oh4w_41",item:"_item_1oh4w_45"};var ao=S(w()),BR=0,Y_=Ae.default.createContext(null),HR=()=>{let e=(0,Ae.useContext)(Y_);if(!e)throw new Error("Invalid DropdownContext");return e},Z_=({trigger:e,children:t,position:n="bottom"})=>{let r=(0,Ae.useMemo)(()=>++BR,[]),o=(0,Ae.useRef)(null),i=(0,Ae.useRef)(null),s=k("Dropdown",Rg),[a,l]=(0,Ae.useState)(!1),[u,c]=(0,Ae.useState)(n),p=h=>{h.preventDefault(),h.stopPropagation(),l(!a)},d=(0,Ae.useCallback)(([h])=>{!h.isIntersecting&&a&&c(u==="top"?"bottom":"top")},[a]);return(0,Ae.useEffect)(()=>{let h=v=>{o.current&&!o.current.contains(v.target)&&l(!1)};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}},[]),(0,Ae.useEffect)(()=>{if(!i.current&&!a)return()=>{};let h=new IntersectionObserver(d,{root:null,rootMargin:"0px",threshold:1});return i.current&&h.observe(i.current),()=>{i.current&&h.unobserve(i.current)}},[i,a]),(0,ao.jsx)(Y_.Provider,{value:{setIsOpen:l},children:(0,ao.jsxs)("div",{ref:o,className:s.root,children:[(0,ao.jsx)("button",{id:`dropdown-${r}`,"data-testid":"dropdown-trigger","aria-haspopup":"true","aria-expanded":a,"aria-label":"Dropdown trigger",type:"button",className:s.trigger,onClick:p,children:e}),(0,ao.jsx)("div",{"data-testid":"dropdown-content",ref:i,"aria-hidden":!a,"aria-labelledby":`dropdown-${r}`,className:(0,Q_.default)(s.content,{[s.contentOpen]:a,[s.contentTop]:u==="top",[s.contentBottom]:u==="bottom"}),children:t})]})})};function UR({as:e,children:t,onClick:n,...r}){let o=e||"button",i=k("Dropdown",Rg),{setIsOpen:s}=HR(),a=l=>{s(!1),n(l),l.stopPropagation()};return(0,ao.jsx)(o,{type:"button",className:i.item,onClick:a,...r,children:t})}Z_.Item=UR;var Ig=Z_;var Lg=S(w()),J_=e=>(0,Lg.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...e,children:(0,Lg.jsx)("path",{fill:"currentColor",d:"M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"})});var lo={};ke(lo,{enUS:()=>zR,nlNL:()=>VR});var zR={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],giveFeedback:[{type:0,value:"Give feedback"}],answer:[{type:0,value:"Answer"}]},VR={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],giveFeedback:[{type:0,value:"Geef feedback"}],answer:[{type:0,value:"Antwoord"}]};var $c=S(w()),KR="%0d%0a%0d%0a%0d%0a",WR=(e,t)=>{let n=[`Suggestie: ${encodeURIComponent(t)}`,"Beschrijf je feedback:"];return`mailto:${e.join(",")}?subject=Suggestie feedback&body=${n.join(KR)}`},$R=({suggestion:e,onFeedback:t})=>{let n=B(lo),r=N("suggestionFeedbackEmailAddresses");return!r||r.length===0?null:(0,$c.jsx)(Ig,{trigger:(0,$c.jsx)(J_,{"data-testid":"feedback-dropdown-trigger"}),children:(0,$c.jsx)(Ig.Item,{as:"a",href:WR(r,e),onClick:t,children:n("giveFeedback")})})},qc=$R;var dt=S(w());function Ag({closeOnSelect:e=!0,lineClamp:t,children:n,onClick:r,onFeedback:o,onSourceClick:i,index:s,description:a,sources:l,styles:u,...c}){let{selected:p,setSelected:d,onChangeOpen:h}=wr(),v=k("CommandPalette",nt);function y(m){r(m),e&&h(!1)}return(0,dt.jsxs)("div",{className:(0,ya.default)(v.listItem,p===s&&v.listItemSelected),children:[(0,dt.jsx)("button",{onMouseEnter:()=>d(s),type:"button",className:(0,ya.default)("command-palette-list-item",v.listItemAction,v.listItemPrimaryAction),"aria-disabled":c.disabled??!1,onClick:y,...c,children:(0,dt.jsxs)("div",{className:v.listItemContent,children:[typeof n=="string"?(0,dt.jsx)("p",{className:(0,ya.default)(v.listItemText,v.truncate,u==null?void 0:u.title),children:n}):n,a&&(0,dt.jsx)(En,{tagName:"p",allowList:[],content:Vc(a),className:(0,ya.default)(v.listItemDescription,u==null?void 0:u.description,t?v.lineClamp:v.truncate)})]})}),o&&p===s&&(0,dt.jsx)("div",{className:v.listItemActions,children:(0,dt.jsx)(qc,{suggestion:String(n),onFeedback:o})}),l&&(0,dt.jsxs)("div",{className:v.sources,children:[(0,dt.jsx)("span",{className:v.sourcesTitle,children:"Sources"}),l.map(m=>m.url?(0,dt.jsx)("a",{className:v.source,href:m.url,target:"_blank",title:m.url,rel:"noopener noreferrer",onClick:()=>i&&i(m),children:m.name},m.url):(0,dt.jsx)("span",{className:v.source,children:m.name},m.name))]})]})}var uo=S(w());function Og({children:e,title:t,id:n,onDismiss:r}){let o=B(so),i=k("CommandPalette",nt),{page:s}=wr();return s!==n?null:(0,uo.jsxs)("div",{className:i.page,id:`page_${n}`,tabIndex:-1,children:[r&&(0,uo.jsxs)("div",{className:i.pageNav,children:[(0,uo.jsxs)("button",{className:i.pageBackButton,type:"button",onClick:r,children:[(0,uo.jsx)(Pc,{}),o("back")]}),t&&(0,uo.jsx)("h3",{className:i.pageTitle,children:t})]}),e]})}var br=S(O());var Gc=()=>/Mac/i.test(navigator.platform);var qR={info(...e){console.info("[Deepdesk]",...e)},warn(...e){console.warn("[Deepdesk]",...e)},error(...e){console.error("[Deepdesk]",...e)}},H=qR;function GR(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function te(e){return Array.isArray(e)?e.map(te):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>({...t,[GR(n)]:te(e[n])}),{}):e}function Ng(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Ce(e){return Array.isArray(e)?e.map(Ce):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>({...t,[Ng(n)]:Ce(e[n])}),{}):e}var XR={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Sa=e=>{var t,n,r;return{timezone:((t=e.info.visitorInfo)==null?void 0:t.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((n=e.info.agentInfo)==null?void 0:n.agentNickname)||"",visitorName:((r=e.info.visitorInfo)==null?void 0:r.visitorName)||""}},va=M("info/setAgentInfo",async(e,t)=>{let{deepdeskAPI:n}=t.extra;if(!e.agentId&&!e.agentNickname)throw new Error("At least provide agentId or agentNickname");let r=await n.client.get("/apis/admin/session/me/",{version:null}),o={};return r.external_id||(o.external_id=e.agentId),r.nickname||(o.nickname=e.agentNickname),!o.external_id&&!o.nickname?te(r):(await n.client.patch("/apis/admin/session/me/",o,{version:null}),te(r))}),Mg=M("info/setAgentSettings",async(e,t)=>{let{deepdeskAPI:n}=t.extra,r=await n.client.get("/apis/admin/session/me/",{version:null}),o={...typeof r.ui_config=="object"?r.ui_config:{},...e};return await n.client.patch("/apis/admin/session/me/",{ui_config:o}),o}),Dg=M("info/getAgentSettings",async(e,t)=>{let{deepdeskAPI:n}=t.extra;return(await n.client.get("/apis/admin/session/me/",{version:null})).ui_config}),ew=e=>e.info.agentInfo,tw=U({name:"info",initialState:XR,reducers:{setVisitorInfo(e,t){e.visitorInfo={...e.visitorInfo,...t.payload}}},extraReducers:e=>{e.addCase(va.pending,(t,n)=>{t.fetchState="loading",t.agentInfo={...t.agentInfo,...n.meta.arg}}).addCase(va.rejected,t=>{t.fetchState="error"}).addCase(va.fulfilled,(t,n)=>{t.fetchState="done",t.agentInfo={...t.agentInfo,...n.meta.arg,agentId:n.payload.externalId||n.meta.arg.agentId||"",agentNickname:n.payload.nickname||n.meta.arg.agentNickname||""}}).addCase(Mg.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(Dg.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(J,t=>{t.visitorInfo=void 0})}}),{setVisitorInfo:nw}=tw.actions,rw=tw.reducer;var Xc={list:[],fetchState:"idle",isOpen:!1,page:"search"},ow=e=>e.search.isOpen,iw=e=>e.search.page,sw=e=>e.search.list;function aw(e,t=n=>n){return n=>n.search.list.filter(r=>r.type===e).map(t)}var co=M("search/getAll",async(e,t)=>{var s;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(s=r.conversation.current)==null?void 0:s.profileCode;if(!o)throw new Error("Profile should be provided in order to be able to search");let{results:i}=await n.search({profile:o,query:e.query,filters:{type:e.type},params:Sa(r),tags:e.tags});return i.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:e.query}))}),lw=U({name:"search",initialState:Xc,reducers:{setIsOpen(e,t){e.isOpen=t.payload},setPage(e,t){e.page=t.payload},resetSearch(e){e.fetchState=Xc.fetchState,e.list=Xc.list}},extraReducers:e=>{e.addCase(co.pending,t=>{t.fetchState="loading"}).addCase(co.rejected,(t,n)=>{t.fetchState="error",H.error(n.error)}).addCase(co.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload}).addCase(J,()=>Xc)}}),{resetSearch:Qc,setIsOpen:$e,setPage:qe}=lw.actions,uw=lw.reducer;var QR=/(https?:\/\/[^\s]+)/,Yc=e=>e.split(" ").find(t=>QR.test(t));var Fg=S($());var Zc=S(w()),YR=({onClick:e,shortKeys:t,children:n,...r})=>{let o=k("CommandPalette",nt);return(0,Zc.jsxs)("button",{type:"button",...r,onClick:e,className:(0,Fg.default)(o.actionButton,r.className),children:[n,t&&t.map(i=>(0,Zc.jsx)("span",{className:(0,Fg.default)(o.actionShortcut,i===8629&&o.actionShortcutFixKerning),children:typeof i=="number"?String.fromCharCode(i):i},i))]})},Ci=YR;var Pn=S(w()),ZR=({children:e,primaryLabel:t,secondaryLabel:n,onPrimary:r,onSecondary:o,list:i})=>{let s=k("CommandPalette",nt),a=B(so),{selected:l,setSelected:u}=wr(),c=i[l],p=c&&typeof c.text=="string"&&Yc(c.text),d=(0,br.useRef)(null);function h(x){if(!d.current)return;let _=d.current.querySelectorAll(".command-palette-list-item"),b=0,E=0;x==="down"?(_.forEach((R,P)=>{P===l&&(b=P)}),E=b===_.length-1?0:b+1):x==="up"?(_.forEach((R,P)=>{P===l&&(b=P)}),E=b?b-1:_.length-1):u(0);let C=_[E];C&&typeof E=="number"&&(u(E),C.scrollIntoView&&C.scrollIntoView({behavior:"smooth",block:E?"center":"end"}))}function v(){if(!d.current)return;let x=d.current.querySelectorAll(".command-palette-list-item"),_=0;x.forEach((E,C)=>{C===l&&(_=C)});let b=x[_];b&&b.click()}let y=()=>{p&&window.open(p,"_blank")},m=()=>{c&&r(c,l)},g=()=>{!c.type||["IMAGE","command"].includes(c.type)||o&&o(c,l)},f=(0,br.useCallback)(x=>{if(x.key==="Enter"&&x.altKey&&p){y();return}if(x.key==="Enter"&&x.shiftKey){g();return}if(x.key==="ArrowDown"){x.preventDefault(),x.stopPropagation(),h("down");return}if(x.key==="ArrowUp"){x.preventDefault(),x.stopPropagation(),h("up");return}x.key==="Enter"&&l!==-1&&(x.preventDefault(),x.stopPropagation(),v())},[l]);return(0,br.useEffect)(()=>(window.addEventListener("keyup",f),()=>{window.removeEventListener("keyup",f)}),[f]),(0,Pn.jsxs)("div",{className:s.actions,children:[(0,Pn.jsx)("div",{className:s.actionsWrapper,ref:d,children:e}),(0,Pn.jsxs)("div",{className:s.actionsBar,children:[p&&(0,Pn.jsx)(Ci,{onClick:y,shortKeys:[Gc()?8997:"ALT",8629],children:a("visitUrl")}),c&&(0,Pn.jsxs)(br.Fragment,{children:[o&&c.type&&!["command","image"].includes(c.type.toLowerCase())&&(0,Pn.jsx)(Ci,{onClick:g,shortKeys:[8679,8629],children:n}),(0,Pn.jsx)(Ci,{onClick:m,shortKeys:[8629],children:t})]})]})]})},dw=ZR;var pw=S(O());var xa=S(w()),Ti=()=>(0,xa.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,xa.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,xa.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});var Vt=S(w());function JR({onChange:e,onChangeType:t,placeholder:n,typePlaceholder:r,types:o,value:i,selectedType:s},a){let l=k("CommandPalette",nt);return(0,Vt.jsxs)("div",{className:l.search,children:[(0,Vt.jsx)("div",{className:l.searchIcon,children:(0,Vt.jsx)(Ti,{})}),(0,Vt.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Vt.jsx)("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:u=>{e(u.currentTarget.value)},onFocus:u=>{u.currentTarget.select()},className:l.searchInput,placeholder:n,value:i,type:"text",id:"command-palette-search-input",autoFocus:!0}),o&&o.length>0&&(0,Vt.jsx)("div",{className:l.selectWrapper,children:(0,Vt.jsxs)("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:u=>t(u.target.value===r?void 0:u.target.value),value:s||r,children:[r&&(0,Vt.jsx)("option",{children:r}),o.map(u=>(0,Vt.jsx)("option",{value:u.value,children:u.label},u.value))]})})]})]})}var fw=(0,pw.forwardRef)(JR);var _a=S(w());function po({placeholder:e="Start typing to search...",typePlaceholder:t="All types",defaultPage:n="search",page:r,onChangePage:o,onChangeSearch:i,onChangeType:s,onChangeOpen:a,selectedType:l,types:u,children:c,isOpen:p,search:d}){let[h,v]=(0,ki.useState)(0),y=(0,ki.useRef)(null),m=()=>{o&&o(n),s(void 0),i(""),a(!1)},g=()=>{var f;if(r!==n&&o){o(n);return}if(l&&s){s(void 0),(f=y.current)==null||f.focus();return}if(d.length>0){i("");return}a(!1)};return(0,ki.useEffect)(()=>{v(0)},[d,r]),(0,_a.jsx)(vi,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:p,onBack:g,onClose:m,children:(0,_a.jsxs)(G_,{selected:h,setSelected:v,isOpen:p,onChangeOpen:a,page:r,children:[r===n&&(0,_a.jsx)(fw,{ref:y,onChange:i,onChangeType:s,placeholder:e,value:d,selectedType:l,types:u,typePlaceholder:t}),c]})})}po.Page=Og;po.List=Pg;po.Image=K_;po.ListItem=Ag;po.ActionsBar=dw;po.Button=Ci;var ne=po;var Ve=S(w()),eI=({suggestion:e,onUse:t,onDismiss:n,onTouched:r,onNext:o,onPrevious:i})=>{let s=e.text||e.url||e.message,a=k("EditSuggestionForm",u_),l=z(),u=B(eg),c=I(v=>v.overlayInput.text);(0,jg.useEffect)(()=>{e&&(l(tt.actions.reset()),l(tt.actions.stageSuggestion({text:s,suggestion:e,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(tt.actions.commitSuggestion()))},[e]);let p=v=>{v.preventDefault(),d(c)},d=v=>{l(dc(v)),t(v)},h=v=>y=>{c!==s?window.confirm(u("warning"))&&v(y):v(y)};return(0,jg.useEffect)(()=>{r&&r(c!==s)},[r,e,c]),(0,Ve.jsxs)("div",{className:a.root,children:[(0,Ve.jsxs)("div",{className:a.content,children:[e.title&&(0,Ve.jsx)("h3",{className:a.title,children:e.title}),e.searchKeywords&&e.searchKeywords.length>0&&(0,Ve.jsx)($d,{labels:e.searchKeywords}),(0,Ve.jsx)(z_,{onUse:d,value:Vc(c)})]}),(0,Ve.jsxs)("form",{className:a.actions,onSubmit:p,children:[(0,Ve.jsxs)("div",{children:[(0,Ve.jsx)("button",{disabled:!i,className:a.pagination,type:"button",onClick:i&&h(i),children:(0,Ve.jsx)(Pc,{})}),(0,Ve.jsx)("button",{disabled:!o,className:a.pagination,type:"button",onClick:o&&h(o),children:(0,Ve.jsx)(S_,{})})]}),(0,Ve.jsxs)("div",{className:a.primaryButtons,children:[(0,Ve.jsx)(ne.Button,{onClick:h(n),shortKeys:["esc"],children:u("dismiss")}),(0,Ve.jsx)(ne.Button,{shortKeys:[8679,8629],type:"submit",children:u("add")})]})]})]})},Jc=eI;var tI=["{amount}"," {amount}","{date}","{email}","{iban}","{name}","{postal_code}","{street}","{tarif}","{usage}","{3_digits}","{4_digits}","{5_digits}","{6_digits}","{7_digits}","{8_digits}","{9_digits}","{10_digits}"],nI=new RegExp(tI.map(e=>`(?:${e.replace("{","\\{").replace("}","\\}")})`).join("|"));function mw(e,t){let n=e.split(nI),r=0,o=[];for(let i=0;i<n.length;i++){let s=n[i];if(o.push(s),i===n.length-1)break;if(t.indexOf(s)===-1)return e;let a=n[i+1],l=i===n.length-2;r+=s.length;let u=r;if(l){let p=a.charAt(0),d=0;do u=p?t.indexOf(p,u+1):-1,d+=1;while(u!==-1&&a.indexOf(t.slice(u))!==0);if(u===-1&&d>2)return e}else u=a&&a!==""?t.indexOf(a,r):-1;let c=u===-1?t.slice(r):t.slice(r,u);o.push(c),r=u}return o.join("")}function gw(e,t){return typeof t=="boolean"?e:e.slice(0,t)}var yw={suggestions:[],fetchState:"idle",isInitialRequest:null},hw={default:yw},vw=e=>t=>{var n;return((n=t.textSuggestions[e])==null?void 0:n.suggestions)||[]},Sw=e=>t=>{var n;return((n=t.textSuggestions[e])==null?void 0:n.suggestions)??[]},xw=e=>{let t=Object.keys(e.textSuggestions).map(n=>{var r;return(r=e.textSuggestions[n])==null?void 0:r.fetchState});return t.length===0?!0:t.every(n=>n!=="done")},Pi=e=>e.textSuggestions,_w=e=>{let t=e.toLowerCase();return n=>{let r=n.text.toLowerCase();return r.startsWith(t)&&r.length>t.length}},ed=fe("textSuggestions/refresh"),Rn=M("textSuggestions/recommendations",async(e,t)=>{var u;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(u=r.conversation.current)==null?void 0:u.id,{textSuggestionsCount:i,inlineSuggestions:s}=r.settings,a=hi(r);if(!o)throw new Error("No current conversation to fetch text suggestions");let l=await n.getTextSuggestions(o,Sa(r),e);if(e==="default"){let c=s?l.filter(_w(a)):l;t.dispatch(on(c.slice(0,i)))}return l}),wa=M("textSuggestions/autocompletions",async(e,t)=>{var u;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(u=r.conversation.current)==null?void 0:u.id,{textSuggestionsCount:i,deanonymize:s,inlineSuggestions:a}=r.settings;if(!o)throw new Error("No current conversation to fetch text suggestions");let l=await n.getAutocompleteSuggestions(o,{...Sa(r),input:e});if(!t.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(_w(e))),s&&(l=l.map(c=>({...c,text:c.source!=="trie-with-typos"?mw(c.text,e):c.text}))),l=gw(l,i),t.dispatch(on(l)),l}),ww=U({name:"textSuggestions",initialState:hw,reducers:{setTextSuggestions:{reducer(e,t){let{contentType:n}=t.payload;e[n].fetchState="done",e[n].suggestions=t.payload.suggestions},prepare(e,t){return{payload:{contentType:e,suggestions:t}}}},setSuggestionState(e,t){return t.payload}},extraReducers:e=>{e.addCase(Rn.pending,(t,n)=>{let r=n.meta.arg,o=t[r]||yw;return{...t,[r]:{...o,fetchState:"loading",isInitialRequest:o.isInitialRequest===null}}}).addCase(Rn.rejected,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="error")}).addCase(Rn.fulfilled,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="done",t[r].suggestions=n.payload)}).addCase(wa.pending,t=>{t.default.fetchState="loading"}).addCase(wa.rejected,t=>{t.default.fetchState="error"}).addCase(wa.fulfilled,(t,n)=>{t.default.fetchState="done",t.default.suggestions=n.payload}).addCase(J,()=>hw)}}),{setTextSuggestions:bw,setSuggestionState:Ew}=ww.actions,Cw=ww.reducer;var Tw={contentType:null,suggestion:null},kw=e=>e.activeSuggestion.suggestion,Pw=e=>e.activeSuggestion.contentType,Rw=U({name:"activeSuggestion",initialState:Tw,reducers:{setActiveSuggestion(e,t){let{contentType:n,suggestion:r}=t.payload;e.contentType=n,e.suggestion=r},resetActiveSuggestion(e){e.contentType=null,e.suggestion=null}},extraReducers:e=>{e.addCase(J,()=>Tw)}}),{setActiveSuggestion:In,resetActiveSuggestion:Bg}=Rw.actions,Iw=Rw.reducer;var Hg={};ke(Hg,{enUS:()=>rI,nlNL:()=>oI});var rI={warning:[{type:0,value:"Are you sure you want to discard the message?"}],editContentLabel:[{type:0,value:"Edit and view suggestion"}],overlayLabel:[{type:0,value:"Close dialog"}]},oI={warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}],editContentLabel:[{type:0,value:"Bewerk en bekijk suggestie"}],overlayLabel:[{type:0,value:"Sluit"}]};var iI={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var td=({ui:e})=>e.overlayCollapsed;var Lw=U({name:"ui",initialState:iI,reducers:{setShowTabHint(e,t){e.showTabHint=t.payload},setInputHasFocus(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:ba,setInputHasFocus:Ri,setOverlayCollapsed:Er,setOpenOverlayWhenTyping:Aw,setOverlayCollapsedUserOverwrite:Ow}=Lw.actions,Nw=Lw.reducer;var Ea=S(O()),Dw=S(w()),Mw=Ea.default.createContext(null),fo=({broadcastEvents:e,children:t})=>{let n=Ea.default.useMemo(()=>e,[]);return(0,Dw.jsx)(Mw.Provider,{value:n,children:t})},It=()=>{let e=(0,Ea.useContext)(Mw);if(!e)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return e};var sI={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},pt=e=>e.auth.isLoggedIn,Fw=e=>e.auth.loginFetchState,jw=e=>e.auth.verifyFetchState,Bw=e=>e.auth.showLoginOverlay,Ln=M("auth/validate",async(e,t)=>t.extra.deepdeskAPI.isLoggedIn()),Hw=M("auth/requestLogin",async({email:e},t)=>{let{deepdeskAPI:n}=t.extra;return n.requestLoginByEmail(e)}),Ca=M("auth/verifyLoginToken",async({token:e},t)=>{let{deepdeskAPI:n}=t.extra;return n.verifyLoginToken(e)}),Uw=U({name:"auth",initialState:sI,reducers:{setIsLoggedIn(e,t){e.isLoggedIn=t.payload},setShowLoginOverlay(e,t){e.showLoginOverlay=t.payload}},extraReducers:e=>{e.addCase(Ln.pending,t=>{t.loginFetchState="loading"}),e.addCase(Ln.fulfilled,(t,{payload:n})=>{t.isLoggedIn=n,t.loginFetchState="done"}),e.addCase(Ln.rejected,t=>{t.loginFetchState="error",t.isLoggedIn=!1}),e.addCase(Ca.pending,t=>{t.verifyFetchState="loading"}),e.addCase(Ca.rejected,t=>{t.verifyFetchState="error"}),e.addCase(Ca.fulfilled,(t,n)=>{n.payload.isLoggedIn?t.verifyFetchState="done":t.verifyFetchState="error"})}}),{setIsLoggedIn:Ii,setShowLoginOverlay:zw}=Uw.actions,Vw=Uw.reducer;var Ug="SetActiveSuggestion",Li="ShowLoginOverlay",Ta="UserLoggedIn",aI="UserLoggedOut",An="ApplySuggestion",zg="ApplyImageSuggestion",lI="ShowCommandPalette",uI=e=>({[Ug]:t=>{e.dispatch(Ew(t.state)),e.dispatch(In({contentType:t.contentType,suggestion:t.suggestion}))},[lI]:t=>{e.dispatch($e(t.isOpen)),t.page&&e.dispatch(qe(t.page))},[Li]:t=>{e.dispatch(zw(t))},[Ta]:()=>{e.dispatch(Ln())},[aI]:()=>{e.dispatch(Ln())},[zg]:t=>{e.dispatch(fc({suggestion:t.suggestion}))},[An]:t=>{e.dispatch(Ht({...t,eventMetrics:{inputType:"mouse"},replace:"selection"})),e.dispatch(_n())}}),Kw=uI;var Vg=S(w()),cI=()=>{var v;let[e,t]=(0,Ww.useState)(!1),n=I(kw),r=I(Pw),o=I(Pi),i=z(),s=It(),a=B(Hg),l=()=>{n!==null&&e?window.confirm(a("warning"))&&u():u()},u=()=>{i(Bg()),i(Ri(!0)),i(tt.actions.reset())},c=(y,m)=>{i(Bg()),i(Ri(!0)),s.send(An,{text:y,suggestion:{...m,source:`${m.source||"text_recommendation"}-preview`}})};if(n===null||r===null)return null;let p=(v=o[r])==null?void 0:v.suggestions.indexOf(n),d=p===0||p===null?void 0:()=>i(In({contentType:r,suggestion:o[r].suggestions[p-1]})),h=p===o[r].suggestions.length-1||p===null?void 0:()=>i(In({contentType:r,suggestion:o[r].suggestions[p+1]}));return(0,Vg.jsx)(vi,{autoFocus:!0,isOpen:p!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,Vg.jsx)(Jc,{onTouched:t,onDismiss:u,onUse:y=>c(y,n),suggestion:n,onNext:h,onPrevious:d})})},$w=cI;var nd=S($()),Kt=S(O());var Gw=S($());var qw={root:"_root_1ukx5_1"};var Xw=S(w()),dI=({className:e,value:t,...n})=>{let r=k("TextInput",qw);return(0,Xw.jsx)("input",{className:(0,Gw.default)(e,r.root),type:"text",value:t,...n})},ka=dI;var Kg={};ke(Kg,{enUS:()=>pI,nlNL:()=>fI});var pI={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"}]},fI={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 Qw={root:"_root_1edpl_1",anchorButton:"_anchorButton_1edpl_5",errorMessage:"_errorMessage_1edpl_19",title:"_title_1edpl_25",subtitle:"_subtitle_1edpl_31",text:"_text_1edpl_38",input:"_input_1edpl_43",actions:"_actions_1edpl_48",button:"_button_1edpl_55",primaryButton:"_primaryButton_1edpl_70"};var ye=S(w());var mI=e=>{try{let t=new URL(e);return new URLSearchParams(t.search).get("token")||void 0}catch{return e}},gI=({agentEmail:e,isOpen:t,origin:n="",onSuccess:r,onDismiss:o})=>{let i=B(Kg),s=k("LoginTokenDialog",Qw),a=I(jw),l=z(),u=N("productName"),[c,p]=(0,Kt.useState)(e||""),[d,h]=(0,Kt.useState)(0),[v,y]=(0,Kt.useState)(""),m=(0,Kt.useCallback)(async _=>{_.preventDefault(),l(Hw({email:c})),h(1)},[n,c]),g=()=>{y(""),h(0)},f=(0,Kt.useCallback)(async _=>{_.preventDefault();let b=mI(_.target.elements.token.value);if(!b){y(i("verifyCodeError",{login:x}));return}l(Ca({token:b}))},[n]),x=(0,Kt.useMemo)(()=>_=>(0,ye.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:s.anchorButton,onClick:g,children:_},"back-button"),[]);return(0,Kt.useEffect)(()=>{a==="error"&&y(i("verifyCodeError",{login:x})),a==="done"&&r()},[a]),(0,ye.jsx)(vi,{autoFocus:!0,isOpen:t,contentAriaLabel:i("promptTitle",{productName:u}),overlayAriaLabel:i("promptTitle",{productName:u}),onClose:o,onBack:o,children:(0,ye.jsxs)("div",{className:s.root,children:[(0,ye.jsx)("h1",{className:s.title,children:i("promptTitle",{productName:u})}),d===0&&(0,ye.jsxs)("form",{onSubmit:m,children:[(0,ye.jsx)("h2",{className:s.subtitle,children:i("requestCodeTitle")}),(0,ye.jsx)("p",{className:s.text,children:i("requestCodeBody",{productName:u})}),(0,ye.jsx)(ka,{className:s.input,name:"email",placeholder:i("requestCodeInputPlaceholder"),value:c,onChange:_=>p(_.target.value)}),(0,ye.jsx)("div",{className:s.actions,children:(0,ye.jsx)("button",{type:"submit",className:(0,nd.default)(s.button,s.primaryButton),children:i("requestCodeSubmitLabel")})})]}),d===1&&(0,ye.jsxs)("form",{onSubmit:f,children:[(0,ye.jsx)("h2",{className:s.subtitle,children:i("verifyCodeTitle")}),(0,ye.jsx)("p",{className:s.text,children:i("verifyCodeBody")}),(0,ye.jsx)(ka,{className:s.input,name:"token",placeholder:i("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),v&&(0,ye.jsx)("div",{className:s.errorMessage,children:v}),(0,ye.jsxs)("div",{className:s.actions,children:[(0,ye.jsx)("button",{type:"button",className:(0,nd.default)(s.button),onClick:g,children:i("back")}),(0,ye.jsx)("button",{type:"submit",className:(0,nd.default)(s.button,s.primaryButton),disabled:["loading","done"].includes(a),children:i("verifyCodeSubmitLabel")})]})]})]})})},Yw=gI;var Jw=S(w()),hI=()=>{let e=I(Bw),t=I(ew),n=N("adminUrl"),r=It(),o=()=>r.send(Li,!1),i=()=>{r.send(Li,!1),r.send(Ta)};return(0,Jw.jsx)(Yw,{isOpen:e,agentEmail:t==null?void 0:t.agentEmail,origin:n,onDismiss:o,onSuccess:i})},Zw=hI;var C1=S(qg()),Ge=S(O());var NI={data:null,fetchState:"idle"},r1=e=>e.contentTypes.data,Pa=M("contentTypes/getContentTypes",async(e,t)=>t.extra.deepdeskAPI.getContentTypes()),MI=U({name:"contentTypes",initialState:NI,reducers:{},extraReducers:e=>{e.addCase(Pa.pending,t=>{t.fetchState="loading"}).addCase(Pa.rejected,t=>{t.fetchState="error"}).addCase(Pa.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),o1=MI.reducer;function Ra(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 i1=S(O());function s1(e,t){(0,i1.useEffect)(()=>{let n=r=>{var o;((o=navigator==null?void 0:navigator.platform)!=null&&o.toLowerCase().includes("mac")?r.metaKey:r.ctrlKey)&&r.key===e&&(r.preventDefault(),r.stopPropagation(),t())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}var Ia=S(O());var a1={data:null,fetchState:"idle"},rd=e=>{var i;let t=[],{visitorName:n}=e.info.visitorInfo??{},{agentName:r,agentNickname:o}=e.info.agentInfo??{};return r&&r!==n&&t.push(r),o&&o!==n&&t.push(o),((i=e.entities.data)==null?void 0:i.filter(s=>!t.includes(s.text)))??null},Wt=M("entities/getEntities",async(e,t)=>{let{deepdeskAPI:n,dynamicThunkObject:r}=t.extra;if(!r.conversationQuery)return Promise.resolve([]);let o=r.conversationQuery,i=await o();return i.length===0?Promise.resolve([]):n.getEntities(i)}),DI=e=>e.filter((t,n)=>n===e.findIndex(r=>r.text===t.text)),FI=U({name:"entities",initialState:a1,reducers:{},extraReducers:e=>{e.addCase(Wt.pending,t=>{t.fetchState="loading"}).addCase(Wt.rejected,t=>{t.fetchState="error"}).addCase(Wt.fulfilled,(t,n)=>{t.fetchState="done",t.data=DI(t.data?[...t.data,...n.payload]:n.payload)}).addCase(J,()=>a1)}}),l1=FI.reducer;var Gg={};ke(Gg,{enUS:()=>jI,nlNL:()=>BI});var jI={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},BI={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var u1={root:"_root_17kae_1",empty:"_empty_17kae_5"};var mo=S(w()),HI=({onCopy:e,onUse:t})=>{let n=(0,Ia.useRef)(null),r=k("EntitiesList",u1),o=B(Gg),i=I(rd),s=z();return(0,Ia.useEffect)(()=>{s(Wt())},[]),(0,Ia.useEffect)(()=>{n.current&&n.current.focus()},[n]),(0,mo.jsxs)("div",{className:r.root,ref:n,tabIndex:-1,children:[i&&i.length>0&&(0,mo.jsx)(ne.ActionsBar,{primaryLabel:o("copy"),secondaryLabel:o("use"),onPrimary:(a,l)=>e(i[l]),onSecondary:(a,l)=>t(i[l]),list:i.map(a=>({text:a.text,type:a.label,primaryAction:"copy",secondaryAction:"use"})),children:(0,mo.jsx)(ne.List,{children:i.map((a,l)=>(0,mo.jsx)(ne.ListItem,{index:l,closeOnSelect:!0,onClick:()=>e(a),children:a.text},a.text))},"entities")}),i&&i.length===0&&(0,mo.jsx)("p",{className:r.empty,children:o("noResults")})]})},c1=HI;var $t=S(O());var d1={data:null,fetchState:"idle"},p1=e=>e.summary.data,f1=e=>e.summary.fetchState==="error",On=M("summary/getSummary",async(e,t)=>{let n=t.getState().profile.data;if(!n)throw new Error("Profile is not defined");let{deepdeskAPI:r,dynamicThunkObject:o}=t.extra;if(!o.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let i=o.conversationQuery,s=await i();if(s.length===0)return Promise.reject(new Error("No messages are included"));let a=await r.getSummary(s,{promptInstruction:n.summarizerPromptInstruction,model:n.summarizerModel});return a?{summary:a}:Promise.reject(new Error("Summary is not provided"))}),UI=U({name:"summary",initialState:d1,reducers:{},extraReducers:e=>{e.addCase(On.pending,t=>{t.data=null,t.fetchState="loading"}).addCase(On.rejected,t=>{t.data=null,t.fetchState="error"}).addCase(On.fulfilled,(t,n)=>{t.fetchState="done",n.payload&&(t.data=n.payload.summary)}).addCase(J,()=>d1)}}),m1=UI.reducer;var Xg={};ke(Xg,{enUS:()=>zI,nlNL:()=>VI});var zI={copy:[{type:0,value:"Copy"}],error:[{type:0,value:"Could not generate a summary"}],loading:[{type:0,value:"Generating summary, this may take a few moments."}]},VI={copy:[{type:0,value:"Kopieer"}],error:[{type:0,value:"Kon helaas geen samenvatting genereren."}],loading:[{type:0,value:"Samenvatting wordt gemaakt, dit kan even duren."}]};var g1={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};var Nn=S(w()),KI=({onCopy:e})=>{let t=(0,$t.useRef)(null),n=k("SummaryForm",g1),[r,o]=(0,$t.useState)(""),i=B(Xg),s=I(p1),a=I(f1),l=z(),u=()=>{l(He({name:"summary copied to clipboard",data:{originalText:s,finalText:r},options:{includeConversationData:!0}})),e(r)},c=()=>{let p=document.getSelection();p&&l(He({name:"summary copied to clipboard",data:{originalText:s,finalText:p==null?void 0:p.toString()},options:{includeConversationData:!0}}))};return(0,$t.useEffect)(()=>{l(On())},[]),(0,$t.useEffect)(()=>{o(s||"")},[s]),(0,$t.useEffect)(()=>{t.current&&s&&t.current.focus()},[t,s]),(0,$t.useEffect)(()=>{let p=d=>{d.key==="Enter"&&d.shiftKey&&u()};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p)}},[r]),(0,Nn.jsx)("div",{className:n.root,tabIndex:-1,children:a?(0,Nn.jsx)("p",{className:n.error,children:i("error")}):(0,Nn.jsxs)($t.Fragment,{children:[(0,Nn.jsx)("div",{className:n.main,children:(0,Nn.jsx)("textarea",{placeholder:s?void 0:i("loading"),disabled:!s,className:n.textInput,ref:t,value:r,onCopy:c,onChange:p=>o(p.target.value)})}),(0,Nn.jsx)("div",{className:n.actions,children:(0,Nn.jsx)(ne.Button,{shortKeys:[8679,8629],onClick:u,children:i("copy")})})]})})},h1=KI;var Qg={};ke(Qg,{enUS:()=>WI,nlNL:()=>$I});var WI={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},$I={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],summaryClipboard:[{type:0,value:"Gesprek samenvatten"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var Cr=S(O());var Yg={};ke(Yg,{enUS:()=>qI,nlNL:()=>GI});var qI={use:[{type:0,value:"Use"}],loading:[{type:0,value:"Loading..."}],error:[{type:0,value:"Something went wrong, please try again later."}],anotherQuestion:[{type:0,value:"Send a message..."}],reset:[{type:0,value:"Reset conversation"}]},GI={use:[{type:0,value:"Gebruik"}],loading:[{type:0,value:"Laden..."}],error:[{type:0,value:"Er ging iets mis, probeer het later opnieuw."}],anotherQuestion:[{type:0,value:"Stuur een bericht..."}],reset:[{type:0,value:"Reset gesprek"}]};var y1={root:"_root_1g4pq_1",title:"_title_1g4pq_9",empty:"_empty_1g4pq_20",status:"_status_1g4pq_24",form:"_form_1g4pq_30",input:"_input_1g4pq_43",submit:"_submit_1g4pq_55",question:"_question_1g4pq_63",answer:"_answer_1g4pq_67",alignRight:"_alignRight_1g4pq_73"};var Zg={data:[],fetchState:"idle"},v1=e=>{var t;return(t=e.answer)==null?void 0:t.data},S1=e=>e.answer.fetchState,Oi=fe("answer/resetKnowledgeSearch"),Ai=M("answer/getAnswer",async(e,t)=>{var s,a;let{deepdeskAPI:n}=t.extra,r=t.getState().answer.data,o=(a=(s=t.getState().profile)==null?void 0:s.data)==null?void 0:a.knowledgeAssistant;if(!o)throw new Error("KnowledgeAssistant is not defined");let i=await n.knowledgeAssist({promptInstruction:e.promptInstruction,question:e.question},r,o);return{question:e.question,answer:i}}),XI=U({name:"answer",initialState:Zg,reducers:{},extraReducers:e=>{e.addCase(Ai.pending,t=>{t.fetchState="loading"}).addCase(Ai.rejected,t=>{t.fetchState="error"}).addCase(Ai.fulfilled,(t,n)=>{t.fetchState="done",t.data=[...t.data,n.payload]}).addCase(J,()=>Zg).addCase(Oi,()=>Zg)}}),x1=XI.reducer;var La=S(w()),_1=()=>(0,La.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,La.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,La.jsx)("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});var rt=S(w()),QI=({onUse:e,onResetQuestion:t,question:n,promptInstruction:r})=>{let[o,i]=Cr.default.useState(""),{setSelected:s}=wr(),a=(0,Cr.useRef)(null),l=k("EntitiesList",y1),u=B(Yg),c=z(),p=I(v1),d=I(S1),h=async y=>{y.preventDefault(),y.stopPropagation(),o!==""&&c(Ai({question:o,promptInstruction:r}))},v=(y,m)=>{c(He({name:"knowledge assist source viewed",data:{question:m,sourceViewed:y.url||y.name},options:{includeConversationData:!0}}))};return(0,Cr.useEffect)(()=>{var y;n&&d==="idle"?c(Ai({question:n,promptInstruction:r})):(y=a.current)==null||y.focus()},[a,d]),(0,Cr.useEffect)(()=>{d==="done"&&(c(He({name:"knowledge assist question answered",data:{question:o||n,sources:p[p.length-1].answer.sources,answer:p[p.length-1].answer.answer,isFollowUpQuestion:p.length>1},options:{includeConversationData:!0}})),s(p.length-1),i(""))},[d,p]),(0,Cr.useEffect)(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,p]),(0,rt.jsxs)("div",{className:l.root,children:[p.length>0&&(0,rt.jsx)("div",{className:l.alignRight,children:(0,rt.jsx)(ne.Button,{onClick:t,children:u("reset")})}),(0,rt.jsxs)(ne.ActionsBar,{list:p.map(({answer:y})=>({text:y.answer,type:"answer"})),primaryLabel:u("use"),onPrimary:y=>e(y.text),children:[p.map(({question:y,answer:m},g)=>(0,rt.jsx)(ne.List,{children:(0,rt.jsx)(ne.ListItem,{"data-testid":"knowledge-search-answer",index:g,description:m.answer,closeOnSelect:!0,onClick:()=>e(m.answer),onSourceClick:f=>v(f,y),sources:m.sources,styles:{title:l.question,description:l.answer},children:y})},`${m.answer}_${g}`)),d==="loading"&&(0,rt.jsx)("p",{className:l.status,children:u("loading")}),d==="error"&&(0,rt.jsx)("p",{className:l.status,children:u("error")}),(0,rt.jsxs)("form",{className:l.form,onSubmit:h,children:[(0,rt.jsx)("input",{ref:a,placeholder:u("anotherQuestion"),className:l.input,type:"text",value:o,onFocus:()=>{s(-1)},onChange:y=>{s(-1),i(y.target.value)}}),(0,rt.jsx)("button",{type:"submit",className:l.submit,children:(0,rt.jsx)(_1,{})})]})]})]})},w1=QI;var YI={data:null,fetchState:"idle"},Ni=e=>e.profile.data,od=e=>e.profile.data?e.profile.data.uiConfig.widget.types.filter(t=>t.isActive):[],Aa=M("profile/getProfile",async(e,t)=>{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)}),ZI=U({name:"profile",initialState:YI,reducers:{},extraReducers:e=>{e.addCase(Aa.pending,t=>{t.fetchState="loading"}).addCase(Aa.rejected,t=>{t.fetchState="error"}).addCase(Aa.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),b1=ZI.reducer;var Te=S(w()),JI=200,eL=5,tL=4,nL=e=>e.reduce((t,n)=>[...t,...n.list.map(r=>({...r,type:n.value}))],[]),E1=(e,t)=>!t||e.toLowerCase().includes(t.toLowerCase()),rL=()=>{let e=z(),t=It(),n=B(Qg),[r,o]=(0,Ge.useState)(!1),[i,s]=(0,Ge.useState)(""),a=I(iw),l=I(Ni),[u,c]=(0,Ge.useState)(null),[p,d]=(0,Ge.useState)([]),[h,v]=(0,Ge.useState)(),y=I(pt),m=N("showSearch"),g=N("showEntitiesCommand"),f=N("showSummaryCommand"),x=N("showKnowledgeSearch"),_=N("showImageSearch"),b=N("searchTriggerKey"),E=I(r1),C=I(sw),R=I(ow),P=L=>_o(C.filter(X=>X.type===L.toUpperCase()),L),V=[{value:"PERSONAL",label:n("personalSuggestions"),list:P("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:n("urlSuggestions"),list:P("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:P("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:P("IMAGE"),listOrientation:"horizontal",shouldShow:_}].filter(L=>L.shouldShow),D=[{label:n("entitiesClipboard"),onClick:()=>e(qe("entities")),shouldShow:g&&E1(n("entitiesClipboard"),i)},{label:n("summaryClipboard"),onClick:()=>e(qe("summary")),shouldShow:f&&E1(n("summaryClipboard"),i)},{label:i?`${n("knowledgeAssist")}: ${i}`:n("knowledgeAssist"),onClick:()=>e(qe("knowledgeAssist")),shouldShow:x}].filter(L=>L.shouldShow),j=(E==null?void 0:E.map(L=>({value:L.code.toUpperCase(),label:`${L.name}s`,list:P(L.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],we=(0,Ge.useCallback)((0,C1.default)((L,X)=>{e(co({query:L,type:X,tags:["search-overlay"]}))},JI),[]),zn=nL([...j,...V]),it=(0,Ge.useCallback)((L,X)=>{if(!X)return;let Xt=[...V,...j].find(({value:Nt})=>Nt===X);Xt&&(e(qe("edit")),c({...L,searchTerm:void 0}),d(Xt.list))},[e,u,j]),xo=(0,Ge.useCallback)((L,X)=>{switch(X.type){case"IMAGE":t.send(zg,{suggestion:X});break;default:t.send(An,{text:L,suggestion:X})}e($e(!1))},[e]),Vi=L=>{Ra(L.text),e(He({name:"entity copied",data:{entity:L,type:"copy"}})),e($e(!1))},Lr=(0,Ge.useCallback)(L=>{e(He({name:"suggestion feedback",data:{text:L.text,source:"search",context:i},options:{includeConversationData:!0}}))},[i]),Ka=L=>{t.send(An,{text:L,suggestion:{source:"knowledge-assist",text:L}}),e(He({name:"answer used",data:{originalText:L},options:{includeConversationData:!0}})),s(""),e(qe("search")),e(Oi()),e($e(!1))},Wa=L=>{Ra(L),e($e(!1))},Ki=L=>{t.send(An,{text:L.text,suggestion:{source:"entity",text:L.text}}),e($e(!1))},Wi=u===null||p.indexOf(u)-1<0?void 0:()=>c(p[p.indexOf(u)-1]),Ar=u===null||p.indexOf(u)===p.length-1?void 0:()=>c(p[p.indexOf(u)+1]);function _o(L,X){return L.slice(0,h?10:X.toLowerCase()==="image"?tL:eL)}function Dd(L,X,Xt){return X.reduce((Nt,Vn)=>Xt&&h===Xt?Vn.length+Nt:_o(Vn,Xt).length+Nt,L)}function Gt(L){return X=>{r?window.confirm(n("warning"))&&(L(X),o(!1)):L(X)}}return(0,Ge.useEffect)(()=>{i?we(i,h):e(Qc())},[i,h]),(0,Ge.useEffect)(()=>{a==="search"&&e(Oi())},[a]),(0,Ge.useEffect)(()=>{y&&e(Pa())},[y]),s1(b,()=>e($e(!0))),!m||!l?null:(0,Te.jsxs)(ne,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:s,onChangeOpen:Gt(L=>e($e(L))),onChangeType:L=>v(L),onChangePage:Gt(L=>e(qe(L))),selectedType:h,search:i,page:a,isOpen:R,types:[...j,...V],children:[(0,Te.jsx)(ne.Page,{id:"search",children:(0,Te.jsxs)(ne.ActionsBar,{list:[...D.map(L=>({text:L.label,type:"command"})),...zn.map(L=>({text:L.text||L.url||L.message,type:L.type}))],primaryLabel:n("use"),secondaryLabel:n("preview"),onPrimary:({text:L},X)=>xo(L,zn[X]),onSecondary:(L,X)=>{it(zn[X-D.length],zn[X-D.length].type)},children:[D.length>0&&(0,Te.jsx)(ne.List,{heading:n("commands"),children:D.map((L,X)=>(0,Te.jsx)(ne.ListItem,{index:Dd(X,[],"commands"),closeOnSelect:!1,onClick:L.onClick,children:L.label},L.label))}),[...j,...V].map(({value:L,label:X,list:Xt,lineClamp:Nt,listOrientation:Vn},Mh)=>(0,Te.jsx)(ne.List,{heading:X,orientation:Vn==="horizontal"?"horizontal":"vertical",children:_o(Xt,L).map((ce,Or)=>(0,Te.jsx)(ne.ListItem,{index:Dd(D.length+Or,[...j,...V].slice(0,Mh).map(({list:PE})=>PE),L),closeOnSelect:!1,lineClamp:Nt,onClick:()=>xo(ce.text,ce),description:L!=="IMAGE"?ce.title&&ce.text:void 0,onFeedback:L!=="IMAGE"?()=>Lr(ce):void 0,children:L==="IMAGE"?(0,Te.jsx)(ne.Image,{title:ce.title||ce.text,src:ce.image}):ce.title||ce.text},`${ce.id}-${ce.text}`))},L))]})}),(0,Te.jsx)(ne.Page,{id:"edit",onDismiss:Gt(()=>{e(qe("search")),c(null)}),children:u&&(0,Te.jsx)(Jc,{suggestion:u,onTouched:o,onDismiss:()=>{o(!1),e(qe("search")),c(null),d([])},onNext:Ar,onPrevious:Wi,onUse:L=>{e(qe("search")),xo(L,{...u,source:`${u.source||"text_recommendation"}-preview`}),e($e(!1)),d([]),c(null)}})}),(0,Te.jsx)(ne.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:Gt(()=>{e(qe("search"))}),children:(0,Te.jsx)(c1,{onUse:Ki,onCopy:Vi})}),(0,Te.jsx)(ne.Page,{id:"summary",title:n("summaryTitle"),onDismiss:Gt(()=>{e(qe("search"))}),children:(0,Te.jsx)(h1,{onCopy:Wa})}),(0,Te.jsx)(ne.Page,{id:"knowledgeAssist",title:n("knowledgeAssist"),onDismiss:Gt(()=>{e(Oi()),e(qe("search"))}),children:(0,Te.jsx)(w1,{promptInstruction:l.knowledgeAssistPromptInstruction,question:i,onUse:Ka,onResetQuestion:()=>{e(Oi()),s("")}})})]})},T1=rL;var Mi=S(w()),oL=()=>{let e=N("showSearch"),t=N("isEmbedded");return(0,Mi.jsxs)(k1.Fragment,{children:[e&&(0,Mi.jsx)(T1,{}),(0,Mi.jsx)($w,{}),t&&(0,Mi.jsx)(Zw,{})]})},P1=oL;var ad=S(O());function Di(e){let{showMidSentenceSuggestions:t,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:r}=e.settings,{text:o,selection:i}=e.input.userCommitted;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 id=S(O());var Fi=S(O());var R1=S(O());function I1(e,t,n){(0,R1.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var L1={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};var go=S(w()),sL=["search","personal-collection-search","search-autocomplete"];function aL(e,t,n,r={}){let o="";return sL.includes(t)?o=H_(Cg(e,n,{stripAgentPart:!0}),r.searchKeywords??[n]):o=Cg(e,n,r),r.placeholders===!0&&(o=U_(o)),o}var lL=()=>{},uL=({index:e,selected:t,suggestion:n,onFeedback:r})=>{let o=N("inlineSuggestions"),i=I(hi),s=z(),a=k("TextSuggestion",L1),l=(0,Fi.useRef)(null);(0,Fi.useEffect)(()=>{let c=setTimeout(()=>{s(e_({text:n.text,suggestion:n}))},500);return()=>{clearTimeout(c)}},[n]),I1(l,"click",()=>{s(Sr(e)),s(Ht({suggestion:n,text:n.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let u=(0,Fi.useMemo)(()=>aL(n.text,n.source,i,{stripAgentPart:o,placeholders:!0,searchKeywords:n.searchKeywords}),[o,n.text,n.source,i,n.searchKeywords]);return n.source==="gpt"&&!o?null:(0,go.jsxs)("div",{className:a.root,onMouseEnter:()=>s(Sr(e)),children:[(0,go.jsx)(oe,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:lL,children:(0,go.jsx)(En,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:u})}),t&&r&&(0,go.jsx)("div",{className:a.actions,children:(0,go.jsx)(qc,{onFeedback:()=>r(n),suggestion:n.text})})]})},A1=uL;var Jg=S(w()),cL=({onFeedback:e,suggestions:t,selectedIndex:n,reverse:r})=>{let o=(0,id.useMemo)(()=>{let i=t.map((s,a)=>(0,Jg.jsx)(A1,{index:a,selected:a===n,suggestion:s,onFeedback:e},`${s.text}-${s.source}`));return r?i.reverse():i},[t,n,r]);return(0,Jg.jsx)(id.Fragment,{children:o})},sd=cL;var O1={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var Oa=S(w()),dL=({textSuggestions:e,selectedIndex:t})=>{let n=(0,ad.useRef)(null),r=k("InlineSuggestionsOverlay",O1),o=I(Di),i=z(),s=I(pt),a=I(gi),l=I(td),u=N("showTextSuggestions");return wi(()=>{i(Er({collapse:!0,skipWhenInputFocus:!0}))}),(0,ad.useEffect)(()=>{let c=n.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let p=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-p.right,0)}px`}),l||!o||!u||e.length===0||s!==!0||a===!1?null:(0,Oa.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,Oa.jsx)("div",{ref:n,className:r.paper,children:(0,Oa.jsx)(St,{children:(0,Oa.jsx)(sd,{suggestions:e,selectedIndex:t})})})})},pL=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),N1=Sn(pL)(dL);var ud=S($()),ji=S(O());var M1=S(O());function D1(e,t){let[n,r]=(0,M1.useState)(()=>{if(typeof window>"u")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return H.error(i),t}});return[n,i=>{try{let s=i instanceof Function?i(n):i;r(s),typeof window<"u"&&window.localStorage.setItem(e,JSON.stringify(s))}catch(s){H.error(s)}}]}var j1=S($()),Mn=S(O());var eh={};ke(eh,{enUS:()=>fL,nlNL:()=>mL});var fL={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"}]}]},mL={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 F1={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var Tr=S(w()),th=(e,t,n)=>r=>(0,Tr.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),gL=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=B(eh),s=It(),a=k("Login",F1),l=N("productName"),u=(0,Mn.useCallback)(m=>{m.preventDefault(),r&&r(parseInt(m.target.value,10))},[]),c=(0,Mn.useCallback)(m=>{m.preventDefault(),s.send(Li,!0)},[t]),p=(0,Mn.useMemo)(()=>m=>(0,Tr.jsx)("a",{onClick:f=>{f.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:m},"login"),[t]),d=(0,Mn.useCallback)(m=>(0,Tr.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:m},"prompt"),[c]),{min:h,hour:v,day:y}=(0,Mn.useMemo)(()=>({min:th(a,60*10,u),hour:th(a,60*60,u),day:th(a,60*60*12,u)}),[]);return(0,Tr.jsxs)("div",{className:(0,j1.default)(e,a.root),children:[i("loginPlease",{login:n?d:p,productName:l}),r&&(0,Tr.jsxs)(Mn.Fragment,{children:[(0,Tr.jsx)("br",{}),i("snooze",{min:h,hour:v,day:y})]})]})},ld=gL;var B1={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var Na=S(w()),hL=({title:e})=>{let t=k("SearchTrigger",B1),n=z();return(0,Na.jsxs)("button",{type:"button",className:t.root,onClick:()=>n($e(!0)),children:[(0,Na.jsx)(Ti,{}),(0,Na.jsx)("span",{className:t.text,children:e})]})},H1=hL;var nh={};ke(nh,{enUS:()=>yL,nlNL:()=>vL});var yL={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"}]},vL={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 U1={root:"_root_onpov_1",isInline:"_isInline_onpov_14",toggleButton:"_toggleButton_onpov_21",toggleButtonWrapper:"_toggleButtonWrapper_onpov_25",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_onpov_32",isCollapsed:"_isCollapsed_onpov_36",collapsible:"_collapsible_onpov_36",hints:"_hints_onpov_44",hintsHidden:"_hintsHidden_onpov_51",triggers:"_triggers_onpov_56",triggersRight:"_triggersRight_onpov_71"};var ue=S(w()),SL=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=k("SuggestionsOverlay",U1),o=B(nh),i=I(Di),s=Xx(),a=z(),l=(0,ji.useRef)(null),u=N("searchTriggerKey"),c=N("productName"),p=I(td),d=I(pt),h=I(gi),[v,y]=(0,ji.useState)(null),m=N("showSearch"),g=N("showTextSuggestions"),f=N("adminUrl"),x=N("isEmbedded"),[_,b]=D1("dd-snooze-until-ms",0),E=p||_>Date.now(),C=I(j=>j.input.text),R=e.filter(j=>j.source!=="gpt").length,P=()=>{E&&b(0),a(Ow(!E))},V=j=>{a(He({name:"suggestion feedback",data:{text:j.text,source:"overlay",context:C},options:{includeConversationData:!0}}))},D=j=>{let we=Date.now()+j*1e3;b(we),H.info(`Snooze until: ${new Date(we)}`),a(Er({collapse:!0}))};return(0,ji.useEffect)(()=>{R===0&&y(null)},[e,R]),wi(()=>{a(Er({collapse:!0,skipWhenInputFocus:!0}))}),d===null||h===!1?null:d===!1?(0,ue.jsxs)("div",{ref:l,className:(0,ud.default)(r.root,{[r.isCollapsed]:E}),children:[!E&&(0,ue.jsxs)("div",{className:r.triggers,children:[(0,ue.jsx)("div",{style:{flex:1}}),(0,ue.jsx)("div",{className:r.triggersRight,children:(0,ue.jsx)(Dr,{className:r.toggleButton,title:o("collapse"),onClick:P,isCollapsed:!1})})]}),(0,ue.jsx)("div",{className:r.toggleButtonWrapper,children:(0,ue.jsx)(Dr,{className:r.toggleButton,title:o("open",{productName:c}),onClick:P,isCollapsed:!0})}),(0,ue.jsx)("div",{className:r.collapsible,children:(0,ue.jsx)(ld,{loginUrl:f,isEmbedded:x,onLogIn:n,onSnooze:D})})]}):!s||!i?null:(0,ue.jsxs)("div",{ref:l,className:(0,ud.default)(r.root,{[r.isCollapsed]:E}),children:[!E&&(0,ue.jsxs)("div",{className:r.triggers,children:[(0,ue.jsx)("div",{style:{flex:1},children:m&&(0,ue.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>y(o(Gc()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>y(null),children:(0,ue.jsx)(H1,{title:o("search")})})}),(0,ue.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,ue.jsx)("div",{className:(0,ud.default)(!v&&r.hintsHidden,r.hints),children:v}),(0,ue.jsx)(Dr,{className:r.toggleButton,title:o("collapse"),onClick:P,isCollapsed:!1})]})]}),(0,ue.jsx)("div",{className:r.toggleButtonWrapper,children:(0,ue.jsx)(Dr,{className:r.toggleButton,title:o("open",{productName:c}),onClick:P,isCollapsed:!0})}),R>0&&g&&(0,ue.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,ue.jsx)(St,{children:(0,ue.jsx)(sd,{onFeedback:V,suggestions:e,selectedIndex:t,reverse:!0})})})]})},xL=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),z1=Sn(xL)(SL);var Ma=S(w()),_L=({children:e})=>{let n=N("locale").replace("-","");return(0,Ma.jsx)(lg.Provider,{value:n,children:e})},wL=({store:e,customStyles:t={},children:n})=>(0,Ma.jsx)(Vm,{store:e,children:(0,Ma.jsx)(_L,{children:(0,Ma.jsx)(qi.Provider,{value:t,children:n})})}),ho=wL;var wd=S($());var jn=S(O());var V1=S(O()),bL=["div","span","mark","strong","b","i","u","em"];function rh(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(bL.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,V1.cloneElement)(r,{children:rh(s,t,n+1)})]}return[...e,...t]}function kr(e){return e.tagName.toLowerCase()==="textarea"}var K1={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var J1=S($());var vd=S(O());function W1(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function cd(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function $1(e){return e!=null}var ih=S($()),Lt=S(O());var dd=S(O()),EL=["bottom","height","left","right","top","width"],CL=(e={},t={})=>EL.some(n=>e[n]!==t[n]),Dn=new Map,q1,G1=()=>{let e=[],t=[];Dn.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();CL(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{Dn.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),q1=window.requestAnimationFrame(G1)};function TL(e,t){return{observe(){let n=Dn.size===0;if(Dn.has(e)){let r=Dn.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else Dn.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&G1()},unobserve(){let n=Dn.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Dn.delete(e),Dn.size||cancelAnimationFrame(q1)}}}}function oh(e){let[t,n]=(0,dd.useState)(null);return(0,dd.useLayoutEffect)(()=>{if(!e.current)return;let r=TL(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var Bi=S(O()),Q1=S(vu());var X1={root:"_root_1jq08_1"};var Y1=({children:e})=>{let[t,n]=(0,Bi.useState)(null),r=(0,Bi.useContext)(qi);return(0,Bi.useLayoutEffect)(()=>{let o=document.createElement("div");return oo(o),o.classList.add(X1.root),r!=null&&r.portalRootNode&&o.classList.add(r==null?void 0:r.portalRootNode),document.body.appendChild(o),n(o),()=>{o.isConnected&&document.body.removeChild(o)}},[]),t?(0,Q1.createPortal)(e,t):null};var ln={ref:"_ref_1rcyi_1",root:"_root_1rcyi_7",positionAbove:"_positionAbove_1rcyi_13",positionBelow:"_positionBelow_1rcyi_17",positionLeft:"_positionLeft_1rcyi_21",positionRight:"_positionRight_1rcyi_25",alignStart:"_alignStart_1rcyi_29",alignCenter:"_alignCenter_1rcyi_34",alignEnd:"_alignEnd_1rcyi_40"};var pd=S(w()),fd=(e=!1)=>{let[t,n]=(0,Lt.useState)(e),r=(0,Lt.useCallback)(()=>n(!0),[]),o=(0,Lt.useCallback)(()=>n(!1),[]),i=(0,Lt.useCallback)(()=>n(a=>!a),[]),s=(0,Lt.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function sh(e,t=null,n=0){if(!e)return{display:"none"};let r=t?e.top-t.top<0||e.top<t.top-n?t.top-n:e.top+e.height>t.top+t.height+n?t.top+t.height+n-e.height:e.top:e.top,o=t?e.left<t.left-n?t.left-n:e.left+e.width>t.left+t.width+n?t.left+t.width+n-e.width:e.left:e.left;return{top:r,left:o,height:e.height,width:e.width}}var md=({className:e,triggerRef:t,boundaryRef:n=(0,Lt.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=sh,...a})=>{let l=oh(t),u=oh(n),c=(0,Lt.useMemo)(()=>s(l,u,0),[l,u]);return(0,pd.jsx)(Y1,{children:(0,pd.jsx)("div",{className:(0,ih.default)(ln.ref,{[ln.positionAbove]:r==="above",[ln.positionBelow]:r==="below",[ln.positionLeft]:r==="left",[ln.positionRight]:r==="right",[ln.alignStart]:o==="start",[ln.alignCenter]:o==="center",[ln.alignEnd]:o==="end"}),style:c,...a,role:"dialog",children:(0,pd.jsx)("div",{className:(0,ih.default)(e,ln.root),children:i})})})};var Z1=S($()),gd=S(O());var ah=S(w()),hd=(0,gd.forwardRef)(({className:e,children:t,...n},r)=>{let o=(0,gd.useRef)(null),i=k("TabCompletion",Cn);return(0,ah.jsx)("div",{ref:cd([o,r]),className:(0,Z1.default)(e,i.popoverContentContainer),...n,children:(0,ah.jsx)("div",{className:i.popoverContent,children:t})})});var Pr=S(w()),kL=e=>t=>{let n=sh(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},PL=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=k("TabCompletion",Cn),s=fd(),a=(0,vd.useMemo)(()=>kL(e.getBoundingClientRect()),[e]),[l,u]=Dc(e);return(0,vd.useEffect)(()=>{u?s.open():s.close()},[u]),(0,Pr.jsxs)("span",{children:[(0,Pr.jsx)("mark",{ref:cd([l,s.triggerRef]),className:(0,J1.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,Pr.jsx)(md,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,Pr.jsx)(hd,{style:n,children:(0,Pr.jsx)("div",{className:i.hintText,children:o})})})]})},yd=class extends wn{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(t,n){return n.keywordMatches&&n.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=n.keywordMatches.map(r=>({...r,keywordRegex:new RegExp(`\\b${W1(r.keyword)}\\b`,"i")})),this.keywordMatches=n.keywordMatches),this.usedKeywordMatches.clear(),t}match(t){let n=this.preparedKeywordMatches.map(o=>{if(this.usedKeywordMatches.has(o))return null;let i=t.match(o.keywordRegex);if(!i)return null;let s=t.charAt(i.index-1),a=t.charAt(i.index+o.keyword.length);return s==="{"&&a==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:o.suggestion,preparedKeywordMatch:o,valid:!0}}).filter($1);if(n.length===0)return null;let r=n.reduce((o,i)=>i.index<o.index?i:o);return this.usedKeywordMatches.add(r.preparedKeywordMatch),r}replaceWith(t,n){return(0,Pr.jsx)(PL,{inputElement:n.inputElement,suggestion:n.suggestion,inputStyle:n.inputStyle,boundaryRef:n.boundaryRef,children:t},`keyword_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var xd=S($());var Qe=S(O());var lh=S(w()),eb=()=>(0,lh.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,lh.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 Rr=S(O());var nb=S(qg());var tb={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Sd(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{return null}}function uh(e){return e.replace("https://www.","").replace("https://","")}var At=S(w()),RL=3,IL=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),LL=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=RL})=>{let i=k("LinkSearch",tb),[s,a]=(0,Rr.useState)(""),l=z(),u=I(vw("url")),c=I(aw("URL",IL)),[p,d]=(0,Rr.useState)(c.length-1),h=N("fallbackImage"),v=f=>{let x=f.target;a(x.value)},y=(f,x)=>{f.stopPropagation(),f.preventDefault(),window.open(x,"_blank")},m=f=>{var b;let x=p-1<0?c.length-1:p-1,_=p+1===c.length?0:p+1;f.code==="Escape"&&(a(""),t()),f.code==="ArrowUp"&&d(x),f.code==="ArrowDown"&&d(_),f.code==="Enter"&&e(((b=c[p])==null?void 0:b.text)||s)},g=(0,Rr.useCallback)((0,nb.default)(f=>{l(co({query:f,type:"URL",tags:["link-search"]}))},300),[]);return(0,Rr.useEffect)(()=>{s&&g(s)},[s]),(0,Rr.useEffect)(()=>()=>{l(Qc())},[]),(0,At.jsxs)("div",{className:i.root,children:[(0,At.jsx)(St,{withDivider:!0,children:(s?c:u).slice(0,o).map((f,x)=>(0,At.jsx)(oe,{selected:p===x,onClick:()=>e(f.text),"data-testid":"linksearch-suggestion",children:(0,At.jsxs)(ge,{children:[(0,At.jsx)(ge.Image,{src:Sd(f,"small",h||void 0),title:f.title||f.text}),(0,At.jsxs)(ge.Content,{className:i.content,cropText:!0,children:[(0,At.jsx)(ge.Title,{children:f.title||uh(f.text)}),f.title&&uh(f.text)]}),(0,At.jsx)(oe.Actions,{children:(0,At.jsx)(oe.ActionButton,{label:r,onClick:_=>y(_,f.text)})})]})},f.text))}),(0,At.jsx)(ka,{value:s,onChange:v,autoFocus:!0,placeholder:n,onKeyUp:m})]})},rb=LL;var ch={};ke(ch,{enUS:()=>AL,nlNL:()=>OL});var AL={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},OL={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var Xe=S(w()),NL=(0,Qe.forwardRef)((e,t)=>{let n=k("TabCompletion",Cn);return(0,Xe.jsx)("mark",{ref:t,className:(0,xd.default)(n.matchSelection)},"selection-start")}),ML=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=B(ch),s=k("TabCompletion",Cn),a=(0,Qe.useRef)(null),l=(0,Qe.useRef)(null),[u,c]=(0,Qe.useState)(null),p=z(),d=fd(document.activeElement===r),[h]=(0,Qe.useState)(()=>document.createRange());d.triggerRef.current=h,(0,Qe.useEffect)(()=>()=>h.detach(),[]),(0,Qe.useEffect)(()=>{let y=e.current,m=a.current;!y||!m||(h.setStart(y,0),h.setEnd(m,0))},[e.current,a.current]),wi(()=>{d.close()});let v=(0,Qe.useCallback)(y=>{let m=h.toString(),g=/^http(s?):\/\//.test(y)?y:`https://${y}`;p(uc({text:`[${m}](${g})`,replace:"selection"}))},[]);return(0,Xe.jsxs)("span",{children:[(0,Xe.jsx)("mark",{ref:a,className:(0,xd.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,Xe.jsx)(md,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,Xe.jsxs)(hd,{style:n,ref:l,children:[(0,Xe.jsx)("div",{className:(0,xd.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,Xe.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,Xe.jsx)(eb,{}),(0,Xe.jsx)("span",{children:"\xA0"}),(0,Xe.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,Xe.jsx)(rb,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:v,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},_d=class extends wn{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(t,n){return this.props=n,this.charCount=0,this.startRef=(0,Qe.createRef)(),this.foundIndex=0,t}match(t){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[n,r]=this.props.selection;if(n===r)return null;let o=this.foundIndex===0?n:r,i=o>=this.charCount&&o<=this.charCount+t.length?{index:o-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let s=this.foundIndex===1;return i&&s?this.charCount+=o-this.charCount:this.charCount+=t.length,i?{isStart:s,...i}:null}replaceWith(t,n){return n.isStart?(0,Xe.jsx)(NL,{ref:this.startRef}):(0,Xe.jsx)(ML,{inputElement:n.inputElement,startRef:this.startRef,boundaryRef:n.boundaryRef,inputStyle:n.inputStyle})}asTag(){return"mark"}};var Fn=S(w()),DL=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=k("TabCompletion",K1),c=N("insertLink"),p=N("showMidSentenceSuggestions"),d=N("inlineSuggestions"),h=jc(a),v=(0,jn.useRef)(null);(0,jn.useEffect)(()=>{kr(a)&&h&&Bc(a,h)},[h]);let y=(0,jn.useCallback)(f=>{if(!o||!n)return f;let x=[(0,Fn.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,Fn.jsx)("span",{"data-testid":"tab-completion",className:(0,wd.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&x.push((0,Fn.jsx)("span",{className:(0,wd.default)(u.hint,u.resetIndent),children:(0,Fn.jsx)(nl,{keyCode:"tab"},"tabHint")})),rh(f,x)},[o,n,r]),m=(0,jn.useMemo)(()=>{let f=[];return c&&f.push(new _d("selection")),f.push(new xi("placeholders")),i&&f.push(new yd("keywords")),f},[d,c,i]),g=(0,jn.useMemo)(()=>{let f=window.getComputedStyle(a);return{"--dd-color":f.color,"--dd-font-size":f.fontSize,"--dd-font-family":f.fontFamily,"--dd-font-variant":f.fontVariant}},[]);return e?(0,Fn.jsxs)("div",{ref:f=>{f!=null&&f.parentElement&&(v.current=f==null?void 0:f.parentElement)},className:u.root,style:g,children:[(0,Fn.jsx)(En,{tagName:"span",containerTagName:"div",className:(0,wd.default)(u.container,u.agentText),disableLineBreaks:kr(a),content:t||"\u200B",onAfterParse:y,matchers:m,selection:h,keywordMatches:s,inputElement:a,inputStyle:g,boundaryRef:v,inlineSuggestionsOnlyAtEnd:!p}),(0,Fn.jsx)("br",{})]}):null},FL=({input:e,ui:t,settings:n,styleSuggestions:r,conversation:o})=>{var y;let{tabCompletionSuggestion:i}=e,s=(i==null?void 0:i.text)||"",a=(i==null?void 0:i.source)||"",l=e.html??Ei(e.text),u=s.indexOf(e.text)===0?s.slice(e.text.length):"",{showTabHint:c}=t,{isSupported:p}=o,{showTabCompletion:d,visible:h,showStyleSuggestions:v}=n;return{showTabHint:c,showStyleSuggestions:v,showTabCompletion:d,content:l,tabText:u,source:a,keywordMatches:((y=r.list)==null?void 0:y.keywordMatches)??[],enabled:h&&p!==!1}},ob=Sn(FL)(DL);var $b=S($()),qb=S(O());var ib={list:[],fetchState:"idle",isInitialRequest:null},ab=e=>e.autoflows.list||[],sb=e=>t=>{var n;return(n=t.list)==null?void 0:n.find(r=>r.triggerPayload===e)},Bn=M("autoflows/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(e)}),dh=M("autoflows/start",async(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");await r.startAutoflowSession(e),await n(Bn(e.platformSessionId))}),ph=M("autoflows/stop",async(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");await r.stopAutoflowSession(e.platformSessionId),await n(Bn(e.platformSessionId))}),jL=U({name:"autoflows",initialState:ib,reducers:{},extraReducers:e=>{e.addCase(dh.pending,(t,n)=>{let r=sb(n.meta.arg.triggerPayload)(t);r.state="Started",r.isBusy=!0}),e.addCase(ph.pending,(t,n)=>{let r=sb(n.meta.arg.triggerPayload)(t);r.state="Aborted",r.isBusy=!0}),e.addCase(Bn.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}),e.addCase(Bn.rejected,t=>{t.fetchState="error"}),e.addCase(Bn.fulfilled,(t,n)=>{t.list=n.payload,t.fetchState="done"}),e.addCase(J,()=>ib)}}),lb=M("autoflows/openStream",(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");let o=r.openStream(e);o.on("sessionAborted",()=>{n(Bn(e))}),o.on("sessionCompleted",()=>{n(Bn(e))})}),ub=M("autoflows/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),cb=jL.reducer;var db={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},pb=e=>e.customMessages.list,fb=e=>t=>!!t.customMessages.sentSuggestions.find(n=>n===e),mb=e=>t=>!!t.customMessages.answeredSuggestions.find(n=>n===e),gb=e=>t=>!!t.customMessages.errorSuggestions.find(n=>n===e),Da=M("customMessages/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(e)}),bd=M("customMessages/send",async(e,t)=>{let{platformSessionId:n,suggestion:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");await o.sendCustomMessage(n,r)}),Ed=M("customMessages/answer",async(e,t)=>{let{platformSessionId:n,reply:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");await o.answerCustomMessage(n,r)}),hb=U({name:"customMessages",initialState:db,reducers:{onCustomMessage(e,t){Array.isArray(t.payload)?e.list=t.payload:e.list=[t.payload]}},extraReducers:e=>{e.addCase(Da.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}).addCase(Da.rejected,t=>{t.fetchState="error"}).addCase(Da.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload||[]}).addCase(bd.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.errorSuggestions=t.errorSuggestions.filter(r=>n.meta.arg.suggestion.text!==r)}).addCase(bd.rejected,(t,n)=>{let r=t.sentSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1))}).addCase(Ed.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(Ed.rejected,(t,n)=>{let r=t.answeredSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1)),t.answeredSuggestions.splice(r,1)}).addCase(J,()=>db)}}),yb=M("customMessages/openStream",(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");r.openStream(e).on("customMessageSuggestion",i=>{n(hb.actions.onCustomMessage(i))})}),vb=M("customMessages/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),Sb=hb.reducer;var BL={token:null,accountUrl:null,interval:null},xb=e=>t=>{let{passwordlessToken:{token:n,accountUrl:r}}=t;return n&&r?`${r}/apis/admin/session/passwordless/login/?token=${n}&redirect=${e}`:null},fh=M("passwordlessToken/getTemporaryPasswordlessToken",async(e,t)=>{let{deepdeskAPI:n}=t.extra,r=await n.requestPasswordlessToken();return{accountUrl:n.client.baseUrl,token:r}}),mh=M("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(fh()),setInterval(()=>r(fh()),n)}),_b=U({name:"passwordlessToken",initialState:BL,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(fh.fulfilled,(t,n)=>{t.token=n.payload.token,t.accountUrl=n.payload.accountUrl}),e.addCase(mh.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:wb}=_b.actions,bb=_b.reducer;function Eb(e){let{customMessages:t,autoflows:n}=e;return n.fetchState==="loading"&&n.isInitialRequest===!0||t.fetchState==="loading"&&t.isInitialRequest===!0}var Ob=S(O());var Ib=S($()),Lb=S(O());var Tb=S($());var Cb={root:"_root_838fd_1"};var Pb=S(w()),HL=({className:e,children:t})=>{let n=k("Unicode",Cb);return(0,Pb.jsx)("span",{className:(0,Tb.default)(e,n.root),children:t})},kb=HL;var Rb={isDisabled:"_isDisabled_1rmfm_1",buttonStart:"_buttonStart_1rmfm_5",root:"_root_1rmfm_8",buttonStop:"_buttonStop_1rmfm_8",stateBadge:"_stateBadge_1rmfm_19",isCompleted:"_isCompleted_1rmfm_26",isStarted:"_isStarted_1rmfm_30",isAborted:"_isAborted_1rmfm_34"};var gh={};ke(gh,{enUS:()=>UL,nlNL:()=>zL});var UL={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]},zL={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]};var ft=S(w()),KL=({disabled:e,state:t,displayName:n,description:r,onStartAutoflow:o,onStopAutoflow:i})=>{let s=k("Autoflow",Rb),a=B(gh),l=t==="Started"?"stop":"start",u=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,ft.jsxs)(oe,{className:(0,Ib.default)(s.root,{[s.isDisabled]:e,[s.isCompleted]:t==="Completed",[s.isAborted]:t==="Aborted",[s.isStarted]:t==="Started"}),children:[(0,ft.jsx)(ge,{children:(0,ft.jsxs)(ge.Content,{children:[(0,ft.jsxs)(ge.Title,{children:[t&&(0,ft.jsx)("span",{className:s.stateBadge,children:a(t)}),n]}),(0,ft.jsx)("span",{children:r})]})}),(0,ft.jsx)(oe.Actions,{fixed:t==="Started",children:(0,ft.jsx)(oe.ActionButton,{primary:!0,className:l==="start"?s.buttonStart:s.buttonStop,onClick:t==="Started"?i:o,disabled:e,label:(0,ft.jsxs)(Lb.Fragment,{children:[(0,ft.jsx)(kb,{children:u})," ",(0,ft.jsx)("span",{children:a(l)})]})})})]})},Ab=KL;var hh=S(w()),WL=(e,t)=>{let n=t.filter(r=>r.state==="Started");return n.length>0?n.indexOf(e)===-1:!1},$L=({autoflows:e,onStartAutoflow:t,onStopAutoflow:n,platformSessionId:r})=>(0,hh.jsx)(Ob.Fragment,{children:e.map(o=>(0,hh.jsx)(Ab,{displayName:o.displayName,description:o.description,disabled:o.isBusy||WL(o,e),state:o.state,onStartAutoflow:()=>t({platformSessionId:r,triggerPayload:o.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:r,triggerPayload:o.triggerPayload})},o.displayName))}),qL=({autoflows:e,conversation:t})=>{var n;return{autoflows:e.list,platformSessionId:(n=t.current)==null?void 0:n.sessionId}},GL={onStartAutoflow:dh,onStopAutoflow:ph},Nb=Sn(qL,GL)($L);var Cd=S(O());var Sh=S($());var yh=S(w()),vh=()=>(0,yh.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,yh.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 Mb={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};var un=S(w()),XL=({entities:e})=>{let t=k("EntitiesWidgetList",Mb),[n,r]=(0,Cd.useState)(void 0),o=z(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),Ra(a.text),o(He({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Cd.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,un.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,un.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,un.jsx)("span",{className:t.entityText,children:a.text}),(0,un.jsxs)("span",{className:t.iconWrapper,children:[(0,un.jsx)("span",{className:(0,Sh.default)(t.icon),children:(0,un.jsx)(vh,{})}),(0,un.jsx)("span",{className:(0,Sh.default)(t.icon,n===l&&t.iconClicked),children:(0,un.jsx)(vh,{})})]})]},a.text))})},Db=XL;var Fb=S($()),xh=S(O());var Hn={root:"_root_1e6ej_1",title:"_title_1e6ej_8",isUsed:"_isUsed_1e6ej_13",quickReplies:"_quickReplies_1e6ej_22",quickReply:"_quickReply_1e6ej_29",hasError:"_hasError_1e6ej_39",label:"_label_1e6ej_43",errorIcon:"_errorIcon_1e6ej_48"};var ot=S(w()),QL=({suggestion:e})=>{let t=B(lo),n=z(),r=I(fb(e.text)),o=I(mb(e.text)),i=I(gb(e.text)),s=I(tc),{replyOptions:a}=e,l=(0,xh.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),!(r||!s)&&n(bd({platformSessionId:s,suggestion:e}))},[e,r,n,s]),u=(0,xh.useCallback)(c=>{if(c.preventDefault(),c.stopPropagation(),!s||!a)return;let p=parseInt(c.target.dataset.index,10),d=a[p];n(Ed({platformSessionId:s,reply:d,suggestion:e}))},[e,r,n,s]);return(0,ot.jsxs)(oe,{onClick:l,className:(0,Fb.default)(Hn.root,{[Hn.isUsed]:r,[Hn.hasError]:i}),children:[(0,ot.jsx)(ge,{children:(0,ot.jsxs)(ge.Content,{children:[(0,ot.jsxs)(ge.Title,{className:Hn.title,children:[e.text," ",(0,ot.jsx)(rl,{className:Hn.label,children:"analyse tool"})," ",i&&(0,ot.jsx)("span",{className:Hn.errorIcon,role:"img","aria-label":t("sendingError"),title:t("sendingError"),children:"!"})]}),a&&a.length>0&&(0,ot.jsx)("ul",{className:Hn.quickReplies,children:a.map(c=>(0,ot.jsx)("li",{className:Hn.quickReply,children:c.title},c.title))})]})}),(0,ot.jsxs)(oe.Actions,{fixed:i||r,children:[a&&a.length>0&&(0,ot.jsx)(oe.DropdownButton,{label:t("answer"),disabled:o,children:a.map((c,p)=>(0,ot.jsx)(oe.DropdownItem,{index:p,label:c.title,onClick:u},c.title))}),(0,ot.jsx)(oe.ActionButton,{primary:!0,disabled:r,onClick:l,label:t(r?"suggestionSent":i?"tryAgain":"sendSuggestion")})]})]})},jb=QL;var _h=S(w()),Bb=()=>(0,_h.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,_h.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 Hb=S(O());var mt=S(w()),YL=({suggestion:e,lines:t,onEdit:n,onUse:r})=>{var d;let o=e.text||e.url||e.message,i=Yc(o),s=B(lo),a=N("showImages"),l=N("fallbackImage"),u=h=>{h.preventDefault(),h.stopPropagation(),r(o)},c=h=>{h.preventDefault(),h.stopPropagation(),n(e)},p=(0,Hb.useCallback)(h=>{window.open(i,"_blank"),h.stopPropagation(),h.preventDefault()},[i]);return(0,mt.jsxs)(oe,{onClick:u,"data-testid":"edit-suggestion",children:[(0,mt.jsxs)(ge,{children:[a&&e.image&&(0,mt.jsx)(ge.Image,{src:Sd(e,"small",l||void 0),title:e.title}),(0,mt.jsxs)(ge.Content,{children:[e.title&&(0,mt.jsx)(ge.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((d=e.searchKeywords)==null?void 0:d.length)>0&&(0,mt.jsx)(oe.Labels,{labels:e.searchKeywords}),(0,mt.jsx)(ge.Content,{cropText:t==="single",lineClamp:t==="multiple",children:o})]})]}),(0,mt.jsxs)(oe.Actions,{children:[i&&(0,mt.jsx)(oe.ActionButton,{onClick:p,label:s("visitUrl")}),(0,mt.jsx)(oe.ActionButton,{primary:!0,onClick:c,label:s("preview")}),(0,mt.jsx)(oe.ActionButton,{primary:!0,onClick:u,label:s("useSuggestion")})]})]})},Ub=YL;var Fa=S(w()),ZL=({contentType:e,lines:t,suggestions:n})=>{let r=It(),o=I(Pi),i=a=>{r.send(Ug,{state:o,suggestion:a,contentType:e})},s=(a,l)=>{r.send(An,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,Fa.jsx)(Fa.Fragment,{children:n.map(a=>(0,Fa.jsx)(Ub,{suggestion:a,lines:t,onEdit:l=>i(l),onUse:l=>s(l,a)},a.text||a.url||a.message))})},zb=ZL;var wh={};ke(wh,{enUS:()=>JL,nlNL:()=>eA});var JL={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},eA={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Vb={root:"_root_x0pwe_1",loginText:"_loginText_x0pwe_7",stateText:"_stateText_x0pwe_8",sectionList:"_sectionList_x0pwe_20",shortcutList:"_shortcutList_x0pwe_24",shortcut:"_shortcut_x0pwe_24",link:"_link_x0pwe_52"};var bh=S(w()),Kb=()=>(0,bh.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,bh.jsx)("path",{d:"M543-340q16.595 0 28.798-12.202Q584-364.405 584-381t-12.202-28.798Q559.595-422 543-422t-28.798 12.202Q502-397.595 502-381t12.202 28.798Q526.405-340 543-340Zm-25-126h47q2-29 8.5-43t32.5-39q27-26 37.5-45.395Q654-612.79 654-639q0-45.882-31.5-74.941Q591-743 540-743q-38 0-68 20.5T428-665l45 19q11-25 27.5-38t39.5-13q29.778 0 48.389 17Q607-663 607-637q0 20-9 35t-32 32q-32 29-40 46.5t-8 57.5ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-620h60v620h620v60H140Zm120-740v560-560Z"})});var Eh=S(w()),Wb=()=>(0,Eh.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Eh.jsx)("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});var K=S(w()),Td=(e,t)=>{let n=I(pt);(0,qb.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},tA=({onLogIn:e})=>{let t=B(wh),n=z(),r=N("isEmbedded"),o=k("Widget",Vb),i=N("showAutoflows"),s=N("showCustomMessages"),a=N("showSummaryCommand"),l=N("showKnowledgeSearch"),u=N("showSearch"),c=I(Ni),p=I(od),d=I(ab),h=I(rd),v=I(pb),y=I(nc),m=I(gi),g=I(pt),f=I(tc),x=I(Eb),_=I(Pi),b=It(),E=I(xw),C=I(xb("/admin/")),R=N("adminUrl"),P=N("productName");if(Td(()=>(n(Da(f)),n(yb(f)),()=>{n(vb(f))}),[n,m,s,f]),Td(()=>(n(Bn(f)),n(lb(f)),()=>{n(ub(f))}),[n,m,i,f]),Td(()=>{p.forEach(({type:D})=>{n(D==="entities"?Wt():Rn(D))})},[n,m,y,c]),Td(()=>(n(mh()),()=>{n(wb())}),[n]),m===!1)return(0,K.jsx)("div",{className:o.stateText,children:(0,K.jsx)("div",{children:(0,K.jsx)("p",{children:t("notSupported")})})},"supported");if(g===!1)return(0,K.jsx)("div",{className:o.loginText,children:(0,K.jsx)("div",{children:(0,K.jsx)(ld,{isEmbedded:r,loginUrl:R,onLogIn:e})})},"login");if(!c||!f||g===null||E||x)return(0,K.jsx)("div",{className:o.stateText,children:(0,K.jsx)("div",{children:(0,K.jsx)("p",{children:t("waiting")})})},"waiting");let V=u||a||l||C;return(0,K.jsx)("div",{className:(0,$b.default)(o.root),"data-testid":"widget",children:(0,K.jsxs)(ol,{className:o.sectionList,children:[V&&(0,K.jsx)(Kn,{title:t("actions"),type:"shortcuts",children:(0,K.jsxs)("div",{className:o.shortcutList,children:[u&&(0,K.jsxs)("button",{className:o.shortcut,"data-testid":"shortcut-search",onClick:()=>b.send("ShowCommandPalette",{isOpen:!0}),children:[(0,K.jsx)(Ti,{}),t("linkSearch")]}),a&&(0,K.jsxs)("button",{className:o.shortcut,"data-testid":"shortcut-summary",onClick:()=>b.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,K.jsx)(Wb,{}),t("linkSummary")]}),l&&(0,K.jsxs)("button",{className:o.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>b.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,K.jsx)(Kb,{}),t("linkKnowledgeSearch")]}),C&&(0,K.jsxs)("a",{className:o.shortcut,target:"_blank",href:C,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[(0,K.jsx)(Bb,{}),t("linkStudioLogin",{productName:P})]})]})}),s&&v.length>0&&(0,K.jsx)(Kn,{type:"custom-messages","data-testid":"custom-messages",children:(0,K.jsx)(St,{withDivider:!0,children:v.map(D=>(0,K.jsx)(jb,{suggestion:D},D.text))})}),i&&d.length>0&&(0,K.jsx)(Kn,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:(0,K.jsx)(St,{withDivider:!0,children:(0,K.jsx)(Nb,{})})}),p.map(({type:D,title:j,amount:we,lines:zn})=>{var it;switch(D){case"entities":return h&&h.length>0&&(0,K.jsx)(Kn,{type:D,title:j,"data-testid":`type-${D}`,children:(0,K.jsx)(Db,{entities:h})},D);default:return((it=_[D])==null?void 0:it.fetchState)==="done"&&_[D].suggestions.length>0&&(0,K.jsx)(Kn,{type:D,title:j,"data-testid":`type-${D}`,children:(0,K.jsx)(St,{withDivider:!0,children:(0,K.jsx)(zb,{lines:zn,contentType:D,suggestions:_[D].suggestions.slice(0,we)||[]})})},D)}})]})})},Gb=tA;function Hi(e){let t=new Range;return t.selectNodeContents(e),t}function Xb(e,t,n){try{return Ir(e,t,n),!0}catch{return!1}}function kd(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function Pd(e){return"tagName"in e&&e.tagName==="BR"}var ja=/[\u200B-\u200D\uFEFF]/g;function Ir(e,t,n){let r=new Range;if(e.firstChild===null&&t===0&&n===0)return r.selectNodeContents(e),r;let o=0,i=!1;function s(l,u){let c=-1,p=/[\u200B-\u200D\uFEFF]/;if(!p.test(l))return u;for(let d=0;d<=l.length;d++)if(p.test(l[d])||c++,c===u)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let u=l.textContent,c=u.replace(ja,""),p=o+c.length,d=t>=o&&t<=p,h=n>=o&&n<=p;if(d){let v=s(u,t-o);v===0&&!h?r.setStartBefore(l):r.setStart(l,v)}h&&(r.setEnd(l,s(u,n-o)),i=!0),o=p;break}case Node.ELEMENT_NODE:{if(Pd(l)&&(o===t&&r.setStartBefore(l),o++,o===n)){r.setEndAfter(l),i=!0;return}for(let c=0;c<l.childNodes.length&&(a(l.childNodes[c]),!i);c++);let u=l.lastChild;kd(l)&&u&&!kd(u)&&!Pd(u)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function Ba(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a,l,u=0;function c(p){let d=p===n,h=p===o;switch(p.nodeType){case Node.TEXT_NODE:{let v=p.textContent;d&&(a=u+v.substring(0,r).replace(ja,"").length),h&&(l=u+v.substring(0,i).replace(ja,"").length),u+=v.replace(ja,"").length;break}case Node.ELEMENT_NODE:{let v=p.nextSibling===null;Pd(p)&&!v&&u++;for(let y=0;y<p.childNodes.length;y++){let m=d&&y===r,g=h&&y===i;if(m&&(a=u),g&&(l=u),l!==void 0||((!m||!s)&&c(p.childNodes[y]),h&&y===i-1&&(l=u),l!==void 0))break}!h&&kd(p)&&!v&&u++,h&&(l=u);break}default:break}}if(c(e),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function Ha(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}=t,s=-1,a="";function l(u){let c=u===n,p=u===o;switch(c&&s++,u.nodeType){case Node.TEXT_NODE:{if(s!==0)return;let d=c?r:0,h=p?i:void 0,v=u.textContent.replace(ja,"");d===0&&h===void 0?a+=v:a+=v.substring(d,h);break}case Node.ELEMENT_NODE:{let d=u.nextSibling===null;s===0&&Pd(u)&&!d&&(a+=`
|
|
19
|
+
`),o=o.replace(/\n/g,"<br/>"),o}createContainer(t){var n;let o=(typeof global<"u"&&global.INTERWEAVE_SSR_POLYFILL||vR)();if(!o)return;let i=(n=this.props.containerTagName)!==null&&n!==void 0?n:"body",s=i==="body"||i==="fragment"?o.body:o.createElement(i);return t.match(gR)||(s.innerHTML=this.convertLineBreaks(this.props.escapeHtml?(0,E_.default)(t):t)),s}extractAttributes(t){let{allowAttributes:n}=this.props,r={},o=0;return t.nodeType!==b_||!t.attributes||([...t.attributes].forEach(i=>{let{name:s,value:a}=i,l=s.toLowerCase(),u=Oc[l]||Oc[s];if(!this.isSafe(t)||!l.match(hR)&&(!n&&(!u||u===mg)||l.startsWith("on")||a.replace(/(\s|\0|�([9AD]);)/,"").match(/(javascript|vbscript|livescript|xss):/i)))return;let c=l==="style"?this.extractStyleAttribute(t):a;u===xr?c=!0:u===to?c=Number.parseFloat(String(c)):u!==Ac&&(c=String(c)),r[gg[l]||l]=this.applyAttributeFilters(l,c),o+=1}),o===0)?null:r}extractStyleAttribute(t){let n={};return Array.from(t.style).forEach(r=>{let o=t.style[r];(typeof o=="string"||typeof o=="number")&&(n[r.replace(/-([a-z])/g,(i,s)=>String(s).toUpperCase())]=o)}),n}getTagConfig(t){let n={children:[],content:0,invalid:[],parent:[],self:!0,tagName:"",type:0,void:!1};return ma[t]?{...n,...ma[t],tagName:t}:n}isSafe(t){if(typeof HTMLAnchorElement<"u"&&t instanceof HTMLAnchorElement){let n=t.getAttribute("href");if(n!=null&&n.startsWith("#"))return!0;let r=t.protocol.toLowerCase();return r===":"||r==="http:"||r==="https:"||r==="mailto:"||r==="tel:"}return!0}isTagAllowed(t){return this.banned.has(t)||this.blocked.has(t)?!1:this.props.allowElements||this.allowed.has(t)}parse(){return this.container?this.parseNode(this.container,this.getTagConfig(this.container.nodeName.toLowerCase())):[]}parseNode(t,n){let{noHtml:r,noHtmlExceptMatchers:o,allowElements:i,transform:s,transformOnlyAllowList:a}=this.props,l=[],u="";return[...t.childNodes].forEach(c=>{if(c.nodeType===b_){let d=c.nodeName.toLowerCase(),h=this.getTagConfig(d);u&&(l.push(u),u="");let v=this.applyNodeFilters(d,c);if(!v)return;let y;if(s&&!(a&&!this.isTagAllowed(d))){this.keyIndex+=1;let m=this.keyIndex;y=this.parseNode(v,h);let g=s(v,y,h);if(g===null)return;if(typeof g<"u"){l.push(ro.default.cloneElement(g,{key:m}));return}this.keyIndex=m-1}if(this.banned.has(d))return;if(!(r||o&&d!=="br")&&this.isTagAllowed(d)&&(i||this.canRenderChild(n,h))){var p;this.keyIndex+=1;let m=this.extractAttributes(v),g={tagName:d};m&&(g.attributes=m),h.void&&(g.selfClose=h.void),l.push(ro.default.createElement(Nc,{...g,key:this.keyIndex},(p=y)!==null&&p!==void 0?p:this.parseNode(v,h)))}else l=[...l,...this.parseNode(v,h.tagName?h:n)]}else if(c.nodeType===mR){let d=r&&!o?c.textContent:this.applyMatchers(c.textContent||"",n);Array.isArray(d)?l=[...l,...d]:u+=d}}),u&&l.push(u),l}replaceTokens(t,n){if(!t.includes("{{{"))return t;let r=[],o=t,i=null;for(;i=o.match(yR);){let[s,a]=i,l=i.index,u=s.includes("/");l>0&&(r.push(o.slice(0,l)),o=o.slice(l));let{children:c,matcher:p,props:d}=n[a],h;if(u)h=s.length,r.push(p.createElement(c,d));else{let v=o.match(new RegExp(`{{{/${a}}}}`));h=v.index+v[0].length,r.push(p.createElement(this.replaceTokens(o.slice(s.length,v.index),n),d))}o=o.slice(h)}return o.length>0&&r.push(o),r.length===0?"":r.length===1&&typeof r[0]=="string"?r[0]:r}};function SR(e){var t;let{attributes:n,className:r,containerTagName:o,content:i,emptyContent:s,parsedContent:a,tagName:l,noWrap:u}=e,c=(t=o??l)!==null&&t!==void 0?t:"span",p=c==="fragment"?!0:u,d;if(a)d=a;else{let h=new Mc(i??"",e).parse();h.length>0&&(d=h)}return d||(d=s),p?ro.default.createElement(ro.default.Fragment,null,d):ro.default.createElement(Nc,{attributes:n,className:r,tagName:c},d)}function En(e){let{attributes:t,className:n,content:r="",disableFilters:o=!1,disableMatchers:i=!1,emptyContent:s=null,filters:a=[],matchers:l=[],onAfterParse:u=null,onBeforeParse:c=null,tagName:p="span",noWrap:d=!1,...h}=e,v=i?[]:l,y=o?[]:a,m=c?[c]:[],g=u?[u]:[];v.forEach(b=>{b.onBeforeParse&&m.push(b.onBeforeParse.bind(b)),b.onAfterParse&&g.push(b.onAfterParse.bind(b))});let f=m.reduce((b,E)=>E(b,e),r??""),x=new Mc(f,h,v,y),_=g.reduce((b,E)=>E(b,e),x.parse());return ro.default.createElement(SR,{attributes:t,className:n,containerTagName:e.containerTagName,emptyContent:s,noWrap:d,parsedContent:_.length===0?void 0:_,tagName:p})}var kg=S($());var yg={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};var T_=S($());var Si=S(O());function C_(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function Dc(e){let t=(0,Si.useRef)(null),[n,r]=(0,Si.useState)(!1);return(0,Si.useEffect)(()=>{let o=!1,i=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[s,a]=C_((c,p)=>{let d=t.current;if(!d)return;let h=c/i,v=p/i,y=d.getBoundingClientRect(),m=h>y.x&&h<y.x+y.width&&v>y.y&&v<y.y+y.height;m&&!o?(o=!0,r(!0)):!m&&o&&(o=!1,r(!1))},({clientX:c,clientY:p})=>[c,p]),[l,u]=C_(()=>{o=!1,r(!1)});return e.addEventListener("mousemove",s),e.addEventListener("mouseleave",l),()=>{a(),u(),e.removeEventListener("mousemove",s),e.removeEventListener("mouseleave",l)}},[t]),[t,n]}var Cn={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var vg=S(w()),xR=({inputElement:e,children:t})=>{let n=k("TabCompletion",Cn),[r,o]=Dc(e);return(0,vg.jsx)("mark",{ref:r,className:(0,T_.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},xi=class extends wn{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,vg.jsx)(xR,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var _i=S(O());function Fc(e){return e.contentEditable==="true"}function _R(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 k_(e){let{selectionStart:t,selectionEnd:n}=Fc(e)?_R(e):e;return[t,n]}function jc(e){let[,t]=(0,_i.useState)(),n=(0,_i.useRef)(null);return n.current=k_(e),(0,_i.useEffect)(()=>{let r=()=>{let[o,i]=n.current??[],s=k_(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 Bc(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(ko);if(!s||s.length===0)return;let a=0;s.find(l=>{let u=r.indexOf(l,a);return o>u&&i<u+l.length?(n.selectionStart=u,n.selectionEnd=u+l.length,!0):(a=u+l.length,!1)})}var P_=S(O());function wi(e){(0,P_.useEffect)(()=>{let t=n=>{n.isWithinRoot||e(n)};return document.body.addEventListener("mouseup",t),()=>{document.body.removeEventListener("mouseup",t)}},[e])}function oo(e){e.addEventListener("mouseup",t=>{t.isWithinRoot=!0},!0)}var R_,sn=new Map,wR=["bottom","height","left","right","top","width"],bR=(e={},t={})=>wR.some(n=>e[n]!==t[n]);function I_(e){var n,r;if(e.ownerDocument===document)return[];let t=((r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)??null;return t?[t,...I_(t)]:[]}function L_(e,t){return!e||!t?null:{...e,top:e.top+t.top,left:e.left+t.left}}var Hc=!1,A_=()=>{Hc=!0;let e=[];if(sn.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),sn.delete(n);return}let r=n.getBoundingClientRect();bR(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(L_,t.rect):t.rect;t.callbacks.forEach(r=>r(n))}),sn.size===0){Hc=!1;return}R_=window.requestAnimationFrame(A_)};function Sg(e,t){let n=I_(e),r=[],o=n.map((i,s)=>Sg(i,a=>{r[s]=a;let l=sn.get(e);if(!l)return;let u=r.reduce(L_,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),sn.has(e)){let s=sn.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else sn.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Hc&&A_()},unobserve(){o.forEach(s=>s.unobserve());let i=sn.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||sn.delete(e),sn.size||(cancelAnimationFrame(R_),Hc=!1)}}}}var O_,an=new Map,N_=()=>{an.forEach((e,t)=>{if(!t.isConnected){an.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)))}),an.size!==0&&(O_=window.requestAnimationFrame(N_))};function M_(e,t){return{observe(){let n=an.size===0;an.has(e)?an.get(e).callbacks.push(t):an.set(e,{visible:void 0,callbacks:[t]}),n&&N_()},unobserve(){let n=an.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||an.delete(e),an.size||cancelAnimationFrame(O_)}}}}var xg=["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 _g(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function bi(e){return parseFloat(e)}function Uc(e){return Math.round(e*1e6)}function D_(e){return e/1e6}function wg(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=bi(e.width),i=bi(e.borderLeftWidth),s=bi(e.borderRightWidth),a=bi(e.paddingRight),l=D_(Uc(o)-Uc(i)-Uc(s)),u=D_(Uc(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function io(e,t={}){var l;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=t.position??"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",oo(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};_g(r,n,xg),wg(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=M_(e,()=>{_g(r,n,xg),wg(r,e,n),i(),setTimeout(i,0)}),a=Sg(e,u=>{if(u===null){t.onRemove&&t.onRemove(),n.remove();return}if(u.height===0&&u.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(_g(r,n,xg),wg(r,e,n),i(),n.style.top=`${u.top}px`,n.style.left=`${u.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let c=t.closestScrollElement.getBoundingClientRect(),p=window.getComputedStyle(t.closestScrollElement),d=bi(p.borderTopWidth),h=bi(p.borderBottomWidth),v=c.top+d-u.top,y=u.top+u.height+-(c.top+c.height-h);n.style.clipPath=`inset(${v}px 0px ${y}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(l=e.parentElement)==null||l.appendChild(n),a.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),a.unobserve(),s.unobserve()}]}var bg={};ke(bg,{enUS:()=>ER,nlNL:()=>CR});var ER={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"No placeholders found"}]},one:{value:[{type:0,value:"There is one placeholder in your message"}]},other:{value:[{type:0,value:"There are "},{type:7},{type:0,value:" placeholders in your message"}]}},offset:0,pluralType:"cardinal"}]},CR={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"Alle placeholders zijn uit je bericht"}]},one:{value:[{type:0,value:"Er is 1 placeholder in jouw bericht"}]},other:{value:[{type:0,value:"Er zijn "},{type:7},{type:0,value:" placeholders in jouw bericht"}]}},offset:0,pluralType:"cardinal"}]};var ga=S(w()),F_=()=>(0,ga.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,ga.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,ga.jsx)("path",{d:"M243.8 339.8C232.9 350.7 215.1 350.7 204.2 339.8L140.2 275.8C129.3 264.9 129.3 247.1 140.2 236.2C151.1 225.3 168.9 225.3 179.8 236.2L224 280.4L332.2 172.2C343.1 161.3 360.9 161.3 371.8 172.2C382.7 183.1 382.7 200.9 371.8 211.8L243.8 339.8zM512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256zM256 48C141.1 48 48 141.1 48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48z"})]});var Eg=S(w()),j_=()=>(0,Eg.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Eg.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});function TR(e){let t=e.scrollHeight>e.clientHeight,r=window.getComputedStyle(e).overflowY.indexOf("hidden")!==-1;return t&&!r}function zc(e){return e?e instanceof ShadowRoot?zc(e.host):e===e.ownerDocument.body?e.ownerDocument:TR(e)?e:zc(e.parentNode):document.body}var B_=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(B_||{}),Tn=class{constructor(t){this.element=t;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentCaret=null;currentSelection={start:0,end:0};currentHTML="";isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(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)}triggerChange(){let t=this.getText(),n=this.getHTML(),r=t!==this.currentText;this.isActive&&(t===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&r&&!this.isSubmitting&&this.emit("change",{plainText:t}),r&&(this.currentSelection=this.getSelection()),this.currentText=t,this.isSubmitting=!1,(this.currentHTML!==n||n===null&&r)&&(this.emit("updated",{plainText:t}),this.triggerCaretPosition(),this.currentHTML=n))}triggerSelection(){let t=this.getSelection();(t.start!==this.currentSelection.start||t.end!==this.currentSelection.end)&&(this.currentSelection=t,this.emit("selection",t),this.triggerCaretPosition())}triggerCaretPosition(){let t=this.getCaretPosition();yr(t,this.currentCaret)||(this.currentCaret=t,this.emit("caret",t))}handleKeyUp(t){let{key:n,shiftKey:r}=t;(n==="Enter"&&r===!0||n==="Backspace")&&this.triggerChange(),this.triggerSelection()}handleClick(){this.triggerSelection()}handleFocus(){this.isFocused||this.emit("focus"),this.triggerSelection(),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(B_).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",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",r=>this.handleKeyDown(r)),this.addEventListener("keyup",r=>this.handleKeyUp(r)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",r=>this.handlePaste(r)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},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()});let n=zc(this.element);if(n){let r=()=>{this.currentCaret!==null&&(this.currentCaret=null,this.emit("caret",null))};n.addEventListener("scroll",r),this.disposeHandlers.push(()=>{n.removeEventListener("scroll",r)})}this.currentSelection=this.getSelection()}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))}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};var kn=class extends Tn{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:t,selectionEnd:n}=this.element;return{start:t,end:n}}getSelectedText(){let t=this.getSelection();return t?this.getText().slice(t.start,t.end):""}getCaretPosition(){return null}applyChanges(t){if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),r=t(this.element);return Promise.resolve(r).then(()=>{this.currentText=this.getText(),n!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let t=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var o;return(o=t==null?void 0:t.get)==null?void 0:o.call(this.element)},set:o=>{var i;(i=t==null?void 0:t.set)==null||i.call(this.element,o),this.triggerChange()}});let n=this.element.disabled,r=new MutationObserver(()=>{this.element.disabled!==n&&(n=this.element.disabled,this.emit(n?"disabled":"enabled"))});r.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>r.disconnect())}};var kR=/[.*+?^${}()|[\]\\]/g,PR=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function RR(e){return e.replace(kR,"\\$&")}function IR(e,t){let n=e.split("").findIndex((r,o)=>r!==t[o]);return n>-1?n:Math.min(e.length,t.length)}function LR(e){return e.search(PR)}function H_(e,t=[]){let n=e;return t.forEach(r=>{if(!r)return;let o=new RegExp(`\\b(${RR(r)})\\b`,"gi");n=n.replace(o,"<strong>$1</strong>")}),n}function U_(e){return e.replace(ko,'<mark data-type="placeholder">$1</mark>')}function Ei(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function AR(e,t){return e.split("").map((s,a)=>({char:s,index:a})).filter(({char:s,index:a})=>/\s/.test(s)&&a<=t).map(({index:s})=>s).reverse()[0]}function Cg(e,t,n={}){if(t){let r=IR(t.toLowerCase(),e.toLowerCase()),o=Ei(e.substring(r,e.length));if(n.stripAgentPart){let l=e.substring(0,r),u=LR(l);return`<span style="opacity: 0.5">${l.substring(u+1)}</span>${o}`}let s=t.split(Ey).length>3||t.length>30?AR(t.trim(),r):0;return`${`${s>0?"\u2026":""}${Ei(e.substring(s,r))}`}<strong>${o}</strong>`}return e}function Tg(e){return/<\/?[a-z][\s\S]*>/i.test(e)}function Vc(e){if(Tg(e)){let n=/<body[^>]*>([\s\S]*)<\/body>/gi.exec(e);return n?n[1]:""}return e}var ze=S(w()),OR=({value:e,onUse:t,...n})=>{var p;let r=B(bg),o=z(),i=Tg(e),s=k("EditSuggestionTextInput",yg),[a,l]=(0,Rt.useState)(null),u=(0,Rt.useRef)(null),c=((p=e.match(ko))==null?void 0:p.length)||0;return(0,Rt.useEffect)(()=>{let d;return u.current&&(l(u.current),d=new kn(u.current),d.on("change",({plainText:h})=>{o(tt.actions.userInput({text:h,selection:d.getSelection()}))}),d.on("keydown",h=>{o(tt.actions.registerKeyDown(lc(h))),h.code==="Enter"&&h.shiftKey&&t(d.getText())}),d.on("paste",({pastedText:h,selectionText:v})=>{o(tt.actions.registerPaste({text:h,selectionText:v}))}),d.on("cut",({selectionText:h})=>{o(tt.actions.registerCut(h))})),()=>{o(tt.actions.reset()),d.dispose(),d.deactivate()}},[u]),(0,Rt.useEffect)(()=>{e&&u.current&&(u.current.value=e)},[e,u]),(0,Rt.useEffect)(()=>{u.current&&setTimeout(()=>{if(!u.current)return;let d=u.current.value.length;u.current.setSelectionRange(d,d),u.current.focus()},0)},[u]),i?(0,ze.jsx)("div",{className:s.textInputWrapper,children:(0,ze.jsx)(En,{className:s.textInput,tagName:"div",content:e})}):(0,ze.jsxs)("div",{className:s.textInputWrapper,children:[(0,ze.jsx)("textarea",{...n,ref:u,"data-testid":"edit-suggestion-dialog-textarea",className:s.textInput,defaultValue:e,onChange:()=>{}}),a&&(0,ze.jsx)(NR,{inputElement:u.current,value:e}),(0,ze.jsxs)("div",{className:(0,kg.default)(s.alert,c===0?s.success:s.warning),children:[(0,ze.jsx)("div",{className:s.alertText,children:r("placeholders",{placeholderSize:c})}),c===0?(0,ze.jsx)(F_,{}):(0,ze.jsx)(j_,{})]})]})},NR=({inputElement:e,value:t})=>{let n=k("EditSuggestionTextInput",yg),r=(0,Rt.useRef)(null),o=jc(e);return(0,Rt.useEffect)(()=>{Bc(e,o)},[o,e]),(0,ze.jsx)(MR,{inputElement:e,children:(0,ze.jsxs)("div",{ref:r,className:(0,kg.default)(n.root,n.agentText),children:[(0,ze.jsx)(En,{tagName:"span",disableLineBreaks:!0,content:t,matchers:[new xi("placeholders")],inputElement:e,boundaryRef:r}),(0,ze.jsx)("br",{})]})})},MR=({inputElement:e,children:t})=>{let n=(0,Rt.useRef)(null);return(0,Rt.useEffect)(()=>{if(!n.current)return()=>{};let[r,o]=io(e,{overlayContainer:n.current,mirrorOverflow:!0});return r.setAttribute("translate","no"),()=>{o()}},[n.current]),(0,ze.jsx)("div",{ref:n,children:t})},z_=OR;var ki=S(O());var V_=S(O()),Kc=S($());var nt={root:"_root_pc5uy_1",list:"_list_pc5uy_2",listWrapper:"_listWrapper_pc5uy_6",listHorizontal:"_listHorizontal_pc5uy_10",page:"_page_pc5uy_19",search:"_search_pc5uy_25",pageNav:"_pageNav_pc5uy_33",pageTitle:"_pageTitle_pc5uy_41",pageBackButton:"_pageBackButton_pc5uy_48",listHeading:"_listHeading_pc5uy_62",listItem:"_listItem_pc5uy_70",listItemContent:"_listItemContent_pc5uy_79",listItemText:"_listItemText_pc5uy_97",listItemDescription:"_listItemDescription_pc5uy_105",listItemActions:"_listItemActions_pc5uy_112",truncate:"_truncate_pc5uy_123",lineClamp:"_lineClamp_pc5uy_129",listItemTitle:"_listItemTitle_pc5uy_136",listItemAction:"_listItemAction_pc5uy_112",listItemPrimaryAction:"_listItemPrimaryAction_pc5uy_157",listItemSelected:"_listItemSelected_pc5uy_162",sources:"_sources_pc5uy_166",sourcesTitle:"_sourcesTitle_pc5uy_173",source:"_source_pc5uy_166",icon:"_icon_pc5uy_188",searchIcon:"_searchIcon_pc5uy_205",searchInputWrapper:"_searchInputWrapper_pc5uy_210",searchInput:"_searchInput_pc5uy_210",select:"_select_pc5uy_231",selectType:"_selectType_pc5uy_248",selectWrapper:"_selectWrapper_pc5uy_252",image:"_image_pc5uy_282",imageSrc:"_imageSrc_pc5uy_289",imageSrcHidden:"_imageSrcHidden_pc5uy_300",imageSrcStatus:"_imageSrcStatus_pc5uy_304",imageTitle:"_imageTitle_pc5uy_314",actions:"_actions_pc5uy_319",actionsWrapper:"_actionsWrapper_pc5uy_323",actionsBar:"_actionsBar_pc5uy_329",actionButton:"_actionButton_pc5uy_338",actionShortcut:"_actionShortcut_pc5uy_356",actionShortcutFixKerning:"_actionShortcutFixKerning_pc5uy_363"};var so={};ke(so,{enUS:()=>DR,nlNL:()=>FR});var DR={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},FR={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};var _r=S(w()),jR=({src:e,title:t})=>{let n=k("CommandPalette",nt),[r,o]=(0,V_.useState)("loading"),i=B(so);return(0,_r.jsxs)("div",{className:n.image,children:[(0,_r.jsx)("img",{src:e,alt:t,onLoad:()=>o("done"),onError:()=>o("error"),className:(0,Kc.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(r)})}),r==="loading"&&(0,_r.jsx)("span",{className:(0,Kc.default)(n.imageSrc,n.imageSrcStatus),children:i("loading")}),r==="error"&&(0,_r.jsx)("span",{className:(0,Kc.default)(n.imageSrc,n.imageSrcStatus),children:(0,_r.jsx)(Za,{})}),t&&(0,_r.jsx)("span",{className:n.imageTitle,children:t})]})},K_=jR;var W_=S(O()),$_=S($());var ha=S(w());function Pg({children:e,heading:t,orientation:n}){let r=k("CommandPalette",nt);return W_.default.Children.count(e)===0?null:(0,ha.jsxs)("div",{"data-testid":"commandpalette-list",className:r.list,children:[t&&(0,ha.jsx)("h4",{className:r.listHeading,children:t}),(0,ha.jsx)("div",{className:(0,$_.default)(r.listWrapper,n==="horizontal"&&r.listHorizontal),children:e})]})}var ya=S($());var Wc=S(O()),X_=S(w()),q_=Wc.default.createContext(void 0);function wr(){let e=Wc.default.useContext(q_);if(e===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return e}var G_=({children:e,page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i})=>{let s=Wc.default.useMemo(()=>({page:t,isOpen:n,onChangeOpen:r,selected:o,setSelected:i}),[n,t,o]);return(0,X_.jsx)(q_.Provider,{value:s,children:e})};var Ae=S(O()),Q_=S($());var Rg={root:"_root_1oh4w_1",trigger:"_trigger_1oh4w_5",content:"_content_1oh4w_19",contentOpen:"_contentOpen_1oh4w_33",contentTop:"_contentTop_1oh4w_37",contentBottom:"_contentBottom_1oh4w_41",item:"_item_1oh4w_45"};var ao=S(w()),BR=0,Y_=Ae.default.createContext(null),HR=()=>{let e=(0,Ae.useContext)(Y_);if(!e)throw new Error("Invalid DropdownContext");return e},Z_=({trigger:e,children:t,position:n="bottom"})=>{let r=(0,Ae.useMemo)(()=>++BR,[]),o=(0,Ae.useRef)(null),i=(0,Ae.useRef)(null),s=k("Dropdown",Rg),[a,l]=(0,Ae.useState)(!1),[u,c]=(0,Ae.useState)(n),p=h=>{h.preventDefault(),h.stopPropagation(),l(!a)},d=(0,Ae.useCallback)(([h])=>{!h.isIntersecting&&a&&c(u==="top"?"bottom":"top")},[a]);return(0,Ae.useEffect)(()=>{let h=v=>{o.current&&!o.current.contains(v.target)&&l(!1)};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}},[]),(0,Ae.useEffect)(()=>{if(!i.current&&!a)return()=>{};let h=new IntersectionObserver(d,{root:null,rootMargin:"0px",threshold:1});return i.current&&h.observe(i.current),()=>{i.current&&h.unobserve(i.current)}},[i,a]),(0,ao.jsx)(Y_.Provider,{value:{setIsOpen:l},children:(0,ao.jsxs)("div",{ref:o,className:s.root,children:[(0,ao.jsx)("button",{id:`dropdown-${r}`,"data-testid":"dropdown-trigger","aria-haspopup":"true","aria-expanded":a,"aria-label":"Dropdown trigger",type:"button",className:s.trigger,onClick:p,children:e}),(0,ao.jsx)("div",{"data-testid":"dropdown-content",ref:i,"aria-hidden":!a,"aria-labelledby":`dropdown-${r}`,className:(0,Q_.default)(s.content,{[s.contentOpen]:a,[s.contentTop]:u==="top",[s.contentBottom]:u==="bottom"}),children:t})]})})};function UR({as:e,children:t,onClick:n,...r}){let o=e||"button",i=k("Dropdown",Rg),{setIsOpen:s}=HR(),a=l=>{s(!1),n(l),l.stopPropagation()};return(0,ao.jsx)(o,{type:"button",className:i.item,onClick:a,...r,children:t})}Z_.Item=UR;var Ig=Z_;var Lg=S(w()),J_=e=>(0,Lg.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512",...e,children:(0,Lg.jsx)("path",{fill:"currentColor",d:"M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"})});var lo={};ke(lo,{enUS:()=>zR,nlNL:()=>VR});var zR={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],giveFeedback:[{type:0,value:"Give feedback"}],answer:[{type:0,value:"Answer"}]},VR={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],giveFeedback:[{type:0,value:"Geef feedback"}],answer:[{type:0,value:"Antwoord"}]};var $c=S(w()),KR="%0d%0a%0d%0a%0d%0a",WR=(e,t)=>{let n=[`Suggestie: ${encodeURIComponent(t)}`,"Beschrijf je feedback:"];return`mailto:${e.join(",")}?subject=Suggestie feedback&body=${n.join(KR)}`},$R=({suggestion:e,onFeedback:t})=>{let n=B(lo),r=N("suggestionFeedbackEmailAddresses");return!r||r.length===0?null:(0,$c.jsx)(Ig,{trigger:(0,$c.jsx)(J_,{"data-testid":"feedback-dropdown-trigger"}),children:(0,$c.jsx)(Ig.Item,{as:"a",href:WR(r,e),onClick:t,children:n("giveFeedback")})})},qc=$R;var dt=S(w());function Ag({closeOnSelect:e=!0,lineClamp:t,children:n,onClick:r,onFeedback:o,onSourceClick:i,index:s,description:a,sources:l,styles:u,...c}){let{selected:p,setSelected:d,onChangeOpen:h}=wr(),v=k("CommandPalette",nt);function y(m){r(m),e&&h(!1)}return(0,dt.jsxs)("div",{className:(0,ya.default)(v.listItem,p===s&&v.listItemSelected),children:[(0,dt.jsx)("button",{onMouseEnter:()=>d(s),type:"button",className:(0,ya.default)("command-palette-list-item",v.listItemAction,v.listItemPrimaryAction),"aria-disabled":c.disabled??!1,onClick:y,...c,children:(0,dt.jsxs)("div",{className:v.listItemContent,children:[typeof n=="string"?(0,dt.jsx)("p",{className:(0,ya.default)(v.listItemText,v.truncate,u==null?void 0:u.title),children:n}):n,a&&(0,dt.jsx)(En,{tagName:"p",allowList:[],content:Vc(a),className:(0,ya.default)(v.listItemDescription,u==null?void 0:u.description,t?v.lineClamp:v.truncate)})]})}),o&&p===s&&(0,dt.jsx)("div",{className:v.listItemActions,children:(0,dt.jsx)(qc,{suggestion:String(n),onFeedback:o})}),l&&(0,dt.jsxs)("div",{className:v.sources,children:[(0,dt.jsx)("span",{className:v.sourcesTitle,children:"Sources"}),l.map(m=>m.url?(0,dt.jsx)("a",{className:v.source,href:m.url,target:"_blank",title:m.url,rel:"noopener noreferrer",onClick:()=>i&&i(m),children:m.name},m.url):(0,dt.jsx)("span",{className:v.source,children:m.name},m.name))]})]})}var uo=S(w());function Og({children:e,title:t,id:n,onDismiss:r}){let o=B(so),i=k("CommandPalette",nt),{page:s}=wr();return s!==n?null:(0,uo.jsxs)("div",{className:i.page,id:`page_${n}`,tabIndex:-1,children:[r&&(0,uo.jsxs)("div",{className:i.pageNav,children:[(0,uo.jsxs)("button",{className:i.pageBackButton,type:"button",onClick:r,children:[(0,uo.jsx)(Pc,{}),o("back")]}),t&&(0,uo.jsx)("h3",{className:i.pageTitle,children:t})]}),e]})}var br=S(O());var Gc=()=>/Mac/i.test(navigator.platform);var qR={info(...e){console.info("[Deepdesk]",...e)},warn(...e){console.warn("[Deepdesk]",...e)},error(...e){console.error("[Deepdesk]",...e)}},H=qR;function GR(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function te(e){return Array.isArray(e)?e.map(te):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>({...t,[GR(n)]:te(e[n])}),{}):e}function Ng(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Ce(e){return Array.isArray(e)?e.map(Ce):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>({...t,[Ng(n)]:Ce(e[n])}),{}):e}var XR={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Sa=e=>{var t,n,r;return{timezone:((t=e.info.visitorInfo)==null?void 0:t.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((n=e.info.agentInfo)==null?void 0:n.agentNickname)||"",visitorName:((r=e.info.visitorInfo)==null?void 0:r.visitorName)||""}},va=M("info/setAgentInfo",async(e,t)=>{let{deepdeskAPI:n}=t.extra;if(!e.agentId&&!e.agentNickname)throw new Error("At least provide agentId or agentNickname");let r=await n.client.get("/apis/admin/session/me/",{version:null}),o={};return r.external_id||(o.external_id=e.agentId),r.nickname||(o.nickname=e.agentNickname),!o.external_id&&!o.nickname?te(r):(await n.client.patch("/apis/admin/session/me/",o,{version:null}),te(r))}),Mg=M("info/setAgentSettings",async(e,t)=>{let{deepdeskAPI:n}=t.extra,r=await n.client.get("/apis/admin/session/me/",{version:null}),o={...typeof r.ui_config=="object"?r.ui_config:{},...e};return await n.client.patch("/apis/admin/session/me/",{ui_config:o}),o}),Dg=M("info/getAgentSettings",async(e,t)=>{let{deepdeskAPI:n}=t.extra;return(await n.client.get("/apis/admin/session/me/",{version:null})).ui_config}),ew=e=>e.info.agentInfo,tw=U({name:"info",initialState:XR,reducers:{setVisitorInfo(e,t){e.visitorInfo={...e.visitorInfo,...t.payload}}},extraReducers:e=>{e.addCase(va.pending,(t,n)=>{t.fetchState="loading",t.agentInfo={...t.agentInfo,...n.meta.arg}}).addCase(va.rejected,t=>{t.fetchState="error"}).addCase(va.fulfilled,(t,n)=>{t.fetchState="done",t.agentInfo={...t.agentInfo,...n.meta.arg,agentId:n.payload.externalId||n.meta.arg.agentId||"",agentNickname:n.payload.nickname||n.meta.arg.agentNickname||""}}).addCase(Mg.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(Dg.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(J,t=>{t.visitorInfo=void 0})}}),{setVisitorInfo:nw}=tw.actions,rw=tw.reducer;var Xc={list:[],fetchState:"idle",isOpen:!1,page:"search"},ow=e=>e.search.isOpen,iw=e=>e.search.page,sw=e=>e.search.list;function aw(e,t=n=>n){return n=>n.search.list.filter(r=>r.type===e).map(t)}var co=M("search/getAll",async(e,t)=>{var s;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(s=r.conversation.current)==null?void 0:s.profileCode;if(!o)throw new Error("Profile should be provided in order to be able to search");let{results:i}=await n.search({profile:o,query:e.query,filters:{type:e.type},params:Sa(r),tags:e.tags});return i.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:e.query}))}),lw=U({name:"search",initialState:Xc,reducers:{setIsOpen(e,t){e.isOpen=t.payload},setPage(e,t){e.page=t.payload},resetSearch(e){e.fetchState=Xc.fetchState,e.list=Xc.list}},extraReducers:e=>{e.addCase(co.pending,t=>{t.fetchState="loading"}).addCase(co.rejected,(t,n)=>{t.fetchState="error",H.error(n.error)}).addCase(co.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload}).addCase(J,()=>Xc)}}),{resetSearch:Qc,setIsOpen:$e,setPage:qe}=lw.actions,uw=lw.reducer;var QR=/(https?:\/\/[^\s]+)/,Yc=e=>e.split(" ").find(t=>QR.test(t));var Fg=S($());var Zc=S(w()),YR=({onClick:e,shortKeys:t,children:n,...r})=>{let o=k("CommandPalette",nt);return(0,Zc.jsxs)("button",{type:"button",...r,onClick:e,className:(0,Fg.default)(o.actionButton,r.className),children:[n,t&&t.map(i=>(0,Zc.jsx)("span",{className:(0,Fg.default)(o.actionShortcut,i===8629&&o.actionShortcutFixKerning),children:typeof i=="number"?String.fromCharCode(i):i},i))]})},Ci=YR;var Pn=S(w()),ZR=({children:e,primaryLabel:t,secondaryLabel:n,onPrimary:r,onSecondary:o,list:i})=>{let s=k("CommandPalette",nt),a=B(so),{selected:l,setSelected:u}=wr(),c=i[l],p=c&&typeof c.text=="string"&&Yc(c.text),d=(0,br.useRef)(null);function h(x){if(!d.current)return;let _=d.current.querySelectorAll(".command-palette-list-item"),b=0,E=0;x==="down"?(_.forEach((R,P)=>{P===l&&(b=P)}),E=b===_.length-1?0:b+1):x==="up"?(_.forEach((R,P)=>{P===l&&(b=P)}),E=b?b-1:_.length-1):u(0);let C=_[E];C&&typeof E=="number"&&(u(E),C.scrollIntoView&&C.scrollIntoView({behavior:"smooth",block:E?"center":"end"}))}function v(){if(!d.current)return;let x=d.current.querySelectorAll(".command-palette-list-item"),_=0;x.forEach((E,C)=>{C===l&&(_=C)});let b=x[_];b&&b.click()}let y=()=>{p&&window.open(p,"_blank")},m=()=>{c&&r(c,l)},g=()=>{!c.type||["IMAGE","command"].includes(c.type)||o&&o(c,l)},f=(0,br.useCallback)(x=>{if(x.key==="Enter"&&x.altKey&&p){y();return}if(x.key==="Enter"&&x.shiftKey){g();return}if(x.key==="ArrowDown"){x.preventDefault(),x.stopPropagation(),h("down");return}if(x.key==="ArrowUp"){x.preventDefault(),x.stopPropagation(),h("up");return}x.key==="Enter"&&l!==-1&&(x.preventDefault(),x.stopPropagation(),v())},[l]);return(0,br.useEffect)(()=>(window.addEventListener("keyup",f),()=>{window.removeEventListener("keyup",f)}),[f]),(0,Pn.jsxs)("div",{className:s.actions,children:[(0,Pn.jsx)("div",{className:s.actionsWrapper,ref:d,children:e}),(0,Pn.jsxs)("div",{className:s.actionsBar,children:[p&&(0,Pn.jsx)(Ci,{onClick:y,shortKeys:[Gc()?8997:"ALT",8629],children:a("visitUrl")}),c&&(0,Pn.jsxs)(br.Fragment,{children:[o&&c.type&&!["command","image"].includes(c.type.toLowerCase())&&(0,Pn.jsx)(Ci,{onClick:g,shortKeys:[8679,8629],children:n}),(0,Pn.jsx)(Ci,{onClick:m,shortKeys:[8629],children:t})]})]})]})},dw=ZR;var pw=S(O());var xa=S(w()),Ti=()=>(0,xa.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,xa.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,xa.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});var Vt=S(w());function JR({onChange:e,onChangeType:t,placeholder:n,typePlaceholder:r,types:o,value:i,selectedType:s},a){let l=k("CommandPalette",nt);return(0,Vt.jsxs)("div",{className:l.search,children:[(0,Vt.jsx)("div",{className:l.searchIcon,children:(0,Vt.jsx)(Ti,{})}),(0,Vt.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Vt.jsx)("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:u=>{e(u.currentTarget.value)},onFocus:u=>{u.currentTarget.select()},className:l.searchInput,placeholder:n,value:i,type:"text",id:"command-palette-search-input",autoFocus:!0}),o&&o.length>0&&(0,Vt.jsx)("div",{className:l.selectWrapper,children:(0,Vt.jsxs)("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:u=>t(u.target.value===r?void 0:u.target.value),value:s||r,children:[r&&(0,Vt.jsx)("option",{children:r}),o.map(u=>(0,Vt.jsx)("option",{value:u.value,children:u.label},u.value))]})})]})]})}var fw=(0,pw.forwardRef)(JR);var _a=S(w());function po({placeholder:e="Start typing to search...",typePlaceholder:t="All types",defaultPage:n="search",page:r,onChangePage:o,onChangeSearch:i,onChangeType:s,onChangeOpen:a,selectedType:l,types:u,children:c,isOpen:p,search:d}){let[h,v]=(0,ki.useState)(0),y=(0,ki.useRef)(null),m=()=>{o&&o(n),s(void 0),i(""),a(!1)},g=()=>{var f;if(r!==n&&o){o(n);return}if(l&&s){s(void 0),(f=y.current)==null||f.focus();return}if(d.length>0){i("");return}a(!1)};return(0,ki.useEffect)(()=>{v(0)},[d,r]),(0,_a.jsx)(vi,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:p,onBack:g,onClose:m,children:(0,_a.jsxs)(G_,{selected:h,setSelected:v,isOpen:p,onChangeOpen:a,page:r,children:[r===n&&(0,_a.jsx)(fw,{ref:y,onChange:i,onChangeType:s,placeholder:e,value:d,selectedType:l,types:u,typePlaceholder:t}),c]})})}po.Page=Og;po.List=Pg;po.Image=K_;po.ListItem=Ag;po.ActionsBar=dw;po.Button=Ci;var ne=po;var Ve=S(w()),eI=({suggestion:e,onUse:t,onDismiss:n,onTouched:r,onNext:o,onPrevious:i})=>{let s=e.text||e.url||e.message,a=k("EditSuggestionForm",u_),l=z(),u=B(eg),c=I(v=>v.overlayInput.text);(0,jg.useEffect)(()=>{e&&(l(tt.actions.reset()),l(tt.actions.stageSuggestion({text:s,suggestion:e,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(tt.actions.commitSuggestion()))},[e]);let p=v=>{v.preventDefault(),d(c)},d=v=>{l(dc(v)),t(v)},h=v=>y=>{c!==s?window.confirm(u("warning"))&&v(y):v(y)};return(0,jg.useEffect)(()=>{r&&r(c!==s)},[r,e,c]),(0,Ve.jsxs)("div",{className:a.root,children:[(0,Ve.jsxs)("div",{className:a.content,children:[e.title&&(0,Ve.jsx)("h3",{className:a.title,children:e.title}),e.searchKeywords&&e.searchKeywords.length>0&&(0,Ve.jsx)($d,{labels:e.searchKeywords}),(0,Ve.jsx)(z_,{onUse:d,value:Vc(c)})]}),(0,Ve.jsxs)("form",{className:a.actions,onSubmit:p,children:[(0,Ve.jsxs)("div",{children:[(0,Ve.jsx)("button",{disabled:!i,className:a.pagination,type:"button",onClick:i&&h(i),children:(0,Ve.jsx)(Pc,{})}),(0,Ve.jsx)("button",{disabled:!o,className:a.pagination,type:"button",onClick:o&&h(o),children:(0,Ve.jsx)(S_,{})})]}),(0,Ve.jsxs)("div",{className:a.primaryButtons,children:[(0,Ve.jsx)(ne.Button,{onClick:h(n),shortKeys:["esc"],children:u("dismiss")}),(0,Ve.jsx)(ne.Button,{shortKeys:[8679,8629],type:"submit",children:u("add")})]})]})]})},Jc=eI;var tI=["{amount}"," {amount}","{date}","{email}","{iban}","{name}","{postal_code}","{street}","{tarif}","{usage}","{3_digits}","{4_digits}","{5_digits}","{6_digits}","{7_digits}","{8_digits}","{9_digits}","{10_digits}"],nI=new RegExp(tI.map(e=>`(?:${e.replace("{","\\{").replace("}","\\}")})`).join("|"));function mw(e,t){let n=e.split(nI),r=0,o=[];for(let i=0;i<n.length;i++){let s=n[i];if(o.push(s),i===n.length-1)break;if(t.indexOf(s)===-1)return e;let a=n[i+1],l=i===n.length-2;r+=s.length;let u=r;if(l){let p=a.charAt(0),d=0;do u=p?t.indexOf(p,u+1):-1,d+=1;while(u!==-1&&a.indexOf(t.slice(u))!==0);if(u===-1&&d>2)return e}else u=a&&a!==""?t.indexOf(a,r):-1;let c=u===-1?t.slice(r):t.slice(r,u);o.push(c),r=u}return o.join("")}function gw(e,t){return typeof t=="boolean"?e:e.slice(0,t)}var yw={suggestions:[],fetchState:"idle",isInitialRequest:null},hw={default:yw},vw=e=>t=>{var n;return((n=t.textSuggestions[e])==null?void 0:n.suggestions)||[]},Sw=e=>t=>{var n;return((n=t.textSuggestions[e])==null?void 0:n.suggestions)??[]},xw=e=>{let t=Object.keys(e.textSuggestions).map(n=>{var r;return(r=e.textSuggestions[n])==null?void 0:r.fetchState});return t.length===0?!0:t.every(n=>n!=="done")},Pi=e=>e.textSuggestions,_w=e=>{let t=e.toLowerCase();return n=>{let r=n.text.toLowerCase();return r.startsWith(t)&&r.length>t.length}},ed=fe("textSuggestions/refresh"),Rn=M("textSuggestions/recommendations",async(e,t)=>{var u;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(u=r.conversation.current)==null?void 0:u.id,{textSuggestionsCount:i,inlineSuggestions:s}=r.settings,a=hi(r);if(!o)throw new Error("No current conversation to fetch text suggestions");let l=await n.getTextSuggestions(o,Sa(r),e);if(e==="default"){let c=s?l.filter(_w(a)):l;t.dispatch(on(c.slice(0,i)))}return l}),wa=M("textSuggestions/autocompletions",async(e,t)=>{var u;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(u=r.conversation.current)==null?void 0:u.id,{textSuggestionsCount:i,deanonymize:s,inlineSuggestions:a}=r.settings;if(!o)throw new Error("No current conversation to fetch text suggestions");let l=await n.getAutocompleteSuggestions(o,{...Sa(r),input:e});if(!t.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(_w(e))),s&&(l=l.map(c=>({...c,text:c.source!=="trie-with-typos"?mw(c.text,e):c.text}))),l=gw(l,i),t.dispatch(on(l)),l}),ww=U({name:"textSuggestions",initialState:hw,reducers:{setTextSuggestions:{reducer(e,t){let{contentType:n}=t.payload;e[n].fetchState="done",e[n].suggestions=t.payload.suggestions},prepare(e,t){return{payload:{contentType:e,suggestions:t}}}},setSuggestionState(e,t){return t.payload}},extraReducers:e=>{e.addCase(Rn.pending,(t,n)=>{let r=n.meta.arg,o=t[r]||yw;return{...t,[r]:{...o,fetchState:"loading",isInitialRequest:o.isInitialRequest===null}}}).addCase(Rn.rejected,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="error")}).addCase(Rn.fulfilled,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="done",t[r].suggestions=n.payload)}).addCase(wa.pending,t=>{t.default.fetchState="loading"}).addCase(wa.rejected,t=>{t.default.fetchState="error"}).addCase(wa.fulfilled,(t,n)=>{t.default.fetchState="done",t.default.suggestions=n.payload}).addCase(J,()=>hw)}}),{setTextSuggestions:bw,setSuggestionState:Ew}=ww.actions,Cw=ww.reducer;var Tw={contentType:null,suggestion:null},kw=e=>e.activeSuggestion.suggestion,Pw=e=>e.activeSuggestion.contentType,Rw=U({name:"activeSuggestion",initialState:Tw,reducers:{setActiveSuggestion(e,t){let{contentType:n,suggestion:r}=t.payload;e.contentType=n,e.suggestion=r},resetActiveSuggestion(e){e.contentType=null,e.suggestion=null}},extraReducers:e=>{e.addCase(J,()=>Tw)}}),{setActiveSuggestion:In,resetActiveSuggestion:Bg}=Rw.actions,Iw=Rw.reducer;var Hg={};ke(Hg,{enUS:()=>rI,nlNL:()=>oI});var rI={warning:[{type:0,value:"Are you sure you want to discard the message?"}],editContentLabel:[{type:0,value:"Edit and view suggestion"}],overlayLabel:[{type:0,value:"Close dialog"}]},oI={warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}],editContentLabel:[{type:0,value:"Bewerk en bekijk suggestie"}],overlayLabel:[{type:0,value:"Sluit"}]};var iI={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var td=({ui:e})=>e.overlayCollapsed;var Lw=U({name:"ui",initialState:iI,reducers:{setShowTabHint(e,t){e.showTabHint=t.payload},setInputHasFocus(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:ba,setInputHasFocus:Ri,setOverlayCollapsed:Er,setOpenOverlayWhenTyping:Aw,setOverlayCollapsedUserOverwrite:Ow}=Lw.actions,Nw=Lw.reducer;var Ea=S(O()),Dw=S(w()),Mw=Ea.default.createContext(null),fo=({broadcastEvents:e,children:t})=>{let n=Ea.default.useMemo(()=>e,[]);return(0,Dw.jsx)(Mw.Provider,{value:n,children:t})},It=()=>{let e=(0,Ea.useContext)(Mw);if(!e)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return e};var sI={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},pt=e=>e.auth.isLoggedIn,Fw=e=>e.auth.loginFetchState,jw=e=>e.auth.verifyFetchState,Bw=e=>e.auth.showLoginOverlay,Ln=M("auth/validate",async(e,t)=>t.extra.deepdeskAPI.isLoggedIn()),Hw=M("auth/requestLogin",async({email:e},t)=>{let{deepdeskAPI:n}=t.extra;return n.requestLoginByEmail(e)}),Ca=M("auth/verifyLoginToken",async({token:e},t)=>{let{deepdeskAPI:n}=t.extra;return n.verifyLoginToken(e)}),Uw=U({name:"auth",initialState:sI,reducers:{setIsLoggedIn(e,t){e.isLoggedIn=t.payload},setShowLoginOverlay(e,t){e.showLoginOverlay=t.payload}},extraReducers:e=>{e.addCase(Ln.pending,t=>{t.loginFetchState="loading"}),e.addCase(Ln.fulfilled,(t,{payload:n})=>{t.isLoggedIn=n,t.loginFetchState="done"}),e.addCase(Ln.rejected,t=>{t.loginFetchState="error",t.isLoggedIn=!1}),e.addCase(Ca.pending,t=>{t.verifyFetchState="loading"}),e.addCase(Ca.rejected,t=>{t.verifyFetchState="error"}),e.addCase(Ca.fulfilled,(t,n)=>{n.payload.isLoggedIn?t.verifyFetchState="done":t.verifyFetchState="error"})}}),{setIsLoggedIn:Ii,setShowLoginOverlay:zw}=Uw.actions,Vw=Uw.reducer;var Ug="SetActiveSuggestion",Li="ShowLoginOverlay",Ta="UserLoggedIn",aI="UserLoggedOut",An="ApplySuggestion",zg="ApplyImageSuggestion",lI="ShowCommandPalette",uI=e=>({[Ug]:t=>{e.dispatch(Ew(t.state)),e.dispatch(In({contentType:t.contentType,suggestion:t.suggestion}))},[lI]:t=>{e.dispatch($e(t.isOpen)),t.page&&e.dispatch(qe(t.page))},[Li]:t=>{e.dispatch(zw(t))},[Ta]:()=>{e.dispatch(Ln())},[aI]:()=>{e.dispatch(Ln())},[zg]:t=>{e.dispatch(fc({suggestion:t.suggestion}))},[An]:t=>{e.dispatch(Ht({...t,eventMetrics:{inputType:"mouse"},replace:"selection"})),e.dispatch(_n())}}),Kw=uI;var Vg=S(w()),cI=()=>{var v;let[e,t]=(0,Ww.useState)(!1),n=I(kw),r=I(Pw),o=I(Pi),i=z(),s=It(),a=B(Hg),l=()=>{n!==null&&e?window.confirm(a("warning"))&&u():u()},u=()=>{i(Bg()),i(Ri(!0)),i(tt.actions.reset())},c=(y,m)=>{i(Bg()),i(Ri(!0)),s.send(An,{text:y,suggestion:{...m,source:`${m.source||"text_recommendation"}-preview`}})};if(n===null||r===null)return null;let p=(v=o[r])==null?void 0:v.suggestions.indexOf(n),d=p===0||p===null?void 0:()=>i(In({contentType:r,suggestion:o[r].suggestions[p-1]})),h=p===o[r].suggestions.length-1||p===null?void 0:()=>i(In({contentType:r,suggestion:o[r].suggestions[p+1]}));return(0,Vg.jsx)(vi,{autoFocus:!0,isOpen:p!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,Vg.jsx)(Jc,{onTouched:t,onDismiss:u,onUse:y=>c(y,n),suggestion:n,onNext:h,onPrevious:d})})},$w=cI;var nd=S($()),Kt=S(O());var Gw=S($());var qw={root:"_root_1ukx5_1"};var Xw=S(w()),dI=({className:e,value:t,...n})=>{let r=k("TextInput",qw);return(0,Xw.jsx)("input",{className:(0,Gw.default)(e,r.root),type:"text",value:t,...n})},ka=dI;var Kg={};ke(Kg,{enUS:()=>pI,nlNL:()=>fI});var pI={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"}]},fI={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 Qw={root:"_root_1edpl_1",anchorButton:"_anchorButton_1edpl_5",errorMessage:"_errorMessage_1edpl_19",title:"_title_1edpl_25",subtitle:"_subtitle_1edpl_31",text:"_text_1edpl_38",input:"_input_1edpl_43",actions:"_actions_1edpl_48",button:"_button_1edpl_55",primaryButton:"_primaryButton_1edpl_70"};var ye=S(w());var mI=e=>{try{let t=new URL(e);return new URLSearchParams(t.search).get("token")||void 0}catch{return e}},gI=({agentEmail:e,isOpen:t,origin:n="",onSuccess:r,onDismiss:o})=>{let i=B(Kg),s=k("LoginTokenDialog",Qw),a=I(jw),l=z(),u=N("productName"),[c,p]=(0,Kt.useState)(e||""),[d,h]=(0,Kt.useState)(0),[v,y]=(0,Kt.useState)(""),m=(0,Kt.useCallback)(async _=>{_.preventDefault(),l(Hw({email:c})),h(1)},[n,c]),g=()=>{y(""),h(0)},f=(0,Kt.useCallback)(async _=>{_.preventDefault();let b=mI(_.target.elements.token.value);if(!b){y(i("verifyCodeError",{login:x}));return}l(Ca({token:b}))},[n]),x=(0,Kt.useMemo)(()=>_=>(0,ye.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:s.anchorButton,onClick:g,children:_},"back-button"),[]);return(0,Kt.useEffect)(()=>{a==="error"&&y(i("verifyCodeError",{login:x})),a==="done"&&r()},[a]),(0,ye.jsx)(vi,{autoFocus:!0,isOpen:t,contentAriaLabel:i("promptTitle",{productName:u}),overlayAriaLabel:i("promptTitle",{productName:u}),onClose:o,onBack:o,children:(0,ye.jsxs)("div",{className:s.root,children:[(0,ye.jsx)("h1",{className:s.title,children:i("promptTitle",{productName:u})}),d===0&&(0,ye.jsxs)("form",{onSubmit:m,children:[(0,ye.jsx)("h2",{className:s.subtitle,children:i("requestCodeTitle")}),(0,ye.jsx)("p",{className:s.text,children:i("requestCodeBody",{productName:u})}),(0,ye.jsx)(ka,{className:s.input,name:"email",placeholder:i("requestCodeInputPlaceholder"),value:c,onChange:_=>p(_.target.value)}),(0,ye.jsx)("div",{className:s.actions,children:(0,ye.jsx)("button",{type:"submit",className:(0,nd.default)(s.button,s.primaryButton),children:i("requestCodeSubmitLabel")})})]}),d===1&&(0,ye.jsxs)("form",{onSubmit:f,children:[(0,ye.jsx)("h2",{className:s.subtitle,children:i("verifyCodeTitle")}),(0,ye.jsx)("p",{className:s.text,children:i("verifyCodeBody")}),(0,ye.jsx)(ka,{className:s.input,name:"token",placeholder:i("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),v&&(0,ye.jsx)("div",{className:s.errorMessage,children:v}),(0,ye.jsxs)("div",{className:s.actions,children:[(0,ye.jsx)("button",{type:"button",className:(0,nd.default)(s.button),onClick:g,children:i("back")}),(0,ye.jsx)("button",{type:"submit",className:(0,nd.default)(s.button,s.primaryButton),disabled:["loading","done"].includes(a),children:i("verifyCodeSubmitLabel")})]})]})]})})},Yw=gI;var Jw=S(w()),hI=()=>{let e=I(Bw),t=I(ew),n=N("adminUrl"),r=It(),o=()=>r.send(Li,!1),i=()=>{r.send(Li,!1),r.send(Ta)};return(0,Jw.jsx)(Yw,{isOpen:e,agentEmail:t==null?void 0:t.agentEmail,origin:n,onDismiss:o,onSuccess:i})},Zw=hI;var C1=S(qg()),Ge=S(O());var NI={data:null,fetchState:"idle"},r1=e=>e.contentTypes.data,Pa=M("contentTypes/getContentTypes",async(e,t)=>t.extra.deepdeskAPI.getContentTypes()),MI=U({name:"contentTypes",initialState:NI,reducers:{},extraReducers:e=>{e.addCase(Pa.pending,t=>{t.fetchState="loading"}).addCase(Pa.rejected,t=>{t.fetchState="error"}).addCase(Pa.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),o1=MI.reducer;function Ra(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 i1=S(O());function s1(e,t){(0,i1.useEffect)(()=>{let n=r=>{var o;((o=navigator==null?void 0:navigator.platform)!=null&&o.toLowerCase().includes("mac")?r.metaKey:r.ctrlKey)&&r.key===e&&(r.preventDefault(),r.stopPropagation(),t())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}var Ia=S(O());var a1={data:null,fetchState:"idle"},rd=e=>{var i;let t=[],{visitorName:n}=e.info.visitorInfo??{},{agentName:r,agentNickname:o}=e.info.agentInfo??{};return r&&r!==n&&t.push(r),o&&o!==n&&t.push(o),((i=e.entities.data)==null?void 0:i.filter(s=>!t.includes(s.text)))??null},Wt=M("entities/getEntities",async(e,t)=>{let{deepdeskAPI:n,dynamicThunkObject:r}=t.extra;if(!r.conversationQuery)return Promise.resolve([]);let o=r.conversationQuery,i=await o();return i.length===0?Promise.resolve([]):n.getEntities(i)}),DI=e=>e.filter((t,n)=>n===e.findIndex(r=>r.text===t.text)),FI=U({name:"entities",initialState:a1,reducers:{},extraReducers:e=>{e.addCase(Wt.pending,t=>{t.fetchState="loading"}).addCase(Wt.rejected,t=>{t.fetchState="error"}).addCase(Wt.fulfilled,(t,n)=>{t.fetchState="done",t.data=DI(t.data?[...t.data,...n.payload]:n.payload)}).addCase(J,()=>a1)}}),l1=FI.reducer;var Gg={};ke(Gg,{enUS:()=>jI,nlNL:()=>BI});var jI={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},BI={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var u1={root:"_root_17kae_1",empty:"_empty_17kae_5"};var mo=S(w()),HI=({onCopy:e,onUse:t})=>{let n=(0,Ia.useRef)(null),r=k("EntitiesList",u1),o=B(Gg),i=I(rd),s=z();return(0,Ia.useEffect)(()=>{s(Wt())},[]),(0,Ia.useEffect)(()=>{n.current&&n.current.focus()},[n]),(0,mo.jsxs)("div",{className:r.root,ref:n,tabIndex:-1,children:[i&&i.length>0&&(0,mo.jsx)(ne.ActionsBar,{primaryLabel:o("copy"),secondaryLabel:o("use"),onPrimary:(a,l)=>e(i[l]),onSecondary:(a,l)=>t(i[l]),list:i.map(a=>({text:a.text,type:a.label,primaryAction:"copy",secondaryAction:"use"})),children:(0,mo.jsx)(ne.List,{children:i.map((a,l)=>(0,mo.jsx)(ne.ListItem,{index:l,closeOnSelect:!0,onClick:()=>e(a),children:a.text},a.text))},"entities")}),i&&i.length===0&&(0,mo.jsx)("p",{className:r.empty,children:o("noResults")})]})},c1=HI;var $t=S(O());var d1={data:null,fetchState:"idle"},p1=e=>e.summary.data,f1=e=>e.summary.fetchState==="error",On=M("summary/getSummary",async(e,t)=>{let n=t.getState().profile.data;if(!n)throw new Error("Profile is not defined");let{deepdeskAPI:r,dynamicThunkObject:o}=t.extra;if(!o.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let i=o.conversationQuery,s=await i();if(s.length===0)return Promise.reject(new Error("No messages are included"));let a=await r.getSummary(s,{promptInstruction:n.summarizerPromptInstruction,model:n.summarizerModel});return a?{summary:a}:Promise.reject(new Error("Summary is not provided"))}),UI=U({name:"summary",initialState:d1,reducers:{},extraReducers:e=>{e.addCase(On.pending,t=>{t.data=null,t.fetchState="loading"}).addCase(On.rejected,t=>{t.data=null,t.fetchState="error"}).addCase(On.fulfilled,(t,n)=>{t.fetchState="done",n.payload&&(t.data=n.payload.summary)}).addCase(J,()=>d1)}}),m1=UI.reducer;var Xg={};ke(Xg,{enUS:()=>zI,nlNL:()=>VI});var zI={copy:[{type:0,value:"Copy"}],error:[{type:0,value:"Could not generate a summary"}],loading:[{type:0,value:"Generating summary, this may take a few moments."}]},VI={copy:[{type:0,value:"Kopieer"}],error:[{type:0,value:"Kon helaas geen samenvatting genereren."}],loading:[{type:0,value:"Samenvatting wordt gemaakt, dit kan even duren."}]};var g1={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};var Nn=S(w()),KI=({onCopy:e})=>{let t=(0,$t.useRef)(null),n=k("SummaryForm",g1),[r,o]=(0,$t.useState)(""),i=B(Xg),s=I(p1),a=I(f1),l=z(),u=()=>{l(He({name:"summary copied to clipboard",data:{originalText:s,finalText:r},options:{includeConversationData:!0}})),e(r)},c=()=>{let p=document.getSelection();p&&l(He({name:"summary copied to clipboard",data:{originalText:s,finalText:p==null?void 0:p.toString()},options:{includeConversationData:!0}}))};return(0,$t.useEffect)(()=>{l(On())},[]),(0,$t.useEffect)(()=>{o(s||"")},[s]),(0,$t.useEffect)(()=>{t.current&&s&&t.current.focus()},[t,s]),(0,$t.useEffect)(()=>{let p=d=>{d.key==="Enter"&&d.shiftKey&&u()};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p)}},[r]),(0,Nn.jsx)("div",{className:n.root,tabIndex:-1,children:a?(0,Nn.jsx)("p",{className:n.error,children:i("error")}):(0,Nn.jsxs)($t.Fragment,{children:[(0,Nn.jsx)("div",{className:n.main,children:(0,Nn.jsx)("textarea",{placeholder:s?void 0:i("loading"),disabled:!s,className:n.textInput,ref:t,value:r,onCopy:c,onChange:p=>o(p.target.value)})}),(0,Nn.jsx)("div",{className:n.actions,children:(0,Nn.jsx)(ne.Button,{shortKeys:[8679,8629],onClick:u,children:i("copy")})})]})})},h1=KI;var Qg={};ke(Qg,{enUS:()=>WI,nlNL:()=>$I});var WI={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},$I={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],summaryClipboard:[{type:0,value:"Gesprek samenvatten"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var Cr=S(O());var Yg={};ke(Yg,{enUS:()=>qI,nlNL:()=>GI});var qI={use:[{type:0,value:"Use"}],loading:[{type:0,value:"Loading..."}],error:[{type:0,value:"Something went wrong, please try again later."}],anotherQuestion:[{type:0,value:"Send a message..."}],reset:[{type:0,value:"Reset conversation"}]},GI={use:[{type:0,value:"Gebruik"}],loading:[{type:0,value:"Laden..."}],error:[{type:0,value:"Er ging iets mis, probeer het later opnieuw."}],anotherQuestion:[{type:0,value:"Stuur een bericht..."}],reset:[{type:0,value:"Reset gesprek"}]};var y1={root:"_root_1g4pq_1",title:"_title_1g4pq_9",empty:"_empty_1g4pq_20",status:"_status_1g4pq_24",form:"_form_1g4pq_30",input:"_input_1g4pq_43",submit:"_submit_1g4pq_55",question:"_question_1g4pq_63",answer:"_answer_1g4pq_67",alignRight:"_alignRight_1g4pq_73"};var Zg={data:[],fetchState:"idle"},v1=e=>{var t;return(t=e.answer)==null?void 0:t.data},S1=e=>e.answer.fetchState,Oi=fe("answer/resetKnowledgeSearch"),Ai=M("answer/getAnswer",async(e,t)=>{var s,a;let{deepdeskAPI:n}=t.extra,r=t.getState().answer.data,o=(a=(s=t.getState().profile)==null?void 0:s.data)==null?void 0:a.knowledgeAssistant;if(!o)throw new Error("KnowledgeAssistant is not defined");let i=await n.knowledgeAssist({promptInstruction:e.promptInstruction,question:e.question},r,o);return{question:e.question,answer:i}}),XI=U({name:"answer",initialState:Zg,reducers:{},extraReducers:e=>{e.addCase(Ai.pending,t=>{t.fetchState="loading"}).addCase(Ai.rejected,t=>{t.fetchState="error"}).addCase(Ai.fulfilled,(t,n)=>{t.fetchState="done",t.data=[...t.data,n.payload]}).addCase(J,()=>Zg).addCase(Oi,()=>Zg)}}),x1=XI.reducer;var La=S(w()),_1=()=>(0,La.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,La.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,La.jsx)("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});var rt=S(w()),QI=({onUse:e,onResetQuestion:t,question:n,promptInstruction:r})=>{let[o,i]=Cr.default.useState(""),{setSelected:s}=wr(),a=(0,Cr.useRef)(null),l=k("EntitiesList",y1),u=B(Yg),c=z(),p=I(v1),d=I(S1),h=async y=>{y.preventDefault(),y.stopPropagation(),o!==""&&c(Ai({question:o,promptInstruction:r}))},v=(y,m)=>{c(He({name:"knowledge assist source viewed",data:{question:m,sourceViewed:y.url||y.name},options:{includeConversationData:!0}}))};return(0,Cr.useEffect)(()=>{var y;n&&d==="idle"?c(Ai({question:n,promptInstruction:r})):(y=a.current)==null||y.focus()},[a,d]),(0,Cr.useEffect)(()=>{d==="done"&&(c(He({name:"knowledge assist question answered",data:{question:o||n,sources:p[p.length-1].answer.sources,answer:p[p.length-1].answer.answer,isFollowUpQuestion:p.length>1},options:{includeConversationData:!0}})),s(p.length-1),i(""))},[d,p]),(0,Cr.useEffect)(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,p]),(0,rt.jsxs)("div",{className:l.root,children:[p.length>0&&(0,rt.jsx)("div",{className:l.alignRight,children:(0,rt.jsx)(ne.Button,{onClick:t,children:u("reset")})}),(0,rt.jsxs)(ne.ActionsBar,{list:p.map(({answer:y})=>({text:y.answer,type:"answer"})),primaryLabel:u("use"),onPrimary:y=>e(y.text),children:[p.map(({question:y,answer:m},g)=>(0,rt.jsx)(ne.List,{children:(0,rt.jsx)(ne.ListItem,{"data-testid":"knowledge-search-answer",index:g,description:m.answer,closeOnSelect:!0,onClick:()=>e(m.answer),onSourceClick:f=>v(f,y),sources:m.sources,styles:{title:l.question,description:l.answer},children:y})},`${m.answer}_${g}`)),d==="loading"&&(0,rt.jsx)("p",{className:l.status,children:u("loading")}),d==="error"&&(0,rt.jsx)("p",{className:l.status,children:u("error")}),(0,rt.jsxs)("form",{className:l.form,onSubmit:h,children:[(0,rt.jsx)("input",{ref:a,placeholder:u("anotherQuestion"),className:l.input,type:"text",value:o,onFocus:()=>{s(-1)},onChange:y=>{s(-1),i(y.target.value)}}),(0,rt.jsx)("button",{type:"submit",className:l.submit,children:(0,rt.jsx)(_1,{})})]})]})]})},w1=QI;var YI={data:null,fetchState:"idle"},Ni=e=>e.profile.data,od=e=>e.profile.data?e.profile.data.uiConfig.widget.types.filter(t=>t.isActive):[],Aa=M("profile/getProfile",async(e,t)=>{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)}),ZI=U({name:"profile",initialState:YI,reducers:{},extraReducers:e=>{e.addCase(Aa.pending,t=>{t.fetchState="loading"}).addCase(Aa.rejected,t=>{t.fetchState="error"}).addCase(Aa.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),b1=ZI.reducer;var Te=S(w()),JI=200,eL=5,tL=4,nL=e=>e.reduce((t,n)=>[...t,...n.list.map(r=>({...r,type:n.value}))],[]),E1=(e,t)=>!t||e.toLowerCase().includes(t.toLowerCase()),rL=()=>{let e=z(),t=It(),n=B(Qg),[r,o]=(0,Ge.useState)(!1),[i,s]=(0,Ge.useState)(""),a=I(iw),l=I(Ni),[u,c]=(0,Ge.useState)(null),[p,d]=(0,Ge.useState)([]),[h,v]=(0,Ge.useState)(),y=I(pt),m=N("showSearch"),g=N("showEntitiesCommand"),f=N("showSummaryCommand"),x=N("showKnowledgeSearch"),_=N("showImageSearch"),b=N("searchTriggerKey"),E=I(r1),C=I(sw),R=I(ow),P=L=>_o(C.filter(X=>X.type===L.toUpperCase()),L),V=[{value:"PERSONAL",label:n("personalSuggestions"),list:P("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:n("urlSuggestions"),list:P("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:P("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:P("IMAGE"),listOrientation:"horizontal",shouldShow:_}].filter(L=>L.shouldShow),D=[{label:n("entitiesClipboard"),onClick:()=>e(qe("entities")),shouldShow:g&&E1(n("entitiesClipboard"),i)},{label:n("summaryClipboard"),onClick:()=>e(qe("summary")),shouldShow:f&&E1(n("summaryClipboard"),i)},{label:i?`${n("knowledgeAssist")}: ${i}`:n("knowledgeAssist"),onClick:()=>e(qe("knowledgeAssist")),shouldShow:x}].filter(L=>L.shouldShow),j=(E==null?void 0:E.map(L=>({value:L.code.toUpperCase(),label:`${L.name}s`,list:P(L.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],we=(0,Ge.useCallback)((0,C1.default)((L,X)=>{e(co({query:L,type:X,tags:["search-overlay"]}))},JI),[]),zn=nL([...j,...V]),it=(0,Ge.useCallback)((L,X)=>{if(!X)return;let Xt=[...V,...j].find(({value:Nt})=>Nt===X);Xt&&(e(qe("edit")),c({...L,searchTerm:void 0}),d(Xt.list))},[e,u,j]),xo=(0,Ge.useCallback)((L,X)=>{switch(X.type){case"IMAGE":t.send(zg,{suggestion:X});break;default:t.send(An,{text:L,suggestion:X})}e($e(!1))},[e]),Vi=L=>{Ra(L.text),e(He({name:"entity copied",data:{entity:L,type:"copy"}})),e($e(!1))},Lr=(0,Ge.useCallback)(L=>{e(He({name:"suggestion feedback",data:{text:L.text,source:"search",context:i},options:{includeConversationData:!0}}))},[i]),Ka=L=>{t.send(An,{text:L,suggestion:{source:"knowledge-assist",text:L}}),e(He({name:"answer used",data:{originalText:L},options:{includeConversationData:!0}})),s(""),e(qe("search")),e(Oi()),e($e(!1))},Wa=L=>{Ra(L),e($e(!1))},Ki=L=>{t.send(An,{text:L.text,suggestion:{source:"entity",text:L.text}}),e($e(!1))},Wi=u===null||p.indexOf(u)-1<0?void 0:()=>c(p[p.indexOf(u)-1]),Ar=u===null||p.indexOf(u)===p.length-1?void 0:()=>c(p[p.indexOf(u)+1]);function _o(L,X){return L.slice(0,h?10:X.toLowerCase()==="image"?tL:eL)}function Dd(L,X,Xt){return X.reduce((Nt,Vn)=>Xt&&h===Xt?Vn.length+Nt:_o(Vn,Xt).length+Nt,L)}function Gt(L){return X=>{r?window.confirm(n("warning"))&&(L(X),o(!1)):L(X)}}return(0,Ge.useEffect)(()=>{i?we(i,h):e(Qc())},[i,h]),(0,Ge.useEffect)(()=>{a==="search"&&e(Oi())},[a]),(0,Ge.useEffect)(()=>{y&&e(Pa())},[y]),s1(b,()=>e($e(!0))),!m||!l?null:(0,Te.jsxs)(ne,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:s,onChangeOpen:Gt(L=>e($e(L))),onChangeType:L=>v(L),onChangePage:Gt(L=>e(qe(L))),selectedType:h,search:i,page:a,isOpen:R,types:[...j,...V],children:[(0,Te.jsx)(ne.Page,{id:"search",children:(0,Te.jsxs)(ne.ActionsBar,{list:[...D.map(L=>({text:L.label,type:"command"})),...zn.map(L=>({text:L.text||L.url||L.message,type:L.type}))],primaryLabel:n("use"),secondaryLabel:n("preview"),onPrimary:({text:L},X)=>xo(L,zn[X]),onSecondary:(L,X)=>{it(zn[X-D.length],zn[X-D.length].type)},children:[D.length>0&&(0,Te.jsx)(ne.List,{heading:n("commands"),children:D.map((L,X)=>(0,Te.jsx)(ne.ListItem,{index:Dd(X,[],"commands"),closeOnSelect:!1,onClick:L.onClick,children:L.label},L.label))}),[...j,...V].map(({value:L,label:X,list:Xt,lineClamp:Nt,listOrientation:Vn},Mh)=>(0,Te.jsx)(ne.List,{heading:X,orientation:Vn==="horizontal"?"horizontal":"vertical",children:_o(Xt,L).map((ce,Or)=>(0,Te.jsx)(ne.ListItem,{index:Dd(D.length+Or,[...j,...V].slice(0,Mh).map(({list:PE})=>PE),L),closeOnSelect:!1,lineClamp:Nt,onClick:()=>xo(ce.text,ce),description:L!=="IMAGE"?ce.title&&ce.text:void 0,onFeedback:L!=="IMAGE"?()=>Lr(ce):void 0,children:L==="IMAGE"?(0,Te.jsx)(ne.Image,{title:ce.title||ce.text,src:ce.image}):ce.title||ce.text},`${ce.id}-${ce.text}`))},L))]})}),(0,Te.jsx)(ne.Page,{id:"edit",onDismiss:Gt(()=>{e(qe("search")),c(null)}),children:u&&(0,Te.jsx)(Jc,{suggestion:u,onTouched:o,onDismiss:()=>{o(!1),e(qe("search")),c(null),d([])},onNext:Ar,onPrevious:Wi,onUse:L=>{e(qe("search")),xo(L,{...u,source:`${u.source||"text_recommendation"}-preview`}),e($e(!1)),d([]),c(null)}})}),(0,Te.jsx)(ne.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:Gt(()=>{e(qe("search"))}),children:(0,Te.jsx)(c1,{onUse:Ki,onCopy:Vi})}),(0,Te.jsx)(ne.Page,{id:"summary",title:n("summaryTitle"),onDismiss:Gt(()=>{e(qe("search"))}),children:(0,Te.jsx)(h1,{onCopy:Wa})}),(0,Te.jsx)(ne.Page,{id:"knowledgeAssist",title:n("knowledgeAssist"),onDismiss:Gt(()=>{e(Oi()),e(qe("search"))}),children:(0,Te.jsx)(w1,{promptInstruction:l.knowledgeAssistPromptInstruction,question:i,onUse:Ka,onResetQuestion:()=>{e(Oi()),s("")}})})]})},T1=rL;var Mi=S(w()),oL=()=>{let e=N("showSearch"),t=N("isEmbedded");return(0,Mi.jsxs)(k1.Fragment,{children:[e&&(0,Mi.jsx)(T1,{}),(0,Mi.jsx)($w,{}),t&&(0,Mi.jsx)(Zw,{})]})},P1=oL;var ad=S(O());function Di(e){let{showMidSentenceSuggestions:t,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:r}=e.settings,{text:o,selection:i}=e.input.userCommitted;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 id=S(O());var Fi=S(O());var R1=S(O());function I1(e,t,n){(0,R1.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var L1={root:"_root_4u430_1",actions:"_actions_4u430_8",badge:"_badge_4u430_15",formattedText:"_formattedText_4u430_19"};var go=S(w()),sL=["search","personal-collection-search","search-autocomplete"];function aL(e,t,n,r={}){let o="";return sL.includes(t)?o=H_(Cg(e,n,{stripAgentPart:!0}),r.searchKeywords??[n]):o=Cg(e,n,r),r.placeholders===!0&&(o=U_(o)),o}var lL=()=>{},uL=({index:e,selected:t,suggestion:n,onFeedback:r})=>{let o=N("inlineSuggestions"),i=I(hi),s=z(),a=k("TextSuggestion",L1),l=(0,Fi.useRef)(null);(0,Fi.useEffect)(()=>{let c=setTimeout(()=>{s(e_({text:n.text,suggestion:n}))},500);return()=>{clearTimeout(c)}},[n]),I1(l,"click",()=>{s(Sr(e)),s(Ht({suggestion:n,text:n.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let u=(0,Fi.useMemo)(()=>aL(n.text,n.source,i,{stripAgentPart:o,placeholders:!0,searchKeywords:n.searchKeywords}),[o,n.text,n.source,i,n.searchKeywords]);return n.source==="gpt"&&!o?null:(0,go.jsxs)("div",{className:a.root,onMouseEnter:()=>s(Sr(e)),children:[(0,go.jsx)(oe,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:t,onClick:lL,children:(0,go.jsx)(En,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:u})}),t&&r&&(0,go.jsx)("div",{className:a.actions,children:(0,go.jsx)(qc,{onFeedback:()=>r(n),suggestion:n.text})})]})},A1=uL;var Jg=S(w()),cL=({onFeedback:e,suggestions:t,selectedIndex:n,reverse:r})=>{let o=(0,id.useMemo)(()=>{let i=t.map((s,a)=>(0,Jg.jsx)(A1,{index:a,selected:a===n,suggestion:s,onFeedback:e},`${s.text}-${s.source}`));return r?i.reverse():i},[t,n,r]);return(0,Jg.jsx)(id.Fragment,{children:o})},sd=cL;var O1={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var Oa=S(w()),dL=({textSuggestions:e,selectedIndex:t})=>{let n=(0,ad.useRef)(null),r=k("InlineSuggestionsOverlay",O1),o=I(Di),i=z(),s=I(pt),a=I(gi),l=I(td),u=N("showTextSuggestions");return wi(()=>{i(Er({collapse:!0,skipWhenInputFocus:!0}))}),(0,ad.useEffect)(()=>{let c=n.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let p=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-p.right,0)}px`}),l||!o||!u||e.length===0||s!==!0||a===!1?null:(0,Oa.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,Oa.jsx)("div",{ref:n,className:r.paper,children:(0,Oa.jsx)(St,{children:(0,Oa.jsx)(sd,{suggestions:e,selectedIndex:t})})})})},pL=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),N1=Sn(pL)(dL);var ud=S($()),ji=S(O());var M1=S(O());function D1(e,t){let[n,r]=(0,M1.useState)(()=>{if(typeof window>"u")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return H.error(i),t}});return[n,i=>{try{let s=i instanceof Function?i(n):i;r(s),typeof window<"u"&&window.localStorage.setItem(e,JSON.stringify(s))}catch(s){H.error(s)}}]}var j1=S($()),Mn=S(O());var eh={};ke(eh,{enUS:()=>fL,nlNL:()=>mL});var fL={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"}]}]},mL={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 F1={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var Tr=S(w()),th=(e,t,n)=>r=>(0,Tr.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),gL=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=B(eh),s=It(),a=k("Login",F1),l=N("productName"),u=(0,Mn.useCallback)(m=>{m.preventDefault(),r&&r(parseInt(m.target.value,10))},[]),c=(0,Mn.useCallback)(m=>{m.preventDefault(),s.send(Li,!0)},[t]),p=(0,Mn.useMemo)(()=>m=>(0,Tr.jsx)("a",{onClick:f=>{f.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:m},"login"),[t]),d=(0,Mn.useCallback)(m=>(0,Tr.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:m},"prompt"),[c]),{min:h,hour:v,day:y}=(0,Mn.useMemo)(()=>({min:th(a,60*10,u),hour:th(a,60*60,u),day:th(a,60*60*12,u)}),[]);return(0,Tr.jsxs)("div",{className:(0,j1.default)(e,a.root),children:[i("loginPlease",{login:n?d:p,productName:l}),r&&(0,Tr.jsxs)(Mn.Fragment,{children:[(0,Tr.jsx)("br",{}),i("snooze",{min:h,hour:v,day:y})]})]})},ld=gL;var B1={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var Na=S(w()),hL=({title:e})=>{let t=k("SearchTrigger",B1),n=z();return(0,Na.jsxs)("button",{type:"button",className:t.root,onClick:()=>n($e(!0)),children:[(0,Na.jsx)(Ti,{}),(0,Na.jsx)("span",{className:t.text,children:e})]})},H1=hL;var nh={};ke(nh,{enUS:()=>yL,nlNL:()=>vL});var yL={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"}]},vL={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 U1={root:"_root_onpov_1",isInline:"_isInline_onpov_14",toggleButton:"_toggleButton_onpov_21",toggleButtonWrapper:"_toggleButtonWrapper_onpov_25",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_onpov_32",isCollapsed:"_isCollapsed_onpov_36",collapsible:"_collapsible_onpov_36",hints:"_hints_onpov_44",hintsHidden:"_hintsHidden_onpov_51",triggers:"_triggers_onpov_56",triggersRight:"_triggersRight_onpov_71"};var ue=S(w()),SL=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=k("SuggestionsOverlay",U1),o=B(nh),i=I(Di),s=Xx(),a=z(),l=(0,ji.useRef)(null),u=N("searchTriggerKey"),c=N("productName"),p=I(td),d=I(pt),h=I(gi),[v,y]=(0,ji.useState)(null),m=N("showSearch"),g=N("showTextSuggestions"),f=N("adminUrl"),x=N("isEmbedded"),[_,b]=D1("dd-snooze-until-ms",0),E=p||_>Date.now(),C=I(j=>j.input.text),R=e.filter(j=>j.source!=="gpt").length,P=()=>{E&&b(0),a(Ow(!E))},V=j=>{a(He({name:"suggestion feedback",data:{text:j.text,source:"overlay",context:C},options:{includeConversationData:!0}}))},D=j=>{let we=Date.now()+j*1e3;b(we),H.info(`Snooze until: ${new Date(we)}`),a(Er({collapse:!0}))};return(0,ji.useEffect)(()=>{R===0&&y(null)},[e,R]),wi(()=>{a(Er({collapse:!0,skipWhenInputFocus:!0}))}),d===null||h===!1?null:d===!1?(0,ue.jsxs)("div",{ref:l,className:(0,ud.default)(r.root,{[r.isCollapsed]:E}),children:[!E&&(0,ue.jsxs)("div",{className:r.triggers,children:[(0,ue.jsx)("div",{style:{flex:1}}),(0,ue.jsx)("div",{className:r.triggersRight,children:(0,ue.jsx)(Dr,{className:r.toggleButton,title:o("collapse"),onClick:P,isCollapsed:!1})})]}),(0,ue.jsx)("div",{className:r.toggleButtonWrapper,children:(0,ue.jsx)(Dr,{className:r.toggleButton,title:o("open",{productName:c}),onClick:P,isCollapsed:!0})}),(0,ue.jsx)("div",{className:r.collapsible,children:(0,ue.jsx)(ld,{loginUrl:f,isEmbedded:x,onLogIn:n,onSnooze:D})})]}):!s||!i?null:(0,ue.jsxs)("div",{ref:l,className:(0,ud.default)(r.root,{[r.isCollapsed]:E}),children:[!E&&(0,ue.jsxs)("div",{className:r.triggers,children:[(0,ue.jsx)("div",{style:{flex:1},children:m&&(0,ue.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>y(o(Gc()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>y(null),children:(0,ue.jsx)(H1,{title:o("search")})})}),(0,ue.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,ue.jsx)("div",{className:(0,ud.default)(!v&&r.hintsHidden,r.hints),children:v}),(0,ue.jsx)(Dr,{className:r.toggleButton,title:o("collapse"),onClick:P,isCollapsed:!1})]})]}),(0,ue.jsx)("div",{className:r.toggleButtonWrapper,children:(0,ue.jsx)(Dr,{className:r.toggleButton,title:o("open",{productName:c}),onClick:P,isCollapsed:!0})}),R>0&&g&&(0,ue.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,ue.jsx)(St,{children:(0,ue.jsx)(sd,{onFeedback:V,suggestions:e,selectedIndex:t,reverse:!0})})})]})},xL=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),z1=Sn(xL)(SL);var Ma=S(w()),_L=({children:e})=>{let n=N("locale").replace("-","");return(0,Ma.jsx)(lg.Provider,{value:n,children:e})},wL=({store:e,customStyles:t={},children:n})=>(0,Ma.jsx)(Vm,{store:e,children:(0,Ma.jsx)(_L,{children:(0,Ma.jsx)(qi.Provider,{value:t,children:n})})}),ho=wL;var wd=S($());var jn=S(O());var V1=S(O()),bL=["div","span","mark","strong","b","i","u","em"];function rh(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(bL.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,V1.cloneElement)(r,{children:rh(s,t,n+1)})]}return[...e,...t]}function kr(e){return e.tagName.toLowerCase()==="textarea"}var K1={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var J1=S($());var vd=S(O());function W1(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function cd(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function $1(e){return e!=null}var ih=S($()),Lt=S(O());var dd=S(O()),EL=["bottom","height","left","right","top","width"],CL=(e={},t={})=>EL.some(n=>e[n]!==t[n]),Dn=new Map,q1,G1=()=>{let e=[],t=[];Dn.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();CL(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{Dn.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),q1=window.requestAnimationFrame(G1)};function TL(e,t){return{observe(){let n=Dn.size===0;if(Dn.has(e)){let r=Dn.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else Dn.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&G1()},unobserve(){let n=Dn.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Dn.delete(e),Dn.size||cancelAnimationFrame(q1)}}}}function oh(e){let[t,n]=(0,dd.useState)(null);return(0,dd.useLayoutEffect)(()=>{if(!e.current)return;let r=TL(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var Bi=S(O()),Q1=S(vu());var X1={root:"_root_1jq08_1"};var Y1=({children:e})=>{let[t,n]=(0,Bi.useState)(null),r=(0,Bi.useContext)(qi);return(0,Bi.useLayoutEffect)(()=>{let o=document.createElement("div");return oo(o),o.classList.add(X1.root),r!=null&&r.portalRootNode&&o.classList.add(r==null?void 0:r.portalRootNode),document.body.appendChild(o),n(o),()=>{o.isConnected&&document.body.removeChild(o)}},[]),t?(0,Q1.createPortal)(e,t):null};var ln={ref:"_ref_1rcyi_1",root:"_root_1rcyi_7",positionAbove:"_positionAbove_1rcyi_13",positionBelow:"_positionBelow_1rcyi_17",positionLeft:"_positionLeft_1rcyi_21",positionRight:"_positionRight_1rcyi_25",alignStart:"_alignStart_1rcyi_29",alignCenter:"_alignCenter_1rcyi_34",alignEnd:"_alignEnd_1rcyi_40"};var pd=S(w()),fd=(e=!1)=>{let[t,n]=(0,Lt.useState)(e),r=(0,Lt.useCallback)(()=>n(!0),[]),o=(0,Lt.useCallback)(()=>n(!1),[]),i=(0,Lt.useCallback)(()=>n(a=>!a),[]),s=(0,Lt.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function sh(e,t=null,n=0){if(!e)return{display:"none"};let r=t?e.top-t.top<0||e.top<t.top-n?t.top-n:e.top+e.height>t.top+t.height+n?t.top+t.height+n-e.height:e.top:e.top,o=t?e.left<t.left-n?t.left-n:e.left+e.width>t.left+t.width+n?t.left+t.width+n-e.width:e.left:e.left;return{top:r,left:o,height:e.height,width:e.width}}var md=({className:e,triggerRef:t,boundaryRef:n=(0,Lt.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=sh,...a})=>{let l=oh(t),u=oh(n),c=(0,Lt.useMemo)(()=>s(l,u,0),[l,u]);return(0,pd.jsx)(Y1,{children:(0,pd.jsx)("div",{className:(0,ih.default)(ln.ref,{[ln.positionAbove]:r==="above",[ln.positionBelow]:r==="below",[ln.positionLeft]:r==="left",[ln.positionRight]:r==="right",[ln.alignStart]:o==="start",[ln.alignCenter]:o==="center",[ln.alignEnd]:o==="end"}),style:c,...a,role:"dialog",children:(0,pd.jsx)("div",{className:(0,ih.default)(e,ln.root),children:i})})})};var Z1=S($()),gd=S(O());var ah=S(w()),hd=(0,gd.forwardRef)(({className:e,children:t,...n},r)=>{let o=(0,gd.useRef)(null),i=k("TabCompletion",Cn);return(0,ah.jsx)("div",{ref:cd([o,r]),className:(0,Z1.default)(e,i.popoverContentContainer),...n,children:(0,ah.jsx)("div",{className:i.popoverContent,children:t})})});var Pr=S(w()),kL=e=>t=>{let n=sh(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},PL=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=k("TabCompletion",Cn),s=fd(),a=(0,vd.useMemo)(()=>kL(e.getBoundingClientRect()),[e]),[l,u]=Dc(e);return(0,vd.useEffect)(()=>{u?s.open():s.close()},[u]),(0,Pr.jsxs)("span",{children:[(0,Pr.jsx)("mark",{ref:cd([l,s.triggerRef]),className:(0,J1.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,Pr.jsx)(md,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,Pr.jsx)(hd,{style:n,children:(0,Pr.jsx)("div",{className:i.hintText,children:o})})})]})},yd=class extends wn{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(t,n){return n.keywordMatches&&n.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=n.keywordMatches.map(r=>({...r,keywordRegex:new RegExp(`\\b${W1(r.keyword)}\\b`,"i")})),this.keywordMatches=n.keywordMatches),this.usedKeywordMatches.clear(),t}match(t){let n=this.preparedKeywordMatches.map(o=>{if(this.usedKeywordMatches.has(o))return null;let i=t.match(o.keywordRegex);if(!i)return null;let s=t.charAt(i.index-1),a=t.charAt(i.index+o.keyword.length);return s==="{"&&a==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:o.suggestion,preparedKeywordMatch:o,valid:!0}}).filter($1);if(n.length===0)return null;let r=n.reduce((o,i)=>i.index<o.index?i:o);return this.usedKeywordMatches.add(r.preparedKeywordMatch),r}replaceWith(t,n){return(0,Pr.jsx)(PL,{inputElement:n.inputElement,suggestion:n.suggestion,inputStyle:n.inputStyle,boundaryRef:n.boundaryRef,children:t},`keyword_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var xd=S($());var Qe=S(O());var lh=S(w()),eb=()=>(0,lh.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,lh.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 Rr=S(O());var nb=S(qg());var tb={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Sd(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{return null}}function uh(e){return e.replace("https://www.","").replace("https://","")}var At=S(w()),RL=3,IL=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),LL=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=RL})=>{let i=k("LinkSearch",tb),[s,a]=(0,Rr.useState)(""),l=z(),u=I(vw("url")),c=I(aw("URL",IL)),[p,d]=(0,Rr.useState)(c.length-1),h=N("fallbackImage"),v=f=>{let x=f.target;a(x.value)},y=(f,x)=>{f.stopPropagation(),f.preventDefault(),window.open(x,"_blank")},m=f=>{var b;let x=p-1<0?c.length-1:p-1,_=p+1===c.length?0:p+1;f.code==="Escape"&&(a(""),t()),f.code==="ArrowUp"&&d(x),f.code==="ArrowDown"&&d(_),f.code==="Enter"&&e(((b=c[p])==null?void 0:b.text)||s)},g=(0,Rr.useCallback)((0,nb.default)(f=>{l(co({query:f,type:"URL",tags:["link-search"]}))},300),[]);return(0,Rr.useEffect)(()=>{s&&g(s)},[s]),(0,Rr.useEffect)(()=>()=>{l(Qc())},[]),(0,At.jsxs)("div",{className:i.root,children:[(0,At.jsx)(St,{withDivider:!0,children:(s?c:u).slice(0,o).map((f,x)=>(0,At.jsx)(oe,{selected:p===x,onClick:()=>e(f.text),"data-testid":"linksearch-suggestion",children:(0,At.jsxs)(ge,{children:[(0,At.jsx)(ge.Image,{src:Sd(f,"small",h||void 0),title:f.title||f.text}),(0,At.jsxs)(ge.Content,{className:i.content,cropText:!0,children:[(0,At.jsx)(ge.Title,{children:f.title||uh(f.text)}),f.title&&uh(f.text)]}),(0,At.jsx)(oe.Actions,{children:(0,At.jsx)(oe.ActionButton,{label:r,onClick:_=>y(_,f.text)})})]})},f.text))}),(0,At.jsx)(ka,{value:s,onChange:v,autoFocus:!0,placeholder:n,onKeyUp:m})]})},rb=LL;var ch={};ke(ch,{enUS:()=>AL,nlNL:()=>OL});var AL={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},OL={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var Xe=S(w()),NL=(0,Qe.forwardRef)((e,t)=>{let n=k("TabCompletion",Cn);return(0,Xe.jsx)("mark",{ref:t,className:(0,xd.default)(n.matchSelection)},"selection-start")}),ML=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=B(ch),s=k("TabCompletion",Cn),a=(0,Qe.useRef)(null),l=(0,Qe.useRef)(null),[u,c]=(0,Qe.useState)(null),p=z(),d=fd(document.activeElement===r),[h]=(0,Qe.useState)(()=>document.createRange());d.triggerRef.current=h,(0,Qe.useEffect)(()=>()=>h.detach(),[]),(0,Qe.useEffect)(()=>{let y=e.current,m=a.current;!y||!m||(h.setStart(y,0),h.setEnd(m,0))},[e.current,a.current]),wi(()=>{d.close()});let v=(0,Qe.useCallback)(y=>{let m=h.toString(),g=/^http(s?):\/\//.test(y)?y:`https://${y}`;p(uc({text:`[${m}](${g})`,replace:"selection"}))},[]);return(0,Xe.jsxs)("span",{children:[(0,Xe.jsx)("mark",{ref:a,className:(0,xd.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,Xe.jsx)(md,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,Xe.jsxs)(hd,{style:n,ref:l,children:[(0,Xe.jsx)("div",{className:(0,xd.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,Xe.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,Xe.jsx)(eb,{}),(0,Xe.jsx)("span",{children:"\xA0"}),(0,Xe.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,Xe.jsx)(rb,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:v,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},_d=class extends wn{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(t,n){return this.props=n,this.charCount=0,this.startRef=(0,Qe.createRef)(),this.foundIndex=0,t}match(t){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[n,r]=this.props.selection;if(n===r)return null;let o=this.foundIndex===0?n:r,i=o>=this.charCount&&o<=this.charCount+t.length?{index:o-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let s=this.foundIndex===1;return i&&s?this.charCount+=o-this.charCount:this.charCount+=t.length,i?{isStart:s,...i}:null}replaceWith(t,n){return n.isStart?(0,Xe.jsx)(NL,{ref:this.startRef}):(0,Xe.jsx)(ML,{inputElement:n.inputElement,startRef:this.startRef,boundaryRef:n.boundaryRef,inputStyle:n.inputStyle})}asTag(){return"mark"}};var Fn=S(w()),DL=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=k("TabCompletion",K1),c=N("insertLink"),p=N("showMidSentenceSuggestions"),d=N("inlineSuggestions"),h=jc(a),v=(0,jn.useRef)(null);(0,jn.useEffect)(()=>{kr(a)&&h&&Bc(a,h)},[h]);let y=(0,jn.useCallback)(f=>{if(!o||!n)return f;let x=[(0,Fn.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,Fn.jsx)("span",{"data-testid":"tab-completion",className:(0,wd.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&x.push((0,Fn.jsx)("span",{className:(0,wd.default)(u.hint,u.resetIndent),children:(0,Fn.jsx)(nl,{keyCode:"tab"},"tabHint")})),rh(f,x)},[o,n,r]),m=(0,jn.useMemo)(()=>{let f=[];return c&&f.push(new _d("selection")),f.push(new xi("placeholders")),i&&f.push(new yd("keywords")),f},[d,c,i]),g=(0,jn.useMemo)(()=>{let f=window.getComputedStyle(a);return{"--dd-color":f.color,"--dd-font-size":f.fontSize,"--dd-font-family":f.fontFamily,"--dd-font-variant":f.fontVariant}},[]);return e?(0,Fn.jsxs)("div",{ref:f=>{f!=null&&f.parentElement&&(v.current=f==null?void 0:f.parentElement)},className:u.root,style:g,children:[(0,Fn.jsx)(En,{tagName:"span",containerTagName:"div",className:(0,wd.default)(u.container,u.agentText),disableLineBreaks:kr(a),content:t||"\u200B",onAfterParse:y,matchers:m,selection:h,keywordMatches:s,inputElement:a,inputStyle:g,boundaryRef:v,inlineSuggestionsOnlyAtEnd:!p}),(0,Fn.jsx)("br",{})]}):null},FL=({input:e,ui:t,settings:n,styleSuggestions:r,conversation:o})=>{var y;let{tabCompletionSuggestion:i}=e,s=(i==null?void 0:i.text)||"",a=(i==null?void 0:i.source)||"",l=e.html??Ei(e.text),u=s.indexOf(e.text)===0?s.slice(e.text.length):"",{showTabHint:c}=t,{isSupported:p}=o,{showTabCompletion:d,visible:h,showStyleSuggestions:v}=n;return{showTabHint:c,showStyleSuggestions:v,showTabCompletion:d,content:l,tabText:u,source:a,keywordMatches:((y=r.list)==null?void 0:y.keywordMatches)??[],enabled:h&&p!==!1}},ob=Sn(FL)(DL);var $b=S($()),qb=S(O());var ib={list:[],fetchState:"idle",isInitialRequest:null},ab=e=>e.autoflows.list||[],sb=e=>t=>{var n;return(n=t.list)==null?void 0:n.find(r=>r.triggerPayload===e)},Bn=M("autoflows/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(e)}),dh=M("autoflows/start",async(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");await r.startAutoflowSession(e),await n(Bn(e.platformSessionId))}),ph=M("autoflows/stop",async(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");await r.stopAutoflowSession(e.platformSessionId),await n(Bn(e.platformSessionId))}),jL=U({name:"autoflows",initialState:ib,reducers:{},extraReducers:e=>{e.addCase(dh.pending,(t,n)=>{let r=sb(n.meta.arg.triggerPayload)(t);r.state="Started",r.isBusy=!0}),e.addCase(ph.pending,(t,n)=>{let r=sb(n.meta.arg.triggerPayload)(t);r.state="Aborted",r.isBusy=!0}),e.addCase(Bn.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}),e.addCase(Bn.rejected,t=>{t.fetchState="error"}),e.addCase(Bn.fulfilled,(t,n)=>{t.list=n.payload,t.fetchState="done"}),e.addCase(J,()=>ib)}}),lb=M("autoflows/openStream",(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");let o=r.openStream(e);o.on("sessionAborted",()=>{n(Bn(e))}),o.on("sessionCompleted",()=>{n(Bn(e))})}),ub=M("autoflows/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),cb=jL.reducer;var db={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},pb=e=>e.customMessages.list,fb=e=>t=>!!t.customMessages.sentSuggestions.find(n=>n===e),mb=e=>t=>!!t.customMessages.answeredSuggestions.find(n=>n===e),gb=e=>t=>!!t.customMessages.errorSuggestions.find(n=>n===e),Da=M("customMessages/getAll",async(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(e)}),bd=M("customMessages/send",async(e,t)=>{let{platformSessionId:n,suggestion:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");await o.sendCustomMessage(n,r)}),Ed=M("customMessages/answer",async(e,t)=>{let{platformSessionId:n,reply:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");await o.answerCustomMessage(n,r)}),hb=U({name:"customMessages",initialState:db,reducers:{onCustomMessage(e,t){Array.isArray(t.payload)?e.list=t.payload:e.list=[t.payload]}},extraReducers:e=>{e.addCase(Da.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}).addCase(Da.rejected,t=>{t.fetchState="error"}).addCase(Da.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload||[]}).addCase(bd.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.errorSuggestions=t.errorSuggestions.filter(r=>n.meta.arg.suggestion.text!==r)}).addCase(bd.rejected,(t,n)=>{let r=t.sentSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1))}).addCase(Ed.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(Ed.rejected,(t,n)=>{let r=t.answeredSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1)),t.answeredSuggestions.splice(r,1)}).addCase(J,()=>db)}}),yb=M("customMessages/openStream",(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");r.openStream(e).on("customMessageSuggestion",i=>{n(hb.actions.onCustomMessage(i))})}),vb=M("customMessages/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),Sb=hb.reducer;var BL={token:null,accountUrl:null,interval:null},xb=e=>t=>{let{passwordlessToken:{token:n,accountUrl:r}}=t;return n&&r?`${r}/apis/admin/session/passwordless/login/?token=${n}&redirect=${e}`:null},fh=M("passwordlessToken/getTemporaryPasswordlessToken",async(e,t)=>{let{deepdeskAPI:n}=t.extra,r=await n.requestPasswordlessToken();return{accountUrl:n.client.baseUrl,token:r}}),mh=M("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(fh()),setInterval(()=>r(fh()),n)}),_b=U({name:"passwordlessToken",initialState:BL,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(fh.fulfilled,(t,n)=>{t.token=n.payload.token,t.accountUrl=n.payload.accountUrl}),e.addCase(mh.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:wb}=_b.actions,bb=_b.reducer;function Eb(e){let{customMessages:t,autoflows:n}=e;return n.fetchState==="loading"&&n.isInitialRequest===!0||t.fetchState==="loading"&&t.isInitialRequest===!0}var Ob=S(O());var Ib=S($()),Lb=S(O());var Tb=S($());var Cb={root:"_root_838fd_1"};var Pb=S(w()),HL=({className:e,children:t})=>{let n=k("Unicode",Cb);return(0,Pb.jsx)("span",{className:(0,Tb.default)(e,n.root),children:t})},kb=HL;var Rb={isDisabled:"_isDisabled_1rmfm_1",buttonStart:"_buttonStart_1rmfm_5",root:"_root_1rmfm_8",buttonStop:"_buttonStop_1rmfm_8",stateBadge:"_stateBadge_1rmfm_19",isCompleted:"_isCompleted_1rmfm_26",isStarted:"_isStarted_1rmfm_30",isAborted:"_isAborted_1rmfm_34"};var gh={};ke(gh,{enUS:()=>UL,nlNL:()=>zL});var UL={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]},zL={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]};var ft=S(w()),KL=({disabled:e,state:t,displayName:n,description:r,onStartAutoflow:o,onStopAutoflow:i})=>{let s=k("Autoflow",Rb),a=B(gh),l=t==="Started"?"stop":"start",u=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,ft.jsxs)(oe,{className:(0,Ib.default)(s.root,{[s.isDisabled]:e,[s.isCompleted]:t==="Completed",[s.isAborted]:t==="Aborted",[s.isStarted]:t==="Started"}),children:[(0,ft.jsx)(ge,{children:(0,ft.jsxs)(ge.Content,{children:[(0,ft.jsxs)(ge.Title,{children:[t&&(0,ft.jsx)("span",{className:s.stateBadge,children:a(t)}),n]}),(0,ft.jsx)("span",{children:r})]})}),(0,ft.jsx)(oe.Actions,{fixed:t==="Started",children:(0,ft.jsx)(oe.ActionButton,{primary:!0,className:l==="start"?s.buttonStart:s.buttonStop,onClick:t==="Started"?i:o,disabled:e,label:(0,ft.jsxs)(Lb.Fragment,{children:[(0,ft.jsx)(kb,{children:u})," ",(0,ft.jsx)("span",{children:a(l)})]})})})]})},Ab=KL;var hh=S(w()),WL=(e,t)=>{let n=t.filter(r=>r.state==="Started");return n.length>0?n.indexOf(e)===-1:!1},$L=({autoflows:e,onStartAutoflow:t,onStopAutoflow:n,platformSessionId:r})=>(0,hh.jsx)(Ob.Fragment,{children:e.map(o=>(0,hh.jsx)(Ab,{displayName:o.displayName,description:o.description,disabled:o.isBusy||WL(o,e),state:o.state,onStartAutoflow:()=>t({platformSessionId:r,triggerPayload:o.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:r,triggerPayload:o.triggerPayload})},o.displayName))}),qL=({autoflows:e,conversation:t})=>{var n;return{autoflows:e.list,platformSessionId:(n=t.current)==null?void 0:n.sessionId}},GL={onStartAutoflow:dh,onStopAutoflow:ph},Nb=Sn(qL,GL)($L);var Cd=S(O());var Sh=S($());var yh=S(w()),vh=()=>(0,yh.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,yh.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 Mb={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};var un=S(w()),XL=({entities:e})=>{let t=k("EntitiesWidgetList",Mb),[n,r]=(0,Cd.useState)(void 0),o=z(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),Ra(a.text),o(He({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Cd.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,un.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,un.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,un.jsx)("span",{className:t.entityText,children:a.text}),(0,un.jsxs)("span",{className:t.iconWrapper,children:[(0,un.jsx)("span",{className:(0,Sh.default)(t.icon),children:(0,un.jsx)(vh,{})}),(0,un.jsx)("span",{className:(0,Sh.default)(t.icon,n===l&&t.iconClicked),children:(0,un.jsx)(vh,{})})]})]},a.text))})},Db=XL;var Fb=S($()),xh=S(O());var Hn={root:"_root_1e6ej_1",title:"_title_1e6ej_8",isUsed:"_isUsed_1e6ej_13",quickReplies:"_quickReplies_1e6ej_22",quickReply:"_quickReply_1e6ej_29",hasError:"_hasError_1e6ej_39",label:"_label_1e6ej_43",errorIcon:"_errorIcon_1e6ej_48"};var ot=S(w()),QL=({suggestion:e})=>{let t=B(lo),n=z(),r=I(fb(e.text)),o=I(mb(e.text)),i=I(gb(e.text)),s=I(tc),{replyOptions:a}=e,l=(0,xh.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),!(r||!s)&&n(bd({platformSessionId:s,suggestion:e}))},[e,r,n,s]),u=(0,xh.useCallback)(c=>{if(c.preventDefault(),c.stopPropagation(),!s||!a)return;let p=parseInt(c.target.dataset.index,10),d=a[p];n(Ed({platformSessionId:s,reply:d,suggestion:e}))},[e,r,n,s]);return(0,ot.jsxs)(oe,{onClick:l,className:(0,Fb.default)(Hn.root,{[Hn.isUsed]:r,[Hn.hasError]:i}),children:[(0,ot.jsx)(ge,{children:(0,ot.jsxs)(ge.Content,{children:[(0,ot.jsxs)(ge.Title,{className:Hn.title,children:[e.text," ",(0,ot.jsx)(rl,{className:Hn.label,children:"analyse tool"})," ",i&&(0,ot.jsx)("span",{className:Hn.errorIcon,role:"img","aria-label":t("sendingError"),title:t("sendingError"),children:"!"})]}),a&&a.length>0&&(0,ot.jsx)("ul",{className:Hn.quickReplies,children:a.map(c=>(0,ot.jsx)("li",{className:Hn.quickReply,children:c.title},c.title))})]})}),(0,ot.jsxs)(oe.Actions,{fixed:i||r,children:[a&&a.length>0&&(0,ot.jsx)(oe.DropdownButton,{label:t("answer"),disabled:o,children:a.map((c,p)=>(0,ot.jsx)(oe.DropdownItem,{index:p,label:c.title,onClick:u},c.title))}),(0,ot.jsx)(oe.ActionButton,{primary:!0,disabled:r,onClick:l,label:t(r?"suggestionSent":i?"tryAgain":"sendSuggestion")})]})]})},jb=QL;var _h=S(w()),Bb=()=>(0,_h.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,_h.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 Hb=S(O());var mt=S(w()),YL=({suggestion:e,lines:t,onEdit:n,onUse:r})=>{var d;let o=e.text||e.url||e.message,i=Yc(o),s=B(lo),a=N("showImages"),l=N("fallbackImage"),u=h=>{h.preventDefault(),h.stopPropagation(),r(o)},c=h=>{h.preventDefault(),h.stopPropagation(),n(e)},p=(0,Hb.useCallback)(h=>{window.open(i,"_blank"),h.stopPropagation(),h.preventDefault()},[i]);return(0,mt.jsxs)(oe,{onClick:u,"data-testid":"edit-suggestion",children:[(0,mt.jsxs)(ge,{children:[a&&e.image&&(0,mt.jsx)(ge.Image,{src:Sd(e,"small",l||void 0),title:e.title}),(0,mt.jsxs)(ge.Content,{children:[e.title&&(0,mt.jsx)(ge.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((d=e.searchKeywords)==null?void 0:d.length)>0&&(0,mt.jsx)(oe.Labels,{labels:e.searchKeywords}),(0,mt.jsx)(ge.Content,{cropText:t==="single",lineClamp:t==="multiple",children:o})]})]}),(0,mt.jsxs)(oe.Actions,{children:[i&&(0,mt.jsx)(oe.ActionButton,{onClick:p,label:s("visitUrl")}),(0,mt.jsx)(oe.ActionButton,{primary:!0,onClick:c,label:s("preview")}),(0,mt.jsx)(oe.ActionButton,{primary:!0,onClick:u,label:s("useSuggestion")})]})]})},Ub=YL;var Fa=S(w()),ZL=({contentType:e,lines:t,suggestions:n})=>{let r=It(),o=I(Pi),i=a=>{r.send(Ug,{state:o,suggestion:a,contentType:e})},s=(a,l)=>{r.send(An,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,Fa.jsx)(Fa.Fragment,{children:n.map(a=>(0,Fa.jsx)(Ub,{suggestion:a,lines:t,onEdit:l=>i(l),onUse:l=>s(l,a)},a.text||a.url||a.message))})},zb=ZL;var wh={};ke(wh,{enUS:()=>JL,nlNL:()=>eA});var JL={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},eA={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Vb={root:"_root_x0pwe_1",loginText:"_loginText_x0pwe_7",stateText:"_stateText_x0pwe_8",sectionList:"_sectionList_x0pwe_20",shortcutList:"_shortcutList_x0pwe_24",shortcut:"_shortcut_x0pwe_24",link:"_link_x0pwe_52"};var bh=S(w()),Kb=()=>(0,bh.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,bh.jsx)("path",{d:"M543-340q16.595 0 28.798-12.202Q584-364.405 584-381t-12.202-28.798Q559.595-422 543-422t-28.798 12.202Q502-397.595 502-381t12.202 28.798Q526.405-340 543-340Zm-25-126h47q2-29 8.5-43t32.5-39q27-26 37.5-45.395Q654-612.79 654-639q0-45.882-31.5-74.941Q591-743 540-743q-38 0-68 20.5T428-665l45 19q11-25 27.5-38t39.5-13q29.778 0 48.389 17Q607-663 607-637q0 20-9 35t-32 32q-32 29-40 46.5t-8 57.5ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-620h60v620h620v60H140Zm120-740v560-560Z"})});var Eh=S(w()),Wb=()=>(0,Eh.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Eh.jsx)("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});var K=S(w()),Td=(e,t)=>{let n=I(pt);(0,qb.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},tA=({onLogIn:e})=>{let t=B(wh),n=z(),r=N("isEmbedded"),o=k("Widget",Vb),i=N("showAutoflows"),s=N("showCustomMessages"),a=N("showSummaryCommand"),l=N("showKnowledgeSearch"),u=N("showSearch"),c=I(Ni),p=I(od),d=I(ab),h=I(rd),v=I(pb),y=I(nc),m=I(gi),g=I(pt),f=I(tc),x=I(Eb),_=I(Pi),b=It(),E=I(xw),C=I(xb("/admin/")),R=N("adminUrl"),P=N("productName");if(Td(()=>(n(Da(f)),n(yb(f)),()=>{n(vb(f))}),[n,m,s,f]),Td(()=>(n(Bn(f)),n(lb(f)),()=>{n(ub(f))}),[n,m,i,f]),Td(()=>{p.forEach(({type:D})=>{n(D==="entities"?Wt():Rn(D))})},[n,m,y,c]),Td(()=>(n(mh()),()=>{n(wb())}),[n]),m===!1)return(0,K.jsx)("div",{className:o.stateText,children:(0,K.jsx)("div",{children:(0,K.jsx)("p",{children:t("notSupported")})})},"supported");if(g===!1)return(0,K.jsx)("div",{className:o.loginText,children:(0,K.jsx)("div",{children:(0,K.jsx)(ld,{isEmbedded:r,loginUrl:R,onLogIn:e})})},"login");if(!c||!f||g===null||E||x)return(0,K.jsx)("div",{className:o.stateText,children:(0,K.jsx)("div",{children:(0,K.jsx)("p",{children:t("waiting")})})},"waiting");let V=u||a||l||C;return(0,K.jsx)("div",{className:(0,$b.default)(o.root),"data-testid":"widget",children:(0,K.jsxs)(ol,{className:o.sectionList,children:[V&&(0,K.jsx)(Kn,{title:t("actions"),type:"shortcuts",children:(0,K.jsxs)("div",{className:o.shortcutList,children:[u&&(0,K.jsxs)("button",{className:o.shortcut,"data-testid":"shortcut-search",onClick:()=>b.send("ShowCommandPalette",{isOpen:!0}),children:[(0,K.jsx)(Ti,{}),t("linkSearch")]}),a&&(0,K.jsxs)("button",{className:o.shortcut,"data-testid":"shortcut-summary",onClick:()=>b.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,K.jsx)(Wb,{}),t("linkSummary")]}),l&&(0,K.jsxs)("button",{className:o.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>b.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,K.jsx)(Kb,{}),t("linkKnowledgeSearch")]}),C&&(0,K.jsxs)("a",{className:o.shortcut,target:"_blank",href:C,"data-testid":"shortcut-studio-login",rel:"noreferrer",children:[(0,K.jsx)(Bb,{}),t("linkStudioLogin",{productName:P})]})]})}),s&&v.length>0&&(0,K.jsx)(Kn,{type:"custom-messages","data-testid":"custom-messages",children:(0,K.jsx)(St,{withDivider:!0,children:v.map(D=>(0,K.jsx)(jb,{suggestion:D},D.text))})}),i&&d.length>0&&(0,K.jsx)(Kn,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:(0,K.jsx)(St,{withDivider:!0,children:(0,K.jsx)(Nb,{})})}),p.map(({type:D,title:j,amount:we,lines:zn})=>{var it;switch(D){case"entities":return h&&h.length>0&&(0,K.jsx)(Kn,{type:D,title:j,"data-testid":`type-${D}`,children:(0,K.jsx)(Db,{entities:h})},D);default:return((it=_[D])==null?void 0:it.fetchState)==="done"&&_[D].suggestions.length>0&&(0,K.jsx)(Kn,{type:D,title:j,"data-testid":`type-${D}`,children:(0,K.jsx)(St,{withDivider:!0,children:(0,K.jsx)(zb,{lines:zn,contentType:D,suggestions:_[D].suggestions.slice(0,we)||[]})})},D)}})]})})},Gb=tA;function Hi(e){let t=new Range;return t.selectNodeContents(e),t}function Xb(e,t,n){try{return Ir(e,t,n),!0}catch{return!1}}function kd(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function Pd(e){return"tagName"in e&&e.tagName==="BR"}var ja=/[\u200B-\u200D\uFEFF]/g;function Ir(e,t,n){let r=new Range;if(e.firstChild===null&&t===0&&n===0)return r.selectNodeContents(e),r;let o=0,i=!1;function s(l,u){let c=-1,p=/[\u200B-\u200D\uFEFF]/;if(!p.test(l))return u;for(let d=0;d<=l.length;d++)if(p.test(l[d])||c++,c===u)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let u=l.textContent,c=u.replace(ja,""),p=o+c.length,d=t>=o&&t<=p,h=n>=o&&n<=p;if(d){let v=s(u,t-o);v===0&&!h?r.setStartBefore(l):r.setStart(l,v)}h&&(r.setEnd(l,s(u,n-o)),i=!0),o=p;break}case Node.ELEMENT_NODE:{if(Pd(l)&&(o===t&&r.setStartBefore(l),o++,o===n)){r.setEndAfter(l),i=!0;return}for(let c=0;c<l.childNodes.length&&(a(l.childNodes[c]),!i);c++);let u=l.lastChild;kd(l)&&u&&!kd(u)&&!Pd(u)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function Ba(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a,l,u=0;function c(p){let d=p===n,h=p===o;switch(p.nodeType){case Node.TEXT_NODE:{let v=p.textContent;d&&(a=u+v.substring(0,r).replace(ja,"").length),h&&(l=u+v.substring(0,i).replace(ja,"").length),u+=v.replace(ja,"").length;break}case Node.ELEMENT_NODE:{let v=p.nextSibling===null;Pd(p)&&!v&&u++;for(let y=0;y<p.childNodes.length;y++){let m=d&&y===r,g=h&&y===i;if(m&&(a=u),g&&(l=u),l!==void 0||((!m||!s)&&c(p.childNodes[y]),h&&y===i-1&&(l=u),l!==void 0))break}!h&&kd(p)&&!v&&u++,h&&(l=u);break}default:break}}if(c(e),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function Ha(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}=t,s=-1,a="";function l(u){let c=u===n,p=u===o;switch(c&&s++,u.nodeType){case Node.TEXT_NODE:{if(s!==0)return;let d=c?r:0,h=p?i:void 0,v=u.textContent.replace(ja,"");d===0&&h===void 0?a+=v:a+=v.substring(d,h);break}case Node.ELEMENT_NODE:{let d=u.nextSibling===null;s===0&&Pd(u)&&!d&&(a+=`
|
|
20
20
|
`);for(let h=c?r:0;h<(p?Math.min(i,u.childNodes.length):u.childNodes.length)&&(l(u.childNodes[h]),s!==1);h++);!p&&s===0&&kd(u)&&!d&&(a+=`
|
|
21
21
|
`);break}default:break}p&&s++}return l(e),a}function Qb(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var yo=class extends Tn{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let t=new Range;return t.selectNodeContents(this.element),Ha(this.element,t)}getHTML(){return this.element.innerHTML||""}getRange(){var i;let t=this.getRootNode();if(t.activeElement!==this.element)return null;let n="getSelection"in t?t.getSelection():window.getSelection();if(!n)return null;let r="getComposedRanges"in n&&t instanceof ShadowRoot?(i=n.getComposedRanges(t))==null?void 0:i[0]:n.rangeCount>0?n.getRangeAt(0):null;if(!r)return null;let o=this.element.ownerDocument.createRange();return o.setStart(r==null?void 0:r.startContainer,r==null?void 0:r.startOffset),o.setEnd(r==null?void 0:r.endContainer,r==null?void 0:r.endOffset),!o||!this.element.contains(o.startContainer)||!this.element.contains(o.endContainer)?null:o}getCaretPosition(){let t=this.getRange();if(!t||!t.collapsed||!("getBoundingClientRect"in t))return null;let n=t.getBoundingClientRect();return!Qb(n)&&(t.insertNode(this.element.ownerDocument.createTextNode("\u2060")),n=t.getBoundingClientRect(),t.deleteContents(),!Qb(n))?null:{top:n.top+n.height,left:n.left}}getSelection(){let t=this.getRange();if(t)return Ba(this.element,t);let n=this.lastKnownSelection;if(n&&Xb(this.element,n.start,n.end))return n;let r=Hi(this.element);return r.collapse(!1),Ba(this.element,r)}getSelectedText(){let{start:t,end:n}=this.getSelection();return Ha(this.element,Ir(this.element,t,n))}applyChanges(t){var o;if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),r=t(this.element);return(o=this.observer)==null||o.takeRecords(),Promise.resolve(r).then(()=>{this.currentText=this.getText(),n!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let t=this.element.isContentEditable,n=new MutationObserver(()=>{this.element.isContentEditable!==t&&(t=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>n.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};function Yb(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}var Ch=class{constructor(t){this.name=t;this.broadcastChannel=new BroadcastChannel(t)}broadcastChannel;disposeHandlers=[];onMessage(t){this.broadcastChannel.addEventListener("message",t),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",t)})}postMessage(t){this.broadcastChannel.postMessage(t)}close(){this.disposeHandlers.forEach(t=>t()),this.broadcastChannel.close()}},Th=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.iframe=Yb(t,`${this.targetOrigin}/v2/widget/liveengage/channel.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];onMessage(t){window.addEventListener("message",t),this.disposeHandlers.push(()=>{window.removeEventListener("message",t)})}postMessage(t){var n;(n=this.iframe.contentWindow)==null||n.postMessage(t,this.targetOrigin)}close(){var t;this.disposeHandlers.forEach(n=>n()),(t=this.iframe)==null||t.remove()}},kh=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(t){this.sessionId!==t&&(this.cleanup(),H.info("Set sessionId",t),this.sessionId=t,this.channel=this.createChannel(t))}createChannel(t){let n=this.params.createCustomChannel?this.params.createCustomChannel(t):this.isCrossOrigin?new Th(t,this.deepdeskUrl,{debug:!0}):new Ch(t),r=o=>{var i,s;o.origin===this.deepdeskUrl&&o.data.type==="event"&&o.data.channel===t&&(H.info("Received broadcast event",this.sessionId,o),(s=(i=this.eventMap)[o.data.name])==null||s.call(i,o.data.payload))};return n.onMessage(r),n}send(t,n){var i,s;H.info("broadcast event",{sessionId:this.sessionId,name:t,payload:n});let r={type:"event",name:t,payload:n};(s=(i=this.eventMap)[t])==null||s.call(i,n);let o=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;o==null||o.postMessage({...r,channel:this.sessionId})}cleanup(t=!1){var n,r;(n=this.channel)==null||n.close(),delete this.channel,t&&((r=this.defaultChannel)==null||r.close(),delete this.defaultChannel)}},Zb=kh;var Ui=class extends Error{constructor(n,r){super(n);this.body=r}name="CustomError"};var Ph=e=>new Promise(t=>{setTimeout(t,e)});var zi=class extends Ui{name="ClientError"},Rh=class extends Ui{name="ServerError"},qt=class e{constructor(t="",n={}){this.baseUrl=t;this.options=n;n.fetch&&(this.fetch=n.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;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,{abortLatest:l=!1,attempts:u=1,retryDelay:c=500,refreshTokenOn401:p=!0,retryOnError:d=_=>_ instanceof TypeError,retryOnResponse:h=_=>_.status>=500,version:v="v1",...y}=n,m={credentials:"include",...y,headers:{"Content-Type":"application/json",...y.headers}};n.method!==void 0&&n.method!=="GET"&&this.csrfToken&&(m.headers={...m.headers,"X-CSRFToken":this.csrfToken}),typeof v=="string"&&(m.headers={...m.headers,"X-Deepdesk-API-Version":v});let g=u,f=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&l&&(this.latestRequestByUrl[s].isAborted=!0,this.latestRequestByUrl[s].reject(new Error("Aborted"))),this.latestRequestByUrl[s]=i;let x=async()=>(g--,a(s,m).then(async _=>h(_)&&!i.isAborted&&g>0?(await Ph(c),x()):_.status===401&&p===!0&&f===!1?(f=!0,await this.refreshToken(),x()):_).catch(async _=>{if(d(_)&&!i.isAborted&&g>0)return await Ph(c),x();throw _}));x().then(_=>_.json().catch(()=>null).then(b=>{_.status>=500?o(new Rh("Server Error",b)):_.status===401?o(new zi("Unauthorized",b)):_.status===403?o(new zi("Forbidden",b)):_.status===404?o(new zi("Not Found",b)):_.status>=400&&o(new zi("Bad Request",b)),delete this.latestRequestByUrl[s],r(b)})).catch(_=>{o(_)})})}async validateToken(){let{has_valid_access_token:t}=await this.get("/auth/validate");if(!t)return!1;let{is_logged_in:n}=await this.get("/apis/admin/session/validate/",{version:null});return!!n}refreshToken(){return e.refreshingToken||(e.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{e.refreshingToken=null},1e3*60)})),e.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,{method:"POST",body:JSON.stringify(n),...r})}patch(t,n,r){return this.request(t,{method:"PATCH",body:JSON.stringify(n),...r})}put(t,n,r){return this.request(t,{method:"PUT",body:JSON.stringify(n),...r})}delete(t,n){return this.request(t,{method:"DELETE",...n})}};var nA;(t=>{let e;(l=>(l.SEND_MESSAGE="Send Message",l.HANDLING_TIME="Handling Time",l.START_AUTOFLOW="Start Autoflow",l.ABORT_AUTOFLOW="Abort Autoflow",l.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",l.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(e=t.EventType||={})})(nA||={});function Rd(e){return{...te(e),tags:e.tags}}var Un=class e{constructor(t,n={}){this.options=n;this.client=new qt(t,{fetch:n.fetch}),this.client.patchFetch(r=>async(o,i)=>{let s=await r(o,i);return this.handleDeepdeskVersionHeaders(s),s})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=await this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(e.exchangeTokenPromise||(e.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),e.exchangeTokenPromise):Promise.resolve()}async createConversation(t){await this.preflight(),H.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=await this.client.post("/api/conversations",{...Ce(t),tags:t.tags},{version:"v2"});return Rd(n)}async getProfile(t){let n=await this.client.get(`/apis/admin/profiles/${t}/`,{version:null});return te(n)}async getContentTypes(){let t=await this.client.get("/apis/admin/content-types/",{version:null});return te(t)}async getPlatformConfig(){let{config:t}=await this.client.get("/platform/config/",{version:null});return te(t)}async checkUserExists(t){let{exists:n}=await this.client.get(`/apis/admin/users/exists?external_id=${t}`);return n}async getConversationBySessionId(t,n={}){await this.preflight(),H.info(`Getting conversation for session ${t}`);let{attempts:r=1,retryDelay:o=1e3}=n,i=await this.client.get(`/api/conversations/by_session_id/${t}`,{attempts:r,retryDelay:o,retryOnResponse:s=>s.status===404||s.status>=500,version:"v2"});return Rd(i)}async isConversationSupported(t,n={}){H.info(`Check if conversation for session ${t} is supported`);let{attempts:r=1,retryDelay:o=1e3}=n;return(await this.client.get(`/api/conversations/by_session_id/${t}/active_profile`,{attempts:r,retryDelay:o,retryOnResponse:s=>s.status===404||s.status>=500,version:"v2"})).has_active_profile}async updateConversation(t,n){let r=Ce(n);n.tags&&(r.tags=n.tags);let o=await this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return Rd(o)}async postMessages(t,n){return(await this.client.post(`/api/conversations/${t}/messages`,n.map(o=>({...Ce(o),tags:o.tags})),{version:"v2"})).map(o=>Rd(o))}async sendEvent(t,n){let{data:r,...o}=n,i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((s,[a,l])=>({...s,[a]:l}),{});return this.client.post("/api/events",Ce({...i,...o,data:r,name:t}),{version:"v2"})}async sendEventV1(t,n){let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>({...o,[i]:s}),{});return this.client.post("/api/events",{event:t,data:Ce({...n,...r})})}async getEntities(t){return(await this.client.post("/api/entities",{messages:t.filter(r=>r.text)})).entities}async getSummary(t,n={}){return(await this.client.post("/api/summary",{conversation:{messages:t.filter(o=>o.text&&o.source)},prompt_instruction:n.promptInstruction,model:n.model})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(t){return this.client.post("/apis/admin/session/jwt/",{jwt:t},{version:null}).catch(n=>{throw H.warn(`Invalid token '${t}'`),n})}async authenticateWithKey(t,n){await this.client.post("/apis/admin/session/api-key/",Ce(n),{version:null,refreshTokenOn401:!1,headers:{apikey:t}})}async getTextSuggestions(t,n={},r){return r==="sticky-messages"?this.getPinnedMessages(t):(await this.client.post(`/api/conversations/${t}/recommend/${r}`,Ce(n),{abortLatest:!0})).map(i=>({...te(i),text:i.text||i.url||i.message,source:r,type:r})).filter((i,s,a)=>s===a.findIndex(l=>l.text===i.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(t,n){return(await this.client.post(`/api/conversations/${t}/autocomplete`,Ce(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))}async getPinnedMessages(t){let n=await this.client.get(`/api/conversations/${t}/sticky-messages`,{abortLatest:!0});return te(n).map(r=>({...r,text:r.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(t){let n=await this.client.post("/api/style-suggestions",Ce(t),{abortLatest:!0});return te(n)}async search(t){let n=await this.client.post(`/api/profiles/${t.profile}/search`,Ce(t),{version:"v2"});return te(n)}async knowledgeAssist(t,n,r){let o=await this.client.post(`/api/knowledge-assist/assistants/${r}/search`,Ce({question:t.question,promptInstruction:t.promptInstruction,chatHistory:n.map(i=>({question:i.question,answer:i.answer.answer}))}),{version:"v2"});return te(o)}async requestLoginByEmail(t){let n=await this.client.post("/apis/admin/session/passwordless/request/",{email:t},{version:null});return te(n)}async requestPasswordlessToken(){let t=await this.client.get("/apis/admin/session/passwordless/request/",{version:null});return te(t.token)}async getCsrfToken(){let{token:t}=await this.client.get("/apis/admin/session/csrf/",{version:null});return t}async verifyLoginToken(t){let n=await this.client.post("/apis/admin/session/passwordless/login/",{token:t},{version:null});return te(n)}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(Cy);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&H.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};var Ua=class{constructor(t,n){this.url=t;this.options={timeout:25e3,...n}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(t){this.eventSource.addEventListener(Ng(t),n=>{let{data:r}=n;try{let o=JSON.parse(r);this.emit(t,te(o))}catch{H.warn(`Invalid JSON for ${t}: ${r}`)}})}connect(){clearTimeout(this.timeoutTimer);let t=new EventSource(this.url,{withCredentials:!0});this.eventSource=t;let n=!1;t.onopen=()=>{n=!0},t.onerror=()=>{n&&t.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{t.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(r=>{this.proxyEvent(r)})}disconnect(){var t;clearTimeout(this.timeoutTimer),this.eventListeners={},(t=this.eventSource)==null||t.close()}emit(t,n){this.eventListeners[t]&&this.eventListeners[t].forEach(r=>r(n))}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),this.proxyEvent(t),()=>{this.off(t,n)}}off(t,n){let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}};var rA;(t=>{let e;(i=>(i.Started="Started",i.Aborted="Aborted",i.Completed="Completed"))(e=t.AutoflowSessionState||={})})(rA||={});var za=class{constructor(t,n={}){this.apiUrl=t;this.client=new qt(t,n)}client;streams={};logger=H;async getCustomMessages(t){let n=await this.client.get(`/sessions/${t}/suggestions`);return te(n.suggestions)}async sendCustomMessage(t,n){let r=await this.client.post(`/sessions/${t}/messages`,Ce(n));return te(r)}async answerCustomMessage(t,n){await this.client.post(`/sessions/${t}/answers`,Ce(n))}async getAutoflows(t){let n=await this.client.get(`/sessions/${t}/autoflows`);return te(n.autoflows)}async startAutoflowSession(t){let n=await this.client.post("/autoflow-sessions",Ce(t));return te(n)}async stopAutoflowSession(t){await this.client.delete(`/autoflow-sessions/${t}`)}openStream(t){return this.streams[t]||(this.streams[t]=new Ua(`${this.apiUrl}/sessions/${t}/events`),this.streams[t].connect()),this.streams[t]}closeStream(t){this.streams[t]||(this.streams[t].disconnect(),delete this.streams[t])}};var Jb={startTime:null,stopTime:null},eE=U({name:"handlingTime",initialState:Jb,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(J,()=>Jb)}}),{handlingTimeStart:tE,handlingTimeStop:Id,handlingTimeReset:nE}=eE.actions,rE=eE.reducer;var oE=(e={})=>{let t={onAuthError:Ii(!1),...e};return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var Ld={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var vo=M("styleSuggestions/getAll",async({text:e},t)=>{var s;let{deepdeskAPI:n}=t.extra,r=t.getState(),{showStyleSuggestions:o}=r.settings,i=(s=r.conversation.current)==null?void 0:s.profileCode;if(!o)return Ld.list;if(!i)throw new Error("No current conversation to fetch pinned messages");return n.getStyleSuggestions({profileCode:i,message:e})}),oA=U({name:"styleSuggestions",initialState:Ld,reducers:{},extraReducers:e=>{e.addCase(vo.pending,t=>{t.isInitialRequest=t.isInitialRequest===null,t.fetchState="loading"}).addCase(vo.rejected,t=>{t.fetchState="error"}).addCase(vo.fulfilled,(t,n)=>{t.fetchState="done",yr(t.list,n.payload)||(t.list=n.payload)}).addCase(Jr,t=>{t.list=Ld.list}).addCase(J,()=>Ld)}}),iE=oA.reducer;var sE=(e={})=>{let t,n=!0,r={getStyleSuggestions:vo,debounce:500,...e};return o=>i=>s=>{var h;let a=o.getState().input.text,l=i(s),u=o.getState();if(u.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:c}=u.settings;if(!((h=u.conversation.current)==null?void 0:h.id)||!c)return l;let{text:d}=u.input;return d===a&&!n||(clearTimeout(t),d==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:d}))},e.debounce)),l}};function iA(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var aE=(e={})=>{let t={getTextSuggestions:Rn,getAutocompleteSuggestions:wa,debounce:200,check:Di,...e},n;return r=>o=>i=>{var y;let{input:{userCommitted:s}}=r.getState(),a=o(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:u,showTabCompletion:c}=l.settings,p=(y=l.conversation.current)==null?void 0:y.id,d=i.type===ed.toString();if(!p||!u&&!c)return a;let{input:{userCommitted:h}}=l;return iA(h,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let m=hi(l);m===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(m))},d?0:t.debounce)),a}};var lE=vo.fulfilled.toString();function sA(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 uE=e=>t=>n=>r=>{var u;if(r.type!==lE){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let i=t.getState(),s=i.styleSuggestions.list,a=(u=i.conversation)==null?void 0:u.current;if(o===s)return;let l=sA(o,s);r.type===lE&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var aA=Cu({activeSuggestion:Iw,answer:x1,auth:Vw,autoflows:cb,conversation:qx,contentTypes:o1,customMessages:Sb,passwordlessToken:bb,entities:l1,handlingTime:rE,info:rw,input:Ym.reducer,overlayInput:tt.reducer,settings:jx,profile:b1,search:uw,summary:m1,styleSuggestions:iE,ui:Nw,textSuggestions:Cw});function cE(e){return K0({reducer:aA,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI,deepdeskBrokerAPI:e.deepdeskBrokerAPI}},serializableCheck:!1}),oE(),aE({debounce:200}),sE({debounce:500}),uE(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var lA=e=>{var t;return((t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())??"unknown"},uA=e=>t=>n=>r=>{var a;let o=t.getState(),i=Wm("inlineSuggestions")(o);switch(r.type){case In.toString():{let l=Sw(r.payload.contentType)(t.getState()),u=l.indexOf(r.payload.suggestion);e.emit("edit-suggestion",{contentType:r.payload.contentType,index:u,suggestions:l});break}case Ii.toString():{!r.payload&&e.emit("logout",void 0);break}case Ht.toString():{let{start:l,end:u}=o.input.selection;e.emit("select-suggestion",{type:lA(r.payload.suggestion),...r.payload,replace:r.payload.replace==="selection"?{start:l,end:u}:{start:0,end:u}},{mayApplyChanges:!0});break}case uc.toString():{let{start:l,end:u}=o.input.selection;e.emit("replace",{...r.payload,replace:r.payload.replace==="selection"?{start:l,end:u}:{start:0,end:u}},{mayApplyChanges:!0});break}case oa.toString():{let l=t.getState(),{text:u,selection:c}=l.input.userCommitted;e.emit("reset",{text:u,selectionAfter:c},{mayApplyChanges:!0});break}case fc.toString():e.emit("select-image",r.payload,{mayApplyChanges:!0}),e.sendEvent("Image attached",{conversationId:o.conversation.current.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case Wt.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:o.conversation.current.id,data:{entities:r.payload}});break;case On.fulfilled.toString():e.sendEvent("conversation summarized",{conversationId:o.conversation.current.id,data:{summary:r.payload.summary}});break;case He.toString():e.sendEvent(r.payload.name,{conversationId:((a=r.payload.options)==null?void 0:a.includeConversationData)&&o.conversation.current.id,data:r.payload.data});break;case cc.toString():e.handleKeyDown(r.payload);break;case Jr.toString():e.logSendMessage(r.payload);break;case dc.toString():e.logSendEditSuggestionMessage(r.payload);break;case pc.toString():e.handleInputChanged(r.payload);break;default:break}let s=n(r);switch(r.type){case Jr.toString():e.handleAfterSendMessage(r.payload);break;case ba.toString():e.onUpdateShowTabHint(r.payload);break;case Id.toString():e.logHandlingTime();break;case Ht.toString():{i&&(t.dispatch(on([])),t.dispatch(_n()));break}case on.toString():{i&&r.payload.length>0&&t.dispatch(Sr(0));break}default:break}return s},dE=uA;function Ih(e){return e.toISOString().replace("T"," ").replace("Z","")}function pE(e,t){var o,i,s;let{startTime:n,stopTime:r}=e.handlingTime;if(!n||!r)throw new Error("No startTime and stopTime for handling time metrics");return{conversationId:e.conversation.current.id,clientVersion:t.version,agentId:(o=e.info.agentInfo)==null?void 0:o.agentId,agentName:(i=e.info.agentInfo)==null?void 0:i.agentName,agentEmail:(s=e.info.agentInfo)==null?void 0:s.agentEmail,timeStart:Ih(n),timeStop:Ih(r)}}function Lh(e,t,n){var C,R,P;let{text:r,metrics:{numCharsTyped:o,numCharsPasted:i,numCharsCut:s,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:u,externalTimeTotalSeconds:c,pastes:p,cuts:d,deletions:h,textSuggestions:v,offeredTextSuggestions:y}}=t[e],m=r.length,f=v.reduce((V,{text:D,searchTerm:j})=>V+D.length-(j?j.length:0),0),x=u??Date.now(),_=(Date.now()-x)/1e3+(c||0),b=o/_,E=v.reduce((V,{searchTerm:D})=>V+(D?D.length:0),0);return{conversationId:t.conversation.current.id,source:"agent",text:r,clientVersion:n.version,pastes:p,cuts:d,deletions:h,lenTextTyped:o+E,lenTextTotal:m,lenTextAssisted:f,lenTextPasted:i,lenTextCut:s,lenTextDeleted:a,timeTotalSeconds:_,charsPerSecond:b,numPastes:l,textSuggestionsV2:v,suggestionsCounters:[{source:"gpt",countOffered:y.filter(V=>V.source==="gpt").length}],agentId:(C=t.info.agentInfo)==null?void 0:C.agentId,agentName:(R=t.info.agentInfo)==null?void 0:R.agentName,agentEmail:(P=t.info.agentInfo)==null?void 0:P.agentEmail}}function Ah(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return Ah(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?Ah(o,t):null}function fE(e,t){return Ah(e,t)}function mE(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function cA(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Ad(e){return cA(e)&&(kr(e)||Fc(e))}var gE=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch{return t}}catch{return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch{H.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function dA(e){return e.offsetParent!==null}function hE(e){if(!dA(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 Od(e,t,n=100){let r=hE(e);t({isVisible:r});let o=setInterval(()=>{let i=hE(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var Nd=S(w()),yE=({className:e})=>(0,Nd.jsx)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 512 512",xmlSpace:"preserve",className:e,children:(0,Nd.jsx)("g",{children:(0,Nd.jsx)("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
|
|
22
22
|
c-17.9,17.9-27.3,40.1-27.3,65.7C163.4,163,163.4,233,163.4,233z M465.5,267.9V477c0,9.4-3.4,17.9-10.2,24.7
|
|
23
23
|
c-6.8,6.8-15.4,10.2-24.7,10.2h-349c-9.4,0-17.9-3.4-24.7-10.2c-6.8-6.8-10.2-15.4-10.2-24.7V267.9c0-9.4,3.4-17.9,10.2-24.7
|
|
24
24
|
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
|
|
25
|
-
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 Oh=S(w()),pA={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},vE=({className:e,color:t})=>(0,Oh.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Oh.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:pA[t||"pink"]})});var SE={root:"_root_bgd7a_1",text:"_text_bgd7a_18",icon:"_icon_bgd7a_33",logo:"_logo_bgd7a_38",lock:"_lock_bgd7a_43"};var Nh={};ke(Nh,{enUS:()=>fA,nlNL:()=>mA});var fA={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"}]},mA={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"}]};var So=S(w()),xE=({onLogIn:e})=>{let t=B(Nh),n=N("productName"),r=z(),o=I(pt),i=k("FloatingMenu",SE);if(o===null)return null;let s=()=>{o===!0?r($e(!0)):e()};return(0,So.jsxs)("button",{className:i.root,onClick:s,children:[(0,So.jsx)("div",{className:i.text,children:t(o?"search":"signin",{productName:n})}),(0,So.jsxs)("div",{className:i.icon,children:[(0,So.jsx)(vE,{className:i.logo,color:"pink"}),o===!1&&(0,So.jsx)(yE,{className:i.lock})]})]})};async function Md(e){let n=await new qt(e).get("/platform/config/",{version:null});return te(n)}var _e=S(w());var _E=gE("showTabHint",!0),Va=class e{static version="10.9.1";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:t,brokerUrl:n,version:r=e.version||"unknown",locale:o="en-US",token:i,fetch:s,productName:a,createCustomChannel:l}){let u=t.replace(/\/api$/,"");this.deepdeskApi=new Un(u,{token:i,fetch:s}),this.version=r,this.instanceId=e.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[dE({emit:(p,d,h)=>this.emit(p,d,h),handleAfterSendMessage:p=>this.handleAfterSendMessage(p),handleInputChanged:p=>this.handleInputChanged(p),handleKeyDown:p=>this.handleKeyDown(p),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:p=>this.logSendMessage(p),logSendEditSuggestionMessage:p=>this.logSendEditMessage(p),onUpdateShowTabHint:p=>_E.update(p),sendEvent:(p,d)=>this.deepdeskApi.sendEvent(p,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new za(n)}),this.store=cE(c),this.broadcastEvents=new Zb({debug:!0,deepdeskUrl:u,eventMap:Kw(this.store),createCustomChannel:l}),this.store.dispatch(na),this.store.dispatch(ba(_E.value())),this.store.dispatch(na({locale:o,adminUrl:u,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(H.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(H.warn("Profile has not been loaded (yet)"),!0):(H.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Ii(null)),this.store.dispatch(Ln()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();pt(r)&&Fw(r)!=="loading"&&t()});this.unmountHandlers.push(()=>{n()})})}async isLoggedIn(){return(await this.store.dispatch(Ln())).payload}async setPlatformAgentId(t){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:t}),version:null})}catch(n){H.warn("Failed to attach user:",n)}}async isConversationSupported(t,n){return(await this.store.dispatch(Xm({sessionId:t,options:n}))).payload}async createConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(rc(t))).payload}async getConversationBySessionId(t,n){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(await this.store.dispatch(oc({sessionId:t,options:n}))).payload}async upsertConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(Qm(t))).payload}async postMessages(t){return(await this.store.dispatch(sc(t))).payload}async updateConversation(t){return(await this.store.dispatch(ic(t))).payload}resetConversation(){this.store.dispatch(J()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let t=await this.store.dispatch(On());if(t.error)throw new Error(t.error.message);return t.payload.summary}configure(t){this.store.dispatch(na(t))}setVisitorInfo(t){this.store.dispatch(nw(t))}async setAgentInfo(t){await this.store.dispatch(va(t))}async setAgentSettings(t){await this.store.dispatch(Mg(t))}async getAgentSettings(){return(await this.store.dispatch(Dg())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let t=[];return this.store.dispatch(ed()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})}notifyInputChanged(t){this.store.dispatch(pc(t))}notifyKeyDown(t){this.store.dispatch(cc(t))}notifyPaste(t,n){this.store.dispatch(o_({text:t,selectionText:n}))}notifyCut(t){this.store.dispatch(n_(t))}notifyExternalSuggestion(t){this.store.dispatch(Ht(t)),this.store.dispatch(_n())}notifyEditSuggestion(t){this.store.dispatch(bw(t.contentType,t.suggestions)),this.store.dispatch(In({contentType:t.contentType,suggestion:typeof t.index=="number"?t.suggestions[t.index]:null}))}handleInputChanged(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui;n&&r&&this.store.dispatch(Er({collapse:!1})),this.inputMediator&&this.store.dispatch(Qx({text:t,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(on([])))}handleKeyDown(t){let{overlayCollapsed:n}=this.state.ui,{textSuggestions:r,selectedSuggestionIndex:o,selection:i}=this.state.input,{inlineSuggestions:s}=this.state.settings,a=r.length>0,l=o!==-1;if(this.store.dispatch(r_(lc(t))),t.key!=="Tab"&&!this.settings.showTextSuggestions)return;let u=()=>{n||!a||i&&(t.shiftKey||(this.store.dispatch(Jx()),s||this.stageSelectedSuggestion({inputType:"arrow"}),t.preventDefault()))},c=()=>{if(n||!a||!i||t.shiftKey)return;this.store.dispatch(t_());let{selectedSuggestionIndex:p}=this.state.input;t.preventDefault(),!s&&(p===-1?this.store.dispatch(oa()):this.stageSelectedSuggestion({inputType:"arrow"}))};switch(t.key){case"Up":case"ArrowUp":s?c():u();return;case"Down":case"ArrowDown":{s?u():c();return}case"Esc":case"Escape":{s&&l&&this.store.dispatch(Sr(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(Sr(-1)),this.store.dispatch(oa()),t.preventDefault()):n||(this.store.dispatch(Er({collapse:!0})),this.store.dispatch(Aw(!0)),t.preventDefault());return}case"Tab":{let{userCommitted:p}=this.state.input,d=p.text.substring(0,p.selection.end),{tabCompletionSuggestion:h}=this.state.input;this.store.dispatch(ba(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!s&&this.settings.showTabCompletion&&h&&h.text.startsWith(d)&&(this.store.dispatch(Ht({text:h.text,suggestion:h,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(_n())),t.preventDefault();break}default:}}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(i_()),this.store.dispatch(on([]))}handlingTimeStart(){this.state.handlingTime.startTime||(H.info("Start handling time"),this.store.dispatch(tE()))}handlingTimeStop(){this.state.handlingTime.startTime&&(H.info("Stop handling time"),this.store.dispatch(Id()))}logSendMessage(t){let n=Lh("input",this.state,{version:this.version});t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n)}logSendEditMessage(t){let n=Lh("overlayInput",this.state,{version:this.version});t&&Object.assign(n,{text:t}),this.store.dispatch(Zx(this.state.overlayInput.metrics))}logHandlingTime(){let t=pE(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(nE())}notifySubmit(t={}){this.shouldAbort()||(this.store.dispatch(_n()),this.store.dispatch(Jr(t.text??this.state.input.text)))}stageSelectedSuggestion(t){let n=this.state.input.selectedSuggestionIndex,{textSuggestions:r}=this.state.input;this.store.dispatch(Ht({text:r[n].text,suggestion:r[n],eventMetrics:t,replace:"until-selection-end"}))}emit(t,n,r={}){let o=()=>{this.eventListeners[t]&&this.eventListeners[t].forEach(i=>{try{i(n)}catch(s){H.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),H.error(s)}})};this.inputMediator&&r.mayApplyChanges?this.inputMediator.applyChanges(o):o()}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}whenConversationLoaded(t){let n=()=>this.loadProfileConfig().then(()=>t());this.hasConversation()&&n();let r=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==r&&(r=this.hasConversation(),r&&n())})}overlayContainerFactory(t,n,r,o){let[i,s]=io(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,Ot.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var s;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=(s=t.ownerDocument.defaultView)==null?void 0:s.frameElement;if(i){let[a,l]=io(i,{appendTo:document.body});a.dataset.testid=n,a.style.zIndex="2",a.appendChild(r),this.unmountHandlers.push(()=>{(0,Ot.unmountComponentAtNode)(o),l()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return oo(o),o.dataset.testid=t,o.style.color=r.color,o.style.fontSize=r.fontSize,o.style.fontFamily=r.fontFamily,o.style.fontVariant=r.fontVariant,o.setAttribute("translate","no"),n.appendChild(o),this.unmountHandlers.push(()=>{(0,Ot.unmountComponentAtNode)(o),o.remove()}),o}storeMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(t,n),H.info(`Stored analytics for ${this.conversationId()}`)}catch{}}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()?(H.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(a_(r.metrics))):H.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch{}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Ad(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:r={},showStyleSuggestions:o,showTabCompletion:i,showTextSuggestions:s,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,isEmbedded:p,detectSubmit:d,insertLink:h,inputMediator:v,closestScrollSelector:y,appendOverlayTo:m,inlineSuggestions:g,floatingMenu:f}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:h,isEmbedded:p,inlineSuggestions:g,floatingMenu:f}),n.automaticHandlingTime&&this.setupHandlingTime(t),oo(t),this.inputMediator=v||(kr(t)?new kn(t):new yo(t)),this.inputMediator.on("change",({plainText:b})=>{this.notifyInputChanged(b)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(s_({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",b=>{this.notifyKeyDown(b)}),this.inputMediator.on("paste",({pastedText:b,selectionText:E})=>{this.notifyPaste(b,E)}),this.inputMediator.on("cut",({selectionText:b})=>{this.notifyCut(b)});let x=y&&fE(t,y)||void 0;if(g){let{customStyles:b,appendOverlayTo:E}=n;if(kr(t))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let C=this.createInlineContainer(t,"deepdesk-caret");(0,Ot.render)((0,_e.jsx)(ho,{store:this.store,customStyles:b,children:(0,_e.jsx)(fo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(N1,{})})}),C),this.inputMediator.on("caret",P=>{this.store.dispatch(on([])),P?(C.style.display="block",C.style.top=`${P.top}px`,C.style.left=`${P.left}px`):C.style.display="none"});let R=this.overlayContainerFactory("floating-menu",x||t,{appendTo:E});(0,Ot.render)((0,_e.jsx)(ho,{store:this.store,customStyles:b,children:(0,_e.jsx)(fo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(xE,{onLogIn:()=>this.loginViaPopup()})})}),R)}else{let b=this.overlayContainerFactory("deepdesk-tab-completion",x||t,{appendTo:m,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),E=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||t,{appendTo:m},r==null?void 0:r.suggestionsRootNode);(0,Ot.render)((0,_e.jsx)(ho,{store:this.store,customStyles:r,children:(0,_e.jsx)(fo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(ob,{inputElement:t})})}),b),(0,Ot.render)((0,_e.jsx)(ho,{store:this.store,customStyles:r,children:(0,_e.jsx)(fo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(z1,{onLogIn:()=>this.loginViaPopup()})})}),E)}(0,Ot.render)((0,_e.jsx)(ho,{store:this.store,customStyles:r,children:(0,_e.jsx)(fo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(P1,{})})}),this.createContainer("deepdesk-overlays"));let _;this.inputMediator.on("selection",b=>{clearTimeout(_),b===null?_=setTimeout(()=>{b!==null&&this.store.dispatch(Zm(b))},500):this.store.dispatch(Zm(b))}),this.inputMediator.on("disabled",()=>{var b;(b=this.inputMediator)==null||b.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(Ri(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(Ri(!0))),this.store.dispatch(Yx({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(_n()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var b;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((b=this.state.conversation.current)==null?void 0:b.sessionId)}),this.isMounted=!0}unmount(){var t;this.unmountHandlers.forEach(n=>n()),this.unmountHandlers=[],(t=this.inputMediator)==null||t.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(t,n={}){if(this.widgetRoot&&H.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,isEmbedded:i}=n;this.widgetRoot=t,this.configure({showImages:o,isEmbedded:i}),(0,Ot.render)((0,_e.jsx)(ho,{store:this.store,customStyles:r,children:(0,_e.jsx)(fo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(Gb,{onLogIn:()=>this.loginViaPopup()})})}),t),this.whenConversationLoaded(()=>{var s;this.broadcastEvents.setSessionId((s=this.state.conversation.current)==null?void 0:s.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Ot.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Od(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){mE(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(Aa());let t=Ni(this.state);t&&this.store.dispatch(na({showSearch:t.search,showAutoflows:t.autoflows,showCustomMessages:t.customMessages,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:t.summarizer,showKnowledgeSearch:t.knowledgeAssistForAgents,recommendTextSuggestions:t.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async loginViaPopup(){let t=this.state.settings.adminUrl,n=new URL(t),r=await Md(n.origin);return new Promise((o,i)=>{let s=new MessageChannel,a=s.port1,l=new URL(r.config.platform.hasSso?`${t}/platform/sso/`:`${t}/admin/`);l.searchParams.append("redirect","/sdk/popup/close.html");let u=!1,c=()=>{p&&!p.closed&&p.close(),window.removeEventListener("message",d),clearInterval(h)};a.onmessage=async v=>{var y,m;if((y=v.data)!=null&&y.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((m=v.data)==null?void 0:m.jwt),await this.isLoggedIn(),this.broadcastEvents.send(Ta),c(),u=!0,s.port1.close(),o()}catch(g){i(g)}};let p=window.open(l.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");p===null&&i(new Error("Popup blocked by browser"));let d=async v=>{var y;if(v.origin===l.origin)switch((y=v.data)==null?void 0:y.type){case"deepdesk-popup-loaded":{p==null||p.postMessage({type:"deepdesk-popup-create-channel"},l.origin,[s.port2]);break}case"deepdesk-popup-error":{c(),v.data.message==="Timeout"&&H.warn("Popup timed out. Check if the account's platform url is configured correctly."),i(new Error(v.data.message));break}}};window.addEventListener("message",d);let h=setInterval(()=>{p&&!p.closed||(c(),u||i(new Error("Popup closed by user")))},200);this.unmountHandlers.push(c)})}async checkForTrialMode(t){try{let{account:n}=await this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(H.info("Trial is active"),!await this.deepdeskApi.checkUserExists(t))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:r}=n;H.info(r),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=od(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(Wt()):this.store.dispatch(Rn(r))})}catch(r){this.handleError(r)}}};async function wE(e,t,n={}){let{value:r}=e,{start:o,end:i}=n.replace??{start:0,end:r.length},s=`${r.slice(0,o)}${t}${r.slice(i)}`,a=n.selectionAfter??{start:o+t.length,end:o+t.length},l=()=>{if(n.setValue)return n.setValue(s);e.value=s};return Promise.resolve(l()).then(()=>{e.selectionStart=a.start,e.selectionEnd=a.end,e.blur(),e.focus()})}async function bE(e,t,n={}){let r=n.replace?Ir(e,n.replace.start,n.replace.end):Hi(e),o,i=()=>{if(n.setRange)return n.setRange(r.cloneRange());r.deleteContents(),o=document.createElement("span"),r.insertNode(o),n.insertBRs!==!1?t.split(`
|
|
25
|
+
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 Oh=S(w()),pA={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},vE=({className:e,color:t})=>(0,Oh.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Oh.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:pA[t||"pink"]})});var SE={root:"_root_bgd7a_1",text:"_text_bgd7a_18",icon:"_icon_bgd7a_33",logo:"_logo_bgd7a_38",lock:"_lock_bgd7a_43"};var Nh={};ke(Nh,{enUS:()=>fA,nlNL:()=>mA});var fA={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"}]},mA={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"}]};var So=S(w()),xE=({onLogIn:e})=>{let t=B(Nh),n=N("productName"),r=z(),o=I(pt),i=k("FloatingMenu",SE);if(o===null)return null;let s=()=>{o===!0?r($e(!0)):e()};return(0,So.jsxs)("button",{className:i.root,onClick:s,children:[(0,So.jsx)("div",{className:i.text,children:t(o?"search":"signin",{productName:n})}),(0,So.jsxs)("div",{className:i.icon,children:[(0,So.jsx)(vE,{className:i.logo,color:"pink"}),o===!1&&(0,So.jsx)(yE,{className:i.lock})]})]})};async function Md(e){let n=await new qt(e).get("/platform/config/",{version:null});return te(n)}var _e=S(w());var _E=gE("showTabHint",!0),Va=class e{static version="10.9.2";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:t,brokerUrl:n,version:r=e.version||"unknown",locale:o="en-US",token:i,fetch:s,productName:a,createCustomChannel:l}){let u=t.replace(/\/api$/,"");this.deepdeskApi=new Un(u,{token:i,fetch:s}),this.version=r,this.instanceId=e.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[dE({emit:(p,d,h)=>this.emit(p,d,h),handleAfterSendMessage:p=>this.handleAfterSendMessage(p),handleInputChanged:p=>this.handleInputChanged(p),handleKeyDown:p=>this.handleKeyDown(p),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:p=>this.logSendMessage(p),logSendEditSuggestionMessage:p=>this.logSendEditMessage(p),onUpdateShowTabHint:p=>_E.update(p),sendEvent:(p,d)=>this.deepdeskApi.sendEvent(p,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new za(n)}),this.store=cE(c),this.broadcastEvents=new Zb({debug:!0,deepdeskUrl:u,eventMap:Kw(this.store),createCustomChannel:l}),this.store.dispatch(na),this.store.dispatch(ba(_E.value())),this.store.dispatch(na({locale:o,adminUrl:u,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(H.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(H.warn("Profile has not been loaded (yet)"),!0):(H.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Ii(null)),this.store.dispatch(Ln()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();pt(r)&&Fw(r)!=="loading"&&t()});this.unmountHandlers.push(()=>{n()})})}async isLoggedIn(){return(await this.store.dispatch(Ln())).payload}async setPlatformAgentId(t){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:t}),version:null})}catch(n){H.warn("Failed to attach user:",n)}}async isConversationSupported(t,n){return(await this.store.dispatch(Xm({sessionId:t,options:n}))).payload}async createConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(rc(t))).payload}async getConversationBySessionId(t,n){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(await this.store.dispatch(oc({sessionId:t,options:n}))).payload}async upsertConversation(t){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(await this.store.dispatch(Qm(t))).payload}async postMessages(t){return(await this.store.dispatch(sc(t))).payload}async updateConversation(t){return(await this.store.dispatch(ic(t))).payload}resetConversation(){this.store.dispatch(J()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}async getSummary(){let t=await this.store.dispatch(On());if(t.error)throw new Error(t.error.message);return t.payload.summary}configure(t){this.store.dispatch(na(t))}setVisitorInfo(t){this.store.dispatch(nw(t))}async setAgentInfo(t){await this.store.dispatch(va(t))}async setAgentSettings(t){await this.store.dispatch(Mg(t))}async getAgentSettings(){return(await this.store.dispatch(Dg())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let t=[];return this.store.dispatch(ed()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})}notifyInputChanged(t){this.store.dispatch(pc(t))}notifyKeyDown(t){this.store.dispatch(cc(t))}notifyPaste(t,n){this.store.dispatch(o_({text:t,selectionText:n}))}notifyCut(t){this.store.dispatch(n_(t))}notifyExternalSuggestion(t){this.store.dispatch(Ht(t)),this.store.dispatch(_n())}notifyEditSuggestion(t){this.store.dispatch(bw(t.contentType,t.suggestions)),this.store.dispatch(In({contentType:t.contentType,suggestion:typeof t.index=="number"?t.suggestions[t.index]:null}))}handleInputChanged(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui;n&&r&&this.store.dispatch(Er({collapse:!1})),this.inputMediator&&this.store.dispatch(Qx({text:t,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(on([])))}handleKeyDown(t){let{overlayCollapsed:n}=this.state.ui,{textSuggestions:r,selectedSuggestionIndex:o,selection:i}=this.state.input,{inlineSuggestions:s}=this.state.settings,a=r.length>0,l=o!==-1;if(this.store.dispatch(r_(lc(t))),t.key!=="Tab"&&!this.settings.showTextSuggestions)return;let u=()=>{n||!a||i&&(t.shiftKey||(this.store.dispatch(Jx()),s||this.stageSelectedSuggestion({inputType:"arrow"}),t.preventDefault()))},c=()=>{if(n||!a||!i||t.shiftKey)return;this.store.dispatch(t_());let{selectedSuggestionIndex:p}=this.state.input;t.preventDefault(),!s&&(p===-1?this.store.dispatch(oa()):this.stageSelectedSuggestion({inputType:"arrow"}))};switch(t.key){case"Up":case"ArrowUp":s?c():u();return;case"Down":case"ArrowDown":{s?u():c();return}case"Esc":case"Escape":{s&&l&&this.store.dispatch(Sr(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(Sr(-1)),this.store.dispatch(oa()),t.preventDefault()):n||(this.store.dispatch(Er({collapse:!0})),this.store.dispatch(Aw(!0)),t.preventDefault());return}case"Tab":{let{userCommitted:p}=this.state.input,d=p.text.substring(0,p.selection.end),{tabCompletionSuggestion:h}=this.state.input;this.store.dispatch(ba(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!s&&this.settings.showTabCompletion&&h&&h.text.startsWith(d)&&(this.store.dispatch(Ht({text:h.text,suggestion:h,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(_n())),t.preventDefault();break}default:}}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(i_()),this.store.dispatch(on([]))}handlingTimeStart(){this.state.handlingTime.startTime||(H.info("Start handling time"),this.store.dispatch(tE()))}handlingTimeStop(){this.state.handlingTime.startTime&&(H.info("Stop handling time"),this.store.dispatch(Id()))}logSendMessage(t){let n=Lh("input",this.state,{version:this.version});t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n)}logSendEditMessage(t){let n=Lh("overlayInput",this.state,{version:this.version});t&&Object.assign(n,{text:t}),this.store.dispatch(Zx(this.state.overlayInput.metrics))}logHandlingTime(){let t=pE(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(nE())}notifySubmit(t={}){this.shouldAbort()||(this.store.dispatch(_n()),this.store.dispatch(Jr(t.text??this.state.input.text)))}stageSelectedSuggestion(t){let n=this.state.input.selectedSuggestionIndex,{textSuggestions:r}=this.state.input;this.store.dispatch(Ht({text:r[n].text,suggestion:r[n],eventMetrics:t,replace:"until-selection-end"}))}emit(t,n,r={}){let o=()=>{this.eventListeners[t]&&this.eventListeners[t].forEach(i=>{try{i(n)}catch(s){H.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),H.error(s)}})};this.inputMediator&&r.mayApplyChanges?this.inputMediator.applyChanges(o):o()}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}whenConversationLoaded(t){let n=()=>this.loadProfileConfig().then(()=>t());this.hasConversation()&&n();let r=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==r&&(r=this.hasConversation(),r&&n())})}overlayContainerFactory(t,n,r,o){let[i,s]=io(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,Ot.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var s;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=(s=t.ownerDocument.defaultView)==null?void 0:s.frameElement;if(i){let[a,l]=io(i,{appendTo:document.body});a.dataset.testid=n,a.style.zIndex="2",a.appendChild(r),this.unmountHandlers.push(()=>{(0,Ot.unmountComponentAtNode)(o),l()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return oo(o),o.dataset.testid=t,o.style.color=r.color,o.style.fontSize=r.fontSize,o.style.fontFamily=r.fontFamily,o.style.fontVariant=r.fontVariant,o.setAttribute("translate","no"),n.appendChild(o),this.unmountHandlers.push(()=>{(0,Ot.unmountComponentAtNode)(o),o.remove()}),o}storeMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(t,n),H.info(`Stored analytics for ${this.conversationId()}`)}catch{}}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()?(H.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(a_(r.metrics))):H.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch{}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Ad(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:r={},showStyleSuggestions:o,showTabCompletion:i,showTextSuggestions:s,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,isEmbedded:p,detectSubmit:d,insertLink:h,inputMediator:v,closestScrollSelector:y,appendOverlayTo:m,inlineSuggestions:g,floatingMenu:f}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:h,isEmbedded:p,inlineSuggestions:g,floatingMenu:f}),n.automaticHandlingTime&&this.setupHandlingTime(t),oo(t),this.inputMediator=v||(kr(t)?new kn(t):new yo(t)),this.inputMediator.on("change",({plainText:b})=>{this.notifyInputChanged(b)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(s_({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",b=>{this.notifyKeyDown(b)}),this.inputMediator.on("paste",({pastedText:b,selectionText:E})=>{this.notifyPaste(b,E)}),this.inputMediator.on("cut",({selectionText:b})=>{this.notifyCut(b)});let x=y&&fE(t,y)||void 0;if(g){let{customStyles:b,appendOverlayTo:E}=n;if(kr(t))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let C=this.createInlineContainer(t,"deepdesk-caret");(0,Ot.render)((0,_e.jsx)(ho,{store:this.store,customStyles:b,children:(0,_e.jsx)(fo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(N1,{})})}),C),this.inputMediator.on("caret",P=>{this.store.dispatch(on([])),P?(C.style.display="block",C.style.top=`${P.top}px`,C.style.left=`${P.left}px`):C.style.display="none"});let R=this.overlayContainerFactory("floating-menu",x||t,{appendTo:E});(0,Ot.render)((0,_e.jsx)(ho,{store:this.store,customStyles:b,children:(0,_e.jsx)(fo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(xE,{onLogIn:()=>this.loginViaPopup()})})}),R)}else{let b=this.overlayContainerFactory("deepdesk-tab-completion",x||t,{appendTo:m,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),E=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||t,{appendTo:m},r==null?void 0:r.suggestionsRootNode);(0,Ot.render)((0,_e.jsx)(ho,{store:this.store,customStyles:r,children:(0,_e.jsx)(fo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(ob,{inputElement:t})})}),b),(0,Ot.render)((0,_e.jsx)(ho,{store:this.store,customStyles:r,children:(0,_e.jsx)(fo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(z1,{onLogIn:()=>this.loginViaPopup()})})}),E)}(0,Ot.render)((0,_e.jsx)(ho,{store:this.store,customStyles:r,children:(0,_e.jsx)(fo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(P1,{})})}),this.createContainer("deepdesk-overlays"));let _;this.inputMediator.on("selection",b=>{clearTimeout(_),b===null?_=setTimeout(()=>{b!==null&&this.store.dispatch(Zm(b))},500):this.store.dispatch(Zm(b))}),this.inputMediator.on("disabled",()=>{var b;(b=this.inputMediator)==null||b.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(Ri(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(Ri(!0))),this.store.dispatch(Yx({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.unmountHandlers.push(()=>{this.state.input.text!==""&&(this.store.dispatch(_n()),this.storeMetrics())}),this.whenConversationLoaded(()=>{var b;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((b=this.state.conversation.current)==null?void 0:b.sessionId)}),this.isMounted=!0}unmount(){var t;this.unmountHandlers.forEach(n=>n()),this.unmountHandlers=[],(t=this.inputMediator)==null||t.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(t,n={}){if(this.widgetRoot&&H.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,isEmbedded:i}=n;this.widgetRoot=t,this.configure({showImages:o,isEmbedded:i}),(0,Ot.render)((0,_e.jsx)(ho,{store:this.store,customStyles:r,children:(0,_e.jsx)(fo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(Gb,{onLogIn:()=>this.loginViaPopup()})})}),t),this.whenConversationLoaded(()=>{var s;this.broadcastEvents.setSessionId((s=this.state.conversation.current)==null?void 0:s.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Ot.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Od(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){mE(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(Aa());let t=Ni(this.state);t&&this.store.dispatch(na({showSearch:t.search,showAutoflows:t.autoflows,showCustomMessages:t.customMessages,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:t.summarizer,showKnowledgeSearch:t.knowledgeAssistForAgents,recommendTextSuggestions:t.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async loginViaPopup(){let t=this.state.settings.adminUrl,n=new URL(t),r=await Md(n.origin);return new Promise((o,i)=>{let s=new MessageChannel,a=s.port1,l=new URL(r.config.platform.hasSso?`${t}/platform/sso/`:`${t}/admin/`);l.searchParams.append("redirect","/sdk/popup/close.html");let u=!1,c=()=>{p&&!p.closed&&p.close(),window.removeEventListener("message",d),clearInterval(h)};a.onmessage=async v=>{var y,m;if((y=v.data)!=null&&y.jwt)try{await this.deepdeskApi.exchangeTokenForAccessCookie((m=v.data)==null?void 0:m.jwt),await this.isLoggedIn(),this.broadcastEvents.send(Ta),c(),u=!0,s.port1.close(),o()}catch(g){i(g)}};let p=window.open(l.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");p===null&&i(new Error("Popup blocked by browser"));let d=async v=>{var y;if(v.origin===l.origin)switch((y=v.data)==null?void 0:y.type){case"deepdesk-popup-loaded":{p==null||p.postMessage({type:"deepdesk-popup-create-channel"},l.origin,[s.port2]);break}case"deepdesk-popup-error":{c(),v.data.message==="Timeout"&&H.warn("Popup timed out. Check if the account's platform url is configured correctly."),i(new Error(v.data.message));break}}};window.addEventListener("message",d);let h=setInterval(()=>{p&&!p.closed||(c(),u||i(new Error("Popup closed by user")))},200);this.unmountHandlers.push(c)})}async checkForTrialMode(t){try{let{account:n}=await this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(H.info("Trial is active"),!await this.deepdeskApi.checkUserExists(t))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:r}=n;H.info(r),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=od(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(Wt()):this.store.dispatch(Rn(r))})}catch(r){this.handleError(r)}}};async function wE(e,t,n={}){let{value:r}=e,{start:o,end:i}=n.replace??{start:0,end:r.length},s=`${r.slice(0,o)}${t}${r.slice(i)}`,a=n.selectionAfter??{start:o+t.length,end:o+t.length},l=()=>{if(n.setValue)return n.setValue(s);e.value=s};return Promise.resolve(l()).then(()=>{e.selectionStart=a.start,e.selectionEnd=a.end,e.blur(),e.focus()})}async function bE(e,t,n={}){let r=n.replace?Ir(e,n.replace.start,n.replace.end):Hi(e),o,i=()=>{if(n.setRange)return n.setRange(r.cloneRange());r.deleteContents(),o=document.createElement("span"),r.insertNode(o),n.insertBRs!==!1?t.split(`
|
|
26
26
|
`).reverse().forEach((s,a)=>{a>0&&r.insertNode(document.createElement("br")),r.insertNode(document.createTextNode(s))}):r.insertNode(document.createTextNode(t))};return Promise.resolve(i()).then(()=>{try{if(n.selectionAfter!==!1){e.focus();let s=n.selectionAfter?Ir(e,n.selectionAfter.start,n.selectionAfter.end):(r.collapse(!1),r),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(s)}if(!o)return;o.scrollIntoView&&o.scrollIntoView({block:"nearest",inline:"nearest"})}finally{o&&o.remove()}})}async function EE(e,t){let n;e.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0}));let r=()=>{let o=e.ownerDocument.defaultView??window,i=o.getSelection();if((!i||i.rangeCount===0)&&(e.focus(),i=o.getSelection()),!i||i.rangeCount===0)return;let s=i.getRangeAt(0);s&&(s.deleteContents(),n=document.createElement("span"),s.insertNode(n),t.split(`
|
|
27
27
|
`).reverse().forEach((a,l)=>{l>0&&s.insertNode(document.createElement("br")),s.insertNode(document.createTextNode(a))}),s.collapse(!1))};return Promise.resolve(r()).then(()=>{if(e.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0})),e.focus(),!!n)try{n.scrollIntoView&&n.scrollIntoView({block:"nearest",inline:"nearest"})}finally{n&&n.remove()}})}function CE(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function TE(e,t,n){await new Un(e).authenticateWithKey(t,n)}async function gA(e){let n=await(e.fetch??window.fetch)(e.url),r=await n.blob();return new File([r],e.name,{type:e.mimeType??n.headers.get("Content-Type")??"image/jpeg"})}async function kE(e,t){let n=await gA(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}}return NE(hA);})();
|
|
28
28
|
/*! Bundled license information:
|