@deepdesk/deepdesk-sdk 12.1.1-beta.0 → 12.1.1-beta.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.
@@ -20,11 +20,11 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
20
20
  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
21
21
  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
22
22
  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
23
- 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 Kh=w(b()),vN={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Ub=({className:e,color:t})=>(0,Kh.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Kh.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:vN[t||"pink"]})});var zb={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var Wh={};$e(Wh,{enUS:()=>SN,nlNL:()=>wN});var SN={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},wN={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Wo=w(b()),jb=({onLogIn:e})=>{let t=q(Wh),n=V("floatingMenu"),r=V("productName"),o=Y(),i=M(rt),s=A("FloatingMenu",zb);if(i===null||n===!1)return null;let a=()=>{i===!0?o(Tt(!0)):e()};return(0,Wo.jsxs)("button",{className:(0,Bb.default)(s.root,{[s.isLoggedIn]:i,[s.isLoggedOut]:!i}),onClick:a,children:[(0,Wo.jsx)("div",{className:s.text,children:t(i?"search":"signin",{productName:r})}),(0,Wo.jsxs)("div",{className:s.icon,children:[(0,Wo.jsx)(Ub,{className:s.logo,color:"pink"}),i===!1&&(0,Wo.jsx)(Hb,{className:s.lock})]})]})};var Zd=w(H());var Vb=w(H());function Jr(e){(0,Vb.useEffect)(()=>{let t=n=>{n.isWithinRoot||e(n)};return document.body.addEventListener("mouseup",t),()=>{document.body.removeEventListener("mouseup",t)}},[e])}function $o(e){e.addEventListener("mouseup",t=>{t.isWithinRoot=!0},!0)}function An(e){let{showMidSentenceSuggestions:t,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:r}=e.settings,{text:o,selection:i}=e.input;return i.start!==i.end?!1:i.end>=o.length?!0:t?n&&new RegExp(n).test(o.substring(i.end))||r&&new RegExp(r).test(o.substring(0,i.end))?!0:n===!1&&r===!1:!1}var xN={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Gd=({ui:e})=>e.overlayCollapsed,Kb=X({name:"ui",initialState:xN,reducers:{setShowTabHint(e,t){e.showTabHint=t.payload},setInputFocus(e,t){e.overlayCollapsedUserOverwrite!==!0&&(t.payload===!0&&(e.overlayCollapsed=!1),e.inputHasFocus=t.payload)},setOverlayCollapsed(e,t){t.payload.collapse===!1&&(e.openOverlayWhenTyping=!1),!(t.payload.skipWhenInputFocus&&e.inputHasFocus)&&(e.overlayCollapsed=t.payload.collapse)},setOpenOverlayWhenTyping(e,t){e.openOverlayWhenTyping=t.payload},setOverlayCollapsedUserOverwrite(e,t){e.overlayCollapsedUserOverwrite=t.payload,e.overlayCollapsed=t.payload}}}),{setShowTabHint:pl,setInputFocus:Xd,setOverlayCollapsed:eo,setOpenOverlayWhenTyping:Wb,setOverlayCollapsedUserOverwrite:$b}=Kb.actions,qb=Kb.reducer;var Yd=w(H());var gs=w(H());var Gb=w(H());function Xb(e,t,n){(0,Gb.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var Yb={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var qo=w(b()),bN=["search","personal-collection-search","search-autocomplete"];function CN(e,t,n,r={}){var i;let o="";return bN.includes(t)?o=ME(Ah(e,n,{stripAgentPart:!0}),(i=r.searchKeywords)!=null?i:[n]):o=Ah(e,n,r),r.placeholders===!0&&(o=_E(o)),o}var TN=()=>{},kN=({selected:e,suggestion:t})=>{let n=V("inlineSuggestions"),r=M(ns),o=V("enableSuggestionFeedback"),i=M(c=>c.input.text),s=Y(),a=A("TextSuggestion",Yb),l=(0,gs.useRef)(null);(0,gs.useEffect)(()=>{let c=setTimeout(()=>{s(L1({text:t.text,suggestion:t}))},500);return()=>{clearTimeout(c)}},[t]),Xb(l,"click",()=>{s(on({suggestion:t,text:t.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let u=(0,gs.useMemo)(()=>CN(t.text,t.source,r,{stripAgentPart:n,placeholders:!0,searchKeywords:t.searchKeywords}),[n,t.text,t.source,r,t.searchKeywords]);return t.source==="gpt"&&!n?null:(0,qo.jsxs)("div",{className:a.root,children:[(0,qo.jsx)(oe,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:TN,children:(0,qo.jsx)(is,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:u})}),e&&o&&(0,qo.jsx)("div",{className:a.actions,children:(0,qo.jsx)($d,{source:"overlay",context:i,suggestion:t})})]})},Qb=kN;var $h=w(b()),PN=({suggestions:e,selectedIndex:t,reverse:n})=>{let r=(0,Yd.useMemo)(()=>{let o=e.map((i,s)=>(0,$h.jsx)(Qb,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]);return(0,$h.jsx)(Yd.Fragment,{children:r})},Qd=PN;var Zb={root:"dd-PfvRI",paper:"dd-HYlyY"};var ml=w(b()),RN=({textSuggestions:e,selectedIndex:t})=>{let n=(0,Zd.useRef)(null),r=A("InlineSuggestionsOverlay",Zb),o=M(An),i=Y(),s=M(rt),a=M(ts),l=M(Gd),u=V("showTextSuggestions");return Jr(()=>{setTimeout(()=>{i(eo({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Zd.useEffect)(()=>{let c=n.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let f=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-f.right,0)}px`}),l||!o||!u||e.length===0||s!==!0||a===!1?null:(0,ml.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,ml.jsx)("div",{ref:n,className:r.paper,children:(0,ml.jsx)(gt,{children:(0,ml.jsx)(Qd,{suggestions:e,selectedIndex:t})})})})},AN=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),Jb=qn(AN)(RN);var gl=w(b()),LN=({children:e})=>{let n=V("locale").replace("-","");return(0,gl.jsx)(mh.Provider,{value:n,children:e})},IN=({store:e,customStyles:t={},children:n})=>(0,gl.jsx)(qg,{store:e,children:(0,gl.jsx)(LN,{children:(0,gl.jsx)(Os.Provider,{value:t,children:n})})}),Go=IN;var ef=w(ie()),hs=w(H());var eC=w(H());function tC(e,t){let[n,r]=(0,eC.useState)(()=>{if(typeof window=="undefined")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return U.error(i),t}});return[n,i=>{try{let s=i instanceof Function?i(n):i;r(s),typeof window!="undefined"&&window.localStorage.setItem(e,JSON.stringify(s))}catch(s){U.error(s)}}]}var nC=()=>/Mac/i.test(navigator.platform);var oC=w(ie()),sr=w(H());var qh={};$e(qh,{enUS:()=>ON,nlNL:()=>NN});var ON={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"}]}]},NN={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 rC={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var to=w(b()),Gh=(e,t,n)=>r=>(0,to.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),MN=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=q(qh),s=$t(),a=A("Login",rC),l=V("productName"),u=(0,sr.useCallback)(g=>{g.preventDefault(),r&&r(parseInt(g.target.value,10))},[]),c=(0,sr.useCallback)(g=>{g.preventDefault(),s.send(os,!0)},[t]),f=(0,sr.useMemo)(()=>g=>(0,to.jsx)("a",{onClick:h=>{h.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[t]),d=(0,sr.useCallback)(g=>(0,to.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:p,hour:v,day:y}=(0,sr.useMemo)(()=>({min:Gh(a,60*10,u),hour:Gh(a,60*60,u),day:Gh(a,60*60*12,u)}),[]);return(0,to.jsxs)("div",{className:(0,oC.default)(e,a.root),children:[i("loginPlease",{login:n?d:f,productName:l}),r&&(0,to.jsxs)(sr.Fragment,{children:[(0,to.jsx)("br",{}),i("snooze",{min:p,hour:v,day:y})]})]})},Jd=MN;var iC={root:"dd-DoQhb",text:"dd-Jwnev"};var hl=w(b()),_N=({title:e})=>{let t=A("SearchTrigger",iC),n=Y();return(0,hl.jsxs)("button",{type:"button",className:t.root,onClick:()=>n(Tt(!0)),children:[(0,hl.jsx)(ls,{}),(0,hl.jsx)("span",{className:t.text,children:e})]})},sC=_N;var Xh={};$e(Xh,{enUS:()=>DN,nlNL:()=>FN});var DN={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"}]},FN={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 aC={root:"dd-oa7Vc",isInline:"dd-bwk31",toggleButton:"dd-MSB8Z",toggleButtonWrapper:"dd-ZkCzT",toggleButtonWrapperHidden:"dd-Sq66c",isCollapsed:"dd-vkrPk",collapsible:"dd-CWQJe",hints:"dd-IOoo3",hintsHidden:"dd-psVuT",triggers:"dd-toIoo",triggersRight:"dd-mc4l2"};var be=w(b()),HN=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=A("SuggestionsOverlay",aC),o=q(Xh),i=M(An),s=A1(),a=Y(),l=(0,hs.useRef)(null),u=V("searchTriggerKey"),c=V("productName"),f=M(Gd),d=M(rt),p=M(ts),[v,y]=(0,hs.useState)(null),g=V("showSearch"),m=V("showTextSuggestions"),h=V("adminUrl"),S=V("isEmbedded"),[x,P]=tC("dd-snooze-until-ms",0),C=f||x>Date.now(),R=e.filter(D=>D.source!=="gpt").length,N=()=>{C&&P(0),a($b(!C))},_=D=>{let G=Date.now()+D*1e3;P(G),U.info(`Snooze until: ${new Date(G)}`),a(eo({collapse:!0}))};return(0,hs.useEffect)(()=>{R===0&&y(null)},[e,R]),Jr(()=>{a(eo({collapse:!0,skipWhenInputFocus:!0}))}),d===null||p===!1?null:d===!1?(0,be.jsxs)("div",{ref:l,className:(0,ef.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,be.jsxs)("div",{className:r.triggers,children:[(0,be.jsx)("div",{style:{flex:1}}),(0,be.jsx)("div",{className:r.triggersRight,children:(0,be.jsx)(mo,{className:r.toggleButton,title:o("collapse"),onClick:N,isCollapsed:!1})})]}),(0,be.jsx)("div",{className:r.toggleButtonWrapper,children:(0,be.jsx)(mo,{className:r.toggleButton,title:o("open",{productName:c}),onClick:N,isCollapsed:!0})}),(0,be.jsx)("div",{className:r.collapsible,children:(0,be.jsx)(Jd,{loginUrl:h,isEmbedded:S,onLogIn:n,onSnooze:_})})]}):!s||!i?null:(0,be.jsxs)("div",{ref:l,className:(0,ef.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,be.jsxs)("div",{className:r.triggers,children:[(0,be.jsx)("div",{style:{flex:1},children:g&&(0,be.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>y(o(nC()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>y(null),children:(0,be.jsx)(sC,{title:o("search")})})}),(0,be.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,be.jsx)("div",{className:(0,ef.default)(!v&&r.hintsHidden,r.hints),children:v}),(0,be.jsx)(mo,{className:r.toggleButton,title:o("collapse"),onClick:N,isCollapsed:!1})]})]}),(0,be.jsx)("div",{className:r.toggleButtonWrapper,children:(0,be.jsx)(mo,{className:r.toggleButton,title:o("open",{productName:c}),onClick:N,isCollapsed:!0})}),R>0&&m&&(0,be.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,be.jsx)(gt,{children:(0,be.jsx)(Qd,{suggestions:e,selectedIndex:t,reverse:!0})})})]})},UN=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),lC=qn(UN)(HN);var hf=w(ie());var cr=w(H());var ys=w(H());function tf(e){return e.contentEditable==="true"}function zN(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 uC(e){let{selectionStart:t,selectionEnd:n}=tf(e)?zN(e):e;return[t,n]}function cC(e){let[,t]=(0,ys.useState)(),n=(0,ys.useRef)(null);return n.current=uC(e),(0,ys.useEffect)(()=>{let r=()=>{var a;let[o,i]=(a=n.current)!=null?a:[],s=uC(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 dC(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(ru);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 fC=w(H()),BN=["div","span","mark","strong","b","i","u","em"];function Yh(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(BN.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,fC.cloneElement)(r,{children:Yh(s,t,n+1)})]}return[...e,...t]}function no(e){return e.tagName.toLowerCase()==="textarea"}var pC={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var bC=w(ie());var df=w(H());var vs=w(H());function mC(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function nf(e){let t=(0,vs.useRef)(null),[n,r]=(0,vs.useState)(!1);return(0,vs.useEffect)(()=>{var c;let o=!1,i=parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[s,a]=mC((f,d)=>{let p=t.current;if(!p)return;let v=f/i,y=d/i,g=p.getBoundingClientRect(),m=v>g.x&&v<g.x+g.width&&y>g.y&&y<g.y+g.height;m&&!o?(o=!0,r(!0)):!m&&o&&(o=!1,r(!1))},({clientX:f,clientY:d})=>[f,d]),[l,u]=mC(()=>{o=!1,r(!1)});return e.addEventListener("mousemove",s),e.addEventListener("mouseleave",l),()=>{a(),u(),e.removeEventListener("mousemove",s),e.removeEventListener("mouseleave",l)}},[t]),[t,n]}function gC(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function rf(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function hC(e){return e!=null}var Zh=w(ie()),Gt=w(H());var of=w(H()),jN=["bottom","height","left","right","top","width"],VN=(e={},t={})=>jN.some(n=>e[n]!==t[n]),ar=new Map,yC,vC=()=>{let e=[],t=[];ar.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();VN(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{ar.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),yC=window.requestAnimationFrame(vC)};function KN(e,t){return{observe(){let n=ar.size===0;if(ar.has(e)){let r=ar.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else ar.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&vC()},unobserve(){let n=ar.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||ar.delete(e),ar.size||cancelAnimationFrame(yC)}}}}function Qh(e){let[t,n]=(0,of.useState)(null);return(0,of.useLayoutEffect)(()=>{if(!e.current)return;let r=KN(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var Ss=w(H()),wC=w(yc());var SC={root:"dd-r-dgo"};var xC=({children:e,parentNode:t})=>{let[n,r]=(0,Ss.useState)(null),o=(0,Ss.useContext)(Os);return(0,Ss.useLayoutEffect)(()=>{let i=document.createElement("div");return $o(i),i.classList.add(SC.root),o!=null&&o.portalRootNode&&i.classList.add(o==null?void 0:o.portalRootNode),(t||document.body).appendChild(i),r(i),()=>{i.isConnected&&i.remove()}},[]),n?(0,wC.createPortal)(e,n):null};var Ln={ref:"dd-iz-KP",root:"dd-vEMon",positionAbove:"dd-mUCxM",positionBelow:"dd-7oZI7",positionLeft:"dd-BiWvD",positionRight:"dd-JIWea",alignStart:"dd-5ivu6",alignCenter:"dd-rnVkP",alignEnd:"dd-gZBp4"};var sf=w(b()),af=(e=!1)=>{let[t,n]=(0,Gt.useState)(e),r=(0,Gt.useCallback)(()=>n(!0),[]),o=(0,Gt.useCallback)(()=>n(!1),[]),i=(0,Gt.useCallback)(()=>n(a=>!a),[]),s=(0,Gt.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function Jh(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 ws=u=>{var c=u,{className:e,triggerRef:t,boundaryRef:n=(0,Gt.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=Jh,parentNode:a}=c,l=ne(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let f=Qh(t),d=Qh(n),p=(0,Gt.useMemo)(()=>s(f,d,0),[f,d]);return(0,sf.jsx)(xC,{parentNode:a,children:(0,sf.jsx)("div",L(T({className:(0,Zh.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:p},l),{role:"dialog",children:(0,sf.jsx)("div",{className:(0,Zh.default)(e,Ln.root),children:i})}))})};var EC=w(ie()),lf=w(H());var lr={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var ey=w(b()),uf=(0,lf.forwardRef)((o,r)=>{var i=o,{className:e,children:t}=i,n=ne(i,["className","children"]);let s=(0,lf.useRef)(null),a=A("TabCompletion",lr);return(0,ey.jsx)("div",L(T({ref:rf([s,r]),className:(0,EC.default)(e,a.popoverContentContainer)},n),{children:(0,ey.jsx)("div",{className:a.popoverContent,children:t})}))});var ro=w(b()),WN=e=>t=>{let n=Jh(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},$N=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=A("TabCompletion",lr),s=af(),a=(0,df.useMemo)(()=>WN(e.getBoundingClientRect()),[e]),[l,u]=nf(e);return(0,df.useEffect)(()=>{u?s.open():s.close()},[u]),(0,ro.jsxs)("span",{children:[(0,ro.jsx)("mark",{ref:rf([l,s.triggerRef]),className:(0,bC.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,ro.jsx)(ws,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,ro.jsx)(uf,{style:n,children:(0,ro.jsx)("div",{className:i.hintText,children:o})})})]})},cf=class extends Jn{constructor(){super(...arguments);this.keywordMatches=[];this.preparedKeywordMatches=[];this.usedKeywordMatches=new Set}onBeforeParse(n,r){return r.keywordMatches&&r.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=r.keywordMatches.map(o=>L(T({},o),{keywordRegex:new RegExp(`\\b${gC(o.keyword)}\\b`,"i")})),this.keywordMatches=r.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let r=this.preparedKeywordMatches.map(i=>{if(this.usedKeywordMatches.has(i))return null;let s=n.match(i.keywordRegex);if(!s)return null;let a=n.charAt(s.index-1),l=n.charAt(s.index+i.keyword.length);return a==="{"&&l==="}"?null:{index:s.index,length:s[0].length,match:s[0],matchString:s[0],suggestion:i.suggestion,preparedKeywordMatch:i,valid:!0}}).filter(hC);if(r.length===0)return null;let o=r.reduce((i,s)=>s.index<i.index?s:i);return this.usedKeywordMatches.add(o.preparedKeywordMatch),o}replaceWith(n,r){return(0,ro.jsx)($N,{inputElement:r.inputElement,suggestion:r.suggestion,inputStyle:r.inputStyle,boundaryRef:r.boundaryRef,children:n},`keyword_${r.matchString}_${r.key}`)}asTag(){return"mark"}};var CC=w(ie());var ty=w(b()),qN=({inputElement:e,children:t})=>{let n=A("TabCompletion",lr),[r,o]=nf(e);return(0,ty.jsx)("mark",{ref:r,className:(0,CC.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},ff=class extends Jn{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,ty.jsx)(qN,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var mf=w(ie());var lt=w(H());var ny=w(b()),TC=()=>(0,ny.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,ny.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 oo=w(H());var PC=w(Sh());var kC={root:"dd-ky-Bv",content:"dd-kV5e1"};function pf(e,t,n){var o;let r=((o=e.imageSizes)==null?void 0:o[t])||e.image||n;if(!r)return null;try{return new URL(r).toString()}catch(i){return null}}function ry(e){return e.replace("https://www.","").replace("https://","")}var Xt=w(b()),GN=3,XN=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),YN=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=GN})=>{let i=A("LinkSearch",kC),[s,a]=(0,oo.useState)(""),l=Y(),u=M(bb("url")),c=M(Q1("URL",XN)),[f,d]=(0,oo.useState)(c.length-1),p=V("fallbackImage"),v=h=>{let S=h.target;a(S.value)},y=(h,S)=>{h.stopPropagation(),h.preventDefault(),window.open(S,"_blank")},g=h=>{var P;let S=f-1<0?c.length-1:f-1,x=f+1===c.length?0:f+1;h.code==="Escape"&&(a(""),t()),h.code==="ArrowUp"&&d(S),h.code==="ArrowDown"&&d(x),h.code==="Enter"&&e(((P=c[f])==null?void 0:P.text)||s)},m=(0,oo.useCallback)((0,PC.default)(h=>{l(No({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,oo.useEffect)(()=>{s&&m(s)},[s]),(0,oo.useEffect)(()=>()=>{l(dd())},[]),(0,Xt.jsxs)("div",{className:i.root,children:[(0,Xt.jsx)(gt,{withDivider:!0,children:(s?c:u).slice(0,o).map((h,S)=>(0,Xt.jsx)(oe,{selected:f===S,onClick:()=>e(h.text),"data-testid":"linksearch-suggestion",children:(0,Xt.jsxs)(ye,{children:[(0,Xt.jsx)(ye.Image,{src:pf(h,"small",p||void 0),title:h.title||h.text}),(0,Xt.jsxs)(ye.Content,{className:i.content,cropText:!0,children:[(0,Xt.jsx)(ye.Title,{children:h.title||ry(h.text)}),h.title&&ry(h.text)]}),(0,Xt.jsx)(oe.Actions,{children:(0,Xt.jsx)(oe.ActionButton,{label:r,onClick:x=>y(x,h.text)})})]})},h.text))}),(0,Xt.jsx)(Ya,{value:s,onChange:v,autoFocus:!0,placeholder:n,onKeyUp:g})]})},RC=YN;var oy={};$e(oy,{enUS:()=>QN,nlNL:()=>ZN});var QN={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},ZN={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var at=w(b()),JN=(0,lt.forwardRef)((e,t)=>{let n=A("TabCompletion",lr);return(0,at.jsx)("mark",{ref:t,className:(0,mf.default)(n.matchSelection)},"selection-start")}),eM=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=q(oy),s=A("TabCompletion",lr),a=(0,lt.useRef)(null),l=(0,lt.useRef)(null),[u,c]=(0,lt.useState)(null),f=Y(),d=af(document.activeElement===r),[p]=(0,lt.useState)(()=>document.createRange());d.triggerRef.current=p,(0,lt.useEffect)(()=>()=>p.detach(),[]),(0,lt.useEffect)(()=>{let y=e.current,g=a.current;!y||!g||(p.setStart(y,0),p.setEnd(g,0))},[e.current,a.current]),Jr(()=>{d.close()});let v=(0,lt.useCallback)(y=>{let g=p.toString(),m=/^http(s?):\/\//.test(y)?y:`https://${y}`;f(id({text:`[${g}](${m})`,replace:"selection"}))},[]);return(0,at.jsxs)("span",{children:[(0,at.jsx)("mark",{ref:a,className:(0,mf.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,at.jsx)(ws,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,at.jsxs)(uf,{style:n,ref:l,children:[(0,at.jsx)("div",{className:(0,mf.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,at.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,at.jsx)(TC,{}),(0,at.jsx)("span",{children:"\xA0"}),(0,at.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,at.jsx)(RC,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:v,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},gf=class extends Jn{constructor(){super(...arguments);this.charCount=0;this.foundIndex=0;this.startRef=null}onBeforeParse(n,r){return this.props=r,this.charCount=0,this.startRef=(0,lt.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[r,o]=this.props.selection;if(r===o)return null;let i=this.foundIndex===0?r:o,s=i>=this.charCount&&i<=this.charCount+n.length?{index:i-this.charCount,length:0,match:"",valid:!0}:null;s&&this.foundIndex++;let a=this.foundIndex===1;return s&&a?this.charCount+=i-this.charCount:this.charCount+=n.length,s?T({isStart:a},s):null}replaceWith(n,r){return r.isStart?(0,at.jsx)(JN,{ref:this.startRef}):(0,at.jsx)(eM,{inputElement:r.inputElement,startRef:this.startRef,boundaryRef:r.boundaryRef,inputStyle:r.inputStyle})}asTag(){return"mark"}};var ur=w(b()),tM=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=A("TabCompletion",pC),c=V("insertLink"),f=V("showMidSentenceSuggestions"),d=V("inlineSuggestions"),p=cC(a),v=(0,cr.useRef)(null),y=M(rt);(0,cr.useEffect)(()=>{no(a)&&p&&dC(a,p)},[p]);let g=(0,cr.useCallback)(S=>{if(!o||!n)return S;let x=[(0,ur.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,ur.jsx)("span",{"data-testid":"tab-completion",className:(0,hf.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&x.push((0,ur.jsx)("span",{className:(0,hf.default)(u.hint,u.resetIndent),children:(0,ur.jsx)(Jl,{keyCode:"tab"},"tabHint")})),Yh(S,x)},[o,n,r]),m=(0,cr.useMemo)(()=>{let S=[];return c&&S.push(new gf("selection")),S.push(new ff("placeholders")),i&&S.push(new cf("keywords")),S},[d,c,i]),h=(0,cr.useMemo)(()=>{let S=window.getComputedStyle(a);return{"--dd-color":S.color,"--dd-font-size":S.fontSize,"--dd-font-family":S.fontFamily,"--dd-font-variant":S.fontVariant}},[]);return!e||!y?null:(0,ur.jsxs)("div",{ref:S=>{S!=null&&S.parentElement&&(v.current=S==null?void 0:S.parentElement)},className:u.root,style:h,children:[(0,ur.jsx)(is,{tagName:"span",containerTagName:"div",className:(0,hf.default)(u.container,u.agentText),disableLineBreaks:no(a),content:t||"\u200B",onAfterParse:g,matchers:m,selection:p,keywordMatches:s,inputElement:a,inputStyle:h,boundaryRef:v,inlineSuggestionsOnlyAtEnd:!f}),(0,ur.jsx)("br",{})]})},nM=e=>{var g,m,h;let{input:t,ui:n,settings:r,styleSuggestions:o,conversation:i}=e,s=rs({input:t}),a=(s==null?void 0:s.text)||"",l=(s==null?void 0:s.source)||"",u=(g=t.html)!=null?g:ss(t.text),c=a.indexOf(t.text)===0?a.slice(t.text.length):"",{showTabHint:f}=n,{isSupported:d}=i,{showTabCompletion:p,visible:v,showStyleSuggestions:y}=r;return{showTabHint:f,showStyleSuggestions:y,showTabCompletion:p&&An(e),content:u,tabText:c,source:l,keywordMatches:(h=(m=o.list)==null?void 0:m.keywordMatches)!=null?h:[],enabled:v&&d!==!1}},AC=qn(nM)(tM);var XT=w(ie()),Al=w(H());var LC={list:[],fetchState:"idle"},OC=e=>e.autoflows.list||[],IC=e=>t=>{var n;return(n=t.list)==null?void 0:n.find(r=>r.triggerPayload===e)},dr=K("autoflows/getAll",(e,t)=>k(void 0,null,function*(){let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(e)})),iy=K("autoflows/start",(e,t)=>k(void 0,null,function*(){let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");yield r.startAutoflowSession(e),yield n(dr(e.platformSessionId))})),sy=K("autoflows/stop",(e,t)=>k(void 0,null,function*(){let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");yield r.stopAutoflowSession(e.platformSessionId),yield n(dr(e.platformSessionId))})),rM=X({name:"autoflows",initialState:LC,reducers:{},extraReducers:e=>{e.addCase(iy.pending,(t,n)=>{let r=IC(n.meta.arg.triggerPayload)(t);r.state="Started",r.isBusy=!0}),e.addCase(sy.pending,(t,n)=>{let r=IC(n.meta.arg.triggerPayload)(t);r.state="Aborted",r.isBusy=!0}),e.addCase(dr.pending,t=>{t.fetchState="loading"}),e.addCase(dr.rejected,t=>{t.fetchState="error"}),e.addCase(dr.fulfilled,(t,n)=>{t.list=n.payload,t.fetchState="done"}),e.addCase(de,()=>LC)}}),NC=K("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(dr(e))}),o.on("sessionCompleted",()=>{n(dr(e))})}),MC=K("autoflows/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),_C=rM.reducer;var DC={list:[],fetchState:"idle",sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},FC=e=>e.customMessages.list,HC=e=>t=>!!t.customMessages.sentSuggestions.find(n=>n===e),UC=e=>t=>!!t.customMessages.answeredSuggestions.find(n=>n===e),zC=e=>t=>!!t.customMessages.errorSuggestions.find(n=>n===e),yl=K("customMessages/getAll",(e,t)=>k(void 0,null,function*(){let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(e)})),yf=K("customMessages/send",(e,t)=>k(void 0,null,function*(){let{platformSessionId:n,suggestion:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");yield o.sendCustomMessage(n,r)})),vf=K("customMessages/answer",(e,t)=>k(void 0,null,function*(){let{platformSessionId:n,reply:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");yield o.answerCustomMessage(n,r)})),BC=X({name:"customMessages",initialState:DC,reducers:{onCustomMessage(e,t){Array.isArray(t.payload)?e.list=t.payload:e.list=[t.payload]}},extraReducers:e=>{e.addCase(yl.pending,t=>{t.fetchState="loading"}).addCase(yl.rejected,t=>{t.fetchState="error"}).addCase(yl.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload||[]}).addCase(yf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.errorSuggestions=t.errorSuggestions.filter(r=>n.meta.arg.suggestion.text!==r)}).addCase(yf.rejected,(t,n)=>{let r=t.sentSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1))}).addCase(vf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(vf.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(de,()=>DC)}}),jC=K("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(BC.actions.onCustomMessage(i))})}),VC=K("customMessages/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),KC=BC.reducer;var oM={token:null,interval:null},ay=K("passwordlessToken/getTemporaryPasswordlessToken",(e,t)=>k(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return{token:yield n.requestPasswordlessToken()}})),ly=K("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(ay()),setInterval(()=>r(ay()),n)}),WC=X({name:"passwordlessToken",initialState:oM,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(ay.fulfilled,(t,n)=>{t.token=n.payload.token}),e.addCase(ly.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:$C}=WC.actions,qC=WC.reducer;var uy={outputs:[],fetchState:"idle"},GC=e=>{var t;return(t=e.assistants)==null?void 0:t.outputs},iM=Ce("assistants/resetOutputs"),Xo=K("assistants/evaluate",(e,t)=>k(void 0,null,function*(){var n,r;try{let{deepdeskAPI:o}=t.extra,i=t.getState(),{platformVariables:s}=i.info,a=(n=i.conversation.current)==null?void 0:n.id;if(!a)throw new Error("No current conversation to evaluate assistants");let l=yield o.evaluateAssistant(e.assistantCode,T({tags:((r=i.conversation.current)==null?void 0:r.tags)||void 0},e.payload),{conversationId:a});return s&&(l=l.map(u=>L(T({},u),{name:it(u.name,s),response:it(u.response,s)}))),l}catch(o){let i=o.message;return U.warn(i),t.rejectWithValue(i)}})),XC=X({name:"assistants",initialState:uy,reducers:{removeOutputByCode(e,t){e.outputs=e.outputs.filter(n=>n.code!==t.payload.code)}},extraReducers:e=>{e.addCase(Xo.pending,t=>{t.fetchState="loading"}).addCase(Xo.rejected,t=>{t.fetchState="error"}).addCase(Xo.fulfilled,(t,n)=>{let r=n.payload.map(i=>i.name),o=t.outputs.filter(i=>!r.includes(i.name));t.fetchState="done",t.outputs=[...n.payload,...o]}).addCase(de,()=>uy).addCase(iM.toString(),()=>uy)}}),{removeOutputByCode:YC}=XC.actions,QC=XC.reducer;var ZC={shouldEmit:!0},cy={cues:[],fetchState:"idle"},JC=e=>{var t;return(t=e.rules)==null?void 0:t.cues},sM=Ce("rules/resetCues"),Yo=K("rules/evaluate",(e,t)=>k(void 0,null,function*(){var n,r;try{let{deepdeskAPI:o}=t.extra,i=t.getState(),{platformVariables:s}=i.info,a=(n=i.conversation.current)==null?void 0:n.id;if(!a)throw new Error("No current conversation to evaluate rules");if(!(yield o.getAccount()).ruleEngine)throw new Error("Rule engine is not enabled for this account");if(!(yield o.getRules()).filter(d=>d.isEnabled).some(d=>d.label===e.label))throw new Error(`No enabled rules found with label: ${e.label}`);let f=yield o.evaluateRule(e.label,a,T({tags:((r=i.conversation.current)==null?void 0:r.tags)||void 0},e.params));return s&&(f=f.map(d=>L(T({},d),{title:it(d.title,s),text:it(d.text,s)}))),{cues:f,options:e.options}}catch(o){let i=o.message;return U.warn(i),t.rejectWithValue(i)}})),eT=X({name:"answer",initialState:cy,reducers:{removeCue(e,t){e.cues=e.cues.filter(n=>n.rule.id!==t.payload.id)}},extraReducers:e=>{e.addCase(Yo.pending,t=>{t.fetchState="loading"}).addCase(Yo.rejected,t=>{t.fetchState="error"}).addCase(Yo.fulfilled,(t,n)=>{let r=n.payload.cues.map(i=>i.rule.id),o=t.cues.filter(i=>!r.includes(i.rule.id));t.fetchState="done",t.cues=[...n.payload.cues,...o]}).addCase(de,()=>cy).addCase(sM.toString(),()=>cy)}}),{removeCue:tT}=eT.actions,nT=eT.reducer;function aM(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}var rT=e=>{let t=JC(e),r=GC(e).map(o=>({text:o.response,title:o.name,rule:{id:aM(o.code),label:o.code,name:o.name,description:o.name}}));return[...t,...r]};var fT=w(H());var uT=w(ie()),cT=w(H());var iT=w(ie());var oT={root:"dd-uszkm"};var aT=w(b()),lM=({className:e,children:t})=>{let n=A("Unicode",oT);return(0,aT.jsx)("span",{className:(0,iT.default)(e,n.root),children:t})},sT=lM;var lT={isDisabled:"dd-Sp--t",root:"dd-maqTG",buttonStop:"dd-rcq8w",stateBadge:"dd-zOnkT",isCompleted:"dd-GA-rt",isStarted:"dd-PZwtX",isAborted:"dd-PAXSE"};var dy={};$e(dy,{enUS:()=>uM,nlNL:()=>cM});var uM={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"}]},cM={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 At=w(b()),fM=({disabled:e,state:t,displayName:n,description:r,onStartAutoflow:o,onStopAutoflow:i})=>{let s=A("Autoflow",lT),a=q(dy),l=t==="Started"?"stop":"start",u=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,At.jsxs)(oe,{className:(0,uT.default)(s.root,{[s.isDisabled]:e,[s.isCompleted]:t==="Completed",[s.isAborted]:t==="Aborted",[s.isStarted]:t==="Started"}),children:[(0,At.jsx)(ye,{children:(0,At.jsxs)(ye.Content,{children:[(0,At.jsxs)(ye.Title,{children:[t&&(0,At.jsx)("span",{className:s.stateBadge,children:a(t)}),n]}),(0,At.jsx)("span",{children:r})]})}),(0,At.jsx)(oe.Actions,{fixed:t==="Started",children:(0,At.jsx)(oe.ActionButton,{primary:!0,className:l==="start"?s.buttonStart:s.buttonStop,onClick:t==="Started"?i:o,disabled:e,label:(0,At.jsxs)(cT.Fragment,{children:[(0,At.jsx)(sT,{children:u})," ",(0,At.jsx)("span",{children:a(l)})]})})})]})},dT=fM;var fy=w(b()),pM=(e,t)=>{let n=t.filter(r=>r.state==="Started");return n.length>0?n.indexOf(e)===-1:!1},mM=({autoflows:e,onStartAutoflow:t,onStopAutoflow:n,platformSessionId:r})=>(0,fy.jsx)(fT.Fragment,{children:e.map(o=>(0,fy.jsx)(dT,{displayName:o.displayName,description:o.description,disabled:o.isBusy||pM(o,e),state:o.state,onStartAutoflow:()=>t({platformSessionId:r,triggerPayload:o.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:r,triggerPayload:o.triggerPayload})},o.displayName))}),gM=({autoflows:e,conversation:t})=>{var n;return{autoflows:e.list,platformSessionId:(n=t.current)==null?void 0:n.sessionId}},hM={onStartAutoflow:iy,onStopAutoflow:sy},pT=qn(gM,hM)(mM);var mT=w(ie()),py=w(H());var fr={root:"dd-ERsBr",title:"dd-b36p6",isUsed:"dd-fp2IX",quickReplies:"dd--VrvP",quickReply:"dd-wFhWh",label:"dd-R9sND",errorIcon:"dd-8cdcH"};var wt=w(b()),yM=({suggestion:e})=>{let t=q(Ko),n=Y(),r=M(HC(e.text)),o=M(UC(e.text)),i=M(zC(e.text)),s=M(es),{replyOptions:a}=e,l=(0,py.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),!(r||!s)&&n(yf({platformSessionId:s,suggestion:e}))},[e,r,n,s]),u=(0,py.useCallback)(c=>{if(c.preventDefault(),c.stopPropagation(),!s||!a)return;let f=parseInt(c.target.dataset.index,10),d=a[f];n(vf({platformSessionId:s,reply:d,suggestion:e}))},[e,r,n,s]);return(0,wt.jsxs)(oe,{onClick:l,className:(0,mT.default)(fr.root,{[fr.isUsed]:r,[fr.hasError]:i}),children:[(0,wt.jsx)(ye,{children:(0,wt.jsxs)(ye.Content,{children:[(0,wt.jsxs)(ye.Title,{className:fr.title,children:[e.text," ",(0,wt.jsx)(eu,{className:fr.label,children:"analyse tool"})," ",i&&(0,wt.jsx)("span",{className:fr.errorIcon,role:"img","aria-label":t("sendingError"),title:t("sendingError"),children:"!"})]}),a&&a.length>0&&(0,wt.jsx)("ul",{className:fr.quickReplies,children:a.map(c=>(0,wt.jsx)("li",{className:fr.quickReply,children:c.title},c.title))})]})}),(0,wt.jsxs)(oe.Actions,{fixed:i||r,children:[a&&a.length>0&&(0,wt.jsx)(oe.DropdownButton,{label:t("answer"),disabled:o,children:a.map((c,f)=>(0,wt.jsx)(oe.DropdownItem,{index:f,label:c.title,onClick:u},c.title))}),(0,wt.jsx)(oe.ActionButton,{primary:!0,disabled:r,onClick:l,label:t(r?"suggestionSent":i?"tryAgain":"sendSuggestion")})]})]})},gT=yM;var Sf=w(H());var gy=w(ie());var my=w(b()),vl=()=>(0,my.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,my.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 hT={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var In=w(b()),vM=({entities:e})=>{let t=A("EntitiesWidgetList",hT),[n,r]=(0,Sf.useState)(void 0),o=Y(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),Qn(a.text),o(ot({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Sf.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,In.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,In.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,In.jsx)("span",{className:t.entityText,children:a.text}),(0,In.jsxs)("span",{className:t.iconWrapper,children:[(0,In.jsx)("span",{className:(0,gy.default)(t.icon),children:(0,In.jsx)(vl,{})}),(0,In.jsx)("span",{className:(0,gy.default)(t.icon,n===l&&t.iconClicked),children:(0,In.jsx)(vl,{})})]})]},a.text))})},yT=vM;var hy=w(b()),vT=()=>(0,hy.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,hy.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 yy=w(b()),ST=()=>(0,yy.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,yy.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 vy=w(b()),wT=()=>(0,vy.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,vy.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 UT=w(H());var Sl=w(b()),xT=({className:e})=>(0,Sl.jsxs)("svg",{viewBox:"0 0 12 12",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:e,children:[(0,Sl.jsx)("line",{x1:"2",y1:"10",x2:"10",y2:"2",stroke:"black",strokeWidth:"1"}),(0,Sl.jsx)("line",{x1:"2",y1:"2",x2:"10",y2:"10",stroke:"black",strokeWidth:"1"})]});var{entries:AT,setPrototypeOf:ET,isFrozen:SM,getPrototypeOf:wM,getOwnPropertyDescriptor:xM}=Object,{freeze:ut,seal:gn,create:LT}=Object,{apply:Cy,construct:Ty}=typeof Reflect!="undefined"&&Reflect;ut||(ut=function(t){return t});gn||(gn=function(t){return t});Cy||(Cy=function(t,n,r){return t.apply(n,r)});Ty||(Ty=function(t,n){return new t(...n)});var wf=It(Array.prototype.forEach),bT=It(Array.prototype.pop),wl=It(Array.prototype.push),bf=It(String.prototype.toLowerCase),Sy=It(String.prototype.toString),EM=It(String.prototype.match),xl=It(String.prototype.replace),bM=It(String.prototype.indexOf),CM=It(String.prototype.trim),mn=It(Object.prototype.hasOwnProperty),Lt=It(RegExp.prototype.test),El=TM(TypeError);function It(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Cy(e,t,r)}}function TM(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Ty(e,n)}}function ee(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:bf;ET&&ET(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){let i=n(o);i!==o&&(SM(t)||(t[r]=i),o=i)}e[o]=!0}return e}function kM(e){for(let t=0;t<e.length;t++)mn(e,t)||(e[t]=null);return e}function Qo(e){let t=LT(null);for(let[n,r]of AT(e))mn(e,n)&&(Array.isArray(r)?t[n]=kM(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Qo(r):t[n]=r);return t}function xf(e,t){for(;e!==null;){let r=xM(e,t);if(r){if(r.get)return It(r.get);if(typeof r.value=="function")return It(r.value)}e=wM(e)}function n(){return null}return n}var CT=ut(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),wy=ut(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),xy=ut(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),PM=ut(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ey=ut(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),RM=ut(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),TT=ut(["#text"]),kT=ut(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),by=ut(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),PT=ut(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ef=ut(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),AM=gn(/\{\{[\w\W]*|[\w\W]*\}\}/gm),LM=gn(/<%[\w\W]*|[\w\W]*%>/gm),IM=gn(/\${[\w\W]*}/gm),OM=gn(/^data-[\-\w.\u00B7-\uFFFF]/),NM=gn(/^aria-[\-\w]+$/),IT=gn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),MM=gn(/^(?:\w+script|data):/i),_M=gn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),OT=gn(/^html$/i),RT=Object.freeze({__proto__:null,MUSTACHE_EXPR:AM,ERB_EXPR:LM,TMPLIT_EXPR:IM,DATA_ATTR:OM,ARIA_ATTR:NM,IS_ALLOWED_URI:IT,IS_SCRIPT_OR_DATA:MM,ATTR_WHITESPACE:_M,DOCTYPE_NAME:OT}),DM=function(){return typeof window=="undefined"?null:window},FM=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null,o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));let i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(s){return s},createScriptURL(s){return s}})}catch(s){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function NT(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:DM(),t=j=>NT(j);if(t.version="3.0.9",t.removed=[],!e||!e.document||e.document.nodeType!==9)return t.isSupported=!1,t;let{document:n}=e,r=n,o=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:s,Node:a,Element:l,NodeFilter:u,NamedNodeMap:c=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:f,DOMParser:d,trustedTypes:p}=e,v=l.prototype,y=xf(v,"cloneNode"),g=xf(v,"nextSibling"),m=xf(v,"childNodes"),h=xf(v,"parentNode");if(typeof s=="function"){let j=n.createElement("template");j.content&&j.content.ownerDocument&&(n=j.content.ownerDocument)}let S,x="",{implementation:P,createNodeIterator:C,createDocumentFragment:R,getElementsByTagName:N}=n,{importNode:_}=r,D={};t.isSupported=typeof AT=="function"&&typeof h=="function"&&P&&P.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:G,ERB_EXPR:Z,TMPLIT_EXPR:se,DATA_ATTR:gr,ARIA_ATTR:Ot,IS_SCRIPT_OR_DATA:hr,ATTR_WHITESPACE:Nt}=RT,{IS_ALLOWED_URI:B}=RT,J=null,yr=ee({},[...CT,...wy,...xy,...Ey,...TT]),we=null,vr=ee({},[...kT,...by,...PT,...Ef]),Q=Object.seal(LT(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Sr=null,Fl=null,ni=!0,lo=!0,ks=!1,Hl=!0,Zt=!1,Jt=!1,Ul=!1,ct=!1,Mt=!1,zl=!1,Bl=!1,zy=!0,By=!1,Bk="user-content-",_f=!0,Ps=!1,ri={},oi=null,jy=ee({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Vy=null,Ky=ee({},["audio","video","img","source","image","track"]),Df=null,Wy=ee({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),jl="http://www.w3.org/1998/Math/MathML",Vl="http://www.w3.org/2000/svg",_n="http://www.w3.org/1999/xhtml",ii=_n,Ff=!1,Hf=null,jk=ee({},[jl,Vl,_n],Sy),Rs=null,Vk=["application/xhtml+xml","text/html"],Kk="text/html",De=null,si=null,Wk=n.createElement("form"),$y=function(E){return E instanceof RegExp||E instanceof Function},Uf=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(si&&si===E)){if((!E||typeof E!="object")&&(E={}),E=Qo(E),Rs=Vk.indexOf(E.PARSER_MEDIA_TYPE)===-1?Kk:E.PARSER_MEDIA_TYPE,De=Rs==="application/xhtml+xml"?Sy:bf,J=mn(E,"ALLOWED_TAGS")?ee({},E.ALLOWED_TAGS,De):yr,we=mn(E,"ALLOWED_ATTR")?ee({},E.ALLOWED_ATTR,De):vr,Hf=mn(E,"ALLOWED_NAMESPACES")?ee({},E.ALLOWED_NAMESPACES,Sy):jk,Df=mn(E,"ADD_URI_SAFE_ATTR")?ee(Qo(Wy),E.ADD_URI_SAFE_ATTR,De):Wy,Vy=mn(E,"ADD_DATA_URI_TAGS")?ee(Qo(Ky),E.ADD_DATA_URI_TAGS,De):Ky,oi=mn(E,"FORBID_CONTENTS")?ee({},E.FORBID_CONTENTS,De):jy,Sr=mn(E,"FORBID_TAGS")?ee({},E.FORBID_TAGS,De):{},Fl=mn(E,"FORBID_ATTR")?ee({},E.FORBID_ATTR,De):{},ri=mn(E,"USE_PROFILES")?E.USE_PROFILES:!1,ni=E.ALLOW_ARIA_ATTR!==!1,lo=E.ALLOW_DATA_ATTR!==!1,ks=E.ALLOW_UNKNOWN_PROTOCOLS||!1,Hl=E.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Zt=E.SAFE_FOR_TEMPLATES||!1,Jt=E.WHOLE_DOCUMENT||!1,Mt=E.RETURN_DOM||!1,zl=E.RETURN_DOM_FRAGMENT||!1,Bl=E.RETURN_TRUSTED_TYPE||!1,ct=E.FORCE_BODY||!1,zy=E.SANITIZE_DOM!==!1,By=E.SANITIZE_NAMED_PROPS||!1,_f=E.KEEP_CONTENT!==!1,Ps=E.IN_PLACE||!1,B=E.ALLOWED_URI_REGEXP||IT,ii=E.NAMESPACE||_n,Q=E.CUSTOM_ELEMENT_HANDLING||{},E.CUSTOM_ELEMENT_HANDLING&&$y(E.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Q.tagNameCheck=E.CUSTOM_ELEMENT_HANDLING.tagNameCheck),E.CUSTOM_ELEMENT_HANDLING&&$y(E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Q.attributeNameCheck=E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),E.CUSTOM_ELEMENT_HANDLING&&typeof E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Q.allowCustomizedBuiltInElements=E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Zt&&(lo=!1),zl&&(Mt=!0),ri&&(J=ee({},TT),we=[],ri.html===!0&&(ee(J,CT),ee(we,kT)),ri.svg===!0&&(ee(J,wy),ee(we,by),ee(we,Ef)),ri.svgFilters===!0&&(ee(J,xy),ee(we,by),ee(we,Ef)),ri.mathMl===!0&&(ee(J,Ey),ee(we,PT),ee(we,Ef))),E.ADD_TAGS&&(J===yr&&(J=Qo(J)),ee(J,E.ADD_TAGS,De)),E.ADD_ATTR&&(we===vr&&(we=Qo(we)),ee(we,E.ADD_ATTR,De)),E.ADD_URI_SAFE_ATTR&&ee(Df,E.ADD_URI_SAFE_ATTR,De),E.FORBID_CONTENTS&&(oi===jy&&(oi=Qo(oi)),ee(oi,E.FORBID_CONTENTS,De)),_f&&(J["#text"]=!0),Jt&&ee(J,["html","head","body"]),J.table&&(ee(J,["tbody"]),delete Sr.tbody),E.TRUSTED_TYPES_POLICY){if(typeof E.TRUSTED_TYPES_POLICY.createHTML!="function")throw El('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof E.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw El('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=E.TRUSTED_TYPES_POLICY,x=S.createHTML("")}else S===void 0&&(S=FM(p,o)),S!==null&&typeof x=="string"&&(x=S.createHTML(""));ut&&ut(E),si=E}},qy=ee({},["mi","mo","mn","ms","mtext"]),Gy=ee({},["foreignobject","desc","title","annotation-xml"]),$k=ee({},["title","style","font","a","script"]),Xy=ee({},[...wy,...xy,...PM]),Yy=ee({},[...Ey,...RM]),qk=function(E){let O=h(E);(!O||!O.tagName)&&(O={namespaceURI:ii,tagName:"template"});let z=bf(E.tagName),me=bf(O.tagName);return Hf[E.namespaceURI]?E.namespaceURI===Vl?O.namespaceURI===_n?z==="svg":O.namespaceURI===jl?z==="svg"&&(me==="annotation-xml"||qy[me]):!!Xy[z]:E.namespaceURI===jl?O.namespaceURI===_n?z==="math":O.namespaceURI===Vl?z==="math"&&Gy[me]:!!Yy[z]:E.namespaceURI===_n?O.namespaceURI===Vl&&!Gy[me]||O.namespaceURI===jl&&!qy[me]?!1:!Yy[z]&&($k[z]||!Xy[z]):!!(Rs==="application/xhtml+xml"&&Hf[E.namespaceURI]):!1},uo=function(E){wl(t.removed,{element:E});try{E.parentNode.removeChild(E)}catch(O){E.remove()}},zf=function(E,O){try{wl(t.removed,{attribute:O.getAttributeNode(E),from:O})}catch(z){wl(t.removed,{attribute:null,from:O})}if(O.removeAttribute(E),E==="is"&&!we[E])if(Mt||zl)try{uo(O)}catch(z){}else try{O.setAttribute(E,"")}catch(z){}},Qy=function(E){let O=null,z=null;if(ct)E="<remove></remove>"+E;else{let We=EM(E,/^[\r\n\t ]+/);z=We&&We[0]}Rs==="application/xhtml+xml"&&ii===_n&&(E='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+E+"</body></html>");let me=S?S.createHTML(E):E;if(ii===_n)try{O=new d().parseFromString(me,Rs)}catch(We){}if(!O||!O.documentElement){O=P.createDocument(ii,"template",null);try{O.documentElement.innerHTML=Ff?x:me}catch(We){}}let Ke=O.body||O.documentElement;return E&&z&&Ke.insertBefore(n.createTextNode(z),Ke.childNodes[0]||null),ii===_n?N.call(O,Jt?"html":"body")[0]:Jt?O.documentElement:Ke},Zy=function(E){return C.call(E.ownerDocument||E,E,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT,null)},Gk=function(E){return E instanceof f&&(typeof E.nodeName!="string"||typeof E.textContent!="string"||typeof E.removeChild!="function"||!(E.attributes instanceof c)||typeof E.removeAttribute!="function"||typeof E.setAttribute!="function"||typeof E.namespaceURI!="string"||typeof E.insertBefore!="function"||typeof E.hasChildNodes!="function")},Jy=function(E){return typeof a=="function"&&E instanceof a},Dn=function(E,O,z){D[E]&&wf(D[E],me=>{me.call(t,O,z,si)})},ev=function(E){let O=null;if(Dn("beforeSanitizeElements",E,null),Gk(E))return uo(E),!0;let z=De(E.nodeName);if(Dn("uponSanitizeElement",E,{tagName:z,allowedTags:J}),E.hasChildNodes()&&!Jy(E.firstElementChild)&&Lt(/<[/\w]/g,E.innerHTML)&&Lt(/<[/\w]/g,E.textContent))return uo(E),!0;if(!J[z]||Sr[z]){if(!Sr[z]&&nv(z)&&(Q.tagNameCheck instanceof RegExp&&Lt(Q.tagNameCheck,z)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck(z)))return!1;if(_f&&!oi[z]){let me=h(E)||E.parentNode,Ke=m(E)||E.childNodes;if(Ke&&me){let We=Ke.length;for(let dt=We-1;dt>=0;--dt)me.insertBefore(y(Ke[dt],!0),g(E))}}return uo(E),!0}return E instanceof l&&!qk(E)||(z==="noscript"||z==="noembed"||z==="noframes")&&Lt(/<\/no(script|embed|frames)/i,E.innerHTML)?(uo(E),!0):(Zt&&E.nodeType===3&&(O=E.textContent,wf([G,Z,se],me=>{O=xl(O,me," ")}),E.textContent!==O&&(wl(t.removed,{element:E.cloneNode()}),E.textContent=O)),Dn("afterSanitizeElements",E,null),!1)},tv=function(E,O,z){if(zy&&(O==="id"||O==="name")&&(z in n||z in Wk))return!1;if(!(lo&&!Fl[O]&&Lt(gr,O))){if(!(ni&&Lt(Ot,O))){if(!we[O]||Fl[O]){if(!(nv(E)&&(Q.tagNameCheck instanceof RegExp&&Lt(Q.tagNameCheck,E)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck(E))&&(Q.attributeNameCheck instanceof RegExp&&Lt(Q.attributeNameCheck,O)||Q.attributeNameCheck instanceof Function&&Q.attributeNameCheck(O))||O==="is"&&Q.allowCustomizedBuiltInElements&&(Q.tagNameCheck instanceof RegExp&&Lt(Q.tagNameCheck,z)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck(z))))return!1}else if(!Df[O]){if(!Lt(B,xl(z,Nt,""))){if(!((O==="src"||O==="xlink:href"||O==="href")&&E!=="script"&&bM(z,"data:")===0&&Vy[E])){if(!(ks&&!Lt(hr,xl(z,Nt,"")))){if(z)return!1}}}}}}return!0},nv=function(E){return E!=="annotation-xml"&&E.indexOf("-")>0},rv=function(E){Dn("beforeSanitizeAttributes",E,null);let{attributes:O}=E;if(!O)return;let z={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:we},me=O.length;for(;me--;){let Ke=O[me],{name:We,namespaceURI:dt,value:co}=Ke,As=De(We),ft=We==="value"?co:CM(co);if(z.attrName=As,z.attrValue=ft,z.keepAttr=!0,z.forceKeepAttr=void 0,Dn("uponSanitizeAttribute",E,z),ft=z.attrValue,z.forceKeepAttr||(zf(We,E),!z.keepAttr))continue;if(!Hl&&Lt(/\/>/i,ft)){zf(We,E);continue}Zt&&wf([G,Z,se],iv=>{ft=xl(ft,iv," ")});let ov=De(E.nodeName);if(tv(ov,As,ft)){if(By&&(As==="id"||As==="name")&&(zf(We,E),ft=Bk+ft),S&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!dt)switch(p.getAttributeType(ov,As)){case"TrustedHTML":{ft=S.createHTML(ft);break}case"TrustedScriptURL":{ft=S.createScriptURL(ft);break}}try{dt?E.setAttributeNS(dt,We,ft):E.setAttribute(We,ft),bT(t.removed)}catch(iv){}}}Dn("afterSanitizeAttributes",E,null)},Xk=function j(E){let O=null,z=Zy(E);for(Dn("beforeSanitizeShadowDOM",E,null);O=z.nextNode();)Dn("uponSanitizeShadowNode",O,null),!ev(O)&&(O.content instanceof i&&j(O.content),rv(O));Dn("afterSanitizeShadowDOM",E,null)};return t.sanitize=function(j){let E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},O=null,z=null,me=null,Ke=null;if(Ff=!j,Ff&&(j="<!-->"),typeof j!="string"&&!Jy(j))if(typeof j.toString=="function"){if(j=j.toString(),typeof j!="string")throw El("dirty is not a string, aborting")}else throw El("toString is not a function");if(!t.isSupported)return j;if(Ul||Uf(E),t.removed=[],typeof j=="string"&&(Ps=!1),Ps){if(j.nodeName){let co=De(j.nodeName);if(!J[co]||Sr[co])throw El("root node is forbidden and cannot be sanitized in-place")}}else if(j instanceof a)O=Qy("<!---->"),z=O.ownerDocument.importNode(j,!0),z.nodeType===1&&z.nodeName==="BODY"||z.nodeName==="HTML"?O=z:O.appendChild(z);else{if(!Mt&&!Zt&&!Jt&&j.indexOf("<")===-1)return S&&Bl?S.createHTML(j):j;if(O=Qy(j),!O)return Mt?null:Bl?x:""}O&&ct&&uo(O.firstChild);let We=Zy(Ps?j:O);for(;me=We.nextNode();)ev(me)||(me.content instanceof i&&Xk(me.content),rv(me));if(Ps)return j;if(Mt){if(zl)for(Ke=R.call(O.ownerDocument);O.firstChild;)Ke.appendChild(O.firstChild);else Ke=O;return(we.shadowroot||we.shadowrootmode)&&(Ke=_.call(r,Ke,!0)),Ke}let dt=Jt?O.outerHTML:O.innerHTML;return Jt&&J["!doctype"]&&O.ownerDocument&&O.ownerDocument.doctype&&O.ownerDocument.doctype.name&&Lt(OT,O.ownerDocument.doctype.name)&&(dt="<!DOCTYPE "+O.ownerDocument.doctype.name+`>
23
+ 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 Kh=w(b()),vN={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Ub=({className:e,color:t})=>(0,Kh.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Kh.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:vN[t||"pink"]})});var zb={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var Wh={};$e(Wh,{enUS:()=>SN,nlNL:()=>wN});var SN={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},wN={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Wo=w(b()),jb=({onLogIn:e})=>{let t=q(Wh),n=V("floatingMenu"),r=V("productName"),o=Y(),i=M(rt),s=A("FloatingMenu",zb);if(i===null||n===!1)return null;let a=()=>{i===!0?o(Tt(!0)):e()};return(0,Wo.jsxs)("button",{className:(0,Bb.default)(s.root,{[s.isLoggedIn]:i,[s.isLoggedOut]:!i}),onClick:a,children:[(0,Wo.jsx)("div",{className:s.text,children:t(i?"search":"signin",{productName:r})}),(0,Wo.jsxs)("div",{className:s.icon,children:[(0,Wo.jsx)(Ub,{className:s.logo,color:"pink"}),i===!1&&(0,Wo.jsx)(Hb,{className:s.lock})]})]})};var Zd=w(H());var Vb=w(H());function Jr(e){(0,Vb.useEffect)(()=>{let t=n=>{n.isWithinRoot||e(n)};return document.body.addEventListener("mouseup",t),()=>{document.body.removeEventListener("mouseup",t)}},[e])}function $o(e){e.addEventListener("mouseup",t=>{t.isWithinRoot=!0},!0)}function An(e){let{showMidSentenceSuggestions:t,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:r}=e.settings,{text:o,selection:i}=e.input;return i.start!==i.end?!1:i.end>=o.length?!0:t?n&&new RegExp(n).test(o.substring(i.end))||r&&new RegExp(r).test(o.substring(0,i.end))?!0:n===!1&&r===!1:!1}var xN={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Gd=({ui:e})=>e.overlayCollapsed,Kb=X({name:"ui",initialState:xN,reducers:{setShowTabHint(e,t){e.showTabHint=t.payload},setInputFocus(e,t){e.overlayCollapsedUserOverwrite!==!0&&(t.payload===!0&&(e.overlayCollapsed=!1),e.inputHasFocus=t.payload)},setOverlayCollapsed(e,t){t.payload.collapse===!1&&(e.openOverlayWhenTyping=!1),!(t.payload.skipWhenInputFocus&&e.inputHasFocus)&&(e.overlayCollapsed=t.payload.collapse)},setOpenOverlayWhenTyping(e,t){e.openOverlayWhenTyping=t.payload},setOverlayCollapsedUserOverwrite(e,t){e.overlayCollapsedUserOverwrite=t.payload,e.overlayCollapsed=t.payload}}}),{setShowTabHint:pl,setInputFocus:Xd,setOverlayCollapsed:eo,setOpenOverlayWhenTyping:Wb,setOverlayCollapsedUserOverwrite:$b}=Kb.actions,qb=Kb.reducer;var Yd=w(H());var gs=w(H());var Gb=w(H());function Xb(e,t,n){(0,Gb.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var Yb={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var qo=w(b()),bN=["search","personal-collection-search","search-autocomplete"];function CN(e,t,n,r={}){var i;let o="";return bN.includes(t)?o=ME(Ah(e,n,{stripAgentPart:!0}),(i=r.searchKeywords)!=null?i:[n]):o=Ah(e,n,r),r.placeholders===!0&&(o=_E(o)),o}var TN=()=>{},kN=({selected:e,suggestion:t})=>{let n=V("inlineSuggestions"),r=M(ns),o=V("enableSuggestionFeedback"),i=M(c=>c.input.text),s=Y(),a=A("TextSuggestion",Yb),l=(0,gs.useRef)(null);(0,gs.useEffect)(()=>{let c=setTimeout(()=>{s(L1({text:t.text,suggestion:t}))},500);return()=>{clearTimeout(c)}},[t]),Xb(l,"click",()=>{s(on({suggestion:t,text:t.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let u=(0,gs.useMemo)(()=>CN(t.text,t.source,r,{stripAgentPart:n,placeholders:!0,searchKeywords:t.searchKeywords}),[n,t.text,t.source,r,t.searchKeywords]);return t.source==="gpt"&&!n?null:(0,qo.jsxs)("div",{className:a.root,children:[(0,qo.jsx)(oe,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:TN,children:(0,qo.jsx)(is,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:u})}),e&&o&&(0,qo.jsx)("div",{className:a.actions,children:(0,qo.jsx)($d,{source:"overlay",context:i,suggestion:t})})]})},Qb=kN;var $h=w(b()),PN=({suggestions:e,selectedIndex:t,reverse:n})=>{let r=(0,Yd.useMemo)(()=>{let o=e.map((i,s)=>(0,$h.jsx)(Qb,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]);return(0,$h.jsx)(Yd.Fragment,{children:r})},Qd=PN;var Zb={root:"dd-PfvRI",paper:"dd-HYlyY"};var ml=w(b()),RN=({textSuggestions:e,selectedIndex:t})=>{let n=(0,Zd.useRef)(null),r=A("InlineSuggestionsOverlay",Zb),o=M(An),i=Y(),s=M(rt),a=M(ts),l=M(Gd),u=V("showTextSuggestions");return Jr(()=>{setTimeout(()=>{i(eo({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Zd.useEffect)(()=>{let c=n.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let f=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-f.right,0)}px`}),l||!o||!u||e.length===0||s!==!0||a===!1?null:(0,ml.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,ml.jsx)("div",{ref:n,className:r.paper,children:(0,ml.jsx)(gt,{children:(0,ml.jsx)(Qd,{suggestions:e,selectedIndex:t})})})})},AN=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),Jb=qn(AN)(RN);var gl=w(b()),LN=({children:e})=>{let n=V("locale").replace("-","");return(0,gl.jsx)(mh.Provider,{value:n,children:e})},IN=({store:e,customStyles:t={},children:n})=>(0,gl.jsx)(qg,{store:e,children:(0,gl.jsx)(LN,{children:(0,gl.jsx)(Os.Provider,{value:t,children:n})})}),Go=IN;var ef=w(ie()),hs=w(H());var eC=w(H());function tC(e,t){let[n,r]=(0,eC.useState)(()=>{if(typeof window=="undefined")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return U.error(i),t}});return[n,i=>{try{let s=i instanceof Function?i(n):i;r(s),typeof window!="undefined"&&window.localStorage.setItem(e,JSON.stringify(s))}catch(s){U.error(s)}}]}var nC=()=>/Mac/i.test(navigator.platform);var oC=w(ie()),sr=w(H());var qh={};$e(qh,{enUS:()=>ON,nlNL:()=>NN});var ON={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"}]}]},NN={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 rC={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var to=w(b()),Gh=(e,t,n)=>r=>(0,to.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),MN=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=q(qh),s=$t(),a=A("Login",rC),l=V("productName"),u=(0,sr.useCallback)(g=>{g.preventDefault(),r&&r(parseInt(g.target.value,10))},[]),c=(0,sr.useCallback)(g=>{g.preventDefault(),s.send(os,!0)},[t]),f=(0,sr.useMemo)(()=>g=>(0,to.jsx)("a",{onClick:h=>{h.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[t]),d=(0,sr.useCallback)(g=>(0,to.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:p,hour:v,day:y}=(0,sr.useMemo)(()=>({min:Gh(a,60*10,u),hour:Gh(a,60*60,u),day:Gh(a,60*60*12,u)}),[]);return(0,to.jsxs)("div",{className:(0,oC.default)(e,a.root),children:[i("loginPlease",{login:n?d:f,productName:l}),r&&(0,to.jsxs)(sr.Fragment,{children:[(0,to.jsx)("br",{}),i("snooze",{min:p,hour:v,day:y})]})]})},Jd=MN;var iC={root:"dd-DoQhb",text:"dd-Jwnev"};var hl=w(b()),_N=({title:e})=>{let t=A("SearchTrigger",iC),n=Y();return(0,hl.jsxs)("button",{type:"button",className:t.root,onClick:()=>n(Tt(!0)),children:[(0,hl.jsx)(ls,{}),(0,hl.jsx)("span",{className:t.text,children:e})]})},sC=_N;var Xh={};$e(Xh,{enUS:()=>DN,nlNL:()=>FN});var DN={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"}]},FN={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 aC={root:"dd-oa7Vc",isInline:"dd-bwk31",toggleButton:"dd-MSB8Z",toggleButtonWrapper:"dd-ZkCzT",toggleButtonWrapperHidden:"dd-Sq66c",isCollapsed:"dd-vkrPk",collapsible:"dd-CWQJe",hints:"dd-IOoo3",hintsHidden:"dd-psVuT",triggers:"dd-toIoo",triggersRight:"dd-mc4l2"};var be=w(b()),HN=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=A("SuggestionsOverlay",aC),o=q(Xh),i=M(An),s=A1(),a=Y(),l=(0,hs.useRef)(null),u=V("searchTriggerKey"),c=V("productName"),f=M(Gd),d=M(rt),p=M(ts),[v,y]=(0,hs.useState)(null),g=V("showSearch"),m=V("showTextSuggestions"),h=V("adminUrl"),S=V("isEmbedded"),[x,P]=tC("dd-snooze-until-ms",0),C=f||x>Date.now(),R=e.filter(D=>D.source!=="gpt").length,N=()=>{C&&P(0),a($b(!C))},_=D=>{let G=Date.now()+D*1e3;P(G),U.info(`Snooze until: ${new Date(G)}`),a(eo({collapse:!0}))};return(0,hs.useEffect)(()=>{R===0&&y(null)},[e,R]),Jr(()=>{a(eo({collapse:!0,skipWhenInputFocus:!0}))}),d===null||p===!1?null:d===!1?(0,be.jsxs)("div",{ref:l,className:(0,ef.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,be.jsxs)("div",{className:r.triggers,children:[(0,be.jsx)("div",{style:{flex:1}}),(0,be.jsx)("div",{className:r.triggersRight,children:(0,be.jsx)(mo,{className:r.toggleButton,title:o("collapse"),onClick:N,isCollapsed:!1})})]}),(0,be.jsx)("div",{className:r.toggleButtonWrapper,children:(0,be.jsx)(mo,{className:r.toggleButton,title:o("open",{productName:c}),onClick:N,isCollapsed:!0})}),(0,be.jsx)("div",{className:r.collapsible,children:(0,be.jsx)(Jd,{loginUrl:h,isEmbedded:S,onLogIn:n,onSnooze:_})})]}):!s||!i?null:(0,be.jsxs)("div",{ref:l,className:(0,ef.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,be.jsxs)("div",{className:r.triggers,children:[(0,be.jsx)("div",{style:{flex:1},children:g&&(0,be.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>y(o(nC()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>y(null),children:(0,be.jsx)(sC,{title:o("search")})})}),(0,be.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,be.jsx)("div",{className:(0,ef.default)(!v&&r.hintsHidden,r.hints),children:v}),(0,be.jsx)(mo,{className:r.toggleButton,title:o("collapse"),onClick:N,isCollapsed:!1})]})]}),(0,be.jsx)("div",{className:r.toggleButtonWrapper,children:(0,be.jsx)(mo,{className:r.toggleButton,title:o("open",{productName:c}),onClick:N,isCollapsed:!0})}),R>0&&m&&(0,be.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,be.jsx)(gt,{children:(0,be.jsx)(Qd,{suggestions:e,selectedIndex:t,reverse:!0})})})]})},UN=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),lC=qn(UN)(HN);var hf=w(ie());var cr=w(H());var ys=w(H());function tf(e){return e.contentEditable==="true"}function zN(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 uC(e){let{selectionStart:t,selectionEnd:n}=tf(e)?zN(e):e;return[t,n]}function cC(e){let[,t]=(0,ys.useState)(),n=(0,ys.useRef)(null);return n.current=uC(e),(0,ys.useEffect)(()=>{let r=()=>{var a;let[o,i]=(a=n.current)!=null?a:[],s=uC(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 dC(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(ru);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 fC=w(H()),BN=["div","span","mark","strong","b","i","u","em"];function Yh(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(BN.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,fC.cloneElement)(r,{children:Yh(s,t,n+1)})]}return[...e,...t]}function no(e){return e.tagName.toLowerCase()==="textarea"}var pC={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var bC=w(ie());var df=w(H());var vs=w(H());function mC(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function nf(e){let t=(0,vs.useRef)(null),[n,r]=(0,vs.useState)(!1);return(0,vs.useEffect)(()=>{var c;let o=!1,i=parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[s,a]=mC((f,d)=>{let p=t.current;if(!p)return;let v=f/i,y=d/i,g=p.getBoundingClientRect(),m=v>g.x&&v<g.x+g.width&&y>g.y&&y<g.y+g.height;m&&!o?(o=!0,r(!0)):!m&&o&&(o=!1,r(!1))},({clientX:f,clientY:d})=>[f,d]),[l,u]=mC(()=>{o=!1,r(!1)});return e.addEventListener("mousemove",s),e.addEventListener("mouseleave",l),()=>{a(),u(),e.removeEventListener("mousemove",s),e.removeEventListener("mouseleave",l)}},[t]),[t,n]}function gC(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function rf(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function hC(e){return e!=null}var Zh=w(ie()),Gt=w(H());var of=w(H()),jN=["bottom","height","left","right","top","width"],VN=(e={},t={})=>jN.some(n=>e[n]!==t[n]),ar=new Map,yC,vC=()=>{let e=[],t=[];ar.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();VN(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{ar.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),yC=window.requestAnimationFrame(vC)};function KN(e,t){return{observe(){let n=ar.size===0;if(ar.has(e)){let r=ar.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else ar.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&vC()},unobserve(){let n=ar.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||ar.delete(e),ar.size||cancelAnimationFrame(yC)}}}}function Qh(e){let[t,n]=(0,of.useState)(null);return(0,of.useLayoutEffect)(()=>{if(!e.current)return;let r=KN(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var Ss=w(H()),wC=w(yc());var SC={root:"dd-r-dgo"};var xC=({children:e,parentNode:t})=>{let[n,r]=(0,Ss.useState)(null),o=(0,Ss.useContext)(Os);return(0,Ss.useLayoutEffect)(()=>{let i=document.createElement("div");return $o(i),i.classList.add(SC.root),o!=null&&o.portalRootNode&&i.classList.add(o==null?void 0:o.portalRootNode),(t||document.body).appendChild(i),r(i),()=>{i.isConnected&&i.remove()}},[]),n?(0,wC.createPortal)(e,n):null};var Ln={ref:"dd-iz-KP",root:"dd-vEMon",positionAbove:"dd-mUCxM",positionBelow:"dd-7oZI7",positionLeft:"dd-BiWvD",positionRight:"dd-JIWea",alignStart:"dd-5ivu6",alignCenter:"dd-rnVkP",alignEnd:"dd-gZBp4"};var sf=w(b()),af=(e=!1)=>{let[t,n]=(0,Gt.useState)(e),r=(0,Gt.useCallback)(()=>n(!0),[]),o=(0,Gt.useCallback)(()=>n(!1),[]),i=(0,Gt.useCallback)(()=>n(a=>!a),[]),s=(0,Gt.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function Jh(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 ws=u=>{var c=u,{className:e,triggerRef:t,boundaryRef:n=(0,Gt.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=Jh,parentNode:a}=c,l=ne(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let f=Qh(t),d=Qh(n),p=(0,Gt.useMemo)(()=>s(f,d,0),[f,d]);return(0,sf.jsx)(xC,{parentNode:a,children:(0,sf.jsx)("div",L(T({className:(0,Zh.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:p},l),{role:"dialog",children:(0,sf.jsx)("div",{className:(0,Zh.default)(e,Ln.root),children:i})}))})};var EC=w(ie()),lf=w(H());var lr={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var ey=w(b()),uf=(0,lf.forwardRef)((o,r)=>{var i=o,{className:e,children:t}=i,n=ne(i,["className","children"]);let s=(0,lf.useRef)(null),a=A("TabCompletion",lr);return(0,ey.jsx)("div",L(T({ref:rf([s,r]),className:(0,EC.default)(e,a.popoverContentContainer)},n),{children:(0,ey.jsx)("div",{className:a.popoverContent,children:t})}))});var ro=w(b()),WN=e=>t=>{let n=Jh(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},$N=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=A("TabCompletion",lr),s=af(),a=(0,df.useMemo)(()=>WN(e.getBoundingClientRect()),[e]),[l,u]=nf(e);return(0,df.useEffect)(()=>{u?s.open():s.close()},[u]),(0,ro.jsxs)("span",{children:[(0,ro.jsx)("mark",{ref:rf([l,s.triggerRef]),className:(0,bC.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,ro.jsx)(ws,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,ro.jsx)(uf,{style:n,children:(0,ro.jsx)("div",{className:i.hintText,children:o})})})]})},cf=class extends Jn{constructor(){super(...arguments);this.keywordMatches=[];this.preparedKeywordMatches=[];this.usedKeywordMatches=new Set}onBeforeParse(n,r){return r.keywordMatches&&r.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=r.keywordMatches.map(o=>L(T({},o),{keywordRegex:new RegExp(`\\b${gC(o.keyword)}\\b`,"i")})),this.keywordMatches=r.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let r=this.preparedKeywordMatches.map(i=>{if(this.usedKeywordMatches.has(i))return null;let s=n.match(i.keywordRegex);if(!s)return null;let a=n.charAt(s.index-1),l=n.charAt(s.index+i.keyword.length);return a==="{"&&l==="}"?null:{index:s.index,length:s[0].length,match:s[0],matchString:s[0],suggestion:i.suggestion,preparedKeywordMatch:i,valid:!0}}).filter(hC);if(r.length===0)return null;let o=r.reduce((i,s)=>s.index<i.index?s:i);return this.usedKeywordMatches.add(o.preparedKeywordMatch),o}replaceWith(n,r){return(0,ro.jsx)($N,{inputElement:r.inputElement,suggestion:r.suggestion,inputStyle:r.inputStyle,boundaryRef:r.boundaryRef,children:n},`keyword_${r.matchString}_${r.key}`)}asTag(){return"mark"}};var CC=w(ie());var ty=w(b()),qN=({inputElement:e,children:t})=>{let n=A("TabCompletion",lr),[r,o]=nf(e);return(0,ty.jsx)("mark",{ref:r,className:(0,CC.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},ff=class extends Jn{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,ty.jsx)(qN,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var mf=w(ie());var lt=w(H());var ny=w(b()),TC=()=>(0,ny.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,ny.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 oo=w(H());var PC=w(Sh());var kC={root:"dd-ky-Bv",content:"dd-kV5e1"};function pf(e,t,n){var o;let r=((o=e.imageSizes)==null?void 0:o[t])||e.image||n;if(!r)return null;try{return new URL(r).toString()}catch(i){return null}}function ry(e){return e.replace("https://www.","").replace("https://","")}var Xt=w(b()),GN=3,XN=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),YN=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=GN})=>{let i=A("LinkSearch",kC),[s,a]=(0,oo.useState)(""),l=Y(),u=M(bb("url")),c=M(Q1("URL",XN)),[f,d]=(0,oo.useState)(c.length-1),p=V("fallbackImage"),v=h=>{let S=h.target;a(S.value)},y=(h,S)=>{h.stopPropagation(),h.preventDefault(),window.open(S,"_blank")},g=h=>{var P;let S=f-1<0?c.length-1:f-1,x=f+1===c.length?0:f+1;h.code==="Escape"&&(a(""),t()),h.code==="ArrowUp"&&d(S),h.code==="ArrowDown"&&d(x),h.code==="Enter"&&e(((P=c[f])==null?void 0:P.text)||s)},m=(0,oo.useCallback)((0,PC.default)(h=>{l(No({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,oo.useEffect)(()=>{s&&m(s)},[s]),(0,oo.useEffect)(()=>()=>{l(dd())},[]),(0,Xt.jsxs)("div",{className:i.root,children:[(0,Xt.jsx)(gt,{withDivider:!0,children:(s?c:u).slice(0,o).map((h,S)=>(0,Xt.jsx)(oe,{selected:f===S,onClick:()=>e(h.text),"data-testid":"linksearch-suggestion",children:(0,Xt.jsxs)(ye,{children:[(0,Xt.jsx)(ye.Image,{src:pf(h,"small",p||void 0),title:h.title||h.text}),(0,Xt.jsxs)(ye.Content,{className:i.content,cropText:!0,children:[(0,Xt.jsx)(ye.Title,{children:h.title||ry(h.text)}),h.title&&ry(h.text)]}),(0,Xt.jsx)(oe.Actions,{children:(0,Xt.jsx)(oe.ActionButton,{label:r,onClick:x=>y(x,h.text)})})]})},h.text))}),(0,Xt.jsx)(Ya,{value:s,onChange:v,autoFocus:!0,placeholder:n,onKeyUp:g})]})},RC=YN;var oy={};$e(oy,{enUS:()=>QN,nlNL:()=>ZN});var QN={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},ZN={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var at=w(b()),JN=(0,lt.forwardRef)((e,t)=>{let n=A("TabCompletion",lr);return(0,at.jsx)("mark",{ref:t,className:(0,mf.default)(n.matchSelection)},"selection-start")}),eM=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=q(oy),s=A("TabCompletion",lr),a=(0,lt.useRef)(null),l=(0,lt.useRef)(null),[u,c]=(0,lt.useState)(null),f=Y(),d=af(document.activeElement===r),[p]=(0,lt.useState)(()=>document.createRange());d.triggerRef.current=p,(0,lt.useEffect)(()=>()=>p.detach(),[]),(0,lt.useEffect)(()=>{let y=e.current,g=a.current;!y||!g||(p.setStart(y,0),p.setEnd(g,0))},[e.current,a.current]),Jr(()=>{d.close()});let v=(0,lt.useCallback)(y=>{let g=p.toString(),m=/^http(s?):\/\//.test(y)?y:`https://${y}`;f(id({text:`[${g}](${m})`,replace:"selection"}))},[]);return(0,at.jsxs)("span",{children:[(0,at.jsx)("mark",{ref:a,className:(0,mf.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,at.jsx)(ws,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,at.jsxs)(uf,{style:n,ref:l,children:[(0,at.jsx)("div",{className:(0,mf.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,at.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,at.jsx)(TC,{}),(0,at.jsx)("span",{children:"\xA0"}),(0,at.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,at.jsx)(RC,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:v,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},gf=class extends Jn{constructor(){super(...arguments);this.charCount=0;this.foundIndex=0;this.startRef=null}onBeforeParse(n,r){return this.props=r,this.charCount=0,this.startRef=(0,lt.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[r,o]=this.props.selection;if(r===o)return null;let i=this.foundIndex===0?r:o,s=i>=this.charCount&&i<=this.charCount+n.length?{index:i-this.charCount,length:0,match:"",valid:!0}:null;s&&this.foundIndex++;let a=this.foundIndex===1;return s&&a?this.charCount+=i-this.charCount:this.charCount+=n.length,s?T({isStart:a},s):null}replaceWith(n,r){return r.isStart?(0,at.jsx)(JN,{ref:this.startRef}):(0,at.jsx)(eM,{inputElement:r.inputElement,startRef:this.startRef,boundaryRef:r.boundaryRef,inputStyle:r.inputStyle})}asTag(){return"mark"}};var ur=w(b()),tM=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=A("TabCompletion",pC),c=V("insertLink"),f=V("showMidSentenceSuggestions"),d=V("inlineSuggestions"),p=cC(a),v=(0,cr.useRef)(null),y=M(rt);(0,cr.useEffect)(()=>{no(a)&&p&&dC(a,p)},[p]);let g=(0,cr.useCallback)(S=>{if(!o||!n)return S;let x=[(0,ur.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,ur.jsx)("span",{"data-testid":"tab-completion",className:(0,hf.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&x.push((0,ur.jsx)("span",{className:(0,hf.default)(u.hint,u.resetIndent),children:(0,ur.jsx)(Jl,{keyCode:"tab"},"tabHint")})),Yh(S,x)},[o,n,r]),m=(0,cr.useMemo)(()=>{let S=[];return c&&S.push(new gf("selection")),S.push(new ff("placeholders")),i&&S.push(new cf("keywords")),S},[d,c,i]),h=(0,cr.useMemo)(()=>{let S=window.getComputedStyle(a);return{"--dd-color":S.color,"--dd-font-size":S.fontSize,"--dd-font-family":S.fontFamily,"--dd-font-variant":S.fontVariant}},[]);return!e||!y?null:(0,ur.jsxs)("div",{ref:S=>{S!=null&&S.parentElement&&(v.current=S==null?void 0:S.parentElement)},className:u.root,style:h,children:[(0,ur.jsx)(is,{tagName:"span",containerTagName:"div",className:(0,hf.default)(u.container,u.agentText),disableLineBreaks:no(a),content:t||"\u200B",onAfterParse:g,matchers:m,selection:p,keywordMatches:s,inputElement:a,inputStyle:h,boundaryRef:v,inlineSuggestionsOnlyAtEnd:!f}),(0,ur.jsx)("br",{})]})},nM=e=>{var g,m,h;let{input:t,ui:n,settings:r,styleSuggestions:o,conversation:i}=e,s=rs({input:t}),a=(s==null?void 0:s.text)||"",l=(s==null?void 0:s.source)||"",u=(g=t.html)!=null?g:ss(t.text),c=a.indexOf(t.text)===0?a.slice(t.text.length):"",{showTabHint:f}=n,{isSupported:d}=i,{showTabCompletion:p,visible:v,showStyleSuggestions:y}=r;return{showTabHint:f,showStyleSuggestions:y,showTabCompletion:p&&An(e),content:u,tabText:c,source:l,keywordMatches:(h=(m=o.list)==null?void 0:m.keywordMatches)!=null?h:[],enabled:v&&d!==!1}},AC=qn(nM)(tM);var XT=w(ie()),Al=w(H());var LC={list:[],fetchState:"idle"},OC=e=>e.autoflows.list||[],IC=e=>t=>{var n;return(n=t.list)==null?void 0:n.find(r=>r.triggerPayload===e)},dr=K("autoflows/getAll",(e,t)=>k(void 0,null,function*(){let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(e)})),iy=K("autoflows/start",(e,t)=>k(void 0,null,function*(){let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");yield r.startAutoflowSession(e),yield n(dr(e.platformSessionId))})),sy=K("autoflows/stop",(e,t)=>k(void 0,null,function*(){let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");yield r.stopAutoflowSession(e.platformSessionId),yield n(dr(e.platformSessionId))})),rM=X({name:"autoflows",initialState:LC,reducers:{},extraReducers:e=>{e.addCase(iy.pending,(t,n)=>{let r=IC(n.meta.arg.triggerPayload)(t);r.state="Started",r.isBusy=!0}),e.addCase(sy.pending,(t,n)=>{let r=IC(n.meta.arg.triggerPayload)(t);r.state="Aborted",r.isBusy=!0}),e.addCase(dr.pending,t=>{t.fetchState="loading"}),e.addCase(dr.rejected,t=>{t.fetchState="error"}),e.addCase(dr.fulfilled,(t,n)=>{t.list=n.payload,t.fetchState="done"}),e.addCase(de,()=>LC)}}),NC=K("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(dr(e))}),o.on("sessionCompleted",()=>{n(dr(e))})}),MC=K("autoflows/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),_C=rM.reducer;var DC={list:[],fetchState:"idle",sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},FC=e=>e.customMessages.list,HC=e=>t=>!!t.customMessages.sentSuggestions.find(n=>n===e),UC=e=>t=>!!t.customMessages.answeredSuggestions.find(n=>n===e),zC=e=>t=>!!t.customMessages.errorSuggestions.find(n=>n===e),yl=K("customMessages/getAll",(e,t)=>k(void 0,null,function*(){let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(e)})),yf=K("customMessages/send",(e,t)=>k(void 0,null,function*(){let{platformSessionId:n,suggestion:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");yield o.sendCustomMessage(n,r)})),vf=K("customMessages/answer",(e,t)=>k(void 0,null,function*(){let{platformSessionId:n,reply:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");yield o.answerCustomMessage(n,r)})),BC=X({name:"customMessages",initialState:DC,reducers:{onCustomMessage(e,t){Array.isArray(t.payload)?e.list=t.payload:e.list=[t.payload]}},extraReducers:e=>{e.addCase(yl.pending,t=>{t.fetchState="loading"}).addCase(yl.rejected,t=>{t.fetchState="error"}).addCase(yl.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload||[]}).addCase(yf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.errorSuggestions=t.errorSuggestions.filter(r=>n.meta.arg.suggestion.text!==r)}).addCase(yf.rejected,(t,n)=>{let r=t.sentSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1))}).addCase(vf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(vf.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(de,()=>DC)}}),jC=K("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(BC.actions.onCustomMessage(i))})}),VC=K("customMessages/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),KC=BC.reducer;var oM={token:null,interval:null},ay=K("passwordlessToken/getTemporaryPasswordlessToken",(e,t)=>k(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return{token:yield n.requestPasswordlessToken()}})),ly=K("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(ay()),setInterval(()=>r(ay()),n)}),WC=X({name:"passwordlessToken",initialState:oM,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(ay.fulfilled,(t,n)=>{t.token=n.payload.token}),e.addCase(ly.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:$C}=WC.actions,qC=WC.reducer;var uy={outputs:[],fetchState:"idle"},GC=e=>{var t;return(t=e.assistants)==null?void 0:t.outputs},iM=Ce("assistants/resetOutputs"),Xo=K("assistants/evaluate",(e,t)=>k(void 0,null,function*(){var n,r;try{let{deepdeskAPI:o}=t.extra,i=t.getState(),{platformVariables:s}=i.info,a=(n=i.conversation.current)==null?void 0:n.sessionId;if(!a)throw new Error("No current conversation to evaluate assistants");let l=yield o.evaluateAssistant(e.assistantCode,T({tags:((r=i.conversation.current)==null?void 0:r.tags)||void 0},e.payload),{conversationId:a});return s&&(l=l.map(u=>L(T({},u),{name:it(u.name,s),response:it(u.response,s)}))),l}catch(o){let i=o.message;return U.warn(i),t.rejectWithValue(i)}})),XC=X({name:"assistants",initialState:uy,reducers:{removeOutputByCode(e,t){e.outputs=e.outputs.filter(n=>n.code!==t.payload.code)}},extraReducers:e=>{e.addCase(Xo.pending,t=>{t.fetchState="loading"}).addCase(Xo.rejected,t=>{t.fetchState="error"}).addCase(Xo.fulfilled,(t,n)=>{let r=n.payload.map(i=>i.name),o=t.outputs.filter(i=>!r.includes(i.name));t.fetchState="done",t.outputs=[...n.payload,...o]}).addCase(de,()=>uy).addCase(iM.toString(),()=>uy)}}),{removeOutputByCode:YC}=XC.actions,QC=XC.reducer;var ZC={shouldEmit:!0},cy={cues:[],fetchState:"idle"},JC=e=>{var t;return(t=e.rules)==null?void 0:t.cues},sM=Ce("rules/resetCues"),Yo=K("rules/evaluate",(e,t)=>k(void 0,null,function*(){var n,r;try{let{deepdeskAPI:o}=t.extra,i=t.getState(),{platformVariables:s}=i.info,a=(n=i.conversation.current)==null?void 0:n.id;if(!a)throw new Error("No current conversation to evaluate rules");if(!(yield o.getAccount()).ruleEngine)throw new Error("Rule engine is not enabled for this account");if(!(yield o.getRules()).filter(d=>d.isEnabled).some(d=>d.label===e.label))throw new Error(`No enabled rules found with label: ${e.label}`);let f=yield o.evaluateRule(e.label,a,T({tags:((r=i.conversation.current)==null?void 0:r.tags)||void 0},e.params));return s&&(f=f.map(d=>L(T({},d),{title:it(d.title,s),text:it(d.text,s)}))),{cues:f,options:e.options}}catch(o){let i=o.message;return U.warn(i),t.rejectWithValue(i)}})),eT=X({name:"answer",initialState:cy,reducers:{removeCue(e,t){e.cues=e.cues.filter(n=>n.rule.id!==t.payload.id)}},extraReducers:e=>{e.addCase(Yo.pending,t=>{t.fetchState="loading"}).addCase(Yo.rejected,t=>{t.fetchState="error"}).addCase(Yo.fulfilled,(t,n)=>{let r=n.payload.cues.map(i=>i.rule.id),o=t.cues.filter(i=>!r.includes(i.rule.id));t.fetchState="done",t.cues=[...n.payload.cues,...o]}).addCase(de,()=>cy).addCase(sM.toString(),()=>cy)}}),{removeCue:tT}=eT.actions,nT=eT.reducer;function aM(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}var rT=e=>{let t=JC(e),r=GC(e).map(o=>({text:o.response,title:o.name,rule:{id:aM(o.code),label:o.code,name:o.name,description:o.name}}));return[...t,...r]};var fT=w(H());var uT=w(ie()),cT=w(H());var iT=w(ie());var oT={root:"dd-uszkm"};var aT=w(b()),lM=({className:e,children:t})=>{let n=A("Unicode",oT);return(0,aT.jsx)("span",{className:(0,iT.default)(e,n.root),children:t})},sT=lM;var lT={isDisabled:"dd-Sp--t",root:"dd-maqTG",buttonStop:"dd-rcq8w",stateBadge:"dd-zOnkT",isCompleted:"dd-GA-rt",isStarted:"dd-PZwtX",isAborted:"dd-PAXSE"};var dy={};$e(dy,{enUS:()=>uM,nlNL:()=>cM});var uM={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"}]},cM={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 At=w(b()),fM=({disabled:e,state:t,displayName:n,description:r,onStartAutoflow:o,onStopAutoflow:i})=>{let s=A("Autoflow",lT),a=q(dy),l=t==="Started"?"stop":"start",u=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,At.jsxs)(oe,{className:(0,uT.default)(s.root,{[s.isDisabled]:e,[s.isCompleted]:t==="Completed",[s.isAborted]:t==="Aborted",[s.isStarted]:t==="Started"}),children:[(0,At.jsx)(ye,{children:(0,At.jsxs)(ye.Content,{children:[(0,At.jsxs)(ye.Title,{children:[t&&(0,At.jsx)("span",{className:s.stateBadge,children:a(t)}),n]}),(0,At.jsx)("span",{children:r})]})}),(0,At.jsx)(oe.Actions,{fixed:t==="Started",children:(0,At.jsx)(oe.ActionButton,{primary:!0,className:l==="start"?s.buttonStart:s.buttonStop,onClick:t==="Started"?i:o,disabled:e,label:(0,At.jsxs)(cT.Fragment,{children:[(0,At.jsx)(sT,{children:u})," ",(0,At.jsx)("span",{children:a(l)})]})})})]})},dT=fM;var fy=w(b()),pM=(e,t)=>{let n=t.filter(r=>r.state==="Started");return n.length>0?n.indexOf(e)===-1:!1},mM=({autoflows:e,onStartAutoflow:t,onStopAutoflow:n,platformSessionId:r})=>(0,fy.jsx)(fT.Fragment,{children:e.map(o=>(0,fy.jsx)(dT,{displayName:o.displayName,description:o.description,disabled:o.isBusy||pM(o,e),state:o.state,onStartAutoflow:()=>t({platformSessionId:r,triggerPayload:o.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:r,triggerPayload:o.triggerPayload})},o.displayName))}),gM=({autoflows:e,conversation:t})=>{var n;return{autoflows:e.list,platformSessionId:(n=t.current)==null?void 0:n.sessionId}},hM={onStartAutoflow:iy,onStopAutoflow:sy},pT=qn(gM,hM)(mM);var mT=w(ie()),py=w(H());var fr={root:"dd-ERsBr",title:"dd-b36p6",isUsed:"dd-fp2IX",quickReplies:"dd--VrvP",quickReply:"dd-wFhWh",label:"dd-R9sND",errorIcon:"dd-8cdcH"};var wt=w(b()),yM=({suggestion:e})=>{let t=q(Ko),n=Y(),r=M(HC(e.text)),o=M(UC(e.text)),i=M(zC(e.text)),s=M(es),{replyOptions:a}=e,l=(0,py.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),!(r||!s)&&n(yf({platformSessionId:s,suggestion:e}))},[e,r,n,s]),u=(0,py.useCallback)(c=>{if(c.preventDefault(),c.stopPropagation(),!s||!a)return;let f=parseInt(c.target.dataset.index,10),d=a[f];n(vf({platformSessionId:s,reply:d,suggestion:e}))},[e,r,n,s]);return(0,wt.jsxs)(oe,{onClick:l,className:(0,mT.default)(fr.root,{[fr.isUsed]:r,[fr.hasError]:i}),children:[(0,wt.jsx)(ye,{children:(0,wt.jsxs)(ye.Content,{children:[(0,wt.jsxs)(ye.Title,{className:fr.title,children:[e.text," ",(0,wt.jsx)(eu,{className:fr.label,children:"analyse tool"})," ",i&&(0,wt.jsx)("span",{className:fr.errorIcon,role:"img","aria-label":t("sendingError"),title:t("sendingError"),children:"!"})]}),a&&a.length>0&&(0,wt.jsx)("ul",{className:fr.quickReplies,children:a.map(c=>(0,wt.jsx)("li",{className:fr.quickReply,children:c.title},c.title))})]})}),(0,wt.jsxs)(oe.Actions,{fixed:i||r,children:[a&&a.length>0&&(0,wt.jsx)(oe.DropdownButton,{label:t("answer"),disabled:o,children:a.map((c,f)=>(0,wt.jsx)(oe.DropdownItem,{index:f,label:c.title,onClick:u},c.title))}),(0,wt.jsx)(oe.ActionButton,{primary:!0,disabled:r,onClick:l,label:t(r?"suggestionSent":i?"tryAgain":"sendSuggestion")})]})]})},gT=yM;var Sf=w(H());var gy=w(ie());var my=w(b()),vl=()=>(0,my.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,my.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 hT={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var In=w(b()),vM=({entities:e})=>{let t=A("EntitiesWidgetList",hT),[n,r]=(0,Sf.useState)(void 0),o=Y(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),Qn(a.text),o(ot({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Sf.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,In.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,In.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,In.jsx)("span",{className:t.entityText,children:a.text}),(0,In.jsxs)("span",{className:t.iconWrapper,children:[(0,In.jsx)("span",{className:(0,gy.default)(t.icon),children:(0,In.jsx)(vl,{})}),(0,In.jsx)("span",{className:(0,gy.default)(t.icon,n===l&&t.iconClicked),children:(0,In.jsx)(vl,{})})]})]},a.text))})},yT=vM;var hy=w(b()),vT=()=>(0,hy.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,hy.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 yy=w(b()),ST=()=>(0,yy.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,yy.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 vy=w(b()),wT=()=>(0,vy.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,vy.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 UT=w(H());var Sl=w(b()),xT=({className:e})=>(0,Sl.jsxs)("svg",{viewBox:"0 0 12 12",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:e,children:[(0,Sl.jsx)("line",{x1:"2",y1:"10",x2:"10",y2:"2",stroke:"black",strokeWidth:"1"}),(0,Sl.jsx)("line",{x1:"2",y1:"2",x2:"10",y2:"10",stroke:"black",strokeWidth:"1"})]});var{entries:AT,setPrototypeOf:ET,isFrozen:SM,getPrototypeOf:wM,getOwnPropertyDescriptor:xM}=Object,{freeze:ut,seal:gn,create:LT}=Object,{apply:Cy,construct:Ty}=typeof Reflect!="undefined"&&Reflect;ut||(ut=function(t){return t});gn||(gn=function(t){return t});Cy||(Cy=function(t,n,r){return t.apply(n,r)});Ty||(Ty=function(t,n){return new t(...n)});var wf=It(Array.prototype.forEach),bT=It(Array.prototype.pop),wl=It(Array.prototype.push),bf=It(String.prototype.toLowerCase),Sy=It(String.prototype.toString),EM=It(String.prototype.match),xl=It(String.prototype.replace),bM=It(String.prototype.indexOf),CM=It(String.prototype.trim),mn=It(Object.prototype.hasOwnProperty),Lt=It(RegExp.prototype.test),El=TM(TypeError);function It(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Cy(e,t,r)}}function TM(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Ty(e,n)}}function ee(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:bf;ET&&ET(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){let i=n(o);i!==o&&(SM(t)||(t[r]=i),o=i)}e[o]=!0}return e}function kM(e){for(let t=0;t<e.length;t++)mn(e,t)||(e[t]=null);return e}function Qo(e){let t=LT(null);for(let[n,r]of AT(e))mn(e,n)&&(Array.isArray(r)?t[n]=kM(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Qo(r):t[n]=r);return t}function xf(e,t){for(;e!==null;){let r=xM(e,t);if(r){if(r.get)return It(r.get);if(typeof r.value=="function")return It(r.value)}e=wM(e)}function n(){return null}return n}var CT=ut(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),wy=ut(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),xy=ut(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),PM=ut(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ey=ut(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),RM=ut(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),TT=ut(["#text"]),kT=ut(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),by=ut(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),PT=ut(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ef=ut(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),AM=gn(/\{\{[\w\W]*|[\w\W]*\}\}/gm),LM=gn(/<%[\w\W]*|[\w\W]*%>/gm),IM=gn(/\${[\w\W]*}/gm),OM=gn(/^data-[\-\w.\u00B7-\uFFFF]/),NM=gn(/^aria-[\-\w]+$/),IT=gn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),MM=gn(/^(?:\w+script|data):/i),_M=gn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),OT=gn(/^html$/i),RT=Object.freeze({__proto__:null,MUSTACHE_EXPR:AM,ERB_EXPR:LM,TMPLIT_EXPR:IM,DATA_ATTR:OM,ARIA_ATTR:NM,IS_ALLOWED_URI:IT,IS_SCRIPT_OR_DATA:MM,ATTR_WHITESPACE:_M,DOCTYPE_NAME:OT}),DM=function(){return typeof window=="undefined"?null:window},FM=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null,o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));let i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(s){return s},createScriptURL(s){return s}})}catch(s){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function NT(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:DM(),t=j=>NT(j);if(t.version="3.0.9",t.removed=[],!e||!e.document||e.document.nodeType!==9)return t.isSupported=!1,t;let{document:n}=e,r=n,o=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:s,Node:a,Element:l,NodeFilter:u,NamedNodeMap:c=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:f,DOMParser:d,trustedTypes:p}=e,v=l.prototype,y=xf(v,"cloneNode"),g=xf(v,"nextSibling"),m=xf(v,"childNodes"),h=xf(v,"parentNode");if(typeof s=="function"){let j=n.createElement("template");j.content&&j.content.ownerDocument&&(n=j.content.ownerDocument)}let S,x="",{implementation:P,createNodeIterator:C,createDocumentFragment:R,getElementsByTagName:N}=n,{importNode:_}=r,D={};t.isSupported=typeof AT=="function"&&typeof h=="function"&&P&&P.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:G,ERB_EXPR:Z,TMPLIT_EXPR:se,DATA_ATTR:gr,ARIA_ATTR:Ot,IS_SCRIPT_OR_DATA:hr,ATTR_WHITESPACE:Nt}=RT,{IS_ALLOWED_URI:B}=RT,J=null,yr=ee({},[...CT,...wy,...xy,...Ey,...TT]),we=null,vr=ee({},[...kT,...by,...PT,...Ef]),Q=Object.seal(LT(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Sr=null,Fl=null,ni=!0,lo=!0,ks=!1,Hl=!0,Zt=!1,Jt=!1,Ul=!1,ct=!1,Mt=!1,zl=!1,Bl=!1,zy=!0,By=!1,Bk="user-content-",_f=!0,Ps=!1,ri={},oi=null,jy=ee({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Vy=null,Ky=ee({},["audio","video","img","source","image","track"]),Df=null,Wy=ee({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),jl="http://www.w3.org/1998/Math/MathML",Vl="http://www.w3.org/2000/svg",_n="http://www.w3.org/1999/xhtml",ii=_n,Ff=!1,Hf=null,jk=ee({},[jl,Vl,_n],Sy),Rs=null,Vk=["application/xhtml+xml","text/html"],Kk="text/html",De=null,si=null,Wk=n.createElement("form"),$y=function(E){return E instanceof RegExp||E instanceof Function},Uf=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(si&&si===E)){if((!E||typeof E!="object")&&(E={}),E=Qo(E),Rs=Vk.indexOf(E.PARSER_MEDIA_TYPE)===-1?Kk:E.PARSER_MEDIA_TYPE,De=Rs==="application/xhtml+xml"?Sy:bf,J=mn(E,"ALLOWED_TAGS")?ee({},E.ALLOWED_TAGS,De):yr,we=mn(E,"ALLOWED_ATTR")?ee({},E.ALLOWED_ATTR,De):vr,Hf=mn(E,"ALLOWED_NAMESPACES")?ee({},E.ALLOWED_NAMESPACES,Sy):jk,Df=mn(E,"ADD_URI_SAFE_ATTR")?ee(Qo(Wy),E.ADD_URI_SAFE_ATTR,De):Wy,Vy=mn(E,"ADD_DATA_URI_TAGS")?ee(Qo(Ky),E.ADD_DATA_URI_TAGS,De):Ky,oi=mn(E,"FORBID_CONTENTS")?ee({},E.FORBID_CONTENTS,De):jy,Sr=mn(E,"FORBID_TAGS")?ee({},E.FORBID_TAGS,De):{},Fl=mn(E,"FORBID_ATTR")?ee({},E.FORBID_ATTR,De):{},ri=mn(E,"USE_PROFILES")?E.USE_PROFILES:!1,ni=E.ALLOW_ARIA_ATTR!==!1,lo=E.ALLOW_DATA_ATTR!==!1,ks=E.ALLOW_UNKNOWN_PROTOCOLS||!1,Hl=E.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Zt=E.SAFE_FOR_TEMPLATES||!1,Jt=E.WHOLE_DOCUMENT||!1,Mt=E.RETURN_DOM||!1,zl=E.RETURN_DOM_FRAGMENT||!1,Bl=E.RETURN_TRUSTED_TYPE||!1,ct=E.FORCE_BODY||!1,zy=E.SANITIZE_DOM!==!1,By=E.SANITIZE_NAMED_PROPS||!1,_f=E.KEEP_CONTENT!==!1,Ps=E.IN_PLACE||!1,B=E.ALLOWED_URI_REGEXP||IT,ii=E.NAMESPACE||_n,Q=E.CUSTOM_ELEMENT_HANDLING||{},E.CUSTOM_ELEMENT_HANDLING&&$y(E.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Q.tagNameCheck=E.CUSTOM_ELEMENT_HANDLING.tagNameCheck),E.CUSTOM_ELEMENT_HANDLING&&$y(E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Q.attributeNameCheck=E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),E.CUSTOM_ELEMENT_HANDLING&&typeof E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Q.allowCustomizedBuiltInElements=E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Zt&&(lo=!1),zl&&(Mt=!0),ri&&(J=ee({},TT),we=[],ri.html===!0&&(ee(J,CT),ee(we,kT)),ri.svg===!0&&(ee(J,wy),ee(we,by),ee(we,Ef)),ri.svgFilters===!0&&(ee(J,xy),ee(we,by),ee(we,Ef)),ri.mathMl===!0&&(ee(J,Ey),ee(we,PT),ee(we,Ef))),E.ADD_TAGS&&(J===yr&&(J=Qo(J)),ee(J,E.ADD_TAGS,De)),E.ADD_ATTR&&(we===vr&&(we=Qo(we)),ee(we,E.ADD_ATTR,De)),E.ADD_URI_SAFE_ATTR&&ee(Df,E.ADD_URI_SAFE_ATTR,De),E.FORBID_CONTENTS&&(oi===jy&&(oi=Qo(oi)),ee(oi,E.FORBID_CONTENTS,De)),_f&&(J["#text"]=!0),Jt&&ee(J,["html","head","body"]),J.table&&(ee(J,["tbody"]),delete Sr.tbody),E.TRUSTED_TYPES_POLICY){if(typeof E.TRUSTED_TYPES_POLICY.createHTML!="function")throw El('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof E.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw El('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=E.TRUSTED_TYPES_POLICY,x=S.createHTML("")}else S===void 0&&(S=FM(p,o)),S!==null&&typeof x=="string"&&(x=S.createHTML(""));ut&&ut(E),si=E}},qy=ee({},["mi","mo","mn","ms","mtext"]),Gy=ee({},["foreignobject","desc","title","annotation-xml"]),$k=ee({},["title","style","font","a","script"]),Xy=ee({},[...wy,...xy,...PM]),Yy=ee({},[...Ey,...RM]),qk=function(E){let O=h(E);(!O||!O.tagName)&&(O={namespaceURI:ii,tagName:"template"});let z=bf(E.tagName),me=bf(O.tagName);return Hf[E.namespaceURI]?E.namespaceURI===Vl?O.namespaceURI===_n?z==="svg":O.namespaceURI===jl?z==="svg"&&(me==="annotation-xml"||qy[me]):!!Xy[z]:E.namespaceURI===jl?O.namespaceURI===_n?z==="math":O.namespaceURI===Vl?z==="math"&&Gy[me]:!!Yy[z]:E.namespaceURI===_n?O.namespaceURI===Vl&&!Gy[me]||O.namespaceURI===jl&&!qy[me]?!1:!Yy[z]&&($k[z]||!Xy[z]):!!(Rs==="application/xhtml+xml"&&Hf[E.namespaceURI]):!1},uo=function(E){wl(t.removed,{element:E});try{E.parentNode.removeChild(E)}catch(O){E.remove()}},zf=function(E,O){try{wl(t.removed,{attribute:O.getAttributeNode(E),from:O})}catch(z){wl(t.removed,{attribute:null,from:O})}if(O.removeAttribute(E),E==="is"&&!we[E])if(Mt||zl)try{uo(O)}catch(z){}else try{O.setAttribute(E,"")}catch(z){}},Qy=function(E){let O=null,z=null;if(ct)E="<remove></remove>"+E;else{let We=EM(E,/^[\r\n\t ]+/);z=We&&We[0]}Rs==="application/xhtml+xml"&&ii===_n&&(E='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+E+"</body></html>");let me=S?S.createHTML(E):E;if(ii===_n)try{O=new d().parseFromString(me,Rs)}catch(We){}if(!O||!O.documentElement){O=P.createDocument(ii,"template",null);try{O.documentElement.innerHTML=Ff?x:me}catch(We){}}let Ke=O.body||O.documentElement;return E&&z&&Ke.insertBefore(n.createTextNode(z),Ke.childNodes[0]||null),ii===_n?N.call(O,Jt?"html":"body")[0]:Jt?O.documentElement:Ke},Zy=function(E){return C.call(E.ownerDocument||E,E,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT,null)},Gk=function(E){return E instanceof f&&(typeof E.nodeName!="string"||typeof E.textContent!="string"||typeof E.removeChild!="function"||!(E.attributes instanceof c)||typeof E.removeAttribute!="function"||typeof E.setAttribute!="function"||typeof E.namespaceURI!="string"||typeof E.insertBefore!="function"||typeof E.hasChildNodes!="function")},Jy=function(E){return typeof a=="function"&&E instanceof a},Dn=function(E,O,z){D[E]&&wf(D[E],me=>{me.call(t,O,z,si)})},ev=function(E){let O=null;if(Dn("beforeSanitizeElements",E,null),Gk(E))return uo(E),!0;let z=De(E.nodeName);if(Dn("uponSanitizeElement",E,{tagName:z,allowedTags:J}),E.hasChildNodes()&&!Jy(E.firstElementChild)&&Lt(/<[/\w]/g,E.innerHTML)&&Lt(/<[/\w]/g,E.textContent))return uo(E),!0;if(!J[z]||Sr[z]){if(!Sr[z]&&nv(z)&&(Q.tagNameCheck instanceof RegExp&&Lt(Q.tagNameCheck,z)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck(z)))return!1;if(_f&&!oi[z]){let me=h(E)||E.parentNode,Ke=m(E)||E.childNodes;if(Ke&&me){let We=Ke.length;for(let dt=We-1;dt>=0;--dt)me.insertBefore(y(Ke[dt],!0),g(E))}}return uo(E),!0}return E instanceof l&&!qk(E)||(z==="noscript"||z==="noembed"||z==="noframes")&&Lt(/<\/no(script|embed|frames)/i,E.innerHTML)?(uo(E),!0):(Zt&&E.nodeType===3&&(O=E.textContent,wf([G,Z,se],me=>{O=xl(O,me," ")}),E.textContent!==O&&(wl(t.removed,{element:E.cloneNode()}),E.textContent=O)),Dn("afterSanitizeElements",E,null),!1)},tv=function(E,O,z){if(zy&&(O==="id"||O==="name")&&(z in n||z in Wk))return!1;if(!(lo&&!Fl[O]&&Lt(gr,O))){if(!(ni&&Lt(Ot,O))){if(!we[O]||Fl[O]){if(!(nv(E)&&(Q.tagNameCheck instanceof RegExp&&Lt(Q.tagNameCheck,E)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck(E))&&(Q.attributeNameCheck instanceof RegExp&&Lt(Q.attributeNameCheck,O)||Q.attributeNameCheck instanceof Function&&Q.attributeNameCheck(O))||O==="is"&&Q.allowCustomizedBuiltInElements&&(Q.tagNameCheck instanceof RegExp&&Lt(Q.tagNameCheck,z)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck(z))))return!1}else if(!Df[O]){if(!Lt(B,xl(z,Nt,""))){if(!((O==="src"||O==="xlink:href"||O==="href")&&E!=="script"&&bM(z,"data:")===0&&Vy[E])){if(!(ks&&!Lt(hr,xl(z,Nt,"")))){if(z)return!1}}}}}}return!0},nv=function(E){return E!=="annotation-xml"&&E.indexOf("-")>0},rv=function(E){Dn("beforeSanitizeAttributes",E,null);let{attributes:O}=E;if(!O)return;let z={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:we},me=O.length;for(;me--;){let Ke=O[me],{name:We,namespaceURI:dt,value:co}=Ke,As=De(We),ft=We==="value"?co:CM(co);if(z.attrName=As,z.attrValue=ft,z.keepAttr=!0,z.forceKeepAttr=void 0,Dn("uponSanitizeAttribute",E,z),ft=z.attrValue,z.forceKeepAttr||(zf(We,E),!z.keepAttr))continue;if(!Hl&&Lt(/\/>/i,ft)){zf(We,E);continue}Zt&&wf([G,Z,se],iv=>{ft=xl(ft,iv," ")});let ov=De(E.nodeName);if(tv(ov,As,ft)){if(By&&(As==="id"||As==="name")&&(zf(We,E),ft=Bk+ft),S&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!dt)switch(p.getAttributeType(ov,As)){case"TrustedHTML":{ft=S.createHTML(ft);break}case"TrustedScriptURL":{ft=S.createScriptURL(ft);break}}try{dt?E.setAttributeNS(dt,We,ft):E.setAttribute(We,ft),bT(t.removed)}catch(iv){}}}Dn("afterSanitizeAttributes",E,null)},Xk=function j(E){let O=null,z=Zy(E);for(Dn("beforeSanitizeShadowDOM",E,null);O=z.nextNode();)Dn("uponSanitizeShadowNode",O,null),!ev(O)&&(O.content instanceof i&&j(O.content),rv(O));Dn("afterSanitizeShadowDOM",E,null)};return t.sanitize=function(j){let E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},O=null,z=null,me=null,Ke=null;if(Ff=!j,Ff&&(j="<!-->"),typeof j!="string"&&!Jy(j))if(typeof j.toString=="function"){if(j=j.toString(),typeof j!="string")throw El("dirty is not a string, aborting")}else throw El("toString is not a function");if(!t.isSupported)return j;if(Ul||Uf(E),t.removed=[],typeof j=="string"&&(Ps=!1),Ps){if(j.nodeName){let co=De(j.nodeName);if(!J[co]||Sr[co])throw El("root node is forbidden and cannot be sanitized in-place")}}else if(j instanceof a)O=Qy("<!---->"),z=O.ownerDocument.importNode(j,!0),z.nodeType===1&&z.nodeName==="BODY"||z.nodeName==="HTML"?O=z:O.appendChild(z);else{if(!Mt&&!Zt&&!Jt&&j.indexOf("<")===-1)return S&&Bl?S.createHTML(j):j;if(O=Qy(j),!O)return Mt?null:Bl?x:""}O&&ct&&uo(O.firstChild);let We=Zy(Ps?j:O);for(;me=We.nextNode();)ev(me)||(me.content instanceof i&&Xk(me.content),rv(me));if(Ps)return j;if(Mt){if(zl)for(Ke=R.call(O.ownerDocument);O.firstChild;)Ke.appendChild(O.firstChild);else Ke=O;return(we.shadowroot||we.shadowrootmode)&&(Ke=_.call(r,Ke,!0)),Ke}let dt=Jt?O.outerHTML:O.innerHTML;return Jt&&J["!doctype"]&&O.ownerDocument&&O.ownerDocument.doctype&&O.ownerDocument.doctype.name&&Lt(OT,O.ownerDocument.doctype.name)&&(dt="<!DOCTYPE "+O.ownerDocument.doctype.name+`>
24
24
  `+dt),Zt&&wf([G,Z,se],co=>{dt=xl(dt,co," ")}),S&&Bl?S.createHTML(dt):dt},t.setConfig=function(){let j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Uf(j),Ul=!0},t.clearConfig=function(){si=null,Ul=!1},t.isValidAttribute=function(j,E,O){si||Uf({});let z=De(j),me=De(E);return tv(z,me,O)},t.addHook=function(j,E){typeof E=="function"&&(D[j]=D[j]||[],wl(D[j],E))},t.removeHook=function(j){if(D[j])return bT(D[j])},t.removeHooks=function(j){D[j]&&(D[j]=[])},t.removeAllHooks=function(){D={}},t}var MT=NT();var io=w(H());var HM={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function _T(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function bl(e){return(e+"").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Cl(e,t){var n,r,o,i,s,a=/((?:^|\n+)(?:\n---+|\* \*(?: \*)+)\n)|(?:^``` *(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t| {2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|( \n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,l=[],u="",c=t||{},f=0;function d(v){var y=HM[v[1]||""],g=l[l.length-1]==v;return y?y[1]?(g?l.pop():l.push(v),y[0|g]):y[0]:v}function p(){for(var v="";l.length;)v+=d(l[l.length-1]);return v}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,function(v,y,g){return c[y.toLowerCase()]=g,""}).replace(/^\n+|\n+$/g,"");o=a.exec(e);)r=e.substring(f,o.index),f=a.lastIndex,n=o[0],r.match(/[^\\](\\\\)*\\$/)||((s=o[3]||o[4])?n='<pre class="code '+(o[4]?"poetry":o[2].toLowerCase())+'"><code'+(o[2]?' class="language-'+o[2].toLowerCase()+'"':"")+">"+_T(bl(s).replace(/^\n+|\n+$/g,""))+"</code></pre>":(s=o[6])?(s.match(/\./)&&(o[5]=o[5].replace(/^\d+/gm,"")),i=Cl(_T(o[5].replace(/^\s*[>*+.-]/gm,""))),s==">"?s="blockquote":(s=s.match(/\./)?"ol":"ul",i=i.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),n="<"+s+">"+i+"</"+s+">"):o[8]?n='<img src="'+bl(o[8])+'" alt="'+bl(o[7])+'">':o[10]?(u=u.replace("<a>",'<a href="'+bl(o[11]||c[r.toLowerCase()])+'">'),n=p()+"</a>"):o[9]?n="<a>":o[12]||o[14]?n="<"+(s="h"+(o[14]?o[14].length:o[13]>"="?1:2))+">"+Cl(o[12]||o[15],c)+"</"+s+">":o[16]?n="<code>"+bl(o[16])+"</code>":(o[17]||o[1])&&(n=d(o[17]||"--"))),u+=r,u+=n;return(u+e.substring(f)+p()).replace(/^\n+|\n+$/g,"")}var DT={root:"dd-L7b3z",popover:"dd-OQOTB",options:"dd-Y12RE",arrow:"dd-cv33T",copyIcon:"dd-6xOsH",option:"dd-9oFX4",divider:"dd-aiZf8",fadeup:"dd-Jq9pd"};var On=w(b());function UM(e){return`<button type="button" class=${e}><svg version="1.1" x="0px" y="0px" viewBox="0 0 115.77 122.88" width="10px" height="10px" fill="black"><g><path d="M89.62,13.96v7.73h12.19h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02v0.02 v73.27v0.01h-0.02c-0.01,3.84-1.57,7.33-4.1,9.86c-2.51,2.5-5.98,4.06-9.82,4.07v0.02h-0.02h-61.7H40.1v-0.02 c-3.84-0.01-7.34-1.57-9.86-4.1c-2.5-2.51-4.06-5.98-4.07-9.82h-0.02v-0.02V92.51H13.96h-0.01v-0.02c-3.84-0.01-7.34-1.57-9.86-4.1 c-2.5-2.51-4.06-5.98-4.07-9.82H0v-0.02V13.96v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07V0h0.02h61.7 h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02V13.96L89.62,13.96z M79.04,21.69v-7.73v-0.02h0.02 c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v64.59v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h12.19V35.65 v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07v-0.02h0.02H79.04L79.04,21.69z M105.18,108.92V35.65v-0.02 h0.02c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v73.27v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h61.7h0.02 v0.02c0.91,0,1.75-0.39,2.37-1.01c0.61-0.61,1-1.46,1-2.37h-0.02V108.92L105.18,108.92z"/></g></svg></button>`}function ky(e){var n;let t=e.cloneNode(!0);return t.querySelectorAll("div,button").forEach(r=>r.remove()),(n=t.textContent)!=null?n:""}function zM(e){return e.replace(/\r\n/g,`
25
25
  `)}var BM=({content:e,useLabel:t,copyLabel:n,onCopy:r,onUse:o})=>{let i=A("Markdown",DT),s=(0,io.useRef)(null),[a,l]=(0,io.useState)(null),u=(0,io.useMemo)(()=>{let y=Cl(zM(e));return MT.sanitize(y).replace(/<\/code>/g,`${UM(i.copyIcon)}</code>`)},[e]),c=y=>{var h;let g=y.target,m=!!((h=s.current)!=null&&h.querySelector("code"));a||m&&g.tagName!=="CODE"||!m&&g!==s.current||(g.addEventListener("mouseleave",()=>l(null),{once:!0}),l(g))},f=()=>{if(!a)return;l(null);let y=a.querySelector("button");y&&(cs(y,i.fadeup),r(ky(a)))},d=y=>{y.target.tagName.toLowerCase()==="button"&&(cs(y.target,i.fadeup),r(ky(y.target.parentElement)))},p=()=>{a&&(l(null),o(ky(a)))},v=y=>{if(y===null)return;let g=y.getBoundingClientRect();g.left<0?y.style.transform=`translateX(${-g.left+2}px)`:g.right>window.innerWidth&&(y.style.transform=`translateX(${window.innerWidth-g.right-2}px)`)};return(0,On.jsxs)(io.Fragment,{children:[a&&(0,On.jsxs)(ws,{triggerRef:{current:a},className:i.popover,parentNode:a,children:[(0,On.jsxs)("div",{className:i.options,ref:v,children:[(0,On.jsx)("button",{type:"button",className:i.option,onClick:f,children:n}),(0,On.jsx)("div",{className:i.divider}),(0,On.jsx)("button",{type:"button",className:i.option,onClick:p,children:t})]}),(0,On.jsx)("div",{className:i.arrow})]}),(0,On.jsx)("div",{ref:s,className:i.root,dangerouslySetInnerHTML:{__html:u},onMouseOver:c,onClick:d})]})},FT=BM;var Py={};$e(Py,{enUS:()=>jM,nlNL:()=>VM});var jM={useCue:[{type:0,value:"Add to message"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},VM={useCue:[{type:0,value:"Voeg toe aan bericht"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var HT={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",thumbsUp:"dd-6QwVx",thumbsDown:"dd-d3E8l"};var hn=w(b()),KM=({cue:e,onRemove:t,onCopy:n,onUse:r})=>{let o=A("WidgetCue",HT),i=q(Py),s=ds(),a=c=>{n&&n(c,e)},l=c=>{r&&r(c,e)},u=c=>{c.preventDefault(),c.stopPropagation(),t(e)};return(0,UT.useEffect)(()=>{s("Assistant response displayed",{name:e.rule.name,description:e.rule.description,group:e.rule.label,cueText:e.text})},[]),(0,hn.jsxs)(oe,{"data-testid":"cue",children:[(0,hn.jsx)(ye,{children:(0,hn.jsxs)(ye.Content,{children:[e.title&&(0,hn.jsx)(ye.Title,{className:o.title,"data-testid":"widget-cue-title",children:e.title}),(0,hn.jsx)(FT,{content:e.text,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:a,onUse:l})]})}),(0,hn.jsxs)(oe.IconButtonContainer,{children:[(0,hn.jsx)(ps,{eventName:"Assistant response feedback",eventData:{name:e.rule.name,group:e.rule.label,description:e.rule.description,cueText:e.text},feedbackText:e.text,feedbackType:"assistant"}),(0,hn.jsx)(oe.IconButton,{title:i("removeCue"),onClick:u,icon:(0,hn.jsx)(xT,{})})]})]})},zT=KM;var Tl=w(b()),WM=({cues:e})=>{let t=Y(),n=$t(),r=ds(),o=a=>{t(tT({id:a.rule.id})),t(YC({code:a.rule.label})),r("Assistant response closed",{name:a.rule.name,group:a.rule.label,description:a.rule.description,cueText:a.text})},i=(a,l)=>{Qn(a),r("Assistant response copied",{name:l.rule.name,group:l.rule.label,description:l.rule.description,copiedText:a})},s=(a,l)=>{n.send(Xr,{text:a,suggestion:{source:"cue",sourceText:a}}),r("Assistant response used",{name:l.rule.name,group:l.rule.label,description:l.rule.description,usedText:a})};return(0,Tl.jsx)(Tl.Fragment,{children:e.map(a=>(0,Tl.jsx)(zT,{cue:a,onRemove:o,onCopy:i,onUse:s},a.rule.id))})},BT=WM;var Cf=w(H());var jT={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var yn=w(b());function $M(e,t){return t.split(".").reduce((n,r)=>!n||typeof n!="object"||!(r in n)?null:n[r],e)}var VT=({data:e,schema:t})=>{let n=A("WidgetCustomData",jT),r=o=>{Qn(o)};return(0,Cf.useEffect)(()=>{U.info("Custom data",e,t)},[e]),(0,yn.jsx)("dl",{className:n.root,children:t.map(o=>{let i=$M(e,o.path);return(0,yn.jsxs)(Cf.Fragment,{children:[(0,yn.jsx)("dt",{className:n.label,children:o.label}),(0,yn.jsx)("dd",{className:n.value,children:o.type==="boolean"&&i?(0,yn.jsx)("span",{className:n.isTrue,children:o.trueValue}):o.type==="boolean"&&!i?(0,yn.jsx)("span",{className:n.isFalse,children:o.falseValue}):i?(0,yn.jsxs)("button",{type:"button",onClick:()=>r(i),className:n.copyButton,children:[(0,yn.jsx)("span",{children:i}),(0,yn.jsx)(vl,{})]}):"-"})]},o.label)})})};var WT=w(H());var qM=/(https?:\/\/[^\s]+)/,KT=e=>e.split(" ").find(t=>qM.test(t));var Yt=w(b()),GM=({suggestion:e,lines:t,onUse:n})=>{var c;let r=e.text||e.url||e.message,o=KT(r),i=q(Ko),s=V("showImages"),a=V("fallbackImage"),l=f=>{f.preventDefault(),f.stopPropagation(),n(r)},u=(0,WT.useCallback)(f=>{window.open(o,"_blank"),f.stopPropagation(),f.preventDefault()},[o]);return(0,Yt.jsxs)(oe,{onClick:l,"data-testid":"edit-suggestion",children:[(0,Yt.jsxs)(ye,{children:[s&&e.image&&(0,Yt.jsx)(ye.Image,{src:pf(e,"small",a||void 0),title:e.title}),(0,Yt.jsxs)(ye.Content,{children:[e.title&&(0,Yt.jsx)(ye.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((c=e.searchKeywords)==null?void 0:c.length)>0&&(0,Yt.jsx)(oe.Labels,{labels:e.searchKeywords}),(0,Yt.jsx)(ye.Content,{cropText:t==="single",lineClamp:t==="multiple",children:r})]})]}),(0,Yt.jsxs)(oe.Actions,{children:[o&&(0,Yt.jsx)(oe.ActionButton,{onClick:u,label:i("visitUrl")}),(0,Yt.jsx)(oe.ActionButton,{primary:!0,onClick:l,label:i("useSuggestion")})]})]})},$T=GM;var kl=w(b()),XM=({lines:e,suggestions:t})=>{let n=$t(),r=(o,i)=>{n.send(Xr,{text:o,suggestion:L(T({},i),{source:i.source,sourceText:i.text})})};return(0,kl.jsx)(kl.Fragment,{children:t.map(o=>(0,kl.jsx)($T,{suggestion:o,lines:e,onUse:i=>r(i,o)},o.text||o.url||o.message))})},qT=XM;var Pl={};$e(Pl,{enUS:()=>YM,nlNL:()=>QM});var YM={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"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},QM={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"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Rl={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",sectionList:"dd-bF9pF",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",link:"dd-DRo0x"};var $=w(b()),Tf=(e,t)=>{let n=M(rt);(0,Al.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},ZM=({onLogIn:e})=>{let t=A("Widget",Rl),n=V("isEmbedded"),r=V("adminUrl");return(0,$.jsx)("div",{className:t.loginText,children:(0,$.jsx)("div",{children:(0,$.jsx)(Jd,{isEmbedded:n,loginUrl:r,onLogIn:e})})},"login")},GT=({text:e})=>{let t=A("Widget",Rl);return(0,$.jsx)("div",{className:t.stateText,children:(0,$.jsx)("div",{children:(0,$.jsx)("p",{children:e})})},"notification")},JM=()=>{let e=q(Pl),t=Y(),n=A("Widget",Rl),r=V("showSearch"),o=V("showSummaryCommand"),i=V("showKnowledgeSearch"),s=M(fs("/admin/")),a=$t(),l=V("productName"),u=r||o||i||s;return Tf(()=>(t(ly()),()=>{t($C())}),[t]),u?(0,$.jsx)(Sn,{title:e("actions"),type:"shortcuts",children:(0,$.jsxs)("div",{className:n.shortcutList,children:[r&&(0,$.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-search","aria-label":e("linkSearch"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0}),children:[(0,$.jsx)(ls,{}),e("linkSearch")]}),o&&(0,$.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-summary","aria-label":e("linkSummary"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,$.jsx)(wT,{}),e("linkSummary")]}),i&&(0,$.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-knowledge-assist","aria-label":e("linkKnowledgeSearch"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,$.jsx)(ST,{}),e("linkKnowledgeSearch")]}),s&&(0,$.jsxs)("a",{className:n.shortcut,target:"_blank",href:s,"data-testid":"shortcut-studio-login","aria-label":e("linkStudioLogin",{productName:l}),rel:"noreferrer",children:[(0,$.jsx)(vT,{}),e("linkStudioLogin",{productName:l})]})]})}):null},e2=()=>{let e=Y(),t=V("showCustomMessages"),n=M(FC),r=M(es);return Tf(()=>(e(yl(r)),e(jC(r)),()=>{e(VC(r))}),[e,t,r]),!t||n.length===0?null:(0,$.jsx)(Sn,{type:"custom-messages","data-testid":"custom-messages",children:(0,$.jsx)(gt,{withDivider:!0,children:n.map(o=>(0,$.jsx)(gT,{suggestion:o},o.text))})})},t2=()=>{let e=q(Pl),t=Y(),n=V("showAutoflows"),r=M(OC),o=M(es);return Tf(()=>(t(dr(o)),t(NC(o)),()=>{t(MC(o))}),[t,n,o]),!n||r.length===0?null:(0,$.jsx)(Sn,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,$.jsx)(gt,{withDivider:!0,children:(0,$.jsx)(pT,{})})})},n2=()=>{let e=Y(),t=M(jd),n=M(yb),r=M(rT),o=M(B1),i=M(zd),s=M(Vd),a=M(ir),l=M(Gr);return(0,Al.useEffect)(()=>{!!o&&!n&&U.warn("Custom data provided, but no schema.")},[o,n]),Tf(()=>{t.forEach(({type:u})=>{u==="entities"?e(dn()):ou.includes(u)||e(pn(u))})},[e,l,a]),(0,$.jsx)(Al.Fragment,{children:t.map(({type:u,title:c,amount:f,lines:d,schema:p})=>{var v,y;switch(u){case"entities":return i&&i.length>0&&(0,$.jsx)(Sn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(yT,{entities:i})},u);case"cues":return r&&r.length>0&&(0,$.jsx)(Sn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(gt,{withDivider:!0,children:(0,$.jsx)(BT,{cues:r})})},u);case"custom-data":return o&&p&&(0,$.jsx)(Sn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(gt,{withDivider:!0,children:(0,$.jsx)(VT,{data:o,schema:p})})},u);default:return((y=(v=s[u])==null?void 0:v.suggestions)==null?void 0:y.length)>0&&(0,$.jsx)(Sn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(gt,{withDivider:!0,children:(0,$.jsx)(qT,{lines:d,contentType:u,suggestions:s[u].suggestions.slice(0,f)||[]})})},u)}})})},r2=({onLogIn:e})=>{let t=q(Pl),n=A("Widget",Rl),r=M(ts),o=M(rt),i=M(es),s=M(ir);return r===!1?(0,$.jsx)(GT,{text:t("notSupported")}):o===!1?(0,$.jsx)(ZM,{onLogIn:e}):!s||!i||o===null?(0,$.jsx)(GT,{text:t("waiting")}):(0,$.jsx)("div",{className:(0,XT.default)(n.root),"data-testid":"widget",children:(0,$.jsxs)(tu,{className:n.sectionList,children:[(0,$.jsx)(JM,{}),(0,$.jsx)(e2,{}),(0,$.jsx)(t2,{}),(0,$.jsx)(n2,{})]})})},YT=r2;function xs(e){let t=new Range;return t.selectNodeContents(e),t}function QT(e,t,n){try{return so(e,t,n),!0}catch(r){return!1}}function kf(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function Pf(e){return"tagName"in e&&e.tagName==="BR"}var Ll=/[\u200B-\u200D\uFEFF]/g;function so(e,t,n){let r=new Range;if(e.firstChild===null&&t===0&&n===0)return r.selectNodeContents(e),r;let o=0,i=!1;function s(l,u){let c=-1,f=/[\u200B-\u200D\uFEFF]/;if(!f.test(l))return u;for(let d=0;d<=l.length;d++)if(f.test(l[d])||c++,c===u)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let u=l.textContent,c=u.replace(Ll,""),f=o+c.length,d=t>=o&&t<=f,p=n>=o&&n<=f;if(d){let v=s(u,t-o);v===0&&!p?r.setStartBefore(l):r.setStart(l,v)}p&&(r.setEnd(l,s(u,n-o)),i=!0),o=f;break}case Node.ELEMENT_NODE:{if(Pf(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;kf(l)&&u&&!kf(u)&&!Pf(u)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function Il(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a,l,u=0;function c(f){let d=f===n,p=f===o;switch(f.nodeType){case Node.TEXT_NODE:{let v=f.textContent;d&&(a=u+v.substring(0,r).replace(Ll,"").length),p&&(l=u+v.substring(0,i).replace(Ll,"").length),u+=v.replace(Ll,"").length;break}case Node.ELEMENT_NODE:{let v=f.nextSibling===null;Pf(f)&&!v&&u++;for(let y=0;y<f.childNodes.length;y++){let g=d&&y===r,m=p&&y===i;if(g&&(a=u),m&&(l=u),l!==void 0||((!g||!s)&&c(f.childNodes[y]),p&&y===i-1&&(l=u),l!==void 0))break}!p&&kf(f)&&!v&&u++,p&&(l=u);break}default:break}}if(c(e),l===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:l,end:l}}function Ol(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,f=u===o;switch(c&&s++,u.nodeType){case Node.TEXT_NODE:{if(s!==0)return;let d=c?r:0,p=f?i:void 0,v=u.textContent.replace(Ll,"");d===0&&p===void 0?a+=v:a+=v.substring(d,p);break}case Node.ELEMENT_NODE:{let d=u.nextSibling===null;s===0&&Pf(u)&&!d&&(a+=`
26
26
  `);for(let p=c?r:0;p<(f?Math.min(i,u.childNodes.length):u.childNodes.length)&&(l(u.childNodes[p]),s!==1);p++);!f&&s===0&&kf(u)&&!d&&(a+=`
27
- `);break}default:break}f&&s++}return l(e),a}var ZT=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(ZT||{}),pr=class{constructor(t){this.element=t;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(t,n){let r=o=>{n(o)};this.element.addEventListener(t,r),this.disposeHandlers.push(()=>{this.element.removeEventListener(t,r)})}removeEventListener(t,n){this.element.removeEventListener(t,n)}handleInteraction(){let t=this.getText(),n=this.getHTML(),r=this.getSelection(),o=this.getCaretPosition();this.isActive&&(t===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),t!==this.cachedText&&(this.cachedText=t,this.cachedHTML=n,this.emit("change",{plainText:t,rawHTML:n})),(r.start!==this.cachedSelection.start||r.end!==this.cachedSelection.end)&&(this.cachedSelection=r,this.emit("selection",r)),qr(o,this.cachedCaretPosition)||(this.cachedCaretPosition=o,this.emit("caretposition",o)))}handleClick(){this.handleInteraction()}handleFocus(){let t=!this.isFocused;this.isFocused=!0,t&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let t=this.isFocused;this.isFocused=!1,t&&this.emit("blur")}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(ZT).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleKeyUp(t){this.handleInteraction(),this.emit("keyup",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let t=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{t.disconnect()})}focus(){this.element.focus()}emit(t,...n){this.isDisposed||this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r(...n)})}on(t,n){this.isDisposed||(this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n))}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};function JT(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var Zo=class extends pr{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),Ol(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){var s;let n=this.getRootNode();if(n.activeElement!==this.element)return null;let r="getSelection"in n?n.getSelection():window.getSelection();if(!r)return null;let o="getComposedRanges"in r&&n instanceof ShadowRoot?(s=r.getComposedRanges(n))==null?void 0:s[0]:r.rangeCount>0?r.getRangeAt(0):null;if(!o)return null;let i=this.element.ownerDocument.createRange();return i.setStart(o==null?void 0:o.startContainer,o==null?void 0:o.startOffset),i.setEnd(o==null?void 0:o.endContainer,o==null?void 0:o.endOffset),!i||!this.element.contains(i.startContainer)||!this.element.contains(i.endContainer)?null:i}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let r=n.getBoundingClientRect();return!JT(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!JT(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return Il(this.element,n);let r=this.lastKnownSelection;if(r&&QT(this.element,r.start,r.end))return r;let o=xs(this.element);return o.collapse(!1),Il(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return Ol(this.element,so(this.element,n,r))}listen(){super.listen();let n=new MutationObserver(()=>{setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let r=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==r&&(r=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}};var Jo=class extends pr{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:r}=this.element;return{start:n,end:r}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return null}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var i;return(i=n==null?void 0:n.get)==null?void 0:i.call(this.element)},set:i=>{var s;(s=n==null?void 0:n.set)==null||s.call(this.element,i),this.handleInteraction()}});let r=this.element.disabled,o=new MutationObserver(()=>{this.element.disabled!==r&&(r=this.element.disabled,this.emit(r?"disabled":"enabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>o.disconnect())}};function ek(e,t,n){let r=`deepdesk-iframe-${e}`,o=document.getElementById(r);if(o)return o;let i=document.createElement("iframe"),s=new URL(t);return Object.entries(n).forEach(([a,l])=>{s.searchParams.append(a,l)}),i.style.position="absolute",i.style.left="-999em",i.style.width="0px",i.style.height="0px",i.tabIndex=-1,i.id=r,i.title=`iframe-${e}`,i.src=s.toString(),window.document.body.appendChild(i),i}function o2(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var Ry=class{constructor(t){this.name=t;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(t)}onMessage(t){this.broadcastChannel.addEventListener("message",t),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",t)})}postMessage(t){this.broadcastChannel.postMessage(JSON.stringify(t))}close(){this.disposeHandlers.forEach(t=>t()),this.broadcastChannel.close()}},Ay=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=ek(t,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(t){window.addEventListener("message",t),this.disposeHandlers.push(()=>{window.removeEventListener("message",t)})}postMessage(t){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(t),this.targetOrigin)}close(){var t;this.disposeHandlers.forEach(n=>n()),(t=this.iframe)==null||t.remove()}},Ly=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(t){this.sessionId!==t&&(this.cleanup(),U.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 Ay(t,this.deepdeskUrl,{debug:!0}):new Ry(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=o2(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(U.info("Received broadcast event",this.sessionId,o),(a=(s=this.eventMap)[i.name])==null||a.call(s,i.payload))};return n.onMessage(r),n}send(t,n,r){var s,a;U.info("Broadcast event",{sessionId:this.sessionId,name:t,payload:n});let o={type:"event",name:t,payload:n};r!==!1&&((a=(s=this.eventMap)[t])==null||a.call(s,n));let i=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;i==null||i.postMessage(L(T({},o),{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)}},tk=Ly;var Es=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var Iy=e=>new Promise(t=>{setTimeout(t,e)});var bs=class extends Es{constructor(){super(...arguments);this.name="ClientError"}},Ny=class extends Es{constructor(){super(...arguments);this.name="ServerError"}},Oy=new Map;function i2(e){return k(this,null,function*(){if(e.status===204)return e.text().catch(()=>{}),null;let t=e.headers.get("content-type");if(t&&t.includes("application/json"))return e.json();let n=yield e.text();return n===""?null:(U.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var ao=class ao{constructor(t="",n={}){this.baseUrl=t;this.options=n;this.latestRequestByUrl={};this.fetch=window.fetch.bind(window);n.fetch&&(this.fetch=n.fetch)}patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let i={isAborted:!1,reject:o},s=`${this.baseUrl}${t}`,a=this.fetch,l=n.method===void 0||n.method.toLowerCase()==="get",C=n,{useCache:u=!1,abortLatest:c=!1,attempts:f=1,retryDelay:d=500,refreshTokenOn401:p=!0,retryOnError:v=R=>R instanceof TypeError,retryOnResponse:y=R=>R.status>=500,version:g="v1"}=C,m=ne(C,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(u)if(l){if(Oy.has(s)){r(Oy.get(s));return}}else throw new Error(`Can't use 'useCache' for ${n.method}`);let h=L(T({credentials:"include"},m),{headers:T({Accept:"application/json","Content-Type":"application/json"},m.headers)});!l&&this.csrfToken&&(h.headers=L(T({},h.headers),{"X-CSRFToken":this.csrfToken})),typeof g=="string"&&(h.headers=L(T({},h.headers),{"X-Deepdesk-API-Version":g}));let S=f,x=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&c&&(this.latestRequestByUrl[s].isAborted=!0,this.latestRequestByUrl[s].reject(new Error("Aborted"))),this.latestRequestByUrl[s]=i;let P=()=>k(this,null,function*(){return S--,a(s,h).then(R=>k(this,null,function*(){return y(R)&&!i.isAborted&&S>0?(yield Iy(d),P()):R.status===401&&p===!0&&x===!1?(x=!0,yield this.refreshToken(),P()):R})).catch(R=>k(this,null,function*(){if(v(R)&&!i.isAborted&&S>0)return yield Iy(d),P();throw R}))});P().then(R=>k(this,null,function*(){let N=yield i2(R);if(delete this.latestRequestByUrl[s],R.status>=500){o(new Ny("Server Error",N));return}else if(R.status===401){o(new bs("Unauthorized",N));return}else if(R.status===403){o(new bs("Forbidden",N));return}else if(R.status===404){o(new bs("Not Found",N));return}else if(R.status>=400){o(new bs("Bad Request",N));return}u&&Oy.set(s,N),r(N)})).catch(R=>{o(R)})})}validateToken(){return k(this,null,function*(){let{has_valid_access_token:t}=yield this.get("/auth/validate");if(!t)try{yield this.refreshToken()}catch(r){return!1}let{is_logged_in:n}=yield this.get("/apis/admin/session/validate/",{version:null});return!!n})}refreshToken(){return ao.refreshingToken||(ao.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{ao.refreshingToken=null},1e3*60)})),ao.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,T({method:"POST",body:JSON.stringify(n)},r))}patch(t,n,r){return this.request(t,T({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,T({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,T({method:"DELETE"},n))}};ao.refreshingToken=null;var vn=ao;var nk;(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||(t.EventType={}))})(nk||(nk={}));function Rf(e){return L(T({},te(e)),{tags:e.tags})}var ei=class ei{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new vn(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,i)=>k(this,null,function*(){let s=yield r(o,i);return this.handleDeepdeskVersionHeaders(s),s}))}preflight(){return k(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(ei.exchangeTokenPromise||(ei.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),ei.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return k(this,null,function*(){yield this.preflight(),U.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=yield this.client.post("/api/conversations",L(T({},Oe(t)),{tags:t.tags}),{version:"v2"});return Rf(n)})}getProfile(t){return k(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{version:null,useCache:!0});return te(n)})}getKnowledgeAssistant(t){return k(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{version:null,useCache:!0});return te(n)})}getContentTypes(){return k(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{version:null,useCache:!0});return te(t)})}getAccount(){return k(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{version:null,useCache:!0});return te(t)})}getPlatformConfig(){return k(this,null,function*(){let{config:t}=yield this.client.get("/platform/config/",{version:null,useCache:!0});return te(t)})}checkUserExists(t){return k(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`);return n})}getConversationBySessionId(r){return k(this,arguments,function*(t,n={}){yield this.preflight(),U.info(`Getting conversation for session ${t}`);let{attempts:o=1,retryDelay:i=1e3}=n,s=yield this.client.get(`/api/conversations/by_session_id/${t}`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return U.info(`Successfully retrieved conversation ${s.id} for session ${t}`),Rf(s)})}isConversationSupported(r){return k(this,arguments,function*(t,n={}){U.info(`Check if conversation for session ${t} is supported`);let{attempts:o=1,retryDelay:i=1e3}=n;return(yield this.client.get(`/api/conversations/by_session_id/${t}/active_profile`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"})).has_active_profile})}updateConversation(t,n){return k(this,null,function*(){let r=Oe(n);n.tags&&(r.tags=n.tags);let o=yield this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return Rf(o)})}postMessages(t,n){return k(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/messages`,n.map(o=>L(T({},Oe(o)),{tags:o.tags})),{version:"v2"})).map(o=>Rf(o))})}sendEvent(t,n){return k(this,null,function*(){let s=n,{data:r}=s,o=ne(s,["data"]),i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((a,[l,u])=>L(T({},a),{[l]:u}),{});return this.client.post("/api/events",Oe(L(T(T({},i),o),{data:r,name:t})),{version:"v2"})})}sendEventV1(t,n){return k(this,null,function*(){let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>L(T({},o),{[i]:s}),{});return this.client.post("/api/events",{event:t,data:Oe(T(T({},n),r))})})}getEntities(t){return k(this,null,function*(){return(yield this.client.post("/api/entities",{messages:t.filter(r=>r.text)})).entities})}getSummary(r){return k(this,arguments,function*(t,n={}){let o=yield this.client.post("/api/summary",{conversation:{messages:t.filter(i=>i.text&&i.source),agent_id:n.agentId,id:n.externalConversationId},prompt_instruction:n.promptInstruction,model:n.model});return te(o)})}getTemporaryExchangeToken(){return k(this,null,function*(){return(yield this.client.get("/auth/exchange-token",{version:null})).jwt})}exchangeTokenForAccessCookie(t){return k(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t},{version:null}).catch(n=>{throw U.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return k(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Oe(n),{version:null,refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return k(this,arguments,function*(t,n={},r){return r==="sticky-messages"?this.getPinnedMessages(t):(yield this.client.post(`/api/conversations/${t}/recommend/${r}`,Oe(n),{abortLatest:!0})).map(s=>L(T({},te(s)),{text:s.text||s.url||s.message,source:r,type:r})).filter((s,a,l)=>a===l.findIndex(u=>u.text===s.text))})}isLoggedIn(){return k(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return k(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/autocomplete`,Oe(n),{abortLatest:!0})).map(o=>({score:1,source:o.source,sourceText:o.source_text,text:o.label,trainingJobs:o.training_jobs,searchKeywords:o.search_keywords,type:o.source})).filter((o,i,s)=>i===s.findIndex(a=>a.text===o.text))})}getPinnedMessages(t){return k(this,null,function*(){let n=yield this.client.get(`/api/conversations/${t}/sticky-messages`,{abortLatest:!0});return te(n).map(r=>L(T({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return k(this,null,function*(){let n=yield this.client.post("/api/style-suggestions",Oe(t),{abortLatest:!0});return te(n)})}search(t){return k(this,null,function*(){let n=yield this.client.post(`/api/profiles/${t.profile}/search`,Oe(t),{version:"v2"});return te(n)})}knowledgeAssist(i,s,a){return k(this,arguments,function*(t,n,r,o={}){let l=yield this.client.post(`/api/knowledge-assist/assistants/${r}/search`,Oe({question:t.question,doNotKnowAnswer:t.doNotKnowAnswer,customerInstruction:t.customerInstruction,chatHistory:n.map(u=>({question:u.question,answer:u.answer.answer})),agentId:o.agentId,conversationId:o.conversationId}),{version:"v2"});return te(l)})}requestLoginByEmail(t){return k(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t},{version:null});return te(n)})}requestPasswordlessToken(){return k(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/",{version:null});return te(t.token)})}getCsrfToken(){return k(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/",{version:null});return t})}verifyLoginToken(t){return k(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t},{version:null});return te(n)})}evaluateRule(i,s,a){return k(this,arguments,function*(t,n,r,o={}){let l=new URLSearchParams;o.raiseForFailingConditions&&l.set("raise_for_failing_conditions","true");let u=yield this.client.post(`/api/conversations/${n}/rules/${t}/evaluate?${l.toString()}`,r,{version:"v2"});return u?te(u.cues):[]})}evaluateAssistant(t,n,r){return k(this,null,function*(){let o=new URLSearchParams;r!=null&&r.conversationId&&o.append("conversation_id",r==null?void 0:r.conversationId);let i=yield this.client.post(`/api/v2/assistants/${t}/evaluate?${o.toString()}`,{input:n},{version:null});return te(i.output)})}getRules(){return k(this,null,function*(){let t=new URLSearchParams,n=yield this.client.get(`/apis/admin/rule-engine/rules/?${t.toString()}`,{version:null,useCache:!0});return te(n)})}translateMessages(t){return k(this,null,function*(){let n=yield this.client.post("/api/translate",Oe(t),{version:"v2"});return te(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(Qv);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&U.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};ei.exchangeTokenPromise=null;var mr=ei;var Nl=class{constructor(t,n){this.url=t;this.eventListeners={};this.options=T({timeout:25e3},n)}proxyEvent(t){this.eventSource.addEventListener(th(t),n=>{let{data:r}=n;try{let o=JSON.parse(r);this.emit(t,te(o))}catch(o){U.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 rk;(t=>{let e;(i=>(i.Started="Started",i.Aborted="Aborted",i.Completed="Completed"))(e=t.AutoflowSessionState||(t.AutoflowSessionState={}))})(rk||(rk={}));var Ml=class{constructor(t,n={}){this.apiUrl=t;this.streams={};this.logger=U;this.client=new vn(t,n)}getCustomMessages(t){return k(this,null,function*(){let n=yield this.client.get(`/sessions/${t}/suggestions`);return te(n.suggestions)})}sendCustomMessage(t,n){return k(this,null,function*(){let r=yield this.client.post(`/sessions/${t}/messages`,Oe(n));return te(r)})}answerCustomMessage(t,n){return k(this,null,function*(){yield this.client.post(`/sessions/${t}/answers`,Oe(n))})}getAutoflows(t){return k(this,null,function*(){let n=yield this.client.get(`/sessions/${t}/autoflows`);return te(n.autoflows)})}startAutoflowSession(t){return k(this,null,function*(){let n=yield this.client.post("/autoflow-sessions",Oe(t));return te(n)})}stopAutoflowSession(t){return k(this,null,function*(){yield this.client.delete(`/autoflow-sessions/${t}`)})}openStream(t){return this.streams[t]||(this.streams[t]=new Nl(`${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 ok={startTime:null,stopTime:null},ik=X({name:"handlingTime",initialState:ok,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(de,()=>ok)}}),{handlingTimeStart:sk,handlingTimeStop:Af,handlingTimeReset:ak}=ik.actions,lk=ik.reducer;var uk=(e={})=>{let t=T({onAuthError:Ji(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var Lf={list:{keywordMatches:[]},fetchState:"idle"};var ti=K("styleSuggestions/getAll",(n,r)=>k(void 0,[n,r],function*({text:e},t){var l;let{deepdeskAPI:o}=t.extra,i=t.getState(),{showStyleSuggestions:s}=i.settings,a=(l=i.conversation.current)==null?void 0:l.profileCode;if(!s)return Lf.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),s2=X({name:"styleSuggestions",initialState:Lf,reducers:{},extraReducers:e=>{e.addCase(ti.pending,t=>{t.fetchState="loading"}).addCase(ti.rejected,t=>{t.fetchState="error"}).addCase(ti.fulfilled,(t,n)=>{t.fetchState="done",qr(t.list,n.payload)||(t.list=n.payload)}).addCase(Oo,t=>{t.list=Lf.list}).addCase(de,()=>Lf)}}),ck=s2.reducer;var dk=(e={})=>{let t,n=!0,r=T({getStyleSuggestions:ti,debounce:500},e);return o=>i=>s=>{var p;let a=o.getState().input.text,l=i(s),u=o.getState();if(u.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:c}=u.settings;if(!((p=u.conversation.current)==null?void 0:p.id)||!c)return l;let{text:d}=u.input;return d===a&&!n||(clearTimeout(t),d==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:d}))},e.debounce)),l}};function a2(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var fk=(e={})=>{let t=T({getTextSuggestions:pn,getAutocompleteSuggestions:dl,debounce:200,check:An},e),n;return r=>o=>i=>{var y;let{input:s}=r.getState(),a=o(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:u,showTabCompletion:c}=l.settings,f=(y=l.conversation.current)==null?void 0:y.id,d=i.type===Kd.toString();if(!f||!u&&!c)return a;let{input:p}=l;return a2(p,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let g=ns(l);g===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(g))},d?0:t.debounce)),a}};var pk=ti.fulfilled.toString();function l2(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 mk=e=>t=>n=>r=>{var u;if(r.type!==pk){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=l2(o,s);r.type===pk&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var u2=Cc({assistants:QC,answer:mb,auth:y1,autoflows:_C,conversation:P1,contentTypes:CE,customMessages:KC,passwordlessToken:qC,entities:XE,knowledgeAssistant:db,handlingTime:lk,info:$1,input:U1,settings:c1,profile:vb,search:J1,summary:nb,styleSuggestions:ck,ui:qb,rules:nT,textSuggestions:kb});function gk(e){return hx({reducer:u2,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI,deepdeskBrokerAPI:e.deepdeskBrokerAPI}},serializableCheck:!1}),uk(),fk({debounce:200}),dk({debounce:500}),mk(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var c2=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},d2=e=>t=>n=>r=>{var a,l,u,c,f,d;let o=t.getState(),i=Xg("inlineSuggestions")(o);switch(r.type){case Ji.toString():{!r.payload&&e.emit("logout",void 0);break}case dn.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:(a=o.conversation.current)==null?void 0:a.id,data:{entities:r.payload}});break;case ot.toString():e.sendEvent(r.payload.name,{conversationId:((l=r.payload.options)==null?void 0:l.includeConversationData)&&((u=o.conversation.current)==null?void 0:u.id),data:r.payload.data});break;case Oo.toString():e.logSendMessage(r.payload);break;case Yo.fulfilled.toString():r.isBroadcasted||e.broadcast(oh,r,!1),(c=r.payload.options)!=null&&c.shouldEmit&&e.emit("cues",r.payload.cues);break;case Xo.fulfilled.toString():r.isBroadcasted||e.broadcast(ih,r,!1);break;default:break}let s=n(r);switch(r.type){case Oo.toString():e.handleAfterSendMessage(r.payload);break;case pl.toString():e.onUpdateShowTabHint(r.payload);break;case Af.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case id.toString():{let{start:p,end:v}=o.input.selection;e.emit("replace",L(T({},r.payload),{replace:r.payload.replace==="selection"?{start:p,end:v}:{start:0,end:v}}));break}case on.toString():{let{start:p,end:v}=o.input.selection;e.emit("select-suggestion",L(T({type:c2(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:p,end:v}:{start:0,end:v}})),i&&t.dispatch(Yn([]));break}case sd.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(f=o.conversation.current)==null?void 0:f.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case Yn.toString():{i&&r.payload.length>0&&t.dispatch(ad(0));break}case nr.fulfilled.toString():{e.sendEvent("conversation summarized",{conversationId:(d=o.conversation.current)==null?void 0:d.id,data:{summary:r.payload.summary,model:t.getState().summary.model}});break}default:break}return s},hk=d2;function My(e){return e.toISOString().replace("T"," ").replace("Z","")}function yk(e,t){var i,s,a,l;let n=(i=e.conversation.current)==null?void 0:i.id;if(!n)return U.warn("No conversationId for handling time metrics"),null;let{startTime:r,stopTime:o}=e.handlingTime;return!r||!o?(U.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:n,clientVersion:t.version,agentId:(s=e.info.agentInfo)==null?void 0:s.agentId,agentName:(a=e.info.agentInfo)==null?void 0:a.agentName,agentEmail:(l=e.info.agentInfo)==null?void 0:l.agentEmail,timeStart:My(r),timeStop:My(o)}}function vk(e,t,n){var N,_,D,G;let r=(N=t.conversation.current)==null?void 0:N.id;if(!r)return U.warn("No conversationId for send message metrics"),null;let{text:o,metrics:{numCharsTyped:i,numCharsPasted:s,numCharsCut:a,numCharsDeleted:l,numPaste:u,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:f,pastes:d,cuts:p,deletions:v,textSuggestions:y,offeredTextSuggestions:g}}=t[e],m=o.length,S=y.reduce((Z,{text:se,searchTerm:gr})=>Z+se.length-(gr?gr.length:0),0),x=c!=null?c:Date.now(),P=(Date.now()-x)/1e3+(f||0),C=i/P,R=y.reduce((Z,{searchTerm:se})=>Z+(se?se.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:d,cuts:p,deletions:v,lenTextTyped:i+R,lenTextTotal:m,lenTextAssisted:S,lenTextPasted:s,lenTextCut:a,lenTextDeleted:l,timeTotalSeconds:P,charsPerSecond:C,numPastes:u,textSuggestionsV2:y,suggestionsCounters:[{source:"gpt",countOffered:g.filter(Z=>Z.source==="gpt").length}],agentId:(_=t.info.agentInfo)==null?void 0:_.agentId,agentName:(D=t.info.agentInfo)==null?void 0:D.agentName,agentEmail:(G=t.info.agentInfo)==null?void 0:G.agentEmail}}function _y(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return _y(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?_y(o,t):null}function Sk(e,t){return _y(e,t)}function wk(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function f2(e){return typeof e=="object"&&e!==null&&"tagName"in e}function If(e){return f2(e)&&(no(e)||tf(e))}var Ek,Nn=new Map,p2=["bottom","height","left","right","top","width"],xk=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:p2.some(n=>e[n]!==t[n]);function bk(e){var n,r,o;if(e.ownerDocument===document)return[];let t=(o=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)!=null?o:null;return t?[t,...bk(t)]:[]}function Ck(e,t){return!e||!t?null:L(T({},e),{top:e.top+t.top,left:e.left+t.left})}var Of=!1,Tk=()=>{Of=!0;let e=[];if(Nn.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Nn.delete(n);return}let r=n.getBoundingClientRect();xk(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(Ck,t.rect):t.rect;xk(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Nn.size===0){Of=!1;return}Ek=window.requestAnimationFrame(Tk)};function Dy(e,t){let n=bk(e),r=[],o=n.map((i,s)=>Dy(i,a=>{r[s]=a;let l=Nn.get(e);if(!l)return;let u=r.reduce(Ck,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),Nn.has(e)){let s=Nn.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else Nn.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Of&&Tk()},unobserve(){o.forEach(s=>s.unobserve());let i=Nn.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||Nn.delete(e),Nn.size||(cancelAnimationFrame(Ek),Of=!1)}}}}var kk,Mn=new Map,Pk=()=>{Mn.forEach((e,t)=>{if(!t.isConnected){Mn.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)))}),Mn.size!==0&&(kk=window.requestAnimationFrame(Pk))};function Rk(e,t){return{observe(){let n=Mn.size===0;Mn.has(e)?Mn.get(e).callbacks.push(t):Mn.set(e,{visible:void 0,callbacks:[t]}),n&&Pk()},unobserve(){let n=Mn.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Mn.delete(e),Mn.size||cancelAnimationFrame(kk)}}}}var Fy=["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 Hy(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function Cs(e){return parseFloat(e)}function Nf(e){return Math.round(e*1e6)}function Ak(e){return e/1e6}function Uy(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=Cs(e.width),i=Cs(e.borderLeftWidth),s=Cs(e.borderRightWidth),a=Cs(e.paddingRight),l=Ak(Nf(o)-Nf(i)-Nf(s)),u=Ak(Nf(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function _l(e,t={}){var c,f;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(c=t.position)!=null?c:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",$o(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};Hy(r,n,Fy),Uy(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=Rk(e,()=>{Hy(r,n,Fy),Uy(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=Dy(e,d=>{if(d===null){t.onRemove&&t.onRemove(),n.remove();return}if(!l&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(Hy(r,n,Fy),Uy(r,e,n),i(),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let p=t.closestScrollElement.getBoundingClientRect(),v=window.getComputedStyle(t.closestScrollElement),y=Cs(v.borderTopWidth),g=Cs(v.borderBottomWidth),m=p.top+y-d.top,h=d.top+d.height+-(p.top+p.height-g);n.style.clipPath=`inset(${m}px 0px ${h}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(f=e.parentElement)==null||f.appendChild(n),u.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),u.unobserve(),s.unobserve()}]}var Lk=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch(r){return t}}catch(n){return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch(r){U.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function m2(e){return e.offsetParent!==null}function Ik(e){if(!m2(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 Mf(e,t,n=100){let r=Ik(e);t({isVisible:r});let o=setInterval(()=>{let i=Ik(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var _e=w(b());var Ok=Lk("showTabHint",!0),Ts=class Ts{constructor({deepdeskUrl:t,brokerUrl:n,version:r=Ts.version||"unknown",locale:o="en-US",token:i,fetch:s,productName:a,createCustomChannel:l}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.widgetRoot=null;this.dynamicThunkObject={};this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let u=t.replace(/\/api$/,"");this.deepdeskApi=new mr(u,{token:i,fetch:s}),this.version=r,this.instanceId=Ts.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[hk({broadcast:(f,d,p)=>{this.broadcastEvents.send(f,d,p)},emit:(f,d)=>this.emit(f,d),handleAfterSendMessage:f=>this.handleAfterSendMessage(f),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:f=>this.logSendMessage(f),onUpdateShowTabHint:f=>Ok.update(f),sendEvent:(f,d)=>this.deepdeskApi.sendEvent(f,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new Ml(n)}),this.store=gk(c),this.broadcastEvents=new tk({debug:!0,deepdeskUrl:u,eventMap:eE(this.store),createCustomChannel:l}),this.store.dispatch(pl(Ok.value())),this.store.dispatch(Jc({locale:o,adminUrl:u,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var t;return(t=this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex])!=null?t:null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(U.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(U.warn("Profile has not been loaded (yet)"),!0):(U.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Ji(null)),this.store.dispatch(Gn()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();rt(r)&&d1(r)!=="loading"&&(n(),t())});this.unmountHandlers.push(()=>{n()})})}isLoggedIn(){return k(this,null,function*(){return(yield this.store.dispatch(Gn())).payload})}setPlatformAgentId(t){return k(this,null,function*(){try{if((yield this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;yield this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:t}),version:null})}catch(n){U.warn("Failed to attach user:",n)}})}isConversationSupported(t,n){return k(this,null,function*(){return(yield this.store.dispatch(Zg({sessionId:t,options:n}))).payload})}createConversation(t){return k(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(td(t))).payload})}getConversationBySessionId(t,n){return k(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(yield this.store.dispatch(nd({sessionId:t,options:n}))).payload})}upsertConversation(t){return k(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(Jg(t))).payload})}postMessages(t){return k(this,null,function*(){return(yield this.store.dispatch(od(t))).payload})}updateConversation(t){return k(this,null,function*(){return(yield this.store.dispatch(rd(t))).payload})}resetConversation(){this.store.dispatch(de()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}getSummary(){return k(this,null,function*(){let t=yield this.store.dispatch(nr());if(t.error)throw new Error(t.error.message);return t.payload.summary})}configure(t){this.store.dispatch(Jc(t))}setVisitorInfo(t){this.store.dispatch(V1(t))}setCustomData(t){this.store.dispatch(K1(t))}setAgentInfo(t){return k(this,null,function*(){yield this.store.dispatch(ja(t))})}setAgentSettings(t){return k(this,null,function*(){yield this.store.dispatch(nh(t))})}getAgentSettings(){return k(this,null,function*(){return(yield this.store.dispatch(rh())).payload})}refresh(){return k(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(ld({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let t=[];return this.store.dispatch(Kd()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}notifyExternalSuggestion(t){this.store.dispatch(on(t))}evaluateRule(o){return k(this,arguments,function*(t,n={},r=ZC){return(yield this.store.dispatch(Yo({label:t,params:n,options:r}))).payload.cues})}evaluateAssistant(r){return k(this,arguments,function*(t,n={}){yield this.store.dispatch(Xo({assistantCode:t,payload:n}))})}handleKeyDown(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:i,selection:s}=this.state.input,{inlineSuggestions:a,showTextSuggestions:l}=this.state.settings,u=a?"below":"above",c=o.length>0;if(!An(this.state)||(this.store.dispatch(O1(eh(t))),t.key!=="Tab"&&!l))return;let f=()=>{n||!c||s&&(t.shiftKey||(this.store.dispatch(_1()),t.preventDefault()))},d=()=>{n||!c||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(D1()),t.preventDefault()))};switch(t.key){case"ArrowUp":u==="below"?d():f();break;case"ArrowDown":{u==="below"?f():d();break}case"Escape":{n||(this.store.dispatch(ad(-1)),this.store.dispatch(eo({collapse:!0})),this.store.dispatch(Wb(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let p=rs(this.state);if(!p)return;this.store.dispatch(pl(!1)),this.store.dispatch(on({text:p.text,suggestion:p,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.state.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let p=rs(this.state);if(!p)return;this.store.dispatch(on({text:p.text,suggestion:p,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.state.settings.inlineSuggestions||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let p=rs(this.state);if(!p)return;this.store.dispatch(on({text:p.text,suggestion:p,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(eo({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(Yn([]))}handlingTimeStart(){this.state.handlingTime.startTime||(U.info("Start handling time"),this.store.dispatch(sk()))}handlingTimeStop(){this.state.handlingTime.startTime&&(U.info("Stop handling time"),this.store.dispatch(Af()))}logSendMessage(t){let n=vk("input",this.state,{version:this.version});n&&(t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n))}logHandlingTime(){let t=yk(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(ak()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(Oo((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(H1()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(i){U.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),U.error(i)}})}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),()=>{this.off(t,n)}}off(t,n){if(!t&&!n){this.eventListeners={};return}let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}setConversationQuery(t){this.dynamicThunkObject.conversationQuery=t}setPlatformVariables(t){this.store.dispatch(W1(t))}whenConversationLoaded(t){let n=()=>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]=_l(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,Qt.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var a;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let i=(a=t.ownerDocument.defaultView)==null?void 0:a.frameElement,s=i.ownerDocument.defaultView;if(i&&(s===window||(s==null?void 0:s.parent)===window)){let[l,u]=_l(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{(0,Qt.unmountComponentAtNode)(o),u()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return $o(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,Qt.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),U.info(`Stored analytics for ${this.conversationId()}`)}catch(t){}}restoreMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(t);if(!n)return;let r=JSON.parse(n);r.text.trim()===this.state.input.text.trim()?(U.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(F1(r.metrics))):U.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch(t){}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!If(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:f,detectSubmit:d,insertLink:p,inputMediator:v,closestScrollSelector:y,appendOverlayTo:g,inlineSuggestions:m,floatingMenu:h}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:p,isEmbedded:f,inlineSuggestions:m,floatingMenu:!!h}),n.automaticHandlingTime&&this.setupHandlingTime(t),$o(t),this.inputMediator=v||(no(t)?new Jo(t):new Zo(t)),this.inputMediator.on("change",({plainText:P,rawHTML:C})=>{this.store.dispatch(ld({text:P,html:C}))}),this.inputMediator.on("keyup",P=>{this.store.dispatch(N1(eh(P)))}),this.inputMediator.on("keydown",P=>{this.handleKeyDown(P)}),this.inputMediator.on("paste",({pastedText:P,selectionText:C})=>{this.store.dispatch(M1({text:P,selectionText:C}))}),this.inputMediator.on("cut",({selectionText:P})=>{this.store.dispatch(I1(P))});let S;this.inputMediator.on("selection",P=>{clearTimeout(S),P===null?S=setTimeout(()=>{P!==null&&this.store.dispatch(ud(P))},500):this.store.dispatch(ud(P))}),this.inputMediator.on("disabled",()=>{var P;(P=this.inputMediator)==null||P.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(Xd(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(Xd(!0))});let x=y&&Sk(t,y)||void 0;if(m){let{customStyles:P,appendOverlayTo:C}=n;if(no(t))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let R=this.createInlineContainer(t,"deepdesk-caret");(0,Qt.render)((0,_e.jsx)(Go,{store:this.store,customStyles:P,children:(0,_e.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(Jb,{})})}),R),this.inputMediator.on("caretposition",_=>{this.store.dispatch(Yn([])),_?(R.style.display="block",R.style.top=`${_.top}px`,R.style.left=`${_.left}px`):R.style.display="none"});let N=this.overlayContainerFactory("floating-menu",x||t,{appendTo:typeof h=="object"&&"appendOverlayTo"in h?h.appendOverlayTo:C},P==null?void 0:P.floatingMenuRootNode);(0,Qt.render)((0,_e.jsx)(Go,{store:this.store,customStyles:P,children:(0,_e.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(jb,{onLogIn:()=>this.loginViaPopup().catch(_=>U.warn(_.message))})})}),N)}else{let P=this.overlayContainerFactory("deepdesk-tab-completion",x||t,{appendTo:g,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||t,{appendTo:g},r==null?void 0:r.suggestionsRootNode);(0,Qt.render)((0,_e.jsx)(Go,{store:this.store,customStyles:r,children:(0,_e.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(AC,{inputElement:t})})}),P),(0,Qt.render)((0,_e.jsx)(Go,{store:this.store,customStyles:r,children:(0,_e.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(lC,{onLogIn:()=>this.loginViaPopup().catch(R=>U.warn(R.message))})})}),C)}(0,Qt.render)((0,_e.jsx)(Go,{store:this.store,customStyles:r,children:(0,_e.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(Fb,{})})}),this.createContainer("deepdesk-overlays")),this.store.dispatch(ld({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(ud(this.inputMediator.getSelection())),this.store.dispatch(Xd(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{var P;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((P=this.state.conversation.current)==null?void 0:P.sessionId)}),this.isMounted=!0}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&&U.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,Qt.render)((0,_e.jsx)(Go,{store:this.store,customStyles:r,children:(0,_e.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(YT,{onLogIn:()=>this.loginViaPopup().catch(s=>U.warn(s.message))})})}),t),this.whenConversationLoaded(()=>{var s;this.broadcastEvents.setSessionId((s=this.state.conversation.current)==null?void 0:s.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Qt.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Mf(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){wk(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>k(this,null,function*(){yield this.store.dispatch(cl());let t=ir(this.state);t&&(yield this.store.dispatch(al()),this.store.dispatch(Jc({showSearch:t.search,showAutoflows:t.autoflows,showCustomMessages:t.customMessages,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:t.summarizer,showKnowledgeSearch:!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions})))})),this.loadProfileConfigPromise)}loginViaPopup(t){return k(this,null,function*(){return new Promise((n,r)=>{let o=new MessageChannel,i=o.port1,s=this.state.settings.adminUrl,a=new URL(t!=null&&t.url?t==null?void 0:t.url:`${s}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,u=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",f),clearInterval(d)};i.onmessage=p=>k(this,null,function*(){var v,y;if((v=p.data)!=null&&v.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((y=p.data)==null?void 0:y.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(Ka),l=!0,o.port1.close(),n()}catch(g){console.error(g),r(g)}finally{l=!0,u()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&r(new Error("Popup blocked by browser"));let f=p=>k(this,null,function*(){var v;if(p.origin===a.origin)switch((v=p.data)==null?void 0:v.type){case"deepdesk-popup-loaded":{try{let y=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(y,a.origin,[o.port2])}catch(y){U.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-error":{u(),p.data.message==="Timeout"&&U.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(p.data.message));break}}});window.addEventListener("message",f);let d=setInterval(()=>{c&&!c.closed||(u(),l||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(u)})})}translateMessages(t){return this.deepdeskApi.translateMessages(t)}checkForTrialMode(t){return k(this,null,function*(){try{let{account:n}=yield this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(U.info("Trial is active"),!(yield this.deepdeskApi.checkUserExists(t)))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:r}=n;U.info(r),this.shouldRender=!1}})}refreshWidgetSuggestions(){return k(this,null,function*(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=jd(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(dn()):ou.includes(r)||this.store.dispatch(pn(r))})}catch(r){this.handleError(r)}})}};Ts.version="12.1.1-beta.0",Ts.count=0;var Dl=Ts;function Nk(r,o){return k(this,arguments,function*(e,t,n={}){var f,d;let{value:i}=e,{start:s,end:a}=(f=n.replace)!=null?f:{start:0,end:i.length},l=`${i.slice(0,s)}${t}${i.slice(a)}`,u=(d=n.selectionAfter)!=null?d:{start:s+t.length,end:s+t.length},c=()=>{if(n.setValue)return n.setValue(l);e.value=l};return Promise.resolve(c()).then(()=>{e.selectionStart=u.start,e.selectionEnd=u.end,e.blur(),e.focus()})})}function Mk(r,o){return k(this,arguments,function*(e,t,n={}){let i=n.replace?so(e,n.replace.start,n.replace.end):xs(e),s,a=()=>{if(n.setRange)return n.setRange(i.cloneRange());i.deleteContents(),s=document.createElement("span"),i.insertNode(s),n.insertBRs!==!1?t.split(`
27
+ `);break}default:break}f&&s++}return l(e),a}var ZT=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(ZT||{}),pr=class{constructor(t){this.element=t;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(t,n){let r=o=>{n(o)};this.element.addEventListener(t,r),this.disposeHandlers.push(()=>{this.element.removeEventListener(t,r)})}removeEventListener(t,n){this.element.removeEventListener(t,n)}handleInteraction(){let t=this.getText(),n=this.getHTML(),r=this.getSelection(),o=this.getCaretPosition();this.isActive&&(t===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),t!==this.cachedText&&(this.cachedText=t,this.cachedHTML=n,this.emit("change",{plainText:t,rawHTML:n})),(r.start!==this.cachedSelection.start||r.end!==this.cachedSelection.end)&&(this.cachedSelection=r,this.emit("selection",r)),qr(o,this.cachedCaretPosition)||(this.cachedCaretPosition=o,this.emit("caretposition",o)))}handleClick(){this.handleInteraction()}handleFocus(){let t=!this.isFocused;this.isFocused=!0,t&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let t=this.isFocused;this.isFocused=!1,t&&this.emit("blur")}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(ZT).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleKeyUp(t){this.handleInteraction(),this.emit("keyup",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let t=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{t.disconnect()})}focus(){this.element.focus()}emit(t,...n){this.isDisposed||this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r(...n)})}on(t,n){this.isDisposed||(this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n))}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};function JT(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var Zo=class extends pr{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),Ol(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){var s;let n=this.getRootNode();if(n.activeElement!==this.element)return null;let r="getSelection"in n?n.getSelection():window.getSelection();if(!r)return null;let o="getComposedRanges"in r&&n instanceof ShadowRoot?(s=r.getComposedRanges(n))==null?void 0:s[0]:r.rangeCount>0?r.getRangeAt(0):null;if(!o)return null;let i=this.element.ownerDocument.createRange();return i.setStart(o==null?void 0:o.startContainer,o==null?void 0:o.startOffset),i.setEnd(o==null?void 0:o.endContainer,o==null?void 0:o.endOffset),!i||!this.element.contains(i.startContainer)||!this.element.contains(i.endContainer)?null:i}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let r=n.getBoundingClientRect();return!JT(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!JT(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return Il(this.element,n);let r=this.lastKnownSelection;if(r&&QT(this.element,r.start,r.end))return r;let o=xs(this.element);return o.collapse(!1),Il(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return Ol(this.element,so(this.element,n,r))}listen(){super.listen();let n=new MutationObserver(()=>{setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let r=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==r&&(r=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}};var Jo=class extends pr{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:r}=this.element;return{start:n,end:r}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return null}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var i;return(i=n==null?void 0:n.get)==null?void 0:i.call(this.element)},set:i=>{var s;(s=n==null?void 0:n.set)==null||s.call(this.element,i),this.handleInteraction()}});let r=this.element.disabled,o=new MutationObserver(()=>{this.element.disabled!==r&&(r=this.element.disabled,this.emit(r?"disabled":"enabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>o.disconnect())}};function ek(e,t,n){let r=`deepdesk-iframe-${e}`,o=document.getElementById(r);if(o)return o;let i=document.createElement("iframe"),s=new URL(t);return Object.entries(n).forEach(([a,l])=>{s.searchParams.append(a,l)}),i.style.position="absolute",i.style.left="-999em",i.style.width="0px",i.style.height="0px",i.tabIndex=-1,i.id=r,i.title=`iframe-${e}`,i.src=s.toString(),window.document.body.appendChild(i),i}function o2(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var Ry=class{constructor(t){this.name=t;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(t)}onMessage(t){this.broadcastChannel.addEventListener("message",t),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",t)})}postMessage(t){this.broadcastChannel.postMessage(JSON.stringify(t))}close(){this.disposeHandlers.forEach(t=>t()),this.broadcastChannel.close()}},Ay=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=ek(t,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(t){window.addEventListener("message",t),this.disposeHandlers.push(()=>{window.removeEventListener("message",t)})}postMessage(t){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(t),this.targetOrigin)}close(){var t;this.disposeHandlers.forEach(n=>n()),(t=this.iframe)==null||t.remove()}},Ly=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(t){this.sessionId!==t&&(this.cleanup(),U.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 Ay(t,this.deepdeskUrl,{debug:!0}):new Ry(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=o2(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(U.info("Received broadcast event",this.sessionId,o),(a=(s=this.eventMap)[i.name])==null||a.call(s,i.payload))};return n.onMessage(r),n}send(t,n,r){var s,a;U.info("Broadcast event",{sessionId:this.sessionId,name:t,payload:n});let o={type:"event",name:t,payload:n};r!==!1&&((a=(s=this.eventMap)[t])==null||a.call(s,n));let i=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;i==null||i.postMessage(L(T({},o),{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)}},tk=Ly;var Es=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var Iy=e=>new Promise(t=>{setTimeout(t,e)});var bs=class extends Es{constructor(){super(...arguments);this.name="ClientError"}},Ny=class extends Es{constructor(){super(...arguments);this.name="ServerError"}},Oy=new Map;function i2(e){return k(this,null,function*(){if(e.status===204)return e.text().catch(()=>{}),null;let t=e.headers.get("content-type");if(t&&t.includes("application/json"))return e.json();let n=yield e.text();return n===""?null:(U.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var ao=class ao{constructor(t="",n={}){this.baseUrl=t;this.options=n;this.latestRequestByUrl={};this.fetch=window.fetch.bind(window);n.fetch&&(this.fetch=n.fetch)}patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let i={isAborted:!1,reject:o},s=`${this.baseUrl}${t}`,a=this.fetch,l=n.method===void 0||n.method.toLowerCase()==="get",C=n,{useCache:u=!1,abortLatest:c=!1,attempts:f=1,retryDelay:d=500,refreshTokenOn401:p=!0,retryOnError:v=R=>R instanceof TypeError,retryOnResponse:y=R=>R.status>=500,version:g="v1"}=C,m=ne(C,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(u)if(l){if(Oy.has(s)){r(Oy.get(s));return}}else throw new Error(`Can't use 'useCache' for ${n.method}`);let h=L(T({credentials:"include"},m),{headers:T({Accept:"application/json","Content-Type":"application/json"},m.headers)});!l&&this.csrfToken&&(h.headers=L(T({},h.headers),{"X-CSRFToken":this.csrfToken})),typeof g=="string"&&(h.headers=L(T({},h.headers),{"X-Deepdesk-API-Version":g}));let S=f,x=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&c&&(this.latestRequestByUrl[s].isAborted=!0,this.latestRequestByUrl[s].reject(new Error("Aborted"))),this.latestRequestByUrl[s]=i;let P=()=>k(this,null,function*(){return S--,a(s,h).then(R=>k(this,null,function*(){return y(R)&&!i.isAborted&&S>0?(yield Iy(d),P()):R.status===401&&p===!0&&x===!1?(x=!0,yield this.refreshToken(),P()):R})).catch(R=>k(this,null,function*(){if(v(R)&&!i.isAborted&&S>0)return yield Iy(d),P();throw R}))});P().then(R=>k(this,null,function*(){let N=yield i2(R);if(delete this.latestRequestByUrl[s],R.status>=500){o(new Ny("Server Error",N));return}else if(R.status===401){o(new bs("Unauthorized",N));return}else if(R.status===403){o(new bs("Forbidden",N));return}else if(R.status===404){o(new bs("Not Found",N));return}else if(R.status>=400){o(new bs("Bad Request",N));return}u&&Oy.set(s,N),r(N)})).catch(R=>{o(R)})})}validateToken(){return k(this,null,function*(){let{has_valid_access_token:t}=yield this.get("/auth/validate");if(!t)try{yield this.refreshToken()}catch(r){return!1}let{is_logged_in:n}=yield this.get("/apis/admin/session/validate/",{version:null});return!!n})}refreshToken(){return ao.refreshingToken||(ao.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{ao.refreshingToken=null},1e3*60)})),ao.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,T({method:"POST",body:JSON.stringify(n)},r))}patch(t,n,r){return this.request(t,T({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,T({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,T({method:"DELETE"},n))}};ao.refreshingToken=null;var vn=ao;var nk;(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||(t.EventType={}))})(nk||(nk={}));function Rf(e){return L(T({},te(e)),{tags:e.tags})}var ei=class ei{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new vn(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,i)=>k(this,null,function*(){let s=yield r(o,i);return this.handleDeepdeskVersionHeaders(s),s}))}preflight(){return k(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(ei.exchangeTokenPromise||(ei.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),ei.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return k(this,null,function*(){yield this.preflight(),U.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=yield this.client.post("/api/conversations",L(T({},Oe(t)),{tags:t.tags}),{version:"v2"});return Rf(n)})}getProfile(t){return k(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{version:null,useCache:!0});return te(n)})}getKnowledgeAssistant(t){return k(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{version:null,useCache:!0});return te(n)})}getContentTypes(){return k(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{version:null,useCache:!0});return te(t)})}getAccount(){return k(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{version:null,useCache:!0});return te(t)})}getPlatformConfig(){return k(this,null,function*(){let{config:t}=yield this.client.get("/platform/config/",{version:null,useCache:!0});return te(t)})}checkUserExists(t){return k(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`);return n})}getConversationBySessionId(r){return k(this,arguments,function*(t,n={}){yield this.preflight(),U.info(`Getting conversation for session ${t}`);let{attempts:o=1,retryDelay:i=1e3}=n,s=yield this.client.get(`/api/conversations/by_session_id/${t}`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return U.info(`Successfully retrieved conversation ${s.id} for session ${t}`),Rf(s)})}isConversationSupported(r){return k(this,arguments,function*(t,n={}){U.info(`Check if conversation for session ${t} is supported`);let{attempts:o=1,retryDelay:i=1e3}=n;return(yield this.client.get(`/api/conversations/by_session_id/${t}/active_profile`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"})).has_active_profile})}updateConversation(t,n){return k(this,null,function*(){let r=Oe(n);n.tags&&(r.tags=n.tags);let o=yield this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return Rf(o)})}postMessages(t,n){return k(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/messages`,n.map(o=>L(T({},Oe(o)),{tags:o.tags})),{version:"v2"})).map(o=>Rf(o))})}sendEvent(t,n){return k(this,null,function*(){let s=n,{data:r}=s,o=ne(s,["data"]),i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((a,[l,u])=>L(T({},a),{[l]:u}),{});return this.client.post("/api/events",Oe(L(T(T({},i),o),{data:r,name:t})),{version:"v2"})})}sendEventV1(t,n){return k(this,null,function*(){let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>L(T({},o),{[i]:s}),{});return this.client.post("/api/events",{event:t,data:Oe(T(T({},n),r))})})}getEntities(t){return k(this,null,function*(){return(yield this.client.post("/api/entities",{messages:t.filter(r=>r.text)})).entities})}getSummary(r){return k(this,arguments,function*(t,n={}){let o=yield this.client.post("/api/summary",{conversation:{messages:t.filter(i=>i.text&&i.source),agent_id:n.agentId,id:n.externalConversationId},prompt_instruction:n.promptInstruction,model:n.model});return te(o)})}getTemporaryExchangeToken(){return k(this,null,function*(){return(yield this.client.get("/auth/exchange-token",{version:null})).jwt})}exchangeTokenForAccessCookie(t){return k(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t},{version:null}).catch(n=>{throw U.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return k(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Oe(n),{version:null,refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return k(this,arguments,function*(t,n={},r){return r==="sticky-messages"?this.getPinnedMessages(t):(yield this.client.post(`/api/conversations/${t}/recommend/${r}`,Oe(n),{abortLatest:!0})).map(s=>L(T({},te(s)),{text:s.text||s.url||s.message,source:r,type:r})).filter((s,a,l)=>a===l.findIndex(u=>u.text===s.text))})}isLoggedIn(){return k(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return k(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/autocomplete`,Oe(n),{abortLatest:!0})).map(o=>({score:1,source:o.source,sourceText:o.source_text,text:o.label,trainingJobs:o.training_jobs,searchKeywords:o.search_keywords,type:o.source})).filter((o,i,s)=>i===s.findIndex(a=>a.text===o.text))})}getPinnedMessages(t){return k(this,null,function*(){let n=yield this.client.get(`/api/conversations/${t}/sticky-messages`,{abortLatest:!0});return te(n).map(r=>L(T({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return k(this,null,function*(){let n=yield this.client.post("/api/style-suggestions",Oe(t),{abortLatest:!0});return te(n)})}search(t){return k(this,null,function*(){let n=yield this.client.post(`/api/profiles/${t.profile}/search`,Oe(t),{version:"v2"});return te(n)})}knowledgeAssist(i,s,a){return k(this,arguments,function*(t,n,r,o={}){let l=yield this.client.post(`/api/knowledge-assist/assistants/${r}/search`,Oe({question:t.question,doNotKnowAnswer:t.doNotKnowAnswer,customerInstruction:t.customerInstruction,chatHistory:n.map(u=>({question:u.question,answer:u.answer.answer})),agentId:o.agentId,conversationId:o.conversationId}),{version:"v2"});return te(l)})}requestLoginByEmail(t){return k(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t},{version:null});return te(n)})}requestPasswordlessToken(){return k(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/",{version:null});return te(t.token)})}getCsrfToken(){return k(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/",{version:null});return t})}verifyLoginToken(t){return k(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t},{version:null});return te(n)})}evaluateRule(i,s,a){return k(this,arguments,function*(t,n,r,o={}){let l=new URLSearchParams;o.raiseForFailingConditions&&l.set("raise_for_failing_conditions","true");let u=yield this.client.post(`/api/conversations/${n}/rules/${t}/evaluate?${l.toString()}`,r,{version:"v2"});return u?te(u.cues):[]})}evaluateAssistant(t,n,r){return k(this,null,function*(){let o=new URLSearchParams;o.append("enforce_cues_schema","true"),r!=null&&r.conversationId&&o.append("conversation_id",r==null?void 0:r.conversationId);let i=yield this.client.post(`/api/v2/assistants/${t}/evaluate?${o.toString()}`,{input:n},{version:null});return te(i.output)})}getRules(){return k(this,null,function*(){let t=new URLSearchParams,n=yield this.client.get(`/apis/admin/rule-engine/rules/?${t.toString()}`,{version:null,useCache:!0});return te(n)})}translateMessages(t){return k(this,null,function*(){let n=yield this.client.post("/api/translate",Oe(t),{version:"v2"});return te(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(Qv);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&U.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};ei.exchangeTokenPromise=null;var mr=ei;var Nl=class{constructor(t,n){this.url=t;this.eventListeners={};this.options=T({timeout:25e3},n)}proxyEvent(t){this.eventSource.addEventListener(th(t),n=>{let{data:r}=n;try{let o=JSON.parse(r);this.emit(t,te(o))}catch(o){U.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 rk;(t=>{let e;(i=>(i.Started="Started",i.Aborted="Aborted",i.Completed="Completed"))(e=t.AutoflowSessionState||(t.AutoflowSessionState={}))})(rk||(rk={}));var Ml=class{constructor(t,n={}){this.apiUrl=t;this.streams={};this.logger=U;this.client=new vn(t,n)}getCustomMessages(t){return k(this,null,function*(){let n=yield this.client.get(`/sessions/${t}/suggestions`);return te(n.suggestions)})}sendCustomMessage(t,n){return k(this,null,function*(){let r=yield this.client.post(`/sessions/${t}/messages`,Oe(n));return te(r)})}answerCustomMessage(t,n){return k(this,null,function*(){yield this.client.post(`/sessions/${t}/answers`,Oe(n))})}getAutoflows(t){return k(this,null,function*(){let n=yield this.client.get(`/sessions/${t}/autoflows`);return te(n.autoflows)})}startAutoflowSession(t){return k(this,null,function*(){let n=yield this.client.post("/autoflow-sessions",Oe(t));return te(n)})}stopAutoflowSession(t){return k(this,null,function*(){yield this.client.delete(`/autoflow-sessions/${t}`)})}openStream(t){return this.streams[t]||(this.streams[t]=new Nl(`${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 ok={startTime:null,stopTime:null},ik=X({name:"handlingTime",initialState:ok,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(de,()=>ok)}}),{handlingTimeStart:sk,handlingTimeStop:Af,handlingTimeReset:ak}=ik.actions,lk=ik.reducer;var uk=(e={})=>{let t=T({onAuthError:Ji(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var Lf={list:{keywordMatches:[]},fetchState:"idle"};var ti=K("styleSuggestions/getAll",(n,r)=>k(void 0,[n,r],function*({text:e},t){var l;let{deepdeskAPI:o}=t.extra,i=t.getState(),{showStyleSuggestions:s}=i.settings,a=(l=i.conversation.current)==null?void 0:l.profileCode;if(!s)return Lf.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),s2=X({name:"styleSuggestions",initialState:Lf,reducers:{},extraReducers:e=>{e.addCase(ti.pending,t=>{t.fetchState="loading"}).addCase(ti.rejected,t=>{t.fetchState="error"}).addCase(ti.fulfilled,(t,n)=>{t.fetchState="done",qr(t.list,n.payload)||(t.list=n.payload)}).addCase(Oo,t=>{t.list=Lf.list}).addCase(de,()=>Lf)}}),ck=s2.reducer;var dk=(e={})=>{let t,n=!0,r=T({getStyleSuggestions:ti,debounce:500},e);return o=>i=>s=>{var p;let a=o.getState().input.text,l=i(s),u=o.getState();if(u.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:c}=u.settings;if(!((p=u.conversation.current)==null?void 0:p.id)||!c)return l;let{text:d}=u.input;return d===a&&!n||(clearTimeout(t),d==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:d}))},e.debounce)),l}};function a2(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var fk=(e={})=>{let t=T({getTextSuggestions:pn,getAutocompleteSuggestions:dl,debounce:200,check:An},e),n;return r=>o=>i=>{var y;let{input:s}=r.getState(),a=o(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:u,showTabCompletion:c}=l.settings,f=(y=l.conversation.current)==null?void 0:y.id,d=i.type===Kd.toString();if(!f||!u&&!c)return a;let{input:p}=l;return a2(p,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let g=ns(l);g===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(g))},d?0:t.debounce)),a}};var pk=ti.fulfilled.toString();function l2(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 mk=e=>t=>n=>r=>{var u;if(r.type!==pk){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=l2(o,s);r.type===pk&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var u2=Cc({assistants:QC,answer:mb,auth:y1,autoflows:_C,conversation:P1,contentTypes:CE,customMessages:KC,passwordlessToken:qC,entities:XE,knowledgeAssistant:db,handlingTime:lk,info:$1,input:U1,settings:c1,profile:vb,search:J1,summary:nb,styleSuggestions:ck,ui:qb,rules:nT,textSuggestions:kb});function gk(e){return hx({reducer:u2,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI,deepdeskBrokerAPI:e.deepdeskBrokerAPI}},serializableCheck:!1}),uk(),fk({debounce:200}),dk({debounce:500}),mk(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var c2=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},d2=e=>t=>n=>r=>{var a,l,u,c,f,d;let o=t.getState(),i=Xg("inlineSuggestions")(o);switch(r.type){case Ji.toString():{!r.payload&&e.emit("logout",void 0);break}case dn.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:(a=o.conversation.current)==null?void 0:a.id,data:{entities:r.payload}});break;case ot.toString():e.sendEvent(r.payload.name,{conversationId:((l=r.payload.options)==null?void 0:l.includeConversationData)&&((u=o.conversation.current)==null?void 0:u.id),data:r.payload.data});break;case Oo.toString():e.logSendMessage(r.payload);break;case Yo.fulfilled.toString():r.isBroadcasted||e.broadcast(oh,r,!1),(c=r.payload.options)!=null&&c.shouldEmit&&e.emit("cues",r.payload.cues);break;case Xo.fulfilled.toString():r.isBroadcasted||e.broadcast(ih,r,!1);break;default:break}let s=n(r);switch(r.type){case Oo.toString():e.handleAfterSendMessage(r.payload);break;case pl.toString():e.onUpdateShowTabHint(r.payload);break;case Af.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case id.toString():{let{start:p,end:v}=o.input.selection;e.emit("replace",L(T({},r.payload),{replace:r.payload.replace==="selection"?{start:p,end:v}:{start:0,end:v}}));break}case on.toString():{let{start:p,end:v}=o.input.selection;e.emit("select-suggestion",L(T({type:c2(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:p,end:v}:{start:0,end:v}})),i&&t.dispatch(Yn([]));break}case sd.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(f=o.conversation.current)==null?void 0:f.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case Yn.toString():{i&&r.payload.length>0&&t.dispatch(ad(0));break}case nr.fulfilled.toString():{e.sendEvent("conversation summarized",{conversationId:(d=o.conversation.current)==null?void 0:d.id,data:{summary:r.payload.summary,model:t.getState().summary.model}});break}default:break}return s},hk=d2;function My(e){return e.toISOString().replace("T"," ").replace("Z","")}function yk(e,t){var i,s,a,l;let n=(i=e.conversation.current)==null?void 0:i.id;if(!n)return U.warn("No conversationId for handling time metrics"),null;let{startTime:r,stopTime:o}=e.handlingTime;return!r||!o?(U.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:n,clientVersion:t.version,agentId:(s=e.info.agentInfo)==null?void 0:s.agentId,agentName:(a=e.info.agentInfo)==null?void 0:a.agentName,agentEmail:(l=e.info.agentInfo)==null?void 0:l.agentEmail,timeStart:My(r),timeStop:My(o)}}function vk(e,t,n){var N,_,D,G;let r=(N=t.conversation.current)==null?void 0:N.id;if(!r)return U.warn("No conversationId for send message metrics"),null;let{text:o,metrics:{numCharsTyped:i,numCharsPasted:s,numCharsCut:a,numCharsDeleted:l,numPaste:u,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:f,pastes:d,cuts:p,deletions:v,textSuggestions:y,offeredTextSuggestions:g}}=t[e],m=o.length,S=y.reduce((Z,{text:se,searchTerm:gr})=>Z+se.length-(gr?gr.length:0),0),x=c!=null?c:Date.now(),P=(Date.now()-x)/1e3+(f||0),C=i/P,R=y.reduce((Z,{searchTerm:se})=>Z+(se?se.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:d,cuts:p,deletions:v,lenTextTyped:i+R,lenTextTotal:m,lenTextAssisted:S,lenTextPasted:s,lenTextCut:a,lenTextDeleted:l,timeTotalSeconds:P,charsPerSecond:C,numPastes:u,textSuggestionsV2:y,suggestionsCounters:[{source:"gpt",countOffered:g.filter(Z=>Z.source==="gpt").length}],agentId:(_=t.info.agentInfo)==null?void 0:_.agentId,agentName:(D=t.info.agentInfo)==null?void 0:D.agentName,agentEmail:(G=t.info.agentInfo)==null?void 0:G.agentEmail}}function _y(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return _y(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?_y(o,t):null}function Sk(e,t){return _y(e,t)}function wk(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function f2(e){return typeof e=="object"&&e!==null&&"tagName"in e}function If(e){return f2(e)&&(no(e)||tf(e))}var Ek,Nn=new Map,p2=["bottom","height","left","right","top","width"],xk=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:p2.some(n=>e[n]!==t[n]);function bk(e){var n,r,o;if(e.ownerDocument===document)return[];let t=(o=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)!=null?o:null;return t?[t,...bk(t)]:[]}function Ck(e,t){return!e||!t?null:L(T({},e),{top:e.top+t.top,left:e.left+t.left})}var Of=!1,Tk=()=>{Of=!0;let e=[];if(Nn.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Nn.delete(n);return}let r=n.getBoundingClientRect();xk(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(Ck,t.rect):t.rect;xk(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Nn.size===0){Of=!1;return}Ek=window.requestAnimationFrame(Tk)};function Dy(e,t){let n=bk(e),r=[],o=n.map((i,s)=>Dy(i,a=>{r[s]=a;let l=Nn.get(e);if(!l)return;let u=r.reduce(Ck,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),Nn.has(e)){let s=Nn.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else Nn.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Of&&Tk()},unobserve(){o.forEach(s=>s.unobserve());let i=Nn.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||Nn.delete(e),Nn.size||(cancelAnimationFrame(Ek),Of=!1)}}}}var kk,Mn=new Map,Pk=()=>{Mn.forEach((e,t)=>{if(!t.isConnected){Mn.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)))}),Mn.size!==0&&(kk=window.requestAnimationFrame(Pk))};function Rk(e,t){return{observe(){let n=Mn.size===0;Mn.has(e)?Mn.get(e).callbacks.push(t):Mn.set(e,{visible:void 0,callbacks:[t]}),n&&Pk()},unobserve(){let n=Mn.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Mn.delete(e),Mn.size||cancelAnimationFrame(kk)}}}}var Fy=["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 Hy(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function Cs(e){return parseFloat(e)}function Nf(e){return Math.round(e*1e6)}function Ak(e){return e/1e6}function Uy(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=Cs(e.width),i=Cs(e.borderLeftWidth),s=Cs(e.borderRightWidth),a=Cs(e.paddingRight),l=Ak(Nf(o)-Nf(i)-Nf(s)),u=Ak(Nf(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function _l(e,t={}){var c,f;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(c=t.position)!=null?c:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",$o(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};Hy(r,n,Fy),Uy(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=Rk(e,()=>{Hy(r,n,Fy),Uy(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=Dy(e,d=>{if(d===null){t.onRemove&&t.onRemove(),n.remove();return}if(!l&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(Hy(r,n,Fy),Uy(r,e,n),i(),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let p=t.closestScrollElement.getBoundingClientRect(),v=window.getComputedStyle(t.closestScrollElement),y=Cs(v.borderTopWidth),g=Cs(v.borderBottomWidth),m=p.top+y-d.top,h=d.top+d.height+-(p.top+p.height-g);n.style.clipPath=`inset(${m}px 0px ${h}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(f=e.parentElement)==null||f.appendChild(n),u.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),u.unobserve(),s.unobserve()}]}var Lk=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch(r){return t}}catch(n){return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch(r){U.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function m2(e){return e.offsetParent!==null}function Ik(e){if(!m2(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 Mf(e,t,n=100){let r=Ik(e);t({isVisible:r});let o=setInterval(()=>{let i=Ik(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var _e=w(b());var Ok=Lk("showTabHint",!0),Ts=class Ts{constructor({deepdeskUrl:t,brokerUrl:n,version:r=Ts.version||"unknown",locale:o="en-US",token:i,fetch:s,productName:a,createCustomChannel:l}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.widgetRoot=null;this.dynamicThunkObject={};this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let u=t.replace(/\/api$/,"");this.deepdeskApi=new mr(u,{token:i,fetch:s}),this.version=r,this.instanceId=Ts.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[hk({broadcast:(f,d,p)=>{this.broadcastEvents.send(f,d,p)},emit:(f,d)=>this.emit(f,d),handleAfterSendMessage:f=>this.handleAfterSendMessage(f),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:f=>this.logSendMessage(f),onUpdateShowTabHint:f=>Ok.update(f),sendEvent:(f,d)=>this.deepdeskApi.sendEvent(f,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new Ml(n)}),this.store=gk(c),this.broadcastEvents=new tk({debug:!0,deepdeskUrl:u,eventMap:eE(this.store),createCustomChannel:l}),this.store.dispatch(pl(Ok.value())),this.store.dispatch(Jc({locale:o,adminUrl:u,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var t;return(t=this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex])!=null?t:null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(U.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(U.warn("Profile has not been loaded (yet)"),!0):(U.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Ji(null)),this.store.dispatch(Gn()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();rt(r)&&d1(r)!=="loading"&&(n(),t())});this.unmountHandlers.push(()=>{n()})})}isLoggedIn(){return k(this,null,function*(){return(yield this.store.dispatch(Gn())).payload})}setPlatformAgentId(t){return k(this,null,function*(){try{if((yield this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;yield this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:t}),version:null})}catch(n){U.warn("Failed to attach user:",n)}})}isConversationSupported(t,n){return k(this,null,function*(){return(yield this.store.dispatch(Zg({sessionId:t,options:n}))).payload})}createConversation(t){return k(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(td(t))).payload})}getConversationBySessionId(t,n){return k(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(yield this.store.dispatch(nd({sessionId:t,options:n}))).payload})}upsertConversation(t){return k(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(Jg(t))).payload})}postMessages(t){return k(this,null,function*(){return(yield this.store.dispatch(od(t))).payload})}updateConversation(t){return k(this,null,function*(){return(yield this.store.dispatch(rd(t))).payload})}resetConversation(){this.store.dispatch(de()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}getSummary(){return k(this,null,function*(){let t=yield this.store.dispatch(nr());if(t.error)throw new Error(t.error.message);return t.payload.summary})}configure(t){this.store.dispatch(Jc(t))}setVisitorInfo(t){this.store.dispatch(V1(t))}setCustomData(t){this.store.dispatch(K1(t))}setAgentInfo(t){return k(this,null,function*(){yield this.store.dispatch(ja(t))})}setAgentSettings(t){return k(this,null,function*(){yield this.store.dispatch(nh(t))})}getAgentSettings(){return k(this,null,function*(){return(yield this.store.dispatch(rh())).payload})}refresh(){return k(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(ld({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let t=[];return this.store.dispatch(Kd()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}notifyExternalSuggestion(t){this.store.dispatch(on(t))}evaluateRule(o){return k(this,arguments,function*(t,n={},r=ZC){return(yield this.store.dispatch(Yo({label:t,params:n,options:r}))).payload.cues})}evaluateAssistant(r){return k(this,arguments,function*(t,n={}){yield this.store.dispatch(Xo({assistantCode:t,payload:n}))})}handleKeyDown(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:i,selection:s}=this.state.input,{inlineSuggestions:a,showTextSuggestions:l}=this.state.settings,u=a?"below":"above",c=o.length>0;if(!An(this.state)||(this.store.dispatch(O1(eh(t))),t.key!=="Tab"&&!l))return;let f=()=>{n||!c||s&&(t.shiftKey||(this.store.dispatch(_1()),t.preventDefault()))},d=()=>{n||!c||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(D1()),t.preventDefault()))};switch(t.key){case"ArrowUp":u==="below"?d():f();break;case"ArrowDown":{u==="below"?f():d();break}case"Escape":{n||(this.store.dispatch(ad(-1)),this.store.dispatch(eo({collapse:!0})),this.store.dispatch(Wb(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let p=rs(this.state);if(!p)return;this.store.dispatch(pl(!1)),this.store.dispatch(on({text:p.text,suggestion:p,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.state.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let p=rs(this.state);if(!p)return;this.store.dispatch(on({text:p.text,suggestion:p,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.state.settings.inlineSuggestions||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let p=rs(this.state);if(!p)return;this.store.dispatch(on({text:p.text,suggestion:p,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(eo({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(Yn([]))}handlingTimeStart(){this.state.handlingTime.startTime||(U.info("Start handling time"),this.store.dispatch(sk()))}handlingTimeStop(){this.state.handlingTime.startTime&&(U.info("Stop handling time"),this.store.dispatch(Af()))}logSendMessage(t){let n=vk("input",this.state,{version:this.version});n&&(t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n))}logHandlingTime(){let t=yk(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(ak()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(Oo((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(H1()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(i){U.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),U.error(i)}})}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),()=>{this.off(t,n)}}off(t,n){if(!t&&!n){this.eventListeners={};return}let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}setConversationQuery(t){this.dynamicThunkObject.conversationQuery=t}setPlatformVariables(t){this.store.dispatch(W1(t))}whenConversationLoaded(t){let n=()=>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]=_l(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,Qt.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var a;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let i=(a=t.ownerDocument.defaultView)==null?void 0:a.frameElement,s=i.ownerDocument.defaultView;if(i&&(s===window||(s==null?void 0:s.parent)===window)){let[l,u]=_l(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{(0,Qt.unmountComponentAtNode)(o),u()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return $o(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,Qt.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),U.info(`Stored analytics for ${this.conversationId()}`)}catch(t){}}restoreMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(t);if(!n)return;let r=JSON.parse(n);r.text.trim()===this.state.input.text.trim()?(U.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(F1(r.metrics))):U.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch(t){}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!If(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:f,detectSubmit:d,insertLink:p,inputMediator:v,closestScrollSelector:y,appendOverlayTo:g,inlineSuggestions:m,floatingMenu:h}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:p,isEmbedded:f,inlineSuggestions:m,floatingMenu:!!h}),n.automaticHandlingTime&&this.setupHandlingTime(t),$o(t),this.inputMediator=v||(no(t)?new Jo(t):new Zo(t)),this.inputMediator.on("change",({plainText:P,rawHTML:C})=>{this.store.dispatch(ld({text:P,html:C}))}),this.inputMediator.on("keyup",P=>{this.store.dispatch(N1(eh(P)))}),this.inputMediator.on("keydown",P=>{this.handleKeyDown(P)}),this.inputMediator.on("paste",({pastedText:P,selectionText:C})=>{this.store.dispatch(M1({text:P,selectionText:C}))}),this.inputMediator.on("cut",({selectionText:P})=>{this.store.dispatch(I1(P))});let S;this.inputMediator.on("selection",P=>{clearTimeout(S),P===null?S=setTimeout(()=>{P!==null&&this.store.dispatch(ud(P))},500):this.store.dispatch(ud(P))}),this.inputMediator.on("disabled",()=>{var P;(P=this.inputMediator)==null||P.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(Xd(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(Xd(!0))});let x=y&&Sk(t,y)||void 0;if(m){let{customStyles:P,appendOverlayTo:C}=n;if(no(t))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let R=this.createInlineContainer(t,"deepdesk-caret");(0,Qt.render)((0,_e.jsx)(Go,{store:this.store,customStyles:P,children:(0,_e.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(Jb,{})})}),R),this.inputMediator.on("caretposition",_=>{this.store.dispatch(Yn([])),_?(R.style.display="block",R.style.top=`${_.top}px`,R.style.left=`${_.left}px`):R.style.display="none"});let N=this.overlayContainerFactory("floating-menu",x||t,{appendTo:typeof h=="object"&&"appendOverlayTo"in h?h.appendOverlayTo:C},P==null?void 0:P.floatingMenuRootNode);(0,Qt.render)((0,_e.jsx)(Go,{store:this.store,customStyles:P,children:(0,_e.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(jb,{onLogIn:()=>this.loginViaPopup().catch(_=>U.warn(_.message))})})}),N)}else{let P=this.overlayContainerFactory("deepdesk-tab-completion",x||t,{appendTo:g,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||t,{appendTo:g},r==null?void 0:r.suggestionsRootNode);(0,Qt.render)((0,_e.jsx)(Go,{store:this.store,customStyles:r,children:(0,_e.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(AC,{inputElement:t})})}),P),(0,Qt.render)((0,_e.jsx)(Go,{store:this.store,customStyles:r,children:(0,_e.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(lC,{onLogIn:()=>this.loginViaPopup().catch(R=>U.warn(R.message))})})}),C)}(0,Qt.render)((0,_e.jsx)(Go,{store:this.store,customStyles:r,children:(0,_e.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(Fb,{})})}),this.createContainer("deepdesk-overlays")),this.store.dispatch(ld({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(ud(this.inputMediator.getSelection())),this.store.dispatch(Xd(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{var P;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((P=this.state.conversation.current)==null?void 0:P.sessionId)}),this.isMounted=!0}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&&U.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,Qt.render)((0,_e.jsx)(Go,{store:this.store,customStyles:r,children:(0,_e.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(YT,{onLogIn:()=>this.loginViaPopup().catch(s=>U.warn(s.message))})})}),t),this.whenConversationLoaded(()=>{var s;this.broadcastEvents.setSessionId((s=this.state.conversation.current)==null?void 0:s.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Qt.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Mf(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){wk(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>k(this,null,function*(){yield this.store.dispatch(cl());let t=ir(this.state);t&&(yield this.store.dispatch(al()),this.store.dispatch(Jc({showSearch:t.search,showAutoflows:t.autoflows,showCustomMessages:t.customMessages,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:t.summarizer,showKnowledgeSearch:!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions})))})),this.loadProfileConfigPromise)}loginViaPopup(t){return k(this,null,function*(){return new Promise((n,r)=>{let o=new MessageChannel,i=o.port1,s=this.state.settings.adminUrl,a=new URL(t!=null&&t.url?t==null?void 0:t.url:`${s}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,u=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",f),clearInterval(d)};i.onmessage=p=>k(this,null,function*(){var v,y;if((v=p.data)!=null&&v.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((y=p.data)==null?void 0:y.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(Ka),l=!0,o.port1.close(),n()}catch(g){console.error(g),r(g)}finally{l=!0,u()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&r(new Error("Popup blocked by browser"));let f=p=>k(this,null,function*(){var v;if(p.origin===a.origin)switch((v=p.data)==null?void 0:v.type){case"deepdesk-popup-loaded":{try{let y=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(y,a.origin,[o.port2])}catch(y){U.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-error":{u(),p.data.message==="Timeout"&&U.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(p.data.message));break}}});window.addEventListener("message",f);let d=setInterval(()=>{c&&!c.closed||(u(),l||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(u)})})}translateMessages(t){return this.deepdeskApi.translateMessages(t)}checkForTrialMode(t){return k(this,null,function*(){try{let{account:n}=yield this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(U.info("Trial is active"),!(yield this.deepdeskApi.checkUserExists(t)))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:r}=n;U.info(r),this.shouldRender=!1}})}refreshWidgetSuggestions(){return k(this,null,function*(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=jd(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(dn()):ou.includes(r)||this.store.dispatch(pn(r))})}catch(r){this.handleError(r)}})}};Ts.version="12.1.1-beta.2",Ts.count=0;var Dl=Ts;function Nk(r,o){return k(this,arguments,function*(e,t,n={}){var f,d;let{value:i}=e,{start:s,end:a}=(f=n.replace)!=null?f:{start:0,end:i.length},l=`${i.slice(0,s)}${t}${i.slice(a)}`,u=(d=n.selectionAfter)!=null?d:{start:s+t.length,end:s+t.length},c=()=>{if(n.setValue)return n.setValue(l);e.value=l};return Promise.resolve(c()).then(()=>{e.selectionStart=u.start,e.selectionEnd=u.end,e.blur(),e.focus()})})}function Mk(r,o){return k(this,arguments,function*(e,t,n={}){let i=n.replace?so(e,n.replace.start,n.replace.end):xs(e),s,a=()=>{if(n.setRange)return n.setRange(i.cloneRange());i.deleteContents(),s=document.createElement("span"),i.insertNode(s),n.insertBRs!==!1?t.split(`
28
28
  `).reverse().forEach((l,u)=>{u>0&&i.insertNode(document.createElement("br")),i.insertNode(document.createTextNode(l))}):i.insertNode(document.createTextNode(t))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){e.focus();let l=n.selectionAfter?so(e,n.selectionAfter.start,n.selectionAfter.end):(i.collapse(!1),i),u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(l)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})})}function g2(e){let t=document.createElement("template");return t.innerHTML=e.replace(/(\[([^\]]+)])\(([^)]+)\)/g,'<a href="$3" target="_blank" rel="noopener noreferrer">$2</a>'),t.content}function h2(e){let t=document.createDocumentFragment();return e.split(`
29
29
  `).forEach((n,r)=>{r>0&&t.appendChild(document.createElement("br"));let o={index:0},i=0;for(;o=n.slice(i).match(/(\[([^\]]+)])\(([^)]+)\)/);){let s=document.createElement("a");s.href=o[3],s.setAttribute("target","_blank"),s.setAttribute("rel","noopener noreferrer"),s.appendChild(document.createTextNode(o[2])),t.appendChild(document.createTextNode(n.slice(i,i+o.index))),t.appendChild(s),i=i+o.index+o[0].length}t.appendChild(document.createTextNode(n.slice(i)))}),t}function _k(e,t){let n=e.parentElement;if(!n){console.warn("No insert point found");return}let{display:r}=window.getComputedStyle(n);r.includes("block")||r==="table-cell"?n==null||n.insertBefore(t,e.nextSibling):_k(n,t)}function Dk(o,i){return k(this,arguments,function*(e,t,{isBlock:n,isHTML:r}={}){let s;e.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0}));let a=()=>{var d;let l=(d=e.ownerDocument.defaultView)!=null?d:window,u=l.getSelection();if((!u||u.rangeCount===0)&&(e.focus(),u=l.getSelection()),!u||u.rangeCount===0)return;let c=u.getRangeAt(0);if(!c)return;s=document.createElement("span"),c.insertNode(s);let f=r?g2(t):h2(t);n?_k(c.startContainer,f):(c.insertNode(f),c.collapse(!1))};return Promise.resolve(a()).then(()=>{if(e.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0})),e.focus(),!!s)try{s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})})}function Fk(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function Hk(e,t,n){return k(this,null,function*(){yield new mr(e).authenticateWithKey(t,n)})}function Uk(e){return k(this,null,function*(){let n=yield new vn(e).get("/platform/config/",{version:null,useCache:!0});return te(n)})}function y2(e){return k(this,null,function*(){var o,i,s;let n=yield((o=e.fetch)!=null?o:window.fetch)(e.url),r=yield n.blob();return new File([r],e.name,{type:(s=(i=e.mimeType)!=null?i:n.headers.get("Content-Type"))!=null?s:"image/jpeg"})})}function zk(e,t){return k(this,null,function*(){let n=yield y2(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 nP(v2);})();
30
30
  /*! Bundled license information: