@deepdesk/deepdesk-sdk 15.1.1-beta.5 → 15.1.1-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +3 -3
- package/dist/index.d.mts +76 -58
- package/dist/index.d.ts +76 -58
- package/dist/index.esm.js +3 -3
- package/dist/index.iife.js +3 -3
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -74,13 +74,13 @@ ${t}</tr>
|
|
|
74
74
|
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Sr(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:n,tokens:r}){let o=this.parser.parseInline(r),i=Sk(t);if(i===null)return o;t=i;let s='<a href="'+t+'"';return n&&(s+=' title="'+Sr(n)+'"'),s+=">"+o+"</a>",s}image({href:t,title:n,text:r}){let o=Sk(t);if(o===null)return Sr(r);t=o;let i=`<img src="${t}" alt="${r}"`;return n&&(i+=` title="${Sr(n)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Sr(t.text)}},ju=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}},Yn=class e{constructor(t){Ae(this,"options");Ae(this,"renderer");Ae(this,"textRenderer");this.options=t||_i,this.options.renderer=this.options.renderer||new ma,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ju}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(t,n=!0){var o,i;let r="";for(let s=0;s<t.length;s++){let a=t[s];if((i=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&i[a.type]){let l=a,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(l.type)){r+=c||"";continue}}let u=a;switch(u.type){case"space":{r+=this.renderer.space(u);continue}case"hr":{r+=this.renderer.hr(u);continue}case"heading":{r+=this.renderer.heading(u);continue}case"code":{r+=this.renderer.code(u);continue}case"table":{r+=this.renderer.table(u);continue}case"blockquote":{r+=this.renderer.blockquote(u);continue}case"list":{r+=this.renderer.list(u);continue}case"html":{r+=this.renderer.html(u);continue}case"paragraph":{r+=this.renderer.paragraph(u);continue}case"text":{let l=u,c=this.renderer.text(l);for(;s+1<t.length&&t[s+1].type==="text";)l=t[++s],c+=`
|
|
75
75
|
`+this.renderer.text(l);n?r+=this.renderer.paragraph({type:"paragraph",raw:c,text:c,tokens:[{type:"text",raw:c,text:c,escaped:!0}]}):r+=c;continue}default:{let l='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}parseInline(t,n=this.renderer){var o,i;let r="";for(let s=0;s<t.length;s++){let a=t[s];if((i=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&i[a.type]){let l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=l||"";continue}}let u=a;switch(u.type){case"escape":{r+=n.text(u);break}case"html":{r+=n.html(u);break}case"link":{r+=n.link(u);break}case"image":{r+=n.image(u);break}case"strong":{r+=n.strong(u);break}case"em":{r+=n.em(u);break}case"codespan":{r+=n.codespan(u);break}case"br":{r+=n.br(u);break}case"del":{r+=n.del(u);break}case"text":{r+=n.text(u);break}default:{let l='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}},Mi=class{constructor(t){Ae(this,"options");Ae(this,"block");this.options=t||_i}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?Gn.lex:Gn.lexInline}provideParser(){return this.block?Yn.parse:Yn.parseInline}};Ae(Mi,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));var Yv=class{constructor(...t){Ae(this,"defaults",Xv());Ae(this,"options",this.setOptions);Ae(this,"parse",this.parseMarkdown(!0));Ae(this,"parseInline",this.parseMarkdown(!1));Ae(this,"Parser",Yn);Ae(this,"Renderer",ma);Ae(this,"TextRenderer",ju);Ae(this,"Lexer",Gn);Ae(this,"Tokenizer",pa);Ae(this,"Hooks",Mi);this.use(...t)}walkTokens(t,n){var o,i;let r=[];for(let s of t)switch(r=r.concat(n.call(this,s)),s.type){case"table":{let a=s;for(let u of a.header)r=r.concat(this.walkTokens(u.tokens,n));for(let u of a.rows)for(let l of u)r=r.concat(this.walkTokens(l.tokens,n));break}case"list":{let a=s;r=r.concat(this.walkTokens(a.items,n));break}default:{let a=s;(i=(o=this.defaults.extensions)==null?void 0:o.childTokens)!=null&&i[a.type]?this.defaults.extensions.childTokens[a.type].forEach(u=>{let l=a[u].flat(1/0);r=r.concat(this.walkTokens(l,n))}):a.tokens&&(r=r.concat(this.walkTokens(a.tokens,n)))}}return r}use(...t){let n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{let o=b({},r);if(o.async=this.defaults.async||o.async||!1,r.extensions&&(r.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=n.renderers[i.name];s?n.renderers[i.name]=function(...a){let u=i.renderer.apply(this,a);return u===!1&&(u=s.apply(this,a)),u}:n.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=n[i.level];s?s.unshift(i.tokenizer):n[i.level]=[i.tokenizer],i.start&&(i.level==="block"?n.startBlock?n.startBlock.push(i.start):n.startBlock=[i.start]:i.level==="inline"&&(n.startInline?n.startInline.push(i.start):n.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(n.childTokens[i.name]=i.childTokens)}),o.extensions=n),r.renderer){let i=this.defaults.renderer||new ma(this.defaults);for(let s in r.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let a=s,u=r.renderer[a],l=i[a];i[a]=(...c)=>{let f=u.apply(i,c);return f===!1&&(f=l.apply(i,c)),f||""}}o.renderer=i}if(r.tokenizer){let i=this.defaults.tokenizer||new pa(this.defaults);for(let s in r.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let a=s,u=r.tokenizer[a],l=i[a];i[a]=(...c)=>{let f=u.apply(i,c);return f===!1&&(f=l.apply(i,c)),f}}o.tokenizer=i}if(r.hooks){let i=this.defaults.hooks||new Mi;for(let s in r.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let a=s,u=r.hooks[a],l=i[a];Mi.passThroughHooks.has(s)?i[a]=c=>{if(this.defaults.async)return Promise.resolve(u.call(i,c)).then(d=>l.call(i,d));let f=u.call(i,c);return l.call(i,f)}:i[a]=(...c)=>{let f=u.apply(i,c);return f===!1&&(f=l.apply(i,c)),f}}o.hooks=i}if(r.walkTokens){let i=this.defaults.walkTokens,s=r.walkTokens;o.walkTokens=function(a){let u=[];return u.push(s.call(this,a)),i&&(u=u.concat(i.call(this,a))),u}}this.defaults=b(b({},this.defaults),o)}),this}setOptions(t){return this.defaults=b(b({},this.defaults),t),this}lexer(t,n){return Gn.lex(t,n!=null?n:this.defaults)}parser(t,n){return Yn.parse(t,n!=null?n:this.defaults)}parseMarkdown(t){return(r,o)=>{let i=b({},o),s=b(b({},this.defaults),i),a=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&i.async===!1)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof r=="undefined"||r===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));s.hooks&&(s.hooks.options=s,s.hooks.block=t);let u=s.hooks?s.hooks.provideLexer():t?Gn.lex:Gn.lexInline,l=s.hooks?s.hooks.provideParser():t?Yn.parse:Yn.parseInline;if(s.async)return Promise.resolve(s.hooks?s.hooks.preprocess(r):r).then(c=>u(c,s)).then(c=>s.hooks?s.hooks.processAllTokens(c):c).then(c=>s.walkTokens?Promise.all(this.walkTokens(c,s.walkTokens)).then(()=>c):c).then(c=>l(c,s)).then(c=>s.hooks?s.hooks.postprocess(c):c).catch(a);try{s.hooks&&(r=s.hooks.preprocess(r));let c=u(r,s);s.hooks&&(c=s.hooks.processAllTokens(c)),s.walkTokens&&this.walkTokens(c,s.walkTokens);let f=l(c,s);return s.hooks&&(f=s.hooks.postprocess(f)),f}catch(c){return a(c)}}}onError(t,n){return r=>{if(r.message+=`
|
|
76
76
|
Please report this to https://github.com/markedjs/marked.`,t){let o="<p>An error occurred:</p><pre>"+Sr(r.message+"",!0)+"</pre>";return n?Promise.resolve(o):o}if(n)return Promise.reject(r);throw r}}},Ni=new Yv;function we(e,t){return Ni.parse(e,t)}we.options=we.setOptions=function(e){return Ni.setOptions(e),we.defaults=Ni.defaults,Ek(we.defaults),we};we.getDefaults=Xv;we.defaults=_i;we.use=function(...e){return Ni.use(...e),we.defaults=Ni.defaults,Ek(we.defaults),we};we.walkTokens=function(e,t){return Ni.walkTokens(e,t)};we.parseInline=Ni.parseInline;we.Parser=Yn;we.parser=Yn.parse;we.Renderer=ma;we.TextRenderer=ju;we.Lexer=Gn;we.lexer=Gn.lex;we.Tokenizer=pa;we.Hooks=Mi;we.parse=we;var hV=we.options,yV=we.setOptions,vV=we.use,xV=we.walkTokens,SV=we.parseInline;var wV=Yn.parse,bV=Gn.lex;var Xn=w(k());function VD(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 r0(e){var n,r;let t=e.cloneNode(!0);return t.querySelectorAll("div,button").forEach(o=>o.remove()),(r=(n=t.textContent)==null?void 0:n.trim())!=null?r:""}function WD(e){return e.replace(/\r\n/g,`
|
|
77
|
-
`)}var $D=({content:e,useLabel:t,copyLabel:n,onCopy:r,onUse:o})=>{let i=_("Markdown",yk),s=(0,Qr.useRef)(null),[a,u]=(0,Qr.useState)(null),l=(0,Qr.useMemo)(()=>{let h=we.parse(WD(e));return ck.sanitize(h.toString()).replaceAll("</code>",`${VD(i.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[e]),c=h=>{var v;let g=h.target,m=!!((v=s.current)!=null&&v.querySelector("code"));if(["A","BUTTON"].includes(g.tagName)){u(null);return}a||m&&g.tagName!=="CODE"||!m&&g!==s.current||(g.addEventListener("mouseleave",()=>u(null),{once:!0}),u(g))},f=()=>{if(!a)return;u(null);let h=a.querySelector("button");h&&(ua(h,i.fadeup),r==null||r(r0(a)))},d=h=>{let g=h.target;if(g.tagName==="A"){h.stopPropagation();return}"copyIcon"in g.dataset&&(ua(g,i.fadeup),r==null||r(r0(g.parentElement)))},p=()=>{!a||!o||(u(null),o(r0(a)))},y=h=>{if(h===null)return;let g=h.getBoundingClientRect();g.left<0?h.style.transform=`translateX(${-g.left+2}px)`:g.right>window.innerWidth&&(h.style.transform=`translateX(${window.innerWidth-g.right-2}px)`)};return(0,Xn.jsxs)(Qr.Fragment,{children:[a&&(r||o)&&(0,Xn.jsxs)(fa,{triggerRef:{current:a},className:i.popover,parentNode:a,children:[(0,Xn.jsxs)("div",{className:i.options,ref:y,children:[r&&(0,Xn.jsx)("button",{type:"button",className:i.option,onClick:f,children:n}),o&&(0,Xn.jsxs)(Qr.Fragment,{children:[(0,Xn.jsx)("div",{className:i.divider}),(0,Xn.jsx)("button",{type:"button",className:i.option,onClick:p,children:t})]})]}),(0,Xn.jsx)("div",{className:i.arrow})]}),(0,Xn.jsx)("div",{ref:s,"data-testid":"widget-markdown-content",className:i.root,dangerouslySetInnerHTML:{__html:l},onMouseOver:c,onClick:d})]})},ga=$D;var kt=w(k()),KD=({threadId:e,onNewThreadId:t,onUse:n,onResetQuestion:r,question:o})=>{var g;let[i,s]=Di.default.useState(""),{setSelected:a}=zo(),u=(0,Di.useRef)(null),l=_("KnowledgeSearchStyles",YC),c=re(Fv),f=ce(),d=(g=V(vu(e!=null?e:-1)))!=null?g:[],p=Gr(m=>xu({input:m,threadId:e,onNewThreadId:v=>t(v)}),{onSuccess(m){f(kn({name:"knowledge assist question answered",data:{question:i||o,sources:m.answer.sources,answer:m.answer.answer,isFollowUpQuestion:d.length>=1},options:{includeConversationData:!0}})),a(`knowledge-assist-${d.length}`),s("")}}),y=m=>P(void 0,null,function*(){m.preventDefault(),m.stopPropagation(),i!==""&&p.call(i)}),h=(m,v)=>{f(kn({name:"knowledge assist source viewed",data:{question:v,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return(0,Di.useEffect)(()=>{var m;o&&p.state==="idle"?p.call(o):(m=u.current)==null||m.focus()},[u,p.state]),(0,Di.useEffect)(()=>{u.current&&u.current.scrollIntoView({behavior:"smooth"})},[u,d]),(0,kt.jsxs)("div",{className:l.root,children:[d.length>0&&(0,kt.jsx)("div",{className:l.alignRight,children:(0,kt.jsx)(We.Button,{onClick:r,children:c("reset")})}),d.map(({question:m,answer:v},x)=>(0,kt.jsx)(We.List,{children:(0,kt.jsx)(We.ListItem,{id:`knowledge-assist-${x}`,"data-testid":"knowledge-search-answer",description:(0,kt.jsx)(ga,{content:v.answer}),closeOnSelect:!0,onClick:()=>n(v.answer),onSourceClick:S=>h(S,m),sources:v.sources,styles:{title:l.question,description:l.answer},extra:(0,kt.jsx)("div",{className:l.listItemFeedback,children:(0,kt.jsx)(Ii,{feedbackText:v.answer,feedbackType:"knowledge-assist-answer",eventName:"knowledge assist feedback",eventData:b({question:m,isAgent:o!==m,isFollowUpQuestion:d.length>1},v)})}),children:m})},`${v.answer}_${x}`)),p.state==="loading"&&(0,kt.jsx)("p",{className:l.status,children:c("loading")}),p.state==="error"&&(0,kt.jsx)("p",{className:l.status,children:c("error")}),(0,kt.jsxs)("form",{className:l.form,onSubmit:y,children:[(0,kt.jsx)("input",{ref:u,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:i,onFocus:()=>{a(void 0)},onChange:m=>{a(void 0),s(m.target.value)}}),(0,kt.jsx)("button",{type:"submit",className:l.submit,disabled:p.state==="loading",children:(0,kt.jsx)(GC,{})})]})]})},Nk=KD;var o0=w(k()),Cp=e=>(0,o0.jsx)("svg",A(b({xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512"},e),{children:(0,o0.jsx)("path",{fill:"currentColor",d:"M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"})}));var Wu={};Lt(Wu,{enUS:()=>qD,nlNL:()=>GD});var qD={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],giveFeedback:[{type:0,value:"Give feedback"}],answer:[{type:0,value:"Answer"}]},GD={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],giveFeedback:[{type:0,value:"Geef feedback"}],answer:[{type:0,value:"Antwoord"}]};var br=w(W());var N=w(W(),1),ka=w(W(),1);function Rp(){return typeof window!="undefined"}function wr(e){return _k(e)?(e.nodeName||"").toLowerCase():"#document"}function zt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Zn(e){var t;return(t=(_k(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function _k(e){return Rp()?e instanceof Node||e instanceof zt(e).Node:!1}function Me(e){return Rp()?e instanceof Element||e instanceof zt(e).Element:!1}function Xe(e){return Rp()?e instanceof HTMLElement||e instanceof zt(e).HTMLElement:!1}function kp(e){return!Rp()||typeof ShadowRoot=="undefined"?!1:e instanceof ShadowRoot||e instanceof zt(e).ShadowRoot}function ha(e){let{overflow:t,overflowX:n,overflowY:r,display:o}=tn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function Dk(e){return["table","td","th"].includes(wr(e))}function $u(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch(n){return!1}})}function Pp(e){let t=ya(),n=Me(e)?tn(e):e;return["transform","translate","scale","rotate","perspective"].some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function Fk(e){let t=Qn(e);for(;Xe(t)&&!Jn(t);){if(Pp(t))return t;if($u(t))return null;t=Qn(t)}return null}function ya(){return typeof CSS=="undefined"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Jn(e){return["html","body","#document"].includes(wr(e))}function tn(e){return zt(e).getComputedStyle(e)}function Ku(e){return Me(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Qn(e){if(wr(e)==="html")return e;let t=e.assignedSlot||e.parentNode||kp(e)&&e.host||Zn(e);return kp(t)?t.host:t}function Hk(e){let t=Qn(e);return Jn(t)?e.ownerDocument?e.ownerDocument.body:e.body:Xe(t)&&ha(t)?t:Hk(t)}function pn(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);let o=Hk(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=zt(o);if(i){let a=Ap(s);return t.concat(s,s.visualViewport||[],ha(o)?o:[],a&&n?pn(a):[])}return t.concat(o,pn(o,[],n))}function Ap(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function jo(e){let t=e.activeElement;for(;((n=t)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;t=t.shadowRoot.activeElement}return t}function Bt(e,t){if(!e||!t)return!1;let n=t.getRootNode==null?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&kp(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function zk(){let e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform}function s0(){let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:r}=t;return n+"/"+r}).join(" "):navigator.userAgent}function Bk(e){return e.mozInputSource===0&&e.isTrusted?!0:i0()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Uk(e){return YD()?!1:!i0()&&e.width===0&&e.height===0||i0()&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function jk(){return/apple/i.test(navigator.vendor)}function i0(){let e=/android/i;return e.test(zk())||e.test(s0())}function YD(){return s0().includes("jsdom/")}function va(e,t){let n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function Vk(e){return"nativeEvent"in e}function Wk(e){return e.matches("html,body")}function Rt(e){return(e==null?void 0:e.ownerDocument)||document}function Ip(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function Vo(e){return"composedPath"in e?e.composedPath()[0]:e.target}var XD="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function a0(e){return Xe(e)&&e.matches(XD)}function Lp(e){e.preventDefault(),e.stopPropagation()}function $k(e){return e?e.getAttribute("role")==="combobox"&&a0(e):!1}var xa=Math.min,Zr=Math.max,Gu=Math.round,Yu=Math.floor,er=e=>({x:e,y:e}),QD={left:"right",right:"left",bottom:"top",top:"bottom"},ZD={start:"end",end:"start"};function l0(e,t,n){return Zr(e,xa(t,n))}function Xu(e,t){return typeof e=="function"?e(t):e}function Wo(e){return e.split("-")[0]}function Qu(e){return e.split("-")[1]}function u0(e){return e==="x"?"y":"x"}function c0(e){return e==="y"?"height":"width"}function Fi(e){return["top","bottom"].includes(Wo(e))?"y":"x"}function d0(e){return u0(Fi(e))}function Kk(e,t,n){n===void 0&&(n=!1);let r=Qu(e),o=d0(e),i=c0(o),s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=qu(s)),[s,qu(s)]}function qk(e){let t=qu(e);return[Op(e),t,Op(t)]}function Op(e){return e.replace(/start|end/g,t=>ZD[t])}function JD(e,t,n){let r=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?i:s;default:return[]}}function Gk(e,t,n,r){let o=Qu(e),i=JD(Wo(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(Op)))),i}function qu(e){return e.replace(/left|right|bottom|top/g,t=>QD[t])}function e3(e){return b({top:0,right:0,bottom:0,left:0},e)}function Yk(e){return typeof e!="number"?e3(e):{top:e,right:e,bottom:e,left:e}}function Hi(e){let{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}var rn=w(k(),1);var t3=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],Mp=t3.join(","),Qk=typeof Element=="undefined",Sa=Qk?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Np=!Qk&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e==null?void 0:e.ownerDocument},_p=function e(t,n){var r;n===void 0&&(n=!0);var o=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"inert"),i=o===""||o==="true",s=i||n&&t&&e(t.parentNode);return s},n3=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},r3=function(t,n,r){if(_p(t))return[];var o=Array.prototype.slice.apply(t.querySelectorAll(Mp));return n&&Sa.call(t,Mp)&&o.unshift(t),o=o.filter(r),o},o3=function e(t,n,r){for(var o=[],i=Array.from(t);i.length;){var s=i.shift();if(!_p(s,!1))if(s.tagName==="SLOT"){var a=s.assignedElements(),u=a.length?a:s.children,l=e(u,!0,r);r.flatten?o.push.apply(o,l):o.push({scopeParent:s,candidates:l})}else{var c=Sa.call(s,Mp);c&&r.filter(s)&&(n||!t.includes(s))&&o.push(s);var f=s.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(s),d=!_p(f,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(s));if(f&&d){var p=e(f===!0?s.children:f.children,!0,r);r.flatten?o.push.apply(o,p):o.push({scopeParent:s,candidates:p})}else i.unshift.apply(i,s.children)}}return o},Zk=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Jk=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||n3(t))&&!Zk(t)?0:t.tabIndex},i3=function(t,n){var r=Jk(t);return r<0&&n&&!Zk(t)?0:r},s3=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},eR=function(t){return t.tagName==="INPUT"},a3=function(t){return eR(t)&&t.type==="hidden"},l3=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},u3=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},c3=function(t){if(!t.name)return!0;var n=t.form||Np(t),r=function(a){return n.querySelectorAll('input[type="radio"][name="'+a+'"]')},o;if(typeof window!="undefined"&&typeof window.CSS!="undefined"&&typeof window.CSS.escape=="function")o=r(window.CSS.escape(t.name));else try{o=r(t.name)}catch(s){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",s.message),!1}var i=u3(o,t.form);return!i||i===t},d3=function(t){return eR(t)&&t.type==="radio"},f3=function(t){return d3(t)&&!c3(t)},p3=function(t){var n,r=t&&Np(t),o=(n=r)===null||n===void 0?void 0:n.host,i=!1;if(r&&r!==t){var s,a,u;for(i=!!((s=o)!==null&&s!==void 0&&(a=s.ownerDocument)!==null&&a!==void 0&&a.contains(o)||t!=null&&(u=t.ownerDocument)!==null&&u!==void 0&&u.contains(t));!i&&o;){var l,c,f;r=Np(o),o=(l=r)===null||l===void 0?void 0:l.host,i=!!((c=o)!==null&&c!==void 0&&(f=c.ownerDocument)!==null&&f!==void 0&&f.contains(o))}}return i},Xk=function(t){var n=t.getBoundingClientRect(),r=n.width,o=n.height;return r===0&&o===0},m3=function(t,n){var r=n.displayCheck,o=n.getShadowRoot;if(getComputedStyle(t).visibility==="hidden")return!0;var i=Sa.call(t,"details>summary:first-of-type"),s=i?t.parentElement:t;if(Sa.call(s,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="legacy-full"){if(typeof o=="function"){for(var a=t;t;){var u=t.parentElement,l=Np(t);if(u&&!u.shadowRoot&&o(u)===!0)return Xk(t);t.assignedSlot?t=t.assignedSlot:!u&&l!==t.ownerDocument?t=l.host:t=u}t=a}if(p3(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return Xk(t);return!1},g3=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var o=n.children.item(r);if(o.tagName==="LEGEND")return Sa.call(n,"fieldset[disabled] *")?!0:!o.contains(t)}return!0}n=n.parentElement}return!1},h3=function(t,n){return!(n.disabled||_p(n)||a3(n)||m3(n,t)||l3(n)||g3(n))},f0=function(t,n){return!(f3(n)||Jk(n)<0||!h3(t,n))},y3=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},v3=function e(t){var n=[],r=[];return t.forEach(function(o,i){var s=!!o.scopeParent,a=s?o.scopeParent:o,u=i3(a,s),l=s?e(o.candidates):a;u===0?s?n.push.apply(n,l):n.push(a):r.push({documentOrder:i,tabIndex:u,item:o,isScope:s,content:l})}),r.sort(s3).reduce(function(o,i){return i.isScope?o.push.apply(o,i.content):o.push(i.content),o},[]).concat(n)},Zu=function(t,n){n=n||{};var r;return n.getShadowRoot?r=o3([t],n.includeContainer,{filter:f0.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:y3}):r=r3(t,n.includeContainer,f0.bind(null,n)),v3(r)};var tR=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return Sa.call(t,Mp)===!1?!1:f0(n,t)};var P0=w(Bs(),1);function nR(e,t,n){let{reference:r,floating:o}=e,i=Fi(t),s=d0(t),a=c0(s),u=Wo(t),l=i==="y",c=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,d=r[a]/2-o[a]/2,p;switch(u){case"top":p={x:c,y:r.y-o.height};break;case"bottom":p={x:c,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Qu(t)){case"start":p[s]-=d*(n&&l?-1:1);break;case"end":p[s]+=d*(n&&l?-1:1);break}return p}var rR=(e,t,n)=>P(void 0,null,function*(){let{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,a=i.filter(Boolean),u=yield s.isRTL==null?void 0:s.isRTL(t),l=yield s.getElementRects({reference:e,floating:t,strategy:o}),{x:c,y:f}=nR(l,r,u),d=r,p={},y=0;for(let h=0;h<a.length;h++){let{name:g,fn:m}=a[h],{x:v,y:x,data:S,reset:C}=yield m({x:c,y:f,initialPlacement:r,placement:d,strategy:o,middlewareData:p,rects:l,platform:s,elements:{reference:e,floating:t}});c=v!=null?v:c,f=x!=null?x:f,p=A(b({},p),{[g]:b(b({},p[g]),S)}),C&&y<=50&&(y++,typeof C=="object"&&(C.placement&&(d=C.placement),C.rects&&(l=C.rects===!0?yield s.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:c,y:f}=nR(l,d,u)),h=-1)}return{x:c,y:f,placement:d,strategy:o,middlewareData:p}});function p0(e,t){return P(this,null,function*(){var n;t===void 0&&(t={});let{x:r,y:o,platform:i,rects:s,elements:a,strategy:u}=e,{boundary:l="clippingAncestors",rootBoundary:c="viewport",elementContext:f="floating",altBoundary:d=!1,padding:p=0}=Xu(t,e),y=Yk(p),g=a[d?f==="floating"?"reference":"floating":f],m=Hi(yield i.getClippingRect({element:(n=yield i.isElement==null?void 0:i.isElement(g))==null||n?g:g.contextElement||(yield i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:l,rootBoundary:c,strategy:u})),v=f==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,x=yield i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating),S=(yield i.isElement==null?void 0:i.isElement(x))?(yield i.getScale==null?void 0:i.getScale(x))||{x:1,y:1}:{x:1,y:1},C=Hi(i.convertOffsetParentRelativeRectToViewportRelativeRect?yield i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:x,strategy:u}):v);return{top:(m.top-C.top+y.top)/S.y,bottom:(C.bottom-m.bottom+y.bottom)/S.y,left:(m.left-C.left+y.left)/S.x,right:(C.right-m.right+y.right)/S.x}})}var oR=function(e){return e===void 0&&(e={}),{name:"flip",options:e,fn(n){return P(this,null,function*(){var r,o;let{placement:i,middlewareData:s,rects:a,initialPlacement:u,platform:l,elements:c}=n,Y=Xu(e,n),{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:p,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:g=!0}=Y,m=te(Y,["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","fallbackAxisSideDirection","flipAlignment"]);if((r=s.arrow)!=null&&r.alignmentOffset)return{};let v=Wo(i),x=Fi(u),S=Wo(u)===u,C=yield l.isRTL==null?void 0:l.isRTL(c.floating),T=p||(S||!g?[qu(u)]:qk(u)),R=h!=="none";!p&&R&&T.push(...Gk(u,g,h,C));let L=[u,...T],O=yield p0(n,m),G=[],D=((o=s.flip)==null?void 0:o.overflows)||[];if(f&&G.push(O[v]),d){let J=Kk(i,a,C);G.push(O[J[0]],O[J[1]])}if(D=[...D,{placement:i,overflows:G}],!G.every(J=>J<=0)){var B,j;let J=(((B=s.flip)==null?void 0:B.index)||0)+1,X=L[J];if(X)return{data:{index:J,overflows:D},reset:{placement:X}};let U=(j=D.filter(I=>I.overflows[0]<=0).sort((I,M)=>I.overflows[1]-M.overflows[1])[0])==null?void 0:j.placement;if(!U)switch(y){case"bestFit":{var le;let I=(le=D.filter(M=>{if(R){let H=Fi(M.placement);return H===x||H==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(H=>H>0).reduce((H,ue)=>H+ue,0)]).sort((M,H)=>M[1]-H[1])[0])==null?void 0:le[0];I&&(U=I);break}case"initialPlacement":U=u;break}if(i!==U)return{reset:{placement:U}}}return{}})}}};function x3(e,t){return P(this,null,function*(){let{placement:n,platform:r,elements:o}=e,i=yield r.isRTL==null?void 0:r.isRTL(o.floating),s=Wo(n),a=Qu(n),u=Fi(n)==="y",l=["left","top"].includes(s)?-1:1,c=i&&u?-1:1,f=Xu(t,e),{mainAxis:d,crossAxis:p,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof y=="number"&&(p=a==="end"?y*-1:y),u?{x:p*c,y:d*l}:{x:d*l,y:p*c}})}var iR=function(e){return e===void 0&&(e=0),{name:"offset",options:e,fn(n){return P(this,null,function*(){var r,o;let{x:i,y:s,placement:a,middlewareData:u}=n,l=yield x3(n,e);return a===((r=u.offset)==null?void 0:r.placement)&&(o=u.arrow)!=null&&o.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:A(b({},l),{placement:a})}})}}},sR=function(e){return e===void 0&&(e={}),{name:"shift",options:e,fn(n){return P(this,null,function*(){let{x:r,y:o,placement:i}=n,m=Xu(e,n),{mainAxis:s=!0,crossAxis:a=!1,limiter:u={fn:v=>{let{x,y:S}=v;return{x,y:S}}}}=m,l=te(m,["mainAxis","crossAxis","limiter"]),c={x:r,y:o},f=yield p0(n,l),d=Fi(Wo(i)),p=u0(d),y=c[p],h=c[d];if(s){let v=p==="y"?"top":"left",x=p==="y"?"bottom":"right",S=y+f[v],C=y-f[x];y=l0(S,y,C)}if(a){let v=d==="y"?"top":"left",x=d==="y"?"bottom":"right",S=h+f[v],C=h-f[x];h=l0(S,h,C)}let g=u.fn(A(b({},n),{[p]:y,[d]:h}));return A(b({},g),{data:{x:g.x-r,y:g.y-o,enabled:{[p]:s,[d]:a}}})})}}};function uR(e){let t=tn(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,o=Xe(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=Gu(n)!==i||Gu(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function g0(e){return Me(e)?e:e.contextElement}function wa(e){let t=g0(e);if(!Xe(t))return er(1);let n=t.getBoundingClientRect(),{width:r,height:o,$:i}=uR(t),s=(i?Gu(n.width):n.width)/r,a=(i?Gu(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var S3=er(0);function cR(e){let t=zt(e);return!ya()||!t.visualViewport?S3:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function w3(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==zt(e)?!1:t}function zi(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let o=e.getBoundingClientRect(),i=g0(e),s=er(1);t&&(r?Me(r)&&(s=wa(r)):s=wa(e));let a=w3(i,n,r)?cR(i):er(0),u=(o.left+a.x)/s.x,l=(o.top+a.y)/s.y,c=o.width/s.x,f=o.height/s.y;if(i){let d=zt(i),p=r&&Me(r)?zt(r):r,y=d,h=Ap(y);for(;h&&r&&p!==y;){let g=wa(h),m=h.getBoundingClientRect(),v=tn(h),x=m.left+(h.clientLeft+parseFloat(v.paddingLeft))*g.x,S=m.top+(h.clientTop+parseFloat(v.paddingTop))*g.y;u*=g.x,l*=g.y,c*=g.x,f*=g.y,u+=x,l+=S,y=zt(h),h=Ap(y)}}return Hi({width:c,height:f,x:u,y:l})}function h0(e,t){let n=Ku(e).scrollLeft;return t?t.left+n:zi(Zn(e)).left+n}function dR(e,t,n){n===void 0&&(n=!1);let r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:h0(e,r)),i=r.top+t.scrollTop;return{x:o,y:i}}function b3(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e,i=o==="fixed",s=Zn(r),a=t?$u(t.floating):!1;if(r===s||a&&i)return n;let u={scrollLeft:0,scrollTop:0},l=er(1),c=er(0),f=Xe(r);if((f||!f&&!i)&&((wr(r)!=="body"||ha(s))&&(u=Ku(r)),Xe(r))){let p=zi(r);l=wa(r),c.x=p.x+r.clientLeft,c.y=p.y+r.clientTop}let d=s&&!f&&!i?dR(s,u,!0):er(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-u.scrollLeft*l.x+c.x+d.x,y:n.y*l.y-u.scrollTop*l.y+c.y+d.y}}function E3(e){return Array.from(e.getClientRects())}function T3(e){let t=Zn(e),n=Ku(e),r=e.ownerDocument.body,o=Zr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Zr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),s=-n.scrollLeft+h0(e),a=-n.scrollTop;return tn(r).direction==="rtl"&&(s+=Zr(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}function C3(e,t){let n=zt(e),r=Zn(e),o=n.visualViewport,i=r.clientWidth,s=r.clientHeight,a=0,u=0;if(o){i=o.width,s=o.height;let l=ya();(!l||l&&t==="fixed")&&(a=o.offsetLeft,u=o.offsetTop)}return{width:i,height:s,x:a,y:u}}function k3(e,t){let n=zi(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Xe(e)?wa(e):er(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,u=o*i.x,l=r*i.y;return{width:s,height:a,x:u,y:l}}function aR(e,t,n){let r;if(t==="viewport")r=C3(e,n);else if(t==="document")r=T3(Zn(e));else if(Me(t))r=k3(t,n);else{let o=cR(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Hi(r)}function fR(e,t){let n=Qn(e);return n===t||!Me(n)||Jn(n)?!1:tn(n).position==="fixed"||fR(n,t)}function R3(e,t){let n=t.get(e);if(n)return n;let r=pn(e,[],!1).filter(a=>Me(a)&&wr(a)!=="body"),o=null,i=tn(e).position==="fixed",s=i?Qn(e):e;for(;Me(s)&&!Jn(s);){let a=tn(s),u=Pp(s);!u&&a.position==="fixed"&&(o=null),(i?!u&&!o:!u&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||ha(s)&&!u&&fR(e,s))?r=r.filter(c=>c!==s):o=a,s=Qn(s)}return t.set(e,r),r}function P3(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e,s=[...n==="clippingAncestors"?$u(t)?[]:R3(t,this._c):[].concat(n),r],a=s[0],u=s.reduce((l,c)=>{let f=aR(t,c,o);return l.top=Zr(f.top,l.top),l.right=xa(f.right,l.right),l.bottom=xa(f.bottom,l.bottom),l.left=Zr(f.left,l.left),l},aR(t,a,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function A3(e){let{width:t,height:n}=uR(e);return{width:t,height:n}}function I3(e,t,n){let r=Xe(t),o=Zn(t),i=n==="fixed",s=zi(e,!0,i,t),a={scrollLeft:0,scrollTop:0},u=er(0);if(r||!r&&!i)if((wr(t)!=="body"||ha(o))&&(a=Ku(t)),r){let d=zi(t,!0,i,t);u.x=d.x+t.clientLeft,u.y=d.y+t.clientTop}else o&&(u.x=h0(o));let l=o&&!r&&!i?dR(o,a):er(0),c=s.left+a.scrollLeft-u.x-l.x,f=s.top+a.scrollTop-u.y-l.y;return{x:c,y:f,width:s.width,height:s.height}}function m0(e){return tn(e).position==="static"}function lR(e,t){if(!Xe(e)||tn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Zn(e)===n&&(n=n.ownerDocument.body),n}function pR(e,t){let n=zt(e);if($u(e))return n;if(!Xe(e)){let o=Qn(e);for(;o&&!Jn(o);){if(Me(o)&&!m0(o))return o;o=Qn(o)}return n}let r=lR(e,t);for(;r&&Dk(r)&&m0(r);)r=lR(r,t);return r&&Jn(r)&&m0(r)&&!Pp(r)?n:r||Fk(e)||n}var L3=function(e){return P(this,null,function*(){let t=this.getOffsetParent||pR,n=this.getDimensions,r=yield n(e.floating);return{reference:I3(e.reference,yield t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}})};function O3(e){return tn(e).direction==="rtl"}var y0={convertOffsetParentRelativeRectToViewportRelativeRect:b3,getDocumentElement:Zn,getClippingRect:P3,getOffsetParent:pR,getElementRects:L3,getClientRects:E3,getDimensions:A3,getScale:wa,isElement:Me,isRTL:O3};function mR(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function M3(e,t){let n=null,r,o=Zn(e);function i(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function s(a,u){a===void 0&&(a=!1),u===void 0&&(u=1),i();let l=e.getBoundingClientRect(),{left:c,top:f,width:d,height:p}=l;if(a||t(),!d||!p)return;let y=Yu(f),h=Yu(o.clientWidth-(c+d)),g=Yu(o.clientHeight-(f+p)),m=Yu(c),x={rootMargin:-y+"px "+-h+"px "+-g+"px "+-m+"px",threshold:Zr(0,xa(1,u))||1},S=!0;function C(T){let R=T[0].intersectionRatio;if(R!==u){if(!S)return s();R?s(!1,R):r=setTimeout(()=>{s(!1,1e-7)},1e3)}R===1&&!mR(l,e.getBoundingClientRect())&&s(),S=!1}try{n=new IntersectionObserver(C,A(b({},x),{root:o.ownerDocument}))}catch(T){n=new IntersectionObserver(C,x)}n.observe(e)}return s(!0),i}function Dp(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,l=g0(e),c=o||i?[...l?pn(l):[],...pn(t)]:[];c.forEach(m=>{o&&m.addEventListener("scroll",n,{passive:!0}),i&&m.addEventListener("resize",n)});let f=l&&a?M3(l,n):null,d=-1,p=null;s&&(p=new ResizeObserver(m=>{let[v]=m;v&&v.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var x;(x=p)==null||x.observe(t)})),n()}),l&&!u&&p.observe(l),p.observe(t));let y,h=u?zi(e):null;u&&g();function g(){let m=zi(e);h&&!mR(h,m)&&n(),h=m,y=requestAnimationFrame(g)}return n(),()=>{var m;c.forEach(v=>{o&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),f==null||f(),(m=p)==null||m.disconnect(),p=null,u&&cancelAnimationFrame(y)}}var gR=iR;var hR=sR,yR=oR;var Fp=(e,t,n)=>{let r=new Map,o=b({platform:y0},n),i=A(b({},o.platform),{_c:r});return rR(e,t,A(b({},o),{platform:i}))};var Je=w(W(),1),Bp=w(W(),1),SR=w(Bs(),1);var Hp=typeof document!="undefined"?Bp.useLayoutEffect:Bp.useEffect;function zp(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!zp(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){let i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!zp(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function wR(e){return typeof window=="undefined"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function vR(e,t){let n=wR(e);return Math.round(t*n)/n}function v0(e){let t=Je.useRef(e);return Hp(()=>{t.current=e}),t}function bR(e){e===void 0&&(e={});let{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:a=!0,whileElementsMounted:u,open:l}=e,[c,f]=Je.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[d,p]=Je.useState(r);zp(d,r)||p(r);let[y,h]=Je.useState(null),[g,m]=Je.useState(null),v=Je.useCallback(U=>{U!==T.current&&(T.current=U,h(U))},[]),x=Je.useCallback(U=>{U!==R.current&&(R.current=U,m(U))},[]),S=i||y,C=s||g,T=Je.useRef(null),R=Je.useRef(null),L=Je.useRef(c),O=u!=null,G=v0(u),D=v0(o),B=v0(l),j=Je.useCallback(()=>{if(!T.current||!R.current)return;let U={placement:t,strategy:n,middleware:d};D.current&&(U.platform=D.current),Fp(T.current,R.current,U).then(I=>{let M=A(b({},I),{isPositioned:B.current!==!1});le.current&&!zp(L.current,M)&&(L.current=M,SR.flushSync(()=>{f(M)}))})},[d,t,n,D,B]);Hp(()=>{l===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,f(U=>A(b({},U),{isPositioned:!1})))},[l]);let le=Je.useRef(!1);Hp(()=>(le.current=!0,()=>{le.current=!1}),[]),Hp(()=>{if(S&&(T.current=S),C&&(R.current=C),S&&C){if(G.current)return G.current(S,C,j);j()}},[S,C,j,G,O]);let Y=Je.useMemo(()=>({reference:T,floating:R,setReference:v,setFloating:x}),[v,x]),J=Je.useMemo(()=>({reference:S,floating:C}),[S,C]),X=Je.useMemo(()=>{let U={position:n,left:0,top:0};if(!J.floating)return U;let I=vR(J.floating,c.x),M=vR(J.floating,c.y);return a?b(A(b({},U),{transform:"translate("+I+"px, "+M+"px)"}),wR(J.floating)>=1.5&&{willChange:"transform"}):{position:n,left:I,top:M}},[n,a,J.floating,c.x,c.y]);return Je.useMemo(()=>A(b({},c),{update:j,refs:Y,elements:J,floatingStyles:X}),[c,j,Y,J,X])}var Up=(e,t)=>A(b({},gR(e)),{options:[e,t]}),x0=(e,t)=>A(b({},hR(e)),{options:[e,t]});var S0=(e,t)=>A(b({},yR(e)),{options:[e,t]});function tc(e){return N.useMemo(()=>e.every(t=>t==null)?null:t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})},e)}var HR=b({},N),N3=HR.useInsertionEffect,_3=N3||(e=>e());function On(e){let t=N.useRef(()=>{});return _3(()=>{t.current=e}),N.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}var D3="ArrowUp",F3="ArrowDown",H3="ArrowLeft",z3="ArrowRight";var nn=typeof document!="undefined"?ka.useLayoutEffect:ka.useEffect;var B3=[H3,z3],U3=[D3,F3],UW=[...B3,...U3];var ER=!1,j3=0,TR=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+j3++;function V3(){let[e,t]=N.useState(()=>ER?TR():void 0);return nn(()=>{e==null&&t(TR())},[]),N.useEffect(()=>{ER=!0},[]),e}var W3=HR.useId,A0=W3||V3;function $3(){let e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(o=>o(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,((r=e.get(t))==null?void 0:r.filter(o=>o!==n))||[])}}}var K3=N.createContext(null),q3=N.createContext(null),I0=()=>{var e;return((e=N.useContext(K3))==null?void 0:e.id)||null},$p=()=>N.useContext(q3);function Ca(e){return"data-floating-ui-"+e}function Ta(e){let t=(0,ka.useRef)(e);return nn(()=>{t.current=e}),t}var CR=Ca("safe-polygon");function w0(e,t,n){return n&&!va(n)?0:typeof e=="number"?e:e==null?void 0:e[t]}function zR(e,t){t===void 0&&(t={});let{open:n,onOpenChange:r,dataRef:o,events:i,elements:s}=e,{enabled:a=!0,delay:u=0,handleClose:l=null,mouseOnly:c=!1,restMs:f=0,move:d=!0}=t,p=$p(),y=I0(),h=Ta(l),g=Ta(u),m=Ta(n),v=N.useRef(),x=N.useRef(-1),S=N.useRef(),C=N.useRef(-1),T=N.useRef(!0),R=N.useRef(!1),L=N.useRef(()=>{}),O=N.useRef(!1),G=N.useCallback(()=>{var X;let U=(X=o.current.openEvent)==null?void 0:X.type;return(U==null?void 0:U.includes("mouse"))&&U!=="mousedown"},[o]);N.useEffect(()=>{if(!a)return;function X(U){let{open:I}=U;I||(clearTimeout(x.current),clearTimeout(C.current),T.current=!0,O.current=!1)}return i.on("openchange",X),()=>{i.off("openchange",X)}},[a,i]),N.useEffect(()=>{if(!a||!h.current||!n)return;function X(I){G()&&r(!1,I,"hover")}let U=Rt(s.floating).documentElement;return U.addEventListener("mouseleave",X),()=>{U.removeEventListener("mouseleave",X)}},[s.floating,n,r,a,h,G]);let D=N.useCallback(function(X,U,I){U===void 0&&(U=!0),I===void 0&&(I="hover");let M=w0(g.current,"close",v.current);M&&!S.current?(clearTimeout(x.current),x.current=window.setTimeout(()=>r(!1,X,I),M)):U&&(clearTimeout(x.current),r(!1,X,I))},[g,r]),B=On(()=>{L.current(),S.current=void 0}),j=On(()=>{if(R.current){let X=Rt(s.floating).body;X.style.pointerEvents="",X.removeAttribute(CR),R.current=!1}}),le=On(()=>o.current.openEvent?["click","mousedown"].includes(o.current.openEvent.type):!1);N.useEffect(()=>{if(!a)return;function X(H){if(clearTimeout(x.current),T.current=!1,c&&!va(v.current)||f>0&&!w0(g.current,"open"))return;let ue=w0(g.current,"open",v.current);ue?x.current=window.setTimeout(()=>{m.current||r(!0,H,"hover")},ue):n||r(!0,H,"hover")}function U(H){if(le())return;L.current();let ue=Rt(s.floating);if(clearTimeout(C.current),O.current=!1,h.current&&o.current.floatingContext){n||clearTimeout(x.current),S.current=h.current(A(b({},o.current.floatingContext),{tree:p,x:H.clientX,y:H.clientY,onClose(){j(),B(),le()||D(H,!0,"safe-polygon")}}));let ge=S.current;ue.addEventListener("mousemove",ge),L.current=()=>{ue.removeEventListener("mousemove",ge)};return}(v.current==="touch"?!Bt(s.floating,H.relatedTarget):!0)&&D(H)}function I(H){le()||o.current.floatingContext&&(h.current==null||h.current(A(b({},o.current.floatingContext),{tree:p,x:H.clientX,y:H.clientY,onClose(){j(),B(),le()||D(H)}}))(H))}if(Me(s.domReference)){var M;let H=s.domReference;return n&&H.addEventListener("mouseleave",I),(M=s.floating)==null||M.addEventListener("mouseleave",I),d&&H.addEventListener("mousemove",X,{once:!0}),H.addEventListener("mouseenter",X),H.addEventListener("mouseleave",U),()=>{var ue;n&&H.removeEventListener("mouseleave",I),(ue=s.floating)==null||ue.removeEventListener("mouseleave",I),d&&H.removeEventListener("mousemove",X),H.removeEventListener("mouseenter",X),H.removeEventListener("mouseleave",U)}}},[s,a,e,c,f,d,D,B,j,r,n,m,p,g,h,o,le]),nn(()=>{var X;if(a&&n&&(X=h.current)!=null&&X.__options.blockPointerEvents&&G()){R.current=!0;let I=s.floating;if(Me(s.domReference)&&I){var U;let M=Rt(s.floating).body;M.setAttribute(CR,"");let H=s.domReference,ue=p==null||(U=p.nodesRef.current.find(ee=>ee.id===y))==null||(U=U.context)==null?void 0:U.elements.floating;return ue&&(ue.style.pointerEvents=""),M.style.pointerEvents="none",H.style.pointerEvents="auto",I.style.pointerEvents="auto",()=>{M.style.pointerEvents="",H.style.pointerEvents="",I.style.pointerEvents=""}}}},[a,n,y,s,p,h,G]),nn(()=>{n||(v.current=void 0,O.current=!1,B(),j())},[n,B,j]),N.useEffect(()=>()=>{B(),clearTimeout(x.current),clearTimeout(C.current),j()},[a,s.domReference,B,j]);let Y=N.useMemo(()=>{function X(U){v.current=U.pointerType}return{onPointerDown:X,onPointerEnter:X,onMouseMove(U){let{nativeEvent:I}=U;function M(){!T.current&&!m.current&&r(!0,I,"hover")}c&&!va(v.current)||n||f===0||O.current&&Um(U.movementX,2)+Um(U.movementY,2)<2||(clearTimeout(C.current),v.current==="touch"?M():(O.current=!0,C.current=window.setTimeout(M,f)))}}},[c,r,n,m,f]),J=N.useMemo(()=>({onMouseEnter(){clearTimeout(x.current)},onMouseLeave(X){le()||D(X.nativeEvent,!1)}}),[D,le]);return N.useMemo(()=>a?{reference:Y,floating:J}:{},[a,Y,J])}var kR=0;function ba(e,t){t===void 0&&(t={});let{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(kR);let i=()=>e==null?void 0:e.focus({preventScroll:n});o?i():kR=requestAnimationFrame(i)}function RR(e,t){var n;let r=[],o=(n=e.find(i=>i.id===t))==null?void 0:n.parentId;for(;o;){let i=e.find(s=>s.id===o);o=i==null?void 0:i.parentId,i&&(r=r.concat(i))}return r}function Ju(e,t){let n=e.filter(o=>{var i;return o.parentId===t&&((i=o.context)==null?void 0:i.open)}),r=n;for(;r.length;)r=e.filter(o=>{var i;return(i=r)==null?void 0:i.some(s=>{var a;return o.parentId===s.id&&((a=o.context)==null?void 0:a.open)})}),n=n.concat(r);return n}var Ea=new WeakMap,jp=new WeakSet,Vp={},b0=0,G3=()=>typeof HTMLElement!="undefined"&&"inert"in HTMLElement.prototype,BR=e=>e&&(e.host||BR(e.parentNode)),Y3=(e,t)=>t.map(n=>{if(e.contains(n))return n;let r=BR(n);return e.contains(r)?r:null}).filter(n=>n!=null);function X3(e,t,n,r){let o="data-floating-ui-inert",i=r?"inert":n?"aria-hidden":null,s=Y3(t,e),a=new Set,u=new Set(s),l=[];Vp[o]||(Vp[o]=new WeakMap);let c=Vp[o];s.forEach(f),d(t),a.clear();function f(p){!p||a.has(p)||(a.add(p),p.parentNode&&f(p.parentNode))}function d(p){!p||u.has(p)||[].forEach.call(p.children,y=>{if(wr(y)!=="script")if(a.has(y))d(y);else{let h=i?y.getAttribute(i):null,g=h!==null&&h!=="false",m=Ea.get(y)||0,v=i?m+1:m,x=(c.get(y)||0)+1;Ea.set(y,v),c.set(y,x),l.push(y),v===1&&g&&jp.add(y),x===1&&y.setAttribute(o,""),!g&&i&&y.setAttribute(i,"true")}})}return b0++,()=>{l.forEach(p=>{let y=Ea.get(p)||0,h=i?y-1:y,g=(c.get(p)||0)-1;Ea.set(p,h),c.set(p,g),h||(!jp.has(p)&&i&&p.removeAttribute(i),jp.delete(p)),g||p.removeAttribute(o)}),b0--,b0||(Ea=new WeakMap,Ea=new WeakMap,jp=new WeakSet,Vp={})}}function PR(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);let r=Rt(e[0]).body;return X3(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}var Kp=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function UR(e,t){let n=Zu(e,Kp());t==="prev"&&n.reverse();let r=n.indexOf(jo(Rt(e)));return n.slice(r+1)[0]}function jR(){return UR(document.body,"next")}function VR(){return UR(document.body,"prev")}function ec(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!Bt(n,r)}function Q3(e){Zu(e,Kp()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function AR(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{let r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}var qp={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},Z3;function IR(e){e.key==="Tab"&&(e.target,clearTimeout(Z3))}var Wp=N.forwardRef(function(t,n){let[r,o]=N.useState();nn(()=>(jk()&&o("button"),document.addEventListener("keydown",IR),()=>{document.removeEventListener("keydown",IR)}),[]);let i={ref:n,tabIndex:0,role:r,"aria-hidden":r?void 0:!0,[Ca("focus-guard")]:"",style:qp};return(0,rn.jsx)("span",b(b({},t),i))}),WR=N.createContext(null),LR=Ca("portal");function J3(e){e===void 0&&(e={});let{id:t,root:n}=e,r=A0(),o=KR(),[i,s]=N.useState(null),a=N.useRef(null);return nn(()=>()=>{i==null||i.remove(),queueMicrotask(()=>{a.current=null})},[i]),nn(()=>{if(!r||a.current)return;let u=t?document.getElementById(t):null;if(!u)return;let l=document.createElement("div");l.id=r,l.setAttribute(LR,""),u.appendChild(l),a.current=l,s(l)},[t,r]),nn(()=>{if(n===null||!r||a.current)return;let u=n||(o==null?void 0:o.portalNode);u&&!Me(u)&&(u=u.current),u=u||document.body;let l=null;t&&(l=document.createElement("div"),l.id=t,u.appendChild(l));let c=document.createElement("div");c.id=r,c.setAttribute(LR,""),u=l||u,u.appendChild(c),a.current=c,s(c)},[t,n,r,o]),i}function $R(e){let{children:t,id:n,root:r,preserveTabOrder:o=!0}=e,i=J3({id:n,root:r}),[s,a]=N.useState(null),u=N.useRef(null),l=N.useRef(null),c=N.useRef(null),f=N.useRef(null),d=s==null?void 0:s.modal,p=s==null?void 0:s.open,y=!!s&&!s.modal&&s.open&&o&&!!(r||i);return N.useEffect(()=>{if(!i||!o||d)return;function h(g){i&&ec(g)&&(g.type==="focusin"?AR:Q3)(i)}return i.addEventListener("focusin",h,!0),i.addEventListener("focusout",h,!0),()=>{i.removeEventListener("focusin",h,!0),i.removeEventListener("focusout",h,!0)}},[i,o,d]),N.useEffect(()=>{i&&(p||AR(i))},[p,i]),(0,rn.jsxs)(WR.Provider,{value:N.useMemo(()=>({preserveTabOrder:o,beforeOutsideRef:u,afterOutsideRef:l,beforeInsideRef:c,afterInsideRef:f,portalNode:i,setFocusManagerState:a}),[o,i]),children:[y&&i&&(0,rn.jsx)(Wp,{"data-type":"outside",ref:u,onFocus:h=>{if(ec(h,i)){var g;(g=c.current)==null||g.focus()}else{let m=VR()||(s==null?void 0:s.domReference);m==null||m.focus()}}}),y&&i&&(0,rn.jsx)("span",{"aria-owns":i.id,style:qp}),i&&P0.createPortal(t,i),y&&i&&(0,rn.jsx)(Wp,{"data-type":"outside",ref:l,onFocus:h=>{if(ec(h,i)){var g;(g=f.current)==null||g.focus()}else{let m=jR()||(s==null?void 0:s.domReference);m==null||m.focus(),s!=null&&s.closeOnFocusOut&&(s==null||s.onOpenChange(!1,h.nativeEvent,"focus-out"))}}})]})}var KR=()=>N.useContext(WR),R0="data-floating-ui-focusable";function OR(e){return e?e.hasAttribute(R0)?e:e.querySelector("["+R0+"]")||e:null}var MR=20,Bi=[];function E0(e){Bi=Bi.filter(t=>t.isConnected),e&&wr(e)!=="body"&&(Bi.push(e),Bi.length>MR&&(Bi=Bi.slice(-MR)))}function NR(){return Bi.slice().reverse().find(e=>e.isConnected)}function e4(e){let t=Kp();return tR(e,t)?e:Zu(e,t)[0]||e}var t4=N.forwardRef(function(t,n){return(0,rn.jsx)("button",A(b({},t),{type:"button",ref:n,tabIndex:-1,style:qp}))});function qR(e){let{context:t,children:n,disabled:r=!1,order:o=["content"],guards:i=!0,initialFocus:s=0,returnFocus:a=!0,restoreFocus:u=!1,modal:l=!0,visuallyHiddenDismiss:c=!1,closeOnFocusOut:f=!0,outsideElementsInert:d=!1}=e,{open:p,onOpenChange:y,events:h,dataRef:g,elements:{domReference:m,floating:v}}=t,x=On(()=>{var oe;return(oe=g.current.floatingContext)==null?void 0:oe.nodeId}),S=typeof s=="number"&&s<0,C=$k(m)&&S,T=G3(),R=T?i:!0,L=!R||T&&d,O=Ta(o),G=Ta(s),D=Ta(a),B=$p(),j=KR(),le=N.useRef(null),Y=N.useRef(null),J=N.useRef(!1),X=N.useRef(!1),U=N.useRef(-1),I=j!=null,M=OR(v),H=On(function(oe){return oe===void 0&&(oe=M),oe?Zu(oe,Kp()):[]}),ue=On(oe=>{let ae=H(oe);return O.current.map(ie=>m&&ie==="reference"?m:M&&ie==="floating"?M:ae).filter(Boolean).flat()});N.useEffect(()=>{if(r||!l)return;function oe(ie){if(ie.key==="Tab"){Bt(M,jo(Rt(M)))&&H().length===0&&!C&&Lp(ie);let de=ue(),pe=Vo(ie);O.current[0]==="reference"&&pe===m&&(Lp(ie),ie.shiftKey?ba(de[de.length-1]):ba(de[1])),O.current[1]==="floating"&&pe===M&&ie.shiftKey&&(Lp(ie),ba(de[0]))}}let ae=Rt(M);return ae.addEventListener("keydown",oe),()=>{ae.removeEventListener("keydown",oe)}},[r,m,M,l,O,C,H,ue]),N.useEffect(()=>{if(r||!v)return;function oe(ae){let ie=Vo(ae),pe=H().indexOf(ie);pe!==-1&&(U.current=pe)}return v.addEventListener("focusin",oe),()=>{v.removeEventListener("focusin",oe)}},[r,v,H]),N.useEffect(()=>{if(r||!f)return;function oe(){X.current=!0,setTimeout(()=>{X.current=!1})}function ae(ie){let de=ie.relatedTarget;queueMicrotask(()=>{let pe=x(),ve=!(Bt(m,de)||Bt(v,de)||Bt(de,v)||Bt(j==null?void 0:j.portalNode,de)||de!=null&&de.hasAttribute(Ca("focus-guard"))||B&&(Ju(B.nodesRef.current,pe).find(_e=>{var At,$e;return Bt((At=_e.context)==null?void 0:At.elements.floating,de)||Bt(($e=_e.context)==null?void 0:$e.elements.domReference,de)})||RR(B.nodesRef.current,pe).find(_e=>{var At,$e,mn;return[(At=_e.context)==null?void 0:At.elements.floating,OR(($e=_e.context)==null?void 0:$e.elements.floating)].includes(de)||((mn=_e.context)==null?void 0:mn.elements.domReference)===de})));if(u&&ve&&jo(Rt(M))===Rt(M).body){Xe(M)&&M.focus();let _e=U.current,At=H(),$e=At[_e]||At[At.length-1]||M;Xe($e)&&$e.focus()}(C||!l)&&de&&ve&&!X.current&&de!==NR()&&(J.current=!0,y(!1,ie,"focus-out"))})}if(v&&Xe(m))return m.addEventListener("focusout",ae),m.addEventListener("pointerdown",oe),v.addEventListener("focusout",ae),()=>{m.removeEventListener("focusout",ae),m.removeEventListener("pointerdown",oe),v.removeEventListener("focusout",ae)}},[r,m,v,M,l,B,j,y,f,u,H,C,x]);let ee=N.useRef(null),ge=N.useRef(null),Pe=tc([ee,j==null?void 0:j.beforeInsideRef]),Ne=tc([ge,j==null?void 0:j.afterInsideRef]);N.useEffect(()=>{var oe;if(r||!v)return;let ae=Array.from((j==null||(oe=j.portalNode)==null?void 0:oe.querySelectorAll("["+Ca("portal")+"]"))||[]),ie=B&&!l?RR(B==null?void 0:B.nodesRef.current,x()).map(ve=>{var _e;return(_e=ve.context)==null?void 0:_e.elements.floating}):[],de=[v,...ae,...ie,le.current,Y.current,ee.current,ge.current,j==null?void 0:j.beforeOutsideRef.current,j==null?void 0:j.afterOutsideRef.current,O.current.includes("reference")||C?m:null].filter(ve=>ve!=null),pe=l||C?PR(de,!L,L):PR(de);return()=>{pe()}},[r,m,v,l,O,j,C,R,L,B,x]),nn(()=>{if(r||!Xe(M))return;let oe=Rt(M),ae=jo(oe);queueMicrotask(()=>{let ie=ue(M),de=G.current,pe=(typeof de=="number"?ie[de]:de.current)||M,ve=Bt(M,ae);!S&&!ve&&p&&ba(pe,{preventScroll:pe===M})})},[r,p,M,S,ue,G]),nn(()=>{if(r||!M)return;let oe=!1,ae=Rt(M),ie=jo(ae),pe=g.current.openEvent;E0(ie);function ve($e){let{open:mn,reason:Pr,event:Ar,nested:or}=$e;mn&&(pe=Ar),Pr==="escape-key"&&m&&E0(m),["hover","safe-polygon"].includes(Pr)&&Ar.type==="mouseleave"&&(J.current=!0),Pr==="outside-press"&&(or?(J.current=!1,oe=!0):J.current=!(Bk(Ar)||Uk(Ar)))}h.on("openchange",ve);let _e=ae.createElement("span");_e.setAttribute("tabindex","-1"),_e.setAttribute("aria-hidden","true"),Object.assign(_e.style,qp),I&&m&&m.insertAdjacentElement("afterend",_e);function At(){return typeof D.current=="boolean"?NR()||_e:D.current.current||_e}return()=>{h.off("openchange",ve);let $e=jo(ae),mn=Bt(v,$e)||B&&Ju(B.nodesRef.current,x()).some(or=>{var yc;return Bt((yc=or.context)==null?void 0:yc.elements.floating,$e)});(mn||pe&&["click","mousedown"].includes(pe.type))&&m&&E0(m);let Ar=At();queueMicrotask(()=>{let or=e4(Ar);D.current&&!J.current&&Xe(or)&&(!(or!==$e&&$e!==ae.body)||mn)&&or.focus({preventScroll:oe}),_e.remove()})}},[r,v,M,D,g,h,B,I,m,x]),N.useEffect(()=>{queueMicrotask(()=>{J.current=!1})},[r]),nn(()=>{if(!r&&j)return j.setFocusManagerState({modal:l,closeOnFocusOut:f,open:p,onOpenChange:y,domReference:m}),()=>{j.setFocusManagerState(null)}},[r,j,l,p,y,f,m]),nn(()=>{if(r||!M||typeof MutationObserver!="function"||S)return;let oe=()=>{let ie=M.getAttribute("tabindex"),de=H(),pe=jo(Rt(v)),ve=de.indexOf(pe);ve!==-1&&(U.current=ve),O.current.includes("floating")||pe!==m&&de.length===0?ie!=="0"&&M.setAttribute("tabindex","0"):ie!=="-1"&&M.setAttribute("tabindex","-1")};oe();let ae=new MutationObserver(oe);return ae.observe(M,{childList:!0,subtree:!0,attributes:!0}),()=>{ae.disconnect()}},[r,v,M,m,O,H,S]);function Qe(oe){return r||!c||!l?null:(0,rn.jsx)(t4,{ref:oe==="start"?le:Y,onClick:ae=>y(!1,ae.nativeEvent),children:typeof c=="string"?c:"Dismiss"})}let Wt=!r&&R&&(l?!C:!0)&&(I||l);return(0,rn.jsxs)(rn.Fragment,{children:[Wt&&(0,rn.jsx)(Wp,{"data-type":"inside",ref:Pe,onFocus:oe=>{if(l){let ie=ue();ba(o[0]==="reference"?ie[0]:ie[ie.length-1])}else if(j!=null&&j.preserveTabOrder&&j.portalNode)if(J.current=!1,ec(oe,j.portalNode)){let ie=jR()||m;ie==null||ie.focus()}else{var ae;(ae=j.beforeOutsideRef.current)==null||ae.focus()}}}),!C&&Qe("start"),n,Qe("end"),Wt&&(0,rn.jsx)(Wp,{"data-type":"inside",ref:Ne,onFocus:oe=>{if(l)ba(ue()[0]);else if(j!=null&&j.preserveTabOrder&&j.portalNode)if(f&&(J.current=!0),ec(oe,j.portalNode)){let ie=VR()||m;ie==null||ie.focus()}else{var ae;(ae=j.afterOutsideRef.current)==null||ae.focus()}}})]})}function _R(e){return Xe(e.target)&&e.target.tagName==="BUTTON"}function DR(e){return a0(e)}function GR(e,t){t===void 0&&(t={});let{open:n,onOpenChange:r,dataRef:o,elements:{domReference:i}}=e,{enabled:s=!0,event:a="click",toggle:u=!0,ignoreMouse:l=!1,keyboardHandlers:c=!0,stickIfOpen:f=!0}=t,d=N.useRef(),p=N.useRef(!1),y=N.useMemo(()=>({onPointerDown(h){d.current=h.pointerType},onMouseDown(h){let g=d.current;h.button===0&&a!=="click"&&(va(g,!0)&&l||(n&&u&&(!(o.current.openEvent&&f)||o.current.openEvent.type==="mousedown")?r(!1,h.nativeEvent,"click"):(h.preventDefault(),r(!0,h.nativeEvent,"click"))))},onClick(h){let g=d.current;if(a==="mousedown"&&d.current){d.current=void 0;return}va(g,!0)&&l||(n&&u&&(!(o.current.openEvent&&f)||o.current.openEvent.type==="click")?r(!1,h.nativeEvent,"click"):r(!0,h.nativeEvent,"click"))},onKeyDown(h){d.current=void 0,!(h.defaultPrevented||!c||_R(h))&&(h.key===" "&&!DR(i)&&(h.preventDefault(),p.current=!0),h.key==="Enter"&&r(!(n&&u),h.nativeEvent,"click"))},onKeyUp(h){h.defaultPrevented||!c||_R(h)||DR(i)||h.key===" "&&p.current&&(p.current=!1,r(!(n&&u),h.nativeEvent,"click"))}}),[o,i,a,l,c,r,n,f,u]);return N.useMemo(()=>s?{reference:y}:{},[s,y])}var n4={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},r4={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},FR=e=>{var t,n;return{escapeKey:typeof e=="boolean"?e:(t=e==null?void 0:e.escapeKey)!=null?t:!1,outsidePress:typeof e=="boolean"?e:(n=e==null?void 0:e.outsidePress)!=null?n:!0}};function YR(e,t){t===void 0&&(t={});let{open:n,onOpenChange:r,elements:o,dataRef:i}=e,{enabled:s=!0,escapeKey:a=!0,outsidePress:u=!0,outsidePressEvent:l="pointerdown",referencePress:c=!1,referencePressEvent:f="pointerdown",ancestorScroll:d=!1,bubbles:p,capture:y}=t,h=$p(),g=On(typeof u=="function"?u:()=>!1),m=typeof u=="function"?g:u,v=N.useRef(!1),x=N.useRef(!1),{escapeKey:S,outsidePress:C}=FR(p),{escapeKey:T,outsidePress:R}=FR(y),L=N.useRef(!1),O=On(Y=>{var J;if(!n||!s||!a||Y.key!=="Escape"||L.current)return;let X=(J=i.current.floatingContext)==null?void 0:J.nodeId,U=h?Ju(h.nodesRef.current,X):[];if(!S&&(Y.stopPropagation(),U.length>0)){let I=!0;if(U.forEach(M=>{var H;if((H=M.context)!=null&&H.open&&!M.context.dataRef.current.__escapeKeyBubbles){I=!1;return}}),!I)return}r(!1,Vk(Y)?Y.nativeEvent:Y,"escape-key")}),G=On(Y=>{var J;let X=()=>{var U;O(Y),(U=Vo(Y))==null||U.removeEventListener("keydown",X)};(J=Vo(Y))==null||J.addEventListener("keydown",X)}),D=On(Y=>{var J;let X=v.current;v.current=!1;let U=x.current;if(x.current=!1,l==="click"&&U||X||typeof m=="function"&&!m(Y))return;let I=Vo(Y),M="["+Ca("inert")+"]",H=Rt(o.floating).querySelectorAll(M),ue=Me(I)?I:null;for(;ue&&!Jn(ue);){let Ne=Qn(ue);if(Jn(Ne)||!Me(Ne))break;ue=Ne}if(H.length&&Me(I)&&!Wk(I)&&!Bt(I,o.floating)&&Array.from(H).every(Ne=>!Bt(ue,Ne)))return;if(Xe(I)&&le){let Ne=Jn(I),Qe=tn(I),Wt=/auto|scroll/,oe=Ne||Wt.test(Qe.overflowX),ae=Ne||Wt.test(Qe.overflowY),ie=oe&&I.clientWidth>0&&I.scrollWidth>I.clientWidth,de=ae&&I.clientHeight>0&&I.scrollHeight>I.clientHeight,pe=Qe.direction==="rtl",ve=de&&(pe?Y.offsetX<=I.offsetWidth-I.clientWidth:Y.offsetX>I.clientWidth),_e=ie&&Y.offsetY>I.clientHeight;if(ve||_e)return}let ee=(J=i.current.floatingContext)==null?void 0:J.nodeId,ge=h&&Ju(h.nodesRef.current,ee).some(Ne=>{var Qe;return Ip(Y,(Qe=Ne.context)==null?void 0:Qe.elements.floating)});if(Ip(Y,o.floating)||Ip(Y,o.domReference)||ge)return;let Pe=h?Ju(h.nodesRef.current,ee):[];if(Pe.length>0){let Ne=!0;if(Pe.forEach(Qe=>{var Wt;if((Wt=Qe.context)!=null&&Wt.open&&!Qe.context.dataRef.current.__outsidePressBubbles){Ne=!1;return}}),!Ne)return}r(!1,Y,"outside-press")}),B=On(Y=>{var J;let X=()=>{var U;D(Y),(U=Vo(Y))==null||U.removeEventListener(l,X)};(J=Vo(Y))==null||J.addEventListener(l,X)});N.useEffect(()=>{if(!n||!s)return;i.current.__escapeKeyBubbles=S,i.current.__outsidePressBubbles=C;let Y=-1;function J(H){r(!1,H,"ancestor-scroll")}function X(){window.clearTimeout(Y),L.current=!0}function U(){Y=window.setTimeout(()=>{L.current=!1},ya()?5:0)}let I=Rt(o.floating);a&&(I.addEventListener("keydown",T?G:O,T),I.addEventListener("compositionstart",X),I.addEventListener("compositionend",U)),m&&I.addEventListener(l,R?B:D,R);let M=[];return d&&(Me(o.domReference)&&(M=pn(o.domReference)),Me(o.floating)&&(M=M.concat(pn(o.floating))),!Me(o.reference)&&o.reference&&o.reference.contextElement&&(M=M.concat(pn(o.reference.contextElement)))),M=M.filter(H=>{var ue;return H!==((ue=I.defaultView)==null?void 0:ue.visualViewport)}),M.forEach(H=>{H.addEventListener("scroll",J,{passive:!0})}),()=>{a&&(I.removeEventListener("keydown",T?G:O,T),I.removeEventListener("compositionstart",X),I.removeEventListener("compositionend",U)),m&&I.removeEventListener(l,R?B:D,R),M.forEach(H=>{H.removeEventListener("scroll",J)}),window.clearTimeout(Y)}},[i,o,a,m,l,n,r,d,s,S,C,O,T,G,D,R,B]),N.useEffect(()=>{v.current=!1},[m,l]);let j=N.useMemo(()=>b({onKeyDown:O},c&&b({[n4[f]]:Y=>{r(!1,Y.nativeEvent,"reference-press")}},f!=="click"&&{onClick(Y){r(!1,Y.nativeEvent,"reference-press")}})),[O,r,c,f]),le=N.useMemo(()=>({onKeyDown:O,onMouseDown(){x.current=!0},onMouseUp(){x.current=!0},[r4[l]]:()=>{v.current=!0}}),[O,l]);return N.useMemo(()=>s?{reference:j,floating:le}:{},[s,j,le])}function o4(e){let{open:t=!1,onOpenChange:n,elements:r}=e,o=A0(),i=N.useRef({}),[s]=N.useState(()=>$3()),a=I0()!=null,[u,l]=N.useState(r.reference),c=On((p,y,h)=>{i.current.openEvent=p?y:void 0,s.emit("openchange",{open:p,event:y,reason:h,nested:a}),n==null||n(p,y,h)}),f=N.useMemo(()=>({setPositionReference:l}),[]),d=N.useMemo(()=>({reference:u||r.reference||null,floating:r.floating||null,domReference:r.reference}),[u,r.reference,r.floating]);return N.useMemo(()=>({dataRef:i,open:t,onOpenChange:c,elements:d,events:s,floatingId:o,refs:f}),[t,c,d,s,o,f])}function XR(e){e===void 0&&(e={});let{nodeId:t}=e,n=o4(A(b({},e),{elements:b({reference:null,floating:null},e.elements)})),r=e.rootContext||n,o=r.elements,[i,s]=N.useState(null),[a,u]=N.useState(null),c=(o==null?void 0:o.domReference)||i,f=N.useRef(null),d=$p();nn(()=>{c&&(f.current=c)},[c]);let p=bR(A(b({},e),{elements:b(b({},o),a&&{reference:a})})),y=N.useCallback(x=>{let S=Me(x)?{getBoundingClientRect:()=>x.getBoundingClientRect(),contextElement:x}:x;u(S),p.refs.setReference(S)},[p.refs]),h=N.useCallback(x=>{(Me(x)||x===null)&&(f.current=x,s(x)),(Me(p.refs.reference.current)||p.refs.reference.current===null||x!==null&&!Me(x))&&p.refs.setReference(x)},[p.refs]),g=N.useMemo(()=>A(b({},p.refs),{setReference:h,setPositionReference:y,domReference:f}),[p.refs,h,y]),m=N.useMemo(()=>A(b({},p.elements),{domReference:c}),[p.elements,c]),v=N.useMemo(()=>A(b(b({},p),r),{refs:g,elements:m,nodeId:t}),[p,g,m,t,r]);return nn(()=>{r.dataRef.current.floatingContext=v;let x=d==null?void 0:d.nodesRef.current.find(S=>S.id===t);x&&(x.context=v)}),N.useMemo(()=>A(b({},p),{context:v,refs:g,elements:m}),[p,g,m,v])}var T0="active",C0="selected";function k0(e,t,n){let r=new Map,o=n==="item",i=e;if(o&&e){let s=e,{[T0]:a,[C0]:u}=s;i=te(s,[jm(T0),jm(C0)])}return b(b(b({},n==="floating"&&{tabIndex:-1,[R0]:""}),i),t.map(a=>{let u=a?a[n]:null;return typeof u=="function"?e?u(e):null:u}).concat(e).reduce((a,u)=>(u&&Object.entries(u).forEach(l=>{let[c,f]=l;if(!(o&&[T0,C0].includes(c)))if(c.indexOf("on")===0){if(r.has(c)||r.set(c,[]),typeof f=="function"){var d;(d=r.get(c))==null||d.push(f),a[c]=function(){for(var p,y=arguments.length,h=new Array(y),g=0;g<y;g++)h[g]=arguments[g];return(p=r.get(c))==null?void 0:p.map(m=>m(...h)).find(m=>m!==void 0)}}}else a[c]=f}),a),{}))}function QR(e){e===void 0&&(e=[]);let t=e.map(a=>a==null?void 0:a.reference),n=e.map(a=>a==null?void 0:a.floating),r=e.map(a=>a==null?void 0:a.item),o=N.useCallback(a=>k0(a,e,"reference"),t),i=N.useCallback(a=>k0(a,e,"floating"),n),s=N.useCallback(a=>k0(a,e,"item"),r);return N.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:s}),[o,i,s])}var i4=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function ZR(e,t){var n;t===void 0&&(t={});let{open:r,floatingId:o}=e,{enabled:i=!0,role:s="dialog"}=t,a=(n=i4.get(s))!=null?n:s,u=A0(),c=I0()!=null,f=N.useMemo(()=>a==="tooltip"||s==="label"?{["aria-"+(s==="label"?"labelledby":"describedby")]:r?o:void 0}:b(b(b(b(b({"aria-expanded":r?"true":"false","aria-haspopup":a==="alertdialog"?"dialog":a,"aria-controls":r?o:void 0},a==="listbox"&&{role:"combobox"}),a==="menu"&&{id:u}),a==="menu"&&c&&{role:"menuitem"}),s==="select"&&{"aria-autocomplete":"none"}),s==="combobox"&&{"aria-autocomplete":"list"}),[a,o,c,r,u,s]),d=N.useMemo(()=>{let y=b({id:o},a&&{role:a});return a==="tooltip"||s==="label"?y:b(b({},y),a==="menu"&&{"aria-labelledby":u})},[a,o,u,s]),p=N.useCallback(y=>{let{active:h,selected:g}=y,m=b({role:"option"},h&&{id:o+"-option"});switch(s){case"select":return A(b({},m),{"aria-selected":h&&g});case"combobox":return b(b({},m),h&&{"aria-selected":!0})}return{}},[o,s]);return N.useMemo(()=>i?{reference:f,floating:d,item:p}:{},[i,f,d,p])}var Ui=w(k());function s4({initialOpen:e=!1,placement:t="bottom",modal:n,tooltip:r}={}){let[o,i]=br.useState(e),s=XR({placement:t,open:o,onOpenChange:i,whileElementsMounted:Dp,middleware:[Up(5),S0({crossAxis:t.includes("-"),fallbackAxisSideDirection:"end",padding:5}),x0({padding:10})]}),a=s.context,u=GR(a),l=YR(a),c=ZR(a),f=zR(a,{move:!1,enabled:r}),d=QR([u,l,c,f]);return br.useMemo(()=>A(b(b({open:o,setOpen:i},d),s),{modal:n}),[o,i,d,s,n])}var JR=br.createContext(null),L0=()=>{let e=br.useContext(JR);if(e==null)throw new Error("Popover components must be wrapped in <Popover />");return e},Gp=r=>{var o=r,{children:e,modal:t=!1}=o,n=te(o,["children","modal"]);let i=s4(b({modal:t},n));return(0,Ui.jsx)(JR.Provider,{value:i,children:e})};function a4(r){var o=r,{as:e,children:t}=o,n=te(o,["as","children"]);let i=L0(),s=e||"button",a=t.ref,u=tc([i.refs.setReference,a]);return(0,Ui.jsx)(s,A(b({ref:u,type:"button","data-state":i.open?"open":"closed"},i.getReferenceProps(n)),{children:t}))}var l4=br.forwardRef(function(o,r){var i=o,{style:t}=i,n=te(i,["style"]);let l=L0(),{context:s}=l,a=te(l,["context"]),u=tc([a.refs.setFloating,r]);return s.open?(0,Ui.jsx)($R,{children:(0,Ui.jsx)(qR,{context:s,modal:a.modal,children:(0,Ui.jsx)("div",A(b({ref:u,style:b(b({},a.floatingStyles),t)},a.getFloatingProps(n)),{children:n.children}))})}):null});function u4(o){var i=o,{as:e,children:t,onClick:n}=i,r=te(i,["as","children","onClick"]);let{setOpen:s}=L0();return(0,Ui.jsx)(e||"button",A(b({type:"button",onClick:l=>{n(l),s(!1),l.stopPropagation()}},r),{children:t}))}Gp.Trigger=a4;Gp.Content=l4;Gp.Button=u4;var on=Gp;var Yp={trigger:"dd-dQ-OH",content:"dd-9k0N3",item:"dd-va6pa"};var ji=w(k()),c4=({suggestion:e,source:t,context:n})=>{let r=re(Wu),o=V(hr),i=ce(),s=q("enableSuggestionFeedback"),a=`${e.text}`,u=V(ca(`/admin/feedback?conversationId=${o}&type=${t}&text=${a}&data=${JSON.stringify({context:n})}`)),l=()=>{i(kn({name:"suggestion feedback",data:{text:e.text,source:t,context:n},options:{includeConversationData:!0}}))};return!s||!u?null:(0,ji.jsxs)(on,{placement:"top-end",children:[(0,ji.jsx)(on.Trigger,{className:Yp.trigger,children:(0,ji.jsx)(Cp,{"data-testid":"feedback-dropdown-trigger"})}),(0,ji.jsx)(on.Content,{className:Yp.content,children:(0,ji.jsx)(on.Button,{className:Yp.item,as:"a",onClick:l,target:"_blank",href:u,children:r("giveFeedback")})})]})},Xp=c4;var nc={};Lt(nc,{enUS:()=>d4,nlNL:()=>f4});var d4={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"URL suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},f4={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"URL suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var lP=w(W());var p4=["{amount}"," {amount}","{date}","{email}","{iban}","{name}","{postal_code}","{street}","{tarif}","{usage}","{3_digits}","{4_digits}","{5_digits}","{6_digits}","{7_digits}","{8_digits}","{9_digits}","{10_digits}"],m4=new RegExp(p4.map(e=>`(?:${e.replace("{","\\{").replace("}","\\}")})`).join("|"));function eP(e,t){let n=e.split(m4),r=0,o=[];for(let i=0;i<n.length;i++){let s=n[i];if(o.push(s),i===n.length-1)break;if(t.indexOf(s)===-1)return e;let a=n[i+1],u=i===n.length-2;r+=s.length;let l=r;if(u){let f=a.charAt(0),d=0;do l=f?t.indexOf(f,l+1):-1,d+=1;while(l!==-1&&a.indexOf(t.slice(l))!==0);if(l===-1&&d>2)return e}else l=a&&a!==""?t.indexOf(a,r):-1;let c=l===-1?t.slice(r):t.slice(r,l);o.push(c),r=l}return o.join("")}function tP(e,t){return typeof t=="boolean"?e:e.slice(0,t)}var rP={suggestions:[],fetchState:"idle"},nP={default:rP},oP=e=>t=>{var n,r;return(r=(n=t.textSuggestions[e])==null?void 0:n.suggestions)!=null?r:[]},Qp=e=>e.textSuggestions,iP=e=>{let t=e.toLowerCase();return n=>{let r=n.text.toLowerCase();return r.startsWith(t)&&r.length>t.length}},Zp=nt("textSuggestions/refresh"),tr=fe("textSuggestions/recommendations",(e,t)=>P(void 0,null,function*(){var c;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(c=r.conversation.current)==null?void 0:c.id,{platformVariables:i}=r.info,{textSuggestionsCount:s,inlineSuggestions:a}=r.settings,u=Js(r);if(!o)throw new Error("No current conversation to fetch text suggestions");let l=yield n.getTextSuggestions(o,nu(r),e);if(i&&(l=l.map(f=>b(A(b({},f),{text:Jt(f.text,i)}),f.title?{title:Jt(f.title,i)}:{}))),e==="default"){let f=a?l.filter(iP(u)):l;t.dispatch(Do(f.slice(0,s)))}return l})),rc=fe("textSuggestions/autocompletions",(e,t)=>P(void 0,null,function*(){var c;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(c=r.conversation.current)==null?void 0:c.id,{platformVariables:i}=r.info,{textSuggestionsCount:s,deanonymize:a,inlineSuggestions:u}=r.settings;if(!o)throw new Error("No current conversation to fetch text suggestions");let l=yield n.getAutocompleteSuggestions(o,A(b({},nu(r)),{input:e}));if(!t.getState().input.text)throw new Error("Abort");return u&&(l=l.filter(iP(e))),i&&(l=l.map(f=>A(b({},f),{text:Jt(f.text,i)}))),a&&(l=l.map(f=>A(b({},f),{text:f.source!=="trie-with-typos"?eP(f.text,e):f.text}))),l=tP(l,s),t.dispatch(Do(l)),l})),sP=ye({name:"textSuggestions",initialState:nP,reducers:{setTextSuggestions:{reducer(e,t){let{contentType:n}=t.payload;e[n].fetchState="done",e[n].suggestions=t.payload.suggestions},prepare(e,t){return{payload:{contentType:e,suggestions:t}}}}},extraReducers:e=>{e.addCase(tr.pending,(t,n)=>{let r=n.meta.arg,o=t[r]||rP;return A(b({},t),{[r]:A(b({},o),{fetchState:"loading"})})}).addCase(tr.rejected,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="error")}).addCase(tr.fulfilled,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="done",t[r].suggestions=n.payload)}).addCase(rc.pending,t=>{t.default.fetchState="loading"}).addCase(rc.rejected,t=>{t.default.fetchState="error"}).addCase(rc.fulfilled,(t,n)=>{t.default.fetchState="done",t.default.suggestions=n.payload}).addCase(rt,()=>nP)}}),{setTextSuggestions:E$}=sP.actions,aP=sP.reducer;var Vi=w(k()),g4=({types:e,commands:t,onClick:n})=>{let r=ce(),o=re(nc),i=V(Qp);return(0,lP.useEffect)(()=>{e.forEach(({type:s})=>{(!i[s]||i[s].suggestions.length===0)&&r(tr(s))})},[]),(0,Vi.jsxs)("div",{children:[t.length>0&&(0,Vi.jsx)(We.List,{heading:o("commands"),children:t.map((s,a)=>(0,Vi.jsx)(We.ListItem,{id:`command-${a}`,closeOnSelect:!1,onClick:s.onClick,children:s.label},s.label))}),e.map(({type:s,title:a})=>{var u;return(0,Vi.jsx)(We.List,{heading:a,orientation:"vertical",children:(u=i[s])==null?void 0:u.suggestions.map((l,c)=>(0,Vi.jsx)(We.ListItem,{id:`${s}-${c}`,closeOnSelect:!1,description:l.title&&l.text,onClick:()=>n(l.text,l),"data-testid":"search-overlay-suggestion",children:l.title||l.text},`${l.id}-${l.text}`))},s)})]})},uP=g4;var pt=w(k()),y4=200,v4=5,x4=4,O0=(e,t,n)=>e.slice(0,n?10:t.toLowerCase()==="image"?x4:v4),S4=(e,t)=>!t||e.toLowerCase().includes(t.toLowerCase()),w4=()=>{var J,X,U;let e=ce(),t=en(),n=re(nc),[r,o]=(0,Ut.useState)(!1),[i,s]=(0,Ut.useState)(""),[a,u]=(0,Ut.useState)(null),l=V(LT),c=V(Ei),[f,d]=(0,Ut.useState)(),p=V(Nt),y=q("showSearch"),h=q("enableSuggestionFeedback"),g=q("showEntitiesCommand"),m=q("showKnowledgeSearch"),v=q("showImageSearch"),x=q("searchTriggerKey"),S=V(dC),C=V(nv),T=V(OT),R=V(IT),L=((U=(X=(J=c==null?void 0:c.uiConfig)==null?void 0:J.search)==null?void 0:X.initialTypes)==null?void 0:U.filter(({isActive:I})=>I))||[],O=(0,Ut.useMemo)(()=>{let I=ee=>O0(C.filter(ge=>ge.type===ee.toUpperCase()),ee,f),M=(S==null?void 0:S.map(ee=>({value:ee.code.toUpperCase(),label:`${ee.name}s`,list:I(ee.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[];if(M.push({value:"PERSONAL",label:n("personalSuggestions"),list:I("PERSONAL"),lineClamp:!1,listOrientation:"vertical"},{value:"URL",label:n("urlSuggestions"),list:I("URL"),lineClamp:!1,listOrientation:"vertical"},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:I("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical"}),v&&M.push({value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:I("IMAGE"),listOrientation:"horizontal"}),L.length===0)return M;let H=L.map(ee=>M.find(ge=>ge.value.toLowerCase()===ee.type)).filter(ee=>!!ee),ue=M.filter(ee=>!H.find(ge=>ge.value===ee.value));return[...H,...ue]},[S,L,v,f]),G=[{label:n("entitiesClipboard"),onClick:()=>e(Vr("entities")),shouldShow:g&&S4(n("entitiesClipboard"),i)},{label:i?`${n("knowledgeAssist")}: ${i}`:n("knowledgeAssist"),onClick:()=>e(Vr("knowledgeAssist")),shouldShow:m}].filter(I=>I.shouldShow).filter(()=>!f),D=(0,Ut.useCallback)((0,cP.default)((I,M)=>{e(Si({query:I,type:M,tags:["search-overlay"],size:f?50:20}))},y4),[f]),B=(0,Ut.useCallback)((I,M)=>{switch(M.type){case"IMAGE":t.send(ov,{suggestion:M});break;default:t.send(yr,{text:I,suggestion:M})}e(Rn(!1))},[e]),j=I=>{vr(I.text),e(kn({name:"entity copied",data:{entity:I,type:"copy"}})),e(Rn(!1))},le=I=>{t.send(yr,{text:I,suggestion:{source:"knowledge-assist",text:I}}),e(kn({name:"answer used",data:{originalText:I},options:{includeConversationData:!0}})),s(""),a&&e(ra(a)),e(Vr("search")),e(Rn(!1))};function Y(I){return M=>{r?window.confirm(n("warning"))&&(I(M),o(!1)):I(M)}}return(0,Ut.useEffect)(()=>{i?D(i,f):e(Vf())},[i,f]),(0,Ut.useEffect)(()=>{p&&e(Su())},[p]),zC(x,()=>e(Rn(!0))),!y||!c?null:(0,pt.jsxs)(We,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:s,onChangeOpen:Y(I=>e(Rn(I))),onChangeType:I=>d(I),onChangePage:Y(I=>e(Vr(I))),selectedType:f,search:i,page:l,isOpen:R,types:O,updateDeps:[C],children:[(0,pt.jsxs)(We.Page,{id:"search",children:[i.length===0&&(0,pt.jsx)(uP,{types:L,commands:G,onClick:B}),i.length>0&&(0,pt.jsxs)(Ut.Fragment,{children:[G.length>0&&(0,pt.jsx)(We.List,{heading:n("commands"),children:G.map((I,M)=>(0,pt.jsx)(We.ListItem,{closeOnSelect:!1,onClick:I.onClick,id:`commands-${M}`,children:I.label},I.label))}),O.map(({value:I,label:M,list:H,lineClamp:ue,listOrientation:ee})=>(0,pt.jsx)(We.List,{heading:M,orientation:ee==="horizontal"?"horizontal":"vertical",onShowAll:()=>d(I),hasMore:!f&&T[I.toLowerCase()]>O0(H,I,f).length,children:O0(H,I,f).map(ge=>(0,pt.jsx)(We.ListItem,{id:`${I}-${ge.id}`,closeOnSelect:!1,lineClamp:ue,onClick:()=>B(ge.text,ge),description:I!=="IMAGE"?ge.title&&ge.text:void 0,extra:h&&(0,pt.jsx)(We.ListItemActions,{children:(0,pt.jsx)(Xp,{context:i,source:"search",suggestion:ge})}),children:I==="IMAGE"?(0,pt.jsx)(We.Image,{title:ge.title||ge.text,src:ge.image}):ge.title||ge.text},`${ge.id}-${ge.text}`))},I))]})]}),(0,pt.jsx)(We.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:Y(()=>{e(Vr("search"))}),children:(0,pt.jsx)(VC,{onCopy:j})}),(0,pt.jsx)(We.Page,{id:"knowledgeAssist",title:n("knowledgeAssist"),onDismiss:Y(()=>{a&&e(ra(a)),e(Vr("search"))}),children:(0,pt.jsx)(Nk,{threadId:a,onNewThreadId:I=>u(I),question:i,onUse:le,onResetQuestion:()=>{a&&e(ra(a)),s(""),u(null)}})})]})},dP=w4;var oc=w(k()),b4=()=>{let e=q("showSearch"),t=q("isEmbedded");return(0,oc.jsxs)(fP.Fragment,{children:[e&&(0,oc.jsx)(dP,{}),t&&(0,oc.jsx)(ZT,{})]})},pP=b4;var yP=w(Ie());var Jp=w(k()),mP=({className:e})=>(0,Jp.jsx)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 512 512",xmlSpace:"preserve",className:e,children:(0,Jp.jsx)("g",{children:(0,Jp.jsx)("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
|
|
77
|
+
`)}var $D=({content:e,useLabel:t,copyLabel:n,onCopy:r,onUse:o})=>{let i=_("Markdown",yk),s=(0,Qr.useRef)(null),[a,u]=(0,Qr.useState)(null),l=(0,Qr.useMemo)(()=>{let h=we.parse(WD(e));return ck.sanitize(h.toString()).replaceAll("</code>",`${VD(i.copyIcon)}</code>`).replaceAll('<a href="','<a target="_blank" rel="noreferrer noopener" href="')},[e]),c=h=>{var v;let g=h.target,m=!!((v=s.current)!=null&&v.querySelector("code"));if(["A","BUTTON"].includes(g.tagName)){u(null);return}a||m&&g.tagName!=="CODE"||!m&&g!==s.current||(g.addEventListener("mouseleave",()=>u(null),{once:!0}),u(g))},f=()=>{if(!a)return;u(null);let h=a.querySelector("button");h&&(ua(h,i.fadeup),r==null||r(r0(a)))},d=h=>{let g=h.target;if(g.tagName==="A"){h.stopPropagation();return}"copyIcon"in g.dataset&&(ua(g,i.fadeup),r==null||r(r0(g.parentElement)))},p=()=>{!a||!o||(u(null),o(r0(a)))},y=h=>{if(h===null)return;let g=h.getBoundingClientRect();g.left<0?h.style.transform=`translateX(${-g.left+2}px)`:g.right>window.innerWidth&&(h.style.transform=`translateX(${window.innerWidth-g.right-2}px)`)};return(0,Xn.jsxs)(Qr.Fragment,{children:[a&&(r||o)&&(0,Xn.jsxs)(fa,{triggerRef:{current:a},className:i.popover,parentNode:a,children:[(0,Xn.jsxs)("div",{className:i.options,ref:y,children:[r&&(0,Xn.jsx)("button",{type:"button",className:i.option,onClick:f,children:n}),o&&(0,Xn.jsxs)(Qr.Fragment,{children:[(0,Xn.jsx)("div",{className:i.divider}),(0,Xn.jsx)("button",{type:"button",className:i.option,onClick:p,children:t})]})]}),(0,Xn.jsx)("div",{className:i.arrow})]}),(0,Xn.jsx)("div",{ref:s,"data-testid":"widget-markdown-content",className:i.root,dangerouslySetInnerHTML:{__html:l},onMouseOver:c,onClick:d})]})},ga=$D;var kt=w(k()),KD=({threadId:e,onNewThreadId:t,onUse:n,onResetQuestion:r,question:o})=>{var g;let[i,s]=Di.default.useState(""),{setSelected:a}=zo(),u=(0,Di.useRef)(null),l=_("KnowledgeSearchStyles",YC),c=re(Fv),f=ce(),d=(g=V(vu(e!=null?e:-1)))!=null?g:[],p=Gr(m=>xu({input:m,threadId:e,onNewThreadId:v=>t(v)}),{onSuccess(m){f(kn({name:"knowledge assist question answered",data:{question:i||o,sources:m.answer.sources,answer:m.answer.answer,isFollowUpQuestion:d.length>=1},options:{includeConversationData:!0}})),a(`knowledge-assist-${d.length}`),s("")}}),y=m=>P(void 0,null,function*(){m.preventDefault(),m.stopPropagation(),i!==""&&p.call(i)}),h=(m,v)=>{f(kn({name:"knowledge assist source viewed",data:{question:v,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return(0,Di.useEffect)(()=>{var m;o&&p.state==="idle"?p.call(o):(m=u.current)==null||m.focus()},[u,p.state]),(0,Di.useEffect)(()=>{u.current&&u.current.scrollIntoView({behavior:"smooth"})},[u,d]),(0,kt.jsxs)("div",{className:l.root,children:[d.length>0&&(0,kt.jsx)("div",{className:l.alignRight,children:(0,kt.jsx)(We.Button,{onClick:r,children:c("reset")})}),d.map(({question:m,answer:v},x)=>(0,kt.jsx)(We.List,{children:(0,kt.jsx)(We.ListItem,{id:`knowledge-assist-${x}`,"data-testid":"knowledge-search-answer",description:(0,kt.jsx)(ga,{content:v.answer}),closeOnSelect:!0,onClick:()=>n(v.answer),onSourceClick:S=>h(S,m),sources:v.sources,styles:{title:l.question,description:l.answer},extra:(0,kt.jsx)("div",{className:l.listItemFeedback,children:(0,kt.jsx)(Ii,{feedbackText:v.answer,feedbackType:"knowledge-assist-answer",eventName:"knowledge assist feedback",eventData:b({question:m,isAgent:o!==m,isFollowUpQuestion:d.length>1},v)})}),children:m})},`${v.answer}_${x}`)),p.state==="loading"&&(0,kt.jsx)("p",{className:l.status,children:c("loading")}),p.state==="error"&&(0,kt.jsx)("p",{className:l.status,children:c("error")}),(0,kt.jsxs)("form",{className:l.form,onSubmit:y,children:[(0,kt.jsx)("input",{ref:u,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:i,onFocus:()=>{a(void 0)},onChange:m=>{a(void 0),s(m.target.value)}}),(0,kt.jsx)("button",{type:"submit",className:l.submit,disabled:p.state==="loading",children:(0,kt.jsx)(GC,{})})]})]})},Nk=KD;var o0=w(k()),Cp=e=>(0,o0.jsx)("svg",A(b({xmlns:"http://www.w3.org/2000/svg",height:"16",width:"14",viewBox:"0 0 448 512"},e),{children:(0,o0.jsx)("path",{fill:"currentColor",d:"M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"})}));var Wu={};Lt(Wu,{enUS:()=>qD,nlNL:()=>GD});var qD={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],giveFeedback:[{type:0,value:"Give feedback"}],answer:[{type:0,value:"Answer"}]},GD={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],giveFeedback:[{type:0,value:"Geef feedback"}],answer:[{type:0,value:"Antwoord"}]};var br=w(W());var N=w(W(),1),ka=w(W(),1);function Rp(){return typeof window!="undefined"}function wr(e){return _k(e)?(e.nodeName||"").toLowerCase():"#document"}function zt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Zn(e){var t;return(t=(_k(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function _k(e){return Rp()?e instanceof Node||e instanceof zt(e).Node:!1}function Me(e){return Rp()?e instanceof Element||e instanceof zt(e).Element:!1}function Xe(e){return Rp()?e instanceof HTMLElement||e instanceof zt(e).HTMLElement:!1}function kp(e){return!Rp()||typeof ShadowRoot=="undefined"?!1:e instanceof ShadowRoot||e instanceof zt(e).ShadowRoot}function ha(e){let{overflow:t,overflowX:n,overflowY:r,display:o}=tn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function Dk(e){return["table","td","th"].includes(wr(e))}function $u(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch(n){return!1}})}function Pp(e){let t=ya(),n=Me(e)?tn(e):e;return["transform","translate","scale","rotate","perspective"].some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function Fk(e){let t=Qn(e);for(;Xe(t)&&!Jn(t);){if(Pp(t))return t;if($u(t))return null;t=Qn(t)}return null}function ya(){return typeof CSS=="undefined"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Jn(e){return["html","body","#document"].includes(wr(e))}function tn(e){return zt(e).getComputedStyle(e)}function Ku(e){return Me(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Qn(e){if(wr(e)==="html")return e;let t=e.assignedSlot||e.parentNode||kp(e)&&e.host||Zn(e);return kp(t)?t.host:t}function Hk(e){let t=Qn(e);return Jn(t)?e.ownerDocument?e.ownerDocument.body:e.body:Xe(t)&&ha(t)?t:Hk(t)}function pn(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);let o=Hk(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=zt(o);if(i){let a=Ap(s);return t.concat(s,s.visualViewport||[],ha(o)?o:[],a&&n?pn(a):[])}return t.concat(o,pn(o,[],n))}function Ap(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function jo(e){let t=e.activeElement;for(;((n=t)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;t=t.shadowRoot.activeElement}return t}function Bt(e,t){if(!e||!t)return!1;let n=t.getRootNode==null?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&kp(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function zk(){let e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform}function s0(){let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:r}=t;return n+"/"+r}).join(" "):navigator.userAgent}function Bk(e){return e.mozInputSource===0&&e.isTrusted?!0:i0()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Uk(e){return YD()?!1:!i0()&&e.width===0&&e.height===0||i0()&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function jk(){return/apple/i.test(navigator.vendor)}function i0(){let e=/android/i;return e.test(zk())||e.test(s0())}function YD(){return s0().includes("jsdom/")}function va(e,t){let n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function Vk(e){return"nativeEvent"in e}function Wk(e){return e.matches("html,body")}function Rt(e){return(e==null?void 0:e.ownerDocument)||document}function Ip(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function Vo(e){return"composedPath"in e?e.composedPath()[0]:e.target}var XD="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function a0(e){return Xe(e)&&e.matches(XD)}function Lp(e){e.preventDefault(),e.stopPropagation()}function $k(e){return e?e.getAttribute("role")==="combobox"&&a0(e):!1}var xa=Math.min,Zr=Math.max,Gu=Math.round,Yu=Math.floor,er=e=>({x:e,y:e}),QD={left:"right",right:"left",bottom:"top",top:"bottom"},ZD={start:"end",end:"start"};function l0(e,t,n){return Zr(e,xa(t,n))}function Xu(e,t){return typeof e=="function"?e(t):e}function Wo(e){return e.split("-")[0]}function Qu(e){return e.split("-")[1]}function u0(e){return e==="x"?"y":"x"}function c0(e){return e==="y"?"height":"width"}function Fi(e){return["top","bottom"].includes(Wo(e))?"y":"x"}function d0(e){return u0(Fi(e))}function Kk(e,t,n){n===void 0&&(n=!1);let r=Qu(e),o=d0(e),i=c0(o),s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=qu(s)),[s,qu(s)]}function qk(e){let t=qu(e);return[Op(e),t,Op(t)]}function Op(e){return e.replace(/start|end/g,t=>ZD[t])}function JD(e,t,n){let r=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?i:s;default:return[]}}function Gk(e,t,n,r){let o=Qu(e),i=JD(Wo(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(Op)))),i}function qu(e){return e.replace(/left|right|bottom|top/g,t=>QD[t])}function e3(e){return b({top:0,right:0,bottom:0,left:0},e)}function Yk(e){return typeof e!="number"?e3(e):{top:e,right:e,bottom:e,left:e}}function Hi(e){let{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}var rn=w(k(),1);var t3=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],Mp=t3.join(","),Qk=typeof Element=="undefined",Sa=Qk?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Np=!Qk&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e==null?void 0:e.ownerDocument},_p=function e(t,n){var r;n===void 0&&(n=!0);var o=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"inert"),i=o===""||o==="true",s=i||n&&t&&e(t.parentNode);return s},n3=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},r3=function(t,n,r){if(_p(t))return[];var o=Array.prototype.slice.apply(t.querySelectorAll(Mp));return n&&Sa.call(t,Mp)&&o.unshift(t),o=o.filter(r),o},o3=function e(t,n,r){for(var o=[],i=Array.from(t);i.length;){var s=i.shift();if(!_p(s,!1))if(s.tagName==="SLOT"){var a=s.assignedElements(),u=a.length?a:s.children,l=e(u,!0,r);r.flatten?o.push.apply(o,l):o.push({scopeParent:s,candidates:l})}else{var c=Sa.call(s,Mp);c&&r.filter(s)&&(n||!t.includes(s))&&o.push(s);var f=s.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(s),d=!_p(f,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(s));if(f&&d){var p=e(f===!0?s.children:f.children,!0,r);r.flatten?o.push.apply(o,p):o.push({scopeParent:s,candidates:p})}else i.unshift.apply(i,s.children)}}return o},Zk=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Jk=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||n3(t))&&!Zk(t)?0:t.tabIndex},i3=function(t,n){var r=Jk(t);return r<0&&n&&!Zk(t)?0:r},s3=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},eR=function(t){return t.tagName==="INPUT"},a3=function(t){return eR(t)&&t.type==="hidden"},l3=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},u3=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},c3=function(t){if(!t.name)return!0;var n=t.form||Np(t),r=function(a){return n.querySelectorAll('input[type="radio"][name="'+a+'"]')},o;if(typeof window!="undefined"&&typeof window.CSS!="undefined"&&typeof window.CSS.escape=="function")o=r(window.CSS.escape(t.name));else try{o=r(t.name)}catch(s){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",s.message),!1}var i=u3(o,t.form);return!i||i===t},d3=function(t){return eR(t)&&t.type==="radio"},f3=function(t){return d3(t)&&!c3(t)},p3=function(t){var n,r=t&&Np(t),o=(n=r)===null||n===void 0?void 0:n.host,i=!1;if(r&&r!==t){var s,a,u;for(i=!!((s=o)!==null&&s!==void 0&&(a=s.ownerDocument)!==null&&a!==void 0&&a.contains(o)||t!=null&&(u=t.ownerDocument)!==null&&u!==void 0&&u.contains(t));!i&&o;){var l,c,f;r=Np(o),o=(l=r)===null||l===void 0?void 0:l.host,i=!!((c=o)!==null&&c!==void 0&&(f=c.ownerDocument)!==null&&f!==void 0&&f.contains(o))}}return i},Xk=function(t){var n=t.getBoundingClientRect(),r=n.width,o=n.height;return r===0&&o===0},m3=function(t,n){var r=n.displayCheck,o=n.getShadowRoot;if(getComputedStyle(t).visibility==="hidden")return!0;var i=Sa.call(t,"details>summary:first-of-type"),s=i?t.parentElement:t;if(Sa.call(s,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="legacy-full"){if(typeof o=="function"){for(var a=t;t;){var u=t.parentElement,l=Np(t);if(u&&!u.shadowRoot&&o(u)===!0)return Xk(t);t.assignedSlot?t=t.assignedSlot:!u&&l!==t.ownerDocument?t=l.host:t=u}t=a}if(p3(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return Xk(t);return!1},g3=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var o=n.children.item(r);if(o.tagName==="LEGEND")return Sa.call(n,"fieldset[disabled] *")?!0:!o.contains(t)}return!0}n=n.parentElement}return!1},h3=function(t,n){return!(n.disabled||_p(n)||a3(n)||m3(n,t)||l3(n)||g3(n))},f0=function(t,n){return!(f3(n)||Jk(n)<0||!h3(t,n))},y3=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},v3=function e(t){var n=[],r=[];return t.forEach(function(o,i){var s=!!o.scopeParent,a=s?o.scopeParent:o,u=i3(a,s),l=s?e(o.candidates):a;u===0?s?n.push.apply(n,l):n.push(a):r.push({documentOrder:i,tabIndex:u,item:o,isScope:s,content:l})}),r.sort(s3).reduce(function(o,i){return i.isScope?o.push.apply(o,i.content):o.push(i.content),o},[]).concat(n)},Zu=function(t,n){n=n||{};var r;return n.getShadowRoot?r=o3([t],n.includeContainer,{filter:f0.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:y3}):r=r3(t,n.includeContainer,f0.bind(null,n)),v3(r)};var tR=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return Sa.call(t,Mp)===!1?!1:f0(n,t)};var P0=w(Bs(),1);function nR(e,t,n){let{reference:r,floating:o}=e,i=Fi(t),s=d0(t),a=c0(s),u=Wo(t),l=i==="y",c=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,d=r[a]/2-o[a]/2,p;switch(u){case"top":p={x:c,y:r.y-o.height};break;case"bottom":p={x:c,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Qu(t)){case"start":p[s]-=d*(n&&l?-1:1);break;case"end":p[s]+=d*(n&&l?-1:1);break}return p}var rR=(e,t,n)=>P(void 0,null,function*(){let{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,a=i.filter(Boolean),u=yield s.isRTL==null?void 0:s.isRTL(t),l=yield s.getElementRects({reference:e,floating:t,strategy:o}),{x:c,y:f}=nR(l,r,u),d=r,p={},y=0;for(let h=0;h<a.length;h++){let{name:g,fn:m}=a[h],{x:v,y:x,data:S,reset:C}=yield m({x:c,y:f,initialPlacement:r,placement:d,strategy:o,middlewareData:p,rects:l,platform:s,elements:{reference:e,floating:t}});c=v!=null?v:c,f=x!=null?x:f,p=A(b({},p),{[g]:b(b({},p[g]),S)}),C&&y<=50&&(y++,typeof C=="object"&&(C.placement&&(d=C.placement),C.rects&&(l=C.rects===!0?yield s.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:c,y:f}=nR(l,d,u)),h=-1)}return{x:c,y:f,placement:d,strategy:o,middlewareData:p}});function p0(e,t){return P(this,null,function*(){var n;t===void 0&&(t={});let{x:r,y:o,platform:i,rects:s,elements:a,strategy:u}=e,{boundary:l="clippingAncestors",rootBoundary:c="viewport",elementContext:f="floating",altBoundary:d=!1,padding:p=0}=Xu(t,e),y=Yk(p),g=a[d?f==="floating"?"reference":"floating":f],m=Hi(yield i.getClippingRect({element:(n=yield i.isElement==null?void 0:i.isElement(g))==null||n?g:g.contextElement||(yield i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:l,rootBoundary:c,strategy:u})),v=f==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,x=yield i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating),S=(yield i.isElement==null?void 0:i.isElement(x))?(yield i.getScale==null?void 0:i.getScale(x))||{x:1,y:1}:{x:1,y:1},C=Hi(i.convertOffsetParentRelativeRectToViewportRelativeRect?yield i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:x,strategy:u}):v);return{top:(m.top-C.top+y.top)/S.y,bottom:(C.bottom-m.bottom+y.bottom)/S.y,left:(m.left-C.left+y.left)/S.x,right:(C.right-m.right+y.right)/S.x}})}var oR=function(e){return e===void 0&&(e={}),{name:"flip",options:e,fn(n){return P(this,null,function*(){var r,o;let{placement:i,middlewareData:s,rects:a,initialPlacement:u,platform:l,elements:c}=n,Y=Xu(e,n),{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:p,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:g=!0}=Y,m=te(Y,["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","fallbackAxisSideDirection","flipAlignment"]);if((r=s.arrow)!=null&&r.alignmentOffset)return{};let v=Wo(i),x=Fi(u),S=Wo(u)===u,C=yield l.isRTL==null?void 0:l.isRTL(c.floating),T=p||(S||!g?[qu(u)]:qk(u)),R=h!=="none";!p&&R&&T.push(...Gk(u,g,h,C));let L=[u,...T],O=yield p0(n,m),G=[],D=((o=s.flip)==null?void 0:o.overflows)||[];if(f&&G.push(O[v]),d){let J=Kk(i,a,C);G.push(O[J[0]],O[J[1]])}if(D=[...D,{placement:i,overflows:G}],!G.every(J=>J<=0)){var B,j;let J=(((B=s.flip)==null?void 0:B.index)||0)+1,X=L[J];if(X)return{data:{index:J,overflows:D},reset:{placement:X}};let U=(j=D.filter(I=>I.overflows[0]<=0).sort((I,M)=>I.overflows[1]-M.overflows[1])[0])==null?void 0:j.placement;if(!U)switch(y){case"bestFit":{var le;let I=(le=D.filter(M=>{if(R){let H=Fi(M.placement);return H===x||H==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(H=>H>0).reduce((H,ue)=>H+ue,0)]).sort((M,H)=>M[1]-H[1])[0])==null?void 0:le[0];I&&(U=I);break}case"initialPlacement":U=u;break}if(i!==U)return{reset:{placement:U}}}return{}})}}};function x3(e,t){return P(this,null,function*(){let{placement:n,platform:r,elements:o}=e,i=yield r.isRTL==null?void 0:r.isRTL(o.floating),s=Wo(n),a=Qu(n),u=Fi(n)==="y",l=["left","top"].includes(s)?-1:1,c=i&&u?-1:1,f=Xu(t,e),{mainAxis:d,crossAxis:p,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof y=="number"&&(p=a==="end"?y*-1:y),u?{x:p*c,y:d*l}:{x:d*l,y:p*c}})}var iR=function(e){return e===void 0&&(e=0),{name:"offset",options:e,fn(n){return P(this,null,function*(){var r,o;let{x:i,y:s,placement:a,middlewareData:u}=n,l=yield x3(n,e);return a===((r=u.offset)==null?void 0:r.placement)&&(o=u.arrow)!=null&&o.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:A(b({},l),{placement:a})}})}}},sR=function(e){return e===void 0&&(e={}),{name:"shift",options:e,fn(n){return P(this,null,function*(){let{x:r,y:o,placement:i}=n,m=Xu(e,n),{mainAxis:s=!0,crossAxis:a=!1,limiter:u={fn:v=>{let{x,y:S}=v;return{x,y:S}}}}=m,l=te(m,["mainAxis","crossAxis","limiter"]),c={x:r,y:o},f=yield p0(n,l),d=Fi(Wo(i)),p=u0(d),y=c[p],h=c[d];if(s){let v=p==="y"?"top":"left",x=p==="y"?"bottom":"right",S=y+f[v],C=y-f[x];y=l0(S,y,C)}if(a){let v=d==="y"?"top":"left",x=d==="y"?"bottom":"right",S=h+f[v],C=h-f[x];h=l0(S,h,C)}let g=u.fn(A(b({},n),{[p]:y,[d]:h}));return A(b({},g),{data:{x:g.x-r,y:g.y-o,enabled:{[p]:s,[d]:a}}})})}}};function uR(e){let t=tn(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,o=Xe(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=Gu(n)!==i||Gu(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function g0(e){return Me(e)?e:e.contextElement}function wa(e){let t=g0(e);if(!Xe(t))return er(1);let n=t.getBoundingClientRect(),{width:r,height:o,$:i}=uR(t),s=(i?Gu(n.width):n.width)/r,a=(i?Gu(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var S3=er(0);function cR(e){let t=zt(e);return!ya()||!t.visualViewport?S3:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function w3(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==zt(e)?!1:t}function zi(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let o=e.getBoundingClientRect(),i=g0(e),s=er(1);t&&(r?Me(r)&&(s=wa(r)):s=wa(e));let a=w3(i,n,r)?cR(i):er(0),u=(o.left+a.x)/s.x,l=(o.top+a.y)/s.y,c=o.width/s.x,f=o.height/s.y;if(i){let d=zt(i),p=r&&Me(r)?zt(r):r,y=d,h=Ap(y);for(;h&&r&&p!==y;){let g=wa(h),m=h.getBoundingClientRect(),v=tn(h),x=m.left+(h.clientLeft+parseFloat(v.paddingLeft))*g.x,S=m.top+(h.clientTop+parseFloat(v.paddingTop))*g.y;u*=g.x,l*=g.y,c*=g.x,f*=g.y,u+=x,l+=S,y=zt(h),h=Ap(y)}}return Hi({width:c,height:f,x:u,y:l})}function h0(e,t){let n=Ku(e).scrollLeft;return t?t.left+n:zi(Zn(e)).left+n}function dR(e,t,n){n===void 0&&(n=!1);let r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:h0(e,r)),i=r.top+t.scrollTop;return{x:o,y:i}}function b3(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e,i=o==="fixed",s=Zn(r),a=t?$u(t.floating):!1;if(r===s||a&&i)return n;let u={scrollLeft:0,scrollTop:0},l=er(1),c=er(0),f=Xe(r);if((f||!f&&!i)&&((wr(r)!=="body"||ha(s))&&(u=Ku(r)),Xe(r))){let p=zi(r);l=wa(r),c.x=p.x+r.clientLeft,c.y=p.y+r.clientTop}let d=s&&!f&&!i?dR(s,u,!0):er(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-u.scrollLeft*l.x+c.x+d.x,y:n.y*l.y-u.scrollTop*l.y+c.y+d.y}}function E3(e){return Array.from(e.getClientRects())}function T3(e){let t=Zn(e),n=Ku(e),r=e.ownerDocument.body,o=Zr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Zr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),s=-n.scrollLeft+h0(e),a=-n.scrollTop;return tn(r).direction==="rtl"&&(s+=Zr(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}function C3(e,t){let n=zt(e),r=Zn(e),o=n.visualViewport,i=r.clientWidth,s=r.clientHeight,a=0,u=0;if(o){i=o.width,s=o.height;let l=ya();(!l||l&&t==="fixed")&&(a=o.offsetLeft,u=o.offsetTop)}return{width:i,height:s,x:a,y:u}}function k3(e,t){let n=zi(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Xe(e)?wa(e):er(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,u=o*i.x,l=r*i.y;return{width:s,height:a,x:u,y:l}}function aR(e,t,n){let r;if(t==="viewport")r=C3(e,n);else if(t==="document")r=T3(Zn(e));else if(Me(t))r=k3(t,n);else{let o=cR(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Hi(r)}function fR(e,t){let n=Qn(e);return n===t||!Me(n)||Jn(n)?!1:tn(n).position==="fixed"||fR(n,t)}function R3(e,t){let n=t.get(e);if(n)return n;let r=pn(e,[],!1).filter(a=>Me(a)&&wr(a)!=="body"),o=null,i=tn(e).position==="fixed",s=i?Qn(e):e;for(;Me(s)&&!Jn(s);){let a=tn(s),u=Pp(s);!u&&a.position==="fixed"&&(o=null),(i?!u&&!o:!u&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||ha(s)&&!u&&fR(e,s))?r=r.filter(c=>c!==s):o=a,s=Qn(s)}return t.set(e,r),r}function P3(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e,s=[...n==="clippingAncestors"?$u(t)?[]:R3(t,this._c):[].concat(n),r],a=s[0],u=s.reduce((l,c)=>{let f=aR(t,c,o);return l.top=Zr(f.top,l.top),l.right=xa(f.right,l.right),l.bottom=xa(f.bottom,l.bottom),l.left=Zr(f.left,l.left),l},aR(t,a,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function A3(e){let{width:t,height:n}=uR(e);return{width:t,height:n}}function I3(e,t,n){let r=Xe(t),o=Zn(t),i=n==="fixed",s=zi(e,!0,i,t),a={scrollLeft:0,scrollTop:0},u=er(0);if(r||!r&&!i)if((wr(t)!=="body"||ha(o))&&(a=Ku(t)),r){let d=zi(t,!0,i,t);u.x=d.x+t.clientLeft,u.y=d.y+t.clientTop}else o&&(u.x=h0(o));let l=o&&!r&&!i?dR(o,a):er(0),c=s.left+a.scrollLeft-u.x-l.x,f=s.top+a.scrollTop-u.y-l.y;return{x:c,y:f,width:s.width,height:s.height}}function m0(e){return tn(e).position==="static"}function lR(e,t){if(!Xe(e)||tn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Zn(e)===n&&(n=n.ownerDocument.body),n}function pR(e,t){let n=zt(e);if($u(e))return n;if(!Xe(e)){let o=Qn(e);for(;o&&!Jn(o);){if(Me(o)&&!m0(o))return o;o=Qn(o)}return n}let r=lR(e,t);for(;r&&Dk(r)&&m0(r);)r=lR(r,t);return r&&Jn(r)&&m0(r)&&!Pp(r)?n:r||Fk(e)||n}var L3=function(e){return P(this,null,function*(){let t=this.getOffsetParent||pR,n=this.getDimensions,r=yield n(e.floating);return{reference:I3(e.reference,yield t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}})};function O3(e){return tn(e).direction==="rtl"}var y0={convertOffsetParentRelativeRectToViewportRelativeRect:b3,getDocumentElement:Zn,getClippingRect:P3,getOffsetParent:pR,getElementRects:L3,getClientRects:E3,getDimensions:A3,getScale:wa,isElement:Me,isRTL:O3};function mR(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function M3(e,t){let n=null,r,o=Zn(e);function i(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function s(a,u){a===void 0&&(a=!1),u===void 0&&(u=1),i();let l=e.getBoundingClientRect(),{left:c,top:f,width:d,height:p}=l;if(a||t(),!d||!p)return;let y=Yu(f),h=Yu(o.clientWidth-(c+d)),g=Yu(o.clientHeight-(f+p)),m=Yu(c),x={rootMargin:-y+"px "+-h+"px "+-g+"px "+-m+"px",threshold:Zr(0,xa(1,u))||1},S=!0;function C(T){let R=T[0].intersectionRatio;if(R!==u){if(!S)return s();R?s(!1,R):r=setTimeout(()=>{s(!1,1e-7)},1e3)}R===1&&!mR(l,e.getBoundingClientRect())&&s(),S=!1}try{n=new IntersectionObserver(C,A(b({},x),{root:o.ownerDocument}))}catch(T){n=new IntersectionObserver(C,x)}n.observe(e)}return s(!0),i}function Dp(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,l=g0(e),c=o||i?[...l?pn(l):[],...pn(t)]:[];c.forEach(m=>{o&&m.addEventListener("scroll",n,{passive:!0}),i&&m.addEventListener("resize",n)});let f=l&&a?M3(l,n):null,d=-1,p=null;s&&(p=new ResizeObserver(m=>{let[v]=m;v&&v.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var x;(x=p)==null||x.observe(t)})),n()}),l&&!u&&p.observe(l),p.observe(t));let y,h=u?zi(e):null;u&&g();function g(){let m=zi(e);h&&!mR(h,m)&&n(),h=m,y=requestAnimationFrame(g)}return n(),()=>{var m;c.forEach(v=>{o&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),f==null||f(),(m=p)==null||m.disconnect(),p=null,u&&cancelAnimationFrame(y)}}var gR=iR;var hR=sR,yR=oR;var Fp=(e,t,n)=>{let r=new Map,o=b({platform:y0},n),i=A(b({},o.platform),{_c:r});return rR(e,t,A(b({},o),{platform:i}))};var Je=w(W(),1),Bp=w(W(),1),SR=w(Bs(),1);var Hp=typeof document!="undefined"?Bp.useLayoutEffect:Bp.useEffect;function zp(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!zp(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){let i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!zp(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function wR(e){return typeof window=="undefined"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function vR(e,t){let n=wR(e);return Math.round(t*n)/n}function v0(e){let t=Je.useRef(e);return Hp(()=>{t.current=e}),t}function bR(e){e===void 0&&(e={});let{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:a=!0,whileElementsMounted:u,open:l}=e,[c,f]=Je.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[d,p]=Je.useState(r);zp(d,r)||p(r);let[y,h]=Je.useState(null),[g,m]=Je.useState(null),v=Je.useCallback(U=>{U!==T.current&&(T.current=U,h(U))},[]),x=Je.useCallback(U=>{U!==R.current&&(R.current=U,m(U))},[]),S=i||y,C=s||g,T=Je.useRef(null),R=Je.useRef(null),L=Je.useRef(c),O=u!=null,G=v0(u),D=v0(o),B=v0(l),j=Je.useCallback(()=>{if(!T.current||!R.current)return;let U={placement:t,strategy:n,middleware:d};D.current&&(U.platform=D.current),Fp(T.current,R.current,U).then(I=>{let M=A(b({},I),{isPositioned:B.current!==!1});le.current&&!zp(L.current,M)&&(L.current=M,SR.flushSync(()=>{f(M)}))})},[d,t,n,D,B]);Hp(()=>{l===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,f(U=>A(b({},U),{isPositioned:!1})))},[l]);let le=Je.useRef(!1);Hp(()=>(le.current=!0,()=>{le.current=!1}),[]),Hp(()=>{if(S&&(T.current=S),C&&(R.current=C),S&&C){if(G.current)return G.current(S,C,j);j()}},[S,C,j,G,O]);let Y=Je.useMemo(()=>({reference:T,floating:R,setReference:v,setFloating:x}),[v,x]),J=Je.useMemo(()=>({reference:S,floating:C}),[S,C]),X=Je.useMemo(()=>{let U={position:n,left:0,top:0};if(!J.floating)return U;let I=vR(J.floating,c.x),M=vR(J.floating,c.y);return a?b(A(b({},U),{transform:"translate("+I+"px, "+M+"px)"}),wR(J.floating)>=1.5&&{willChange:"transform"}):{position:n,left:I,top:M}},[n,a,J.floating,c.x,c.y]);return Je.useMemo(()=>A(b({},c),{update:j,refs:Y,elements:J,floatingStyles:X}),[c,j,Y,J,X])}var Up=(e,t)=>A(b({},gR(e)),{options:[e,t]}),x0=(e,t)=>A(b({},hR(e)),{options:[e,t]});var S0=(e,t)=>A(b({},yR(e)),{options:[e,t]});function tc(e){return N.useMemo(()=>e.every(t=>t==null)?null:t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})},e)}var HR=b({},N),N3=HR.useInsertionEffect,_3=N3||(e=>e());function On(e){let t=N.useRef(()=>{});return _3(()=>{t.current=e}),N.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}var D3="ArrowUp",F3="ArrowDown",H3="ArrowLeft",z3="ArrowRight";var nn=typeof document!="undefined"?ka.useLayoutEffect:ka.useEffect;var B3=[H3,z3],U3=[D3,F3],UW=[...B3,...U3];var ER=!1,j3=0,TR=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+j3++;function V3(){let[e,t]=N.useState(()=>ER?TR():void 0);return nn(()=>{e==null&&t(TR())},[]),N.useEffect(()=>{ER=!0},[]),e}var W3=HR.useId,A0=W3||V3;function $3(){let e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(o=>o(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,((r=e.get(t))==null?void 0:r.filter(o=>o!==n))||[])}}}var K3=N.createContext(null),q3=N.createContext(null),I0=()=>{var e;return((e=N.useContext(K3))==null?void 0:e.id)||null},$p=()=>N.useContext(q3);function Ca(e){return"data-floating-ui-"+e}function Ta(e){let t=(0,ka.useRef)(e);return nn(()=>{t.current=e}),t}var CR=Ca("safe-polygon");function w0(e,t,n){return n&&!va(n)?0:typeof e=="number"?e:e==null?void 0:e[t]}function zR(e,t){t===void 0&&(t={});let{open:n,onOpenChange:r,dataRef:o,events:i,elements:s}=e,{enabled:a=!0,delay:u=0,handleClose:l=null,mouseOnly:c=!1,restMs:f=0,move:d=!0}=t,p=$p(),y=I0(),h=Ta(l),g=Ta(u),m=Ta(n),v=N.useRef(),x=N.useRef(-1),S=N.useRef(),C=N.useRef(-1),T=N.useRef(!0),R=N.useRef(!1),L=N.useRef(()=>{}),O=N.useRef(!1),G=N.useCallback(()=>{var X;let U=(X=o.current.openEvent)==null?void 0:X.type;return(U==null?void 0:U.includes("mouse"))&&U!=="mousedown"},[o]);N.useEffect(()=>{if(!a)return;function X(U){let{open:I}=U;I||(clearTimeout(x.current),clearTimeout(C.current),T.current=!0,O.current=!1)}return i.on("openchange",X),()=>{i.off("openchange",X)}},[a,i]),N.useEffect(()=>{if(!a||!h.current||!n)return;function X(I){G()&&r(!1,I,"hover")}let U=Rt(s.floating).documentElement;return U.addEventListener("mouseleave",X),()=>{U.removeEventListener("mouseleave",X)}},[s.floating,n,r,a,h,G]);let D=N.useCallback(function(X,U,I){U===void 0&&(U=!0),I===void 0&&(I="hover");let M=w0(g.current,"close",v.current);M&&!S.current?(clearTimeout(x.current),x.current=window.setTimeout(()=>r(!1,X,I),M)):U&&(clearTimeout(x.current),r(!1,X,I))},[g,r]),B=On(()=>{L.current(),S.current=void 0}),j=On(()=>{if(R.current){let X=Rt(s.floating).body;X.style.pointerEvents="",X.removeAttribute(CR),R.current=!1}}),le=On(()=>o.current.openEvent?["click","mousedown"].includes(o.current.openEvent.type):!1);N.useEffect(()=>{if(!a)return;function X(H){if(clearTimeout(x.current),T.current=!1,c&&!va(v.current)||f>0&&!w0(g.current,"open"))return;let ue=w0(g.current,"open",v.current);ue?x.current=window.setTimeout(()=>{m.current||r(!0,H,"hover")},ue):n||r(!0,H,"hover")}function U(H){if(le())return;L.current();let ue=Rt(s.floating);if(clearTimeout(C.current),O.current=!1,h.current&&o.current.floatingContext){n||clearTimeout(x.current),S.current=h.current(A(b({},o.current.floatingContext),{tree:p,x:H.clientX,y:H.clientY,onClose(){j(),B(),le()||D(H,!0,"safe-polygon")}}));let ge=S.current;ue.addEventListener("mousemove",ge),L.current=()=>{ue.removeEventListener("mousemove",ge)};return}(v.current==="touch"?!Bt(s.floating,H.relatedTarget):!0)&&D(H)}function I(H){le()||o.current.floatingContext&&(h.current==null||h.current(A(b({},o.current.floatingContext),{tree:p,x:H.clientX,y:H.clientY,onClose(){j(),B(),le()||D(H)}}))(H))}if(Me(s.domReference)){var M;let H=s.domReference;return n&&H.addEventListener("mouseleave",I),(M=s.floating)==null||M.addEventListener("mouseleave",I),d&&H.addEventListener("mousemove",X,{once:!0}),H.addEventListener("mouseenter",X),H.addEventListener("mouseleave",U),()=>{var ue;n&&H.removeEventListener("mouseleave",I),(ue=s.floating)==null||ue.removeEventListener("mouseleave",I),d&&H.removeEventListener("mousemove",X),H.removeEventListener("mouseenter",X),H.removeEventListener("mouseleave",U)}}},[s,a,e,c,f,d,D,B,j,r,n,m,p,g,h,o,le]),nn(()=>{var X;if(a&&n&&(X=h.current)!=null&&X.__options.blockPointerEvents&&G()){R.current=!0;let I=s.floating;if(Me(s.domReference)&&I){var U;let M=Rt(s.floating).body;M.setAttribute(CR,"");let H=s.domReference,ue=p==null||(U=p.nodesRef.current.find(ee=>ee.id===y))==null||(U=U.context)==null?void 0:U.elements.floating;return ue&&(ue.style.pointerEvents=""),M.style.pointerEvents="none",H.style.pointerEvents="auto",I.style.pointerEvents="auto",()=>{M.style.pointerEvents="",H.style.pointerEvents="",I.style.pointerEvents=""}}}},[a,n,y,s,p,h,G]),nn(()=>{n||(v.current=void 0,O.current=!1,B(),j())},[n,B,j]),N.useEffect(()=>()=>{B(),clearTimeout(x.current),clearTimeout(C.current),j()},[a,s.domReference,B,j]);let Y=N.useMemo(()=>{function X(U){v.current=U.pointerType}return{onPointerDown:X,onPointerEnter:X,onMouseMove(U){let{nativeEvent:I}=U;function M(){!T.current&&!m.current&&r(!0,I,"hover")}c&&!va(v.current)||n||f===0||O.current&&Um(U.movementX,2)+Um(U.movementY,2)<2||(clearTimeout(C.current),v.current==="touch"?M():(O.current=!0,C.current=window.setTimeout(M,f)))}}},[c,r,n,m,f]),J=N.useMemo(()=>({onMouseEnter(){clearTimeout(x.current)},onMouseLeave(X){le()||D(X.nativeEvent,!1)}}),[D,le]);return N.useMemo(()=>a?{reference:Y,floating:J}:{},[a,Y,J])}var kR=0;function ba(e,t){t===void 0&&(t={});let{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(kR);let i=()=>e==null?void 0:e.focus({preventScroll:n});o?i():kR=requestAnimationFrame(i)}function RR(e,t){var n;let r=[],o=(n=e.find(i=>i.id===t))==null?void 0:n.parentId;for(;o;){let i=e.find(s=>s.id===o);o=i==null?void 0:i.parentId,i&&(r=r.concat(i))}return r}function Ju(e,t){let n=e.filter(o=>{var i;return o.parentId===t&&((i=o.context)==null?void 0:i.open)}),r=n;for(;r.length;)r=e.filter(o=>{var i;return(i=r)==null?void 0:i.some(s=>{var a;return o.parentId===s.id&&((a=o.context)==null?void 0:a.open)})}),n=n.concat(r);return n}var Ea=new WeakMap,jp=new WeakSet,Vp={},b0=0,G3=()=>typeof HTMLElement!="undefined"&&"inert"in HTMLElement.prototype,BR=e=>e&&(e.host||BR(e.parentNode)),Y3=(e,t)=>t.map(n=>{if(e.contains(n))return n;let r=BR(n);return e.contains(r)?r:null}).filter(n=>n!=null);function X3(e,t,n,r){let o="data-floating-ui-inert",i=r?"inert":n?"aria-hidden":null,s=Y3(t,e),a=new Set,u=new Set(s),l=[];Vp[o]||(Vp[o]=new WeakMap);let c=Vp[o];s.forEach(f),d(t),a.clear();function f(p){!p||a.has(p)||(a.add(p),p.parentNode&&f(p.parentNode))}function d(p){!p||u.has(p)||[].forEach.call(p.children,y=>{if(wr(y)!=="script")if(a.has(y))d(y);else{let h=i?y.getAttribute(i):null,g=h!==null&&h!=="false",m=Ea.get(y)||0,v=i?m+1:m,x=(c.get(y)||0)+1;Ea.set(y,v),c.set(y,x),l.push(y),v===1&&g&&jp.add(y),x===1&&y.setAttribute(o,""),!g&&i&&y.setAttribute(i,"true")}})}return b0++,()=>{l.forEach(p=>{let y=Ea.get(p)||0,h=i?y-1:y,g=(c.get(p)||0)-1;Ea.set(p,h),c.set(p,g),h||(!jp.has(p)&&i&&p.removeAttribute(i),jp.delete(p)),g||p.removeAttribute(o)}),b0--,b0||(Ea=new WeakMap,Ea=new WeakMap,jp=new WeakSet,Vp={})}}function PR(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);let r=Rt(e[0]).body;return X3(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}var Kp=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function UR(e,t){let n=Zu(e,Kp());t==="prev"&&n.reverse();let r=n.indexOf(jo(Rt(e)));return n.slice(r+1)[0]}function jR(){return UR(document.body,"next")}function VR(){return UR(document.body,"prev")}function ec(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!Bt(n,r)}function Q3(e){Zu(e,Kp()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function AR(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{let r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}var qp={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},Z3;function IR(e){e.key==="Tab"&&(e.target,clearTimeout(Z3))}var Wp=N.forwardRef(function(t,n){let[r,o]=N.useState();nn(()=>(jk()&&o("button"),document.addEventListener("keydown",IR),()=>{document.removeEventListener("keydown",IR)}),[]);let i={ref:n,tabIndex:0,role:r,"aria-hidden":r?void 0:!0,[Ca("focus-guard")]:"",style:qp};return(0,rn.jsx)("span",b(b({},t),i))}),WR=N.createContext(null),LR=Ca("portal");function J3(e){e===void 0&&(e={});let{id:t,root:n}=e,r=A0(),o=KR(),[i,s]=N.useState(null),a=N.useRef(null);return nn(()=>()=>{i==null||i.remove(),queueMicrotask(()=>{a.current=null})},[i]),nn(()=>{if(!r||a.current)return;let u=t?document.getElementById(t):null;if(!u)return;let l=document.createElement("div");l.id=r,l.setAttribute(LR,""),u.appendChild(l),a.current=l,s(l)},[t,r]),nn(()=>{if(n===null||!r||a.current)return;let u=n||(o==null?void 0:o.portalNode);u&&!Me(u)&&(u=u.current),u=u||document.body;let l=null;t&&(l=document.createElement("div"),l.id=t,u.appendChild(l));let c=document.createElement("div");c.id=r,c.setAttribute(LR,""),u=l||u,u.appendChild(c),a.current=c,s(c)},[t,n,r,o]),i}function $R(e){let{children:t,id:n,root:r,preserveTabOrder:o=!0}=e,i=J3({id:n,root:r}),[s,a]=N.useState(null),u=N.useRef(null),l=N.useRef(null),c=N.useRef(null),f=N.useRef(null),d=s==null?void 0:s.modal,p=s==null?void 0:s.open,y=!!s&&!s.modal&&s.open&&o&&!!(r||i);return N.useEffect(()=>{if(!i||!o||d)return;function h(g){i&&ec(g)&&(g.type==="focusin"?AR:Q3)(i)}return i.addEventListener("focusin",h,!0),i.addEventListener("focusout",h,!0),()=>{i.removeEventListener("focusin",h,!0),i.removeEventListener("focusout",h,!0)}},[i,o,d]),N.useEffect(()=>{i&&(p||AR(i))},[p,i]),(0,rn.jsxs)(WR.Provider,{value:N.useMemo(()=>({preserveTabOrder:o,beforeOutsideRef:u,afterOutsideRef:l,beforeInsideRef:c,afterInsideRef:f,portalNode:i,setFocusManagerState:a}),[o,i]),children:[y&&i&&(0,rn.jsx)(Wp,{"data-type":"outside",ref:u,onFocus:h=>{if(ec(h,i)){var g;(g=c.current)==null||g.focus()}else{let m=VR()||(s==null?void 0:s.domReference);m==null||m.focus()}}}),y&&i&&(0,rn.jsx)("span",{"aria-owns":i.id,style:qp}),i&&P0.createPortal(t,i),y&&i&&(0,rn.jsx)(Wp,{"data-type":"outside",ref:l,onFocus:h=>{if(ec(h,i)){var g;(g=f.current)==null||g.focus()}else{let m=jR()||(s==null?void 0:s.domReference);m==null||m.focus(),s!=null&&s.closeOnFocusOut&&(s==null||s.onOpenChange(!1,h.nativeEvent,"focus-out"))}}})]})}var KR=()=>N.useContext(WR),R0="data-floating-ui-focusable";function OR(e){return e?e.hasAttribute(R0)?e:e.querySelector("["+R0+"]")||e:null}var MR=20,Bi=[];function E0(e){Bi=Bi.filter(t=>t.isConnected),e&&wr(e)!=="body"&&(Bi.push(e),Bi.length>MR&&(Bi=Bi.slice(-MR)))}function NR(){return Bi.slice().reverse().find(e=>e.isConnected)}function e4(e){let t=Kp();return tR(e,t)?e:Zu(e,t)[0]||e}var t4=N.forwardRef(function(t,n){return(0,rn.jsx)("button",A(b({},t),{type:"button",ref:n,tabIndex:-1,style:qp}))});function qR(e){let{context:t,children:n,disabled:r=!1,order:o=["content"],guards:i=!0,initialFocus:s=0,returnFocus:a=!0,restoreFocus:u=!1,modal:l=!0,visuallyHiddenDismiss:c=!1,closeOnFocusOut:f=!0,outsideElementsInert:d=!1}=e,{open:p,onOpenChange:y,events:h,dataRef:g,elements:{domReference:m,floating:v}}=t,x=On(()=>{var oe;return(oe=g.current.floatingContext)==null?void 0:oe.nodeId}),S=typeof s=="number"&&s<0,C=$k(m)&&S,T=G3(),R=T?i:!0,L=!R||T&&d,O=Ta(o),G=Ta(s),D=Ta(a),B=$p(),j=KR(),le=N.useRef(null),Y=N.useRef(null),J=N.useRef(!1),X=N.useRef(!1),U=N.useRef(-1),I=j!=null,M=OR(v),H=On(function(oe){return oe===void 0&&(oe=M),oe?Zu(oe,Kp()):[]}),ue=On(oe=>{let ae=H(oe);return O.current.map(ie=>m&&ie==="reference"?m:M&&ie==="floating"?M:ae).filter(Boolean).flat()});N.useEffect(()=>{if(r||!l)return;function oe(ie){if(ie.key==="Tab"){Bt(M,jo(Rt(M)))&&H().length===0&&!C&&Lp(ie);let de=ue(),pe=Vo(ie);O.current[0]==="reference"&&pe===m&&(Lp(ie),ie.shiftKey?ba(de[de.length-1]):ba(de[1])),O.current[1]==="floating"&&pe===M&&ie.shiftKey&&(Lp(ie),ba(de[0]))}}let ae=Rt(M);return ae.addEventListener("keydown",oe),()=>{ae.removeEventListener("keydown",oe)}},[r,m,M,l,O,C,H,ue]),N.useEffect(()=>{if(r||!v)return;function oe(ae){let ie=Vo(ae),pe=H().indexOf(ie);pe!==-1&&(U.current=pe)}return v.addEventListener("focusin",oe),()=>{v.removeEventListener("focusin",oe)}},[r,v,H]),N.useEffect(()=>{if(r||!f)return;function oe(){X.current=!0,setTimeout(()=>{X.current=!1})}function ae(ie){let de=ie.relatedTarget;queueMicrotask(()=>{let pe=x(),ve=!(Bt(m,de)||Bt(v,de)||Bt(de,v)||Bt(j==null?void 0:j.portalNode,de)||de!=null&&de.hasAttribute(Ca("focus-guard"))||B&&(Ju(B.nodesRef.current,pe).find(_e=>{var At,$e;return Bt((At=_e.context)==null?void 0:At.elements.floating,de)||Bt(($e=_e.context)==null?void 0:$e.elements.domReference,de)})||RR(B.nodesRef.current,pe).find(_e=>{var At,$e,mn;return[(At=_e.context)==null?void 0:At.elements.floating,OR(($e=_e.context)==null?void 0:$e.elements.floating)].includes(de)||((mn=_e.context)==null?void 0:mn.elements.domReference)===de})));if(u&&ve&&jo(Rt(M))===Rt(M).body){Xe(M)&&M.focus();let _e=U.current,At=H(),$e=At[_e]||At[At.length-1]||M;Xe($e)&&$e.focus()}(C||!l)&&de&&ve&&!X.current&&de!==NR()&&(J.current=!0,y(!1,ie,"focus-out"))})}if(v&&Xe(m))return m.addEventListener("focusout",ae),m.addEventListener("pointerdown",oe),v.addEventListener("focusout",ae),()=>{m.removeEventListener("focusout",ae),m.removeEventListener("pointerdown",oe),v.removeEventListener("focusout",ae)}},[r,m,v,M,l,B,j,y,f,u,H,C,x]);let ee=N.useRef(null),ge=N.useRef(null),Pe=tc([ee,j==null?void 0:j.beforeInsideRef]),Ne=tc([ge,j==null?void 0:j.afterInsideRef]);N.useEffect(()=>{var oe;if(r||!v)return;let ae=Array.from((j==null||(oe=j.portalNode)==null?void 0:oe.querySelectorAll("["+Ca("portal")+"]"))||[]),ie=B&&!l?RR(B==null?void 0:B.nodesRef.current,x()).map(ve=>{var _e;return(_e=ve.context)==null?void 0:_e.elements.floating}):[],de=[v,...ae,...ie,le.current,Y.current,ee.current,ge.current,j==null?void 0:j.beforeOutsideRef.current,j==null?void 0:j.afterOutsideRef.current,O.current.includes("reference")||C?m:null].filter(ve=>ve!=null),pe=l||C?PR(de,!L,L):PR(de);return()=>{pe()}},[r,m,v,l,O,j,C,R,L,B,x]),nn(()=>{if(r||!Xe(M))return;let oe=Rt(M),ae=jo(oe);queueMicrotask(()=>{let ie=ue(M),de=G.current,pe=(typeof de=="number"?ie[de]:de.current)||M,ve=Bt(M,ae);!S&&!ve&&p&&ba(pe,{preventScroll:pe===M})})},[r,p,M,S,ue,G]),nn(()=>{if(r||!M)return;let oe=!1,ae=Rt(M),ie=jo(ae),pe=g.current.openEvent;E0(ie);function ve($e){let{open:mn,reason:Pr,event:Ar,nested:or}=$e;mn&&(pe=Ar),Pr==="escape-key"&&m&&E0(m),["hover","safe-polygon"].includes(Pr)&&Ar.type==="mouseleave"&&(J.current=!0),Pr==="outside-press"&&(or?(J.current=!1,oe=!0):J.current=!(Bk(Ar)||Uk(Ar)))}h.on("openchange",ve);let _e=ae.createElement("span");_e.setAttribute("tabindex","-1"),_e.setAttribute("aria-hidden","true"),Object.assign(_e.style,qp),I&&m&&m.insertAdjacentElement("afterend",_e);function At(){return typeof D.current=="boolean"?NR()||_e:D.current.current||_e}return()=>{h.off("openchange",ve);let $e=jo(ae),mn=Bt(v,$e)||B&&Ju(B.nodesRef.current,x()).some(or=>{var yc;return Bt((yc=or.context)==null?void 0:yc.elements.floating,$e)});(mn||pe&&["click","mousedown"].includes(pe.type))&&m&&E0(m);let Ar=At();queueMicrotask(()=>{let or=e4(Ar);D.current&&!J.current&&Xe(or)&&(!(or!==$e&&$e!==ae.body)||mn)&&or.focus({preventScroll:oe}),_e.remove()})}},[r,v,M,D,g,h,B,I,m,x]),N.useEffect(()=>{queueMicrotask(()=>{J.current=!1})},[r]),nn(()=>{if(!r&&j)return j.setFocusManagerState({modal:l,closeOnFocusOut:f,open:p,onOpenChange:y,domReference:m}),()=>{j.setFocusManagerState(null)}},[r,j,l,p,y,f,m]),nn(()=>{if(r||!M||typeof MutationObserver!="function"||S)return;let oe=()=>{let ie=M.getAttribute("tabindex"),de=H(),pe=jo(Rt(v)),ve=de.indexOf(pe);ve!==-1&&(U.current=ve),O.current.includes("floating")||pe!==m&&de.length===0?ie!=="0"&&M.setAttribute("tabindex","0"):ie!=="-1"&&M.setAttribute("tabindex","-1")};oe();let ae=new MutationObserver(oe);return ae.observe(M,{childList:!0,subtree:!0,attributes:!0}),()=>{ae.disconnect()}},[r,v,M,m,O,H,S]);function Qe(oe){return r||!c||!l?null:(0,rn.jsx)(t4,{ref:oe==="start"?le:Y,onClick:ae=>y(!1,ae.nativeEvent),children:typeof c=="string"?c:"Dismiss"})}let Wt=!r&&R&&(l?!C:!0)&&(I||l);return(0,rn.jsxs)(rn.Fragment,{children:[Wt&&(0,rn.jsx)(Wp,{"data-type":"inside",ref:Pe,onFocus:oe=>{if(l){let ie=ue();ba(o[0]==="reference"?ie[0]:ie[ie.length-1])}else if(j!=null&&j.preserveTabOrder&&j.portalNode)if(J.current=!1,ec(oe,j.portalNode)){let ie=jR()||m;ie==null||ie.focus()}else{var ae;(ae=j.beforeOutsideRef.current)==null||ae.focus()}}}),!C&&Qe("start"),n,Qe("end"),Wt&&(0,rn.jsx)(Wp,{"data-type":"inside",ref:Ne,onFocus:oe=>{if(l)ba(ue()[0]);else if(j!=null&&j.preserveTabOrder&&j.portalNode)if(f&&(J.current=!0),ec(oe,j.portalNode)){let ie=VR()||m;ie==null||ie.focus()}else{var ae;(ae=j.afterOutsideRef.current)==null||ae.focus()}}})]})}function _R(e){return Xe(e.target)&&e.target.tagName==="BUTTON"}function DR(e){return a0(e)}function GR(e,t){t===void 0&&(t={});let{open:n,onOpenChange:r,dataRef:o,elements:{domReference:i}}=e,{enabled:s=!0,event:a="click",toggle:u=!0,ignoreMouse:l=!1,keyboardHandlers:c=!0,stickIfOpen:f=!0}=t,d=N.useRef(),p=N.useRef(!1),y=N.useMemo(()=>({onPointerDown(h){d.current=h.pointerType},onMouseDown(h){let g=d.current;h.button===0&&a!=="click"&&(va(g,!0)&&l||(n&&u&&(!(o.current.openEvent&&f)||o.current.openEvent.type==="mousedown")?r(!1,h.nativeEvent,"click"):(h.preventDefault(),r(!0,h.nativeEvent,"click"))))},onClick(h){let g=d.current;if(a==="mousedown"&&d.current){d.current=void 0;return}va(g,!0)&&l||(n&&u&&(!(o.current.openEvent&&f)||o.current.openEvent.type==="click")?r(!1,h.nativeEvent,"click"):r(!0,h.nativeEvent,"click"))},onKeyDown(h){d.current=void 0,!(h.defaultPrevented||!c||_R(h))&&(h.key===" "&&!DR(i)&&(h.preventDefault(),p.current=!0),h.key==="Enter"&&r(!(n&&u),h.nativeEvent,"click"))},onKeyUp(h){h.defaultPrevented||!c||_R(h)||DR(i)||h.key===" "&&p.current&&(p.current=!1,r(!(n&&u),h.nativeEvent,"click"))}}),[o,i,a,l,c,r,n,f,u]);return N.useMemo(()=>s?{reference:y}:{},[s,y])}var n4={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},r4={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},FR=e=>{var t,n;return{escapeKey:typeof e=="boolean"?e:(t=e==null?void 0:e.escapeKey)!=null?t:!1,outsidePress:typeof e=="boolean"?e:(n=e==null?void 0:e.outsidePress)!=null?n:!0}};function YR(e,t){t===void 0&&(t={});let{open:n,onOpenChange:r,elements:o,dataRef:i}=e,{enabled:s=!0,escapeKey:a=!0,outsidePress:u=!0,outsidePressEvent:l="pointerdown",referencePress:c=!1,referencePressEvent:f="pointerdown",ancestorScroll:d=!1,bubbles:p,capture:y}=t,h=$p(),g=On(typeof u=="function"?u:()=>!1),m=typeof u=="function"?g:u,v=N.useRef(!1),x=N.useRef(!1),{escapeKey:S,outsidePress:C}=FR(p),{escapeKey:T,outsidePress:R}=FR(y),L=N.useRef(!1),O=On(Y=>{var J;if(!n||!s||!a||Y.key!=="Escape"||L.current)return;let X=(J=i.current.floatingContext)==null?void 0:J.nodeId,U=h?Ju(h.nodesRef.current,X):[];if(!S&&(Y.stopPropagation(),U.length>0)){let I=!0;if(U.forEach(M=>{var H;if((H=M.context)!=null&&H.open&&!M.context.dataRef.current.__escapeKeyBubbles){I=!1;return}}),!I)return}r(!1,Vk(Y)?Y.nativeEvent:Y,"escape-key")}),G=On(Y=>{var J;let X=()=>{var U;O(Y),(U=Vo(Y))==null||U.removeEventListener("keydown",X)};(J=Vo(Y))==null||J.addEventListener("keydown",X)}),D=On(Y=>{var J;let X=v.current;v.current=!1;let U=x.current;if(x.current=!1,l==="click"&&U||X||typeof m=="function"&&!m(Y))return;let I=Vo(Y),M="["+Ca("inert")+"]",H=Rt(o.floating).querySelectorAll(M),ue=Me(I)?I:null;for(;ue&&!Jn(ue);){let Ne=Qn(ue);if(Jn(Ne)||!Me(Ne))break;ue=Ne}if(H.length&&Me(I)&&!Wk(I)&&!Bt(I,o.floating)&&Array.from(H).every(Ne=>!Bt(ue,Ne)))return;if(Xe(I)&&le){let Ne=Jn(I),Qe=tn(I),Wt=/auto|scroll/,oe=Ne||Wt.test(Qe.overflowX),ae=Ne||Wt.test(Qe.overflowY),ie=oe&&I.clientWidth>0&&I.scrollWidth>I.clientWidth,de=ae&&I.clientHeight>0&&I.scrollHeight>I.clientHeight,pe=Qe.direction==="rtl",ve=de&&(pe?Y.offsetX<=I.offsetWidth-I.clientWidth:Y.offsetX>I.clientWidth),_e=ie&&Y.offsetY>I.clientHeight;if(ve||_e)return}let ee=(J=i.current.floatingContext)==null?void 0:J.nodeId,ge=h&&Ju(h.nodesRef.current,ee).some(Ne=>{var Qe;return Ip(Y,(Qe=Ne.context)==null?void 0:Qe.elements.floating)});if(Ip(Y,o.floating)||Ip(Y,o.domReference)||ge)return;let Pe=h?Ju(h.nodesRef.current,ee):[];if(Pe.length>0){let Ne=!0;if(Pe.forEach(Qe=>{var Wt;if((Wt=Qe.context)!=null&&Wt.open&&!Qe.context.dataRef.current.__outsidePressBubbles){Ne=!1;return}}),!Ne)return}r(!1,Y,"outside-press")}),B=On(Y=>{var J;let X=()=>{var U;D(Y),(U=Vo(Y))==null||U.removeEventListener(l,X)};(J=Vo(Y))==null||J.addEventListener(l,X)});N.useEffect(()=>{if(!n||!s)return;i.current.__escapeKeyBubbles=S,i.current.__outsidePressBubbles=C;let Y=-1;function J(H){r(!1,H,"ancestor-scroll")}function X(){window.clearTimeout(Y),L.current=!0}function U(){Y=window.setTimeout(()=>{L.current=!1},ya()?5:0)}let I=Rt(o.floating);a&&(I.addEventListener("keydown",T?G:O,T),I.addEventListener("compositionstart",X),I.addEventListener("compositionend",U)),m&&I.addEventListener(l,R?B:D,R);let M=[];return d&&(Me(o.domReference)&&(M=pn(o.domReference)),Me(o.floating)&&(M=M.concat(pn(o.floating))),!Me(o.reference)&&o.reference&&o.reference.contextElement&&(M=M.concat(pn(o.reference.contextElement)))),M=M.filter(H=>{var ue;return H!==((ue=I.defaultView)==null?void 0:ue.visualViewport)}),M.forEach(H=>{H.addEventListener("scroll",J,{passive:!0})}),()=>{a&&(I.removeEventListener("keydown",T?G:O,T),I.removeEventListener("compositionstart",X),I.removeEventListener("compositionend",U)),m&&I.removeEventListener(l,R?B:D,R),M.forEach(H=>{H.removeEventListener("scroll",J)}),window.clearTimeout(Y)}},[i,o,a,m,l,n,r,d,s,S,C,O,T,G,D,R,B]),N.useEffect(()=>{v.current=!1},[m,l]);let j=N.useMemo(()=>b({onKeyDown:O},c&&b({[n4[f]]:Y=>{r(!1,Y.nativeEvent,"reference-press")}},f!=="click"&&{onClick(Y){r(!1,Y.nativeEvent,"reference-press")}})),[O,r,c,f]),le=N.useMemo(()=>({onKeyDown:O,onMouseDown(){x.current=!0},onMouseUp(){x.current=!0},[r4[l]]:()=>{v.current=!0}}),[O,l]);return N.useMemo(()=>s?{reference:j,floating:le}:{},[s,j,le])}function o4(e){let{open:t=!1,onOpenChange:n,elements:r}=e,o=A0(),i=N.useRef({}),[s]=N.useState(()=>$3()),a=I0()!=null,[u,l]=N.useState(r.reference),c=On((p,y,h)=>{i.current.openEvent=p?y:void 0,s.emit("openchange",{open:p,event:y,reason:h,nested:a}),n==null||n(p,y,h)}),f=N.useMemo(()=>({setPositionReference:l}),[]),d=N.useMemo(()=>({reference:u||r.reference||null,floating:r.floating||null,domReference:r.reference}),[u,r.reference,r.floating]);return N.useMemo(()=>({dataRef:i,open:t,onOpenChange:c,elements:d,events:s,floatingId:o,refs:f}),[t,c,d,s,o,f])}function XR(e){e===void 0&&(e={});let{nodeId:t}=e,n=o4(A(b({},e),{elements:b({reference:null,floating:null},e.elements)})),r=e.rootContext||n,o=r.elements,[i,s]=N.useState(null),[a,u]=N.useState(null),c=(o==null?void 0:o.domReference)||i,f=N.useRef(null),d=$p();nn(()=>{c&&(f.current=c)},[c]);let p=bR(A(b({},e),{elements:b(b({},o),a&&{reference:a})})),y=N.useCallback(x=>{let S=Me(x)?{getBoundingClientRect:()=>x.getBoundingClientRect(),contextElement:x}:x;u(S),p.refs.setReference(S)},[p.refs]),h=N.useCallback(x=>{(Me(x)||x===null)&&(f.current=x,s(x)),(Me(p.refs.reference.current)||p.refs.reference.current===null||x!==null&&!Me(x))&&p.refs.setReference(x)},[p.refs]),g=N.useMemo(()=>A(b({},p.refs),{setReference:h,setPositionReference:y,domReference:f}),[p.refs,h,y]),m=N.useMemo(()=>A(b({},p.elements),{domReference:c}),[p.elements,c]),v=N.useMemo(()=>A(b(b({},p),r),{refs:g,elements:m,nodeId:t}),[p,g,m,t,r]);return nn(()=>{r.dataRef.current.floatingContext=v;let x=d==null?void 0:d.nodesRef.current.find(S=>S.id===t);x&&(x.context=v)}),N.useMemo(()=>A(b({},p),{context:v,refs:g,elements:m}),[p,g,m,v])}var T0="active",C0="selected";function k0(e,t,n){let r=new Map,o=n==="item",i=e;if(o&&e){let s=e,{[T0]:a,[C0]:u}=s;i=te(s,[jm(T0),jm(C0)])}return b(b(b({},n==="floating"&&{tabIndex:-1,[R0]:""}),i),t.map(a=>{let u=a?a[n]:null;return typeof u=="function"?e?u(e):null:u}).concat(e).reduce((a,u)=>(u&&Object.entries(u).forEach(l=>{let[c,f]=l;if(!(o&&[T0,C0].includes(c)))if(c.indexOf("on")===0){if(r.has(c)||r.set(c,[]),typeof f=="function"){var d;(d=r.get(c))==null||d.push(f),a[c]=function(){for(var p,y=arguments.length,h=new Array(y),g=0;g<y;g++)h[g]=arguments[g];return(p=r.get(c))==null?void 0:p.map(m=>m(...h)).find(m=>m!==void 0)}}}else a[c]=f}),a),{}))}function QR(e){e===void 0&&(e=[]);let t=e.map(a=>a==null?void 0:a.reference),n=e.map(a=>a==null?void 0:a.floating),r=e.map(a=>a==null?void 0:a.item),o=N.useCallback(a=>k0(a,e,"reference"),t),i=N.useCallback(a=>k0(a,e,"floating"),n),s=N.useCallback(a=>k0(a,e,"item"),r);return N.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:s}),[o,i,s])}var i4=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function ZR(e,t){var n;t===void 0&&(t={});let{open:r,floatingId:o}=e,{enabled:i=!0,role:s="dialog"}=t,a=(n=i4.get(s))!=null?n:s,u=A0(),c=I0()!=null,f=N.useMemo(()=>a==="tooltip"||s==="label"?{["aria-"+(s==="label"?"labelledby":"describedby")]:r?o:void 0}:b(b(b(b(b({"aria-expanded":r?"true":"false","aria-haspopup":a==="alertdialog"?"dialog":a,"aria-controls":r?o:void 0},a==="listbox"&&{role:"combobox"}),a==="menu"&&{id:u}),a==="menu"&&c&&{role:"menuitem"}),s==="select"&&{"aria-autocomplete":"none"}),s==="combobox"&&{"aria-autocomplete":"list"}),[a,o,c,r,u,s]),d=N.useMemo(()=>{let y=b({id:o},a&&{role:a});return a==="tooltip"||s==="label"?y:b(b({},y),a==="menu"&&{"aria-labelledby":u})},[a,o,u,s]),p=N.useCallback(y=>{let{active:h,selected:g}=y,m=b({role:"option"},h&&{id:o+"-option"});switch(s){case"select":return A(b({},m),{"aria-selected":h&&g});case"combobox":return b(b({},m),h&&{"aria-selected":!0})}return{}},[o,s]);return N.useMemo(()=>i?{reference:f,floating:d,item:p}:{},[i,f,d,p])}var Ui=w(k());function s4({initialOpen:e=!1,placement:t="bottom",modal:n,tooltip:r}={}){let[o,i]=br.useState(e),s=XR({placement:t,open:o,onOpenChange:i,whileElementsMounted:Dp,middleware:[Up(5),S0({crossAxis:t.includes("-"),fallbackAxisSideDirection:"end",padding:5}),x0({padding:10})]}),a=s.context,u=GR(a),l=YR(a),c=ZR(a),f=[u,l,c];r&&f.push(zR(a,{move:!1}));let d=QR(f);return br.useMemo(()=>A(b(b({open:o,setOpen:i},d),s),{modal:n}),[o,i,d,s,n])}var JR=br.createContext(null),L0=()=>{let e=br.useContext(JR);if(e==null)throw new Error("Popover components must be wrapped in <Popover />");return e},Gp=r=>{var o=r,{children:e,modal:t=!1}=o,n=te(o,["children","modal"]);let i=s4(b({modal:t},n));return(0,Ui.jsx)(JR.Provider,{value:i,children:e})};function a4(r){var o=r,{as:e,children:t}=o,n=te(o,["as","children"]);let i=L0(),s=e||"button",a=t.ref,u=tc([i.refs.setReference,a]);return(0,Ui.jsx)(s,A(b({ref:u,type:"button","data-state":i.open?"open":"closed"},i.getReferenceProps(n)),{children:t}))}var l4=br.forwardRef(function(o,r){var i=o,{style:t}=i,n=te(i,["style"]);let l=L0(),{context:s}=l,a=te(l,["context"]),u=tc([a.refs.setFloating,r]);return s.open?(0,Ui.jsx)($R,{children:(0,Ui.jsx)(qR,{context:s,modal:a.modal,children:(0,Ui.jsx)("div",A(b({ref:u,style:b(b({},a.floatingStyles),t)},a.getFloatingProps(n)),{children:n.children}))})}):null});function u4(o){var i=o,{as:e,children:t,onClick:n}=i,r=te(i,["as","children","onClick"]);let{setOpen:s}=L0();return(0,Ui.jsx)(e||"button",A(b({type:"button",onClick:l=>{n(l),s(!1),l.stopPropagation()}},r),{children:t}))}Gp.Trigger=a4;Gp.Content=l4;Gp.Button=u4;var on=Gp;var Yp={trigger:"dd-dQ-OH",content:"dd-9k0N3",item:"dd-va6pa"};var ji=w(k()),c4=({suggestion:e,source:t,context:n})=>{let r=re(Wu),o=V(hr),i=ce(),s=q("enableSuggestionFeedback"),a=`${e.text}`,u=V(ca(`/admin/feedback?conversationId=${o}&type=${t}&text=${a}&data=${JSON.stringify({context:n})}`)),l=()=>{i(kn({name:"suggestion feedback",data:{text:e.text,source:t,context:n},options:{includeConversationData:!0}}))};return!s||!u?null:(0,ji.jsxs)(on,{placement:"top-end",children:[(0,ji.jsx)(on.Trigger,{className:Yp.trigger,children:(0,ji.jsx)(Cp,{"data-testid":"feedback-dropdown-trigger"})}),(0,ji.jsx)(on.Content,{className:Yp.content,children:(0,ji.jsx)(on.Button,{className:Yp.item,as:"a",onClick:l,target:"_blank",href:u,children:r("giveFeedback")})})]})},Xp=c4;var nc={};Lt(nc,{enUS:()=>d4,nlNL:()=>f4});var d4={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"URL suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},f4={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"URL suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var lP=w(W());var p4=["{amount}"," {amount}","{date}","{email}","{iban}","{name}","{postal_code}","{street}","{tarif}","{usage}","{3_digits}","{4_digits}","{5_digits}","{6_digits}","{7_digits}","{8_digits}","{9_digits}","{10_digits}"],m4=new RegExp(p4.map(e=>`(?:${e.replace("{","\\{").replace("}","\\}")})`).join("|"));function eP(e,t){let n=e.split(m4),r=0,o=[];for(let i=0;i<n.length;i++){let s=n[i];if(o.push(s),i===n.length-1)break;if(t.indexOf(s)===-1)return e;let a=n[i+1],u=i===n.length-2;r+=s.length;let l=r;if(u){let f=a.charAt(0),d=0;do l=f?t.indexOf(f,l+1):-1,d+=1;while(l!==-1&&a.indexOf(t.slice(l))!==0);if(l===-1&&d>2)return e}else l=a&&a!==""?t.indexOf(a,r):-1;let c=l===-1?t.slice(r):t.slice(r,l);o.push(c),r=l}return o.join("")}function tP(e,t){return typeof t=="boolean"?e:e.slice(0,t)}var rP={suggestions:[],fetchState:"idle"},nP={default:rP},oP=e=>t=>{var n,r;return(r=(n=t.textSuggestions[e])==null?void 0:n.suggestions)!=null?r:[]},Qp=e=>e.textSuggestions,iP=e=>{let t=e.toLowerCase();return n=>{let r=n.text.toLowerCase();return r.startsWith(t)&&r.length>t.length}},Zp=nt("textSuggestions/refresh"),tr=fe("textSuggestions/recommendations",(e,t)=>P(void 0,null,function*(){var c;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(c=r.conversation.current)==null?void 0:c.id,{platformVariables:i}=r.info,{textSuggestionsCount:s,inlineSuggestions:a}=r.settings,u=Js(r);if(!o)throw new Error("No current conversation to fetch text suggestions");let l=yield n.getTextSuggestions(o,nu(r),e);if(i&&(l=l.map(f=>b(A(b({},f),{text:Jt(f.text,i)}),f.title?{title:Jt(f.title,i)}:{}))),e==="default"){let f=a?l.filter(iP(u)):l;t.dispatch(Do(f.slice(0,s)))}return l})),rc=fe("textSuggestions/autocompletions",(e,t)=>P(void 0,null,function*(){var c;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(c=r.conversation.current)==null?void 0:c.id,{platformVariables:i}=r.info,{textSuggestionsCount:s,deanonymize:a,inlineSuggestions:u}=r.settings;if(!o)throw new Error("No current conversation to fetch text suggestions");let l=yield n.getAutocompleteSuggestions(o,A(b({},nu(r)),{input:e}));if(!t.getState().input.text)throw new Error("Abort");return u&&(l=l.filter(iP(e))),i&&(l=l.map(f=>A(b({},f),{text:Jt(f.text,i)}))),a&&(l=l.map(f=>A(b({},f),{text:f.source!=="trie-with-typos"?eP(f.text,e):f.text}))),l=tP(l,s),t.dispatch(Do(l)),l})),sP=ye({name:"textSuggestions",initialState:nP,reducers:{setTextSuggestions:{reducer(e,t){let{contentType:n}=t.payload;e[n].fetchState="done",e[n].suggestions=t.payload.suggestions},prepare(e,t){return{payload:{contentType:e,suggestions:t}}}}},extraReducers:e=>{e.addCase(tr.pending,(t,n)=>{let r=n.meta.arg,o=t[r]||rP;return A(b({},t),{[r]:A(b({},o),{fetchState:"loading"})})}).addCase(tr.rejected,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="error")}).addCase(tr.fulfilled,(t,n)=>{let r=n.meta.arg;t[r]&&(t[r].fetchState="done",t[r].suggestions=n.payload)}).addCase(rc.pending,t=>{t.default.fetchState="loading"}).addCase(rc.rejected,t=>{t.default.fetchState="error"}).addCase(rc.fulfilled,(t,n)=>{t.default.fetchState="done",t.default.suggestions=n.payload}).addCase(rt,()=>nP)}}),{setTextSuggestions:E$}=sP.actions,aP=sP.reducer;var Vi=w(k()),g4=({types:e,commands:t,onClick:n})=>{let r=ce(),o=re(nc),i=V(Qp);return(0,lP.useEffect)(()=>{e.forEach(({type:s})=>{(!i[s]||i[s].suggestions.length===0)&&r(tr(s))})},[]),(0,Vi.jsxs)("div",{children:[t.length>0&&(0,Vi.jsx)(We.List,{heading:o("commands"),children:t.map((s,a)=>(0,Vi.jsx)(We.ListItem,{id:`command-${a}`,closeOnSelect:!1,onClick:s.onClick,children:s.label},s.label))}),e.map(({type:s,title:a})=>{var u;return(0,Vi.jsx)(We.List,{heading:a,orientation:"vertical",children:(u=i[s])==null?void 0:u.suggestions.map((l,c)=>(0,Vi.jsx)(We.ListItem,{id:`${s}-${c}`,closeOnSelect:!1,description:l.title&&l.text,onClick:()=>n(l.text,l),"data-testid":"search-overlay-suggestion",children:l.title||l.text},`${l.id}-${l.text}`))},s)})]})},uP=g4;var pt=w(k()),y4=200,v4=5,x4=4,O0=(e,t,n)=>e.slice(0,n?10:t.toLowerCase()==="image"?x4:v4),S4=(e,t)=>!t||e.toLowerCase().includes(t.toLowerCase()),w4=()=>{var J,X,U;let e=ce(),t=en(),n=re(nc),[r,o]=(0,Ut.useState)(!1),[i,s]=(0,Ut.useState)(""),[a,u]=(0,Ut.useState)(null),l=V(LT),c=V(Ei),[f,d]=(0,Ut.useState)(),p=V(Nt),y=q("showSearch"),h=q("enableSuggestionFeedback"),g=q("showEntitiesCommand"),m=q("showKnowledgeSearch"),v=q("showImageSearch"),x=q("searchTriggerKey"),S=V(dC),C=V(nv),T=V(OT),R=V(IT),L=((U=(X=(J=c==null?void 0:c.uiConfig)==null?void 0:J.search)==null?void 0:X.initialTypes)==null?void 0:U.filter(({isActive:I})=>I))||[],O=(0,Ut.useMemo)(()=>{let I=ee=>O0(C.filter(ge=>ge.type===ee.toUpperCase()),ee,f),M=(S==null?void 0:S.map(ee=>({value:ee.code.toUpperCase(),label:`${ee.name}s`,list:I(ee.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[];if(M.push({value:"PERSONAL",label:n("personalSuggestions"),list:I("PERSONAL"),lineClamp:!1,listOrientation:"vertical"},{value:"URL",label:n("urlSuggestions"),list:I("URL"),lineClamp:!1,listOrientation:"vertical"},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:I("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical"}),v&&M.push({value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:I("IMAGE"),listOrientation:"horizontal"}),L.length===0)return M;let H=L.map(ee=>M.find(ge=>ge.value.toLowerCase()===ee.type)).filter(ee=>!!ee),ue=M.filter(ee=>!H.find(ge=>ge.value===ee.value));return[...H,...ue]},[S,L,v,f]),G=[{label:n("entitiesClipboard"),onClick:()=>e(Vr("entities")),shouldShow:g&&S4(n("entitiesClipboard"),i)},{label:i?`${n("knowledgeAssist")}: ${i}`:n("knowledgeAssist"),onClick:()=>e(Vr("knowledgeAssist")),shouldShow:m}].filter(I=>I.shouldShow).filter(()=>!f),D=(0,Ut.useCallback)((0,cP.default)((I,M)=>{e(Si({query:I,type:M,tags:["search-overlay"],size:f?50:20}))},y4),[f]),B=(0,Ut.useCallback)((I,M)=>{switch(M.type){case"IMAGE":t.send(ov,{suggestion:M});break;default:t.send(yr,{text:I,suggestion:M})}e(Rn(!1))},[e]),j=I=>{vr(I.text),e(kn({name:"entity copied",data:{entity:I,type:"copy"}})),e(Rn(!1))},le=I=>{t.send(yr,{text:I,suggestion:{source:"knowledge-assist",text:I}}),e(kn({name:"answer used",data:{originalText:I},options:{includeConversationData:!0}})),s(""),a&&e(ra(a)),e(Vr("search")),e(Rn(!1))};function Y(I){return M=>{r?window.confirm(n("warning"))&&(I(M),o(!1)):I(M)}}return(0,Ut.useEffect)(()=>{i?D(i,f):e(Vf())},[i,f]),(0,Ut.useEffect)(()=>{p&&e(Su())},[p]),zC(x,()=>e(Rn(!0))),!y||!c?null:(0,pt.jsxs)(We,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:s,onChangeOpen:Y(I=>e(Rn(I))),onChangeType:I=>d(I),onChangePage:Y(I=>e(Vr(I))),selectedType:f,search:i,page:l,isOpen:R,types:O,updateDeps:[C],children:[(0,pt.jsxs)(We.Page,{id:"search",children:[i.length===0&&(0,pt.jsx)(uP,{types:L,commands:G,onClick:B}),i.length>0&&(0,pt.jsxs)(Ut.Fragment,{children:[G.length>0&&(0,pt.jsx)(We.List,{heading:n("commands"),children:G.map((I,M)=>(0,pt.jsx)(We.ListItem,{closeOnSelect:!1,onClick:I.onClick,id:`commands-${M}`,children:I.label},I.label))}),O.map(({value:I,label:M,list:H,lineClamp:ue,listOrientation:ee})=>(0,pt.jsx)(We.List,{heading:M,orientation:ee==="horizontal"?"horizontal":"vertical",onShowAll:()=>d(I),hasMore:!f&&T[I.toLowerCase()]>O0(H,I,f).length,children:O0(H,I,f).map(ge=>(0,pt.jsx)(We.ListItem,{id:`${I}-${ge.id}`,closeOnSelect:!1,lineClamp:ue,onClick:()=>B(ge.text,ge),description:I!=="IMAGE"?ge.title&&ge.text:void 0,extra:h&&(0,pt.jsx)(We.ListItemActions,{children:(0,pt.jsx)(Xp,{context:i,source:"search",suggestion:ge})}),children:I==="IMAGE"?(0,pt.jsx)(We.Image,{title:ge.title||ge.text,src:ge.image}):ge.title||ge.text},`${ge.id}-${ge.text}`))},I))]})]}),(0,pt.jsx)(We.Page,{id:"entities",title:n("entitiesTitle"),onDismiss:Y(()=>{e(Vr("search"))}),children:(0,pt.jsx)(VC,{onCopy:j})}),(0,pt.jsx)(We.Page,{id:"knowledgeAssist",title:n("knowledgeAssist"),onDismiss:Y(()=>{a&&e(ra(a)),e(Vr("search"))}),children:(0,pt.jsx)(Nk,{threadId:a,onNewThreadId:I=>u(I),question:i,onUse:le,onResetQuestion:()=>{a&&e(ra(a)),s(""),u(null)}})})]})},dP=w4;var oc=w(k()),b4=()=>{let e=q("showSearch"),t=q("isEmbedded");return(0,oc.jsxs)(fP.Fragment,{children:[e&&(0,oc.jsx)(dP,{}),t&&(0,oc.jsx)(ZT,{})]})},pP=b4;var yP=w(Ie());var Jp=w(k()),mP=({className:e})=>(0,Jp.jsx)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 512 512",xmlSpace:"preserve",className:e,children:(0,Jp.jsx)("g",{children:(0,Jp.jsx)("path",{d:`M163.4,233h186v-70c0-25.6-9.4-47.8-27.3-65.7C304.2,79.4,282,70,256.4,70s-47.8,9.4-65.7,27.3
|
|
78
78
|
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
|
|
79
79
|
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
|
|
80
80
|
c6.8-6.8,15.4-10.2,24.7-10.2h11.9v-70c0-44.4,16.2-82.8,47.8-115.2S212.1,0,256.4,0s82.8,16.2,115.2,47.8
|
|
81
|
-
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 M0=w(k()),E4={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},gP=({className:e,color:t})=>(0,M0.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,M0.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:E4[t||"pink"]})});var hP={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var N0={};Lt(N0,{enUS:()=>T4,nlNL:()=>C4});var T4={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},C4={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Wi=w(k()),vP=({onLogIn:e})=>{let t=re(N0),n=q("floatingMenu"),r=q("productName"),o=ce(),i=V(Nt),s=_("FloatingMenu",hP);if(i===null||n===!1)return null;let a=()=>{i===!0?o(Rn(!0)):e()};return(0,Wi.jsxs)("button",{className:(0,yP.default)(s.root,{[s.isLoggedIn]:i,[s.isLoggedOut]:!i}),onClick:a,children:[(0,Wi.jsx)("div",{className:s.text,children:t(i?"search":"signin",{productName:r})}),(0,Wi.jsxs)("div",{className:s.icon,children:[(0,Wi.jsx)(gP,{className:s.logo,color:"pink"}),i===!1&&(0,Wi.jsx)(mP,{className:s.lock})]})]})};var om=w(W());function Er(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 k4={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},em=({ui:e})=>e.overlayCollapsed,xP=ye({name:"ui",initialState:k4,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:ic,setInputFocus:tm,setOverlayCollapsed:$o,setOpenOverlayWhenTyping:SP,setOverlayCollapsedUserOverwrite:wP}=xP.actions,bP=xP.reducer;var nm=w(W());var Ko=w(W());var EP=w(W());function TP(e,t,n){(0,EP.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var CP={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var $i=w(k()),P4=["search","personal-collection-search","search-autocomplete"];function A4(e,t,n,r={}){var i;let o="";return P4.includes(t)?o=kC(Pv(e,n,{stripAgentPart:!0}),(i=r.searchKeywords)!=null?i:[n]):o=Pv(e,n,r),r.placeholders===!0&&(o=RC(o)),o}var I4=()=>{},L4=({selected:e,suggestion:t})=>{let n=q("inlineSuggestions"),r=V(Js),[o,i]=(0,Ko.useState)(!1),s=q("enableSuggestionFeedback"),a=V(d=>d.input.text),u=ce(),l=_("TextSuggestion",CP),c=(0,Ko.useRef)(null);(0,Ko.useEffect)(()=>{let d=setTimeout(()=>{u(fT({text:t.text,suggestion:t}))},500);return()=>{clearTimeout(d)}},[t]),TP(c,"click",()=>{u(Bn({suggestion:t,text:t.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let f=(0,Ko.useMemo)(()=>A4(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,$i.jsxs)("div",{className:l.root,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[(0,$i.jsx)(be,{ref:c,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:I4,children:(0,$i.jsx)(oa,{containerTagName:"div",noWrap:!1,tagName:"span",className:l.formattedText,content:f})}),s&&o&&(0,$i.jsx)("div",{className:l.actions,children:(0,$i.jsx)(Xp,{source:"overlay",context:a,suggestion:t})})]})},kP=L4;var _0=w(k()),O4=({suggestions:e,selectedIndex:t,reverse:n})=>{let r=(0,nm.useMemo)(()=>{let o=e.map((i,s)=>(0,_0.jsx)(kP,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]);return(0,_0.jsx)(nm.Fragment,{children:r})},rm=O4;var RP={root:"dd-PfvRI",paper:"dd-HYlyY"};var sc=w(k()),M4=({textSuggestions:e,selectedIndex:t})=>{let n=(0,om.useRef)(null),r=_("InlineSuggestionsOverlay",RP),o=V(Er),i=ce(),s=V(Nt),a=V(Zs),u=V(em),l=q("showTextSuggestions");return Uo(()=>{setTimeout(()=>{i($o({collapse:!0,skipWhenInputFocus:!0}))})}),(0,om.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`}),u||!o||!l||e.length===0||s!==!0||a===!1?null:(0,sc.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,sc.jsx)("div",{ref:n,className:r.paper,children:(0,sc.jsx)(Gt,{children:(0,sc.jsx)(rm,{suggestions:e,selectedIndex:t})})})})},N4=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),PP=yi(N4)(M4);var ac=w(k()),_4=({children:e})=>{let n=q("locale").replace("-","");return(0,ac.jsx)(pv.Provider,{value:n,children:e})},D4=({store:e,customStyles:t={},children:n})=>(0,ac.jsx)(qy,{store:e,children:(0,ac.jsx)(_4,{children:(0,ac.jsx)(Wa.Provider,{value:t,children:n})})}),Ki=D4;var sm=w(Ie()),Ra=w(W());var AP=w(W());function IP(e,t){let[n,r]=(0,AP.useState)(()=>{if(typeof window=="undefined")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return Q.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){Q.error(s)}}]}var LP=()=>/Mac/i.test(navigator.platform);var MP=w(Ie()),Jr=w(W());var D0={};Lt(D0,{enUS:()=>F4,nlNL:()=>H4});var F4={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"}]}]},H4={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 OP={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var qo=w(k()),F0=(e,t,n)=>r=>(0,qo.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),z4=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=re(D0),s=en(),a=_("Login",OP),u=q("productName"),l=(0,Jr.useCallback)(g=>{g.preventDefault(),r&&r(parseInt(g.target.value,10))},[]),c=(0,Jr.useCallback)(g=>{g.preventDefault(),s.send(na,!0)},[t]),f=(0,Jr.useMemo)(()=>g=>(0,qo.jsx)("a",{onClick:v=>{v.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[t]),d=(0,Jr.useCallback)(g=>(0,qo.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:p,hour:y,day:h}=(0,Jr.useMemo)(()=>({min:F0(a,60*10,l),hour:F0(a,60*60,l),day:F0(a,60*60*12,l)}),[]);return(0,qo.jsxs)("div",{className:(0,MP.default)(e,a.root),children:[i("loginPlease",{login:n?d:f,productName:u}),r&&(0,qo.jsxs)(Jr.Fragment,{children:[(0,qo.jsx)("br",{}),i("snooze",{min:p,hour:y,day:h})]})]})},im=z4;var NP={root:"dd-DoQhb",text:"dd-Jwnev"};var lc=w(k()),B4=({title:e})=>{let t=_("SearchTrigger",NP),n=ce();return(0,lc.jsxs)("button",{type:"button",className:t.root,onClick:()=>n(Rn(!0)),children:[(0,lc.jsx)(sa,{}),(0,lc.jsx)("span",{className:t.text,children:e})]})},_P=B4;var H0={};Lt(H0,{enUS:()=>U4,nlNL:()=>j4});var U4={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"}]},j4={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 DP={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 je=w(k()),V4=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=_("SuggestionsOverlay",DP),o=re(H0),i=V(Er),s=dT(),a=ce(),u=(0,Ra.useRef)(null),l=q("searchTriggerKey"),c=q("productName"),f=V(em),d=V(Nt),p=V(Zs),[y,h]=(0,Ra.useState)(null),g=q("showSearch"),m=q("showTextSuggestions"),v=q("adminUrl"),x=q("isEmbedded"),[S,C]=IP("dd-snooze-until-ms",0),T=f||S>Date.now(),R=e.filter(G=>G.source!=="gpt").length,L=()=>{T&&C(0),a(wP(!T))},O=G=>{let D=Date.now()+G*1e3;C(D),Q.info(`Snooze until: ${new Date(D)}`),a($o({collapse:!0}))};return(0,Ra.useEffect)(()=>{R===0&&h(null)},[e,R]),Uo(()=>{a($o({collapse:!0,skipWhenInputFocus:!0}))}),d===null||p===!1?null:d===!1?(0,je.jsxs)("div",{ref:u,className:(0,sm.default)(r.root,{[r.isCollapsed]:T}),children:[!T&&(0,je.jsxs)("div",{className:r.triggers,children:[(0,je.jsx)("div",{style:{flex:1}}),(0,je.jsx)("div",{className:r.triggersRight,children:(0,je.jsx)(Jo,{className:r.toggleButton,title:o("collapse"),onClick:L,isCollapsed:!1})})]}),(0,je.jsx)("div",{className:r.toggleButtonWrapper,children:(0,je.jsx)(Jo,{className:r.toggleButton,title:o("open",{productName:c}),onClick:L,isCollapsed:!0})}),(0,je.jsx)("div",{className:r.collapsible,children:(0,je.jsx)(im,{loginUrl:v,isEmbedded:x,onLogIn:n,onSnooze:O})})]}):!s||!i?null:(0,je.jsxs)("div",{ref:u,className:(0,sm.default)(r.root,{[r.isCollapsed]:T}),children:[!T&&(0,je.jsxs)("div",{className:r.triggers,children:[(0,je.jsx)("div",{style:{flex:1},children:g&&(0,je.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>h(o(LP()?"searchHintMac":"searchHintWindows",{searchTriggerKey:l.toUpperCase()})),onMouseLeave:()=>h(null),children:(0,je.jsx)(_P,{title:o("search")})})}),(0,je.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,je.jsx)("div",{className:(0,sm.default)(!y&&r.hintsHidden,r.hints),children:y}),(0,je.jsx)(Jo,{className:r.toggleButton,title:o("collapse"),onClick:L,isCollapsed:!1})]})]}),(0,je.jsx)("div",{className:r.toggleButtonWrapper,children:(0,je.jsx)(Jo,{className:r.toggleButton,title:o("open",{productName:c}),onClick:L,isCollapsed:!0})}),R>0&&m&&(0,je.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,je.jsx)(Gt,{children:(0,je.jsx)(rm,{suggestions:e,selectedIndex:t,reverse:!0})})})]})},W4=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),FP=yi(W4)(V4);var vm=w(Ie());var no=w(W());var Pa=w(W());function am(e){return e.contentEditable==="true"}function $4(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 HP(e){let{selectionStart:t,selectionEnd:n}=am(e)?$4(e):e;return[t,n]}function zP(e){let[,t]=(0,Pa.useState)(),n=(0,Pa.useRef)(null);return n.current=HP(e),(0,Pa.useEffect)(()=>{let r=()=>{var a;let[o,i]=(a=n.current)!=null?a:[],s=HP(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 BP(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(_c);if(!s||s.length===0)return;let a=0;s.find(u=>{let l=r.indexOf(u,a);return o>l&&i<l+u.length?(n.selectionStart=l,n.selectionEnd=l+u.length,!0):(a=l+u.length,!1)})}var UP=w(W()),K4=["div","span","mark","strong","b","i","u","em"];function z0(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(K4.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,UP.cloneElement)(r,{children:z0(s,t,n+1)})]}return[...e,...t]}function qi(e){return e.tagName.toLowerCase()==="textarea"}var jP={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 qP=w(Ie());var pm=w(W());var Aa=w(W());function VP(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function lm(e){let t=(0,Aa.useRef)(null),[n,r]=(0,Aa.useState)(!1);return(0,Aa.useEffect)(()=>{var c;let o=!1,i=parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[s,a]=VP((f,d)=>{let p=t.current;if(!p)return;let y=f/i,h=d/i,g=p.getBoundingClientRect(),m=y>g.x&&y<g.x+g.width&&h>g.y&&h<g.y+g.height;m&&!o?(o=!0,r(!0)):!m&&o&&(o=!1,r(!1))},({clientX:f,clientY:d})=>[f,d]),[u,l]=VP(()=>{o=!1,r(!1)});return e.addEventListener("mousemove",s),e.addEventListener("mouseleave",u),()=>{a(),l(),e.removeEventListener("mousemove",s),e.removeEventListener("mouseleave",u)}},[t]),[t,n]}function WP(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function um(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function $P(e){return e!=null}var KP=w(Ie()),cm=w(W());var eo={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 B0=w(k()),dm=(0,cm.forwardRef)((o,r)=>{var i=o,{className:e,children:t}=i,n=te(i,["className","children"]);let s=(0,cm.useRef)(null),a=_("TabCompletion",eo);return(0,B0.jsx)("div",A(b({ref:um([s,r]),className:(0,KP.default)(e,a.popoverContentContainer)},n),{children:(0,B0.jsx)("div",{className:a.popoverContent,children:t})}))});var Go=w(k()),q4=e=>t=>{let n=qv(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},G4=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=_("TabCompletion",eo),s=Sp(),a=(0,pm.useMemo)(()=>q4(e.getBoundingClientRect()),[e]),[u,l]=lm(e);return(0,pm.useEffect)(()=>{l?s.open():s.close()},[l]),(0,Go.jsxs)("span",{children:[(0,Go.jsx)("mark",{ref:um([u,s.triggerRef]),className:(0,qP.default)(i.matchKeyword,{[i.hover]:l}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,Go.jsx)(fa,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,Go.jsx)(dm,{style:n,children:(0,Go.jsx)("div",{className:i.hintText,children:o})})})]})},fm=class extends $r{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=>A(b({},o),{keywordRegex:new RegExp(`\\b${WP(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),u=n.charAt(s.index+i.keyword.length);return a==="{"&&u==="}"?null:{index:s.index,length:s[0].length,match:s[0],matchString:s[0],suggestion:i.suggestion,preparedKeywordMatch:i,valid:!0}}).filter($P);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,Go.jsx)(G4,{inputElement:r.inputElement,suggestion:r.suggestion,inputStyle:r.inputStyle,boundaryRef:r.boundaryRef,children:n},`keyword_${r.matchString}_${r.key}`)}asTag(){return"mark"}};var GP=w(Ie());var U0=w(k()),Y4=({inputElement:e,children:t})=>{let n=_("TabCompletion",eo),[r,o]=lm(e);return(0,U0.jsx)("mark",{ref:r,className:(0,GP.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},mm=class extends $r{match(t){let n=t.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(t,n){return(0,U0.jsx)(Y4,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var hm=w(Ie());var Vt=w(W());var j0=w(k()),YP=()=>(0,j0.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,j0.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 Tr=w(W());var QP=w(vv());var XP={root:"dd-ky-Bv",content:"dd-kV5e1"};function gm(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 V0(e){return e.replace("https://www.","").replace("https://","")}var Mn=w(k()),X4=3,Q4=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),Z4=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=X4})=>{let i=_("LinkSearch",XP),[s,a]=(0,Tr.useState)(""),u=ce(),l=V(oP("url")),c=V(MT("URL")),f=(0,Tr.useMemo)(()=>c.map(Q4),[c]),[d,p]=(0,Tr.useState)(f.length-1),y=q("fallbackImage"),h=x=>{let S=x.target;a(S.value)},g=(x,S)=>{x.stopPropagation(),x.preventDefault(),window.open(S,"_blank")},m=x=>{var T;let S=d-1<0?f.length-1:d-1,C=d+1===f.length?0:d+1;x.code==="Escape"&&(a(""),t()),x.code==="ArrowUp"&&p(S),x.code==="ArrowDown"&&p(C),x.code==="Enter"&&e(((T=f[d])==null?void 0:T.text)||s)},v=(0,Tr.useCallback)((0,QP.default)(x=>{u(Si({query:x,type:"URL",tags:["link-search"]}))},300),[]);return(0,Tr.useEffect)(()=>{s&&v(s)},[s]),(0,Tr.useEffect)(()=>()=>{u(Vf())},[]),(0,Mn.jsxs)("div",{className:i.root,children:[(0,Mn.jsx)(Gt,{withDivider:!0,children:(s?f:l).slice(0,o).map((x,S)=>(0,Mn.jsx)(be,{selected:d===S,onClick:()=>e(x.text),"data-testid":"linksearch-suggestion",children:(0,Mn.jsxs)(De,{children:[(0,Mn.jsx)(De.Image,{src:gm(x,"small",y||void 0),title:x.title||x.text}),(0,Mn.jsxs)(De.Content,{className:i.content,cropText:!0,children:[(0,Mn.jsx)(De.Title,{children:x.title||V0(x.text)}),x.title&&V0(x.text)]}),(0,Mn.jsx)(be.Actions,{children:(0,Mn.jsx)(be.ActionButton,{label:r,onClick:C=>g(C,x.text)})})]})},x.text))}),(0,Mn.jsx)(gu,{value:s,onChange:h,autoFocus:!0,placeholder:n,onKeyUp:m})]})},ZP=Z4;var W0={};Lt(W0,{enUS:()=>J4,nlNL:()=>eF});var J4={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},eF={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var jt=w(k()),tF=(0,Vt.forwardRef)((e,t)=>{let n=_("TabCompletion",eo);return(0,jt.jsx)("mark",{ref:t,className:(0,hm.default)(n.matchSelection)},"selection-start")}),nF=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=re(W0),s=_("TabCompletion",eo),a=(0,Vt.useRef)(null),u=(0,Vt.useRef)(null),[l,c]=(0,Vt.useState)(null),f=ce(),d=Sp(document.activeElement===r),[p]=(0,Vt.useState)(()=>document.createRange());d.triggerRef.current=p,(0,Vt.useEffect)(()=>()=>p.detach(),[]),(0,Vt.useEffect)(()=>{let h=e.current,g=a.current;!h||!g||(p.setStart(h,0),p.setEnd(g,0))},[e.current,a.current]),Uo(()=>{d.close()});let y=(0,Vt.useCallback)(h=>{let g=p.toString(),m=/^http(s?):\/\//.test(h)?h:`https://${h}`;f(Ff({text:`[${g}](${m})`,replace:"selection"}))},[]);return(0,jt.jsxs)("span",{children:[(0,jt.jsx)("mark",{ref:a,className:(0,hm.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,jt.jsx)(fa,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,jt.jsxs)(dm,{style:n,ref:u,children:[(0,jt.jsx)("div",{className:(0,hm.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:l!==null}),children:(0,jt.jsxs)("button",{type:"button",tabIndex:l===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,jt.jsx)(YP,{}),(0,jt.jsx)("span",{children:"\xA0"}),(0,jt.jsx)("span",{children:i("insertLink")})]})}),l==="insertLink"&&(0,jt.jsx)(ZP,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:y,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},ym=class extends $r{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,Vt.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[r,o]=this.props.selection;if(r===o)return null;let i=this.foundIndex===0?r:o,s=i>=this.charCount&&i<=this.charCount+n.length?{index:i-this.charCount,length:0,match:"",valid:!0}:null;s&&this.foundIndex++;let a=this.foundIndex===1;return s&&a?this.charCount+=i-this.charCount:this.charCount+=n.length,s?b({isStart:a},s):null}replaceWith(n,r){return r.isStart?(0,jt.jsx)(tF,{ref:this.startRef}):(0,jt.jsx)(nF,{inputElement:r.inputElement,startRef:this.startRef,boundaryRef:r.boundaryRef,inputStyle:r.inputStyle})}asTag(){return"mark"}};var to=w(k()),rF=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:u})=>{let l=_("TabCompletion",jP),c=q("insertLink"),f=q("showMidSentenceSuggestions"),d=q("inlineSuggestions"),p=zP(a),y=(0,no.useRef)(null),h=V(Nt);(0,no.useEffect)(()=>{qi(a)&&p&&BP(a,p)},[p]);let g=(0,no.useCallback)(x=>{if(!o||!n)return x;let S=[(0,to.jsx)("span",{className:l.resetIndent,children:"\u200B"},"u200B"),(0,to.jsx)("span",{"data-testid":"tab-completion",className:(0,vm.default)(l.tabText,l.resetIndent),"data-source":u,children:n},"tabText")];return r&&S.push((0,to.jsx)("span",{className:(0,vm.default)(l.hint,l.resetIndent),children:(0,to.jsx)(Oc,{keyCode:"tab"},"tabHint")})),z0(x,S)},[o,n,r]),m=(0,no.useMemo)(()=>{let x=[];return c&&x.push(new ym("selection")),x.push(new mm("placeholders")),i&&x.push(new fm("keywords")),x},[d,c,i]),v=(0,no.useMemo)(()=>{let x=window.getComputedStyle(a);return{"--dd-color":x.color,"--dd-font-size":x.fontSize,"--dd-font-family":x.fontFamily,"--dd-font-variant":x.fontVariant}},[]);return!e||!h?null:(0,to.jsxs)("div",{ref:x=>{x!=null&&x.parentElement&&(y.current=x==null?void 0:x.parentElement)},className:l.root,style:v,children:[(0,to.jsx)(oa,{tagName:"span",containerTagName:"div",className:(0,vm.default)(l.container,l.agentText),disableLineBreaks:qi(a),content:t||"\u200B",onAfterParse:g,matchers:m,selection:p,keywordMatches:s,inputElement:a,inputStyle:v,boundaryRef:y,inlineSuggestionsOnlyAtEnd:!f}),(0,to.jsx)("br",{})]})},oF=e=>{var g,m,v;let{input:t,ui:n,settings:r,styleSuggestions:o,conversation:i}=e,s=ea({input:t}),a=(s==null?void 0:s.text)||"",u=(s==null?void 0:s.source)||"",l=(g=t.html)!=null?g:ia(t.text),c=a.indexOf(t.text)===0?a.slice(t.text.length):"",{showTabHint:f}=n,{isSupported:d}=i,{showTabCompletion:p,visible:y,showStyleSuggestions:h}=r;return{showTabHint:f,showStyleSuggestions:h,showTabCompletion:p&&Er(e),content:l,tabText:c,source:u,keywordMatches:(v=(m=o.list)==null?void 0:m.keywordMatches)!=null?v:[],enabled:y&&d!==!1}},JP=yi(oF)(rF);var LA=w(Ie()),Ma=w(W());var iF={token:null,interval:null},$0=fe("passwordlessToken/getTemporaryPasswordlessToken",(e,t)=>P(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return{token:yield n.requestPasswordlessToken()}})),K0=fe("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r($0()),setInterval(()=>r($0()),n)}),eA=ye({name:"passwordlessToken",initialState:iF,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase($0.fulfilled,(t,n)=>{t.token=n.payload.token}),e.addCase(K0.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:tA}=eA.actions,nA=eA.reducer;function sF(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}var rA=zn([sC],e=>e.map(n=>({text:n.response,title:n.name,callToAction:n.callToAction,isLoading:n.isLoading,specialType:n.specialType,rule:{id:sF(n.code),label:n.code,name:n.name,description:n.name}})));var xm=w(W());var G0=w(Ie());var q0=w(k()),uc=()=>(0,q0.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,q0.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 oA={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var Cr=w(k()),aF=({entities:e})=>{let t=_("EntitiesWidgetList",oA),[n,r]=(0,xm.useState)(void 0),o=ce(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),vr(a.text),o(kn({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,xm.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,Cr.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,u)=>(0,Cr.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,Cr.jsx)("span",{className:t.entityText,children:a.text}),(0,Cr.jsxs)("span",{className:t.iconWrapper,children:[(0,Cr.jsx)("span",{className:(0,G0.default)(t.icon),children:(0,Cr.jsx)(uc,{})}),(0,Cr.jsx)("span",{className:(0,G0.default)(t.icon,n===u&&t.iconClicked),children:(0,Cr.jsx)(uc,{})})]})]},a.text))})},iA=aF;var Y0=w(k()),sA=()=>(0,Y0.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Y0.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 X0=w(k()),aA=()=>(0,X0.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,X0.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 Q0=w(k()),lA=()=>(0,Q0.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Q0.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 uA={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var cA={root:"dd-nazq3",rotation:"dd-3EHTv"};var fA=w(k()),lF=({size:e=12})=>{let t=_("LoadingSpinner",cA);return(0,fA.jsx)("span",{style:{width:`${e}px`,height:`${e}px`},className:t.root})},dA=lF;var Z0=w(k()),pA=()=>(0,Z0.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Z0.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var nr=w(k()),uF=()=>{let e=_("Widget",uA),t=Gr(Vn),n=Gr(jn),r=V(pC),o=V(mC),i=V(aC),s=o.filter(l=>l.isPinned),a=o.filter(l=>!l.isPinned),u=l=>{if(l===r){n.call({transcript:"in-memory-transcript"});return}t.call({assistantCode:l,expectFormat:"json-schema:cues",transcript:"in-memory-transcript"})};return o.length===0?null:(0,nr.jsxs)("div",{className:e.root,children:[s.map(({assistant:l,assistantName:c})=>(0,nr.jsx)("button",{type:"button",className:e.button,disabled:i==="loading",onClick:()=>u(l),children:c},l)),a.length>0&&(0,nr.jsxs)(on,{placement:"top-end",children:[(0,nr.jsxs)(on.Trigger,{className:e.trigger,children:[i==="loading"&&(0,nr.jsx)(dA,{}),i==="error"&&(0,nr.jsx)(pA,{}),!["loading","error"].includes(i)&&(0,nr.jsx)(Cp,{"data-testid":"trigger"})]}),(0,nr.jsx)(on.Content,{className:e.nav,children:a.map(({assistant:l,assistantName:c})=>(0,nr.jsx)(on.Button,{className:e.item,disabled:i==="loading",onClick:()=>u(l),children:c},l))})]})]})},mA=uF;var yA=w(W());var gA={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};var hA=w(k()),cF=({width:e})=>{let t=_("LoadingProgressBar",gA);return(0,hA.jsx)("div",{className:t.loadingBar,style:{width:e}})},Sm=cF;var ro=w(k()),wm=({title:e})=>{let t=(0,yA.useRef)(null);return gS(t),(0,ro.jsx)(be,{ref:t,children:(0,ro.jsx)(De,{children:(0,ro.jsxs)(De.Content,{children:[(0,ro.jsx)(De.Title,{children:e}),(0,ro.jsx)(Sm,{width:"60%"}),(0,ro.jsx)(Sm,{width:"90%"}),(0,ro.jsx)(Sm,{width:"50%"})]})})})};var cc={};Lt(cc,{enUS:()=>dF,nlNL:()=>fF});var dF={useCue:[{type:0,value:"Add to message"}],__summarizerAssistant__:[{type:0,value:"Summary"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},fF={useCue:[{type:0,value:"Voeg toe aan bericht"}],__summarizerAssistant__:[{type:0,value:"Samenvatting"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var Gi=w(W());var J0={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",actions:"dd-9Iqn9",thumbsUp:"dd-6QwVx",thumbsDown:"dd-d3E8l",form:"dd-sPNU2",formInput:"dd-F3E4I",formSubmit:"dd-vw5S0",actionButton:"dd-cCWyJ",editableCue:"dd-nWSD-",inputSpace:"dd-DGYB1"};var Pt=w(k()),pF=500,mF=100,gF=({content:e,onChange:t,onCopy:n})=>{let r=(0,Gi.useRef)(null),o=_("WidgetCue",J0);return(0,Gi.useEffect)(()=>{let i=r.current;if(!i)return;i.style.setProperty("height","0px");let s=Math.min(Math.max(i.scrollHeight,mF),pF);i.style.setProperty("height",`${s}px`)},[e]),(0,Pt.jsx)("textarea",{ref:r,className:o.editableCue,onCopy:n,onChange:t,value:e})},hF=({cue:e,onCallToAction:t,onRemove:n,onCopy:r,onUse:o})=>{var h;let i=_("WidgetCue",J0),s=re(cc),a=Bo(),u=q("hasKeyboardInput"),[l,c]=(0,Gi.useState)(e.text),f=()=>{t&&t(e),n(e)},d=g=>{r&&r(g,e)},p=g=>{o&&o(g,e)},y=g=>{g.preventDefault(),g.stopPropagation(),n(e)};return(0,Gi.useEffect)(()=>{a("Assistant response displayed",{name:e.rule.name,description:e.rule.description,group:e.rule.label,cueText:e.text})},[]),(0,Pt.jsxs)(be,{"data-testid":"cue",children:[(0,Pt.jsx)(De,{children:(0,Pt.jsxs)(De.Content,{children:[e.title&&(0,Pt.jsx)(De.Title,{className:i.title,"data-testid":"widget-cue-title",children:e.rule.label.startsWith("__")?s(e.rule.label):e.title}),e.specialType==="summary"?(0,Pt.jsx)(gF,{content:l,onCopy:()=>{let g=document.getSelection();g&&d(g.toString())},onChange:g=>{var m;return c((m=g.target.value)!=null?m:"")}}):(0,Pt.jsx)(ga,{content:e.text,useLabel:s("useCue"),copyLabel:s("copyCue"),onCopy:d,onUse:u?p:void 0})]})}),(0,Pt.jsxs)(be.ButtonsContainer,{children:[(0,Pt.jsxs)("div",{className:i.actions,children:[e.specialType==="summary"&&(0,Pt.jsx)(be.Button,{onClick:()=>d(l),children:s("copyCue")}),e.callToAction&&(0,Pt.jsx)(be.Button,{onClick:f,children:e.callToAction.label}),(0,Pt.jsx)(be.Button,{onClick:y,children:s("removeCue")})]}),e.specialType==="summary"?(0,Pt.jsx)(Ii,{eventName:"summary feedback",feedbackText:(h=e.text)!=null?h:"",feedbackType:"summary",eventData:{summary:e.text}}):(0,Pt.jsx)(Ii,{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"})]})]})},vA=hF;var Ia=w(k()),yF=({cues:e})=>{let t=ce(),n=en(),r=re(cc),o=Bo(),i=l=>{t(uC({code:l.rule.label})),o("Assistant response closed",{name:l.rule.name,group:l.rule.label,description:l.rule.description,cueText:l.text})},s=(l,c)=>{switch(vr(l),c.specialType){case"summary":o("summary copied to clipboard",{originalText:c.text,finalText:l,assistant:c.rule.label});break;default:o("Assistant response copied",{name:c.rule.name,group:c.rule.label,description:c.rule.description,copiedText:l})}},a=l=>{l.callToAction&&(t(tp(l)),o("Assistant call to action",{name:l.rule.name,group:l.rule.label,description:l.rule.description,eventName:l.callToAction.event,value:l.callToAction.value}))},u=(l,c)=>{n.send(yr,{text:l,suggestion:{source:"cue",sourceText:l}}),o("Assistant response used",{name:c.rule.name,group:c.rule.label,description:c.rule.description,usedText:l})};return(0,Ia.jsx)(Ia.Fragment,{children:e.map(l=>l.isLoading?(0,Ia.jsx)(wm,{title:l.rule.label.startsWith("__")?r(l.rule.label):l.title},l.rule.id):(0,Ia.jsx)(vA,{cue:l,onCallToAction:a,onRemove:i,onCopy:s,onUse:u},l.rule.id))})},xA=yF;var bm=w(W());var SA={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var rr=w(k());function vF(e,t){return t.split(".").reduce((n,r)=>!n||typeof n!="object"||!(r in n)?null:n[r],e)}var wA=({data:e,schema:t})=>{let n=_("WidgetCustomData",SA),r=o=>{vr(o)};return(0,bm.useEffect)(()=>{Q.info("Custom data",e,t)},[e]),(0,rr.jsx)("dl",{className:n.root,children:t.map(o=>{let i=vF(e,o.path);return(0,rr.jsxs)(bm.Fragment,{children:[(0,rr.jsx)("dt",{className:n.label,children:o.label}),(0,rr.jsx)("dd",{className:n.value,children:o.type==="boolean"&&i?(0,rr.jsx)("span",{className:n.isTrue,children:o.trueValue}):o.type==="boolean"&&!i?(0,rr.jsx)("span",{className:n.isFalse,children:o.falseValue}):i?(0,rr.jsxs)("button",{type:"button",onClick:()=>r(i),className:n.copyButton,children:[(0,rr.jsx)("span",{className:n.copyButtonText,children:i}),(0,rr.jsx)(uc,{})]}):"-"})]},o.label)})})};var sn=w(W());var ex=w(k()),bA=()=>(0,ex.jsx)("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"ReplayIcon",children:(0,ex.jsx)("path",{d:"M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8"})});var La={};Lt(La,{enUS:()=>xF,nlNL:()=>SF});var xF={titleKnowledgeAssistant:[{type:0,value:"Knowledge Assistant"}],inputPlaceholder:[{type:0,value:"What is your question?"}],useCue:[{type:0,value:"Add to message"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Submit"}],resetLabel:[{type:0,value:"Reset"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},SF={titleKnowledgeAssistant:[{type:0,value:"Knowledge Assistant"}],inputPlaceholder:[{type:0,value:"Wat is je vraag?"}],useCue:[{type:0,value:"Voeg toe aan bericht"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Verzend"}],resetLabel:[{type:0,value:"Reset"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var tx={form:"dd-pleCH",formInput:"dd-pGJMY",formSubmit:"dd--gkRg",actionButton:"dd-I2NEH",sources:"dd-xf9c6",source:"dd-a-vyX",tooltip:"dd-EsgcZ",linkContent:"dd-gARDA",showMoreSources:"dd-uDGi-"};var Re=w(k()),wF=3,bF=({sources:e,onClick:t})=>{let n=re(La),r=_("WidgetKnowledgeAssistant",tx),[o,i]=(0,sn.useState)(!1),s=o?e:e.slice(0,wF);return s.length===0?null:(0,Re.jsxs)("ul",{className:r.sources,children:[s.map(a=>(0,Re.jsx)("li",{className:r.source,"data-testid":"knowledge-assist-source",children:(0,Re.jsxs)(on,{tooltip:!0,placement:"top-start",children:[(0,Re.jsx)(on.Trigger,{as:"a",className:r.link,rel:"noreferrer",target:"_blank",href:a.url,onClick:u=>{u.stopPropagation(),t(a)},children:(0,Re.jsx)("span",{className:r.linkContent,children:a.name})}),a.url&&(0,Re.jsx)(on.Content,{className:r.tooltip,children:decodeURIComponent(a.url)})]})},a.name)),s<e&&(0,Re.jsx)("button",{type:"button",className:r.showMoreSources,onClick:()=>i(!0),children:n("showMore",{amount:e.length-s.length})})]})},EF=({innerRef:e,item:t,index:n,hasKeyboardInput:r,onCopy:o,onUse:i,onSourceClick:s})=>{var u;let a=re(La);return(0,Re.jsxs)(be,{"data-testid":"knowledge-assist-answer",ref:e,children:[(0,Re.jsx)(De,{children:(0,Re.jsxs)(De.Content,{children:[(0,Re.jsx)(De.Title,{children:t.question}),(0,Re.jsx)(ga,{content:t.answer.answer,useLabel:a("useCue"),copyLabel:a("copyCue"),onCopy:o,onUse:r?i:void 0}),(0,Re.jsx)(bF,{sources:(u=t.answer.sources)!=null?u:[],onClick:l=>s(l,t.question)})]})}),(0,Re.jsxs)(be.ButtonsContainer,{children:[(0,Re.jsx)("div",{}),(0,Re.jsx)(Ii,{eventName:"knowledge assist feedback",eventData:{question:t.question,isFollowUpQuestion:n>0,isAgent:!0,answer:t.answer.answer},feedbackText:t.answer.answer,feedbackType:"assistant"})]})]})},nx=(0,sn.createContext)(null),EA=({children:e})=>{let[t,n]=(0,sn.useState)(null),r=V(Eu("knowledge-assist")),[o,i]=(0,sn.useState)(!1),[s,a]=(0,sn.useState)(null),u=ce(),l=Gr(d=>xu({input:d,threadId:t,onNewThreadId(p){n(p)}})),c={isEnabled:r,isSubmitting:o,threadId:t,pendingInput:s,onSubmit(d){return P(this,null,function*(){i(!0),a(d),yield l.call(d),i(!1),a(null)})},onReset(){t&&u(ra(t))}};return(0,Re.jsx)(nx.Provider,{value:c,children:e})},TA=()=>{let e=re(La),t=_("WidgetKnowledgeAssistant",tx),n=(0,sn.useContext)(nx),r=(0,sn.useRef)(null),[o,i]=(0,sn.useState)(""),s=l=>{i(l.target.value)},a=l=>{l.preventDefault(),n.onSubmit(o).then(()=>{var c;r.current&&((c=r.current)==null||c.focus(),i(""))})},u=l=>{l.preventDefault(),n.onReset()};return n.isEnabled?(0,Re.jsxs)("form",{className:t.form,onSubmit:a,children:[(0,Re.jsx)("input",{ref:r,className:t.formInput,placeholder:e("inputPlaceholder"),type:"text",disabled:n.isSubmitting,value:o,onChange:s}),(0,Re.jsx)("button",{type:"submit",disabled:n.isSubmitting||o==="",className:t.formSubmit,children:e("submitLabel")}),(0,Re.jsx)("button",{type:"button",title:e("resetLabel"),disabled:n.threadId===null||n.isSubmitting,onClick:u,className:t.actionButton,children:(0,Re.jsx)(bA,{})})]}):null},CA=()=>{var c,f;let e=re(La),t=Bo(),n=(0,sn.useRef)(null),r=(0,sn.useContext)(nx),o=(f=V(vu((c=r.threadId)!=null?c:-1)))!=null?f:[],i=q("hasKeyboardInput"),s=en(),a=d=>{vr(d),t("Assistant response copied",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",copiedText:d})},u=(d,p)=>{t("knowledge assist source viewed",{question:p,sourceViewed:d.url||d.name})},l=d=>{s.send(yr,{text:d,suggestion:{source:"cue",sourceText:d}}),t("Assistant response used",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",usedText:d})};return!r.isEnabled||(o==null?void 0:o.length)===0&&!r.isSubmitting?null:(0,Re.jsx)(ar,{type:"knowledge",title:e("titleKnowledgeAssistant"),"data-testid":"knowledge",children:(0,Re.jsxs)(Gt,{withDivider:!0,children:[o.map((d,p)=>(0,Re.jsx)(EF,{innerRef:p===o.length-1?n:void 0,item:d,index:p,hasKeyboardInput:i,onCopy:a,onUse:l,onSourceClick:u},`${d.question}_${d.answer}_${p}`)),r.pendingInput&&(0,Re.jsx)(wm,{title:r.pendingInput})]})})};var RA=w(W());var CF=/(https?:\/\/[^\s]+)/,kA=e=>e.split(" ").find(t=>CF.test(t));var Nn=w(k()),kF=({suggestion:e,lines:t,onUse:n})=>{var f;let r=e.text||e.url||e.message,o=kA(r),i=re(Wu),s=q("showImages"),a=q("fallbackImage"),u=q("hasKeyboardInput"),l=d=>{d.preventDefault(),d.stopPropagation(),u&&n(r)},c=(0,RA.useCallback)(d=>{window.open(o,"_blank"),d.stopPropagation(),d.preventDefault()},[o]);return(0,Nn.jsxs)(be,{onClick:u?l:void 0,"data-testid":"edit-suggestion",children:[(0,Nn.jsxs)(De,{children:[s&&e.image&&(0,Nn.jsx)(De.Image,{src:gm(e,"small",a||void 0),title:e.title}),(0,Nn.jsxs)(De.Content,{children:[e.title&&(0,Nn.jsx)(De.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((f=e.searchKeywords)==null?void 0:f.length)>0&&(0,Nn.jsx)(be.Labels,{labels:e.searchKeywords}),(0,Nn.jsx)(De.Content,{cropText:t==="single",lineClamp:t==="multiple",children:r})]})]}),(0,Nn.jsxs)(be.Actions,{children:[o&&(0,Nn.jsx)(be.ActionButton,{onClick:c,label:i("visitUrl")}),u&&(0,Nn.jsx)(be.ActionButton,{primary:!0,onClick:l,label:i("useSuggestion")})]})]})},PA=kF;var dc=w(k()),RF=({lines:e,suggestions:t})=>{let n=en(),r=(o,i)=>{n.send(yr,{text:o,suggestion:A(b({},i),{source:i.source,sourceText:i.text})})};return(0,dc.jsx)(dc.Fragment,{children:t.map(o=>(0,dc.jsx)(PA,{suggestion:o,lines:e,onUse:i=>r(i,o)},o.text||o.url||o.message))})},AA=RF;var Em={};Lt(Em,{enUS:()=>PF,nlNL:()=>AF});var PF={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},AF={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Oa={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",sectionList:"dd-bF9pF",footer:"dd-tvofr",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",footerShortcut:"dd-dH7XJ",link:"dd-DRo0x"};var se=w(k()),OA=(e,t)=>{let n=V(Nt);(0,Ma.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},IF=({onLogIn:e})=>{let t=_("Widget",Oa),n=q("isEmbedded"),r=q("adminUrl");return(0,se.jsx)("div",{className:t.loginText,children:(0,se.jsx)("div",{children:(0,se.jsx)(im,{isEmbedded:n,loginUrl:r,onLogIn:e})})},"login")},IA=({text:e})=>{let t=_("Widget",Oa);return(0,se.jsx)("div",{className:t.stateText,children:(0,se.jsx)("div",{children:(0,se.jsx)("p",{children:e})})},"notification")},LF=()=>{let e=re(Em),t=ce(),n=_("Widget",Oa),r=q("showSearch"),o=q("showSummaryCommand"),i=q("showKnowledgeSearch"),s=V(Eu("knowledge-assist")),a=q("isEmbedded"),u=V(ca("/admin/")),l=en(),c=q("productName"),f=q("hasKeyboardInput"),d=Gr(()=>jn({})),p=r||o||i||u;return OA(()=>{if(a)return t(K0()),()=>{t(tA())}},[t,a]),!p||!f?null:(0,se.jsx)(ar,{title:e("actions"),type:"shortcuts",children:(0,se.jsxs)("div",{className:n.shortcutList,children:[r&&(0,se.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-search","aria-label":e("linkSearch"),onClick:()=>l.send("ShowCommandPalette",{isOpen:!0}),children:[(0,se.jsx)(sa,{}),e("linkSearch")]}),o&&!s&&(0,se.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-summary","aria-label":e("linkSummary"),disabled:d.state==="loading",onClick:()=>d.call(),children:[(0,se.jsx)(lA,{}),e("linkSummary")]}),i&&!s&&(0,se.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-knowledge-assist","aria-label":e("linkKnowledgeSearch"),onClick:()=>l.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,se.jsx)(aA,{}),e("linkKnowledgeSearch")]}),u&&(0,se.jsxs)("a",{className:n.shortcut,target:"_blank",href:u,"data-testid":"shortcut-studio-login","aria-label":e("linkStudioLogin",{productName:c}),rel:"noreferrer",children:[(0,se.jsx)(sA,{}),e("linkStudioLogin",{productName:c})]})]})})},OF=()=>{let e=ce(),t=V(bu),n=V(gC),r=V(rA),o=V(TT),i=V(pp),s=V(Qp),a=V(Ei),u=V(hr);return(0,Ma.useEffect)(()=>{!!o&&!n&&Q.warn("Custom data provided, but no schema.")},[o,n]),OA(()=>{t.forEach(({type:l})=>{l==="entities"?e(Kn()):Dc.includes(l)||e(tr(l))})},[e,u,a]),(0,Ma.useEffect)(()=>{r.length>0&&!t.some(l=>l.type==="cues")&&Q.warn("Received cues, but cues are not configured in widget.")},[t,r]),(0,se.jsx)(Ma.Fragment,{children:t.map(({type:l,title:c,amount:f,lines:d,schema:p})=>{var y,h;switch(l){case"entities":return i&&i.length>0&&(0,se.jsx)(ar,{type:l,title:c,"data-testid":`type-${l}`,children:(0,se.jsx)(iA,{entities:i})},l);case"cues":return r&&r.length>0&&(0,se.jsx)(ar,{type:l,title:c,"data-testid":`type-${l}`,children:(0,se.jsx)(Gt,{withDivider:!0,children:(0,se.jsx)(xA,{cues:r})})},l);case"custom-data":return o&&p&&(0,se.jsx)(ar,{type:l,title:c,"data-testid":`type-${l}`,children:(0,se.jsx)(Gt,{withDivider:!0,children:(0,se.jsx)(wA,{data:o,schema:p})})},l);default:return((h=(y=s[l])==null?void 0:y.suggestions)==null?void 0:h.length)>0&&(0,se.jsx)(ar,{type:l,title:c,"data-testid":`type-${l}`,children:(0,se.jsx)(Gt,{withDivider:!0,children:(0,se.jsx)(AA,{lines:d,contentType:l,suggestions:s[l].suggestions.slice(0,f)||[]})})},l)}})})},MF=({children:e})=>{let t=_("Widget",Oa);return(0,se.jsx)("div",{className:t.footer,children:e})},NF=({onLogIn:e})=>{let t=re(Em),n=_("Widget",Oa),r=V(Zs),o=V(Nt),i=V(lT),s=V(Ei),a=V(Eu("knowledge-assist"));return r===!1?(0,se.jsx)(IA,{text:t("notSupported")}):o===!1?(0,se.jsx)(IF,{onLogIn:e}):!s||!i||o===null?(0,se.jsx)(IA,{text:t("waiting")}):(0,se.jsx)("div",{className:(0,LA.default)(n.root),"data-testid":"widget",children:(0,se.jsxs)(EA,{children:[(0,se.jsxs)(Mc,{className:n.sectionList,children:[(0,se.jsx)(LF,{}),(0,se.jsx)(OF,{}),(0,se.jsx)(CA,{})]}),(0,se.jsxs)(MF,{children:[(0,se.jsx)(TA,{}),a&&(0,se.jsx)(mA,{})]})]})})},MA=NF;function Na(e){let t=new Range;return t.selectNodeContents(e),t}function NA(e,t,n){try{return Yo(e,t,n),!0}catch(r){return!1}}function Tm(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function Cm(e){return"tagName"in e&&e.tagName==="BR"}var fc=/[\u200B-\u200D\uFEFF]/g;function Yo(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(u,l){let c=-1,f=/[\u200B-\u200D\uFEFF]/;if(!f.test(u))return l;for(let d=0;d<=u.length;d++)if(f.test(u[d])||c++,c===l)return d;throw new Error("Offset out of range")}function a(u){switch(u.nodeType){case Node.TEXT_NODE:{let l=u.textContent,c=l.replace(fc,""),f=o+c.length,d=t>=o&&t<=f,p=n>=o&&n<=f;if(d){let y=s(l,t-o);y===0&&!p?r.setStartBefore(u):r.setStart(u,y)}p&&(r.setEnd(u,s(l,n-o)),i=!0),o=f;break}case Node.ELEMENT_NODE:{if(Cm(u)&&(o===t&&r.setStartBefore(u),o++,o===n)){r.setEndAfter(u),i=!0;return}for(let c=0;c<u.childNodes.length&&(a(u.childNodes[c]),!i);c++);let l=u.lastChild;Tm(u)&&l&&!Tm(l)&&!Cm(l)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function pc(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,u,l=0;function c(f){let d=f===e,p=f===n,y=f===o;switch(f.nodeType){case Node.TEXT_NODE:{let h=f.textContent;p&&(a=l+h.substring(0,r).replace(fc,"").length),y&&(u=l+h.substring(0,i).replace(fc,"").length),l+=h.replace(fc,"").length;break}case Node.ELEMENT_NODE:{if(Cm(f)&&f.nextSibling){l++;break}!d&&Tm(f)&&f.previousSibling&&l++;for(let h=0;h<f.childNodes.length;h++){let g=p&&h===r,m=y&&h===i;if(g&&(a=l),m&&(u=l),u!==void 0||((!g||!s)&&c(f.childNodes[h]),y&&h===i-1&&(u=l),u!==void 0))break}y&&(u=l);break}default:break}}if(c(e),u===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:u,end:u}}function mc(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,u="";function l(c){let f=c===e,d=c===n,p=c===o;switch(d&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let y=d?r:0,h=p?i:void 0;u+=c.textContent.replace(fc,"").substring(y,h);break}case Node.ELEMENT_NODE:{if(!s&&a===1&&Cm(c)&&c.nextSibling){u+=`
|
|
81
|
+
c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var M0=w(k()),E4={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},gP=({className:e,color:t})=>(0,M0.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,M0.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:E4[t||"pink"]})});var hP={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var N0={};Lt(N0,{enUS:()=>T4,nlNL:()=>C4});var T4={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},C4={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Wi=w(k()),vP=({onLogIn:e})=>{let t=re(N0),n=q("floatingMenu"),r=q("productName"),o=ce(),i=V(Nt),s=_("FloatingMenu",hP);if(i===null||n===!1)return null;let a=()=>{i===!0?o(Rn(!0)):e()};return(0,Wi.jsxs)("button",{className:(0,yP.default)(s.root,{[s.isLoggedIn]:i,[s.isLoggedOut]:!i}),onClick:a,children:[(0,Wi.jsx)("div",{className:s.text,children:t(i?"search":"signin",{productName:r})}),(0,Wi.jsxs)("div",{className:s.icon,children:[(0,Wi.jsx)(gP,{className:s.logo,color:"pink"}),i===!1&&(0,Wi.jsx)(mP,{className:s.lock})]})]})};var om=w(W());function Er(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 k4={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},em=({ui:e})=>e.overlayCollapsed,xP=ye({name:"ui",initialState:k4,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:ic,setInputFocus:tm,setOverlayCollapsed:$o,setOpenOverlayWhenTyping:SP,setOverlayCollapsedUserOverwrite:wP}=xP.actions,bP=xP.reducer;var nm=w(W());var Ko=w(W());var EP=w(W());function TP(e,t,n){(0,EP.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var CP={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var $i=w(k()),P4=["search","personal-collection-search","search-autocomplete"];function A4(e,t,n,r={}){var i;let o="";return P4.includes(t)?o=kC(Pv(e,n,{stripAgentPart:!0}),(i=r.searchKeywords)!=null?i:[n]):o=Pv(e,n,r),r.placeholders===!0&&(o=RC(o)),o}var I4=()=>{},L4=({selected:e,suggestion:t})=>{let n=q("inlineSuggestions"),r=V(Js),[o,i]=(0,Ko.useState)(!1),s=q("enableSuggestionFeedback"),a=V(d=>d.input.text),u=ce(),l=_("TextSuggestion",CP),c=(0,Ko.useRef)(null);(0,Ko.useEffect)(()=>{let d=setTimeout(()=>{u(fT({text:t.text,suggestion:t}))},500);return()=>{clearTimeout(d)}},[t]),TP(c,"click",()=>{u(Bn({suggestion:t,text:t.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let f=(0,Ko.useMemo)(()=>A4(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,$i.jsxs)("div",{className:l.root,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[(0,$i.jsx)(be,{ref:c,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:I4,children:(0,$i.jsx)(oa,{containerTagName:"div",noWrap:!1,tagName:"span",className:l.formattedText,content:f})}),s&&o&&(0,$i.jsx)("div",{className:l.actions,children:(0,$i.jsx)(Xp,{source:"overlay",context:a,suggestion:t})})]})},kP=L4;var _0=w(k()),O4=({suggestions:e,selectedIndex:t,reverse:n})=>{let r=(0,nm.useMemo)(()=>{let o=e.map((i,s)=>(0,_0.jsx)(kP,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]);return(0,_0.jsx)(nm.Fragment,{children:r})},rm=O4;var RP={root:"dd-PfvRI",paper:"dd-HYlyY"};var sc=w(k()),M4=({textSuggestions:e,selectedIndex:t})=>{let n=(0,om.useRef)(null),r=_("InlineSuggestionsOverlay",RP),o=V(Er),i=ce(),s=V(Nt),a=V(Zs),u=V(em),l=q("showTextSuggestions");return Uo(()=>{setTimeout(()=>{i($o({collapse:!0,skipWhenInputFocus:!0}))})}),(0,om.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`}),u||!o||!l||e.length===0||s!==!0||a===!1?null:(0,sc.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,sc.jsx)("div",{ref:n,className:r.paper,children:(0,sc.jsx)(Gt,{children:(0,sc.jsx)(rm,{suggestions:e,selectedIndex:t})})})})},N4=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),PP=yi(N4)(M4);var ac=w(k()),_4=({children:e})=>{let n=q("locale").replace("-","");return(0,ac.jsx)(pv.Provider,{value:n,children:e})},D4=({store:e,customStyles:t={},children:n})=>(0,ac.jsx)(qy,{store:e,children:(0,ac.jsx)(_4,{children:(0,ac.jsx)(Wa.Provider,{value:t,children:n})})}),Ki=D4;var sm=w(Ie()),Ra=w(W());var AP=w(W());function IP(e,t){let[n,r]=(0,AP.useState)(()=>{if(typeof window=="undefined")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return Q.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){Q.error(s)}}]}var LP=()=>/Mac/i.test(navigator.platform);var MP=w(Ie()),Jr=w(W());var D0={};Lt(D0,{enUS:()=>F4,nlNL:()=>H4});var F4={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"}]}]},H4={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 OP={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var qo=w(k()),F0=(e,t,n)=>r=>(0,qo.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),z4=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=re(D0),s=en(),a=_("Login",OP),u=q("productName"),l=(0,Jr.useCallback)(g=>{g.preventDefault(),r&&r(parseInt(g.target.value,10))},[]),c=(0,Jr.useCallback)(g=>{g.preventDefault(),s.send(na,!0)},[t]),f=(0,Jr.useMemo)(()=>g=>(0,qo.jsx)("a",{onClick:v=>{v.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[t]),d=(0,Jr.useCallback)(g=>(0,qo.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:p,hour:y,day:h}=(0,Jr.useMemo)(()=>({min:F0(a,60*10,l),hour:F0(a,60*60,l),day:F0(a,60*60*12,l)}),[]);return(0,qo.jsxs)("div",{className:(0,MP.default)(e,a.root),children:[i("loginPlease",{login:n?d:f,productName:u}),r&&(0,qo.jsxs)(Jr.Fragment,{children:[(0,qo.jsx)("br",{}),i("snooze",{min:p,hour:y,day:h})]})]})},im=z4;var NP={root:"dd-DoQhb",text:"dd-Jwnev"};var lc=w(k()),B4=({title:e})=>{let t=_("SearchTrigger",NP),n=ce();return(0,lc.jsxs)("button",{type:"button",className:t.root,onClick:()=>n(Rn(!0)),children:[(0,lc.jsx)(sa,{}),(0,lc.jsx)("span",{className:t.text,children:e})]})},_P=B4;var H0={};Lt(H0,{enUS:()=>U4,nlNL:()=>j4});var U4={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"}]},j4={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 DP={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 je=w(k()),V4=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=_("SuggestionsOverlay",DP),o=re(H0),i=V(Er),s=dT(),a=ce(),u=(0,Ra.useRef)(null),l=q("searchTriggerKey"),c=q("productName"),f=V(em),d=V(Nt),p=V(Zs),[y,h]=(0,Ra.useState)(null),g=q("showSearch"),m=q("showTextSuggestions"),v=q("adminUrl"),x=q("isEmbedded"),[S,C]=IP("dd-snooze-until-ms",0),T=f||S>Date.now(),R=e.filter(G=>G.source!=="gpt").length,L=()=>{T&&C(0),a(wP(!T))},O=G=>{let D=Date.now()+G*1e3;C(D),Q.info(`Snooze until: ${new Date(D)}`),a($o({collapse:!0}))};return(0,Ra.useEffect)(()=>{R===0&&h(null)},[e,R]),Uo(()=>{a($o({collapse:!0,skipWhenInputFocus:!0}))}),d===null||p===!1?null:d===!1?(0,je.jsxs)("div",{ref:u,className:(0,sm.default)(r.root,{[r.isCollapsed]:T}),children:[!T&&(0,je.jsxs)("div",{className:r.triggers,children:[(0,je.jsx)("div",{style:{flex:1}}),(0,je.jsx)("div",{className:r.triggersRight,children:(0,je.jsx)(Jo,{className:r.toggleButton,title:o("collapse"),onClick:L,isCollapsed:!1})})]}),(0,je.jsx)("div",{className:r.toggleButtonWrapper,children:(0,je.jsx)(Jo,{className:r.toggleButton,title:o("open",{productName:c}),onClick:L,isCollapsed:!0})}),(0,je.jsx)("div",{className:r.collapsible,children:(0,je.jsx)(im,{loginUrl:v,isEmbedded:x,onLogIn:n,onSnooze:O})})]}):!s||!i?null:(0,je.jsxs)("div",{ref:u,className:(0,sm.default)(r.root,{[r.isCollapsed]:T}),children:[!T&&(0,je.jsxs)("div",{className:r.triggers,children:[(0,je.jsx)("div",{style:{flex:1},children:g&&(0,je.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>h(o(LP()?"searchHintMac":"searchHintWindows",{searchTriggerKey:l.toUpperCase()})),onMouseLeave:()=>h(null),children:(0,je.jsx)(_P,{title:o("search")})})}),(0,je.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,je.jsx)("div",{className:(0,sm.default)(!y&&r.hintsHidden,r.hints),children:y}),(0,je.jsx)(Jo,{className:r.toggleButton,title:o("collapse"),onClick:L,isCollapsed:!1})]})]}),(0,je.jsx)("div",{className:r.toggleButtonWrapper,children:(0,je.jsx)(Jo,{className:r.toggleButton,title:o("open",{productName:c}),onClick:L,isCollapsed:!0})}),R>0&&m&&(0,je.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,je.jsx)(Gt,{children:(0,je.jsx)(rm,{suggestions:e,selectedIndex:t,reverse:!0})})})]})},W4=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),FP=yi(W4)(V4);var vm=w(Ie());var no=w(W());var Pa=w(W());function am(e){return e.contentEditable==="true"}function $4(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 HP(e){let{selectionStart:t,selectionEnd:n}=am(e)?$4(e):e;return[t,n]}function zP(e){let[,t]=(0,Pa.useState)(),n=(0,Pa.useRef)(null);return n.current=HP(e),(0,Pa.useEffect)(()=>{let r=()=>{var a;let[o,i]=(a=n.current)!=null?a:[],s=HP(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 BP(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(_c);if(!s||s.length===0)return;let a=0;s.find(u=>{let l=r.indexOf(u,a);return o>l&&i<l+u.length?(n.selectionStart=l,n.selectionEnd=l+u.length,!0):(a=l+u.length,!1)})}var UP=w(W()),K4=["div","span","mark","strong","b","i","u","em"];function z0(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(K4.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,UP.cloneElement)(r,{children:z0(s,t,n+1)})]}return[...e,...t]}function qi(e){return e.tagName.toLowerCase()==="textarea"}var jP={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 qP=w(Ie());var pm=w(W());var Aa=w(W());function VP(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function lm(e){let t=(0,Aa.useRef)(null),[n,r]=(0,Aa.useState)(!1);return(0,Aa.useEffect)(()=>{var c;let o=!1,i=parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[s,a]=VP((f,d)=>{let p=t.current;if(!p)return;let y=f/i,h=d/i,g=p.getBoundingClientRect(),m=y>g.x&&y<g.x+g.width&&h>g.y&&h<g.y+g.height;m&&!o?(o=!0,r(!0)):!m&&o&&(o=!1,r(!1))},({clientX:f,clientY:d})=>[f,d]),[u,l]=VP(()=>{o=!1,r(!1)});return e.addEventListener("mousemove",s),e.addEventListener("mouseleave",u),()=>{a(),l(),e.removeEventListener("mousemove",s),e.removeEventListener("mouseleave",u)}},[t]),[t,n]}function WP(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function um(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function $P(e){return e!=null}var KP=w(Ie()),cm=w(W());var eo={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 B0=w(k()),dm=(0,cm.forwardRef)((o,r)=>{var i=o,{className:e,children:t}=i,n=te(i,["className","children"]);let s=(0,cm.useRef)(null),a=_("TabCompletion",eo);return(0,B0.jsx)("div",A(b({ref:um([s,r]),className:(0,KP.default)(e,a.popoverContentContainer)},n),{children:(0,B0.jsx)("div",{className:a.popoverContent,children:t})}))});var Go=w(k()),q4=e=>t=>{let n=qv(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},G4=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=_("TabCompletion",eo),s=Sp(),a=(0,pm.useMemo)(()=>q4(e.getBoundingClientRect()),[e]),[u,l]=lm(e);return(0,pm.useEffect)(()=>{l?s.open():s.close()},[l]),(0,Go.jsxs)("span",{children:[(0,Go.jsx)("mark",{ref:um([u,s.triggerRef]),className:(0,qP.default)(i.matchKeyword,{[i.hover]:l}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,Go.jsx)(fa,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,Go.jsx)(dm,{style:n,children:(0,Go.jsx)("div",{className:i.hintText,children:o})})})]})},fm=class extends $r{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=>A(b({},o),{keywordRegex:new RegExp(`\\b${WP(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),u=n.charAt(s.index+i.keyword.length);return a==="{"&&u==="}"?null:{index:s.index,length:s[0].length,match:s[0],matchString:s[0],suggestion:i.suggestion,preparedKeywordMatch:i,valid:!0}}).filter($P);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,Go.jsx)(G4,{inputElement:r.inputElement,suggestion:r.suggestion,inputStyle:r.inputStyle,boundaryRef:r.boundaryRef,children:n},`keyword_${r.matchString}_${r.key}`)}asTag(){return"mark"}};var GP=w(Ie());var U0=w(k()),Y4=({inputElement:e,children:t})=>{let n=_("TabCompletion",eo),[r,o]=lm(e);return(0,U0.jsx)("mark",{ref:r,className:(0,GP.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},mm=class extends $r{match(t){let n=t.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(t,n){return(0,U0.jsx)(Y4,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var hm=w(Ie());var Vt=w(W());var j0=w(k()),YP=()=>(0,j0.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,j0.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 Tr=w(W());var QP=w(vv());var XP={root:"dd-ky-Bv",content:"dd-kV5e1"};function gm(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 V0(e){return e.replace("https://www.","").replace("https://","")}var Mn=w(k()),X4=3,Q4=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),Z4=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=X4})=>{let i=_("LinkSearch",XP),[s,a]=(0,Tr.useState)(""),u=ce(),l=V(oP("url")),c=V(MT("URL")),f=(0,Tr.useMemo)(()=>c.map(Q4),[c]),[d,p]=(0,Tr.useState)(f.length-1),y=q("fallbackImage"),h=x=>{let S=x.target;a(S.value)},g=(x,S)=>{x.stopPropagation(),x.preventDefault(),window.open(S,"_blank")},m=x=>{var T;let S=d-1<0?f.length-1:d-1,C=d+1===f.length?0:d+1;x.code==="Escape"&&(a(""),t()),x.code==="ArrowUp"&&p(S),x.code==="ArrowDown"&&p(C),x.code==="Enter"&&e(((T=f[d])==null?void 0:T.text)||s)},v=(0,Tr.useCallback)((0,QP.default)(x=>{u(Si({query:x,type:"URL",tags:["link-search"]}))},300),[]);return(0,Tr.useEffect)(()=>{s&&v(s)},[s]),(0,Tr.useEffect)(()=>()=>{u(Vf())},[]),(0,Mn.jsxs)("div",{className:i.root,children:[(0,Mn.jsx)(Gt,{withDivider:!0,children:(s?f:l).slice(0,o).map((x,S)=>(0,Mn.jsx)(be,{selected:d===S,onClick:()=>e(x.text),"data-testid":"linksearch-suggestion",children:(0,Mn.jsxs)(De,{children:[(0,Mn.jsx)(De.Image,{src:gm(x,"small",y||void 0),title:x.title||x.text}),(0,Mn.jsxs)(De.Content,{className:i.content,cropText:!0,children:[(0,Mn.jsx)(De.Title,{children:x.title||V0(x.text)}),x.title&&V0(x.text)]}),(0,Mn.jsx)(be.Actions,{children:(0,Mn.jsx)(be.ActionButton,{label:r,onClick:C=>g(C,x.text)})})]})},x.text))}),(0,Mn.jsx)(gu,{value:s,onChange:h,autoFocus:!0,placeholder:n,onKeyUp:m})]})},ZP=Z4;var W0={};Lt(W0,{enUS:()=>J4,nlNL:()=>eF});var J4={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},eF={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var jt=w(k()),tF=(0,Vt.forwardRef)((e,t)=>{let n=_("TabCompletion",eo);return(0,jt.jsx)("mark",{ref:t,className:(0,hm.default)(n.matchSelection)},"selection-start")}),nF=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=re(W0),s=_("TabCompletion",eo),a=(0,Vt.useRef)(null),u=(0,Vt.useRef)(null),[l,c]=(0,Vt.useState)(null),f=ce(),d=Sp(document.activeElement===r),[p]=(0,Vt.useState)(()=>document.createRange());d.triggerRef.current=p,(0,Vt.useEffect)(()=>()=>p.detach(),[]),(0,Vt.useEffect)(()=>{let h=e.current,g=a.current;!h||!g||(p.setStart(h,0),p.setEnd(g,0))},[e.current,a.current]),Uo(()=>{d.close()});let y=(0,Vt.useCallback)(h=>{let g=p.toString(),m=/^http(s?):\/\//.test(h)?h:`https://${h}`;f(Ff({text:`[${g}](${m})`,replace:"selection"}))},[]);return(0,jt.jsxs)("span",{children:[(0,jt.jsx)("mark",{ref:a,className:(0,hm.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,jt.jsx)(fa,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,jt.jsxs)(dm,{style:n,ref:u,children:[(0,jt.jsx)("div",{className:(0,hm.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:l!==null}),children:(0,jt.jsxs)("button",{type:"button",tabIndex:l===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,jt.jsx)(YP,{}),(0,jt.jsx)("span",{children:"\xA0"}),(0,jt.jsx)("span",{children:i("insertLink")})]})}),l==="insertLink"&&(0,jt.jsx)(ZP,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:y,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},ym=class extends $r{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,Vt.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[r,o]=this.props.selection;if(r===o)return null;let i=this.foundIndex===0?r:o,s=i>=this.charCount&&i<=this.charCount+n.length?{index:i-this.charCount,length:0,match:"",valid:!0}:null;s&&this.foundIndex++;let a=this.foundIndex===1;return s&&a?this.charCount+=i-this.charCount:this.charCount+=n.length,s?b({isStart:a},s):null}replaceWith(n,r){return r.isStart?(0,jt.jsx)(tF,{ref:this.startRef}):(0,jt.jsx)(nF,{inputElement:r.inputElement,startRef:this.startRef,boundaryRef:r.boundaryRef,inputStyle:r.inputStyle})}asTag(){return"mark"}};var to=w(k()),rF=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:u})=>{let l=_("TabCompletion",jP),c=q("insertLink"),f=q("showMidSentenceSuggestions"),d=q("inlineSuggestions"),p=zP(a),y=(0,no.useRef)(null),h=V(Nt);(0,no.useEffect)(()=>{qi(a)&&p&&BP(a,p)},[p]);let g=(0,no.useCallback)(x=>{if(!o||!n)return x;let S=[(0,to.jsx)("span",{className:l.resetIndent,children:"\u200B"},"u200B"),(0,to.jsx)("span",{"data-testid":"tab-completion",className:(0,vm.default)(l.tabText,l.resetIndent),"data-source":u,children:n},"tabText")];return r&&S.push((0,to.jsx)("span",{className:(0,vm.default)(l.hint,l.resetIndent),children:(0,to.jsx)(Oc,{keyCode:"tab"},"tabHint")})),z0(x,S)},[o,n,r]),m=(0,no.useMemo)(()=>{let x=[];return c&&x.push(new ym("selection")),x.push(new mm("placeholders")),i&&x.push(new fm("keywords")),x},[d,c,i]),v=(0,no.useMemo)(()=>{let x=window.getComputedStyle(a);return{"--dd-color":x.color,"--dd-font-size":x.fontSize,"--dd-font-family":x.fontFamily,"--dd-font-variant":x.fontVariant}},[]);return!e||!h?null:(0,to.jsxs)("div",{ref:x=>{x!=null&&x.parentElement&&(y.current=x==null?void 0:x.parentElement)},className:l.root,style:v,children:[(0,to.jsx)(oa,{tagName:"span",containerTagName:"div",className:(0,vm.default)(l.container,l.agentText),disableLineBreaks:qi(a),content:t||"\u200B",onAfterParse:g,matchers:m,selection:p,keywordMatches:s,inputElement:a,inputStyle:v,boundaryRef:y,inlineSuggestionsOnlyAtEnd:!f}),(0,to.jsx)("br",{})]})},oF=e=>{var g,m,v;let{input:t,ui:n,settings:r,styleSuggestions:o,conversation:i}=e,s=ea({input:t}),a=(s==null?void 0:s.text)||"",u=(s==null?void 0:s.source)||"",l=(g=t.html)!=null?g:ia(t.text),c=a.indexOf(t.text)===0?a.slice(t.text.length):"",{showTabHint:f}=n,{isSupported:d}=i,{showTabCompletion:p,visible:y,showStyleSuggestions:h}=r;return{showTabHint:f,showStyleSuggestions:h,showTabCompletion:p&&Er(e),content:l,tabText:c,source:u,keywordMatches:(v=(m=o.list)==null?void 0:m.keywordMatches)!=null?v:[],enabled:y&&d!==!1}},JP=yi(oF)(rF);var LA=w(Ie()),Ma=w(W());var iF={token:null,interval:null},$0=fe("passwordlessToken/getTemporaryPasswordlessToken",(e,t)=>P(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return{token:yield n.requestPasswordlessToken()}})),K0=fe("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r($0()),setInterval(()=>r($0()),n)}),eA=ye({name:"passwordlessToken",initialState:iF,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase($0.fulfilled,(t,n)=>{t.token=n.payload.token}),e.addCase(K0.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:tA}=eA.actions,nA=eA.reducer;function sF(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}var rA=zn([sC],e=>e.map(n=>({text:n.response,title:n.name,callToAction:n.callToAction,isLoading:n.isLoading,specialType:n.specialType,rule:{id:sF(n.code),label:n.code,name:n.name,description:n.name}})));var xm=w(W());var G0=w(Ie());var q0=w(k()),uc=()=>(0,q0.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,q0.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 oA={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var Cr=w(k()),aF=({entities:e})=>{let t=_("EntitiesWidgetList",oA),[n,r]=(0,xm.useState)(void 0),o=ce(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),vr(a.text),o(kn({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,xm.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,Cr.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,u)=>(0,Cr.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,Cr.jsx)("span",{className:t.entityText,children:a.text}),(0,Cr.jsxs)("span",{className:t.iconWrapper,children:[(0,Cr.jsx)("span",{className:(0,G0.default)(t.icon),children:(0,Cr.jsx)(uc,{})}),(0,Cr.jsx)("span",{className:(0,G0.default)(t.icon,n===u&&t.iconClicked),children:(0,Cr.jsx)(uc,{})})]})]},a.text))})},iA=aF;var Y0=w(k()),sA=()=>(0,Y0.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Y0.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 X0=w(k()),aA=()=>(0,X0.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,X0.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 Q0=w(k()),lA=()=>(0,Q0.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Q0.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 uA={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var cA={root:"dd-nazq3",rotation:"dd-3EHTv"};var fA=w(k()),lF=({size:e=12})=>{let t=_("LoadingSpinner",cA);return(0,fA.jsx)("span",{style:{width:`${e}px`,height:`${e}px`},className:t.root})},dA=lF;var Z0=w(k()),pA=()=>(0,Z0.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Z0.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var nr=w(k()),uF=()=>{let e=_("OnDemandAssistants",uA),t=Gr(Vn),n=Gr(jn),r=V(pC),o=V(mC),i=V(aC),s=o.filter(l=>l.isPinned),a=o.filter(l=>!l.isPinned),u=l=>{if(l===r){n.call({transcript:"in-memory-transcript"});return}t.call({assistantCode:l,expectFormat:"json-schema:cues",transcript:"in-memory-transcript"})};return o.length===0?null:(0,nr.jsxs)("div",{className:e.root,children:[s.map(({assistant:l,assistantName:c})=>(0,nr.jsx)("button",{type:"button",className:e.button,disabled:i==="loading",onClick:()=>u(l),children:c},l)),a.length>0&&(0,nr.jsxs)(on,{placement:"top-end",children:[(0,nr.jsxs)(on.Trigger,{className:e.trigger,children:[i==="loading"&&(0,nr.jsx)(dA,{}),i==="error"&&(0,nr.jsx)(pA,{}),!["loading","error"].includes(i)&&(0,nr.jsx)(Cp,{"data-testid":"trigger"})]}),(0,nr.jsx)(on.Content,{className:e.nav,children:a.map(({assistant:l,assistantName:c})=>(0,nr.jsx)(on.Button,{className:e.item,disabled:i==="loading",onClick:()=>u(l),children:c},l))})]})]})},mA=uF;var yA=w(W());var gA={loadingBar:"dd-6as-V",placeHolderShimmer:"dd-TFYmA"};var hA=w(k()),cF=({width:e})=>{let t=_("LoadingProgressBar",gA);return(0,hA.jsx)("div",{className:t.loadingBar,style:{width:e}})},Sm=cF;var ro=w(k()),wm=({title:e})=>{let t=(0,yA.useRef)(null);return gS(t),(0,ro.jsx)(be,{ref:t,children:(0,ro.jsx)(De,{children:(0,ro.jsxs)(De.Content,{children:[(0,ro.jsx)(De.Title,{children:e}),(0,ro.jsx)(Sm,{width:"60%"}),(0,ro.jsx)(Sm,{width:"90%"}),(0,ro.jsx)(Sm,{width:"50%"})]})})})};var cc={};Lt(cc,{enUS:()=>dF,nlNL:()=>fF});var dF={useCue:[{type:0,value:"Add to message"}],__summarizerAssistant__:[{type:0,value:"Summary"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},fF={useCue:[{type:0,value:"Voeg toe aan bericht"}],__summarizerAssistant__:[{type:0,value:"Samenvatting"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var Gi=w(W());var J0={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",actions:"dd-9Iqn9",thumbsUp:"dd-6QwVx",thumbsDown:"dd-d3E8l",form:"dd-sPNU2",formInput:"dd-F3E4I",formSubmit:"dd-vw5S0",actionButton:"dd-cCWyJ",editableCue:"dd-nWSD-",inputSpace:"dd-DGYB1"};var Pt=w(k()),pF=500,mF=100,gF=({content:e,onChange:t,onCopy:n})=>{let r=(0,Gi.useRef)(null),o=_("WidgetCue",J0);return(0,Gi.useEffect)(()=>{let i=r.current;if(!i)return;i.style.setProperty("height","0px");let s=Math.min(Math.max(i.scrollHeight,mF),pF);i.style.setProperty("height",`${s}px`)},[e]),(0,Pt.jsx)("textarea",{ref:r,className:o.editableCue,onCopy:n,onChange:t,value:e})},hF=({cue:e,onCallToAction:t,onRemove:n,onCopy:r,onUse:o})=>{var h;let i=_("WidgetCue",J0),s=re(cc),a=Bo(),u=q("hasKeyboardInput"),[l,c]=(0,Gi.useState)(e.text),f=()=>{t&&t(e),n(e)},d=g=>{r&&r(g,e)},p=g=>{o&&o(g,e)},y=g=>{g.preventDefault(),g.stopPropagation(),n(e)};return(0,Gi.useEffect)(()=>{a("Assistant response displayed",{name:e.rule.name,description:e.rule.description,group:e.rule.label,cueText:e.text})},[]),(0,Pt.jsxs)(be,{"data-testid":"cue",children:[(0,Pt.jsx)(De,{children:(0,Pt.jsxs)(De.Content,{children:[e.title&&(0,Pt.jsx)(De.Title,{className:i.title,"data-testid":"widget-cue-title",children:e.rule.label.startsWith("__")?s(e.rule.label):e.title}),e.specialType==="summary"?(0,Pt.jsx)(gF,{content:l,onCopy:()=>{let g=document.getSelection();g&&d(g.toString())},onChange:g=>{var m;return c((m=g.target.value)!=null?m:"")}}):(0,Pt.jsx)(ga,{content:e.text,useLabel:s("useCue"),copyLabel:s("copyCue"),onCopy:d,onUse:u?p:void 0})]})}),(0,Pt.jsxs)(be.ButtonsContainer,{children:[(0,Pt.jsxs)("div",{className:i.actions,children:[e.specialType==="summary"&&(0,Pt.jsx)(be.Button,{onClick:()=>d(l),children:s("copyCue")}),e.callToAction&&(0,Pt.jsx)(be.Button,{onClick:f,children:e.callToAction.label}),(0,Pt.jsx)(be.Button,{onClick:y,children:s("removeCue")})]}),e.specialType==="summary"?(0,Pt.jsx)(Ii,{eventName:"summary feedback",feedbackText:(h=e.text)!=null?h:"",feedbackType:"summary",eventData:{summary:e.text}}):(0,Pt.jsx)(Ii,{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"})]})]})},vA=hF;var Ia=w(k()),yF=({cues:e})=>{let t=ce(),n=en(),r=re(cc),o=Bo(),i=l=>{t(uC({code:l.rule.label})),o("Assistant response closed",{name:l.rule.name,group:l.rule.label,description:l.rule.description,cueText:l.text})},s=(l,c)=>{switch(vr(l),c.specialType){case"summary":o("summary copied to clipboard",{originalText:c.text,finalText:l,assistant:c.rule.label});break;default:o("Assistant response copied",{name:c.rule.name,group:c.rule.label,description:c.rule.description,copiedText:l})}},a=l=>{l.callToAction&&(t(tp(l)),o("Assistant call to action",{name:l.rule.name,group:l.rule.label,description:l.rule.description,eventName:l.callToAction.event,value:l.callToAction.value}))},u=(l,c)=>{n.send(yr,{text:l,suggestion:{source:"cue",sourceText:l}}),o("Assistant response used",{name:c.rule.name,group:c.rule.label,description:c.rule.description,usedText:l})};return(0,Ia.jsx)(Ia.Fragment,{children:e.map(l=>l.isLoading?(0,Ia.jsx)(wm,{title:l.rule.label.startsWith("__")?r(l.rule.label):l.title},l.rule.id):(0,Ia.jsx)(vA,{cue:l,onCallToAction:a,onRemove:i,onCopy:s,onUse:u},l.rule.id))})},xA=yF;var bm=w(W());var SA={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var rr=w(k());function vF(e,t){return t.split(".").reduce((n,r)=>!n||typeof n!="object"||!(r in n)?null:n[r],e)}var wA=({data:e,schema:t})=>{let n=_("WidgetCustomData",SA),r=o=>{vr(o)};return(0,bm.useEffect)(()=>{Q.info("Custom data",e,t)},[e]),(0,rr.jsx)("dl",{className:n.root,children:t.map(o=>{let i=vF(e,o.path);return(0,rr.jsxs)(bm.Fragment,{children:[(0,rr.jsx)("dt",{className:n.label,children:o.label}),(0,rr.jsx)("dd",{className:n.value,children:o.type==="boolean"&&i?(0,rr.jsx)("span",{className:n.isTrue,children:o.trueValue}):o.type==="boolean"&&!i?(0,rr.jsx)("span",{className:n.isFalse,children:o.falseValue}):i?(0,rr.jsxs)("button",{type:"button",onClick:()=>r(i),className:n.copyButton,children:[(0,rr.jsx)("span",{className:n.copyButtonText,children:i}),(0,rr.jsx)(uc,{})]}):"-"})]},o.label)})})};var sn=w(W());var ex=w(k()),bA=()=>(0,ex.jsx)("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"ReplayIcon",children:(0,ex.jsx)("path",{d:"M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8"})});var La={};Lt(La,{enUS:()=>xF,nlNL:()=>SF});var xF={titleKnowledgeAssistant:[{type:0,value:"Knowledge Assistant"}],inputPlaceholder:[{type:0,value:"What is your question?"}],useCue:[{type:0,value:"Add to message"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Submit"}],resetLabel:[{type:0,value:"Reset"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},SF={titleKnowledgeAssistant:[{type:0,value:"Knowledge Assistant"}],inputPlaceholder:[{type:0,value:"Wat is je vraag?"}],useCue:[{type:0,value:"Voeg toe aan bericht"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}],submitLabel:[{type:0,value:"Verzend"}],resetLabel:[{type:0,value:"Reset"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var tx={form:"dd-pleCH",formInput:"dd-pGJMY",formSubmit:"dd--gkRg",actionButton:"dd-I2NEH",sources:"dd-xf9c6",source:"dd-a-vyX",tooltip:"dd-EsgcZ",linkContent:"dd-gARDA",showMoreSources:"dd-uDGi-"};var Re=w(k()),wF=3,bF=({sources:e,onClick:t})=>{let n=re(La),r=_("WidgetKnowledgeAssistant",tx),[o,i]=(0,sn.useState)(!1),s=o?e:e.slice(0,wF);return s.length===0?null:(0,Re.jsxs)("ul",{className:r.sources,children:[s.map(a=>(0,Re.jsx)("li",{className:r.source,"data-testid":"knowledge-assist-source",children:(0,Re.jsxs)(on,{tooltip:!0,placement:"top-start",children:[(0,Re.jsx)(on.Trigger,{as:"a",rel:"noreferrer",target:"_blank",href:a.url,onClick:u=>{u.stopPropagation(),t(a)},children:(0,Re.jsx)("span",{className:r.linkContent,children:a.name})}),a.url&&(0,Re.jsx)(on.Content,{className:r.tooltip,children:decodeURIComponent(a.url)})]})},a.name)),s<e&&(0,Re.jsx)("button",{type:"button",className:r.showMoreSources,onClick:()=>i(!0),children:n("showMore",{amount:e.length-s.length})})]})},EF=({innerRef:e,item:t,index:n,hasKeyboardInput:r,onCopy:o,onUse:i,onSourceClick:s})=>{var u;let a=re(La);return(0,Re.jsxs)(be,{"data-testid":"knowledge-assist-answer",ref:e,children:[(0,Re.jsx)(De,{children:(0,Re.jsxs)(De.Content,{children:[(0,Re.jsx)(De.Title,{children:t.question}),(0,Re.jsx)(ga,{content:t.answer.answer,useLabel:a("useCue"),copyLabel:a("copyCue"),onCopy:o,onUse:r?i:void 0}),(0,Re.jsx)(bF,{sources:(u=t.answer.sources)!=null?u:[],onClick:l=>s(l,t.question)})]})}),(0,Re.jsxs)(be.ButtonsContainer,{children:[(0,Re.jsx)("div",{}),(0,Re.jsx)(Ii,{eventName:"knowledge assist feedback",eventData:{question:t.question,isFollowUpQuestion:n>0,isAgent:!0,answer:t.answer.answer},feedbackText:t.answer.answer,feedbackType:"assistant"})]})]})},nx=(0,sn.createContext)(null),EA=({children:e})=>{let[t,n]=(0,sn.useState)(null),r=V(Eu("knowledge-assist")),[o,i]=(0,sn.useState)(!1),[s,a]=(0,sn.useState)(null),u=ce(),l=Gr(d=>xu({input:d,threadId:t,onNewThreadId(p){n(p)}})),c={isEnabled:r,isSubmitting:o,threadId:t,pendingInput:s,onSubmit(d){return P(this,null,function*(){i(!0),a(d),yield l.call(d),i(!1),a(null)})},onReset(){t&&u(ra(t))}};return(0,Re.jsx)(nx.Provider,{value:c,children:e})},TA=()=>{let e=re(La),t=_("WidgetKnowledgeAssistant",tx),n=(0,sn.useContext)(nx),r=(0,sn.useRef)(null),[o,i]=(0,sn.useState)(""),s=l=>{i(l.target.value)},a=l=>{l.preventDefault(),n.onSubmit(o).then(()=>{var c;r.current&&((c=r.current)==null||c.focus(),i(""))})},u=l=>{l.preventDefault(),n.onReset()};return n.isEnabled?(0,Re.jsxs)("form",{className:t.form,onSubmit:a,children:[(0,Re.jsx)("input",{ref:r,className:t.formInput,placeholder:e("inputPlaceholder"),type:"text",disabled:n.isSubmitting,value:o,onChange:s}),(0,Re.jsx)("button",{type:"submit",disabled:n.isSubmitting||o==="",className:t.formSubmit,children:e("submitLabel")}),(0,Re.jsx)("button",{type:"button",title:e("resetLabel"),disabled:n.threadId===null||n.isSubmitting,onClick:u,className:t.actionButton,children:(0,Re.jsx)(bA,{})})]}):null},CA=()=>{var c,f;let e=re(La),t=Bo(),n=(0,sn.useRef)(null),r=(0,sn.useContext)(nx),o=(f=V(vu((c=r.threadId)!=null?c:-1)))!=null?f:[],i=q("hasKeyboardInput"),s=en(),a=d=>{vr(d),t("Assistant response copied",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",copiedText:d})},u=(d,p)=>{t("knowledge assist source viewed",{question:p,sourceViewed:d.url||d.name})},l=d=>{s.send(yr,{text:d,suggestion:{source:"cue",sourceText:d}}),t("Assistant response used",{name:"Knowledge Assistant",group:"knowlegde-assist",description:"",usedText:d})};return!r.isEnabled||(o==null?void 0:o.length)===0&&!r.isSubmitting?null:(0,Re.jsx)(ar,{type:"knowledge",title:e("titleKnowledgeAssistant"),"data-testid":"knowledge",children:(0,Re.jsxs)(Gt,{withDivider:!0,children:[o.map((d,p)=>(0,Re.jsx)(EF,{innerRef:p===o.length-1?n:void 0,item:d,index:p,hasKeyboardInput:i,onCopy:a,onUse:l,onSourceClick:u},`${d.question}_${d.answer}_${p}`)),r.pendingInput&&(0,Re.jsx)(wm,{title:r.pendingInput})]})})};var RA=w(W());var CF=/(https?:\/\/[^\s]+)/,kA=e=>e.split(" ").find(t=>CF.test(t));var Nn=w(k()),kF=({suggestion:e,lines:t,onUse:n})=>{var f;let r=e.text||e.url||e.message,o=kA(r),i=re(Wu),s=q("showImages"),a=q("fallbackImage"),u=q("hasKeyboardInput"),l=d=>{d.preventDefault(),d.stopPropagation(),u&&n(r)},c=(0,RA.useCallback)(d=>{window.open(o,"_blank"),d.stopPropagation(),d.preventDefault()},[o]);return(0,Nn.jsxs)(be,{onClick:u?l:void 0,"data-testid":"edit-suggestion",children:[(0,Nn.jsxs)(De,{children:[s&&e.image&&(0,Nn.jsx)(De.Image,{src:gm(e,"small",a||void 0),title:e.title}),(0,Nn.jsxs)(De.Content,{children:[e.title&&(0,Nn.jsx)(De.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((f=e.searchKeywords)==null?void 0:f.length)>0&&(0,Nn.jsx)(be.Labels,{labels:e.searchKeywords}),(0,Nn.jsx)(De.Content,{cropText:t==="single",lineClamp:t==="multiple",children:r})]})]}),(0,Nn.jsxs)(be.Actions,{children:[o&&(0,Nn.jsx)(be.ActionButton,{onClick:c,label:i("visitUrl")}),u&&(0,Nn.jsx)(be.ActionButton,{primary:!0,onClick:l,label:i("useSuggestion")})]})]})},PA=kF;var dc=w(k()),RF=({lines:e,suggestions:t})=>{let n=en(),r=(o,i)=>{n.send(yr,{text:o,suggestion:A(b({},i),{source:i.source,sourceText:i.text})})};return(0,dc.jsx)(dc.Fragment,{children:t.map(o=>(0,dc.jsx)(PA,{suggestion:o,lines:e,onUse:i=>r(i,o)},o.text||o.url||o.message))})},AA=RF;var Em={};Lt(Em,{enUS:()=>PF,nlNL:()=>AF});var PF={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},AF={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Oa={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",sectionList:"dd-bF9pF",footer:"dd-tvofr",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",footerShortcut:"dd-dH7XJ",link:"dd-DRo0x"};var se=w(k()),OA=(e,t)=>{let n=V(Nt);(0,Ma.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},IF=({onLogIn:e})=>{let t=_("Widget",Oa),n=q("isEmbedded"),r=q("adminUrl");return(0,se.jsx)("div",{className:t.loginText,children:(0,se.jsx)("div",{children:(0,se.jsx)(im,{isEmbedded:n,loginUrl:r,onLogIn:e})})},"login")},IA=({text:e})=>{let t=_("Widget",Oa);return(0,se.jsx)("div",{className:t.stateText,children:(0,se.jsx)("div",{children:(0,se.jsx)("p",{children:e})})},"notification")},LF=()=>{let e=re(Em),t=ce(),n=_("Widget",Oa),r=q("showSearch"),o=q("showSummaryCommand"),i=q("showKnowledgeSearch"),s=V(Eu("knowledge-assist")),a=q("isEmbedded"),u=V(ca("/admin/")),l=en(),c=q("productName"),f=q("hasKeyboardInput"),d=Gr(()=>jn({})),p=r||o||i||u;return OA(()=>{if(a)return t(K0()),()=>{t(tA())}},[t,a]),!p||!f?null:(0,se.jsx)(ar,{title:e("actions"),type:"shortcuts",children:(0,se.jsxs)("div",{className:n.shortcutList,children:[r&&(0,se.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-search","aria-label":e("linkSearch"),onClick:()=>l.send("ShowCommandPalette",{isOpen:!0}),children:[(0,se.jsx)(sa,{}),e("linkSearch")]}),o&&!s&&(0,se.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-summary","aria-label":e("linkSummary"),disabled:d.state==="loading",onClick:()=>d.call(),children:[(0,se.jsx)(lA,{}),e("linkSummary")]}),i&&!s&&(0,se.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-knowledge-assist","aria-label":e("linkKnowledgeSearch"),onClick:()=>l.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,se.jsx)(aA,{}),e("linkKnowledgeSearch")]}),u&&(0,se.jsxs)("a",{className:n.shortcut,target:"_blank",href:u,"data-testid":"shortcut-studio-login","aria-label":e("linkStudioLogin",{productName:c}),rel:"noreferrer",children:[(0,se.jsx)(sA,{}),e("linkStudioLogin",{productName:c})]})]})})},OF=()=>{let e=ce(),t=V(bu),n=V(gC),r=V(rA),o=V(TT),i=V(pp),s=V(Qp),a=V(Ei),u=V(hr);return(0,Ma.useEffect)(()=>{!!o&&!n&&Q.warn("Custom data provided, but no schema.")},[o,n]),OA(()=>{t.forEach(({type:l})=>{l==="entities"?e(Kn()):Dc.includes(l)||e(tr(l))})},[e,u,a]),(0,Ma.useEffect)(()=>{r.length>0&&!t.some(l=>l.type==="cues")&&Q.warn("Received cues, but cues are not configured in widget.")},[t,r]),(0,se.jsx)(Ma.Fragment,{children:t.map(({type:l,title:c,amount:f,lines:d,schema:p})=>{var y,h;switch(l){case"entities":return i&&i.length>0&&(0,se.jsx)(ar,{type:l,title:c,"data-testid":`type-${l}`,children:(0,se.jsx)(iA,{entities:i})},l);case"cues":return r&&r.length>0&&(0,se.jsx)(ar,{type:l,title:c,"data-testid":`type-${l}`,children:(0,se.jsx)(Gt,{withDivider:!0,children:(0,se.jsx)(xA,{cues:r})})},l);case"custom-data":return o&&p&&(0,se.jsx)(ar,{type:l,title:c,"data-testid":`type-${l}`,children:(0,se.jsx)(Gt,{withDivider:!0,children:(0,se.jsx)(wA,{data:o,schema:p})})},l);default:return((h=(y=s[l])==null?void 0:y.suggestions)==null?void 0:h.length)>0&&(0,se.jsx)(ar,{type:l,title:c,"data-testid":`type-${l}`,children:(0,se.jsx)(Gt,{withDivider:!0,children:(0,se.jsx)(AA,{lines:d,contentType:l,suggestions:s[l].suggestions.slice(0,f)||[]})})},l)}})})},MF=({children:e})=>{let t=_("Widget",Oa);return(0,se.jsx)("div",{className:t.footer,children:e})},NF=({onLogIn:e})=>{let t=re(Em),n=_("Widget",Oa),r=V(Zs),o=V(Nt),i=V(lT),s=V(Ei),a=V(Eu("knowledge-assist"));return r===!1?(0,se.jsx)(IA,{text:t("notSupported")}):o===!1?(0,se.jsx)(IF,{onLogIn:e}):!s||!i||o===null?(0,se.jsx)(IA,{text:t("waiting")}):(0,se.jsx)("div",{className:(0,LA.default)(n.root),"data-testid":"widget",children:(0,se.jsxs)(EA,{children:[(0,se.jsxs)(Mc,{className:n.sectionList,children:[(0,se.jsx)(LF,{}),(0,se.jsx)(OF,{}),(0,se.jsx)(CA,{})]}),(0,se.jsxs)(MF,{children:[(0,se.jsx)(TA,{}),a&&(0,se.jsx)(mA,{})]})]})})},MA=NF;function Na(e){let t=new Range;return t.selectNodeContents(e),t}function NA(e,t,n){try{return Yo(e,t,n),!0}catch(r){return!1}}function Tm(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function Cm(e){return"tagName"in e&&e.tagName==="BR"}var fc=/[\u200B-\u200D\uFEFF]/g;function Yo(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(u,l){let c=-1,f=/[\u200B-\u200D\uFEFF]/;if(!f.test(u))return l;for(let d=0;d<=u.length;d++)if(f.test(u[d])||c++,c===l)return d;throw new Error("Offset out of range")}function a(u){switch(u.nodeType){case Node.TEXT_NODE:{let l=u.textContent,c=l.replace(fc,""),f=o+c.length,d=t>=o&&t<=f,p=n>=o&&n<=f;if(d){let y=s(l,t-o);y===0&&!p?r.setStartBefore(u):r.setStart(u,y)}p&&(r.setEnd(u,s(l,n-o)),i=!0),o=f;break}case Node.ELEMENT_NODE:{if(Cm(u)&&(o===t&&r.setStartBefore(u),o++,o===n)){r.setEndAfter(u),i=!0;return}for(let c=0;c<u.childNodes.length&&(a(u.childNodes[c]),!i);c++);let l=u.lastChild;Tm(u)&&l&&!Tm(l)&&!Cm(l)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function pc(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,u,l=0;function c(f){let d=f===e,p=f===n,y=f===o;switch(f.nodeType){case Node.TEXT_NODE:{let h=f.textContent;p&&(a=l+h.substring(0,r).replace(fc,"").length),y&&(u=l+h.substring(0,i).replace(fc,"").length),l+=h.replace(fc,"").length;break}case Node.ELEMENT_NODE:{if(Cm(f)&&f.nextSibling){l++;break}!d&&Tm(f)&&f.previousSibling&&l++;for(let h=0;h<f.childNodes.length;h++){let g=p&&h===r,m=y&&h===i;if(g&&(a=l),m&&(u=l),u!==void 0||((!g||!s)&&c(f.childNodes[h]),y&&h===i-1&&(u=l),u!==void 0))break}y&&(u=l);break}default:break}}if(c(e),u===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:u,end:u}}function mc(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,u="";function l(c){let f=c===e,d=c===n,p=c===o;switch(d&&(a=1),c.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let y=d?r:0,h=p?i:void 0;u+=c.textContent.replace(fc,"").substring(y,h);break}case Node.ELEMENT_NODE:{if(!s&&a===1&&Cm(c)&&c.nextSibling){u+=`
|
|
82
82
|
`;break}!f&&!s&&a===1&&Tm(c)&&c.previousSibling&&(u+=`
|
|
83
|
-
`);let y=d?r:0,h=p?Math.min(i,c.childNodes.length):c.childNodes.length;for(let g=y;g<h&&(l(c.childNodes[g]),a!==2);g++);break}default:break}p&&(a=2)}return l(e),u}var _A=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(_A||{}),oo=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();_o(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(_A).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleKeyUp(t){this.handleInteraction(),this.emit("keyup",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let t=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{t.disconnect()})}focus(){this.element.focus()}emit(t,...n){this.isDisposed||this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r(...n)})}on(t,n){this.isDisposed||(this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n))}off(t,n){if(!this.eventListeners[t])return;let r=this.eventListeners[t].indexOf(n);r!==-1&&this.eventListeners[t].splice(r,1)}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};function DA(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var Yi=class extends oo{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),mc(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!DA(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!DA(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return pc(this.element,n);let r=this.lastKnownSelection;if(r&&NA(this.element,r.start,r.end))return r;let o=Na(this.element);return o.collapse(!1),pc(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return mc(this.element,Yo(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 _F=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize"];function FA(e,t){let n="mozInnerScreenX"in window,r=document.createElement("div");r.id="input-textarea-caret-position-mirror-div";let o=r.style,i=window.getComputedStyle(e),s=e.ownerDocument.body;o.whiteSpace="pre-wrap",o.wordWrap="break-word",o.position="absolute",o.visibility="hidden",_F.forEach(function(c){o[c]=i[c]}),n?e.scrollHeight>parseInt(i.height)&&(o.overflowY="scroll"):o.overflow="hidden",r.textContent=e.value.substring(0,t);let a=document.createElement("span");a.textContent=e.value.substring(t)||".",r.appendChild(a),s.appendChild(r);let u=e.getBoundingClientRect(),l={top:u.top-e.scrollTop+a.offsetTop+parseInt(i.borderTopWidth)+a.offsetHeight,left:u.left-e.scrollLeft+a.offsetLeft+parseInt(i.borderLeftWidth)};return s.removeChild(r),l}var Xi=class extends oo{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 FA(this.element,this.element.selectionEnd)}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var i;return(i=n==null?void 0:n.get)==null?void 0:i.call(this.element)},set:i=>{var s;(s=n==null?void 0:n.set)==null||s.call(this.element,i),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let r=this.element.disabled,o=new MutationObserver(()=>{this.element.disabled!==r&&(r=this.element.disabled,this.emit(r?"disabled":"enabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>o.disconnect())}};function HA(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,u])=>{s.searchParams.append(a,u)}),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 DF(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var rx=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()}},ox=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=HA(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()}},ix=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(),Q.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 ox(t,this.deepdeskUrl,{debug:!0}):new rx(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=DF(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(Q.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;Q.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(A(b({},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)}},zA=ix;function FF(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function Ve(e){return Array.isArray(e)?e.map(Ve):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>A(b({},t),{[FF(n)]:Ve(e[n])}),{}):e}function HF(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function mt(e){return Array.isArray(e)?e.map(mt):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>A(b({},t),{[HF(n)]:mt(e[n])}),{}):e}var _a=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var sx=e=>new Promise(t=>{setTimeout(t,e)});var Da=class extends _a{constructor(){super(...arguments);this.name="ClientError"}},lx=class extends _a{constructor(){super(...arguments);this.name="ServerError"}},ax=new Map;function zF(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:(Q.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var Xo=class Xo{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,u=n.method===void 0||n.method.toLowerCase()==="get",T=n,{useCache:l=!1,abortLatest:c=!1,attempts:f=1,retryDelay:d=500,refreshTokenOn401:p=!0,retryOnError:y=R=>R instanceof TypeError,retryOnResponse:h=R=>R.status>=500,version:g=null}=T,m=te(T,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(l)if(u){if(ax.has(s)){r(ax.get(s));return}}else throw new Error(`Can't use 'useCache' for ${n.method}`);let v=A(b({credentials:"include"},m),{headers:b({Accept:"application/json","Content-Type":"application/json"},m.headers)});!u&&this.csrfToken&&(v.headers=A(b({},v.headers),{"X-CSRFToken":this.csrfToken})),typeof g=="string"&&(v.headers=A(b({},v.headers),{"X-Deepdesk-API-Version":g}));let x=f,S=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&c&&(this.latestRequestByUrl[s].isAborted=!0,this.latestRequestByUrl[s].reject(new Error("Aborted"))),this.latestRequestByUrl[s]=i;let C=()=>P(this,null,function*(){return x--,a(s,v).then(R=>P(this,null,function*(){return h(R)&&!i.isAborted&&x>0?(yield sx(d),C()):R.status===401&&p===!0&&S===!1?(S=!0,yield this.refreshToken(),C()):R})).catch(R=>P(this,null,function*(){if(y(R)&&!i.isAborted&&x>0)return yield sx(d),C();throw R}))});C().then(R=>P(this,null,function*(){let L=yield zF(R);if(delete this.latestRequestByUrl[s],R.status>=500){o(new lx("Server Error",L));return}else if(R.status===401){o(new Da("Unauthorized",L));return}else if(R.status===403){o(new Da("Forbidden",L));return}else if(R.status===404){o(new Da("Not Found",L));return}else if(R.status>=400){o(new Da("Bad Request",L));return}l&&ax.set(s,L),r(L)})).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 Xo.refreshingToken||(Xo.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{Xo.refreshingToken=null},1e3*60)})),Xo.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,b({method:"POST",body:JSON.stringify(n)},r))}patch(t,n,r){return this.request(t,b({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,b({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,b({method:"DELETE"},n))}};Xo.refreshingToken=null;var Qi=Xo;var BA;(t=>{let e;(s=>(s.SEND_MESSAGE="Send Message",s.HANDLING_TIME="Handling Time",s.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",s.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(e=t.EventType||(t.EventType={}))})(BA||(BA={}));function km(e){return A(b({},Ve(e)),{tags:e.tags})}var Zi=class Zi{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new Qi(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?(Zi.exchangeTokenPromise||(Zi.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),Zi.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return P(this,null,function*(){yield this.preflight(),Q.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=yield this.client.post("/api/conversations",A(b({},mt(t)),{tags:t.tags}),{version:"v2"});return km(n)})}getMe(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/session/me/");return Ve(t)})}postIdentity(t){return P(this,null,function*(){yield this.client.post("/apis/admin/session/me/identities/",mt(t))})}patchMe(t){return P(this,null,function*(){let n=yield this.client.patch("/apis/admin/session/me/",mt(t));return Ve(n)})}getProfile(t){return P(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{useCache:!0});return Ve(n)})}getKnowledgeAssistant(t){return P(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{useCache:!0});return Ve(n)})}getContentTypes(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return Ve(t)})}getAccount(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{useCache:!0});return Ve(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 Ve(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(),Q.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 Q.info(`Successfully retrieved conversation ${s.id} for session ${t}`),km(s)})}isConversationSupported(r){return P(this,arguments,function*(t,n={}){Q.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=mt(n);n.tags&&(r.tags=n.tags);let o=yield this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return km(o)})}postMessages(t,n){return P(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/messages`,n.map(o=>A(b({},mt(o)),{tags:o.tags})),{version:"v2"})).map(o=>km(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,[u,l])=>A(b({},a),{[u]:l}),{});return this.client.post("/api/events",mt(A(b(b({},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])=>A(b({},o),{[i]:s}),{});return this.client.post("/api/events",{event:t,data:mt(b(b({},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})}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 Q.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/",mt(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}`,mt(n),{abortLatest:!0,version:"v1"})).map(s=>A(b({},Ve(s)),{text:s.text||s.url||s.message,source:r,type:r})).filter((s,a,u)=>a===u.findIndex(l=>l.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`,mt(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 Ve(n).map(r=>A(b({},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",mt(t),{abortLatest:!0,version:"v1"});return Ve(n)})}search(t){return P(this,null,function*(){let n=yield this.client.post(`/api/profiles/${t.profile}/search`,mt(t),{version:"v2"});return Ve(n)})}knowledgeAssist(i,s,a){return P(this,arguments,function*(t,n,r,o={}){let u=yield this.client.post(`/api/knowledge-assist/assistants/${r}/search`,mt({question:t.question,doNotKnowAnswer:t.doNotKnowAnswer,customerInstruction:t.customerInstruction,chatHistory:n.map(l=>({question:l.question,answer:l.answer.answer})),agentId:o.agentId,conversationId:o.conversationId}),{version:"v2"});return Ve(u)})}requestLoginByEmail(t){return P(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t});return Ve(n)})}requestPasswordlessToken(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/");return Ve(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 Ve(n)})}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 Ve(o)})}evaluateAssistant(t,n){return P(this,null,function*(){var a;let r=new URLSearchParams,{expectFormat:o="text"}=n||{};if(o.startsWith("json-schema:")){let u=o.replace("json-schema:","");r.append("expect_response_format","json-schema"),r.append("expect_response_format_schema",u)}else r.append("expect_response_format",o);n!=null&&n.externalConversationId&&r.append("external_conversation_id",n.externalConversationId);let i=n!=null&&n.threadId?`/api/v2/assistants/${t}/threads/${n==null?void 0:n.threadId}/evaluate?${r.toString()}`:`/api/v2/assistants/${t}/evaluate?${r.toString()}`,s=yield this.client.post(i,{input:(a=n==null?void 0:n.input)!=null?a:{},conversation:n==null?void 0:n.transcript});return Ve(s.output)})}createAssistantThread(t){return P(this,null,function*(){let{assistantCode:n}=t,r=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return Ve(r)})}postMessageToAssistantThread(t){return P(this,null,function*(){let{assistantCode:n,threadId:r,message:o}=t,i=yield this.client.post(`/apis/admin/assistants/${n}/threads/${r}/messages/`,{content:o,role:"user"});return Ve(i)})}translateMessages(t){return P(this,null,function*(){let n=yield this.client.post("/api/translate",mt(t),{version:"v2"});return Ve(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(kS);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&Q.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};Zi.exchangeTokenPromise=null;var io=Zi;var UA={startTime:null,stopTime:null},jA=e=>e.handlingTime,VA=ye({name:"handlingTime",initialState:UA,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(rt,()=>UA)}}),{handlingTimeStart:WA,handlingTimeStop:Rm,handlingTimeReset:$A}=VA.actions,KA=VA.reducer;var qA=(e={})=>{let t=b({onAuthError:Qs(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var Pm={list:{keywordMatches:[]},fetchState:"idle"};var Ji=fe("styleSuggestions/getAll",(n,r)=>P(void 0,[n,r],function*({text:e},t){var u;let{deepdeskAPI:o}=t.extra,i=t.getState(),{showStyleSuggestions:s}=i.settings,a=(u=i.conversation.current)==null?void 0:u.profileCode;if(!s)return Pm.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),BF=ye({name:"styleSuggestions",initialState:Pm,reducers:{},extraReducers:e=>{e.addCase(Ji.pending,t=>{t.fetchState="loading"}).addCase(Ji.rejected,t=>{t.fetchState="error"}).addCase(Ji.fulfilled,(t,n)=>{t.fetchState="done",_o(t.list,n.payload)||(t.list=n.payload)}).addCase(xi,t=>{t.list=Pm.list}).addCase(rt,()=>Pm)}}),GA=BF.reducer;var YA=(e={})=>{let t,n=!0,r=b({getStyleSuggestions:Ji,debounce:500},e);return o=>i=>s=>{var p;let a=o.getState().input.text,u=i(s),l=o.getState();if(l.auth.isLoggedIn!==!0)return u;let{showStyleSuggestions:c}=l.settings;if(!((p=l.conversation.current)==null?void 0:p.id)||!c)return u;let{text:d}=l.input;return d===a&&!n||(clearTimeout(t),d==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:d}))},e.debounce)),u}};function UF(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var XA=(e={})=>{let t=b({getTextSuggestions:tr,getAutocompleteSuggestions:rc,debounce:200,check:Er},e),n;return r=>o=>i=>{var h;let{input:s}=r.getState(),a=o(i),u=r.getState();if(u.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:l,showTabCompletion:c}=u.settings,f=(h=u.conversation.current)==null?void 0:h.id,d=i.type===Zp.toString();if(!f||!l&&!c)return a;let{input:p}=u;return UF(p,s)&&!d||(clearTimeout(n),!t.check(u))||(n=setTimeout(()=>{let g=Js(u);g===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(g))},d?0:t.debounce)),a}};var QA=Ji.fulfilled.toString();function jF(e,t){let n=new Set([...t.keywordMatches.map(o=>o.keyword)]),r=[];return n.forEach(o=>{let i=e.keywordMatches.filter(u=>u.keyword===o),s=t.keywordMatches.filter(u=>u.keyword===o),a=s.length-i.length;a<=0||r.push(...s.slice(0,a))}),r}var ZA=e=>t=>n=>r=>{var l;if(r.type!==QA){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let i=t.getState(),s=i.styleSuggestions.list,a=(l=i.conversation)==null?void 0:l.current;if(o===s)return;let u=jF(o,s);r.type===QA&&u.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:u}})};var VF=ef({assistants:cC,auth:ZE,conversation:uT,contentTypes:fC,passwordlessToken:nA,entities:UC,knowledgeAssistant:oC,handlingTime:KA,info:AT,input:wT,settings:$E,profile:hC,search:_T,styleSuggestions:GA,ui:bP,textSuggestions:aP});function JA(e){return Q1({reducer:VF,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI}},serializableCheck:!1}),qA(),XA({debounce:200}),YA({debounce:500}),ZA(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var WF=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},$F=e=>t=>n=>r=>{var a,u,l,c,f,d;let o=t.getState(),i=Zl("inlineSuggestions")(o);switch(r.type){case Qs.toString():{!r.payload&&e.emit("logout",void 0);break}case Kn.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 kn.toString():e.sendEvent(r.payload.name,{conversationId:((u=r.payload.options)==null?void 0:u.includeConversationData)&&((l=o.conversation.current)==null?void 0:l.id),data:r.payload.data});break;case xi.toString():e.logSendMessage(r.payload);break;case tp.toString():e.emit("call-to-action",{cue:r.payload});break;case Vn.fulfilled.toString():r.isBroadcasted||e.broadcast(rv,r,!1);break;default:break}let s=n(r);switch(r.type){case xi.toString():e.handleAfterSendMessage(r.payload);break;case ic.toString():e.onUpdateShowTabHint(r.payload);break;case Rm.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case Ff.toString():{let{start:p,end:y}=o.input.selection;e.emit("replace",A(b({},r.payload),{replace:r.payload.replace==="selection"?{start:p,end:y}:{start:0,end:y}}));break}case Bn.toString():{let{start:p,end:y}=o.input.selection;e.emit("select-suggestion",A(b({type:WF(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:p,end:y}:{start:0,end:y}})),i&&t.dispatch(Do([]));break}case Hf.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(c=o.conversation.current)==null?void 0:c.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case Do.toString():{i&&r.payload.length>0&&t.dispatch(zf(0));break}case jn.fulfilled.toString():{e.sendEvent("conversation summarized",{conversationId:(f=o.conversation.current)==null?void 0:f.id,data:{summary:r.payload,assistant:(d=t.getState().profile.data)==null?void 0:d.summarizerAssistantNew}});break}default:break}return s},eI=$F;function ux(e){return e.toISOString().replace("T"," ").replace("Z","")}var KF=(e,t)=>t.version,tI=zn([ta,hr,jA,KF],(e,t,n,r)=>{if(!t)return Q.warn("No conversationId for handling time metrics"),null;let{startTime:o,stopTime:i}=n;return!o||!i?(Q.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:t,clientVersion:r,agentId:e==null?void 0:e.agentId,agentName:e==null?void 0:e.agentName,agentEmail:e==null?void 0:e.agentEmail,timeStart:ux(o),timeStop:ux(i)}});function nI(e,t,n){var L,O,G,D;let r=(L=t.conversation.current)==null?void 0:L.id;if(!r)return Q.warn("No conversationId for send message metrics"),null;let{text:o,metrics:{numCharsTyped:i,numCharsPasted:s,numCharsCut:a,numCharsDeleted:u,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:f,pastes:d,cuts:p,deletions:y,textSuggestions:h,offeredTextSuggestions:g}}=t[e],m=o.length,x=h.reduce((B,{text:j,searchTerm:le})=>B+j.length-(le?le.length:0),0),S=c!=null?c:Date.now(),C=(Date.now()-S)/1e3+(f||0),T=i/C,R=h.reduce((B,{searchTerm:j})=>B+(j?j.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:d,cuts:p,deletions:y,lenTextTyped:i+R,lenTextTotal:m,lenTextAssisted:x,lenTextPasted:s,lenTextCut:a,lenTextDeleted:u,timeTotalSeconds:C,charsPerSecond:T,numPastes:l,textSuggestionsV2:h,suggestionsCounters:[{source:"gpt",countOffered:g.filter(B=>B.source==="gpt").length}],agentId:(O=t.info.agentInfo)==null?void 0:O.agentId,agentName:(G=t.info.agentInfo)==null?void 0:G.agentName,agentEmail:(D=t.info.agentInfo)==null?void 0:D.agentEmail}}function cx(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return cx(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?cx(o,t):null}function dx(e,t){return cx(e,t)}function rI(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function qF(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Am(e){return qF(e)&&(qi(e)||am(e))}var iI,kr=new Map,GF=["bottom","height","left","right","top","width"],oI=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:GF.some(n=>e[n]!==t[n]);function sI(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,...sI(t)]:[]}function aI(e,t){return!e||!t?null:A(b({},e),{top:e.top+t.top,left:e.left+t.left})}var Im=!1,lI=()=>{Im=!0;let e=[];if(kr.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),kr.delete(n);return}let r=n.getBoundingClientRect();oI(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(aI,t.rect):t.rect;oI(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),kr.size===0){Im=!1;return}iI=window.requestAnimationFrame(lI)};function fx(e,t){let n=sI(e),r=[],o=n.map((i,s)=>fx(i,a=>{r[s]=a;let u=kr.get(e);if(!u)return;let l=r.reduce(aI,u.rect);u.callbacks.forEach(c=>c(l))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),kr.has(e)){let s=kr.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else kr.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Im&&lI()},unobserve(){o.forEach(s=>s.unobserve());let i=kr.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||kr.delete(e),kr.size||(cancelAnimationFrame(iI),Im=!1)}}}}var uI,Rr=new Map,cI=()=>{Rr.forEach((e,t)=>{if(!t.isConnected){Rr.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)))}),Rr.size!==0&&(uI=window.requestAnimationFrame(cI))};function dI(e,t){return{observe(){let n=Rr.size===0;Rr.has(e)?Rr.get(e).callbacks.push(t):Rr.set(e,{visible:void 0,callbacks:[t]}),n&&cI()},unobserve(){let n=Rr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Rr.delete(e),Rr.size||cancelAnimationFrame(uI)}}}}var px=["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 mx(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function Fa(e){return parseFloat(e)}function Lm(e){return Math.round(e*1e6)}function fI(e){return e/1e6}function gx(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=Fa(e.width),i=Fa(e.borderLeftWidth),s=Fa(e.borderRightWidth),a=Fa(e.paddingRight),u=fI(Lm(o)-Lm(i)-Lm(s)),l=fI(Lm(r));if(u-l>2){let c=u-l;n.style.paddingRight=`${a+c}px`}}function gc(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",Oi(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};mx(r,n,px),gx(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=dI(e,()=>{mx(r,n,px),gx(r,e,n),i(),setTimeout(i,0)}),a,u=!0,l=fx(e,d=>{if(d===null){t.onRemove&&t.onRemove(),n.remove();return}if(!u&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),u=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),u=!1},200),d.height===0&&d.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(mx(r,n,px),gx(r,e,n),i(),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let p=t.closestScrollElement.getBoundingClientRect(),y=window.getComputedStyle(t.closestScrollElement),h=Fa(y.borderTopWidth),g=Fa(y.borderBottomWidth),m=p.top+h-d.top,v=d.top+d.height+-(p.top+p.height-g);n.style.clipPath=`inset(${m}px 0px ${v}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(f=e.parentElement)==null||f.appendChild(n),l.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),l.unobserve(),s.unobserve()}]}var pI=(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){Q.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function YF(e){return e.offsetParent!==null}function mI(e){if(!YF(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 Om(e,t,n=100){let r=mI(e);t({isVisible:r});let o=setInterval(()=>{let i=mI(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var it=w(k());var gI=pI("showTabHint",!0),Ha=class Ha{constructor({deepdeskUrl:t,version:n=Ha.version||"unknown",locale:r="en-US",token:o,fetch:i,productName:s,createCustomChannel:a}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.inlineSuggestions=null;this.aboveSuggestions=null;this.floatingMenu=null;this.widgetRoot=null;this.dynamicThunkObject={};this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let u=t.replace(/\/api$/,"");this.deepdeskApi=new io(u,{token:o,fetch:i}),this.version=n,this.instanceId=Ha.count++;let l={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[eI({broadcast:(c,f,d)=>{this.broadcastEvents.send(c,f,d)},emit:(c,f)=>this.emit(c,f),handleAfterSendMessage:c=>this.handleAfterSendMessage(c),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:c=>this.logSendMessage(c),onUpdateShowTabHint:c=>gI.update(c),sendEvent:(c,f)=>this.deepdeskApi.sendEvent(c,f)})]};this.store=JA(l),this.broadcastEvents=new zA({debug:!0,deepdeskUrl:u,eventMap:DT(this.store),createCustomChannel:a}),this.store.dispatch(ic(gI.value())),this.store.dispatch(Lf({locale:r,adminUrl:u,productName:s}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var t;return(t=this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex])!=null?t:null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(Q.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(Q.warn("Profile has not been loaded (yet)"),!0):(Q.warn("No conversation loaded (yet)"),!0)}login(){this.store.dispatch(Qs(null)),this.store.dispatch(Ur());let t=n=>Nt(n)&&KE(n)!=="loading";return new Promise(n=>{let r=this.subscribe(t,o=>{o&&(r(),n())});this.unmountHandlers.push(()=>{r()})})}isLoggedIn(){return P(this,null,function*(){return(yield this.store.dispatch(Ur())).payload})}isConversationSupported(t,n){return P(this,null,function*(){return(yield this.store.dispatch(Qy({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(Mf(t))).payload})}getConversationBySessionId(t,n){return P(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(yield this.store.dispatch(Nf({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(Zy(t))).payload})}postMessages(t){return P(this,null,function*(){return(yield this.store.dispatch(Df(t))).payload})}updateConversation(t){return P(this,null,function*(){return(yield this.store.dispatch(_f(t))).payload})}resetConversation(){this.store.dispatch(rt()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(t){this.store.dispatch(Lf(t))}setVisitorInfo(t){this.store.dispatch(kT(t))}setCustomData(t){this.store.dispatch(RT(t))}setAgentInfo(t,n){return P(this,null,function*(){yield this.store.dispatch(tu(b(b({},t),n)))})}setAgentSettings(t){return P(this,null,function*(){yield this.store.dispatch(ev(t))})}getAgentSettings(){return P(this,null,function*(){return(yield this.store.dispatch(tv())).payload})}refresh(){return P(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(Bf({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let t=[];return this.store.dispatch(Zp()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}notifyExternalSuggestion(t){this.store.dispatch(Bn(t))}evaluateAssistant(t,n){return P(this,null,function*(){let c=n||{},{input:r={},transcript:o,showCuesInWidget:i=!0,includeTags:s,expectFormat:a}=c,u=te(c,["input","transcript","showCuesInWidget","includeTags","expectFormat"]);Object.assign(r,u);let l=yield this.store.dispatch(Vn({assistantCode:t,expectFormat:a||"json-schema:cues",transcript:o,includeTags:s,input:r,skipState:!i}));if(l.error)throw new Error(l.error.message);return l.payload})}evaluateConversationAssistant(t,n){return P(this,null,function*(){yield this.loadProfileConfig();let r={accepted:"conversationAcceptedAssistant","new-message":"conversationNewMessageAssistant",ended:"conversationEndedAssistant"},o=this.state.profile.data[r[t]];if(!o){Q.warn(`No assistant set in profile for conversation event "${t}"`);return}yield this.evaluateAssistant(o,b({transcript:"stored-transcript",includeTags:!0},n))})}getSummary(){return P(this,null,function*(){var n;if(!this.hasConversation())return Q.warn("No conversation to create summary for."),null;(n=this.state.profile.data)!=null&&n.summarizerAssistantNew||Q.warn("No profile loaded yet, or no summarizer assistant set in profile");let t=yield this.store.dispatch(jn({}));if(t.error)throw new Error(t.error.message);return t.payload})}handleKeyDown(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:i,selection:s}=this.state.input,{inlineSuggestions:a,showTextSuggestions:u}=this.settings,l=a?"below":"above",c=o.length>0;if(this.store.dispatch(mT(Jy(t))),!Er(this.state)||t.key!=="Tab"&&!u)return;let f=()=>{n||!c||s&&(t.shiftKey||(this.store.dispatch(yT()),t.preventDefault()))},d=()=>{n||!c||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(vT()),t.preventDefault()))};switch(t.key){case"ArrowUp":l==="below"?d():f();break;case"ArrowDown":{l==="below"?f():d();break}case"Escape":{n||(this.store.dispatch(zf(-1)),this.store.dispatch($o({collapse:!0})),this.store.dispatch(SP(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let p=ea(this.state);if(!p)return;this.store.dispatch(ic(!1)),this.store.dispatch(Bn({text:p.text,suggestion:p,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let p=ea(this.state);if(!p)return;this.store.dispatch(Bn({text:p.text,suggestion:p,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.settings.inlineSuggestions||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let p=ea(this.state);if(!p)return;this.store.dispatch(Bn({text:p.text,suggestion:p,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch($o({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(Do([]))}handlingTimeStart(){this.state.handlingTime.startTime||(Q.info("Start handling time"),this.store.dispatch(WA()))}handlingTimeStop(){this.state.handlingTime.startTime&&(Q.info("Stop handling time"),this.store.dispatch(Rm()))}logSendMessage(t){let n=nI("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=tI(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch($A()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(xi((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(ST()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(i){Q.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),Q.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(PT(t))}whenConversationLoaded(t){let n=o=>{var i;return(i=o.conversation.current)==null?void 0:i.id},r=()=>this.loadProfileConfig().then(()=>t());n(this.state)&&r(),this.subscribe(n,o=>{o&&r()})}overlayContainerFactory(t,n,r,o){let[i,s]=gc(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,gt.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[u,l]=gc(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});u.dataset.testid=n,u.style.zIndex="2",u.appendChild(r),this.unmountHandlers.push(()=>{(0,gt.unmountComponentAtNode)(o),l()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return Oi(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,gt.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),Q.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()?(Q.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(xT(r.metrics))):Q.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(!Am(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let d=n,{customStyles:r,closestScrollSelector:o,floatingMenuParent:i,appendOverlayTo:s,inputMediator:a}=d,u=te(d,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),l={customStyles:r,closestScrollSelector:o,floatingMenuParent:i,appendOverlayTo:s};this.configure(u),this.settings.automaticHandlingTime&&this.setupHandlingTime(t),Oi(t),this.inputMediator=a||(qi(t)?new Xi(t):new Yi(t)),this.inputMediator.on("change",({plainText:p,rawHTML:y})=>{this.store.dispatch(Bf({text:p,html:y}))}),this.inputMediator.on("keyup",p=>{this.store.dispatch(gT(Jy(p)))}),this.inputMediator.on("keydown",p=>{this.handleKeyDown(p)}),this.inputMediator.on("paste",({pastedText:p,selectionText:y})=>{this.store.dispatch(hT({text:p,selectionText:y}))}),this.inputMediator.on("cut",({selectionText:p})=>{this.store.dispatch(pT(p))});let c;this.inputMediator.on("selection",p=>{clearTimeout(c),p===null?c=setTimeout(()=>{p!==null&&this.store.dispatch(Uf(p))},500):this.store.dispatch(Uf(p))}),this.inputMediator.on("disabled",()=>{var p;(p=this.inputMediator)==null||p.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{this.settings.detectSubmit&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(tm(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(tm(!0))}),this.renderSuggestions(t,l),this.subscribe(Zl("inlineSuggestions"),()=>{this.renderSuggestions(t,l)});let f=this.renderOverlays(n);this.unmountHandlers.push(()=>{f.unmount()}),this.store.dispatch(Bf({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(Uf(this.inputMediator.getSelection())),this.store.dispatch(tm(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{var p;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((p=this.state.conversation.current)==null?void 0:p.sessionId)}),this.isMounted=!0}subscribe(t,n){let r=t(this.store.getState());return this.store.subscribe(()=>{let o=t(this.store.getState());o!==r&&(r=o,n(r))})}unmount(){var t,n,r,o;(t=this.inlineSuggestions)==null||t.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(r=this.floatingMenu)==null||r.unmount(),this.unmountHandlers.forEach(i=>i()),this.unmountHandlers=[],(o=this.inputMediator)==null||o.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderSuggestions(t,n){var r,o,i;(r=this.floatingMenu)==null||r.unmount(),(o=this.inlineSuggestions)==null||o.unmount(),(i=this.aboveSuggestions)==null||i.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(t,n)),this.settings.inlineSuggestions?this.inlineSuggestions=this.renderInlineSuggestions(t,n):this.aboveSuggestions=this.renderAboveSuggestions(t,n)}renderInlineSuggestions(t,n){let{customStyles:r}=n,o=this.createInlineContainer(t,"deepdesk-caret");(0,gt.render)((0,it.jsx)(Ki,{store:this.store,customStyles:r,children:(0,it.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,it.jsx)(PP,{})})}),o);let i=s=>{s?(o.style.display="block",o.style.top=`${s.top}px`,o.style.left=`${s.left}px`):o.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var s;(0,gt.unmountComponentAtNode)(o),(s=this.inputMediator)==null||s.off("caretposition",i),o.remove()}}}renderAboveSuggestions(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:i}=n,s=o&&dx(t,o)||void 0,a=this.overlayContainerFactory("deepdesk-tab-completion",s||t,{appendTo:i,closestScrollElement:s,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),u=this.overlayContainerFactory("deepdesk-suggestions-overlay",s||t,{appendTo:i},r==null?void 0:r.suggestionsRootNode);return(0,gt.render)((0,it.jsx)(Ki,{store:this.store,customStyles:r,children:(0,it.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,it.jsx)(JP,{inputElement:t})})}),a),(0,gt.render)((0,it.jsx)(Ki,{store:this.store,customStyles:r,children:(0,it.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,it.jsx)(FP,{onLogIn:()=>this.loginViaPopup().catch(l=>Q.warn(l.message))})})}),u),{unmount(){(0,gt.unmountComponentAtNode)(a),(0,gt.unmountComponentAtNode)(u),a.remove(),u.remove()}}}renderFloatingMenu(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:i,floatingMenuParent:s}=n,a=o&&dx(t,o)||void 0,u=this.overlayContainerFactory("floating-menu",a||t,{appendTo:s!=null?s:i},r==null?void 0:r.floatingMenuParent);return(0,gt.render)((0,it.jsx)(Ki,{store:this.store,customStyles:r,children:(0,it.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,it.jsx)(vP,{onLogIn:()=>this.loginViaPopup().catch(l=>Q.warn(l.message))})})}),u),{unmount(){(0,gt.unmountComponentAtNode)(u),u.remove()}}}renderOverlays(t){let{customStyles:n}=t,r=this.createContainer("deepdesk-overlays");return(0,gt.render)((0,it.jsx)(Ki,{store:this.store,customStyles:n,children:(0,it.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,it.jsx)(pP,{})})}),r),{unmount(){(0,gt.unmountComponentAtNode)(r),r.remove()}}}renderWidget(t,n={}){if(this.widgetRoot&&Q.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,gt.render)((0,it.jsx)(Ki,{store:this.store,customStyles:r,children:(0,it.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,it.jsx)(MA,{onLogIn:()=>this.loginViaPopup().catch(s=>Q.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,gt.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Om(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){rI(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(wu());let t=Ei(this.state);t&&(yield this.store.dispatch(hu()),this.store.dispatch(Lf({showSearch:t.search,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:!!t.summarizerAssistantNew||t.summarizer,showKnowledgeSearch:!!t.knowledgeAssistantNew||!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions})))})),this.loadProfileConfigPromise)}loginViaPopup(t){return P(this,null,function*(){return new Promise((n,r)=>{let o=new MessageChannel,i=o.port1,s=this.settings.adminUrl,a=new URL(t!=null&&t.url?t==null?void 0:t.url:`${s}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let u=!1,l=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",f),clearInterval(d)};i.onmessage=p=>P(this,null,function*(){var y,h;if((y=p.data)!=null&&y.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((h=p.data)==null?void 0:h.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(ru),u=!0,o.port1.close(),n()}catch(g){console.error(g),r(g)}finally{u=!0,l()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&r(new Error("Popup blocked by browser"));let f=p=>P(this,null,function*(){var y;if(p.origin===a.origin)switch((y=p.data)==null?void 0:y.type){case"deepdesk-popup-loaded":{try{let h=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(h,a.origin,[o.port2])}catch(h){Q.error("Error posting message to popup",h),r(h)}break}case"deepdesk-popup-error":{l(),p.data.message==="Timeout"&&Q.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(p.data.message));break}}});window.addEventListener("message",f);let d=setInterval(()=>{c&&!c.closed||(l(),u||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(l)})})}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(Q.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;Q.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=bu(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(Kn()):Dc.includes(r)||this.store.dispatch(tr(r))})}catch(r){this.handleError(r)}})}};Ha.version="15.1.1-beta.5",Ha.count=0;var hc=Ha;function XF(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 hI(e,t){return P(this,null,function*(){let n=yield XF(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 yI(e,t,n){return P(this,null,function*(){yield new io(e).authenticateWithKey(t,n)})}function vI(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function xI(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},u=`${i.slice(0,s)}${t}${i.slice(a)}`,l=(d=n.selectionAfter)!=null?d:{start:s+t.length,end:s+t.length},c=()=>{if(n.setValue)return n.setValue(u);e.value=u};return Promise.resolve(c()).then(()=>{e.selectionStart=l.start,e.selectionEnd=l.end,e.blur(),e.focus()})})}function SI(r,o){return P(this,arguments,function*(e,t,n={}){let i=n.replace?Yo(e,n.replace.start,n.replace.end):Na(e),s,a=()=>{if(n.setRange)return n.setRange(i.cloneRange());i.deleteContents(),s=document.createElement("span"),i.insertNode(s),n.insertBRs!==!1?t.split(`
|
|
83
|
+
`);let y=d?r:0,h=p?Math.min(i,c.childNodes.length):c.childNodes.length;for(let g=y;g<h&&(l(c.childNodes[g]),a!==2);g++);break}default:break}p&&(a=2)}return l(e),u}var _A=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(_A||{}),oo=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();_o(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(_A).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleKeyUp(t){this.handleInteraction(),this.emit("keyup",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),this.addEventListener("click",()=>this.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let t=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{t.disconnect()})}focus(){this.element.focus()}emit(t,...n){this.isDisposed||this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r(...n)})}on(t,n){this.isDisposed||(this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n))}off(t,n){if(!this.eventListeners[t])return;let r=this.eventListeners[t].indexOf(n);r!==-1&&this.eventListeners[t].splice(r,1)}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};function DA(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var Yi=class extends oo{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),mc(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!DA(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!DA(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return pc(this.element,n);let r=this.lastKnownSelection;if(r&&NA(this.element,r.start,r.end))return r;let o=Na(this.element);return o.collapse(!1),pc(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return mc(this.element,Yo(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 _F=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize"];function FA(e,t){let n="mozInnerScreenX"in window,r=document.createElement("div");r.id="input-textarea-caret-position-mirror-div";let o=r.style,i=window.getComputedStyle(e),s=e.ownerDocument.body;o.whiteSpace="pre-wrap",o.wordWrap="break-word",o.position="absolute",o.visibility="hidden",_F.forEach(function(c){o[c]=i[c]}),n?e.scrollHeight>parseInt(i.height)&&(o.overflowY="scroll"):o.overflow="hidden",r.textContent=e.value.substring(0,t);let a=document.createElement("span");a.textContent=e.value.substring(t)||".",r.appendChild(a),s.appendChild(r);let u=e.getBoundingClientRect(),l={top:u.top-e.scrollTop+a.offsetTop+parseInt(i.borderTopWidth)+a.offsetHeight,left:u.left-e.scrollLeft+a.offsetLeft+parseInt(i.borderLeftWidth)};return s.removeChild(r),l}var Xi=class extends oo{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 FA(this.element,this.element.selectionEnd)}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var i;return(i=n==null?void 0:n.get)==null?void 0:i.call(this.element)},set:i=>{var s;(s=n==null?void 0:n.set)==null||s.call(this.element,i),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});let r=this.element.disabled,o=new MutationObserver(()=>{this.element.disabled!==r&&(r=this.element.disabled,this.emit(r?"disabled":"enabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>o.disconnect())}};function HA(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,u])=>{s.searchParams.append(a,u)}),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 DF(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var rx=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()}},ox=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=HA(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()}},ix=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(),Q.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 ox(t,this.deepdeskUrl,{debug:!0}):new rx(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=DF(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(Q.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;Q.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(A(b({},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)}},zA=ix;function FF(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function Ve(e){return Array.isArray(e)?e.map(Ve):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>A(b({},t),{[FF(n)]:Ve(e[n])}),{}):e}function HF(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function mt(e){return Array.isArray(e)?e.map(mt):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>A(b({},t),{[HF(n)]:mt(e[n])}),{}):e}var _a=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var sx=e=>new Promise(t=>{setTimeout(t,e)});var Da=class extends _a{constructor(){super(...arguments);this.name="ClientError"}},lx=class extends _a{constructor(){super(...arguments);this.name="ServerError"}},ax=new Map;function zF(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:(Q.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var Xo=class Xo{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,u=n.method===void 0||n.method.toLowerCase()==="get",T=n,{useCache:l=!1,abortLatest:c=!1,attempts:f=1,retryDelay:d=500,refreshTokenOn401:p=!0,retryOnError:y=R=>R instanceof TypeError,retryOnResponse:h=R=>R.status>=500,version:g=null}=T,m=te(T,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(l)if(u){if(ax.has(s)){r(ax.get(s));return}}else throw new Error(`Can't use 'useCache' for ${n.method}`);let v=A(b({credentials:"include"},m),{headers:b({Accept:"application/json","Content-Type":"application/json"},m.headers)});!u&&this.csrfToken&&(v.headers=A(b({},v.headers),{"X-CSRFToken":this.csrfToken})),typeof g=="string"&&(v.headers=A(b({},v.headers),{"X-Deepdesk-API-Version":g}));let x=f,S=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&c&&(this.latestRequestByUrl[s].isAborted=!0,this.latestRequestByUrl[s].reject(new Error("Aborted"))),this.latestRequestByUrl[s]=i;let C=()=>P(this,null,function*(){return x--,a(s,v).then(R=>P(this,null,function*(){return h(R)&&!i.isAborted&&x>0?(yield sx(d),C()):R.status===401&&p===!0&&S===!1?(S=!0,yield this.refreshToken(),C()):R})).catch(R=>P(this,null,function*(){if(y(R)&&!i.isAborted&&x>0)return yield sx(d),C();throw R}))});C().then(R=>P(this,null,function*(){let L=yield zF(R);if(delete this.latestRequestByUrl[s],R.status>=500){o(new lx("Server Error",L));return}else if(R.status===401){o(new Da("Unauthorized",L));return}else if(R.status===403){o(new Da("Forbidden",L));return}else if(R.status===404){o(new Da("Not Found",L));return}else if(R.status>=400){o(new Da("Bad Request",L));return}l&&ax.set(s,L),r(L)})).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 Xo.refreshingToken||(Xo.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{Xo.refreshingToken=null},1e3*60)})),Xo.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,b({method:"POST",body:JSON.stringify(n)},r))}patch(t,n,r){return this.request(t,b({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,b({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,b({method:"DELETE"},n))}};Xo.refreshingToken=null;var Qi=Xo;var BA;(t=>{let e;(s=>(s.SEND_MESSAGE="Send Message",s.HANDLING_TIME="Handling Time",s.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",s.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(e=t.EventType||(t.EventType={}))})(BA||(BA={}));function km(e){return A(b({},Ve(e)),{tags:e.tags})}var Zi=class Zi{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new Qi(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?(Zi.exchangeTokenPromise||(Zi.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),Zi.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return P(this,null,function*(){yield this.preflight(),Q.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=yield this.client.post("/api/conversations",A(b({},mt(t)),{tags:t.tags}),{version:"v2"});return km(n)})}getMe(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/session/me/");return Ve(t)})}postIdentity(t){return P(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",mt(t))})}patchMe(t){return P(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",mt(t));return Ve(n)})}getProfile(t){return P(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{useCache:!0});return Ve(n)})}getKnowledgeAssistant(t){return P(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{useCache:!0});return Ve(n)})}getContentTypes(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return Ve(t)})}getAccount(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{useCache:!0});return Ve(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 Ve(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(),Q.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 Q.info(`Successfully retrieved conversation ${s.id} for session ${t}`),km(s)})}isConversationSupported(r){return P(this,arguments,function*(t,n={}){Q.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*(){yield this.preflight();let r=mt(n);n.tags&&(r.tags=n.tags);let o=yield this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return km(o)})}postMessages(t,n){return P(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/conversations/${t}/messages`,n.map(o=>A(b({},mt(o)),{tags:o.tags})),{version:"v2"})).map(o=>km(o))})}sendEvent(t,n){return P(this,null,function*(){yield this.preflight();let s=n,{data:r}=s,o=te(s,["data"]),i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((a,[u,l])=>A(b({},a),{[u]:l}),{});return this.client.post("/api/events",mt(A(b(b({},i),o),{data:r,name:t})),{version:"v2"})})}sendEventV1(t,n){return P(this,null,function*(){yield this.preflight();let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>A(b({},o),{[i]:s}),{});return this.client.post("/api/events",{event:t,data:mt(b(b({},n),r))},{version:"v1"})})}getEntities(t){return P(this,null,function*(){return yield this.preflight(),(yield this.client.post("/api/entities",{messages:t.filter(r=>r.text)},{version:"v1"})).entities})}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 Q.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/",mt(n),{refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return P(this,arguments,function*(t,n={},r){return yield this.preflight(),r==="sticky-messages"?this.getPinnedMessages(t):(yield this.client.post(`/api/conversations/${t}/recommend/${r}`,mt(n),{abortLatest:!0,version:"v1"})).map(s=>A(b({},Ve(s)),{text:s.text||s.url||s.message,source:r,type:r})).filter((s,a,u)=>a===u.findIndex(l=>l.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.preflight(),(yield this.client.post(`/api/conversations/${t}/autocomplete`,mt(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 Ve(n).map(r=>A(b({},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",mt(t),{abortLatest:!0,version:"v1"});return Ve(n)})}search(t){return P(this,null,function*(){let n=yield this.client.post(`/api/profiles/${t.profile}/search`,mt(t),{version:"v2"});return Ve(n)})}knowledgeAssist(i,s,a){return P(this,arguments,function*(t,n,r,o={}){yield this.preflight();let u=yield this.client.post(`/api/knowledge-assist/assistants/${r}/search`,mt({question:t.question,doNotKnowAnswer:t.doNotKnowAnswer,customerInstruction:t.customerInstruction,chatHistory:n.map(l=>({question:l.question,answer:l.answer.answer})),agentId:o.agentId,conversationId:o.conversationId}),{version:"v2"});return Ve(u)})}requestLoginByEmail(t){return P(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t});return Ve(n)})}requestPasswordlessToken(){return P(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/");return Ve(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 Ve(n)})}getSummary(r){return P(this,arguments,function*(t,n={}){yield this.preflight();let o=yield this.client.post("/api/summary",{conversation:{messages:t.filter(i=>i.text&&i.source),agent_id:n.agentId,id:n.externalConversationId},prompt_instruction:n.promptInstruction,model:n.model},{version:"v1"});return Ve(o)})}evaluateAssistant(t,n){return P(this,null,function*(){var a;yield this.preflight();let r=new URLSearchParams,{expectFormat:o="text"}=n||{};if(o.startsWith("json-schema:")){let u=o.replace("json-schema:","");r.append("expect_response_format","json-schema"),r.append("expect_response_format_schema",u)}else r.append("expect_response_format",o);n!=null&&n.externalConversationId&&r.append("external_conversation_id",n.externalConversationId);let i=n!=null&&n.threadId?`/api/v2/assistants/${t}/threads/${n==null?void 0:n.threadId}/evaluate?${r.toString()}`:`/api/v2/assistants/${t}/evaluate?${r.toString()}`,s=yield this.client.post(i,{input:(a=n==null?void 0:n.input)!=null?a:{},conversation:n==null?void 0:n.transcript});return Ve(s.output)})}createAssistantThread(t){return P(this,null,function*(){yield this.preflight();let{assistantCode:n}=t,r=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return Ve(r)})}postMessageToAssistantThread(t){return P(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:r,message:o}=t,i=yield this.client.post(`/apis/admin/assistants/${n}/threads/${r}/messages/`,{content:o,role:"user"});return Ve(i)})}translateMessages(t){return P(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/translate",mt(t),{version:"v2"});return Ve(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(kS);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&Q.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};Zi.exchangeTokenPromise=null;var io=Zi;var UA={startTime:null,stopTime:null},jA=e=>e.handlingTime,VA=ye({name:"handlingTime",initialState:UA,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(rt,()=>UA)}}),{handlingTimeStart:WA,handlingTimeStop:Rm,handlingTimeReset:$A}=VA.actions,KA=VA.reducer;var qA=(e={})=>{let t=b({onAuthError:Qs(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var Pm={list:{keywordMatches:[]},fetchState:"idle"};var Ji=fe("styleSuggestions/getAll",(n,r)=>P(void 0,[n,r],function*({text:e},t){var u;let{deepdeskAPI:o}=t.extra,i=t.getState(),{showStyleSuggestions:s}=i.settings,a=(u=i.conversation.current)==null?void 0:u.profileCode;if(!s)return Pm.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),BF=ye({name:"styleSuggestions",initialState:Pm,reducers:{},extraReducers:e=>{e.addCase(Ji.pending,t=>{t.fetchState="loading"}).addCase(Ji.rejected,t=>{t.fetchState="error"}).addCase(Ji.fulfilled,(t,n)=>{t.fetchState="done",_o(t.list,n.payload)||(t.list=n.payload)}).addCase(xi,t=>{t.list=Pm.list}).addCase(rt,()=>Pm)}}),GA=BF.reducer;var YA=(e={})=>{let t,n=!0,r=b({getStyleSuggestions:Ji,debounce:500},e);return o=>i=>s=>{var p;let a=o.getState().input.text,u=i(s),l=o.getState();if(l.auth.isLoggedIn!==!0)return u;let{showStyleSuggestions:c}=l.settings;if(!((p=l.conversation.current)==null?void 0:p.id)||!c)return u;let{text:d}=l.input;return d===a&&!n||(clearTimeout(t),d==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:d}))},e.debounce)),u}};function UF(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var XA=(e={})=>{let t=b({getTextSuggestions:tr,getAutocompleteSuggestions:rc,debounce:200,check:Er},e),n;return r=>o=>i=>{var h;let{input:s}=r.getState(),a=o(i),u=r.getState();if(u.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:l,showTabCompletion:c}=u.settings,f=(h=u.conversation.current)==null?void 0:h.id,d=i.type===Zp.toString();if(!f||!l&&!c)return a;let{input:p}=u;return UF(p,s)&&!d||(clearTimeout(n),!t.check(u))||(n=setTimeout(()=>{let g=Js(u);g===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(g))},d?0:t.debounce)),a}};var QA=Ji.fulfilled.toString();function jF(e,t){let n=new Set([...t.keywordMatches.map(o=>o.keyword)]),r=[];return n.forEach(o=>{let i=e.keywordMatches.filter(u=>u.keyword===o),s=t.keywordMatches.filter(u=>u.keyword===o),a=s.length-i.length;a<=0||r.push(...s.slice(0,a))}),r}var ZA=e=>t=>n=>r=>{var l;if(r.type!==QA){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let i=t.getState(),s=i.styleSuggestions.list,a=(l=i.conversation)==null?void 0:l.current;if(o===s)return;let u=jF(o,s);r.type===QA&&u.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:u}})};var VF=ef({assistants:cC,auth:ZE,conversation:uT,contentTypes:fC,passwordlessToken:nA,entities:UC,knowledgeAssistant:oC,handlingTime:KA,info:AT,input:wT,settings:$E,profile:hC,search:_T,styleSuggestions:GA,ui:bP,textSuggestions:aP});function JA(e){return Q1({reducer:VF,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI}},serializableCheck:!1}),qA(),XA({debounce:200}),YA({debounce:500}),ZA(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var WF=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},$F=e=>t=>n=>r=>{var a,u,l,c,f,d;let o=t.getState(),i=Zl("inlineSuggestions")(o);switch(r.type){case Qs.toString():{!r.payload&&e.emit("logout",void 0);break}case Kn.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 kn.toString():e.sendEvent(r.payload.name,{conversationId:((u=r.payload.options)==null?void 0:u.includeConversationData)&&((l=o.conversation.current)==null?void 0:l.id),data:r.payload.data});break;case xi.toString():e.logSendMessage(r.payload);break;case tp.toString():e.emit("call-to-action",{cue:r.payload});break;case Vn.fulfilled.toString():r.isBroadcasted||e.broadcast(rv,r,!1);break;default:break}let s=n(r);switch(r.type){case xi.toString():e.handleAfterSendMessage(r.payload);break;case ic.toString():e.onUpdateShowTabHint(r.payload);break;case Rm.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case Ff.toString():{let{start:p,end:y}=o.input.selection;e.emit("replace",A(b({},r.payload),{replace:r.payload.replace==="selection"?{start:p,end:y}:{start:0,end:y}}));break}case Bn.toString():{let{start:p,end:y}=o.input.selection;e.emit("select-suggestion",A(b({type:WF(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:p,end:y}:{start:0,end:y}})),i&&t.dispatch(Do([]));break}case Hf.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(c=o.conversation.current)==null?void 0:c.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case Do.toString():{i&&r.payload.length>0&&t.dispatch(zf(0));break}case jn.fulfilled.toString():{e.sendEvent("conversation summarized",{conversationId:(f=o.conversation.current)==null?void 0:f.id,data:{summary:r.payload,assistant:(d=t.getState().profile.data)==null?void 0:d.summarizerAssistantNew}}),e.emit("summary-generated",{summary:r.payload});break}default:break}return s},eI=$F;function ux(e){return e.toISOString().replace("T"," ").replace("Z","")}var KF=(e,t)=>t.version,tI=zn([ta,hr,jA,KF],(e,t,n,r)=>{if(!t)return Q.warn("No conversationId for handling time metrics"),null;let{startTime:o,stopTime:i}=n;return!o||!i?(Q.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:t,clientVersion:r,agentId:e==null?void 0:e.agentId,agentName:e==null?void 0:e.agentName,agentEmail:e==null?void 0:e.agentEmail,timeStart:ux(o),timeStop:ux(i)}});function nI(e,t,n){var L,O,G,D;let r=(L=t.conversation.current)==null?void 0:L.id;if(!r)return Q.warn("No conversationId for send message metrics"),null;let{text:o,metrics:{numCharsTyped:i,numCharsPasted:s,numCharsCut:a,numCharsDeleted:u,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:f,pastes:d,cuts:p,deletions:y,textSuggestions:h,offeredTextSuggestions:g}}=t[e],m=o.length,x=h.reduce((B,{text:j,searchTerm:le})=>B+j.length-(le?le.length:0),0),S=c!=null?c:Date.now(),C=(Date.now()-S)/1e3+(f||0),T=i/C,R=h.reduce((B,{searchTerm:j})=>B+(j?j.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:d,cuts:p,deletions:y,lenTextTyped:i+R,lenTextTotal:m,lenTextAssisted:x,lenTextPasted:s,lenTextCut:a,lenTextDeleted:u,timeTotalSeconds:C,charsPerSecond:T,numPastes:l,textSuggestionsV2:h,suggestionsCounters:[{source:"gpt",countOffered:g.filter(B=>B.source==="gpt").length}],agentId:(O=t.info.agentInfo)==null?void 0:O.agentId,agentName:(G=t.info.agentInfo)==null?void 0:G.agentName,agentEmail:(D=t.info.agentInfo)==null?void 0:D.agentEmail}}function cx(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return cx(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?cx(o,t):null}function dx(e,t){return cx(e,t)}function rI(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function qF(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Am(e){return qF(e)&&(qi(e)||am(e))}var iI,kr=new Map,GF=["bottom","height","left","right","top","width"],oI=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:GF.some(n=>e[n]!==t[n]);function sI(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,...sI(t)]:[]}function aI(e,t){return!e||!t?null:A(b({},e),{top:e.top+t.top,left:e.left+t.left})}var Im=!1,lI=()=>{Im=!0;let e=[];if(kr.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),kr.delete(n);return}let r=n.getBoundingClientRect();oI(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(aI,t.rect):t.rect;oI(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),kr.size===0){Im=!1;return}iI=window.requestAnimationFrame(lI)};function fx(e,t){let n=sI(e),r=[],o=n.map((i,s)=>fx(i,a=>{r[s]=a;let u=kr.get(e);if(!u)return;let l=r.reduce(aI,u.rect);u.callbacks.forEach(c=>c(l))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),kr.has(e)){let s=kr.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else kr.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Im&&lI()},unobserve(){o.forEach(s=>s.unobserve());let i=kr.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||kr.delete(e),kr.size||(cancelAnimationFrame(iI),Im=!1)}}}}var uI,Rr=new Map,cI=()=>{Rr.forEach((e,t)=>{if(!t.isConnected){Rr.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)))}),Rr.size!==0&&(uI=window.requestAnimationFrame(cI))};function dI(e,t){return{observe(){let n=Rr.size===0;Rr.has(e)?Rr.get(e).callbacks.push(t):Rr.set(e,{visible:void 0,callbacks:[t]}),n&&cI()},unobserve(){let n=Rr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Rr.delete(e),Rr.size||cancelAnimationFrame(uI)}}}}var px=["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 mx(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function Fa(e){return parseFloat(e)}function Lm(e){return Math.round(e*1e6)}function fI(e){return e/1e6}function gx(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=Fa(e.width),i=Fa(e.borderLeftWidth),s=Fa(e.borderRightWidth),a=Fa(e.paddingRight),u=fI(Lm(o)-Lm(i)-Lm(s)),l=fI(Lm(r));if(u-l>2){let c=u-l;n.style.paddingRight=`${a+c}px`}}function gc(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",Oi(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};mx(r,n,px),gx(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=dI(e,()=>{mx(r,n,px),gx(r,e,n),i(),setTimeout(i,0)}),a,u=!0,l=fx(e,d=>{if(d===null){t.onRemove&&t.onRemove(),n.remove();return}if(!u&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),u=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),u=!1},200),d.height===0&&d.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(mx(r,n,px),gx(r,e,n),i(),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let p=t.closestScrollElement.getBoundingClientRect(),y=window.getComputedStyle(t.closestScrollElement),h=Fa(y.borderTopWidth),g=Fa(y.borderBottomWidth),m=p.top+h-d.top,v=d.top+d.height+-(p.top+p.height-g);n.style.clipPath=`inset(${m}px 0px ${v}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(f=e.parentElement)==null||f.appendChild(n),l.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),l.unobserve(),s.unobserve()}]}var pI=(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){Q.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function YF(e){return e.offsetParent!==null}function mI(e){if(!YF(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 Om(e,t,n=100){let r=mI(e);t({isVisible:r});let o=setInterval(()=>{let i=mI(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var it=w(k());var gI=pI("showTabHint",!0),Ha=class Ha{constructor({deepdeskUrl:t,version:n=Ha.version||"unknown",locale:r="en-US",token:o,fetch:i,productName:s,createCustomChannel:a}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.inlineSuggestions=null;this.aboveSuggestions=null;this.floatingMenu=null;this.widgetRoot=null;this.dynamicThunkObject={};this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let u=t.replace(/\/api$/,"");this.deepdeskApi=new io(u,{token:o,fetch:i}),this.version=n,this.instanceId=Ha.count++;let l={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[eI({broadcast:(c,f,d)=>{this.broadcastEvents.send(c,f,d)},emit:(c,f)=>this.emit(c,f),handleAfterSendMessage:c=>this.handleAfterSendMessage(c),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:c=>this.logSendMessage(c),onUpdateShowTabHint:c=>gI.update(c),sendEvent:(c,f)=>this.deepdeskApi.sendEvent(c,f)})]};this.store=JA(l),this.broadcastEvents=new zA({debug:!0,deepdeskUrl:u,eventMap:DT(this.store),createCustomChannel:a}),this.store.dispatch(ic(gI.value())),this.store.dispatch(Lf({locale:r,adminUrl:u,productName:s}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var t;return(t=this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex])!=null?t:null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(Q.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(Q.warn("Profile has not been loaded (yet)"),!0):(Q.warn("No conversation loaded (yet)"),!0)}login(){this.store.dispatch(Qs(null)),this.store.dispatch(Ur());let t=n=>Nt(n)&&KE(n)!=="loading";return new Promise(n=>{let r=this.subscribe(t,o=>{o&&(r(),n())});this.unmountHandlers.push(()=>{r()})})}isLoggedIn(){return P(this,null,function*(){return(yield this.store.dispatch(Ur())).payload})}isConversationSupported(t,n){return P(this,null,function*(){return(yield this.store.dispatch(Qy({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(Mf(t))).payload})}getConversationBySessionId(t,n){return P(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(yield this.store.dispatch(Nf({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(Zy(t))).payload})}postMessages(t){return P(this,null,function*(){return(yield this.store.dispatch(Df(t))).payload})}updateConversation(t){return P(this,null,function*(){return(yield this.store.dispatch(_f(t))).payload})}resetConversation(){this.store.dispatch(rt()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(t){this.store.dispatch(Lf(t))}setVisitorInfo(t){this.store.dispatch(kT(t))}setCustomData(t){this.store.dispatch(RT(t))}setAgentInfo(t,n){return P(this,null,function*(){yield this.store.dispatch(tu(b(b({},t),n)))})}setAgentSettings(t){return P(this,null,function*(){yield this.store.dispatch(ev(t))})}getAgentSettings(){return P(this,null,function*(){return(yield this.store.dispatch(tv())).payload})}refresh(){return P(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(Bf({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let t=[];return this.store.dispatch(Zp()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}notifyExternalSuggestion(t){this.store.dispatch(Bn(t))}evaluateAssistant(t,n){return P(this,null,function*(){let c=n||{},{input:r={},transcript:o,showCuesInWidget:i=!0,includeTags:s,expectFormat:a}=c,u=te(c,["input","transcript","showCuesInWidget","includeTags","expectFormat"]);Object.assign(r,u);let l=yield this.store.dispatch(Vn({assistantCode:t,expectFormat:a||"json-schema:cues",transcript:o,includeTags:s,input:r,skipState:!i}));if(l.error)throw new Error(l.error.message);return l.payload})}evaluateConversationAssistant(t,n){return P(this,null,function*(){yield this.loadProfileConfig();let r={accepted:"conversationAcceptedAssistant","new-message":"conversationNewMessageAssistant",ended:"conversationEndedAssistant"},o=this.state.profile.data[r[t]];if(!o){Q.warn(`No assistant set in profile for conversation event "${t}"`);return}yield this.evaluateAssistant(o,b({transcript:"stored-transcript",includeTags:!0},n))})}getSummary(){return P(this,null,function*(){var n;if(!this.hasConversation())return Q.warn("No conversation to create summary for."),null;(n=this.state.profile.data)!=null&&n.summarizerAssistantNew||Q.warn("No profile loaded yet, or no summarizer assistant set in profile");let t=yield this.store.dispatch(jn({}));if(t.error)throw new Error(t.error.message);return t.payload})}handleKeyDown(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:i,selection:s}=this.state.input,{inlineSuggestions:a,showTextSuggestions:u}=this.settings,l=a?"below":"above",c=o.length>0;if(this.store.dispatch(mT(Jy(t))),!Er(this.state)||t.key!=="Tab"&&!u)return;let f=()=>{n||!c||s&&(t.shiftKey||(this.store.dispatch(yT()),t.preventDefault()))},d=()=>{n||!c||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(vT()),t.preventDefault()))};switch(t.key){case"ArrowUp":l==="below"?d():f();break;case"ArrowDown":{l==="below"?f():d();break}case"Escape":{n||(this.store.dispatch(zf(-1)),this.store.dispatch($o({collapse:!0})),this.store.dispatch(SP(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let p=ea(this.state);if(!p)return;this.store.dispatch(ic(!1)),this.store.dispatch(Bn({text:p.text,suggestion:p,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let p=ea(this.state);if(!p)return;this.store.dispatch(Bn({text:p.text,suggestion:p,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.settings.inlineSuggestions||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let p=ea(this.state);if(!p)return;this.store.dispatch(Bn({text:p.text,suggestion:p,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch($o({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(Do([]))}handlingTimeStart(){this.state.handlingTime.startTime||(Q.info("Start handling time"),this.store.dispatch(WA()))}handlingTimeStop(){this.state.handlingTime.startTime&&(Q.info("Stop handling time"),this.store.dispatch(Rm()))}logSendMessage(t){let n=nI("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=tI(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch($A()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(xi((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(ST()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(i){Q.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),Q.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(PT(t))}whenConversationLoaded(t){let n=o=>{var i;return(i=o.conversation.current)==null?void 0:i.id},r=()=>this.loadProfileConfig().then(()=>t());n(this.state)&&r(),this.subscribe(n,o=>{o&&r()})}overlayContainerFactory(t,n,r,o){let[i,s]=gc(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,gt.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[u,l]=gc(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});u.dataset.testid=n,u.style.zIndex="2",u.appendChild(r),this.unmountHandlers.push(()=>{(0,gt.unmountComponentAtNode)(o),l()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return Oi(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,gt.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),Q.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()?(Q.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(xT(r.metrics))):Q.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(!Am(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let d=n,{customStyles:r,closestScrollSelector:o,floatingMenuParent:i,appendOverlayTo:s,inputMediator:a}=d,u=te(d,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),l={customStyles:r,closestScrollSelector:o,floatingMenuParent:i,appendOverlayTo:s};this.configure(u),this.settings.automaticHandlingTime&&this.setupHandlingTime(t),Oi(t),this.inputMediator=a||(qi(t)?new Xi(t):new Yi(t)),this.inputMediator.on("change",({plainText:p,rawHTML:y})=>{this.store.dispatch(Bf({text:p,html:y}))}),this.inputMediator.on("keyup",p=>{this.store.dispatch(gT(Jy(p)))}),this.inputMediator.on("keydown",p=>{this.handleKeyDown(p)}),this.inputMediator.on("paste",({pastedText:p,selectionText:y})=>{this.store.dispatch(hT({text:p,selectionText:y}))}),this.inputMediator.on("cut",({selectionText:p})=>{this.store.dispatch(pT(p))});let c;this.inputMediator.on("selection",p=>{clearTimeout(c),p===null?c=setTimeout(()=>{p!==null&&this.store.dispatch(Uf(p))},500):this.store.dispatch(Uf(p))}),this.inputMediator.on("disabled",()=>{var p;(p=this.inputMediator)==null||p.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{this.settings.detectSubmit&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(tm(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(tm(!0))}),this.renderSuggestions(t,l),this.subscribe(Zl("inlineSuggestions"),()=>{this.renderSuggestions(t,l)});let f=this.renderOverlays(n);this.unmountHandlers.push(()=>{f.unmount()}),this.store.dispatch(Bf({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(Uf(this.inputMediator.getSelection())),this.store.dispatch(tm(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{var p;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((p=this.state.conversation.current)==null?void 0:p.sessionId)}),this.isMounted=!0}subscribe(t,n){let r=t(this.store.getState());return this.store.subscribe(()=>{let o=t(this.store.getState());o!==r&&(r=o,n(r))})}unmount(){var t,n,r,o;(t=this.inlineSuggestions)==null||t.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(r=this.floatingMenu)==null||r.unmount(),this.unmountHandlers.forEach(i=>i()),this.unmountHandlers=[],(o=this.inputMediator)==null||o.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderSuggestions(t,n){var r,o,i;(r=this.floatingMenu)==null||r.unmount(),(o=this.inlineSuggestions)==null||o.unmount(),(i=this.aboveSuggestions)==null||i.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(t,n)),this.settings.inlineSuggestions?this.inlineSuggestions=this.renderInlineSuggestions(t,n):this.aboveSuggestions=this.renderAboveSuggestions(t,n)}renderInlineSuggestions(t,n){let{customStyles:r}=n,o=this.createInlineContainer(t,"deepdesk-caret");(0,gt.render)((0,it.jsx)(Ki,{store:this.store,customStyles:r,children:(0,it.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,it.jsx)(PP,{})})}),o);let i=s=>{s?(o.style.display="block",o.style.top=`${s.top}px`,o.style.left=`${s.left}px`):o.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var s;(0,gt.unmountComponentAtNode)(o),(s=this.inputMediator)==null||s.off("caretposition",i),o.remove()}}}renderAboveSuggestions(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:i}=n,s=o&&dx(t,o)||void 0,a=this.overlayContainerFactory("deepdesk-tab-completion",s||t,{appendTo:i,closestScrollElement:s,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),u=this.overlayContainerFactory("deepdesk-suggestions-overlay",s||t,{appendTo:i},r==null?void 0:r.suggestionsRootNode);return(0,gt.render)((0,it.jsx)(Ki,{store:this.store,customStyles:r,children:(0,it.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,it.jsx)(JP,{inputElement:t})})}),a),(0,gt.render)((0,it.jsx)(Ki,{store:this.store,customStyles:r,children:(0,it.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,it.jsx)(FP,{onLogIn:()=>this.loginViaPopup().catch(l=>Q.warn(l.message))})})}),u),{unmount(){(0,gt.unmountComponentAtNode)(a),(0,gt.unmountComponentAtNode)(u),a.remove(),u.remove()}}}renderFloatingMenu(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:i,floatingMenuParent:s}=n,a=o&&dx(t,o)||void 0,u=this.overlayContainerFactory("floating-menu",a||t,{appendTo:s!=null?s:i},r==null?void 0:r.floatingMenuParent);return(0,gt.render)((0,it.jsx)(Ki,{store:this.store,customStyles:r,children:(0,it.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,it.jsx)(vP,{onLogIn:()=>this.loginViaPopup().catch(l=>Q.warn(l.message))})})}),u),{unmount(){(0,gt.unmountComponentAtNode)(u),u.remove()}}}renderOverlays(t){let{customStyles:n}=t,r=this.createContainer("deepdesk-overlays");return(0,gt.render)((0,it.jsx)(Ki,{store:this.store,customStyles:n,children:(0,it.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,it.jsx)(pP,{})})}),r),{unmount(){(0,gt.unmountComponentAtNode)(r),r.remove()}}}renderWidget(t,n={}){if(this.widgetRoot&&Q.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,gt.render)((0,it.jsx)(Ki,{store:this.store,customStyles:r,children:(0,it.jsx)(wi,{broadcastEvents:this.broadcastEvents,children:(0,it.jsx)(MA,{onLogIn:()=>this.loginViaPopup().catch(s=>Q.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,gt.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Om(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){rI(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(wu());let t=Ei(this.state);t&&(yield this.store.dispatch(hu()),this.store.dispatch(Lf({showSearch:t.search,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:!!t.summarizerAssistantNew||t.summarizer,showKnowledgeSearch:!!t.knowledgeAssistantNew||!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions})))})),this.loadProfileConfigPromise)}loginViaPopup(t){return P(this,null,function*(){return new Promise((n,r)=>{let o=new MessageChannel,i=o.port1,s=this.settings.adminUrl,a=new URL(t!=null&&t.url?t==null?void 0:t.url:`${s}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let u=!1,l=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",f),clearInterval(d)};i.onmessage=p=>P(this,null,function*(){var y,h;if((y=p.data)!=null&&y.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((h=p.data)==null?void 0:h.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(ru),u=!0,o.port1.close(),n()}catch(g){console.error(g),r(g)}finally{u=!0,l()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&r(new Error("Popup blocked by browser"));let f=p=>P(this,null,function*(){var y;if(p.origin===a.origin)switch((y=p.data)==null?void 0:y.type){case"deepdesk-popup-loaded":{try{let h=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(h,a.origin,[o.port2])}catch(h){Q.error("Error posting message to popup",h),r(h)}break}case"deepdesk-popup-error":{l(),p.data.message==="Timeout"&&Q.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(p.data.message));break}}});window.addEventListener("message",f);let d=setInterval(()=>{c&&!c.closed||(l(),u||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(l)})})}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(Q.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;Q.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=bu(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(Kn()):Dc.includes(r)||this.store.dispatch(tr(r))})}catch(r){this.handleError(r)}})}};Ha.version="15.1.1-beta.7",Ha.count=0;var hc=Ha;function XF(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 hI(e,t){return P(this,null,function*(){let n=yield XF(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 yI(e,t,n){return P(this,null,function*(){yield new io(e).authenticateWithKey(t,n)})}function vI(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function xI(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},u=`${i.slice(0,s)}${t}${i.slice(a)}`,l=(d=n.selectionAfter)!=null?d:{start:s+t.length,end:s+t.length},c=()=>{if(n.setValue)return n.setValue(u);e.value=u};return Promise.resolve(c()).then(()=>{e.selectionStart=l.start,e.selectionEnd=l.end,e.blur(),e.focus()})})}function SI(r,o){return P(this,arguments,function*(e,t,n={}){let i=n.replace?Yo(e,n.replace.start,n.replace.end):Na(e),s,a=()=>{if(n.setRange)return n.setRange(i.cloneRange());i.deleteContents(),s=document.createElement("span"),i.insertNode(s),n.insertBRs!==!1?t.split(`
|
|
84
84
|
`).reverse().forEach((u,l)=>{l>0&&i.insertNode(document.createElement("br")),i.insertNode(document.createTextNode(u))}):i.insertNode(document.createTextNode(t))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){e.focus();let u=n.selectionAfter?Yo(e,n.selectionAfter.start,n.selectionAfter.end):(i.collapse(!1),i),l=window.getSelection();l==null||l.removeAllRanges(),l==null||l.addRange(u)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})})}function QF(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 ZF(e){let t=document.createDocumentFragment();return e.split(`
|
|
85
85
|
`).forEach((n,r)=>{r>0&&t.appendChild(document.createElement("br"));let o={index:0},i=0;for(;o=n.slice(i).match(/(\[([^\]]+)])\(([^)]+)\)/);){let s=document.createElement("a");s.href=o[3],s.setAttribute("target","_blank"),s.setAttribute("rel","noopener noreferrer"),s.appendChild(document.createTextNode(o[2])),t.appendChild(document.createTextNode(n.slice(i,i+o.index))),t.appendChild(s),i=i+o.index+o[0].length}t.appendChild(document.createTextNode(n.slice(i)))}),t}function wI(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):wI(n,t)}function bI(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 u=(d=e.ownerDocument.defaultView)!=null?d:window,l=u.getSelection();if((!l||l.rangeCount===0)&&(e.focus(),l=u.getSelection()),!l||l.rangeCount===0)return;let c=l.getRangeAt(0);if(!c)return;s=document.createElement("span"),c.insertNode(s);let f=r?QF(t):ZF(t);n?wI(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 DI(JF);})();
|
|
86
86
|
/*! Bundled license information:
|