@deepdesk/deepdesk-sdk 14.1.0 → 14.1.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.iife.js +2 -2
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -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 $h=w(b()),xN={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Vb=({className:e,color:t})=>(0,$h.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,$h.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:xN[t||"pink"]})});var Kb={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var qh={};Ye(qh,{enUS:()=>EN,nlNL:()=>bN});var EN={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},bN={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Wo=w(b()),$b=({onLogIn:e})=>{let t=q(qh),n=z("floatingMenu"),r=z("productName"),o=Q(),i=M(at),s=L("FloatingMenu",Kb);if(i===null||n===!1)return null;let a=()=>{i===!0?o(Lt(!0)):e()};return(0,Wo.jsxs)("button",{className:(0,Wb.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)(Vb,{className:s.logo,color:"pink"}),i===!1&&(0,Wo.jsx)(jb,{className:s.lock})]})]})};var ef=w(H());var qb=w(H());function to(e){(0,qb.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 Ln(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 CN={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Qd=({ui:e})=>e.overlayCollapsed,Gb=Y({name:"ui",initialState:CN,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:hl,setInputFocus:Xd,setOverlayCollapsed:no,setOpenOverlayWhenTyping:Yb,setOverlayCollapsedUserOverwrite:Qb}=Gb.actions,Xb=Gb.reducer;var Zd=w(H());var Ss=w(H());var Zb=w(H());function Jb(e,t,n){(0,Zb.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var eC={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var qo=w(b()),kN=["search","personal-collection-search","search-autocomplete"];function PN(e,t,n,r={}){var i;let o="";return kN.includes(t)?o=HE(Ih(e,n,{stripAgentPart:!0}),(i=r.searchKeywords)!=null?i:[n]):o=Ih(e,n,r),r.placeholders===!0&&(o=UE(o)),o}var RN=()=>{},AN=({selected:e,suggestion:t})=>{let n=z("inlineSuggestions"),r=M(ss),o=z("enableSuggestionFeedback"),i=M(c=>c.input.text),s=Q(),a=L("TextSuggestion",eC),l=(0,Ss.useRef)(null);(0,Ss.useEffect)(()=>{let c=setTimeout(()=>{s(M1({text:t.text,suggestion:t}))},500);return()=>{clearTimeout(c)}},[t]),Jb(l,"click",()=>{s(an({suggestion:t,text:t.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let u=(0,Ss.useMemo)(()=>PN(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)(re,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:RN,children:(0,qo.jsx)(us,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:u})}),o&&(0,qo.jsx)("div",{className:a.actions,children:(0,qo.jsx)(Gd,{source:"overlay",context:i,suggestion:t})})]})},tC=AN;var Gh=w(b()),LN=({suggestions:e,selectedIndex:t,reverse:n})=>{let r=(0,Zd.useMemo)(()=>{let o=e.map((i,s)=>(0,Gh.jsx)(tC,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]);return(0,Gh.jsx)(Zd.Fragment,{children:r})},Jd=LN;var nC={root:"dd-PfvRI",paper:"dd-HYlyY"};var yl=w(b()),IN=({textSuggestions:e,selectedIndex:t})=>{let n=(0,ef.useRef)(null),r=L("InlineSuggestionsOverlay",nC),o=M(Ln),i=Q(),s=M(at),a=M(is),l=M(Qd),u=z("showTextSuggestions");return to(()=>{setTimeout(()=>{i(no({collapse:!0,skipWhenInputFocus:!0}))})}),(0,ef.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,yl.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,yl.jsx)("div",{ref:n,className:r.paper,children:(0,yl.jsx)(St,{children:(0,yl.jsx)(Jd,{suggestions:e,selectedIndex:t})})})})},ON=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),rC=Yn(ON)(IN);var vl=w(b()),NN=({children:e})=>{let n=z("locale").replace("-","");return(0,vl.jsx)(hh.Provider,{value:n,children:e})},MN=({store:e,customStyles:t={},children:n})=>(0,vl.jsx)(Yg,{store:e,children:(0,vl.jsx)(NN,{children:(0,vl.jsx)(_s.Provider,{value:t,children:n})})}),Go=MN;var nf=w(oe()),ws=w(H());var oC=w(H());function iC(e,t){let[n,r]=(0,oC.useState)(()=>{if(typeof window=="undefined")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return B.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){B.error(s)}}]}var sC=()=>/Mac/i.test(navigator.platform);var lC=w(oe()),ar=w(H());var Yh={};Ye(Yh,{enUS:()=>_N,nlNL:()=>DN});var _N={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"}]}]},DN={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 aC={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var ro=w(b()),Qh=(e,t,n)=>r=>(0,ro.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),FN=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=q(Yh),s=Yt(),a=L("Login",aC),l=z("productName"),u=(0,ar.useCallback)(p=>{p.preventDefault(),r&&r(parseInt(p.target.value,10))},[]),c=(0,ar.useCallback)(p=>{p.preventDefault(),s.send(ls,!0)},[t]),f=(0,ar.useMemo)(()=>p=>(0,ro.jsx)("a",{onClick:h=>{h.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:p},"login"),[t]),d=(0,ar.useCallback)(p=>(0,ro.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:p},"prompt"),[c]),{min:m,hour:S,day:y}=(0,ar.useMemo)(()=>({min:Qh(a,60*10,u),hour:Qh(a,60*60,u),day:Qh(a,60*60*12,u)}),[]);return(0,ro.jsxs)("div",{className:(0,lC.default)(e,a.root),children:[i("loginPlease",{login:n?d:f,productName:l}),r&&(0,ro.jsxs)(ar.Fragment,{children:[(0,ro.jsx)("br",{}),i("snooze",{min:m,hour:S,day:y})]})]})},tf=FN;var uC={root:"dd-DoQhb",text:"dd-Jwnev"};var Sl=w(b()),HN=({title:e})=>{let t=L("SearchTrigger",uC),n=Q();return(0,Sl.jsxs)("button",{type:"button",className:t.root,onClick:()=>n(Lt(!0)),children:[(0,Sl.jsx)(fs,{}),(0,Sl.jsx)("span",{className:t.text,children:e})]})},cC=HN;var Xh={};Ye(Xh,{enUS:()=>UN,nlNL:()=>zN});var UN={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"}]},zN={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 dC={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()),BN=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=L("SuggestionsOverlay",dC),o=q(Xh),i=M(Ln),s=N1(),a=Q(),l=(0,ws.useRef)(null),u=z("searchTriggerKey"),c=z("productName"),f=M(Qd),d=M(at),m=M(is),[S,y]=(0,ws.useState)(null),p=z("showSearch"),g=z("showTextSuggestions"),h=z("adminUrl"),v=z("isEmbedded"),[x,k]=iC("dd-snooze-until-ms",0),C=f||x>Date.now(),R=e.filter(D=>D.source!=="gpt").length,N=()=>{C&&k(0),a(Qb(!C))},_=D=>{let G=Date.now()+D*1e3;k(G),B.info(`Snooze until: ${new Date(G)}`),a(no({collapse:!0}))};return(0,ws.useEffect)(()=>{R===0&&y(null)},[e,R]),to(()=>{a(no({collapse:!0,skipWhenInputFocus:!0}))}),d===null||m===!1?null:d===!1?(0,be.jsxs)("div",{ref:l,className:(0,nf.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)(tf,{loginUrl:h,isEmbedded:v,onLogIn:n,onSnooze:_})})]}):!s||!i?null:(0,be.jsxs)("div",{ref:l,className:(0,nf.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,be.jsxs)("div",{className:r.triggers,children:[(0,be.jsx)("div",{style:{flex:1},children:p&&(0,be.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>y(o(sC()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>y(null),children:(0,be.jsx)(cC,{title:o("search")})})}),(0,be.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,be.jsx)("div",{className:(0,nf.default)(!S&&r.hintsHidden,r.hints),children:S}),(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&&g&&(0,be.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,be.jsx)(St,{children:(0,be.jsx)(Jd,{suggestions:e,selectedIndex:t,reverse:!0})})})]})},jN=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),fC=Yn(jN)(BN);var vf=w(oe());var dr=w(H());var xs=w(H());function rf(e){return e.contentEditable==="true"}function VN(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 pC(e){let{selectionStart:t,selectionEnd:n}=rf(e)?VN(e):e;return[t,n]}function mC(e){let[,t]=(0,xs.useState)(),n=(0,xs.useRef)(null);return n.current=pC(e),(0,xs.useEffect)(()=>{let r=()=>{var a;let[o,i]=(a=n.current)!=null?a:[],s=pC(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 gC(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(iu);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 hC=w(H()),KN=["div","span","mark","strong","b","i","u","em"];function Zh(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(KN.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,hC.cloneElement)(r,{children:Zh(s,t,n+1)})]}return[...e,...t]}function oo(e){return e.tagName.toLowerCase()==="textarea"}var yC={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 PC=w(oe());var pf=w(H());var Es=w(H());function vC(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function of(e){let t=(0,Es.useRef)(null),[n,r]=(0,Es.useState)(!1);return(0,Es.useEffect)(()=>{var c;let o=!1,i=parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[s,a]=vC((f,d)=>{let m=t.current;if(!m)return;let S=f/i,y=d/i,p=m.getBoundingClientRect(),g=S>p.x&&S<p.x+p.width&&y>p.y&&y<p.y+p.height;g&&!o?(o=!0,r(!0)):!g&&o&&(o=!1,r(!1))},({clientX:f,clientY:d})=>[f,d]),[l,u]=vC(()=>{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 SC(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function sf(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function wC(e){return e!=null}var ey=w(oe()),Xt=w(H());var af=w(H()),WN=["bottom","height","left","right","top","width"],$N=(e={},t={})=>WN.some(n=>e[n]!==t[n]),lr=new Map,xC,EC=()=>{let e=[],t=[];lr.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();$N(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{lr.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),xC=window.requestAnimationFrame(EC)};function qN(e,t){return{observe(){let n=lr.size===0;if(lr.has(e)){let r=lr.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else lr.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&EC()},unobserve(){let n=lr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||lr.delete(e),lr.size||cancelAnimationFrame(xC)}}}}function Jh(e){let[t,n]=(0,af.useState)(null);return(0,af.useLayoutEffect)(()=>{if(!e.current)return;let r=qN(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var bs=w(H()),CC=w(Sc());var bC={root:"dd-r-dgo"};var TC=({children:e,parentNode:t})=>{let[n,r]=(0,bs.useState)(null),o=(0,bs.useContext)(_s);return(0,bs.useLayoutEffect)(()=>{let i=document.createElement("div");return $o(i),i.classList.add(bC.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,CC.createPortal)(e,n):null};var In={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 lf=w(b()),uf=(e=!1)=>{let[t,n]=(0,Xt.useState)(e),r=(0,Xt.useCallback)(()=>n(!0),[]),o=(0,Xt.useCallback)(()=>n(!1),[]),i=(0,Xt.useCallback)(()=>n(a=>!a),[]),s=(0,Xt.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function ty(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 Cs=u=>{var c=u,{className:e,triggerRef:t,boundaryRef:n=(0,Xt.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=ty,parentNode:a}=c,l=te(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let f=Jh(t),d=Jh(n),m=(0,Xt.useMemo)(()=>s(f,d,0),[f,d]);return(0,lf.jsx)(TC,{parentNode:a,children:(0,lf.jsx)("div",I(T({className:(0,ey.default)(In.ref,{[In.positionAbove]:r==="above",[In.positionBelow]:r==="below",[In.positionLeft]:r==="left",[In.positionRight]:r==="right",[In.alignStart]:o==="start",[In.alignCenter]:o==="center",[In.alignEnd]:o==="end"}),style:m},l),{role:"dialog",children:(0,lf.jsx)("div",{className:(0,ey.default)(e,In.root),children:i})}))})};var kC=w(oe()),cf=w(H());var ur={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 ny=w(b()),df=(0,cf.forwardRef)((o,r)=>{var i=o,{className:e,children:t}=i,n=te(i,["className","children"]);let s=(0,cf.useRef)(null),a=L("TabCompletion",ur);return(0,ny.jsx)("div",I(T({ref:sf([s,r]),className:(0,kC.default)(e,a.popoverContentContainer)},n),{children:(0,ny.jsx)("div",{className:a.popoverContent,children:t})}))});var io=w(b()),GN=e=>t=>{let n=ty(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},YN=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=L("TabCompletion",ur),s=uf(),a=(0,pf.useMemo)(()=>GN(e.getBoundingClientRect()),[e]),[l,u]=of(e);return(0,pf.useEffect)(()=>{u?s.open():s.close()},[u]),(0,io.jsxs)("span",{children:[(0,io.jsx)("mark",{ref:sf([l,s.triggerRef]),className:(0,PC.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,io.jsx)(Cs,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,io.jsx)(df,{style:n,children:(0,io.jsx)("div",{className:i.hintText,children:o})})})]})},ff=class extends er{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=>I(T({},o),{keywordRegex:new RegExp(`\\b${SC(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(wC);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,io.jsx)(YN,{inputElement:r.inputElement,suggestion:r.suggestion,inputStyle:r.inputStyle,boundaryRef:r.boundaryRef,children:n},`keyword_${r.matchString}_${r.key}`)}asTag(){return"mark"}};var RC=w(oe());var ry=w(b()),QN=({inputElement:e,children:t})=>{let n=L("TabCompletion",ur),[r,o]=of(e);return(0,ry.jsx)("mark",{ref:r,className:(0,RC.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},mf=class extends er{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,ry.jsx)(QN,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var hf=w(oe());var ft=w(H());var oy=w(b()),AC=()=>(0,oy.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,oy.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 so=w(H());var IC=w(xh());var LC={root:"dd-ky-Bv",content:"dd-kV5e1"};function gf(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 iy(e){return e.replace("https://www.","").replace("https://","")}var Zt=w(b()),XN=3,ZN=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),JN=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=XN})=>{let i=L("LinkSearch",LC),[s,a]=(0,so.useState)(""),l=Q(),u=M(Pb("url")),c=M(tE("URL",ZN)),[f,d]=(0,so.useState)(c.length-1),m=z("fallbackImage"),S=h=>{let v=h.target;a(v.value)},y=(h,v)=>{h.stopPropagation(),h.preventDefault(),window.open(v,"_blank")},p=h=>{var k;let v=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(v),h.code==="ArrowDown"&&d(x),h.code==="Enter"&&e(((k=c[f])==null?void 0:k.text)||s)},g=(0,so.useCallback)((0,IC.default)(h=>{l(No({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,so.useEffect)(()=>{s&&g(s)},[s]),(0,so.useEffect)(()=>()=>{l(pd())},[]),(0,Zt.jsxs)("div",{className:i.root,children:[(0,Zt.jsx)(St,{withDivider:!0,children:(s?c:u).slice(0,o).map((h,v)=>(0,Zt.jsx)(re,{selected:f===v,onClick:()=>e(h.text),"data-testid":"linksearch-suggestion",children:(0,Zt.jsxs)(ge,{children:[(0,Zt.jsx)(ge.Image,{src:gf(h,"small",m||void 0),title:h.title||h.text}),(0,Zt.jsxs)(ge.Content,{className:i.content,cropText:!0,children:[(0,Zt.jsx)(ge.Title,{children:h.title||iy(h.text)}),h.title&&iy(h.text)]}),(0,Zt.jsx)(re.Actions,{children:(0,Zt.jsx)(re.ActionButton,{label:r,onClick:x=>y(x,h.text)})})]})},h.text))}),(0,Zt.jsx)(Ja,{value:s,onChange:S,autoFocus:!0,placeholder:n,onKeyUp:p})]})},OC=JN;var sy={};Ye(sy,{enUS:()=>eM,nlNL:()=>tM});var eM={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},tM={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var dt=w(b()),nM=(0,ft.forwardRef)((e,t)=>{let n=L("TabCompletion",ur);return(0,dt.jsx)("mark",{ref:t,className:(0,hf.default)(n.matchSelection)},"selection-start")}),rM=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=q(sy),s=L("TabCompletion",ur),a=(0,ft.useRef)(null),l=(0,ft.useRef)(null),[u,c]=(0,ft.useState)(null),f=Q(),d=uf(document.activeElement===r),[m]=(0,ft.useState)(()=>document.createRange());d.triggerRef.current=m,(0,ft.useEffect)(()=>()=>m.detach(),[]),(0,ft.useEffect)(()=>{let y=e.current,p=a.current;!y||!p||(m.setStart(y,0),m.setEnd(p,0))},[e.current,a.current]),to(()=>{d.close()});let S=(0,ft.useCallback)(y=>{let p=m.toString(),g=/^http(s?):\/\//.test(y)?y:`https://${y}`;f(ad({text:`[${p}](${g})`,replace:"selection"}))},[]);return(0,dt.jsxs)("span",{children:[(0,dt.jsx)("mark",{ref:a,className:(0,hf.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,dt.jsx)(Cs,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,dt.jsxs)(df,{style:n,ref:l,children:[(0,dt.jsx)("div",{className:(0,hf.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,dt.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,dt.jsx)(AC,{}),(0,dt.jsx)("span",{children:"\xA0"}),(0,dt.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,dt.jsx)(OC,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:S,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},yf=class extends er{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,ft.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,dt.jsx)(nM,{ref:this.startRef}):(0,dt.jsx)(rM,{inputElement:r.inputElement,startRef:this.startRef,boundaryRef:r.boundaryRef,inputStyle:r.inputStyle})}asTag(){return"mark"}};var cr=w(b()),oM=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=L("TabCompletion",yC),c=z("insertLink"),f=z("showMidSentenceSuggestions"),d=z("inlineSuggestions"),m=mC(a),S=(0,dr.useRef)(null),y=M(at);(0,dr.useEffect)(()=>{oo(a)&&m&&gC(a,m)},[m]);let p=(0,dr.useCallback)(v=>{if(!o||!n)return v;let x=[(0,cr.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,cr.jsx)("span",{"data-testid":"tab-completion",className:(0,vf.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&x.push((0,cr.jsx)("span",{className:(0,vf.default)(u.hint,u.resetIndent),children:(0,cr.jsx)(tu,{keyCode:"tab"},"tabHint")})),Zh(v,x)},[o,n,r]),g=(0,dr.useMemo)(()=>{let v=[];return c&&v.push(new yf("selection")),v.push(new mf("placeholders")),i&&v.push(new ff("keywords")),v},[d,c,i]),h=(0,dr.useMemo)(()=>{let v=window.getComputedStyle(a);return{"--dd-color":v.color,"--dd-font-size":v.fontSize,"--dd-font-family":v.fontFamily,"--dd-font-variant":v.fontVariant}},[]);return!e||!y?null:(0,cr.jsxs)("div",{ref:v=>{v!=null&&v.parentElement&&(S.current=v==null?void 0:v.parentElement)},className:u.root,style:h,children:[(0,cr.jsx)(us,{tagName:"span",containerTagName:"div",className:(0,vf.default)(u.container,u.agentText),disableLineBreaks:oo(a),content:t||"\u200B",onAfterParse:p,matchers:g,selection:m,keywordMatches:s,inputElement:a,inputStyle:h,boundaryRef:S,inlineSuggestionsOnlyAtEnd:!f}),(0,cr.jsx)("br",{})]})},iM=e=>{var p,g,h;let{input:t,ui:n,settings:r,styleSuggestions:o,conversation:i}=e,s=as({input:t}),a=(s==null?void 0:s.text)||"",l=(s==null?void 0:s.source)||"",u=(p=t.html)!=null?p:cs(t.text),c=a.indexOf(t.text)===0?a.slice(t.text.length):"",{showTabHint:f}=n,{isSupported:d}=i,{showTabCompletion:m,visible:S,showStyleSuggestions:y}=r;return{showTabHint:f,showStyleSuggestions:y,showTabCompletion:m&&Ln(e),content:u,tabText:c,source:l,keywordMatches:(h=(g=o.list)==null?void 0:g.keywordMatches)!=null?h:[],enabled:S&&d!==!1}},NC=Yn(iM)(oM);var ek=w(oe()),Il=w(H());var MC={list:[],fetchState:"idle"},DC=e=>e.autoflows.list||[],_C=e=>t=>{var n;return(n=t.list)==null?void 0:n.find(r=>r.triggerPayload===e)},fr=K("autoflows/getAll",(e,t)=>P(void 0,null,function*(){let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(e)})),ay=K("autoflows/start",(e,t)=>P(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(fr(e.platformSessionId))})),ly=K("autoflows/stop",(e,t)=>P(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(fr(e.platformSessionId))})),sM=Y({name:"autoflows",initialState:MC,reducers:{},extraReducers:e=>{e.addCase(ay.pending,(t,n)=>{let r=_C(n.meta.arg.triggerPayload)(t);r.state="Started",r.isBusy=!0}),e.addCase(ly.pending,(t,n)=>{let r=_C(n.meta.arg.triggerPayload)(t);r.state="Aborted",r.isBusy=!0}),e.addCase(fr.pending,t=>{t.fetchState="loading"}),e.addCase(fr.rejected,t=>{t.fetchState="error"}),e.addCase(fr.fulfilled,(t,n)=>{t.list=n.payload,t.fetchState="done"}),e.addCase(ce,()=>MC)}}),FC=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(fr(e))}),o.on("sessionCompleted",()=>{n(fr(e))})}),HC=K("autoflows/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),UC=sM.reducer;var zC={list:[],fetchState:"idle",sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},BC=e=>e.customMessages.list,jC=e=>t=>!!t.customMessages.sentSuggestions.find(n=>n===e),VC=e=>t=>!!t.customMessages.answeredSuggestions.find(n=>n===e),KC=e=>t=>!!t.customMessages.errorSuggestions.find(n=>n===e),wl=K("customMessages/getAll",(e,t)=>P(void 0,null,function*(){let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(e)})),Sf=K("customMessages/send",(e,t)=>P(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)})),wf=K("customMessages/answer",(e,t)=>P(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)})),WC=Y({name:"customMessages",initialState:zC,reducers:{onCustomMessage(e,t){Array.isArray(t.payload)?e.list=t.payload:e.list=[t.payload]}},extraReducers:e=>{e.addCase(wl.pending,t=>{t.fetchState="loading"}).addCase(wl.rejected,t=>{t.fetchState="error"}).addCase(wl.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload||[]}).addCase(Sf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.errorSuggestions=t.errorSuggestions.filter(r=>n.meta.arg.suggestion.text!==r)}).addCase(Sf.rejected,(t,n)=>{let r=t.sentSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1))}).addCase(wf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(wf.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(ce,()=>zC)}}),$C=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(WC.actions.onCustomMessage(i))})}),qC=K("customMessages/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),GC=WC.reducer;var aM={token:null,interval:null},uy=K("passwordlessToken/getTemporaryPasswordlessToken",(e,t)=>P(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return{token:yield n.requestPasswordlessToken()}})),cy=K("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(uy()),setInterval(()=>r(uy()),n)}),YC=Y({name:"passwordlessToken",initialState:aM,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(uy.fulfilled,(t,n)=>{t.token=n.payload.token}),e.addCase(cy.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:QC}=YC.actions,XC=YC.reducer;var dy={outputs:[],fetchState:"idle"},ZC=e=>{var t;return(t=e.assistants)==null?void 0:t.outputs},lM=Ce("assistants/resetOutputs"),Yo=K("assistants/evaluate",(e,t)=>P(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=>I(T({},u),{name:ut(u.name,s),response:ut(u.response,s)}))),l}catch(o){let i=o.message;return B.warn(i),t.rejectWithValue(i)}})),JC=Y({name:"assistants",initialState:dy,reducers:{removeOutputByCode(e,t){e.outputs=e.outputs.filter(n=>n.code!==t.payload.code)}},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.map(i=>i.name),o=t.outputs.filter(i=>!r.includes(i.name));t.fetchState="done",t.outputs=[...n.payload,...o]}).addCase(ce,()=>dy).addCase(lM.toString(),()=>dy)}}),{removeOutputByCode:eT}=JC.actions,tT=JC.reducer;var nT={shouldEmit:!0},fy={cues:[],fetchState:"idle"},rT=e=>{var t;return(t=e.rules)==null?void 0:t.cues},uM=Ce("rules/resetCues"),Qo=K("rules/evaluate",(e,t)=>P(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=>I(T({},d),{title:ut(d.title,s),text:ut(d.text,s)}))),{cues:f,options:e.options}}catch(o){let i=o.message;return B.warn(i),t.rejectWithValue(i)}})),oT=Y({name:"answer",initialState:fy,reducers:{removeCue(e,t){e.cues=e.cues.filter(n=>n.rule.id!==t.payload.id)}},extraReducers:e=>{e.addCase(Qo.pending,t=>{t.fetchState="loading"}).addCase(Qo.rejected,t=>{t.fetchState="error"}).addCase(Qo.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(ce,()=>fy).addCase(uM.toString(),()=>fy)}}),{removeCue:iT}=oT.actions,sT=oT.reducer;function cM(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}var aT=e=>{let t=rT(e),r=ZC(e).map(o=>({text:o.response,title:o.name,rule:{id:cM(o.code),label:o.code,name:o.name,description:o.name}}));return[...t,...r]};var hT=w(H());var pT=w(oe()),mT=w(H());var uT=w(oe());var lT={root:"dd-uszkm"};var dT=w(b()),dM=({className:e,children:t})=>{let n=L("Unicode",lT);return(0,dT.jsx)("span",{className:(0,uT.default)(e,n.root),children:t})},cT=dM;var fT={isDisabled:"dd-Sp--t",root:"dd-maqTG",buttonStop:"dd-rcq8w",stateBadge:"dd-zOnkT",isCompleted:"dd-GA-rt",isStarted:"dd-PZwtX",isAborted:"dd-PAXSE"};var py={};Ye(py,{enUS:()=>fM,nlNL:()=>pM});var fM={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"}]},pM={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 Mt=w(b()),gM=({disabled:e,state:t,displayName:n,description:r,onStartAutoflow:o,onStopAutoflow:i})=>{let s=L("Autoflow",fT),a=q(py),l=t==="Started"?"stop":"start",u=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,Mt.jsxs)(re,{className:(0,pT.default)(s.root,{[s.isDisabled]:e,[s.isCompleted]:t==="Completed",[s.isAborted]:t==="Aborted",[s.isStarted]:t==="Started"}),children:[(0,Mt.jsx)(ge,{children:(0,Mt.jsxs)(ge.Content,{children:[(0,Mt.jsxs)(ge.Title,{children:[t&&(0,Mt.jsx)("span",{className:s.stateBadge,children:a(t)}),n]}),(0,Mt.jsx)("span",{children:r})]})}),(0,Mt.jsx)(re.Actions,{fixed:t==="Started",children:(0,Mt.jsx)(re.ActionButton,{primary:!0,className:l==="start"?s.buttonStart:s.buttonStop,onClick:t==="Started"?i:o,disabled:e,label:(0,Mt.jsxs)(mT.Fragment,{children:[(0,Mt.jsx)(cT,{children:u})," ",(0,Mt.jsx)("span",{children:a(l)})]})})})]})},gT=gM;var my=w(b()),hM=(e,t)=>{let n=t.filter(r=>r.state==="Started");return n.length>0?n.indexOf(e)===-1:!1},yM=({autoflows:e,onStartAutoflow:t,onStopAutoflow:n,platformSessionId:r})=>(0,my.jsx)(hT.Fragment,{children:e.map(o=>(0,my.jsx)(gT,{displayName:o.displayName,description:o.description,disabled:o.isBusy||hM(o,e),state:o.state,onStartAutoflow:()=>t({platformSessionId:r,triggerPayload:o.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:r,triggerPayload:o.triggerPayload})},o.displayName))}),vM=({autoflows:e,conversation:t})=>{var n;return{autoflows:e.list,platformSessionId:(n=t.current)==null?void 0:n.sessionId}},SM={onStartAutoflow:ay,onStopAutoflow:ly},yT=Yn(vM,SM)(yM);var vT=w(oe()),gy=w(H());var pr={root:"dd-ERsBr",title:"dd-b36p6",isUsed:"dd-fp2IX",quickReplies:"dd--VrvP",quickReply:"dd-wFhWh",label:"dd-R9sND",errorIcon:"dd-8cdcH"};var Ct=w(b()),wM=({suggestion:e})=>{let t=q(Ko),n=Q(),r=M(jC(e.text)),o=M(VC(e.text)),i=M(KC(e.text)),s=M(os),{replyOptions:a}=e,l=(0,gy.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),!(r||!s)&&n(Sf({platformSessionId:s,suggestion:e}))},[e,r,n,s]),u=(0,gy.useCallback)(c=>{if(c.preventDefault(),c.stopPropagation(),!s||!a)return;let f=parseInt(c.target.dataset.index,10),d=a[f];n(wf({platformSessionId:s,reply:d,suggestion:e}))},[e,r,n,s]);return(0,Ct.jsxs)(re,{onClick:l,className:(0,vT.default)(pr.root,{[pr.isUsed]:r,[pr.hasError]:i}),children:[(0,Ct.jsx)(ge,{children:(0,Ct.jsxs)(ge.Content,{children:[(0,Ct.jsxs)(ge.Title,{className:pr.title,children:[e.text," ",(0,Ct.jsx)(nu,{className:pr.label,children:"analyse tool"})," ",i&&(0,Ct.jsx)("span",{className:pr.errorIcon,role:"img","aria-label":t("sendingError"),title:t("sendingError"),children:"!"})]}),a&&a.length>0&&(0,Ct.jsx)("ul",{className:pr.quickReplies,children:a.map(c=>(0,Ct.jsx)("li",{className:pr.quickReply,children:c.title},c.title))})]})}),(0,Ct.jsxs)(re.Actions,{fixed:i||r,children:[a&&a.length>0&&(0,Ct.jsx)(re.DropdownButton,{label:t("answer"),disabled:o,children:a.map((c,f)=>(0,Ct.jsx)(re.DropdownItem,{index:f,label:c.title,onClick:u},c.title))}),(0,Ct.jsx)(re.ActionButton,{primary:!0,disabled:r,onClick:l,label:t(r?"suggestionSent":i?"tryAgain":"sendSuggestion")})]})]})},ST=wM;var xf=w(H());var yy=w(oe());var hy=w(b()),xl=()=>(0,hy.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,hy.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 wT={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var On=w(b()),xM=({entities:e})=>{let t=L("EntitiesWidgetList",wT),[n,r]=(0,xf.useState)(void 0),o=Q(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),Zn(a.text),o(lt({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,xf.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,On.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,On.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,On.jsx)("span",{className:t.entityText,children:a.text}),(0,On.jsxs)("span",{className:t.iconWrapper,children:[(0,On.jsx)("span",{className:(0,yy.default)(t.icon),children:(0,On.jsx)(xl,{})}),(0,On.jsx)("span",{className:(0,yy.default)(t.icon,n===l&&t.iconClicked),children:(0,On.jsx)(xl,{})})]})]},a.text))})},xT=xM;var vy=w(b()),ET=()=>(0,vy.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,vy.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 Sy=w(b()),bT=()=>(0,Sy.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Sy.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 wy=w(b()),CT=()=>(0,wy.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,wy.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 KT=w(H());var{entries:MT,setPrototypeOf:TT,isFrozen:EM,getPrototypeOf:bM,getOwnPropertyDescriptor:CM}=Object,{freeze:mt,seal:Jt,create:_T}=Object,{apply:ky,construct:Py}=typeof Reflect!="undefined"&&Reflect;mt||(mt=function(t){return t});Jt||(Jt=function(t){return t});ky||(ky=function(t,n,r){return t.apply(n,r)});Py||(Py=function(t,n){return new t(...n)});var Ef=Tt(Array.prototype.forEach),kT=Tt(Array.prototype.pop),El=Tt(Array.prototype.push),Tf=Tt(String.prototype.toLowerCase),xy=Tt(String.prototype.toString),PT=Tt(String.prototype.match),bl=Tt(String.prototype.replace),TM=Tt(String.prototype.indexOf),kM=Tt(String.prototype.trim),hn=Tt(Object.prototype.hasOwnProperty),pt=Tt(RegExp.prototype.test),Cl=PM(TypeError),RT=Tt(Number.isNaN);function Tt(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 ky(e,t,r)}}function PM(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Py(e,n)}}function J(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Tf;TT&&TT(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){let i=n(o);i!==o&&(EM(t)||(t[r]=i),o=i)}e[o]=!0}return e}function RM(e){for(let t=0;t<e.length;t++)hn(e,t)||(e[t]=null);return e}function Zo(e){let t=_T(null);for(let[n,r]of MT(e))hn(e,n)&&(Array.isArray(r)?t[n]=RM(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Zo(r):t[n]=r);return t}function bf(e,t){for(;e!==null;){let r=CM(e,t);if(r){if(r.get)return Tt(r.get);if(typeof r.value=="function")return Tt(r.value)}e=bM(e)}function n(){return null}return n}var AT=mt(["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"]),Ey=mt(["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"]),by=mt(["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"]),AM=mt(["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"]),Cy=mt(["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"]),LM=mt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),LT=mt(["#text"]),IT=mt(["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","wrap","xmlns","slot"]),Ty=mt(["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"]),OT=mt(["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"]),Cf=mt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),IM=Jt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),OM=Jt(/<%[\w\W]*|[\w\W]*%>/gm),NM=Jt(/\${[\w\W]*}/gm),MM=Jt(/^data-[\-\w.\u00B7-\uFFFF]/),_M=Jt(/^aria-[\-\w]+$/),DT=Jt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),DM=Jt(/^(?:\w+script|data):/i),FM=Jt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),FT=Jt(/^html$/i),HM=Jt(/^[a-z][.\w]*(-[.\w]+)+$/i),NT=Object.freeze({__proto__:null,MUSTACHE_EXPR:IM,ERB_EXPR:OM,TMPLIT_EXPR:NM,DATA_ATTR:MM,ARIA_ATTR:_M,IS_ALLOWED_URI:DT,IS_SCRIPT_OR_DATA:DM,ATTR_WHITESPACE:FM,DOCTYPE_NAME:FT,CUSTOM_ELEMENT:HM}),Xo={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},UM=function(){return typeof window=="undefined"?null:window},zM=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 HT(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:UM(),t=j=>HT(j);if(t.version="3.1.3",t.removed=[],!e||!e.document||e.document.nodeType!==Xo.document)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:m}=e,S=l.prototype,y=bf(S,"cloneNode"),p=bf(S,"nextSibling"),g=bf(S,"childNodes"),h=bf(S,"parentNode");if(typeof s=="function"){let j=n.createElement("template");j.content&&j.content.ownerDocument&&(n=j.content.ownerDocument)}let v,x="",{implementation:k,createNodeIterator:C,createDocumentFragment:R,getElementsByTagName:N}=n,{importNode:_}=r,D={};t.isSupported=typeof MT=="function"&&typeof h=="function"&&k&&k.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:G,ERB_EXPR:Z,TMPLIT_EXPR:ie,DATA_ATTR:vr,ARIA_ATTR:_t,IS_SCRIPT_OR_DATA:Sr,ATTR_WHITESPACE:Dt,CUSTOM_ELEMENT:V}=NT,{IS_ALLOWED_URI:Te}=NT,ve=null,wr=J({},[...AT,...Ey,...by,...Cy,...LT]),Se=null,ke=J({},[...IT,...Ty,...OT,...Cf]),we=Object.seal(_T(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}})),ri=null,uo=null,oi=!0,ii=!0,Ul=!1,co=!0,Sn=!1,zl=!0,He=!1,Dn=!1,Ff=!1,si=!1,Bl=!1,jl=!1,jy=!0,Vy=!1,Wk="user-content-",Hf=!0,Ls=!1,ai={},li=null,Ky=J({},["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"]),Wy=null,$y=J({},["audio","video","img","source","image","track"]),Uf=null,qy=J({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Vl="http://www.w3.org/1998/Math/MathML",Kl="http://www.w3.org/2000/svg",Fn="http://www.w3.org/1999/xhtml",ui=Fn,zf=!1,Bf=null,$k=J({},[Vl,Kl,Fn],xy),Is=null,qk=["application/xhtml+xml","text/html"],Gk="text/html",Ue=null,ci=null,Gy=255,Yk=n.createElement("form"),Yy=function(E){return E instanceof RegExp||E instanceof Function},jf=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ci&&ci===E)){if((!E||typeof E!="object")&&(E={}),E=Zo(E),Is=qk.indexOf(E.PARSER_MEDIA_TYPE)===-1?Gk:E.PARSER_MEDIA_TYPE,Ue=Is==="application/xhtml+xml"?xy:Tf,ve=hn(E,"ALLOWED_TAGS")?J({},E.ALLOWED_TAGS,Ue):wr,Se=hn(E,"ALLOWED_ATTR")?J({},E.ALLOWED_ATTR,Ue):ke,Bf=hn(E,"ALLOWED_NAMESPACES")?J({},E.ALLOWED_NAMESPACES,xy):$k,Uf=hn(E,"ADD_URI_SAFE_ATTR")?J(Zo(qy),E.ADD_URI_SAFE_ATTR,Ue):qy,Wy=hn(E,"ADD_DATA_URI_TAGS")?J(Zo($y),E.ADD_DATA_URI_TAGS,Ue):$y,li=hn(E,"FORBID_CONTENTS")?J({},E.FORBID_CONTENTS,Ue):Ky,ri=hn(E,"FORBID_TAGS")?J({},E.FORBID_TAGS,Ue):{},uo=hn(E,"FORBID_ATTR")?J({},E.FORBID_ATTR,Ue):{},ai=hn(E,"USE_PROFILES")?E.USE_PROFILES:!1,oi=E.ALLOW_ARIA_ATTR!==!1,ii=E.ALLOW_DATA_ATTR!==!1,Ul=E.ALLOW_UNKNOWN_PROTOCOLS||!1,co=E.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Sn=E.SAFE_FOR_TEMPLATES||!1,zl=E.SAFE_FOR_XML!==!1,He=E.WHOLE_DOCUMENT||!1,si=E.RETURN_DOM||!1,Bl=E.RETURN_DOM_FRAGMENT||!1,jl=E.RETURN_TRUSTED_TYPE||!1,Ff=E.FORCE_BODY||!1,jy=E.SANITIZE_DOM!==!1,Vy=E.SANITIZE_NAMED_PROPS||!1,Hf=E.KEEP_CONTENT!==!1,Ls=E.IN_PLACE||!1,Te=E.ALLOWED_URI_REGEXP||DT,ui=E.NAMESPACE||Fn,we=E.CUSTOM_ELEMENT_HANDLING||{},E.CUSTOM_ELEMENT_HANDLING&&Yy(E.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(we.tagNameCheck=E.CUSTOM_ELEMENT_HANDLING.tagNameCheck),E.CUSTOM_ELEMENT_HANDLING&&Yy(E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(we.attributeNameCheck=E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),E.CUSTOM_ELEMENT_HANDLING&&typeof E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(we.allowCustomizedBuiltInElements=E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Sn&&(ii=!1),Bl&&(si=!0),ai&&(ve=J({},LT),Se=[],ai.html===!0&&(J(ve,AT),J(Se,IT)),ai.svg===!0&&(J(ve,Ey),J(Se,Ty),J(Se,Cf)),ai.svgFilters===!0&&(J(ve,by),J(Se,Ty),J(Se,Cf)),ai.mathMl===!0&&(J(ve,Cy),J(Se,OT),J(Se,Cf))),E.ADD_TAGS&&(ve===wr&&(ve=Zo(ve)),J(ve,E.ADD_TAGS,Ue)),E.ADD_ATTR&&(Se===ke&&(Se=Zo(Se)),J(Se,E.ADD_ATTR,Ue)),E.ADD_URI_SAFE_ATTR&&J(Uf,E.ADD_URI_SAFE_ATTR,Ue),E.FORBID_CONTENTS&&(li===Ky&&(li=Zo(li)),J(li,E.FORBID_CONTENTS,Ue)),Hf&&(ve["#text"]=!0),He&&J(ve,["html","head","body"]),ve.table&&(J(ve,["tbody"]),delete ri.tbody),E.TRUSTED_TYPES_POLICY){if(typeof E.TRUSTED_TYPES_POLICY.createHTML!="function")throw Cl('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof E.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Cl('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');v=E.TRUSTED_TYPES_POLICY,x=v.createHTML("")}else v===void 0&&(v=zM(m,o)),v!==null&&typeof x=="string"&&(x=v.createHTML(""));mt&&mt(E),ci=E}},Qy=J({},["mi","mo","mn","ms","mtext"]),Xy=J({},["foreignobject","annotation-xml"]),Qk=J({},["title","style","font","a","script"]),Zy=J({},[...Ey,...by,...AM]),Jy=J({},[...Cy,...LM]),Xk=function(E){let A=h(E);(!A||!A.tagName)&&(A={namespaceURI:ui,tagName:"template"});let U=Tf(E.tagName),X=Tf(A.tagName);return Bf[E.namespaceURI]?E.namespaceURI===Kl?A.namespaceURI===Fn?U==="svg":A.namespaceURI===Vl?U==="svg"&&(X==="annotation-xml"||Qy[X]):!!Zy[U]:E.namespaceURI===Vl?A.namespaceURI===Fn?U==="math":A.namespaceURI===Kl?U==="math"&&Xy[X]:!!Jy[U]:E.namespaceURI===Fn?A.namespaceURI===Kl&&!Xy[X]||A.namespaceURI===Vl&&!Qy[X]?!1:!Jy[U]&&(Qk[U]||!Zy[U]):!!(Is==="application/xhtml+xml"&&Bf[E.namespaceURI]):!1},Ft=function(E){El(t.removed,{element:E});try{E.parentNode.removeChild(E)}catch(A){E.remove()}},Wl=function(E,A){try{El(t.removed,{attribute:A.getAttributeNode(E),from:A})}catch(U){El(t.removed,{attribute:null,from:A})}if(A.removeAttribute(E),E==="is"&&!Se[E])if(si||Bl)try{Ft(A)}catch(U){}else try{A.setAttribute(E,"")}catch(U){}},ev=function(E){let A=null,U=null;if(Ff)E="<remove></remove>"+E;else{let Ve=PT(E,/^[\r\n\t ]+/);U=Ve&&Ve[0]}Is==="application/xhtml+xml"&&ui===Fn&&(E='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+E+"</body></html>");let X=v?v.createHTML(E):E;if(ui===Fn)try{A=new d().parseFromString(X,Is)}catch(Ve){}if(!A||!A.documentElement){A=k.createDocument(ui,"template",null);try{A.documentElement.innerHTML=zf?x:X}catch(Ve){}}let Ge=A.body||A.documentElement;return E&&U&&Ge.insertBefore(n.createTextNode(U),Ge.childNodes[0]||null),ui===Fn?N.call(A,He?"html":"body")[0]:He?A.documentElement:Ge},tv=function(E){return C.call(E.ownerDocument||E,E,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},nv=function(E){return E instanceof f&&(typeof E.__depth!="undefined"&&typeof E.__depth!="number"||typeof E.__removalCount!="undefined"&&typeof E.__removalCount!="number"||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")},rv=function(E){return typeof a=="function"&&E instanceof a},Hn=function(E,A,U){D[E]&&Ef(D[E],X=>{X.call(t,A,U,ci)})},ov=function(E){let A=null;if(Hn("beforeSanitizeElements",E,null),nv(E))return Ft(E),!0;let U=Ue(E.nodeName);if(Hn("uponSanitizeElement",E,{tagName:U,allowedTags:ve}),E.hasChildNodes()&&!rv(E.firstElementChild)&&pt(/<[/\w]/g,E.innerHTML)&&pt(/<[/\w]/g,E.textContent)||E.nodeType===Xo.progressingInstruction||zl&&E.nodeType===Xo.comment&&pt(/<[/\w]/g,E.data))return Ft(E),!0;if(!ve[U]||ri[U]){if(!ri[U]&&sv(U)&&(we.tagNameCheck instanceof RegExp&&pt(we.tagNameCheck,U)||we.tagNameCheck instanceof Function&&we.tagNameCheck(U)))return!1;if(Hf&&!li[U]){let X=h(E)||E.parentNode,Ge=g(E)||E.childNodes;if(Ge&&X){let Ve=Ge.length;for(let gt=Ve-1;gt>=0;--gt){let ht=y(Ge[gt],!0);ht.__removalCount=(E.__removalCount||0)+1,X.insertBefore(ht,p(E))}}}return Ft(E),!0}return E instanceof l&&!Xk(E)||(U==="noscript"||U==="noembed"||U==="noframes")&&pt(/<\/no(script|embed|frames)/i,E.innerHTML)?(Ft(E),!0):(Sn&&E.nodeType===Xo.text&&(A=E.textContent,Ef([G,Z,ie],X=>{A=bl(A,X," ")}),E.textContent!==A&&(El(t.removed,{element:E.cloneNode()}),E.textContent=A)),Hn("afterSanitizeElements",E,null),!1)},iv=function(E,A,U){if(jy&&(A==="id"||A==="name")&&(U in n||U in Yk||U==="__depth"||U==="__removalCount"))return!1;if(!(ii&&!uo[A]&&pt(vr,A))){if(!(oi&&pt(_t,A))){if(!Se[A]||uo[A]){if(!(sv(E)&&(we.tagNameCheck instanceof RegExp&&pt(we.tagNameCheck,E)||we.tagNameCheck instanceof Function&&we.tagNameCheck(E))&&(we.attributeNameCheck instanceof RegExp&&pt(we.attributeNameCheck,A)||we.attributeNameCheck instanceof Function&&we.attributeNameCheck(A))||A==="is"&&we.allowCustomizedBuiltInElements&&(we.tagNameCheck instanceof RegExp&&pt(we.tagNameCheck,U)||we.tagNameCheck instanceof Function&&we.tagNameCheck(U))))return!1}else if(!Uf[A]){if(!pt(Te,bl(U,Dt,""))){if(!((A==="src"||A==="xlink:href"||A==="href")&&E!=="script"&&TM(U,"data:")===0&&Wy[E])){if(!(Ul&&!pt(Sr,bl(U,Dt,"")))){if(U)return!1}}}}}}return!0},sv=function(E){return E!=="annotation-xml"&&PT(E,V)},av=function(E){Hn("beforeSanitizeAttributes",E,null);let{attributes:A}=E;if(!A)return;let U={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Se},X=A.length;for(;X--;){let Ge=A[X],{name:Ve,namespaceURI:gt,value:ht}=Ge,Os=Ue(Ve),ot=Ve==="value"?ht:kM(ht);if(U.attrName=Os,U.attrValue=ot,U.keepAttr=!0,U.forceKeepAttr=void 0,Hn("uponSanitizeAttribute",E,U),ot=U.attrValue,U.forceKeepAttr||(Wl(Ve,E),!U.keepAttr))continue;if(!co&&pt(/\/>/i,ot)){Wl(Ve,E);continue}if(zl&&pt(/((--!?|])>)|<\/(style|title)/i,ot)){Wl(Ve,E);continue}Sn&&Ef([G,Z,ie],uv=>{ot=bl(ot,uv," ")});let lv=Ue(E.nodeName);if(iv(lv,Os,ot)){if(Vy&&(Os==="id"||Os==="name")&&(Wl(Ve,E),ot=Wk+ot),v&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!gt)switch(m.getAttributeType(lv,Os)){case"TrustedHTML":{ot=v.createHTML(ot);break}case"TrustedScriptURL":{ot=v.createScriptURL(ot);break}}try{gt?E.setAttributeNS(gt,Ve,ot):E.setAttribute(Ve,ot),nv(E)?Ft(E):kT(t.removed)}catch(uv){}}}Hn("afterSanitizeAttributes",E,null)},Zk=function j(E){let A=null,U=tv(E);for(Hn("beforeSanitizeShadowDOM",E,null);A=U.nextNode();){if(Hn("uponSanitizeShadowNode",A,null),ov(A))continue;let X=h(A);A.nodeType===Xo.element&&(X&&X.__depth?A.__depth=(A.__removalCount||0)+X.__depth+1:A.__depth=1),(A.__depth>=Gy||A.__depth<0||RT(A.__depth))&&Ft(A),A.content instanceof i&&(A.content.__depth=A.__depth,j(A.content)),av(A)}Hn("afterSanitizeShadowDOM",E,null)};return t.sanitize=function(j){let E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},A=null,U=null,X=null,Ge=null;if(zf=!j,zf&&(j="<!-->"),typeof j!="string"&&!rv(j))if(typeof j.toString=="function"){if(j=j.toString(),typeof j!="string")throw Cl("dirty is not a string, aborting")}else throw Cl("toString is not a function");if(!t.isSupported)return j;if(Dn||jf(E),t.removed=[],typeof j=="string"&&(Ls=!1),Ls){if(j.nodeName){let ht=Ue(j.nodeName);if(!ve[ht]||ri[ht])throw Cl("root node is forbidden and cannot be sanitized in-place")}}else if(j instanceof a)A=ev("<!---->"),U=A.ownerDocument.importNode(j,!0),U.nodeType===Xo.element&&U.nodeName==="BODY"||U.nodeName==="HTML"?A=U:A.appendChild(U);else{if(!si&&!Sn&&!He&&j.indexOf("<")===-1)return v&&jl?v.createHTML(j):j;if(A=ev(j),!A)return si?null:jl?x:""}A&&Ff&&Ft(A.firstChild);let Ve=tv(Ls?j:A);for(;X=Ve.nextNode();){if(ov(X))continue;let ht=h(X);X.nodeType===Xo.element&&(ht&&ht.__depth?X.__depth=(X.__removalCount||0)+ht.__depth+1:X.__depth=1),(X.__depth>=Gy||X.__depth<0||RT(X.__depth))&&Ft(X),X.content instanceof i&&(X.content.__depth=X.__depth,Zk(X.content)),av(X)}if(Ls)return j;if(si){if(Bl)for(Ge=R.call(A.ownerDocument);A.firstChild;)Ge.appendChild(A.firstChild);else Ge=A;return(Se.shadowroot||Se.shadowrootmode)&&(Ge=_.call(r,Ge,!0)),Ge}let gt=He?A.outerHTML:A.innerHTML;return He&&ve["!doctype"]&&A.ownerDocument&&A.ownerDocument.doctype&&A.ownerDocument.doctype.name&&pt(FT,A.ownerDocument.doctype.name)&&(gt="<!DOCTYPE "+A.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 $h=w(b()),xN={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Vb=({className:e,color:t})=>(0,$h.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,$h.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:xN[t||"pink"]})});var Kb={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var qh={};Ye(qh,{enUS:()=>EN,nlNL:()=>bN});var EN={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},bN={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Wo=w(b()),$b=({onLogIn:e})=>{let t=q(qh),n=z("floatingMenu"),r=z("productName"),o=Q(),i=M(at),s=L("FloatingMenu",Kb);if(i===null||n===!1)return null;let a=()=>{i===!0?o(Lt(!0)):e()};return(0,Wo.jsxs)("button",{className:(0,Wb.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)(Vb,{className:s.logo,color:"pink"}),i===!1&&(0,Wo.jsx)(jb,{className:s.lock})]})]})};var ef=w(H());var qb=w(H());function to(e){(0,qb.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 Ln(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 CN={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Qd=({ui:e})=>e.overlayCollapsed,Gb=Y({name:"ui",initialState:CN,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:hl,setInputFocus:Xd,setOverlayCollapsed:no,setOpenOverlayWhenTyping:Yb,setOverlayCollapsedUserOverwrite:Qb}=Gb.actions,Xb=Gb.reducer;var Zd=w(H());var Ss=w(H());var Zb=w(H());function Jb(e,t,n){(0,Zb.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var eC={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var qo=w(b()),kN=["search","personal-collection-search","search-autocomplete"];function PN(e,t,n,r={}){var i;let o="";return kN.includes(t)?o=HE(Ih(e,n,{stripAgentPart:!0}),(i=r.searchKeywords)!=null?i:[n]):o=Ih(e,n,r),r.placeholders===!0&&(o=UE(o)),o}var RN=()=>{},AN=({selected:e,suggestion:t})=>{let n=z("inlineSuggestions"),r=M(ss),o=z("enableSuggestionFeedback"),i=M(c=>c.input.text),s=Q(),a=L("TextSuggestion",eC),l=(0,Ss.useRef)(null);(0,Ss.useEffect)(()=>{let c=setTimeout(()=>{s(M1({text:t.text,suggestion:t}))},500);return()=>{clearTimeout(c)}},[t]),Jb(l,"click",()=>{s(an({suggestion:t,text:t.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let u=(0,Ss.useMemo)(()=>PN(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)(re,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:RN,children:(0,qo.jsx)(us,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:u})}),o&&(0,qo.jsx)("div",{className:a.actions,children:(0,qo.jsx)(Gd,{source:"overlay",context:i,suggestion:t})})]})},tC=AN;var Gh=w(b()),LN=({suggestions:e,selectedIndex:t,reverse:n})=>{let r=(0,Zd.useMemo)(()=>{let o=e.map((i,s)=>(0,Gh.jsx)(tC,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]);return(0,Gh.jsx)(Zd.Fragment,{children:r})},Jd=LN;var nC={root:"dd-PfvRI",paper:"dd-HYlyY"};var yl=w(b()),IN=({textSuggestions:e,selectedIndex:t})=>{let n=(0,ef.useRef)(null),r=L("InlineSuggestionsOverlay",nC),o=M(Ln),i=Q(),s=M(at),a=M(is),l=M(Qd),u=z("showTextSuggestions");return to(()=>{setTimeout(()=>{i(no({collapse:!0,skipWhenInputFocus:!0}))})}),(0,ef.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,yl.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,yl.jsx)("div",{ref:n,className:r.paper,children:(0,yl.jsx)(St,{children:(0,yl.jsx)(Jd,{suggestions:e,selectedIndex:t})})})})},ON=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),rC=Yn(ON)(IN);var vl=w(b()),NN=({children:e})=>{let n=z("locale").replace("-","");return(0,vl.jsx)(hh.Provider,{value:n,children:e})},MN=({store:e,customStyles:t={},children:n})=>(0,vl.jsx)(Yg,{store:e,children:(0,vl.jsx)(NN,{children:(0,vl.jsx)(_s.Provider,{value:t,children:n})})}),Go=MN;var nf=w(oe()),ws=w(H());var oC=w(H());function iC(e,t){let[n,r]=(0,oC.useState)(()=>{if(typeof window=="undefined")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return B.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){B.error(s)}}]}var sC=()=>/Mac/i.test(navigator.platform);var lC=w(oe()),ar=w(H());var Yh={};Ye(Yh,{enUS:()=>_N,nlNL:()=>DN});var _N={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"}]}]},DN={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 aC={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var ro=w(b()),Qh=(e,t,n)=>r=>(0,ro.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),FN=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=q(Yh),s=Yt(),a=L("Login",aC),l=z("productName"),u=(0,ar.useCallback)(p=>{p.preventDefault(),r&&r(parseInt(p.target.value,10))},[]),c=(0,ar.useCallback)(p=>{p.preventDefault(),s.send(ls,!0)},[t]),f=(0,ar.useMemo)(()=>p=>(0,ro.jsx)("a",{onClick:h=>{h.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:p},"login"),[t]),d=(0,ar.useCallback)(p=>(0,ro.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:p},"prompt"),[c]),{min:m,hour:S,day:y}=(0,ar.useMemo)(()=>({min:Qh(a,60*10,u),hour:Qh(a,60*60,u),day:Qh(a,60*60*12,u)}),[]);return(0,ro.jsxs)("div",{className:(0,lC.default)(e,a.root),children:[i("loginPlease",{login:n?d:f,productName:l}),r&&(0,ro.jsxs)(ar.Fragment,{children:[(0,ro.jsx)("br",{}),i("snooze",{min:m,hour:S,day:y})]})]})},tf=FN;var uC={root:"dd-DoQhb",text:"dd-Jwnev"};var Sl=w(b()),HN=({title:e})=>{let t=L("SearchTrigger",uC),n=Q();return(0,Sl.jsxs)("button",{type:"button",className:t.root,onClick:()=>n(Lt(!0)),children:[(0,Sl.jsx)(fs,{}),(0,Sl.jsx)("span",{className:t.text,children:e})]})},cC=HN;var Xh={};Ye(Xh,{enUS:()=>UN,nlNL:()=>zN});var UN={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"}]},zN={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 dC={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()),BN=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=L("SuggestionsOverlay",dC),o=q(Xh),i=M(Ln),s=N1(),a=Q(),l=(0,ws.useRef)(null),u=z("searchTriggerKey"),c=z("productName"),f=M(Qd),d=M(at),m=M(is),[S,y]=(0,ws.useState)(null),p=z("showSearch"),g=z("showTextSuggestions"),h=z("adminUrl"),v=z("isEmbedded"),[x,k]=iC("dd-snooze-until-ms",0),C=f||x>Date.now(),R=e.filter(D=>D.source!=="gpt").length,N=()=>{C&&k(0),a(Qb(!C))},_=D=>{let G=Date.now()+D*1e3;k(G),B.info(`Snooze until: ${new Date(G)}`),a(no({collapse:!0}))};return(0,ws.useEffect)(()=>{R===0&&y(null)},[e,R]),to(()=>{a(no({collapse:!0,skipWhenInputFocus:!0}))}),d===null||m===!1?null:d===!1?(0,be.jsxs)("div",{ref:l,className:(0,nf.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)(tf,{loginUrl:h,isEmbedded:v,onLogIn:n,onSnooze:_})})]}):!s||!i?null:(0,be.jsxs)("div",{ref:l,className:(0,nf.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,be.jsxs)("div",{className:r.triggers,children:[(0,be.jsx)("div",{style:{flex:1},children:p&&(0,be.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>y(o(sC()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>y(null),children:(0,be.jsx)(cC,{title:o("search")})})}),(0,be.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,be.jsx)("div",{className:(0,nf.default)(!S&&r.hintsHidden,r.hints),children:S}),(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&&g&&(0,be.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,be.jsx)(St,{children:(0,be.jsx)(Jd,{suggestions:e,selectedIndex:t,reverse:!0})})})]})},jN=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),fC=Yn(jN)(BN);var vf=w(oe());var dr=w(H());var xs=w(H());function rf(e){return e.contentEditable==="true"}function VN(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 pC(e){let{selectionStart:t,selectionEnd:n}=rf(e)?VN(e):e;return[t,n]}function mC(e){let[,t]=(0,xs.useState)(),n=(0,xs.useRef)(null);return n.current=pC(e),(0,xs.useEffect)(()=>{let r=()=>{var a;let[o,i]=(a=n.current)!=null?a:[],s=pC(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 gC(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(iu);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 hC=w(H()),KN=["div","span","mark","strong","b","i","u","em"];function Zh(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(KN.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,hC.cloneElement)(r,{children:Zh(s,t,n+1)})]}return[...e,...t]}function oo(e){return e.tagName.toLowerCase()==="textarea"}var yC={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 PC=w(oe());var pf=w(H());var Es=w(H());function vC(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function of(e){let t=(0,Es.useRef)(null),[n,r]=(0,Es.useState)(!1);return(0,Es.useEffect)(()=>{var c;let o=!1,i=parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[s,a]=vC((f,d)=>{let m=t.current;if(!m)return;let S=f/i,y=d/i,p=m.getBoundingClientRect(),g=S>p.x&&S<p.x+p.width&&y>p.y&&y<p.y+p.height;g&&!o?(o=!0,r(!0)):!g&&o&&(o=!1,r(!1))},({clientX:f,clientY:d})=>[f,d]),[l,u]=vC(()=>{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 SC(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function sf(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function wC(e){return e!=null}var ey=w(oe()),Xt=w(H());var af=w(H()),WN=["bottom","height","left","right","top","width"],$N=(e={},t={})=>WN.some(n=>e[n]!==t[n]),lr=new Map,xC,EC=()=>{let e=[],t=[];lr.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();$N(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{lr.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),xC=window.requestAnimationFrame(EC)};function qN(e,t){return{observe(){let n=lr.size===0;if(lr.has(e)){let r=lr.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else lr.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&EC()},unobserve(){let n=lr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||lr.delete(e),lr.size||cancelAnimationFrame(xC)}}}}function Jh(e){let[t,n]=(0,af.useState)(null);return(0,af.useLayoutEffect)(()=>{if(!e.current)return;let r=qN(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var bs=w(H()),CC=w(Sc());var bC={root:"dd-r-dgo"};var TC=({children:e,parentNode:t})=>{let[n,r]=(0,bs.useState)(null),o=(0,bs.useContext)(_s);return(0,bs.useLayoutEffect)(()=>{let i=document.createElement("div");return $o(i),i.classList.add(bC.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,CC.createPortal)(e,n):null};var In={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 lf=w(b()),uf=(e=!1)=>{let[t,n]=(0,Xt.useState)(e),r=(0,Xt.useCallback)(()=>n(!0),[]),o=(0,Xt.useCallback)(()=>n(!1),[]),i=(0,Xt.useCallback)(()=>n(a=>!a),[]),s=(0,Xt.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function ty(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 Cs=u=>{var c=u,{className:e,triggerRef:t,boundaryRef:n=(0,Xt.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=ty,parentNode:a}=c,l=te(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let f=Jh(t),d=Jh(n),m=(0,Xt.useMemo)(()=>s(f,d,0),[f,d]);return(0,lf.jsx)(TC,{parentNode:a,children:(0,lf.jsx)("div",I(T({className:(0,ey.default)(In.ref,{[In.positionAbove]:r==="above",[In.positionBelow]:r==="below",[In.positionLeft]:r==="left",[In.positionRight]:r==="right",[In.alignStart]:o==="start",[In.alignCenter]:o==="center",[In.alignEnd]:o==="end"}),style:m},l),{role:"dialog",children:(0,lf.jsx)("div",{className:(0,ey.default)(e,In.root),children:i})}))})};var kC=w(oe()),cf=w(H());var ur={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 ny=w(b()),df=(0,cf.forwardRef)((o,r)=>{var i=o,{className:e,children:t}=i,n=te(i,["className","children"]);let s=(0,cf.useRef)(null),a=L("TabCompletion",ur);return(0,ny.jsx)("div",I(T({ref:sf([s,r]),className:(0,kC.default)(e,a.popoverContentContainer)},n),{children:(0,ny.jsx)("div",{className:a.popoverContent,children:t})}))});var io=w(b()),GN=e=>t=>{let n=ty(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},YN=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=L("TabCompletion",ur),s=uf(),a=(0,pf.useMemo)(()=>GN(e.getBoundingClientRect()),[e]),[l,u]=of(e);return(0,pf.useEffect)(()=>{u?s.open():s.close()},[u]),(0,io.jsxs)("span",{children:[(0,io.jsx)("mark",{ref:sf([l,s.triggerRef]),className:(0,PC.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,io.jsx)(Cs,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,io.jsx)(df,{style:n,children:(0,io.jsx)("div",{className:i.hintText,children:o})})})]})},ff=class extends er{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=>I(T({},o),{keywordRegex:new RegExp(`\\b${SC(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(wC);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,io.jsx)(YN,{inputElement:r.inputElement,suggestion:r.suggestion,inputStyle:r.inputStyle,boundaryRef:r.boundaryRef,children:n},`keyword_${r.matchString}_${r.key}`)}asTag(){return"mark"}};var RC=w(oe());var ry=w(b()),QN=({inputElement:e,children:t})=>{let n=L("TabCompletion",ur),[r,o]=of(e);return(0,ry.jsx)("mark",{ref:r,className:(0,RC.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},mf=class extends er{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,ry.jsx)(QN,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var hf=w(oe());var ft=w(H());var oy=w(b()),AC=()=>(0,oy.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,oy.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 so=w(H());var IC=w(xh());var LC={root:"dd-ky-Bv",content:"dd-kV5e1"};function gf(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 iy(e){return e.replace("https://www.","").replace("https://","")}var Zt=w(b()),XN=3,ZN=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),JN=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=XN})=>{let i=L("LinkSearch",LC),[s,a]=(0,so.useState)(""),l=Q(),u=M(Pb("url")),c=M(tE("URL",ZN)),[f,d]=(0,so.useState)(c.length-1),m=z("fallbackImage"),S=h=>{let v=h.target;a(v.value)},y=(h,v)=>{h.stopPropagation(),h.preventDefault(),window.open(v,"_blank")},p=h=>{var k;let v=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(v),h.code==="ArrowDown"&&d(x),h.code==="Enter"&&e(((k=c[f])==null?void 0:k.text)||s)},g=(0,so.useCallback)((0,IC.default)(h=>{l(No({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,so.useEffect)(()=>{s&&g(s)},[s]),(0,so.useEffect)(()=>()=>{l(pd())},[]),(0,Zt.jsxs)("div",{className:i.root,children:[(0,Zt.jsx)(St,{withDivider:!0,children:(s?c:u).slice(0,o).map((h,v)=>(0,Zt.jsx)(re,{selected:f===v,onClick:()=>e(h.text),"data-testid":"linksearch-suggestion",children:(0,Zt.jsxs)(ge,{children:[(0,Zt.jsx)(ge.Image,{src:gf(h,"small",m||void 0),title:h.title||h.text}),(0,Zt.jsxs)(ge.Content,{className:i.content,cropText:!0,children:[(0,Zt.jsx)(ge.Title,{children:h.title||iy(h.text)}),h.title&&iy(h.text)]}),(0,Zt.jsx)(re.Actions,{children:(0,Zt.jsx)(re.ActionButton,{label:r,onClick:x=>y(x,h.text)})})]})},h.text))}),(0,Zt.jsx)(Ja,{value:s,onChange:S,autoFocus:!0,placeholder:n,onKeyUp:p})]})},OC=JN;var sy={};Ye(sy,{enUS:()=>eM,nlNL:()=>tM});var eM={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},tM={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var dt=w(b()),nM=(0,ft.forwardRef)((e,t)=>{let n=L("TabCompletion",ur);return(0,dt.jsx)("mark",{ref:t,className:(0,hf.default)(n.matchSelection)},"selection-start")}),rM=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=q(sy),s=L("TabCompletion",ur),a=(0,ft.useRef)(null),l=(0,ft.useRef)(null),[u,c]=(0,ft.useState)(null),f=Q(),d=uf(document.activeElement===r),[m]=(0,ft.useState)(()=>document.createRange());d.triggerRef.current=m,(0,ft.useEffect)(()=>()=>m.detach(),[]),(0,ft.useEffect)(()=>{let y=e.current,p=a.current;!y||!p||(m.setStart(y,0),m.setEnd(p,0))},[e.current,a.current]),to(()=>{d.close()});let S=(0,ft.useCallback)(y=>{let p=m.toString(),g=/^http(s?):\/\//.test(y)?y:`https://${y}`;f(ad({text:`[${p}](${g})`,replace:"selection"}))},[]);return(0,dt.jsxs)("span",{children:[(0,dt.jsx)("mark",{ref:a,className:(0,hf.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,dt.jsx)(Cs,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,dt.jsxs)(df,{style:n,ref:l,children:[(0,dt.jsx)("div",{className:(0,hf.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,dt.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,dt.jsx)(AC,{}),(0,dt.jsx)("span",{children:"\xA0"}),(0,dt.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,dt.jsx)(OC,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:S,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},yf=class extends er{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,ft.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,dt.jsx)(nM,{ref:this.startRef}):(0,dt.jsx)(rM,{inputElement:r.inputElement,startRef:this.startRef,boundaryRef:r.boundaryRef,inputStyle:r.inputStyle})}asTag(){return"mark"}};var cr=w(b()),oM=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=L("TabCompletion",yC),c=z("insertLink"),f=z("showMidSentenceSuggestions"),d=z("inlineSuggestions"),m=mC(a),S=(0,dr.useRef)(null),y=M(at);(0,dr.useEffect)(()=>{oo(a)&&m&&gC(a,m)},[m]);let p=(0,dr.useCallback)(v=>{if(!o||!n)return v;let x=[(0,cr.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,cr.jsx)("span",{"data-testid":"tab-completion",className:(0,vf.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&x.push((0,cr.jsx)("span",{className:(0,vf.default)(u.hint,u.resetIndent),children:(0,cr.jsx)(tu,{keyCode:"tab"},"tabHint")})),Zh(v,x)},[o,n,r]),g=(0,dr.useMemo)(()=>{let v=[];return c&&v.push(new yf("selection")),v.push(new mf("placeholders")),i&&v.push(new ff("keywords")),v},[d,c,i]),h=(0,dr.useMemo)(()=>{let v=window.getComputedStyle(a);return{"--dd-color":v.color,"--dd-font-size":v.fontSize,"--dd-font-family":v.fontFamily,"--dd-font-variant":v.fontVariant}},[]);return!e||!y?null:(0,cr.jsxs)("div",{ref:v=>{v!=null&&v.parentElement&&(S.current=v==null?void 0:v.parentElement)},className:u.root,style:h,children:[(0,cr.jsx)(us,{tagName:"span",containerTagName:"div",className:(0,vf.default)(u.container,u.agentText),disableLineBreaks:oo(a),content:t||"\u200B",onAfterParse:p,matchers:g,selection:m,keywordMatches:s,inputElement:a,inputStyle:h,boundaryRef:S,inlineSuggestionsOnlyAtEnd:!f}),(0,cr.jsx)("br",{})]})},iM=e=>{var p,g,h;let{input:t,ui:n,settings:r,styleSuggestions:o,conversation:i}=e,s=as({input:t}),a=(s==null?void 0:s.text)||"",l=(s==null?void 0:s.source)||"",u=(p=t.html)!=null?p:cs(t.text),c=a.indexOf(t.text)===0?a.slice(t.text.length):"",{showTabHint:f}=n,{isSupported:d}=i,{showTabCompletion:m,visible:S,showStyleSuggestions:y}=r;return{showTabHint:f,showStyleSuggestions:y,showTabCompletion:m&&Ln(e),content:u,tabText:c,source:l,keywordMatches:(h=(g=o.list)==null?void 0:g.keywordMatches)!=null?h:[],enabled:S&&d!==!1}},NC=Yn(iM)(oM);var ek=w(oe()),Il=w(H());var MC={list:[],fetchState:"idle"},DC=e=>e.autoflows.list||[],_C=e=>t=>{var n;return(n=t.list)==null?void 0:n.find(r=>r.triggerPayload===e)},fr=K("autoflows/getAll",(e,t)=>P(void 0,null,function*(){let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(e)})),ay=K("autoflows/start",(e,t)=>P(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(fr(e.platformSessionId))})),ly=K("autoflows/stop",(e,t)=>P(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(fr(e.platformSessionId))})),sM=Y({name:"autoflows",initialState:MC,reducers:{},extraReducers:e=>{e.addCase(ay.pending,(t,n)=>{let r=_C(n.meta.arg.triggerPayload)(t);r.state="Started",r.isBusy=!0}),e.addCase(ly.pending,(t,n)=>{let r=_C(n.meta.arg.triggerPayload)(t);r.state="Aborted",r.isBusy=!0}),e.addCase(fr.pending,t=>{t.fetchState="loading"}),e.addCase(fr.rejected,t=>{t.fetchState="error"}),e.addCase(fr.fulfilled,(t,n)=>{t.list=n.payload,t.fetchState="done"}),e.addCase(ce,()=>MC)}}),FC=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(fr(e))}),o.on("sessionCompleted",()=>{n(fr(e))})}),HC=K("autoflows/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),UC=sM.reducer;var zC={list:[],fetchState:"idle",sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},BC=e=>e.customMessages.list,jC=e=>t=>!!t.customMessages.sentSuggestions.find(n=>n===e),VC=e=>t=>!!t.customMessages.answeredSuggestions.find(n=>n===e),KC=e=>t=>!!t.customMessages.errorSuggestions.find(n=>n===e),wl=K("customMessages/getAll",(e,t)=>P(void 0,null,function*(){let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(e)})),Sf=K("customMessages/send",(e,t)=>P(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)})),wf=K("customMessages/answer",(e,t)=>P(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)})),WC=Y({name:"customMessages",initialState:zC,reducers:{onCustomMessage(e,t){Array.isArray(t.payload)?e.list=t.payload:e.list=[t.payload]}},extraReducers:e=>{e.addCase(wl.pending,t=>{t.fetchState="loading"}).addCase(wl.rejected,t=>{t.fetchState="error"}).addCase(wl.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload||[]}).addCase(Sf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.errorSuggestions=t.errorSuggestions.filter(r=>n.meta.arg.suggestion.text!==r)}).addCase(Sf.rejected,(t,n)=>{let r=t.sentSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1))}).addCase(wf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(wf.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(ce,()=>zC)}}),$C=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(WC.actions.onCustomMessage(i))})}),qC=K("customMessages/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),GC=WC.reducer;var aM={token:null,interval:null},uy=K("passwordlessToken/getTemporaryPasswordlessToken",(e,t)=>P(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return{token:yield n.requestPasswordlessToken()}})),cy=K("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(uy()),setInterval(()=>r(uy()),n)}),YC=Y({name:"passwordlessToken",initialState:aM,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(uy.fulfilled,(t,n)=>{t.token=n.payload.token}),e.addCase(cy.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:QC}=YC.actions,XC=YC.reducer;var dy={outputs:[],fetchState:"idle"},ZC=e=>{var t;return(t=e.assistants)==null?void 0:t.outputs},lM=Ce("assistants/resetOutputs"),Yo=K("assistants/evaluate",(e,t)=>P(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=>I(T({},u),{name:ut(u.name,s),response:ut(u.response,s)}))),l}catch(o){let i=o.message;return B.warn(i),t.rejectWithValue(i)}})),JC=Y({name:"assistants",initialState:dy,reducers:{removeOutputByCode(e,t){e.outputs=e.outputs.filter(n=>n.code!==t.payload.code)}},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.map(i=>i.name),o=t.outputs.filter(i=>!r.includes(i.name));t.fetchState="done",t.outputs=[...n.payload,...o]}).addCase(ce,()=>dy).addCase(lM.toString(),()=>dy)}}),{removeOutputByCode:eT}=JC.actions,tT=JC.reducer;var nT={excludeFromWidget:!1},fy={cues:[],fetchState:"idle"},rT=e=>{var t;return(t=e.rules)==null?void 0:t.cues},uM=Ce("rules/resetCues"),Qo=K("rules/evaluate",(e,t)=>P(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=>I(T({},d),{title:ut(d.title,s),text:ut(d.text,s)}))),{cues:f,options:e.options}}catch(o){let i=o.message;return B.warn(i),t.rejectWithValue(i)}})),oT=Y({name:"answer",initialState:fy,reducers:{removeCue(e,t){e.cues=e.cues.filter(n=>n.rule.id!==t.payload.id)}},extraReducers:e=>{e.addCase(Qo.pending,t=>{t.fetchState="loading"}).addCase(Qo.rejected,t=>{t.fetchState="error"}).addCase(Qo.fulfilled,(t,n)=>{var i;if((i=n.payload.options)!=null&&i.excludeFromWidget){t.fetchState="done";return}let r=n.payload.cues.map(s=>s.rule.id),o=t.cues.filter(s=>!r.includes(s.rule.id));t.fetchState="done",t.cues=[...n.payload.cues,...o]}).addCase(ce,()=>fy).addCase(uM.toString(),()=>fy)}}),{removeCue:iT}=oT.actions,sT=oT.reducer;function cM(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}var aT=e=>{let t=rT(e),r=ZC(e).map(o=>({text:o.response,title:o.name,rule:{id:cM(o.code),label:o.code,name:o.name,description:o.name}}));return[...t,...r]};var hT=w(H());var pT=w(oe()),mT=w(H());var uT=w(oe());var lT={root:"dd-uszkm"};var dT=w(b()),dM=({className:e,children:t})=>{let n=L("Unicode",lT);return(0,dT.jsx)("span",{className:(0,uT.default)(e,n.root),children:t})},cT=dM;var fT={isDisabled:"dd-Sp--t",root:"dd-maqTG",buttonStop:"dd-rcq8w",stateBadge:"dd-zOnkT",isCompleted:"dd-GA-rt",isStarted:"dd-PZwtX",isAborted:"dd-PAXSE"};var py={};Ye(py,{enUS:()=>fM,nlNL:()=>pM});var fM={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"}]},pM={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 Mt=w(b()),gM=({disabled:e,state:t,displayName:n,description:r,onStartAutoflow:o,onStopAutoflow:i})=>{let s=L("Autoflow",fT),a=q(py),l=t==="Started"?"stop":"start",u=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,Mt.jsxs)(re,{className:(0,pT.default)(s.root,{[s.isDisabled]:e,[s.isCompleted]:t==="Completed",[s.isAborted]:t==="Aborted",[s.isStarted]:t==="Started"}),children:[(0,Mt.jsx)(ge,{children:(0,Mt.jsxs)(ge.Content,{children:[(0,Mt.jsxs)(ge.Title,{children:[t&&(0,Mt.jsx)("span",{className:s.stateBadge,children:a(t)}),n]}),(0,Mt.jsx)("span",{children:r})]})}),(0,Mt.jsx)(re.Actions,{fixed:t==="Started",children:(0,Mt.jsx)(re.ActionButton,{primary:!0,className:l==="start"?s.buttonStart:s.buttonStop,onClick:t==="Started"?i:o,disabled:e,label:(0,Mt.jsxs)(mT.Fragment,{children:[(0,Mt.jsx)(cT,{children:u})," ",(0,Mt.jsx)("span",{children:a(l)})]})})})]})},gT=gM;var my=w(b()),hM=(e,t)=>{let n=t.filter(r=>r.state==="Started");return n.length>0?n.indexOf(e)===-1:!1},yM=({autoflows:e,onStartAutoflow:t,onStopAutoflow:n,platformSessionId:r})=>(0,my.jsx)(hT.Fragment,{children:e.map(o=>(0,my.jsx)(gT,{displayName:o.displayName,description:o.description,disabled:o.isBusy||hM(o,e),state:o.state,onStartAutoflow:()=>t({platformSessionId:r,triggerPayload:o.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:r,triggerPayload:o.triggerPayload})},o.displayName))}),vM=({autoflows:e,conversation:t})=>{var n;return{autoflows:e.list,platformSessionId:(n=t.current)==null?void 0:n.sessionId}},SM={onStartAutoflow:ay,onStopAutoflow:ly},yT=Yn(vM,SM)(yM);var vT=w(oe()),gy=w(H());var pr={root:"dd-ERsBr",title:"dd-b36p6",isUsed:"dd-fp2IX",quickReplies:"dd--VrvP",quickReply:"dd-wFhWh",label:"dd-R9sND",errorIcon:"dd-8cdcH"};var Ct=w(b()),wM=({suggestion:e})=>{let t=q(Ko),n=Q(),r=M(jC(e.text)),o=M(VC(e.text)),i=M(KC(e.text)),s=M(os),{replyOptions:a}=e,l=(0,gy.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),!(r||!s)&&n(Sf({platformSessionId:s,suggestion:e}))},[e,r,n,s]),u=(0,gy.useCallback)(c=>{if(c.preventDefault(),c.stopPropagation(),!s||!a)return;let f=parseInt(c.target.dataset.index,10),d=a[f];n(wf({platformSessionId:s,reply:d,suggestion:e}))},[e,r,n,s]);return(0,Ct.jsxs)(re,{onClick:l,className:(0,vT.default)(pr.root,{[pr.isUsed]:r,[pr.hasError]:i}),children:[(0,Ct.jsx)(ge,{children:(0,Ct.jsxs)(ge.Content,{children:[(0,Ct.jsxs)(ge.Title,{className:pr.title,children:[e.text," ",(0,Ct.jsx)(nu,{className:pr.label,children:"analyse tool"})," ",i&&(0,Ct.jsx)("span",{className:pr.errorIcon,role:"img","aria-label":t("sendingError"),title:t("sendingError"),children:"!"})]}),a&&a.length>0&&(0,Ct.jsx)("ul",{className:pr.quickReplies,children:a.map(c=>(0,Ct.jsx)("li",{className:pr.quickReply,children:c.title},c.title))})]})}),(0,Ct.jsxs)(re.Actions,{fixed:i||r,children:[a&&a.length>0&&(0,Ct.jsx)(re.DropdownButton,{label:t("answer"),disabled:o,children:a.map((c,f)=>(0,Ct.jsx)(re.DropdownItem,{index:f,label:c.title,onClick:u},c.title))}),(0,Ct.jsx)(re.ActionButton,{primary:!0,disabled:r,onClick:l,label:t(r?"suggestionSent":i?"tryAgain":"sendSuggestion")})]})]})},ST=wM;var xf=w(H());var yy=w(oe());var hy=w(b()),xl=()=>(0,hy.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,hy.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 wT={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var On=w(b()),xM=({entities:e})=>{let t=L("EntitiesWidgetList",wT),[n,r]=(0,xf.useState)(void 0),o=Q(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),Zn(a.text),o(lt({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,xf.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,On.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,On.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,On.jsx)("span",{className:t.entityText,children:a.text}),(0,On.jsxs)("span",{className:t.iconWrapper,children:[(0,On.jsx)("span",{className:(0,yy.default)(t.icon),children:(0,On.jsx)(xl,{})}),(0,On.jsx)("span",{className:(0,yy.default)(t.icon,n===l&&t.iconClicked),children:(0,On.jsx)(xl,{})})]})]},a.text))})},xT=xM;var vy=w(b()),ET=()=>(0,vy.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,vy.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 Sy=w(b()),bT=()=>(0,Sy.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Sy.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 wy=w(b()),CT=()=>(0,wy.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,wy.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 KT=w(H());var{entries:MT,setPrototypeOf:TT,isFrozen:EM,getPrototypeOf:bM,getOwnPropertyDescriptor:CM}=Object,{freeze:mt,seal:Jt,create:_T}=Object,{apply:ky,construct:Py}=typeof Reflect!="undefined"&&Reflect;mt||(mt=function(t){return t});Jt||(Jt=function(t){return t});ky||(ky=function(t,n,r){return t.apply(n,r)});Py||(Py=function(t,n){return new t(...n)});var Ef=Tt(Array.prototype.forEach),kT=Tt(Array.prototype.pop),El=Tt(Array.prototype.push),Tf=Tt(String.prototype.toLowerCase),xy=Tt(String.prototype.toString),PT=Tt(String.prototype.match),bl=Tt(String.prototype.replace),TM=Tt(String.prototype.indexOf),kM=Tt(String.prototype.trim),hn=Tt(Object.prototype.hasOwnProperty),pt=Tt(RegExp.prototype.test),Cl=PM(TypeError),RT=Tt(Number.isNaN);function Tt(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 ky(e,t,r)}}function PM(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Py(e,n)}}function J(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Tf;TT&&TT(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){let i=n(o);i!==o&&(EM(t)||(t[r]=i),o=i)}e[o]=!0}return e}function RM(e){for(let t=0;t<e.length;t++)hn(e,t)||(e[t]=null);return e}function Zo(e){let t=_T(null);for(let[n,r]of MT(e))hn(e,n)&&(Array.isArray(r)?t[n]=RM(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Zo(r):t[n]=r);return t}function bf(e,t){for(;e!==null;){let r=CM(e,t);if(r){if(r.get)return Tt(r.get);if(typeof r.value=="function")return Tt(r.value)}e=bM(e)}function n(){return null}return n}var AT=mt(["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"]),Ey=mt(["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"]),by=mt(["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"]),AM=mt(["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"]),Cy=mt(["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"]),LM=mt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),LT=mt(["#text"]),IT=mt(["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","wrap","xmlns","slot"]),Ty=mt(["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"]),OT=mt(["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"]),Cf=mt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),IM=Jt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),OM=Jt(/<%[\w\W]*|[\w\W]*%>/gm),NM=Jt(/\${[\w\W]*}/gm),MM=Jt(/^data-[\-\w.\u00B7-\uFFFF]/),_M=Jt(/^aria-[\-\w]+$/),DT=Jt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),DM=Jt(/^(?:\w+script|data):/i),FM=Jt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),FT=Jt(/^html$/i),HM=Jt(/^[a-z][.\w]*(-[.\w]+)+$/i),NT=Object.freeze({__proto__:null,MUSTACHE_EXPR:IM,ERB_EXPR:OM,TMPLIT_EXPR:NM,DATA_ATTR:MM,ARIA_ATTR:_M,IS_ALLOWED_URI:DT,IS_SCRIPT_OR_DATA:DM,ATTR_WHITESPACE:FM,DOCTYPE_NAME:FT,CUSTOM_ELEMENT:HM}),Xo={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},UM=function(){return typeof window=="undefined"?null:window},zM=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 HT(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:UM(),t=j=>HT(j);if(t.version="3.1.3",t.removed=[],!e||!e.document||e.document.nodeType!==Xo.document)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:m}=e,S=l.prototype,y=bf(S,"cloneNode"),p=bf(S,"nextSibling"),g=bf(S,"childNodes"),h=bf(S,"parentNode");if(typeof s=="function"){let j=n.createElement("template");j.content&&j.content.ownerDocument&&(n=j.content.ownerDocument)}let v,x="",{implementation:k,createNodeIterator:C,createDocumentFragment:R,getElementsByTagName:N}=n,{importNode:_}=r,D={};t.isSupported=typeof MT=="function"&&typeof h=="function"&&k&&k.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:G,ERB_EXPR:Z,TMPLIT_EXPR:ie,DATA_ATTR:vr,ARIA_ATTR:_t,IS_SCRIPT_OR_DATA:Sr,ATTR_WHITESPACE:Dt,CUSTOM_ELEMENT:V}=NT,{IS_ALLOWED_URI:Te}=NT,ve=null,wr=J({},[...AT,...Ey,...by,...Cy,...LT]),Se=null,ke=J({},[...IT,...Ty,...OT,...Cf]),we=Object.seal(_T(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}})),ri=null,uo=null,oi=!0,ii=!0,Ul=!1,co=!0,Sn=!1,zl=!0,He=!1,Dn=!1,Ff=!1,si=!1,Bl=!1,jl=!1,jy=!0,Vy=!1,Wk="user-content-",Hf=!0,Ls=!1,ai={},li=null,Ky=J({},["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"]),Wy=null,$y=J({},["audio","video","img","source","image","track"]),Uf=null,qy=J({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Vl="http://www.w3.org/1998/Math/MathML",Kl="http://www.w3.org/2000/svg",Fn="http://www.w3.org/1999/xhtml",ui=Fn,zf=!1,Bf=null,$k=J({},[Vl,Kl,Fn],xy),Is=null,qk=["application/xhtml+xml","text/html"],Gk="text/html",Ue=null,ci=null,Gy=255,Yk=n.createElement("form"),Yy=function(E){return E instanceof RegExp||E instanceof Function},jf=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ci&&ci===E)){if((!E||typeof E!="object")&&(E={}),E=Zo(E),Is=qk.indexOf(E.PARSER_MEDIA_TYPE)===-1?Gk:E.PARSER_MEDIA_TYPE,Ue=Is==="application/xhtml+xml"?xy:Tf,ve=hn(E,"ALLOWED_TAGS")?J({},E.ALLOWED_TAGS,Ue):wr,Se=hn(E,"ALLOWED_ATTR")?J({},E.ALLOWED_ATTR,Ue):ke,Bf=hn(E,"ALLOWED_NAMESPACES")?J({},E.ALLOWED_NAMESPACES,xy):$k,Uf=hn(E,"ADD_URI_SAFE_ATTR")?J(Zo(qy),E.ADD_URI_SAFE_ATTR,Ue):qy,Wy=hn(E,"ADD_DATA_URI_TAGS")?J(Zo($y),E.ADD_DATA_URI_TAGS,Ue):$y,li=hn(E,"FORBID_CONTENTS")?J({},E.FORBID_CONTENTS,Ue):Ky,ri=hn(E,"FORBID_TAGS")?J({},E.FORBID_TAGS,Ue):{},uo=hn(E,"FORBID_ATTR")?J({},E.FORBID_ATTR,Ue):{},ai=hn(E,"USE_PROFILES")?E.USE_PROFILES:!1,oi=E.ALLOW_ARIA_ATTR!==!1,ii=E.ALLOW_DATA_ATTR!==!1,Ul=E.ALLOW_UNKNOWN_PROTOCOLS||!1,co=E.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Sn=E.SAFE_FOR_TEMPLATES||!1,zl=E.SAFE_FOR_XML!==!1,He=E.WHOLE_DOCUMENT||!1,si=E.RETURN_DOM||!1,Bl=E.RETURN_DOM_FRAGMENT||!1,jl=E.RETURN_TRUSTED_TYPE||!1,Ff=E.FORCE_BODY||!1,jy=E.SANITIZE_DOM!==!1,Vy=E.SANITIZE_NAMED_PROPS||!1,Hf=E.KEEP_CONTENT!==!1,Ls=E.IN_PLACE||!1,Te=E.ALLOWED_URI_REGEXP||DT,ui=E.NAMESPACE||Fn,we=E.CUSTOM_ELEMENT_HANDLING||{},E.CUSTOM_ELEMENT_HANDLING&&Yy(E.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(we.tagNameCheck=E.CUSTOM_ELEMENT_HANDLING.tagNameCheck),E.CUSTOM_ELEMENT_HANDLING&&Yy(E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(we.attributeNameCheck=E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),E.CUSTOM_ELEMENT_HANDLING&&typeof E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(we.allowCustomizedBuiltInElements=E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Sn&&(ii=!1),Bl&&(si=!0),ai&&(ve=J({},LT),Se=[],ai.html===!0&&(J(ve,AT),J(Se,IT)),ai.svg===!0&&(J(ve,Ey),J(Se,Ty),J(Se,Cf)),ai.svgFilters===!0&&(J(ve,by),J(Se,Ty),J(Se,Cf)),ai.mathMl===!0&&(J(ve,Cy),J(Se,OT),J(Se,Cf))),E.ADD_TAGS&&(ve===wr&&(ve=Zo(ve)),J(ve,E.ADD_TAGS,Ue)),E.ADD_ATTR&&(Se===ke&&(Se=Zo(Se)),J(Se,E.ADD_ATTR,Ue)),E.ADD_URI_SAFE_ATTR&&J(Uf,E.ADD_URI_SAFE_ATTR,Ue),E.FORBID_CONTENTS&&(li===Ky&&(li=Zo(li)),J(li,E.FORBID_CONTENTS,Ue)),Hf&&(ve["#text"]=!0),He&&J(ve,["html","head","body"]),ve.table&&(J(ve,["tbody"]),delete ri.tbody),E.TRUSTED_TYPES_POLICY){if(typeof E.TRUSTED_TYPES_POLICY.createHTML!="function")throw Cl('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof E.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Cl('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');v=E.TRUSTED_TYPES_POLICY,x=v.createHTML("")}else v===void 0&&(v=zM(m,o)),v!==null&&typeof x=="string"&&(x=v.createHTML(""));mt&&mt(E),ci=E}},Qy=J({},["mi","mo","mn","ms","mtext"]),Xy=J({},["foreignobject","annotation-xml"]),Qk=J({},["title","style","font","a","script"]),Zy=J({},[...Ey,...by,...AM]),Jy=J({},[...Cy,...LM]),Xk=function(E){let A=h(E);(!A||!A.tagName)&&(A={namespaceURI:ui,tagName:"template"});let U=Tf(E.tagName),X=Tf(A.tagName);return Bf[E.namespaceURI]?E.namespaceURI===Kl?A.namespaceURI===Fn?U==="svg":A.namespaceURI===Vl?U==="svg"&&(X==="annotation-xml"||Qy[X]):!!Zy[U]:E.namespaceURI===Vl?A.namespaceURI===Fn?U==="math":A.namespaceURI===Kl?U==="math"&&Xy[X]:!!Jy[U]:E.namespaceURI===Fn?A.namespaceURI===Kl&&!Xy[X]||A.namespaceURI===Vl&&!Qy[X]?!1:!Jy[U]&&(Qk[U]||!Zy[U]):!!(Is==="application/xhtml+xml"&&Bf[E.namespaceURI]):!1},Ft=function(E){El(t.removed,{element:E});try{E.parentNode.removeChild(E)}catch(A){E.remove()}},Wl=function(E,A){try{El(t.removed,{attribute:A.getAttributeNode(E),from:A})}catch(U){El(t.removed,{attribute:null,from:A})}if(A.removeAttribute(E),E==="is"&&!Se[E])if(si||Bl)try{Ft(A)}catch(U){}else try{A.setAttribute(E,"")}catch(U){}},ev=function(E){let A=null,U=null;if(Ff)E="<remove></remove>"+E;else{let Ve=PT(E,/^[\r\n\t ]+/);U=Ve&&Ve[0]}Is==="application/xhtml+xml"&&ui===Fn&&(E='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+E+"</body></html>");let X=v?v.createHTML(E):E;if(ui===Fn)try{A=new d().parseFromString(X,Is)}catch(Ve){}if(!A||!A.documentElement){A=k.createDocument(ui,"template",null);try{A.documentElement.innerHTML=zf?x:X}catch(Ve){}}let Ge=A.body||A.documentElement;return E&&U&&Ge.insertBefore(n.createTextNode(U),Ge.childNodes[0]||null),ui===Fn?N.call(A,He?"html":"body")[0]:He?A.documentElement:Ge},tv=function(E){return C.call(E.ownerDocument||E,E,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},nv=function(E){return E instanceof f&&(typeof E.__depth!="undefined"&&typeof E.__depth!="number"||typeof E.__removalCount!="undefined"&&typeof E.__removalCount!="number"||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")},rv=function(E){return typeof a=="function"&&E instanceof a},Hn=function(E,A,U){D[E]&&Ef(D[E],X=>{X.call(t,A,U,ci)})},ov=function(E){let A=null;if(Hn("beforeSanitizeElements",E,null),nv(E))return Ft(E),!0;let U=Ue(E.nodeName);if(Hn("uponSanitizeElement",E,{tagName:U,allowedTags:ve}),E.hasChildNodes()&&!rv(E.firstElementChild)&&pt(/<[/\w]/g,E.innerHTML)&&pt(/<[/\w]/g,E.textContent)||E.nodeType===Xo.progressingInstruction||zl&&E.nodeType===Xo.comment&&pt(/<[/\w]/g,E.data))return Ft(E),!0;if(!ve[U]||ri[U]){if(!ri[U]&&sv(U)&&(we.tagNameCheck instanceof RegExp&&pt(we.tagNameCheck,U)||we.tagNameCheck instanceof Function&&we.tagNameCheck(U)))return!1;if(Hf&&!li[U]){let X=h(E)||E.parentNode,Ge=g(E)||E.childNodes;if(Ge&&X){let Ve=Ge.length;for(let gt=Ve-1;gt>=0;--gt){let ht=y(Ge[gt],!0);ht.__removalCount=(E.__removalCount||0)+1,X.insertBefore(ht,p(E))}}}return Ft(E),!0}return E instanceof l&&!Xk(E)||(U==="noscript"||U==="noembed"||U==="noframes")&&pt(/<\/no(script|embed|frames)/i,E.innerHTML)?(Ft(E),!0):(Sn&&E.nodeType===Xo.text&&(A=E.textContent,Ef([G,Z,ie],X=>{A=bl(A,X," ")}),E.textContent!==A&&(El(t.removed,{element:E.cloneNode()}),E.textContent=A)),Hn("afterSanitizeElements",E,null),!1)},iv=function(E,A,U){if(jy&&(A==="id"||A==="name")&&(U in n||U in Yk||U==="__depth"||U==="__removalCount"))return!1;if(!(ii&&!uo[A]&&pt(vr,A))){if(!(oi&&pt(_t,A))){if(!Se[A]||uo[A]){if(!(sv(E)&&(we.tagNameCheck instanceof RegExp&&pt(we.tagNameCheck,E)||we.tagNameCheck instanceof Function&&we.tagNameCheck(E))&&(we.attributeNameCheck instanceof RegExp&&pt(we.attributeNameCheck,A)||we.attributeNameCheck instanceof Function&&we.attributeNameCheck(A))||A==="is"&&we.allowCustomizedBuiltInElements&&(we.tagNameCheck instanceof RegExp&&pt(we.tagNameCheck,U)||we.tagNameCheck instanceof Function&&we.tagNameCheck(U))))return!1}else if(!Uf[A]){if(!pt(Te,bl(U,Dt,""))){if(!((A==="src"||A==="xlink:href"||A==="href")&&E!=="script"&&TM(U,"data:")===0&&Wy[E])){if(!(Ul&&!pt(Sr,bl(U,Dt,"")))){if(U)return!1}}}}}}return!0},sv=function(E){return E!=="annotation-xml"&&PT(E,V)},av=function(E){Hn("beforeSanitizeAttributes",E,null);let{attributes:A}=E;if(!A)return;let U={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Se},X=A.length;for(;X--;){let Ge=A[X],{name:Ve,namespaceURI:gt,value:ht}=Ge,Os=Ue(Ve),ot=Ve==="value"?ht:kM(ht);if(U.attrName=Os,U.attrValue=ot,U.keepAttr=!0,U.forceKeepAttr=void 0,Hn("uponSanitizeAttribute",E,U),ot=U.attrValue,U.forceKeepAttr||(Wl(Ve,E),!U.keepAttr))continue;if(!co&&pt(/\/>/i,ot)){Wl(Ve,E);continue}if(zl&&pt(/((--!?|])>)|<\/(style|title)/i,ot)){Wl(Ve,E);continue}Sn&&Ef([G,Z,ie],uv=>{ot=bl(ot,uv," ")});let lv=Ue(E.nodeName);if(iv(lv,Os,ot)){if(Vy&&(Os==="id"||Os==="name")&&(Wl(Ve,E),ot=Wk+ot),v&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!gt)switch(m.getAttributeType(lv,Os)){case"TrustedHTML":{ot=v.createHTML(ot);break}case"TrustedScriptURL":{ot=v.createScriptURL(ot);break}}try{gt?E.setAttributeNS(gt,Ve,ot):E.setAttribute(Ve,ot),nv(E)?Ft(E):kT(t.removed)}catch(uv){}}}Hn("afterSanitizeAttributes",E,null)},Zk=function j(E){let A=null,U=tv(E);for(Hn("beforeSanitizeShadowDOM",E,null);A=U.nextNode();){if(Hn("uponSanitizeShadowNode",A,null),ov(A))continue;let X=h(A);A.nodeType===Xo.element&&(X&&X.__depth?A.__depth=(A.__removalCount||0)+X.__depth+1:A.__depth=1),(A.__depth>=Gy||A.__depth<0||RT(A.__depth))&&Ft(A),A.content instanceof i&&(A.content.__depth=A.__depth,j(A.content)),av(A)}Hn("afterSanitizeShadowDOM",E,null)};return t.sanitize=function(j){let E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},A=null,U=null,X=null,Ge=null;if(zf=!j,zf&&(j="<!-->"),typeof j!="string"&&!rv(j))if(typeof j.toString=="function"){if(j=j.toString(),typeof j!="string")throw Cl("dirty is not a string, aborting")}else throw Cl("toString is not a function");if(!t.isSupported)return j;if(Dn||jf(E),t.removed=[],typeof j=="string"&&(Ls=!1),Ls){if(j.nodeName){let ht=Ue(j.nodeName);if(!ve[ht]||ri[ht])throw Cl("root node is forbidden and cannot be sanitized in-place")}}else if(j instanceof a)A=ev("<!---->"),U=A.ownerDocument.importNode(j,!0),U.nodeType===Xo.element&&U.nodeName==="BODY"||U.nodeName==="HTML"?A=U:A.appendChild(U);else{if(!si&&!Sn&&!He&&j.indexOf("<")===-1)return v&&jl?v.createHTML(j):j;if(A=ev(j),!A)return si?null:jl?x:""}A&&Ff&&Ft(A.firstChild);let Ve=tv(Ls?j:A);for(;X=Ve.nextNode();){if(ov(X))continue;let ht=h(X);X.nodeType===Xo.element&&(ht&&ht.__depth?X.__depth=(X.__removalCount||0)+ht.__depth+1:X.__depth=1),(X.__depth>=Gy||X.__depth<0||RT(X.__depth))&&Ft(X),X.content instanceof i&&(X.content.__depth=X.__depth,Zk(X.content)),av(X)}if(Ls)return j;if(si){if(Bl)for(Ge=R.call(A.ownerDocument);A.firstChild;)Ge.appendChild(A.firstChild);else Ge=A;return(Se.shadowroot||Se.shadowrootmode)&&(Ge=_.call(r,Ge,!0)),Ge}let gt=He?A.outerHTML:A.innerHTML;return He&&ve["!doctype"]&&A.ownerDocument&&A.ownerDocument.doctype&&A.ownerDocument.doctype.name&&pt(FT,A.ownerDocument.doctype.name)&&(gt="<!DOCTYPE "+A.ownerDocument.doctype.name+`>
|
|
24
24
|
`+gt),Sn&&Ef([G,Z,ie],ht=>{gt=bl(gt,ht," ")}),v&&jl?v.createHTML(gt):gt},t.setConfig=function(){let j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};jf(j),Dn=!0},t.clearConfig=function(){ci=null,Dn=!1},t.isValidAttribute=function(j,E,A){ci||jf({});let U=Ue(j),X=Ue(E);return iv(U,X,A)},t.addHook=function(j,E){typeof E=="function"&&(D[j]=D[j]||[],El(D[j],E))},t.removeHook=function(j){if(D[j])return kT(D[j])},t.removeHooks=function(j){D[j]&&(D[j]=[])},t.removeAllHooks=function(){D={}},t}var UT=HT();var mr=w(H());var BM={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function zT(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function Tl(e){return(e+"").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function kl(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(S){var y=BM[S[1]||""],p=l[l.length-1]==S;return y?y[1]?(p?l.pop():l.push(S),y[0|p]):y[0]:S}function m(){for(var S="";l.length;)S+=d(l[l.length-1]);return S}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,function(S,y,p){return c[y.toLowerCase()]=p,""}).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()+'"':"")+">"+zT(Tl(s).replace(/^\n+|\n+$/g,""))+"</code></pre>":(s=o[6])?(s.match(/\./)&&(o[5]=o[5].replace(/^\d+/gm,"")),i=kl(zT(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="'+Tl(o[8])+'" alt="'+Tl(o[7])+'">':o[10]?(u=u.replace("<a>",'<a href="'+Tl(o[11]||c[r.toLowerCase()])+'">'),n=m()+"</a>"):o[9]?n="<a>":o[12]||o[14]?n="<"+(s="h"+(o[14]?o[14].length:o[13]>"="?1:2))+">"+kl(o[12]||o[15],c)+"</"+s+">":o[16]?n="<code>"+Tl(o[16])+"</code>":(o[17]||o[1])&&(n=d(o[17]||"--"))),u+=r,u+=n;return(u+e.substring(f)+m()).replace(/^\n+|\n+$/g,"")}var BT={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 yn=w(b());function jM(e){return`<button type="button" data-copy-icon class=${e}><svg version="1.1" x="0px" y="0px" viewBox="0 0 115.77 122.88" width="10px" height="10px" fill="black"><g><path d="M89.62,13.96v7.73h12.19h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02v0.02 v73.27v0.01h-0.02c-0.01,3.84-1.57,7.33-4.1,9.86c-2.51,2.5-5.98,4.06-9.82,4.07v0.02h-0.02h-61.7H40.1v-0.02 c-3.84-0.01-7.34-1.57-9.86-4.1c-2.5-2.51-4.06-5.98-4.07-9.82h-0.02v-0.02V92.51H13.96h-0.01v-0.02c-3.84-0.01-7.34-1.57-9.86-4.1 c-2.5-2.51-4.06-5.98-4.07-9.82H0v-0.02V13.96v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07V0h0.02h61.7 h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02V13.96L89.62,13.96z M79.04,21.69v-7.73v-0.02h0.02 c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v64.59v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h12.19V35.65 v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07v-0.02h0.02H79.04L79.04,21.69z M105.18,108.92V35.65v-0.02 h0.02c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v73.27v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h61.7h0.02 v0.02c0.91,0,1.75-0.39,2.37-1.01c0.61-0.61,1-1.46,1-2.37h-0.02V108.92L105.18,108.92z"/></g></svg></button>`}function Ry(e){var n;let t=e.cloneNode(!0);return t.querySelectorAll("div,button").forEach(r=>r.remove()),(n=t.textContent)!=null?n:""}function VM(e){return e.replace(/\r\n/g,`
|
|
25
25
|
`)}var KM=({content:e,useLabel:t,copyLabel:n,onCopy:r,onUse:o})=>{let i=L("Markdown",BT),s=(0,mr.useRef)(null),[a,l]=(0,mr.useState)(null),u=(0,mr.useMemo)(()=>{let y=kl(VM(e));return UT.sanitize(y).replaceAll("</code>",`${jM(i.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[e]),c=y=>{var h;let p=y.target,g=!!((h=s.current)!=null&&h.querySelector("code"));if(["A","BUTTON"].includes(p.tagName)){l(null);return}a||g&&p.tagName!=="CODE"||!g&&p!==s.current||(p.addEventListener("mouseleave",()=>l(null),{once:!0}),l(p))},f=()=>{if(!a)return;l(null);let y=a.querySelector("button");y&&(ms(y,i.fadeup),r(Ry(a)))},d=y=>{let p=y.target;if(p.tagName==="A"){y.stopPropagation();return}"copyIcon"in p.dataset&&(ms(p,i.fadeup),r(Ry(p.parentElement)))},m=()=>{!a||!o||(l(null),o(Ry(a)))},S=y=>{if(y===null)return;let p=y.getBoundingClientRect();p.left<0?y.style.transform=`translateX(${-p.left+2}px)`:p.right>window.innerWidth&&(y.style.transform=`translateX(${window.innerWidth-p.right-2}px)`)};return(0,yn.jsxs)(mr.Fragment,{children:[a&&(0,yn.jsxs)(Cs,{triggerRef:{current:a},className:i.popover,parentNode:a,children:[(0,yn.jsxs)("div",{className:i.options,ref:S,children:[(0,yn.jsx)("button",{type:"button",className:i.option,onClick:f,children:n}),o&&(0,yn.jsxs)(mr.Fragment,{children:[(0,yn.jsx)("div",{className:i.divider}),(0,yn.jsx)("button",{type:"button",className:i.option,onClick:m,children:t})]})]}),(0,yn.jsx)("div",{className:i.arrow})]}),(0,yn.jsx)("div",{ref:s,className:i.root,dangerouslySetInnerHTML:{__html:u},onMouseOver:c,onClick:d})]})},jT=KM;var Ay={};Ye(Ay,{enUS:()=>WM,nlNL:()=>$M});var WM={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"}]},$M={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 VT={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",thumbsUp:"dd-6QwVx",thumbsDown:"dd-d3E8l"};var Nn=w(b()),qM=({cue:e,onRemove:t,onCopy:n,onUse:r})=>{let o=L("WidgetCue",VT),i=q(Ay),s=gs(),a=z("hasKeyboardInput"),l=f=>{n&&n(f,e)},u=f=>{r&&r(f,e)},c=f=>{f.preventDefault(),f.stopPropagation(),t(e)};return(0,KT.useEffect)(()=>{s("Assistant response displayed",{name:e.rule.name,description:e.rule.description,group:e.rule.label,cueText:e.text})},[]),(0,Nn.jsxs)(re,{"data-testid":"cue",children:[(0,Nn.jsx)(ge,{children:(0,Nn.jsxs)(ge.Content,{children:[e.title&&(0,Nn.jsx)(ge.Title,{className:o.title,"data-testid":"widget-cue-title",children:e.title}),(0,Nn.jsx)(jT,{content:e.text,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:l,onUse:a?u:void 0})]})}),(0,Nn.jsxs)(re.ButtonsContainer,{children:[(0,Nn.jsx)(re.Button,{onClick:c,children:i("removeCue")}),(0,Nn.jsx)(ys,{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"})]})]})},WT=qM;var Pl=w(b()),GM=({cues:e})=>{let t=Q(),n=Yt(),r=gs(),o=a=>{t(iT({id:a.rule.id})),t(eT({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)=>{Zn(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,Pl.jsx)(Pl.Fragment,{children:e.map(a=>(0,Pl.jsx)(WT,{cue:a,onRemove:o,onCopy:i,onUse:s},a.rule.id))})},$T=GM;var kf=w(H());var qT={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var vn=w(b());function YM(e,t){return t.split(".").reduce((n,r)=>!n||typeof n!="object"||!(r in n)?null:n[r],e)}var GT=({data:e,schema:t})=>{let n=L("WidgetCustomData",qT),r=o=>{Zn(o)};return(0,kf.useEffect)(()=>{B.info("Custom data",e,t)},[e]),(0,vn.jsx)("dl",{className:n.root,children:t.map(o=>{let i=YM(e,o.path);return(0,vn.jsxs)(kf.Fragment,{children:[(0,vn.jsx)("dt",{className:n.label,children:o.label}),(0,vn.jsx)("dd",{className:n.value,children:o.type==="boolean"&&i?(0,vn.jsx)("span",{className:n.isTrue,children:o.trueValue}):o.type==="boolean"&&!i?(0,vn.jsx)("span",{className:n.isFalse,children:o.falseValue}):i?(0,vn.jsxs)("button",{type:"button",onClick:()=>r(i),className:n.copyButton,children:[(0,vn.jsx)("span",{children:i}),(0,vn.jsx)(xl,{})]}):"-"})]},o.label)})})};var QT=w(H());var QM=/(https?:\/\/[^\s]+)/,YT=e=>e.split(" ").find(t=>QM.test(t));var en=w(b()),XM=({suggestion:e,lines:t,onUse:n})=>{var f;let r=e.text||e.url||e.message,o=YT(r),i=q(Ko),s=z("showImages"),a=z("fallbackImage"),l=z("hasKeyboardInput"),u=d=>{d.preventDefault(),d.stopPropagation(),l&&n(r)},c=(0,QT.useCallback)(d=>{window.open(o,"_blank"),d.stopPropagation(),d.preventDefault()},[o]);return(0,en.jsxs)(re,{onClick:l?u:void 0,"data-testid":"edit-suggestion",children:[(0,en.jsxs)(ge,{children:[s&&e.image&&(0,en.jsx)(ge.Image,{src:gf(e,"small",a||void 0),title:e.title}),(0,en.jsxs)(ge.Content,{children:[e.title&&(0,en.jsx)(ge.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((f=e.searchKeywords)==null?void 0:f.length)>0&&(0,en.jsx)(re.Labels,{labels:e.searchKeywords}),(0,en.jsx)(ge.Content,{cropText:t==="single",lineClamp:t==="multiple",children:r})]})]}),(0,en.jsxs)(re.Actions,{children:[o&&(0,en.jsx)(re.ActionButton,{onClick:c,label:i("visitUrl")}),l&&(0,en.jsx)(re.ActionButton,{primary:!0,onClick:u,label:i("useSuggestion")})]})]})},XT=XM;var Rl=w(b()),ZM=({lines:e,suggestions:t})=>{let n=Yt(),r=(o,i)=>{n.send(Xr,{text:o,suggestion:I(T({},i),{source:i.source,sourceText:i.text})})};return(0,Rl.jsx)(Rl.Fragment,{children:t.map(o=>(0,Rl.jsx)(XT,{suggestion:o,lines:e,onUse:i=>r(i,o)},o.text||o.url||o.message))})},ZT=ZM;var Al={};Ye(Al,{enUS:()=>JM,nlNL:()=>e_});var JM={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"}]},e_={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 Ll={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",sectionList:"dd-bF9pF",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",link:"dd-DRo0x"};var $=w(b()),Pf=(e,t)=>{let n=M(at);(0,Il.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},t_=({onLogIn:e})=>{let t=L("Widget",Ll),n=z("isEmbedded"),r=z("adminUrl");return(0,$.jsx)("div",{className:t.loginText,children:(0,$.jsx)("div",{children:(0,$.jsx)(tf,{isEmbedded:n,loginUrl:r,onLogIn:e})})},"login")},JT=({text:e})=>{let t=L("Widget",Ll);return(0,$.jsx)("div",{className:t.stateText,children:(0,$.jsx)("div",{children:(0,$.jsx)("p",{children:e})})},"notification")},n_=()=>{let e=q(Al),t=Q(),n=L("Widget",Ll),r=z("showSearch"),o=z("showSummaryCommand"),i=z("showKnowledgeSearch"),s=M(hs("/admin/")),a=Yt(),l=z("productName"),u=z("hasKeyboardInput"),c=r||o||i||s;return Pf(()=>(t(cy()),()=>{t(QC())}),[t]),!c||!u?null:(0,$.jsx)(wn,{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)(fs,{}),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)(CT,{}),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)(bT,{}),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)(ET,{}),e("linkStudioLogin",{productName:l})]})]})})},r_=()=>{let e=Q(),t=z("showCustomMessages"),n=M(BC),r=M(os);return Pf(()=>(e(wl(r)),e($C(r)),()=>{e(qC(r))}),[e,t,r]),!t||n.length===0?null:(0,$.jsx)(wn,{type:"custom-messages","data-testid":"custom-messages",children:(0,$.jsx)(St,{withDivider:!0,children:n.map(o=>(0,$.jsx)(ST,{suggestion:o},o.text))})})},o_=()=>{let e=q(Al),t=Q(),n=z("showAutoflows"),r=M(DC),o=M(os);return Pf(()=>(t(fr(o)),t(FC(o)),()=>{t(HC(o))}),[t,n,o]),!n||r.length===0?null:(0,$.jsx)(wn,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,$.jsx)(St,{withDivider:!0,children:(0,$.jsx)(yT,{})})})},i_=()=>{let e=Q(),t=M(Kd),n=M(xb),r=M(aT),o=M(W1),i=M(jd),s=M(Wd),a=M(sr),l=M(Yr);return(0,Il.useEffect)(()=>{!!o&&!n&&B.warn("Custom data provided, but no schema.")},[o,n]),Pf(()=>{t.forEach(({type:u})=>{u==="entities"?e(pn()):su.includes(u)||e(gn(u))})},[e,l,a]),(0,$.jsx)(Il.Fragment,{children:t.map(({type:u,title:c,amount:f,lines:d,schema:m})=>{var S,y;switch(u){case"entities":return i&&i.length>0&&(0,$.jsx)(wn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(xT,{entities:i})},u);case"cues":return r&&r.length>0&&(0,$.jsx)(wn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(St,{withDivider:!0,children:(0,$.jsx)($T,{cues:r})})},u);case"custom-data":return o&&m&&(0,$.jsx)(wn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(St,{withDivider:!0,children:(0,$.jsx)(GT,{data:o,schema:m})})},u);default:return((y=(S=s[u])==null?void 0:S.suggestions)==null?void 0:y.length)>0&&(0,$.jsx)(wn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(St,{withDivider:!0,children:(0,$.jsx)(ZT,{lines:d,contentType:u,suggestions:s[u].suggestions.slice(0,f)||[]})})},u)}})})},s_=({onLogIn:e})=>{let t=q(Al),n=L("Widget",Ll),r=M(is),o=M(at),i=M(os),s=M(sr);return r===!1?(0,$.jsx)(JT,{text:t("notSupported")}):o===!1?(0,$.jsx)(t_,{onLogIn:e}):!s||!i||o===null?(0,$.jsx)(JT,{text:t("waiting")}):(0,$.jsx)("div",{className:(0,ek.default)(n.root),"data-testid":"widget",children:(0,$.jsxs)(ru,{className:n.sectionList,children:[(0,$.jsx)(n_,{}),(0,$.jsx)(r_,{}),(0,$.jsx)(o_,{}),(0,$.jsx)(i_,{})]})})},tk=s_;function Ts(e){let t=new Range;return t.selectNodeContents(e),t}function nk(e,t,n){try{return ao(e,t,n),!0}catch(r){return!1}}function Rf(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function Af(e){return"tagName"in e&&e.tagName==="BR"}var Ol=/[\u200B-\u200D\uFEFF]/g;function ao(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(Ol,""),f=o+c.length,d=t>=o&&t<=f,m=n>=o&&n<=f;if(d){let S=s(u,t-o);S===0&&!m?r.setStartBefore(l):r.setStart(l,S)}m&&(r.setEnd(l,s(u,n-o)),i=!0),o=f;break}case Node.ELEMENT_NODE:{if(Af(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;Rf(l)&&u&&!Rf(u)&&!Af(u)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function Nl(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a,l,u=0;function c(f){let d=f===e,m=f===n,S=f===o;switch(f.nodeType){case Node.TEXT_NODE:{let y=f.textContent;m&&(a=u+y.substring(0,r).replace(Ol,"").length),S&&(l=u+y.substring(0,i).replace(Ol,"").length),u+=y.replace(Ol,"").length;break}case Node.ELEMENT_NODE:{if(Af(f)&&f.nextSibling){u++;break}!d&&Rf(f)&&f.previousSibling&&u++;for(let y=0;y<f.childNodes.length;y++){let p=m&&y===r,g=S&&y===i;if(p&&(a=u),g&&(l=u),l!==void 0||((!p||!s)&&c(f.childNodes[y]),S&&y===i-1&&(l=u),l!==void 0))break}S&&(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 Ml(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a=0,l="";function u(c){let f=c===e,d=c===n,m=c===o;switch(d&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let S=d?r:0,y=m?i:void 0;l+=c.textContent.replace(Ol,"").substring(S,y);break}case Node.ELEMENT_NODE:{if(!s&&a===1&&Af(c)&&c.nextSibling){l+=`
|
|
26
26
|
`;break}!f&&!s&&a===1&&Rf(c)&&c.previousSibling&&(l+=`
|
|
27
|
-
`);let S=d?r:0,y=m?Math.min(i,c.childNodes.length):c.childNodes.length;for(let p=S;p<y&&(u(c.childNodes[p]),a!==2);p++);break}default:break}m&&(a=2)}return u(e),l}var rk=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(rk||{}),gr=class{constructor(t){this.element=t;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(t,n){let r=o=>{n(o)};this.element.addEventListener(t,r),this.disposeHandlers.push(()=>{this.element.removeEventListener(t,r)})}removeEventListener(t,n){this.element.removeEventListener(t,n)}handleInteraction(){let t=this.getText(),n=this.getHTML(),r=this.getSelection(),o=this.cachedCaretPosition===null;if(!this.isActive||(t===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),t!==this.cachedText?(this.cachedText=t,this.cachedHTML=n,o=!0,this.emit("change",{plainText:t,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,o=!0,this.emit("change",{plainText:t,rawHTML:n})),(r.start!==this.cachedSelection.start||r.end!==this.cachedSelection.end)&&(this.cachedSelection=r,o=!0,this.emit("selection",r)),!o))return;let i=this.getCaretPosition();Gr(i,this.cachedCaretPosition)||(this.cachedCaretPosition=i,this.emit("caretposition",i))}handleClick(){this.handleInteraction()}handleFocus(){let t=!this.isFocused;this.isFocused=!0,t&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let t=this.isFocused;this.isFocused=!1,t&&this.emit("blur")}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(rk).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 ok(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var Jo=class extends gr{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),Ml(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!ok(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!ok(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return Nl(this.element,n);let r=this.lastKnownSelection;if(r&&nk(this.element,r.start,r.end))return r;let o=Ts(this.element);return o.collapse(!1),Nl(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return Ml(this.element,ao(this.element,n,r))}listen(){super.listen();let n=new MutationObserver(i=>{var s,a;i.length===2&&i[0].addedNodes.length===1&&((s=i[0].addedNodes[0])==null?void 0:s.textContent)==="\u2060"&&((a=i[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let r=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==r&&(r=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}};var ei=class extends gr{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 ik(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 a_(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var Ly=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()}},Iy=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=ik(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()}},Oy=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(),B.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 Iy(t,this.deepdeskUrl,{debug:!0}):new Ly(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=a_(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(B.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;B.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(I(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)}},sk=Oy;var ks=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var Ny=e=>new Promise(t=>{setTimeout(t,e)});var Ps=class extends ks{constructor(){super(...arguments);this.name="ClientError"}},_y=class extends ks{constructor(){super(...arguments);this.name="ServerError"}},My=new Map;function l_(e){return P(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:(B.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var lo=class lo{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:m=!0,retryOnError:S=R=>R instanceof TypeError,retryOnResponse:y=R=>R.status>=500,version:p=null}=C,g=te(C,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(u)if(l){if(My.has(s)){r(My.get(s));return}}else throw new Error(`Can't use 'useCache' for ${n.method}`);let h=I(T({credentials:"include"},g),{headers:T({Accept:"application/json","Content-Type":"application/json"},g.headers)});!l&&this.csrfToken&&(h.headers=I(T({},h.headers),{"X-CSRFToken":this.csrfToken})),typeof p=="string"&&(h.headers=I(T({},h.headers),{"X-Deepdesk-API-Version":p}));let v=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 k=()=>P(this,null,function*(){return v--,a(s,h).then(R=>P(this,null,function*(){return y(R)&&!i.isAborted&&v>0?(yield Ny(d),k()):R.status===401&&m===!0&&x===!1?(x=!0,yield this.refreshToken(),k()):R})).catch(R=>P(this,null,function*(){if(S(R)&&!i.isAborted&&v>0)return yield Ny(d),k();throw R}))});k().then(R=>P(this,null,function*(){let N=yield l_(R);if(delete this.latestRequestByUrl[s],R.status>=500){o(new _y("Server Error",N));return}else if(R.status===401){o(new Ps("Unauthorized",N));return}else if(R.status===403){o(new Ps("Forbidden",N));return}else if(R.status===404){o(new Ps("Not Found",N));return}else if(R.status>=400){o(new Ps("Bad Request",N));return}u&&My.set(s,N),r(N)})).catch(R=>{o(R)})})}validateToken(){return P(this,null,function*(){let{has_valid_access_token:t}=yield this.get("/auth/validate");if(!t)try{yield this.refreshToken()}catch(r){return!1}let{is_logged_in:n}=yield this.get("/apis/admin/session/validate/");return!!n})}refreshToken(){return lo.refreshingToken||(lo.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{lo.refreshingToken=null},1e3*60)})),lo.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))}};lo.refreshingToken=null;var hr=lo;var ak;(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={}))})(ak||(ak={}));function Lf(e){return I(T({},ee(e)),{tags:e.tags})}var ti=class ti{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new hr(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,i)=>P(this,null,function*(){let s=yield r(o,i);return this.handleDeepdeskVersionHeaders(s),s}))}preflight(){return P(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(ti.exchangeTokenPromise||(ti.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),ti.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return P(this,null,function*(){yield this.preflight(),B.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=yield this.client.post("/api/conversations",I(T({},Ie(t)),{tags:t.tags}),{version:"v2"});return Lf(n)})}getMe(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/session/me/");return ee(t)})}patchMe(t){return P(this,null,function*(){let n=yield this.client.patch("/apis/admin/session/me/",Ie(t));return ee(n)})}getProfile(t){return P(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{useCache:!0});return ee(n)})}getKnowledgeAssistant(t){return P(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{useCache:!0});return ee(n)})}getContentTypes(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return ee(t)})}getAccount(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{useCache:!0});return ee(t)})}getPlatformConfig(t){return P(this,null,function*(){let n=t!==void 0?`/platform/config/${t}/`:"/platform/config/",{config:r}=yield this.client.get(n,{useCache:!0});return ee(r)})}checkUserExists(t){return P(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`,{version:"v1"});return n})}getConversationBySessionId(r){return P(this,arguments,function*(t,n={}){yield this.preflight(),B.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 B.info(`Successfully retrieved conversation ${s.id} for session ${t}`),Lf(s)})}isConversationSupported(r){return P(this,arguments,function*(t,n={}){B.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 P(this,null,function*(){let r=Ie(n);n.tags&&(r.tags=n.tags);let o=yield this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return Lf(o)})}postMessages(t,n){return P(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/messages`,n.map(o=>I(T({},Ie(o)),{tags:o.tags})),{version:"v2"})).map(o=>Lf(o))})}sendEvent(t,n){return P(this,null,function*(){let s=n,{data:r}=s,o=te(s,["data"]),i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((a,[l,u])=>I(T({},a),{[l]:u}),{});return this.client.post("/api/events",Ie(I(T(T({},i),o),{data:r,name:t})),{version:"v2"})})}sendEventV1(t,n){return P(this,null,function*(){let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>I(T({},o),{[i]:s}),{});return this.client.post("/api/events",{event:t,data:Ie(T(T({},n),r))},{version:"v1"})})}getEntities(t){return P(this,null,function*(){return(yield this.client.post("/api/entities",{messages:t.filter(r=>r.text)},{version:"v1"})).entities})}getSummary(r){return P(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},{version:"v1"});return ee(o)})}getTemporaryExchangeToken(){return P(this,null,function*(){return(yield this.client.get("/auth/exchange-token")).jwt})}exchangeTokenForAccessCookie(t){return P(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t}).catch(n=>{throw B.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return P(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Ie(n),{refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return P(this,arguments,function*(t,n={},r){return r==="sticky-messages"?this.getPinnedMessages(t):(yield this.client.post(`/api/conversations/${t}/recommend/${r}`,Ie(n),{abortLatest:!0,version:"v1"})).map(s=>I(T({},ee(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 P(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return P(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/autocomplete`,Ie(n),{abortLatest:!0,version:"v1"})).map(o=>({score:1,source:o.source,sourceText:o.source_text,text:o.label,trainingJobs:o.training_jobs,searchKeywords:o.search_keywords,type:o.source})).filter((o,i,s)=>i===s.findIndex(a=>a.text===o.text))})}getPinnedMessages(t){return P(this,null,function*(){let n=yield this.client.get(`/api/conversations/${t}/sticky-messages`,{abortLatest:!0,version:"v1"});return ee(n).map(r=>I(T({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return P(this,null,function*(){let n=yield this.client.post("/api/style-suggestions",Ie(t),{abortLatest:!0,version:"v1"});return ee(n)})}search(t){return P(this,null,function*(){let n=yield this.client.post(`/api/profiles/${t.profile}/search`,Ie(t),{version:"v2"});return ee(n)})}knowledgeAssist(i,s,a){return P(this,arguments,function*(t,n,r,o={}){let l=yield this.client.post(`/api/knowledge-assist/assistants/${r}/search`,Ie({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 ee(l)})}requestLoginByEmail(t){return P(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t});return ee(n)})}requestPasswordlessToken(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/");return ee(t.token)})}getCsrfToken(){return P(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/");return t})}verifyLoginToken(t){return P(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t});return ee(n)})}evaluateRule(i,s,a){return P(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?ee(u.cues):[]})}evaluateAssistant(t,n,r){return P(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});return ee(i.output)})}getRules(){return P(this,null,function*(){let t=new URLSearchParams,n=yield this.client.get(`/apis/admin/rule-engine/rules/?${t.toString()}`,{useCache:!0});return ee(n)})}translateMessages(t){return P(this,null,function*(){let n=yield this.client.post("/api/translate",Ie(t),{version:"v2"});return ee(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(t0);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&B.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};ti.exchangeTokenPromise=null;var yr=ti;var _l=class{constructor(t,n){this.url=t;this.eventListeners={};this.options=T({timeout:25e3},n)}proxyEvent(t){this.eventSource.addEventListener(rh(t),n=>{let{data:r}=n;try{let o=JSON.parse(r);this.emit(t,ee(o))}catch(o){B.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 lk;(t=>{let e;(i=>(i.Started="Started",i.Aborted="Aborted",i.Completed="Completed"))(e=t.AutoflowSessionState||(t.AutoflowSessionState={}))})(lk||(lk={}));var Dl=class{constructor(t,n={}){this.apiUrl=t;this.streams={};this.logger=B;this.client=new hr(t,n)}getCustomMessages(t){return P(this,null,function*(){let n=yield this.client.get(`/sessions/${t}/suggestions`);return ee(n.suggestions)})}sendCustomMessage(t,n){return P(this,null,function*(){let r=yield this.client.post(`/sessions/${t}/messages`,Ie(n));return ee(r)})}answerCustomMessage(t,n){return P(this,null,function*(){yield this.client.post(`/sessions/${t}/answers`,Ie(n))})}getAutoflows(t){return P(this,null,function*(){let n=yield this.client.get(`/sessions/${t}/autoflows`);return ee(n.autoflows)})}startAutoflowSession(t){return P(this,null,function*(){let n=yield this.client.post("/autoflow-sessions",Ie(t));return ee(n)})}stopAutoflowSession(t){return P(this,null,function*(){yield this.client.delete(`/autoflow-sessions/${t}`)})}openStream(t){return this.streams[t]||(this.streams[t]=new _l(`${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 uk={startTime:null,stopTime:null},ck=Y({name:"handlingTime",initialState:uk,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(ce,()=>uk)}}),{handlingTimeStart:dk,handlingTimeStop:If,handlingTimeReset:fk}=ck.actions,pk=ck.reducer;var mk=(e={})=>{let t=T({onAuthError:rs(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var Of={list:{keywordMatches:[]},fetchState:"idle"};var ni=K("styleSuggestions/getAll",(n,r)=>P(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 Of.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),u_=Y({name:"styleSuggestions",initialState:Of,reducers:{},extraReducers:e=>{e.addCase(ni.pending,t=>{t.fetchState="loading"}).addCase(ni.rejected,t=>{t.fetchState="error"}).addCase(ni.fulfilled,(t,n)=>{t.fetchState="done",Gr(t.list,n.payload)||(t.list=n.payload)}).addCase(Oo,t=>{t.list=Of.list}).addCase(ce,()=>Of)}}),gk=u_.reducer;var hk=(e={})=>{let t,n=!0,r=T({getStyleSuggestions:ni,debounce:500},e);return o=>i=>s=>{var m;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(!((m=u.conversation.current)==null?void 0:m.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 c_(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var yk=(e={})=>{let t=T({getTextSuggestions:gn,getAutocompleteSuggestions:ml,debounce:200,check:Ln},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===$d.toString();if(!f||!u&&!c)return a;let{input:m}=l;return c_(m,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let p=ss(l);p===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(p))},d?0:t.debounce)),a}};var vk=ni.fulfilled.toString();function d_(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 Sk=e=>t=>n=>r=>{var u;if(r.type!==vk){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=d_(o,s);r.type===vk&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var f_=kc({assistants:tT,answer:vb,auth:x1,autoflows:UC,conversation:I1,contentTypes:RE,customMessages:GC,passwordlessToken:XC,entities:JE,knowledgeAssistant:gb,handlingTime:pk,info:Q1,input:V1,settings:m1,profile:Eb,search:rE,summary:sb,styleSuggestions:gk,ui:Xb,rules:sT,textSuggestions:Lb});function wk(e){return wx({reducer:f_,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI,deepdeskBrokerAPI:e.deepdeskBrokerAPI}},serializableCheck:!1}),mk(),yk({debounce:200}),hk({debounce:500}),Sk(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var p_=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},m_=e=>t=>n=>r=>{var a,l,u,c,f,d;let o=t.getState(),i=Xg("inlineSuggestions")(o);switch(r.type){case rs.toString():{!r.payload&&e.emit("logout",void 0);break}case pn.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 lt.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 Qo.fulfilled.toString():r.isBroadcasted||e.broadcast(sh,r,!1),(c=r.payload.options)!=null&&c.shouldEmit&&e.emit("cues",r.payload.cues);break;case Yo.fulfilled.toString():r.isBroadcasted||e.broadcast(ah,r,!1);break;default:break}let s=n(r);switch(r.type){case Oo.toString():e.handleAfterSendMessage(r.payload);break;case hl.toString():e.onUpdateShowTabHint(r.payload);break;case If.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case ad.toString():{let{start:m,end:S}=o.input.selection;e.emit("replace",I(T({},r.payload),{replace:r.payload.replace==="selection"?{start:m,end:S}:{start:0,end:S}}));break}case an.toString():{let{start:m,end:S}=o.input.selection;e.emit("select-suggestion",I(T({type:p_(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:m,end:S}:{start:0,end:S}})),i&&t.dispatch(Qr([]));break}case ld.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 Qr.toString():{i&&r.payload.length>0&&t.dispatch(ud(0));break}case rr.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},xk=m_;function Dy(e){return e.toISOString().replace("T"," ").replace("Z","")}function Ek(e,t){var i,s,a,l;let n=(i=e.conversation.current)==null?void 0:i.id;if(!n)return B.warn("No conversationId for handling time metrics"),null;let{startTime:r,stopTime:o}=e.handlingTime;return!r||!o?(B.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:Dy(r),timeStop:Dy(o)}}function bk(e,t,n){var N,_,D,G;let r=(N=t.conversation.current)==null?void 0:N.id;if(!r)return B.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:m,deletions:S,textSuggestions:y,offeredTextSuggestions:p}}=t[e],g=o.length,v=y.reduce((Z,{text:ie,searchTerm:vr})=>Z+ie.length-(vr?vr.length:0),0),x=c!=null?c:Date.now(),k=(Date.now()-x)/1e3+(f||0),C=i/k,R=y.reduce((Z,{searchTerm:ie})=>Z+(ie?ie.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:d,cuts:m,deletions:S,lenTextTyped:i+R,lenTextTotal:g,lenTextAssisted:v,lenTextPasted:s,lenTextCut:a,lenTextDeleted:l,timeTotalSeconds:k,charsPerSecond:C,numPastes:u,textSuggestionsV2:y,suggestionsCounters:[{source:"gpt",countOffered:p.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 Fy(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return Fy(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?Fy(o,t):null}function Ck(e,t){return Fy(e,t)}function Tk(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function g_(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Nf(e){return g_(e)&&(oo(e)||rf(e))}var Pk,Mn=new Map,h_=["bottom","height","left","right","top","width"],kk=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:h_.some(n=>e[n]!==t[n]);function Rk(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,...Rk(t)]:[]}function Ak(e,t){return!e||!t?null:I(T({},e),{top:e.top+t.top,left:e.left+t.left})}var Mf=!1,Lk=()=>{Mf=!0;let e=[];if(Mn.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Mn.delete(n);return}let r=n.getBoundingClientRect();kk(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(Ak,t.rect):t.rect;kk(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Mn.size===0){Mf=!1;return}Pk=window.requestAnimationFrame(Lk)};function Hy(e,t){let n=Rk(e),r=[],o=n.map((i,s)=>Hy(i,a=>{r[s]=a;let l=Mn.get(e);if(!l)return;let u=r.reduce(Ak,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),Mn.has(e)){let s=Mn.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else Mn.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Mf&&Lk()},unobserve(){o.forEach(s=>s.unobserve());let i=Mn.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||Mn.delete(e),Mn.size||(cancelAnimationFrame(Pk),Mf=!1)}}}}var Ik,_n=new Map,Ok=()=>{_n.forEach((e,t)=>{if(!t.isConnected){_n.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)))}),_n.size!==0&&(Ik=window.requestAnimationFrame(Ok))};function Nk(e,t){return{observe(){let n=_n.size===0;_n.has(e)?_n.get(e).callbacks.push(t):_n.set(e,{visible:void 0,callbacks:[t]}),n&&Ok()},unobserve(){let n=_n.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||_n.delete(e),_n.size||cancelAnimationFrame(Ik)}}}}var Uy=["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 zy(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function Rs(e){return parseFloat(e)}function _f(e){return Math.round(e*1e6)}function Mk(e){return e/1e6}function By(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=Rs(e.width),i=Rs(e.borderLeftWidth),s=Rs(e.borderRightWidth),a=Rs(e.paddingRight),l=Mk(_f(o)-_f(i)-_f(s)),u=Mk(_f(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function Fl(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};zy(r,n,Uy),By(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=Nk(e,()=>{zy(r,n,Uy),By(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=Hy(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(zy(r,n,Uy),By(r,e,n),i(),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let m=t.closestScrollElement.getBoundingClientRect(),S=window.getComputedStyle(t.closestScrollElement),y=Rs(S.borderTopWidth),p=Rs(S.borderBottomWidth),g=m.top+y-d.top,h=d.top+d.height+-(m.top+m.height-p);n.style.clipPath=`inset(${g}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 _k=(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){B.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function y_(e){return e.offsetParent!==null}function Dk(e){if(!y_(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 Df(e,t,n=100){let r=Dk(e);t({isVisible:r});let o=setInterval(()=>{let i=Dk(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var Fe=w(b());var Fk=_k("showTabHint",!0),As=class As{constructor({deepdeskUrl:t,brokerUrl:n,version:r=As.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 yr(u,{token:i,fetch:s}),this.version=r,this.instanceId=As.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[xk({broadcast:(f,d,m)=>{this.broadcastEvents.send(f,d,m)},emit:(f,d)=>this.emit(f,d),handleAfterSendMessage:f=>this.handleAfterSendMessage(f),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:f=>this.logSendMessage(f),onUpdateShowTabHint:f=>Fk.update(f),sendEvent:(f,d)=>this.deepdeskApi.sendEvent(f,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new Dl(n)}),this.store=wk(c),this.broadcastEvents=new sk({debug:!0,deepdeskUrl:u,eventMap:oE(this.store),createCustomChannel:l}),this.store.dispatch(hl(Fk.value())),this.store.dispatch(td({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?(B.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(B.warn("Profile has not been loaded (yet)"),!0):(B.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(rs(null)),this.store.dispatch(Qn()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();at(r)&&g1(r)!=="loading"&&(n(),t())});this.unmountHandlers.push(()=>{n()})})}isLoggedIn(){return P(this,null,function*(){return(yield this.store.dispatch(Qn())).payload})}isConversationSupported(t,n){return P(this,null,function*(){return(yield this.store.dispatch(eh({sessionId:t,options:n}))).payload})}createConversation(t){return P(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(rd(t))).payload})}getConversationBySessionId(t,n){return P(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(yield this.store.dispatch(od({sessionId:t,options:n}))).payload})}upsertConversation(t){return P(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(th(t))).payload})}postMessages(t){return P(this,null,function*(){return(yield this.store.dispatch(sd(t))).payload})}updateConversation(t){return P(this,null,function*(){return(yield this.store.dispatch(id(t))).payload})}resetConversation(){this.store.dispatch(ce()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}getSummary(){return P(this,null,function*(){let t=yield this.store.dispatch(rr());if(t.error)throw new Error(t.error.message);return t.payload.summary})}configure(t){this.store.dispatch(td(t))}setVisitorInfo(t){this.store.dispatch(q1(t))}setCustomData(t){this.store.dispatch(G1(t))}setAgentInfo(t){return P(this,null,function*(){yield this.store.dispatch(Wa(t))})}setAgentSettings(t){return P(this,null,function*(){yield this.store.dispatch(oh(t))})}getAgentSettings(){return P(this,null,function*(){return(yield this.store.dispatch(ih())).payload})}refresh(){return P(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(cd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let t=[];return this.store.dispatch($d()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}notifyExternalSuggestion(t){this.store.dispatch(an(t))}evaluateRule(o){return P(this,arguments,function*(t,n={},r=nT){return(yield this.store.dispatch(Qo({label:t,params:n,options:r}))).payload.cues})}evaluateAssistant(r){return P(this,arguments,function*(t,n={}){yield this.store.dispatch(Yo({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(!Ln(this.state)||(this.store.dispatch(D1(nh(t))),t.key!=="Tab"&&!l))return;let f=()=>{n||!c||s&&(t.shiftKey||(this.store.dispatch(U1()),t.preventDefault()))},d=()=>{n||!c||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(z1()),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(ud(-1)),this.store.dispatch(no({collapse:!0})),this.store.dispatch(Yb(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let m=as(this.state);if(!m)return;this.store.dispatch(hl(!1)),this.store.dispatch(an({text:m.text,suggestion:m,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.state.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let m=as(this.state);if(!m)return;this.store.dispatch(an({text:m.text,suggestion:m,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.state.settings.inlineSuggestions||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let m=as(this.state);if(!m)return;this.store.dispatch(an({text:m.text,suggestion:m,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(no({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(Qr([]))}handlingTimeStart(){this.state.handlingTime.startTime||(B.info("Start handling time"),this.store.dispatch(dk()))}handlingTimeStop(){this.state.handlingTime.startTime&&(B.info("Stop handling time"),this.store.dispatch(If()))}logSendMessage(t){let n=bk("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=Ek(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(fk()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(Oo((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(j1()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(i){B.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),B.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(Y1(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]=Fl(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,tn.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var a;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let i=(a=t.ownerDocument.defaultView)==null?void 0:a.frameElement,s=i?i.ownerDocument.defaultView:null;if(i&&(s===window||(s==null?void 0:s.parent)===window)){let[l,u]=Fl(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{(0,tn.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,tn.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),B.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()?(B.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(B1(r.metrics))):B.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(!Nf(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:m,inputMediator:S,closestScrollSelector:y,appendOverlayTo:p,inlineSuggestions:g,floatingMenu:h}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:m,isEmbedded:f,inlineSuggestions:g,floatingMenu:!!h}),n.automaticHandlingTime&&this.setupHandlingTime(t),$o(t),this.inputMediator=S||(oo(t)?new ei(t):new Jo(t)),this.inputMediator.on("change",({plainText:k,rawHTML:C})=>{this.store.dispatch(cd({text:k,html:C}))}),this.inputMediator.on("keyup",k=>{this.store.dispatch(F1(nh(k)))}),this.inputMediator.on("keydown",k=>{this.handleKeyDown(k)}),this.inputMediator.on("paste",({pastedText:k,selectionText:C})=>{this.store.dispatch(H1({text:k,selectionText:C}))}),this.inputMediator.on("cut",({selectionText:k})=>{this.store.dispatch(_1(k))});let v;this.inputMediator.on("selection",k=>{clearTimeout(v),k===null?v=setTimeout(()=>{k!==null&&this.store.dispatch(dd(k))},500):this.store.dispatch(dd(k))}),this.inputMediator.on("disabled",()=>{var k;(k=this.inputMediator)==null||k.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&&Ck(t,y)||void 0;if(g){let{customStyles:k,appendOverlayTo:C}=n;if(oo(t))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let R=this.createInlineContainer(t,"deepdesk-caret");(0,tn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:k,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(rC,{})})}),R),this.inputMediator.on("caretposition",_=>{_?(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},k==null?void 0:k.floatingMenuRootNode);(0,tn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:k,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)($b,{onLogIn:()=>this.loginViaPopup().catch(_=>B.warn(_.message))})})}),N)}else{let k=this.overlayContainerFactory("deepdesk-tab-completion",x||t,{appendTo:p,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||t,{appendTo:p},r==null?void 0:r.suggestionsRootNode);(0,tn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:r,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(NC,{inputElement:t})})}),k),(0,tn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:r,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(fC,{onLogIn:()=>this.loginViaPopup().catch(R=>B.warn(R.message))})})}),C)}(0,tn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:r,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(Bb,{})})}),this.createContainer("deepdesk-overlays")),this.store.dispatch(cd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(dd(this.inputMediator.getSelection())),this.store.dispatch(Xd(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{var k;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((k=this.state.conversation.current)==null?void 0:k.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&&B.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,tn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:r,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(tk,{onLogIn:()=>this.loginViaPopup().catch(s=>B.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,tn.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Df(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){Tk(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>P(this,null,function*(){yield this.store.dispatch(pl());let t=sr(this.state);t&&(yield this.store.dispatch(cl()),this.store.dispatch(td({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 P(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=m=>P(this,null,function*(){var S,y;if((S=m.data)!=null&&S.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((y=m.data)==null?void 0:y.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(qa),l=!0,o.port1.close(),n()}catch(p){console.error(p),r(p)}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=m=>P(this,null,function*(){var S;if(m.origin===a.origin)switch((S=m.data)==null?void 0:S.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){B.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-error":{u(),m.data.message==="Timeout"&&B.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(m.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 P(this,null,function*(){try{let{account:n}=yield this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(B.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;B.info(r),this.shouldRender=!1}})}refreshWidgetSuggestions(){return P(this,null,function*(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=Kd(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(pn()):su.includes(r)||this.store.dispatch(gn(r))})}catch(r){this.handleError(r)}})}};As.version="14.1.0",As.count=0;var Hl=As;function v_(e){return P(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 Hk(e,t){return P(this,null,function*(){let n=yield v_(t),r=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(e,"files",{configurable:!0,get:()=>[n]}),e.dispatchEvent(r)}finally{Object.hasOwn(e,"files")&&delete e.files}})}function Uk(e,t,n){return P(this,null,function*(){yield new yr(e).authenticateWithKey(t,n)})}function zk(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function Bk(r,o){return P(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 jk(r,o){return P(this,arguments,function*(e,t,n={}){let i=n.replace?ao(e,n.replace.start,n.replace.end):Ts(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
|
+
`);let S=d?r:0,y=m?Math.min(i,c.childNodes.length):c.childNodes.length;for(let p=S;p<y&&(u(c.childNodes[p]),a!==2);p++);break}default:break}m&&(a=2)}return u(e),l}var rk=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(rk||{}),gr=class{constructor(t){this.element=t;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(t,n){let r=o=>{n(o)};this.element.addEventListener(t,r),this.disposeHandlers.push(()=>{this.element.removeEventListener(t,r)})}removeEventListener(t,n){this.element.removeEventListener(t,n)}handleInteraction(){let t=this.getText(),n=this.getHTML(),r=this.getSelection(),o=this.cachedCaretPosition===null;if(!this.isActive||(t===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),t!==this.cachedText?(this.cachedText=t,this.cachedHTML=n,o=!0,this.emit("change",{plainText:t,rawHTML:n})):n!==null&&n!==this.cachedHTML&&(this.cachedHTML=n,o=!0,this.emit("change",{plainText:t,rawHTML:n})),(r.start!==this.cachedSelection.start||r.end!==this.cachedSelection.end)&&(this.cachedSelection=r,o=!0,this.emit("selection",r)),!o))return;let i=this.getCaretPosition();Gr(i,this.cachedCaretPosition)||(this.cachedCaretPosition=i,this.emit("caretposition",i))}handleClick(){this.handleInteraction()}handleFocus(){let t=!this.isFocused;this.isFocused=!0,t&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let t=this.isFocused;this.isFocused=!1,t&&this.emit("blur")}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(rk).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 ok(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var Jo=class extends gr{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),Ml(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!ok(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!ok(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return Nl(this.element,n);let r=this.lastKnownSelection;if(r&&nk(this.element,r.start,r.end))return r;let o=Ts(this.element);return o.collapse(!1),Nl(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return Ml(this.element,ao(this.element,n,r))}listen(){super.listen();let n=new MutationObserver(i=>{var s,a;i.length===2&&i[0].addedNodes.length===1&&((s=i[0].addedNodes[0])==null?void 0:s.textContent)==="\u2060"&&((a=i[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let r=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==r&&(r=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}};var ei=class extends gr{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 ik(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 a_(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var Ly=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()}},Iy=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=ik(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()}},Oy=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(),B.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 Iy(t,this.deepdeskUrl,{debug:!0}):new Ly(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=a_(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(B.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;B.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(I(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)}},sk=Oy;var ks=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var Ny=e=>new Promise(t=>{setTimeout(t,e)});var Ps=class extends ks{constructor(){super(...arguments);this.name="ClientError"}},_y=class extends ks{constructor(){super(...arguments);this.name="ServerError"}},My=new Map;function l_(e){return P(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:(B.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var lo=class lo{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:m=!0,retryOnError:S=R=>R instanceof TypeError,retryOnResponse:y=R=>R.status>=500,version:p=null}=C,g=te(C,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(u)if(l){if(My.has(s)){r(My.get(s));return}}else throw new Error(`Can't use 'useCache' for ${n.method}`);let h=I(T({credentials:"include"},g),{headers:T({Accept:"application/json","Content-Type":"application/json"},g.headers)});!l&&this.csrfToken&&(h.headers=I(T({},h.headers),{"X-CSRFToken":this.csrfToken})),typeof p=="string"&&(h.headers=I(T({},h.headers),{"X-Deepdesk-API-Version":p}));let v=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 k=()=>P(this,null,function*(){return v--,a(s,h).then(R=>P(this,null,function*(){return y(R)&&!i.isAborted&&v>0?(yield Ny(d),k()):R.status===401&&m===!0&&x===!1?(x=!0,yield this.refreshToken(),k()):R})).catch(R=>P(this,null,function*(){if(S(R)&&!i.isAborted&&v>0)return yield Ny(d),k();throw R}))});k().then(R=>P(this,null,function*(){let N=yield l_(R);if(delete this.latestRequestByUrl[s],R.status>=500){o(new _y("Server Error",N));return}else if(R.status===401){o(new Ps("Unauthorized",N));return}else if(R.status===403){o(new Ps("Forbidden",N));return}else if(R.status===404){o(new Ps("Not Found",N));return}else if(R.status>=400){o(new Ps("Bad Request",N));return}u&&My.set(s,N),r(N)})).catch(R=>{o(R)})})}validateToken(){return P(this,null,function*(){let{has_valid_access_token:t}=yield this.get("/auth/validate");if(!t)try{yield this.refreshToken()}catch(r){return!1}let{is_logged_in:n}=yield this.get("/apis/admin/session/validate/");return!!n})}refreshToken(){return lo.refreshingToken||(lo.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{lo.refreshingToken=null},1e3*60)})),lo.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))}};lo.refreshingToken=null;var hr=lo;var ak;(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={}))})(ak||(ak={}));function Lf(e){return I(T({},ee(e)),{tags:e.tags})}var ti=class ti{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new hr(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,i)=>P(this,null,function*(){let s=yield r(o,i);return this.handleDeepdeskVersionHeaders(s),s}))}preflight(){return P(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(ti.exchangeTokenPromise||(ti.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),ti.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return P(this,null,function*(){yield this.preflight(),B.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=yield this.client.post("/api/conversations",I(T({},Ie(t)),{tags:t.tags}),{version:"v2"});return Lf(n)})}getMe(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/session/me/");return ee(t)})}patchMe(t){return P(this,null,function*(){let n=yield this.client.patch("/apis/admin/session/me/",Ie(t));return ee(n)})}getProfile(t){return P(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{useCache:!0});return ee(n)})}getKnowledgeAssistant(t){return P(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{useCache:!0});return ee(n)})}getContentTypes(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return ee(t)})}getAccount(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{useCache:!0});return ee(t)})}getPlatformConfig(t){return P(this,null,function*(){let n=t!==void 0?`/platform/config/${t}/`:"/platform/config/",{config:r}=yield this.client.get(n,{useCache:!0});return ee(r)})}checkUserExists(t){return P(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`,{version:"v1"});return n})}getConversationBySessionId(r){return P(this,arguments,function*(t,n={}){yield this.preflight(),B.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 B.info(`Successfully retrieved conversation ${s.id} for session ${t}`),Lf(s)})}isConversationSupported(r){return P(this,arguments,function*(t,n={}){B.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 P(this,null,function*(){let r=Ie(n);n.tags&&(r.tags=n.tags);let o=yield this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return Lf(o)})}postMessages(t,n){return P(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/messages`,n.map(o=>I(T({},Ie(o)),{tags:o.tags})),{version:"v2"})).map(o=>Lf(o))})}sendEvent(t,n){return P(this,null,function*(){let s=n,{data:r}=s,o=te(s,["data"]),i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((a,[l,u])=>I(T({},a),{[l]:u}),{});return this.client.post("/api/events",Ie(I(T(T({},i),o),{data:r,name:t})),{version:"v2"})})}sendEventV1(t,n){return P(this,null,function*(){let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>I(T({},o),{[i]:s}),{});return this.client.post("/api/events",{event:t,data:Ie(T(T({},n),r))},{version:"v1"})})}getEntities(t){return P(this,null,function*(){return(yield this.client.post("/api/entities",{messages:t.filter(r=>r.text)},{version:"v1"})).entities})}getSummary(r){return P(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},{version:"v1"});return ee(o)})}getTemporaryExchangeToken(){return P(this,null,function*(){return(yield this.client.get("/auth/exchange-token")).jwt})}exchangeTokenForAccessCookie(t){return P(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t}).catch(n=>{throw B.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return P(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Ie(n),{refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return P(this,arguments,function*(t,n={},r){return r==="sticky-messages"?this.getPinnedMessages(t):(yield this.client.post(`/api/conversations/${t}/recommend/${r}`,Ie(n),{abortLatest:!0,version:"v1"})).map(s=>I(T({},ee(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 P(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return P(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/autocomplete`,Ie(n),{abortLatest:!0,version:"v1"})).map(o=>({score:1,source:o.source,sourceText:o.source_text,text:o.label,trainingJobs:o.training_jobs,searchKeywords:o.search_keywords,type:o.source})).filter((o,i,s)=>i===s.findIndex(a=>a.text===o.text))})}getPinnedMessages(t){return P(this,null,function*(){let n=yield this.client.get(`/api/conversations/${t}/sticky-messages`,{abortLatest:!0,version:"v1"});return ee(n).map(r=>I(T({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return P(this,null,function*(){let n=yield this.client.post("/api/style-suggestions",Ie(t),{abortLatest:!0,version:"v1"});return ee(n)})}search(t){return P(this,null,function*(){let n=yield this.client.post(`/api/profiles/${t.profile}/search`,Ie(t),{version:"v2"});return ee(n)})}knowledgeAssist(i,s,a){return P(this,arguments,function*(t,n,r,o={}){let l=yield this.client.post(`/api/knowledge-assist/assistants/${r}/search`,Ie({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 ee(l)})}requestLoginByEmail(t){return P(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t});return ee(n)})}requestPasswordlessToken(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/");return ee(t.token)})}getCsrfToken(){return P(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/");return t})}verifyLoginToken(t){return P(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t});return ee(n)})}evaluateRule(i,s,a){return P(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?ee(u.cues):[]})}evaluateAssistant(t,n,r){return P(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});return ee(i.output)})}getRules(){return P(this,null,function*(){let t=new URLSearchParams,n=yield this.client.get(`/apis/admin/rule-engine/rules/?${t.toString()}`,{useCache:!0});return ee(n)})}translateMessages(t){return P(this,null,function*(){let n=yield this.client.post("/api/translate",Ie(t),{version:"v2"});return ee(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(t0);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&B.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};ti.exchangeTokenPromise=null;var yr=ti;var _l=class{constructor(t,n){this.url=t;this.eventListeners={};this.options=T({timeout:25e3},n)}proxyEvent(t){this.eventSource.addEventListener(rh(t),n=>{let{data:r}=n;try{let o=JSON.parse(r);this.emit(t,ee(o))}catch(o){B.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 lk;(t=>{let e;(i=>(i.Started="Started",i.Aborted="Aborted",i.Completed="Completed"))(e=t.AutoflowSessionState||(t.AutoflowSessionState={}))})(lk||(lk={}));var Dl=class{constructor(t,n={}){this.apiUrl=t;this.streams={};this.logger=B;this.client=new hr(t,n)}getCustomMessages(t){return P(this,null,function*(){let n=yield this.client.get(`/sessions/${t}/suggestions`);return ee(n.suggestions)})}sendCustomMessage(t,n){return P(this,null,function*(){let r=yield this.client.post(`/sessions/${t}/messages`,Ie(n));return ee(r)})}answerCustomMessage(t,n){return P(this,null,function*(){yield this.client.post(`/sessions/${t}/answers`,Ie(n))})}getAutoflows(t){return P(this,null,function*(){let n=yield this.client.get(`/sessions/${t}/autoflows`);return ee(n.autoflows)})}startAutoflowSession(t){return P(this,null,function*(){let n=yield this.client.post("/autoflow-sessions",Ie(t));return ee(n)})}stopAutoflowSession(t){return P(this,null,function*(){yield this.client.delete(`/autoflow-sessions/${t}`)})}openStream(t){return this.streams[t]||(this.streams[t]=new _l(`${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 uk={startTime:null,stopTime:null},ck=Y({name:"handlingTime",initialState:uk,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(ce,()=>uk)}}),{handlingTimeStart:dk,handlingTimeStop:If,handlingTimeReset:fk}=ck.actions,pk=ck.reducer;var mk=(e={})=>{let t=T({onAuthError:rs(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var Of={list:{keywordMatches:[]},fetchState:"idle"};var ni=K("styleSuggestions/getAll",(n,r)=>P(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 Of.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),u_=Y({name:"styleSuggestions",initialState:Of,reducers:{},extraReducers:e=>{e.addCase(ni.pending,t=>{t.fetchState="loading"}).addCase(ni.rejected,t=>{t.fetchState="error"}).addCase(ni.fulfilled,(t,n)=>{t.fetchState="done",Gr(t.list,n.payload)||(t.list=n.payload)}).addCase(Oo,t=>{t.list=Of.list}).addCase(ce,()=>Of)}}),gk=u_.reducer;var hk=(e={})=>{let t,n=!0,r=T({getStyleSuggestions:ni,debounce:500},e);return o=>i=>s=>{var m;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(!((m=u.conversation.current)==null?void 0:m.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 c_(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var yk=(e={})=>{let t=T({getTextSuggestions:gn,getAutocompleteSuggestions:ml,debounce:200,check:Ln},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===$d.toString();if(!f||!u&&!c)return a;let{input:m}=l;return c_(m,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let p=ss(l);p===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(p))},d?0:t.debounce)),a}};var vk=ni.fulfilled.toString();function d_(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 Sk=e=>t=>n=>r=>{var u;if(r.type!==vk){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=d_(o,s);r.type===vk&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var f_=kc({assistants:tT,answer:vb,auth:x1,autoflows:UC,conversation:I1,contentTypes:RE,customMessages:GC,passwordlessToken:XC,entities:JE,knowledgeAssistant:gb,handlingTime:pk,info:Q1,input:V1,settings:m1,profile:Eb,search:rE,summary:sb,styleSuggestions:gk,ui:Xb,rules:sT,textSuggestions:Lb});function wk(e){return wx({reducer:f_,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI,deepdeskBrokerAPI:e.deepdeskBrokerAPI}},serializableCheck:!1}),mk(),yk({debounce:200}),hk({debounce:500}),Sk(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var p_=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},m_=e=>t=>n=>r=>{var a,l,u,c,f,d;let o=t.getState(),i=Xg("inlineSuggestions")(o);switch(r.type){case rs.toString():{!r.payload&&e.emit("logout",void 0);break}case pn.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 lt.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 Qo.fulfilled.toString():r.isBroadcasted||e.broadcast(sh,r,!1),(c=r.payload.options)!=null&&c.shouldEmit&&e.emit("cues",r.payload.cues);break;case Yo.fulfilled.toString():r.isBroadcasted||e.broadcast(ah,r,!1);break;default:break}let s=n(r);switch(r.type){case Oo.toString():e.handleAfterSendMessage(r.payload);break;case hl.toString():e.onUpdateShowTabHint(r.payload);break;case If.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case ad.toString():{let{start:m,end:S}=o.input.selection;e.emit("replace",I(T({},r.payload),{replace:r.payload.replace==="selection"?{start:m,end:S}:{start:0,end:S}}));break}case an.toString():{let{start:m,end:S}=o.input.selection;e.emit("select-suggestion",I(T({type:p_(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:m,end:S}:{start:0,end:S}})),i&&t.dispatch(Qr([]));break}case ld.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 Qr.toString():{i&&r.payload.length>0&&t.dispatch(ud(0));break}case rr.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},xk=m_;function Dy(e){return e.toISOString().replace("T"," ").replace("Z","")}function Ek(e,t){var i,s,a,l;let n=(i=e.conversation.current)==null?void 0:i.id;if(!n)return B.warn("No conversationId for handling time metrics"),null;let{startTime:r,stopTime:o}=e.handlingTime;return!r||!o?(B.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:Dy(r),timeStop:Dy(o)}}function bk(e,t,n){var N,_,D,G;let r=(N=t.conversation.current)==null?void 0:N.id;if(!r)return B.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:m,deletions:S,textSuggestions:y,offeredTextSuggestions:p}}=t[e],g=o.length,v=y.reduce((Z,{text:ie,searchTerm:vr})=>Z+ie.length-(vr?vr.length:0),0),x=c!=null?c:Date.now(),k=(Date.now()-x)/1e3+(f||0),C=i/k,R=y.reduce((Z,{searchTerm:ie})=>Z+(ie?ie.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:d,cuts:m,deletions:S,lenTextTyped:i+R,lenTextTotal:g,lenTextAssisted:v,lenTextPasted:s,lenTextCut:a,lenTextDeleted:l,timeTotalSeconds:k,charsPerSecond:C,numPastes:u,textSuggestionsV2:y,suggestionsCounters:[{source:"gpt",countOffered:p.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 Fy(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return Fy(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?Fy(o,t):null}function Ck(e,t){return Fy(e,t)}function Tk(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function g_(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Nf(e){return g_(e)&&(oo(e)||rf(e))}var Pk,Mn=new Map,h_=["bottom","height","left","right","top","width"],kk=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:h_.some(n=>e[n]!==t[n]);function Rk(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,...Rk(t)]:[]}function Ak(e,t){return!e||!t?null:I(T({},e),{top:e.top+t.top,left:e.left+t.left})}var Mf=!1,Lk=()=>{Mf=!0;let e=[];if(Mn.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Mn.delete(n);return}let r=n.getBoundingClientRect();kk(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(Ak,t.rect):t.rect;kk(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Mn.size===0){Mf=!1;return}Pk=window.requestAnimationFrame(Lk)};function Hy(e,t){let n=Rk(e),r=[],o=n.map((i,s)=>Hy(i,a=>{r[s]=a;let l=Mn.get(e);if(!l)return;let u=r.reduce(Ak,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),Mn.has(e)){let s=Mn.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else Mn.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Mf&&Lk()},unobserve(){o.forEach(s=>s.unobserve());let i=Mn.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||Mn.delete(e),Mn.size||(cancelAnimationFrame(Pk),Mf=!1)}}}}var Ik,_n=new Map,Ok=()=>{_n.forEach((e,t)=>{if(!t.isConnected){_n.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)))}),_n.size!==0&&(Ik=window.requestAnimationFrame(Ok))};function Nk(e,t){return{observe(){let n=_n.size===0;_n.has(e)?_n.get(e).callbacks.push(t):_n.set(e,{visible:void 0,callbacks:[t]}),n&&Ok()},unobserve(){let n=_n.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||_n.delete(e),_n.size||cancelAnimationFrame(Ik)}}}}var Uy=["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 zy(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function Rs(e){return parseFloat(e)}function _f(e){return Math.round(e*1e6)}function Mk(e){return e/1e6}function By(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=Rs(e.width),i=Rs(e.borderLeftWidth),s=Rs(e.borderRightWidth),a=Rs(e.paddingRight),l=Mk(_f(o)-_f(i)-_f(s)),u=Mk(_f(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function Fl(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};zy(r,n,Uy),By(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=Nk(e,()=>{zy(r,n,Uy),By(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=Hy(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(zy(r,n,Uy),By(r,e,n),i(),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let m=t.closestScrollElement.getBoundingClientRect(),S=window.getComputedStyle(t.closestScrollElement),y=Rs(S.borderTopWidth),p=Rs(S.borderBottomWidth),g=m.top+y-d.top,h=d.top+d.height+-(m.top+m.height-p);n.style.clipPath=`inset(${g}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 _k=(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){B.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function y_(e){return e.offsetParent!==null}function Dk(e){if(!y_(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 Df(e,t,n=100){let r=Dk(e);t({isVisible:r});let o=setInterval(()=>{let i=Dk(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var Fe=w(b());var Fk=_k("showTabHint",!0),As=class As{constructor({deepdeskUrl:t,brokerUrl:n,version:r=As.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 yr(u,{token:i,fetch:s}),this.version=r,this.instanceId=As.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[xk({broadcast:(f,d,m)=>{this.broadcastEvents.send(f,d,m)},emit:(f,d)=>this.emit(f,d),handleAfterSendMessage:f=>this.handleAfterSendMessage(f),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:f=>this.logSendMessage(f),onUpdateShowTabHint:f=>Fk.update(f),sendEvent:(f,d)=>this.deepdeskApi.sendEvent(f,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new Dl(n)}),this.store=wk(c),this.broadcastEvents=new sk({debug:!0,deepdeskUrl:u,eventMap:oE(this.store),createCustomChannel:l}),this.store.dispatch(hl(Fk.value())),this.store.dispatch(td({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?(B.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(B.warn("Profile has not been loaded (yet)"),!0):(B.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(rs(null)),this.store.dispatch(Qn()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();at(r)&&g1(r)!=="loading"&&(n(),t())});this.unmountHandlers.push(()=>{n()})})}isLoggedIn(){return P(this,null,function*(){return(yield this.store.dispatch(Qn())).payload})}isConversationSupported(t,n){return P(this,null,function*(){return(yield this.store.dispatch(eh({sessionId:t,options:n}))).payload})}createConversation(t){return P(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(rd(t))).payload})}getConversationBySessionId(t,n){return P(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(yield this.store.dispatch(od({sessionId:t,options:n}))).payload})}upsertConversation(t){return P(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(th(t))).payload})}postMessages(t){return P(this,null,function*(){return(yield this.store.dispatch(sd(t))).payload})}updateConversation(t){return P(this,null,function*(){return(yield this.store.dispatch(id(t))).payload})}resetConversation(){this.store.dispatch(ce()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}getSummary(){return P(this,null,function*(){let t=yield this.store.dispatch(rr());if(t.error)throw new Error(t.error.message);return t.payload.summary})}configure(t){this.store.dispatch(td(t))}setVisitorInfo(t){this.store.dispatch(q1(t))}setCustomData(t){this.store.dispatch(G1(t))}setAgentInfo(t){return P(this,null,function*(){yield this.store.dispatch(Wa(t))})}setAgentSettings(t){return P(this,null,function*(){yield this.store.dispatch(oh(t))})}getAgentSettings(){return P(this,null,function*(){return(yield this.store.dispatch(ih())).payload})}refresh(){return P(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(cd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let t=[];return this.store.dispatch($d()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}notifyExternalSuggestion(t){this.store.dispatch(an(t))}evaluateRule(o){return P(this,arguments,function*(t,n={},r=nT){return(yield this.store.dispatch(Qo({label:t,params:n,options:r}))).payload.cues})}evaluateAssistant(r){return P(this,arguments,function*(t,n={}){yield this.store.dispatch(Yo({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(!Ln(this.state)||(this.store.dispatch(D1(nh(t))),t.key!=="Tab"&&!l))return;let f=()=>{n||!c||s&&(t.shiftKey||(this.store.dispatch(U1()),t.preventDefault()))},d=()=>{n||!c||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(z1()),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(ud(-1)),this.store.dispatch(no({collapse:!0})),this.store.dispatch(Yb(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let m=as(this.state);if(!m)return;this.store.dispatch(hl(!1)),this.store.dispatch(an({text:m.text,suggestion:m,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.state.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let m=as(this.state);if(!m)return;this.store.dispatch(an({text:m.text,suggestion:m,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.state.settings.inlineSuggestions||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let m=as(this.state);if(!m)return;this.store.dispatch(an({text:m.text,suggestion:m,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(no({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(Qr([]))}handlingTimeStart(){this.state.handlingTime.startTime||(B.info("Start handling time"),this.store.dispatch(dk()))}handlingTimeStop(){this.state.handlingTime.startTime&&(B.info("Stop handling time"),this.store.dispatch(If()))}logSendMessage(t){let n=bk("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=Ek(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(fk()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(Oo((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(j1()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(i){B.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),B.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(Y1(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]=Fl(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,tn.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var a;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let i=(a=t.ownerDocument.defaultView)==null?void 0:a.frameElement,s=i?i.ownerDocument.defaultView:null;if(i&&(s===window||(s==null?void 0:s.parent)===window)){let[l,u]=Fl(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{(0,tn.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,tn.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),B.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()?(B.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(B1(r.metrics))):B.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(!Nf(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:m,inputMediator:S,closestScrollSelector:y,appendOverlayTo:p,inlineSuggestions:g,floatingMenu:h}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:m,isEmbedded:f,inlineSuggestions:g,floatingMenu:!!h}),n.automaticHandlingTime&&this.setupHandlingTime(t),$o(t),this.inputMediator=S||(oo(t)?new ei(t):new Jo(t)),this.inputMediator.on("change",({plainText:k,rawHTML:C})=>{this.store.dispatch(cd({text:k,html:C}))}),this.inputMediator.on("keyup",k=>{this.store.dispatch(F1(nh(k)))}),this.inputMediator.on("keydown",k=>{this.handleKeyDown(k)}),this.inputMediator.on("paste",({pastedText:k,selectionText:C})=>{this.store.dispatch(H1({text:k,selectionText:C}))}),this.inputMediator.on("cut",({selectionText:k})=>{this.store.dispatch(_1(k))});let v;this.inputMediator.on("selection",k=>{clearTimeout(v),k===null?v=setTimeout(()=>{k!==null&&this.store.dispatch(dd(k))},500):this.store.dispatch(dd(k))}),this.inputMediator.on("disabled",()=>{var k;(k=this.inputMediator)==null||k.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&&Ck(t,y)||void 0;if(g){let{customStyles:k,appendOverlayTo:C}=n;if(oo(t))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let R=this.createInlineContainer(t,"deepdesk-caret");(0,tn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:k,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(rC,{})})}),R),this.inputMediator.on("caretposition",_=>{_?(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},k==null?void 0:k.floatingMenuRootNode);(0,tn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:k,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)($b,{onLogIn:()=>this.loginViaPopup().catch(_=>B.warn(_.message))})})}),N)}else{let k=this.overlayContainerFactory("deepdesk-tab-completion",x||t,{appendTo:p,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||t,{appendTo:p},r==null?void 0:r.suggestionsRootNode);(0,tn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:r,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(NC,{inputElement:t})})}),k),(0,tn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:r,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(fC,{onLogIn:()=>this.loginViaPopup().catch(R=>B.warn(R.message))})})}),C)}(0,tn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:r,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(Bb,{})})}),this.createContainer("deepdesk-overlays")),this.store.dispatch(cd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(dd(this.inputMediator.getSelection())),this.store.dispatch(Xd(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{var k;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((k=this.state.conversation.current)==null?void 0:k.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&&B.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,tn.render)((0,Fe.jsx)(Go,{store:this.store,customStyles:r,children:(0,Fe.jsx)(Mo,{broadcastEvents:this.broadcastEvents,children:(0,Fe.jsx)(tk,{onLogIn:()=>this.loginViaPopup().catch(s=>B.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,tn.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Df(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){Tk(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>P(this,null,function*(){yield this.store.dispatch(pl());let t=sr(this.state);t&&(yield this.store.dispatch(cl()),this.store.dispatch(td({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 P(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=m=>P(this,null,function*(){var S,y;if((S=m.data)!=null&&S.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((y=m.data)==null?void 0:y.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(qa),l=!0,o.port1.close(),n()}catch(p){console.error(p),r(p)}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=m=>P(this,null,function*(){var S;if(m.origin===a.origin)switch((S=m.data)==null?void 0:S.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){B.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-error":{u(),m.data.message==="Timeout"&&B.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(m.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 P(this,null,function*(){try{let{account:n}=yield this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(B.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;B.info(r),this.shouldRender=!1}})}refreshWidgetSuggestions(){return P(this,null,function*(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=Kd(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(pn()):su.includes(r)||this.store.dispatch(gn(r))})}catch(r){this.handleError(r)}})}};As.version="14.1.1-beta.0",As.count=0;var Hl=As;function v_(e){return P(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 Hk(e,t){return P(this,null,function*(){let n=yield v_(t),r=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(e,"files",{configurable:!0,get:()=>[n]}),e.dispatchEvent(r)}finally{Object.hasOwn(e,"files")&&delete e.files}})}function Uk(e,t,n){return P(this,null,function*(){yield new yr(e).authenticateWithKey(t,n)})}function zk(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function Bk(r,o){return P(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 jk(r,o){return P(this,arguments,function*(e,t,n={}){let i=n.replace?ao(e,n.replace.start,n.replace.end):Ts(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?ao(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 S_(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 w_(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 Vk(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):Vk(n,t)}function Kk(o,i){return P(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?S_(t):w_(t);n?Vk(c.startContainer,f):(c.insertNode(f),c.collapse(!1))};return Promise.resolve(a()).then(()=>{if(e.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0})),e.focus(),!!s)try{s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})})}return iP(x_);})();
|
|
30
30
|
/*! Bundled license information:
|