vanilla-agent 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +1 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/launcher.ts +1 -1
package/dist/index.global.js
CHANGED
|
@@ -60,7 +60,7 @@ lucide.createIcons({icons});\``);if(typeof a=="undefined")throw new Error("`crea
|
|
|
60
60
|
<span class="tvw-text-xs tvw-text-cw-muted" data-role="launcher-subtitle"></span>
|
|
61
61
|
</span>
|
|
62
62
|
<span class="tvw-ml-2 tvw-grid tvw-place-items-center tvw-rounded-full tvw-bg-cw-primary tvw-text-cw-call-to-action" data-role="launcher-call-to-action-icon">\u2197</span>
|
|
63
|
-
`,t.addEventListener("click",e);let a=l=>{var U,B,A,E,y,yt,q,L,lt,ct;let d=(U=l.launcher)!=null?U:{},s=t.querySelector("[data-role='launcher-title']");s&&(s.textContent=(B=d.title)!=null?B:"Chat Assistant");let p=t.querySelector("[data-role='launcher-subtitle']");p&&(p.textContent=(A=d.subtitle)!=null?A:"Get answers fast");let c=t.querySelector(".tvw-flex-col");c&&(d.textHidden?c.style.display="none":c.style.display="");let h=t.querySelector("[data-role='launcher-icon']");if(h)if(d.agentIconHidden)h.style.display="none";else{let ut=(E=d.agentIconSize)!=null?E:"40px";if(h.style.height=ut,h.style.width=ut,h.innerHTML="",d.agentIconName){let kt=parseFloat(ut)||24,Ct=vt(d.agentIconName,kt*.6,"#ffffff",2);Ct?(h.appendChild(Ct),h.style.display=""):(h.textContent=(y=d.agentIconText)!=null?y:"\u{1F4AC}",h.style.display="")}else d.iconUrl?h.style.display="none":(h.textContent=(yt=d.agentIconText)!=null?yt:"\u{1F4AC}",h.style.display="")}let m=t.querySelector("[data-role='launcher-image']");if(m){let ut=(q=d.agentIconSize)!=null?q:"40px";m.style.height=ut,m.style.width=ut,d.iconUrl&&!d.agentIconName&&!d.agentIconHidden?(m.src=d.iconUrl,m.style.display="block"):m.style.display="none"}let f=t.querySelector("[data-role='launcher-call-to-action-icon']");if(f){let ut=(L=d.callToActionIconSize)!=null?L:"32px";f.style.height=ut,f.style.width=ut,d.callToActionIconBackgroundColor?(f.style.backgroundColor=d.callToActionIconBackgroundColor,f.classList.remove("tvw-bg-cw-primary")):(f.style.backgroundColor="",f.classList.add("tvw-bg-cw-primary"));let kt=0;if(d.callToActionIconPadding?(f.style.boxSizing="border-box",f.style.padding=d.callToActionIconPadding,kt=(parseFloat(d.callToActionIconPadding)||0)*2):(f.style.boxSizing="",f.style.padding=""),d.callToActionIconHidden)f.style.display="none";else if(f.style.display="",f.innerHTML="",d.callToActionIconName){let Ct=parseFloat(ut)||24,k=Math.max(Ct-kt,8),G=vt(d.callToActionIconName,k,"currentColor",2);G?f.appendChild(G):f.textContent=(lt=d.callToActionIconText)!=null?lt:"\u2197"}else f.textContent=(ct=d.callToActionIconText)!=null?ct:"\u2197"}let C=d.position&&Ua[d.position]?Ua[d.position]:Ua["bottom-right"],D="tvw-fixed tvw-flex tvw-items-center tvw-gap-3 tvw-rounded-launcher tvw-bg-cw-surface tvw-py-2.5 tvw-pl-3 tvw-pr-3 tvw-shadow-lg tvw-border tvw-border-gray-200 tvw-transition hover:tvw-translate-y-[-2px] tvw-cursor-pointer";t.className=`${D} ${C}`},o=()=>{t.removeEventListener("click",e),t.remove()};return r&&a(r),{element:t,update:a,destroy:o}};var BA=r=>{var p,c,h,m,f;if(!((c=(p=r==null?void 0:r.launcher)==null?void 0:p.enabled)!=null?c:!0)){let C=g("div","tvw-relative tvw-w-full tvw-h-full"),D=g("div","tvw-relative tvw-w-full tvw-h-full tvw-min-h-[360px]");return C.appendChild(D),{wrapper:C,panel:D}}let t=(h=r==null?void 0:r.launcher)!=null?h:{},a=t.position&&Ua[t.position]?Ua[t.position]:Ua["bottom-right"],o=g("div",`tvw-fixed ${a} tvw-z-50 tvw-transition`),l=g("div","tvw-relative tvw-min-h-[320px]"),d=(f=(m=r==null?void 0:r.launcher)==null?void 0:m.width)!=null?f:r==null?void 0:r.launcherWidth,s=d!=null?d:"min(400px, calc(100vw - 24px))";return l.style.width=s,l.style.maxWidth=s,o.appendChild(l),{wrapper:o,panel:l}},PA=(r,e=!0)=>{var Bt,Xt,Ut,ga,va,Et,Xa,ha,ya,st,Yt,wa,Ca,ae,Sa,Aa,ka,ba,Ha,La,Ta,Va,Ba,n,P,i,R,v,S,w,O,z,u,b,T,M,x,I,W,j,ot,nt,ft,at,_,X,Y,Ht,J,ea,xo,mo,Mo,go,vo,yo,wo,Co,So,Ao;let t=g("div","tvw-flex tvw-h-full tvw-w-full tvw-flex-col tvw-bg-cw-surface tvw-text-cw-primary tvw-rounded-2xl tvw-overflow-hidden tvw-shadow-2xl tvw-border tvw-border-cw-border"),a=g("div","tvw-flex tvw-items-center tvw-gap-3 tvw-bg-cw-surface tvw-px-6 tvw-py-5 tvw-border-b-cw-divider"),o=(Bt=r==null?void 0:r.launcher)!=null?Bt:{},l=(Xt=o.headerIconSize)!=null?Xt:"48px",d=(Ut=o.closeButtonSize)!=null?Ut:"32px",s=(ga=o.closeButtonPlacement)!=null?ga:"inline",p=(va=o.headerIconHidden)!=null?va:!1,c=o.headerIconName,h=g("div","tvw-flex tvw-items-center tvw-justify-center tvw-rounded-xl tvw-bg-cw-primary tvw-text-white tvw-text-xl");if(h.style.height=l,h.style.width=l,!p)if(c){let N=parseFloat(l)||24,xt=vt(c,N*.6,"#ffffff",2);xt?h.replaceChildren(xt):h.textContent=(Xa=(Et=r==null?void 0:r.launcher)==null?void 0:Et.agentIconText)!=null?Xa:"\u{1F4AC}"}else if((ha=r==null?void 0:r.launcher)!=null&&ha.iconUrl){let N=g("img");N.src=r.launcher.iconUrl,N.alt="",N.className="tvw-rounded-xl tvw-object-cover",N.style.height=l,N.style.width=l,h.replaceChildren(N)}else h.textContent=(st=(ya=r==null?void 0:r.launcher)==null?void 0:ya.agentIconText)!=null?st:"\u{1F4AC}";let m=g("div","tvw-flex tvw-flex-col"),f=g("span","tvw-text-base tvw-font-semibold");f.textContent=(wa=(Yt=r==null?void 0:r.launcher)==null?void 0:Yt.title)!=null?wa:"Chat Assistant";let C=g("span","tvw-text-xs tvw-text-cw-muted");C.textContent=(ae=(Ca=r==null?void 0:r.launcher)==null?void 0:Ca.subtitle)!=null?ae:"Here to help you get answers fast",m.append(f,C),p?a.append(m):a.append(h,m);let D=(Sa=o.clearChat)!=null?Sa:{},U=(Aa=D.enabled)!=null?Aa:!0,B=null,A=null;if(U){let N=(ka=D.size)!=null?ka:"32px",xt=(ba=D.iconName)!=null?ba:"refresh-cw",Lt=(Ha=D.iconColor)!=null?Ha:"",Qt=(La=D.backgroundColor)!=null?La:"",qt=(Ta=D.borderWidth)!=null?Ta:"",na=(Va=D.borderColor)!=null?Va:"",Pa=(Ba=D.borderRadius)!=null?Ba:"",fa=(n=D.paddingX)!=null?n:"",_a=(P=D.paddingY)!=null?P:"",ia=(i=D.tooltipText)!=null?i:"Clear chat",Fo=(R=D.showTooltip)!=null?R:!0;A=g("div","tvw-relative tvw-ml-auto tvw-clear-chat-button-wrapper"),B=g("button","tvw-inline-flex tvw-items-center tvw-justify-center tvw-rounded-full tvw-text-cw-muted hover:tvw-bg-gray-100 tvw-cursor-pointer tvw-border-none"),B.style.height=N,B.style.width=N,B.type="button",B.setAttribute("aria-label",ia);let ko=vt(xt,"20px",Lt||"",2);if(ko&&B.appendChild(ko),Lt&&(B.style.color=Lt,B.classList.remove("tvw-text-cw-muted")),Qt&&(B.style.backgroundColor=Qt,B.classList.remove("hover:tvw-bg-gray-100")),qt||na){let St=qt||"0px",ca=na||"transparent";B.style.border=`${St} solid ${ca}`,B.classList.remove("tvw-border-none")}if(Pa&&(B.style.borderRadius=Pa,B.classList.remove("tvw-rounded-full")),fa?(B.style.paddingLeft=fa,B.style.paddingRight=fa):(B.style.paddingLeft="",B.style.paddingRight=""),_a?(B.style.paddingTop=_a,B.style.paddingBottom=_a):(B.style.paddingTop="",B.style.paddingBottom=""),A.appendChild(B),Fo&&ia&&B&&A){let St=null,ca=()=>{if(St||!B)return;St=g("div","tvw-clear-chat-tooltip"),St.textContent=ia;let bo=g("div");bo.className="tvw-clear-chat-tooltip-arrow",St.appendChild(bo);let ee=B.getBoundingClientRect();St.style.position="fixed",St.style.left=`${ee.left+ee.width/2}px`,St.style.top=`${ee.top-8}px`,St.style.transform="translate(-50%, -100%)",document.body.appendChild(St)},Ra=()=>{St&&St.parentNode&&(St.parentNode.removeChild(St),St=null)};A.addEventListener("mouseenter",ca),A.addEventListener("mouseleave",Ra),B.addEventListener("focus",ca),B.addEventListener("blur",Ra),A._cleanupTooltip=()=>{Ra(),A&&(A.removeEventListener("mouseenter",ca),A.removeEventListener("mouseleave",Ra)),B&&(B.removeEventListener("focus",ca),B.removeEventListener("blur",Ra))}}a.appendChild(A)}let E=g("div",s==="top-right"?"tvw-absolute tvw-top-4 tvw-right-4 tvw-z-50":U?"":"tvw-ml-auto"),y=g("button","tvw-inline-flex tvw-items-center tvw-justify-center tvw-rounded-full tvw-text-cw-muted hover:tvw-bg-gray-100 tvw-cursor-pointer tvw-border-none");y.style.height=d,y.style.width=d,y.type="button";let yt=(v=o.closeButtonTooltipText)!=null?v:"Close chat",q=(S=o.closeButtonShowTooltip)!=null?S:!0;y.setAttribute("aria-label",yt),y.style.display=e?"":"none";let L=(w=o.closeButtonIconName)!=null?w:"x",lt=(O=o.closeButtonIconText)!=null?O:"\xD7",ct=vt(L,"20px",o.closeButtonColor||"",2);if(ct?y.appendChild(ct):y.textContent=lt,o.closeButtonColor?(y.style.color=o.closeButtonColor,y.classList.remove("tvw-text-cw-muted")):(y.style.color="",y.classList.add("tvw-text-cw-muted")),o.closeButtonBackgroundColor?(y.style.backgroundColor=o.closeButtonBackgroundColor,y.classList.remove("hover:tvw-bg-gray-100")):(y.style.backgroundColor="",y.classList.add("hover:tvw-bg-gray-100")),o.closeButtonBorderWidth||o.closeButtonBorderColor){let N=o.closeButtonBorderWidth||"0px",xt=o.closeButtonBorderColor||"transparent";y.style.border=`${N} solid ${xt}`,y.classList.remove("tvw-border-none")}else y.style.border="",y.classList.add("tvw-border-none");if(o.closeButtonBorderRadius?(y.style.borderRadius=o.closeButtonBorderRadius,y.classList.remove("tvw-rounded-full")):(y.style.borderRadius="",y.classList.add("tvw-rounded-full")),o.closeButtonPaddingX?(y.style.paddingLeft=o.closeButtonPaddingX,y.style.paddingRight=o.closeButtonPaddingX):(y.style.paddingLeft="",y.style.paddingRight=""),o.closeButtonPaddingY?(y.style.paddingTop=o.closeButtonPaddingY,y.style.paddingBottom=o.closeButtonPaddingY):(y.style.paddingTop="",y.style.paddingBottom=""),E.appendChild(y),q&&yt){let N=null,xt=()=>{if(N)return;N=g("div","tvw-clear-chat-tooltip"),N.textContent=yt;let Qt=g("div");Qt.className="tvw-clear-chat-tooltip-arrow",N.appendChild(Qt);let qt=y.getBoundingClientRect();N.style.position="fixed",N.style.left=`${qt.left+qt.width/2}px`,N.style.top=`${qt.top-8}px`,N.style.transform="translate(-50%, -100%)",document.body.appendChild(N)},Lt=()=>{N&&N.parentNode&&(N.parentNode.removeChild(N),N=null)};E.addEventListener("mouseenter",xt),E.addEventListener("mouseleave",Lt),y.addEventListener("focus",xt),y.addEventListener("blur",Lt),E._cleanupTooltip=()=>{Lt(),E.removeEventListener("mouseenter",xt),E.removeEventListener("mouseleave",Lt),y.removeEventListener("focus",xt),y.removeEventListener("blur",Lt)}}s==="top-right"?(t.style.position="relative",t.appendChild(E)):a.appendChild(E);let ut=g("div","tvw-flex tvw-flex-1 tvw-min-h-0 tvw-flex-col tvw-gap-6 tvw-overflow-y-auto tvw-bg-cw-container tvw-px-6 tvw-py-6");ut.id="vanilla-agent-scroll-container";let kt=g("div","tvw-rounded-2xl tvw-bg-cw-surface tvw-p-6 tvw-shadow-sm"),Ct=g("h2","tvw-text-lg tvw-font-semibold tvw-text-cw-primary");Ct.textContent=(u=(z=r==null?void 0:r.copy)==null?void 0:z.welcomeTitle)!=null?u:"Hello \u{1F44B}";let k=g("p","tvw-mt-2 tvw-text-sm tvw-text-cw-muted");k.textContent=(T=(b=r==null?void 0:r.copy)==null?void 0:b.welcomeSubtitle)!=null?T:"Ask anything about your account or products.",kt.append(Ct,k);let G=g("div","tvw-flex tvw-flex-col tvw-gap-3");ut.append(kt,G);let H=g("div","tvw-border-t-cw-divider tvw-bg-cw-surface tvw-px-6 tvw-py-4"),At=g("div","tvw-mb-3 tvw-flex tvw-flex-wrap tvw-gap-2"),Wt=((M=r==null?void 0:r.voiceRecognition)==null?void 0:M.enabled)===!0,jt=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined"),Rt=g("form",`tvw-flex tvw-items-end ${Wt&&jt?"tvw-gap-1":"tvw-gap-3"} tvw-rounded-2xl tvw-border tvw-border-gray-200 tvw-bg-cw-input-background tvw-px-4 tvw-py-3`);Rt.style.outline="none";let Q=g("textarea");Q.placeholder=(I=(x=r==null?void 0:r.copy)==null?void 0:x.inputPlaceholder)!=null?I:"Type your message\u2026",Q.className="tvw-min-h-[48px] tvw-flex-1 tvw-resize-none tvw-border-none tvw-bg-transparent tvw-text-sm tvw-text-cw-primary focus:tvw-outline-none focus:tvw-border-none",Q.rows=1;let da=(j=(W=r==null?void 0:r.theme)==null?void 0:W.inputFontFamily)!=null?j:"sans-serif",Na=(nt=(ot=r==null?void 0:r.theme)==null?void 0:ot.inputFontWeight)!=null?nt:"400",Kt=N=>{switch(N){case"serif":return'Georgia, "Times New Roman", Times, serif';case"mono":return'"Courier New", Courier, "Lucida Console", Monaco, monospace';case"sans-serif":default:return'-apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif'}};Q.style.fontFamily=Kt(da),Q.style.fontWeight=Na,Q.style.border="none",Q.style.outline="none",Q.style.borderWidth="0",Q.style.borderStyle="none",Q.style.borderColor="transparent",Q.addEventListener("focus",()=>{Q.style.border="none",Q.style.outline="none",Q.style.borderWidth="0",Q.style.borderStyle="none",Q.style.borderColor="transparent",Q.style.boxShadow="none"}),Q.addEventListener("blur",()=>{Q.style.border="none",Q.style.outline="none"});let rt=(ft=r==null?void 0:r.sendButton)!=null?ft:{},la=(at=rt.useIcon)!=null?at:!1,sa=(_=rt.iconText)!=null?_:"\u2191",Ga=rt.iconName,Za=(X=rt.tooltipText)!=null?X:"Send message",te=(Y=rt.showTooltip)!=null?Y:!1,$t=(Ht=rt.size)!=null?Ht:"40px",Jt=rt.backgroundColor,Mt=rt.textColor,ta=g("div","tvw-send-button-wrapper"),$=g("button",la?"tvw-rounded-button tvw-flex tvw-items-center tvw-justify-center disabled:tvw-opacity-50 tvw-cursor-pointer":"tvw-rounded-button tvw-bg-cw-accent tvw-px-4 tvw-py-2 tvw-text-sm tvw-font-semibold disabled:tvw-opacity-50 tvw-cursor-pointer");if($.type="submit",la){if($.style.width=$t,$.style.height=$t,$.style.minWidth=$t,$.style.minHeight=$t,$.style.fontSize="18px",$.style.lineHeight="1",$.innerHTML="",Ga){let N=parseFloat($t)||24,xt=Mt&&typeof Mt=="string"&&Mt.trim()?Mt.trim():"currentColor",Lt=vt(Ga,N,xt,2);Lt?($.appendChild(Lt),$.style.color=xt):($.textContent=sa,Mt?$.style.color=Mt:$.classList.add("tvw-text-white"))}else $.textContent=sa,Mt?$.style.color=Mt:$.classList.add("tvw-text-white");Jt?$.style.backgroundColor=Jt:$.classList.add("tvw-bg-cw-primary")}else $.textContent=(ea=(J=r==null?void 0:r.copy)==null?void 0:J.sendButtonLabel)!=null?ea:"Send",Mt?$.style.color=Mt:$.classList.add("tvw-text-white");if(rt.borderWidth&&($.style.borderWidth=rt.borderWidth,$.style.borderStyle="solid"),rt.borderColor&&($.style.borderColor=rt.borderColor),rt.paddingX?($.style.paddingLeft=rt.paddingX,$.style.paddingRight=rt.paddingX):($.style.paddingLeft="",$.style.paddingRight=""),rt.paddingY?($.style.paddingTop=rt.paddingY,$.style.paddingBottom=rt.paddingY):($.style.paddingTop="",$.style.paddingBottom=""),te&&Za){let N=g("div","tvw-send-button-tooltip");N.textContent=Za,ta.appendChild(N)}ta.appendChild($);let ht=(xo=r==null?void 0:r.voiceRecognition)!=null?xo:{},pa=ht.enabled===!0,Z=null,zt=null,$a=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined");if(pa&&$a){zt=g("div","tvw-send-button-wrapper"),Z=g("button","tvw-rounded-button tvw-flex tvw-items-center tvw-justify-center disabled:tvw-opacity-50 tvw-cursor-pointer"),Z.type="button",Z.setAttribute("aria-label","Start voice recognition");let N=(mo=ht.iconName)!=null?mo:"mic",xt=(Mo=ht.iconSize)!=null?Mo:$t,Lt=parseFloat(xt)||24,Qt=(go=ht.backgroundColor)!=null?go:Jt,qt=(vo=ht.iconColor)!=null?vo:Mt;Z.style.width=xt,Z.style.height=xt,Z.style.minWidth=xt,Z.style.minHeight=xt,Z.style.fontSize="18px",Z.style.lineHeight="1";let na=qt||"currentColor",Pa=vt(N,Lt,na,1.5);Pa?(Z.appendChild(Pa),Z.style.color=na):(Z.textContent="\u{1F3A4}",Z.style.color=na),Qt?Z.style.backgroundColor=Qt:Z.classList.add("tvw-bg-cw-primary"),qt?Z.style.color=qt:!qt&&!Mt&&Z.classList.add("tvw-text-white"),ht.borderWidth&&(Z.style.borderWidth=ht.borderWidth,Z.style.borderStyle="solid"),ht.borderColor&&(Z.style.borderColor=ht.borderColor),ht.paddingX&&(Z.style.paddingLeft=ht.paddingX,Z.style.paddingRight=ht.paddingX),ht.paddingY&&(Z.style.paddingTop=ht.paddingY,Z.style.paddingBottom=ht.paddingY),zt.appendChild(Z);let fa=(yo=ht.tooltipText)!=null?yo:"Start voice recognition";if(((wo=ht.showTooltip)!=null?wo:!1)&&fa){let ia=g("div","tvw-send-button-tooltip");ia.textContent=fa,zt.appendChild(ia)}}Rt.addEventListener("click",N=>{N.target!==$&&N.target!==ta&&N.target!==Z&&N.target!==zt&&Q.focus()}),Rt.append(Q),zt&&Rt.append(zt),Rt.append(ta);let aa=g("div","tvw-mt-2 tvw-text-right tvw-text-xs tvw-text-cw-muted"),Ma=(Co=r==null?void 0:r.statusIndicator)!=null?Co:{},bt=(So=Ma.visible)!=null?So:!0;return aa.style.display=bt?"":"none",aa.textContent=(Ao=Ma.idleText)!=null?Ao:"Online",H.append(At,Rt,aa),t.append(a,ut,H),{container:t,body:ut,messagesWrapper:G,suggestions:At,textarea:Q,sendButton:$,sendButtonWrapper:ta,micButton:Z,micButtonWrapper:zt,composerForm:Rt,statusText:aa,introTitle:Ct,introSubtitle:k,closeButton:y,closeButtonWrapper:E,clearChatButton:B,clearChatButtonWrapper:A,iconHolder:h}};var wS=()=>{let r=document.createElement("div");r.className="tvw-flex tvw-items-center tvw-space-x-1 tvw-h-5 tvw-mt-2";let e=document.createElement("div");e.className="tvw-bg-cw-primary tvw-animate-typing tvw-rounded-full tvw-h-1.5 tvw-w-1.5",e.style.animationDelay="0ms";let t=document.createElement("div");t.className="tvw-bg-cw-primary tvw-animate-typing tvw-rounded-full tvw-h-1.5 tvw-w-1.5",t.style.animationDelay="250ms";let a=document.createElement("div");a.className="tvw-bg-cw-primary tvw-animate-typing tvw-rounded-full tvw-h-1.5 tvw-w-1.5",a.style.animationDelay="500ms";let o=document.createElement("span");return o.className="tvw-sr-only",o.textContent="Loading",r.appendChild(e),r.appendChild(t),r.appendChild(a),r.appendChild(o),r},CS=(r,e)=>{let t=["tvw-max-w-[85%]","tvw-rounded-2xl","tvw-text-sm","tvw-leading-relaxed","tvw-shadow-sm"];r.role==="user"?t.push("tvw-ml-auto","tvw-bg-cw-accent","tvw-text-white","tvw-px-5","tvw-py-3"):t.push("tvw-bg-cw-surface","tvw-border","tvw-border-cw-message-border","tvw-text-cw-primary","tvw-px-5","tvw-py-3");let a=g("div",t.join(" ")),o=document.createElement("div");if(o.innerHTML=e({text:r.content,message:r,streaming:!!r.streaming}),a.appendChild(o),r.streaming&&r.role==="assistant"&&(!r.content||!r.content.trim())){let l=wS();a.appendChild(l)}return a};var SS=new Set,AS=r=>{let e=r.reasoning,t=g("div",["tvw-w-full","tvw-max-w-[85%]","tvw-rounded-2xl","tvw-bg-cw-surface","tvw-border","tvw-border-cw-message-border","tvw-text-cw-primary","tvw-shadow-sm","tvw-overflow-hidden","tvw-px-0","tvw-py-0"].join(" "));if(!e)return t;let a=SS.has(r.id),o=g("button","tvw-flex tvw-w-full tvw-items-center tvw-justify-between tvw-gap-3 tvw-bg-transparent tvw-px-4 tvw-py-3 tvw-text-left tvw-cursor-pointer tvw-border-none");o.type="button",o.setAttribute("aria-expanded",a?"true":"false");let l=g("div","tvw-flex tvw-flex-col tvw-text-left"),d=g("span","tvw-text-xs tvw-text-cw-primary");d.textContent="Thinking...",l.appendChild(d);let s=g("span","tvw-text-xs tvw-text-cw-primary");s.textContent=AA(e),l.appendChild(s),e.status==="complete"?d.style.display="none":d.style.display="";let p=g("div","tvw-flex tvw-items-center"),h=vt(a?"chevron-up":"chevron-down",16,"currentColor",2);h?p.appendChild(h):p.textContent=a?"Hide":"Show";let m=g("div","tvw-flex tvw-items-center tvw-ml-auto");m.append(p),o.append(l,m);let f=g("div","tvw-border-t tvw-border-gray-200 tvw-bg-gray-50 tvw-px-4 tvw-py-3");f.style.display=a?"":"none";let C=e.chunks.join(""),D=g("div","tvw-whitespace-pre-wrap tvw-text-xs tvw-leading-snug tvw-text-cw-muted");D.textContent=C||(e.status==="complete"?"No additional context was shared.":"Waiting for details\u2026"),f.appendChild(D);let U=()=>{o.setAttribute("aria-expanded",a?"true":"false"),p.innerHTML="";let E=vt(a?"chevron-up":"chevron-down",16,"currentColor",2);E?p.appendChild(E):p.textContent=a?"Hide":"Show",f.style.display=a?"":"none"},B=()=>{a=!a,a?SS.add(r.id):SS.delete(r.id),U()};return o.addEventListener("pointerdown",A=>{A.preventDefault(),B()}),o.addEventListener("keydown",A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),B())}),U(),t.append(o,f),t};var kS=new Set,bS=(r,e)=>{var B;let t=r.toolCall,a=(B=e==null?void 0:e.toolCall)!=null?B:{},o=g("div",["tvw-w-full","tvw-max-w-[85%]","tvw-rounded-2xl","tvw-bg-cw-surface","tvw-border","tvw-border-cw-message-border","tvw-text-cw-primary","tvw-shadow-sm","tvw-overflow-hidden","tvw-px-0","tvw-py-0"].join(" "));if(a.backgroundColor&&(o.style.backgroundColor=a.backgroundColor),a.borderColor&&(o.style.borderColor=a.borderColor),a.borderWidth&&(o.style.borderWidth=a.borderWidth),a.borderRadius&&(o.style.borderRadius=a.borderRadius),!t)return o;let l=kS.has(r.id),d=g("button","tvw-flex tvw-w-full tvw-items-center tvw-justify-between tvw-gap-3 tvw-bg-transparent tvw-px-4 tvw-py-3 tvw-text-left tvw-cursor-pointer tvw-border-none");d.type="button",d.setAttribute("aria-expanded",l?"true":"false"),a.headerBackgroundColor&&(d.style.backgroundColor=a.headerBackgroundColor),a.headerPaddingX&&(d.style.paddingLeft=a.headerPaddingX,d.style.paddingRight=a.headerPaddingX),a.headerPaddingY&&(d.style.paddingTop=a.headerPaddingY,d.style.paddingBottom=a.headerPaddingY);let s=g("div","tvw-flex tvw-flex-col tvw-text-left"),p=g("span","tvw-text-xs tvw-text-cw-primary");a.headerTextColor&&(p.style.color=a.headerTextColor),p.textContent=kA(t),s.appendChild(p);let c=g("div","tvw-flex tvw-items-center"),h=a.toggleTextColor||a.headerTextColor||"currentColor",m=vt(l?"chevron-up":"chevron-down",16,h,2);m?c.appendChild(m):c.textContent=l?"Hide":"Show";let f=g("div","tvw-flex tvw-items-center tvw-gap-2 tvw-ml-auto");f.append(c),d.append(s,f);let C=g("div","tvw-border-t tvw-border-gray-200 tvw-bg-gray-50 tvw-space-y-3 tvw-px-4 tvw-py-3");if(C.style.display=l?"":"none",a.contentBackgroundColor&&(C.style.backgroundColor=a.contentBackgroundColor),a.contentTextColor&&(C.style.color=a.contentTextColor),a.contentPaddingX&&(C.style.paddingLeft=a.contentPaddingX,C.style.paddingRight=a.contentPaddingX),a.contentPaddingY&&(C.style.paddingTop=a.contentPaddingY,C.style.paddingBottom=a.contentPaddingY),t.name){let A=g("div","tvw-text-xs tvw-text-cw-muted tvw-italic");a.contentTextColor?A.style.color=a.contentTextColor:a.headerTextColor&&(A.style.color=a.headerTextColor),A.textContent=t.name,C.appendChild(A)}if(t.args!==void 0){let A=g("div","tvw-space-y-1"),E=g("div","tvw-text-xs tvw-text-cw-muted");a.labelTextColor&&(E.style.color=a.labelTextColor),E.textContent="Arguments";let y=g("pre","tvw-max-h-48 tvw-overflow-auto tvw-whitespace-pre-wrap tvw-rounded-lg tvw-border tvw-border-gray-100 tvw-bg-white tvw-px-3 tvw-py-2 tvw-text-xs tvw-text-cw-primary");y.style.fontSize="0.75rem",y.style.lineHeight="1rem",a.codeBlockBackgroundColor&&(y.style.backgroundColor=a.codeBlockBackgroundColor),a.codeBlockBorderColor&&(y.style.borderColor=a.codeBlockBorderColor),a.codeBlockTextColor&&(y.style.color=a.codeBlockTextColor),y.textContent=xS(t.args),A.append(E,y),C.appendChild(A)}if(t.chunks&&t.chunks.length){let A=g("div","tvw-space-y-1"),E=g("div","tvw-text-xs tvw-text-cw-muted");a.labelTextColor&&(E.style.color=a.labelTextColor),E.textContent="Activity";let y=g("pre","tvw-max-h-48 tvw-overflow-auto tvw-whitespace-pre-wrap tvw-rounded-lg tvw-border tvw-border-gray-100 tvw-bg-white tvw-px-3 tvw-py-2 tvw-text-xs tvw-text-cw-primary");y.style.fontSize="0.75rem",y.style.lineHeight="1rem",a.codeBlockBackgroundColor&&(y.style.backgroundColor=a.codeBlockBackgroundColor),a.codeBlockBorderColor&&(y.style.borderColor=a.codeBlockBorderColor),a.codeBlockTextColor&&(y.style.color=a.codeBlockTextColor),y.textContent=t.chunks.join(`
|
|
63
|
+
`,t.addEventListener("click",e);let a=l=>{var U,B,A,E,y,yt,q,L,lt,ct;let d=(U=l.launcher)!=null?U:{},s=t.querySelector("[data-role='launcher-title']");s&&(s.textContent=(B=d.title)!=null?B:"Chat Assistant");let p=t.querySelector("[data-role='launcher-subtitle']");p&&(p.textContent=(A=d.subtitle)!=null?A:"Get answers fast");let c=t.querySelector(".tvw-flex-col");c&&(d.textHidden?c.style.display="none":c.style.display="");let h=t.querySelector("[data-role='launcher-icon']");if(h)if(d.agentIconHidden)h.style.display="none";else{let ut=(E=d.agentIconSize)!=null?E:"40px";if(h.style.height=ut,h.style.width=ut,h.innerHTML="",d.agentIconName){let kt=parseFloat(ut)||24,Ct=vt(d.agentIconName,kt*.6,"#ffffff",2);Ct?(h.appendChild(Ct),h.style.display=""):(h.textContent=(y=d.agentIconText)!=null?y:"\u{1F4AC}",h.style.display="")}else d.iconUrl?h.style.display="none":(h.textContent=(yt=d.agentIconText)!=null?yt:"\u{1F4AC}",h.style.display="")}let m=t.querySelector("[data-role='launcher-image']");if(m){let ut=(q=d.agentIconSize)!=null?q:"40px";m.style.height=ut,m.style.width=ut,d.iconUrl&&!d.agentIconName&&!d.agentIconHidden?(m.src=d.iconUrl,m.style.display="block"):m.style.display="none"}let f=t.querySelector("[data-role='launcher-call-to-action-icon']");if(f){let ut=(L=d.callToActionIconSize)!=null?L:"32px";f.style.height=ut,f.style.width=ut,d.callToActionIconBackgroundColor?(f.style.backgroundColor=d.callToActionIconBackgroundColor,f.classList.remove("tvw-bg-cw-primary")):(f.style.backgroundColor="",f.classList.add("tvw-bg-cw-primary"));let kt=0;if(d.callToActionIconPadding?(f.style.boxSizing="border-box",f.style.padding=d.callToActionIconPadding,kt=(parseFloat(d.callToActionIconPadding)||0)*2):(f.style.boxSizing="",f.style.padding=""),d.callToActionIconHidden)f.style.display="none";else if(f.style.display="",f.innerHTML="",d.callToActionIconName){let Ct=parseFloat(ut)||24,k=Math.max(Ct-kt,8),G=vt(d.callToActionIconName,k,"currentColor",2);G?f.appendChild(G):f.textContent=(lt=d.callToActionIconText)!=null?lt:"\u2197"}else f.textContent=(ct=d.callToActionIconText)!=null?ct:"\u2197"}let C=d.position&&Ua[d.position]?Ua[d.position]:Ua["bottom-right"],D="tvw-fixed tvw-flex tvw-items-center tvw-gap-3 tvw-rounded-launcher tvw-bg-cw-surface tvw-py-2.5 tvw-pl-3 tvw-pr-3 tvw-shadow-lg tvw-border tvw-border-gray-200 tvw-transition hover:tvw-translate-y-[-2px] tvw-cursor-pointer tvw-z-50";t.className=`${D} ${C}`},o=()=>{t.removeEventListener("click",e),t.remove()};return r&&a(r),{element:t,update:a,destroy:o}};var BA=r=>{var p,c,h,m,f;if(!((c=(p=r==null?void 0:r.launcher)==null?void 0:p.enabled)!=null?c:!0)){let C=g("div","tvw-relative tvw-w-full tvw-h-full"),D=g("div","tvw-relative tvw-w-full tvw-h-full tvw-min-h-[360px]");return C.appendChild(D),{wrapper:C,panel:D}}let t=(h=r==null?void 0:r.launcher)!=null?h:{},a=t.position&&Ua[t.position]?Ua[t.position]:Ua["bottom-right"],o=g("div",`tvw-fixed ${a} tvw-z-50 tvw-transition`),l=g("div","tvw-relative tvw-min-h-[320px]"),d=(f=(m=r==null?void 0:r.launcher)==null?void 0:m.width)!=null?f:r==null?void 0:r.launcherWidth,s=d!=null?d:"min(400px, calc(100vw - 24px))";return l.style.width=s,l.style.maxWidth=s,o.appendChild(l),{wrapper:o,panel:l}},PA=(r,e=!0)=>{var Bt,Xt,Ut,ga,va,Et,Xa,ha,ya,st,Yt,wa,Ca,ae,Sa,Aa,ka,ba,Ha,La,Ta,Va,Ba,n,P,i,R,v,S,w,O,z,u,b,T,M,x,I,W,j,ot,nt,ft,at,_,X,Y,Ht,J,ea,xo,mo,Mo,go,vo,yo,wo,Co,So,Ao;let t=g("div","tvw-flex tvw-h-full tvw-w-full tvw-flex-col tvw-bg-cw-surface tvw-text-cw-primary tvw-rounded-2xl tvw-overflow-hidden tvw-shadow-2xl tvw-border tvw-border-cw-border"),a=g("div","tvw-flex tvw-items-center tvw-gap-3 tvw-bg-cw-surface tvw-px-6 tvw-py-5 tvw-border-b-cw-divider"),o=(Bt=r==null?void 0:r.launcher)!=null?Bt:{},l=(Xt=o.headerIconSize)!=null?Xt:"48px",d=(Ut=o.closeButtonSize)!=null?Ut:"32px",s=(ga=o.closeButtonPlacement)!=null?ga:"inline",p=(va=o.headerIconHidden)!=null?va:!1,c=o.headerIconName,h=g("div","tvw-flex tvw-items-center tvw-justify-center tvw-rounded-xl tvw-bg-cw-primary tvw-text-white tvw-text-xl");if(h.style.height=l,h.style.width=l,!p)if(c){let N=parseFloat(l)||24,xt=vt(c,N*.6,"#ffffff",2);xt?h.replaceChildren(xt):h.textContent=(Xa=(Et=r==null?void 0:r.launcher)==null?void 0:Et.agentIconText)!=null?Xa:"\u{1F4AC}"}else if((ha=r==null?void 0:r.launcher)!=null&&ha.iconUrl){let N=g("img");N.src=r.launcher.iconUrl,N.alt="",N.className="tvw-rounded-xl tvw-object-cover",N.style.height=l,N.style.width=l,h.replaceChildren(N)}else h.textContent=(st=(ya=r==null?void 0:r.launcher)==null?void 0:ya.agentIconText)!=null?st:"\u{1F4AC}";let m=g("div","tvw-flex tvw-flex-col"),f=g("span","tvw-text-base tvw-font-semibold");f.textContent=(wa=(Yt=r==null?void 0:r.launcher)==null?void 0:Yt.title)!=null?wa:"Chat Assistant";let C=g("span","tvw-text-xs tvw-text-cw-muted");C.textContent=(ae=(Ca=r==null?void 0:r.launcher)==null?void 0:Ca.subtitle)!=null?ae:"Here to help you get answers fast",m.append(f,C),p?a.append(m):a.append(h,m);let D=(Sa=o.clearChat)!=null?Sa:{},U=(Aa=D.enabled)!=null?Aa:!0,B=null,A=null;if(U){let N=(ka=D.size)!=null?ka:"32px",xt=(ba=D.iconName)!=null?ba:"refresh-cw",Lt=(Ha=D.iconColor)!=null?Ha:"",Qt=(La=D.backgroundColor)!=null?La:"",qt=(Ta=D.borderWidth)!=null?Ta:"",na=(Va=D.borderColor)!=null?Va:"",Pa=(Ba=D.borderRadius)!=null?Ba:"",fa=(n=D.paddingX)!=null?n:"",_a=(P=D.paddingY)!=null?P:"",ia=(i=D.tooltipText)!=null?i:"Clear chat",Fo=(R=D.showTooltip)!=null?R:!0;A=g("div","tvw-relative tvw-ml-auto tvw-clear-chat-button-wrapper"),B=g("button","tvw-inline-flex tvw-items-center tvw-justify-center tvw-rounded-full tvw-text-cw-muted hover:tvw-bg-gray-100 tvw-cursor-pointer tvw-border-none"),B.style.height=N,B.style.width=N,B.type="button",B.setAttribute("aria-label",ia);let ko=vt(xt,"20px",Lt||"",2);if(ko&&B.appendChild(ko),Lt&&(B.style.color=Lt,B.classList.remove("tvw-text-cw-muted")),Qt&&(B.style.backgroundColor=Qt,B.classList.remove("hover:tvw-bg-gray-100")),qt||na){let St=qt||"0px",ca=na||"transparent";B.style.border=`${St} solid ${ca}`,B.classList.remove("tvw-border-none")}if(Pa&&(B.style.borderRadius=Pa,B.classList.remove("tvw-rounded-full")),fa?(B.style.paddingLeft=fa,B.style.paddingRight=fa):(B.style.paddingLeft="",B.style.paddingRight=""),_a?(B.style.paddingTop=_a,B.style.paddingBottom=_a):(B.style.paddingTop="",B.style.paddingBottom=""),A.appendChild(B),Fo&&ia&&B&&A){let St=null,ca=()=>{if(St||!B)return;St=g("div","tvw-clear-chat-tooltip"),St.textContent=ia;let bo=g("div");bo.className="tvw-clear-chat-tooltip-arrow",St.appendChild(bo);let ee=B.getBoundingClientRect();St.style.position="fixed",St.style.left=`${ee.left+ee.width/2}px`,St.style.top=`${ee.top-8}px`,St.style.transform="translate(-50%, -100%)",document.body.appendChild(St)},Ra=()=>{St&&St.parentNode&&(St.parentNode.removeChild(St),St=null)};A.addEventListener("mouseenter",ca),A.addEventListener("mouseleave",Ra),B.addEventListener("focus",ca),B.addEventListener("blur",Ra),A._cleanupTooltip=()=>{Ra(),A&&(A.removeEventListener("mouseenter",ca),A.removeEventListener("mouseleave",Ra)),B&&(B.removeEventListener("focus",ca),B.removeEventListener("blur",Ra))}}a.appendChild(A)}let E=g("div",s==="top-right"?"tvw-absolute tvw-top-4 tvw-right-4 tvw-z-50":U?"":"tvw-ml-auto"),y=g("button","tvw-inline-flex tvw-items-center tvw-justify-center tvw-rounded-full tvw-text-cw-muted hover:tvw-bg-gray-100 tvw-cursor-pointer tvw-border-none");y.style.height=d,y.style.width=d,y.type="button";let yt=(v=o.closeButtonTooltipText)!=null?v:"Close chat",q=(S=o.closeButtonShowTooltip)!=null?S:!0;y.setAttribute("aria-label",yt),y.style.display=e?"":"none";let L=(w=o.closeButtonIconName)!=null?w:"x",lt=(O=o.closeButtonIconText)!=null?O:"\xD7",ct=vt(L,"20px",o.closeButtonColor||"",2);if(ct?y.appendChild(ct):y.textContent=lt,o.closeButtonColor?(y.style.color=o.closeButtonColor,y.classList.remove("tvw-text-cw-muted")):(y.style.color="",y.classList.add("tvw-text-cw-muted")),o.closeButtonBackgroundColor?(y.style.backgroundColor=o.closeButtonBackgroundColor,y.classList.remove("hover:tvw-bg-gray-100")):(y.style.backgroundColor="",y.classList.add("hover:tvw-bg-gray-100")),o.closeButtonBorderWidth||o.closeButtonBorderColor){let N=o.closeButtonBorderWidth||"0px",xt=o.closeButtonBorderColor||"transparent";y.style.border=`${N} solid ${xt}`,y.classList.remove("tvw-border-none")}else y.style.border="",y.classList.add("tvw-border-none");if(o.closeButtonBorderRadius?(y.style.borderRadius=o.closeButtonBorderRadius,y.classList.remove("tvw-rounded-full")):(y.style.borderRadius="",y.classList.add("tvw-rounded-full")),o.closeButtonPaddingX?(y.style.paddingLeft=o.closeButtonPaddingX,y.style.paddingRight=o.closeButtonPaddingX):(y.style.paddingLeft="",y.style.paddingRight=""),o.closeButtonPaddingY?(y.style.paddingTop=o.closeButtonPaddingY,y.style.paddingBottom=o.closeButtonPaddingY):(y.style.paddingTop="",y.style.paddingBottom=""),E.appendChild(y),q&&yt){let N=null,xt=()=>{if(N)return;N=g("div","tvw-clear-chat-tooltip"),N.textContent=yt;let Qt=g("div");Qt.className="tvw-clear-chat-tooltip-arrow",N.appendChild(Qt);let qt=y.getBoundingClientRect();N.style.position="fixed",N.style.left=`${qt.left+qt.width/2}px`,N.style.top=`${qt.top-8}px`,N.style.transform="translate(-50%, -100%)",document.body.appendChild(N)},Lt=()=>{N&&N.parentNode&&(N.parentNode.removeChild(N),N=null)};E.addEventListener("mouseenter",xt),E.addEventListener("mouseleave",Lt),y.addEventListener("focus",xt),y.addEventListener("blur",Lt),E._cleanupTooltip=()=>{Lt(),E.removeEventListener("mouseenter",xt),E.removeEventListener("mouseleave",Lt),y.removeEventListener("focus",xt),y.removeEventListener("blur",Lt)}}s==="top-right"?(t.style.position="relative",t.appendChild(E)):a.appendChild(E);let ut=g("div","tvw-flex tvw-flex-1 tvw-min-h-0 tvw-flex-col tvw-gap-6 tvw-overflow-y-auto tvw-bg-cw-container tvw-px-6 tvw-py-6");ut.id="vanilla-agent-scroll-container";let kt=g("div","tvw-rounded-2xl tvw-bg-cw-surface tvw-p-6 tvw-shadow-sm"),Ct=g("h2","tvw-text-lg tvw-font-semibold tvw-text-cw-primary");Ct.textContent=(u=(z=r==null?void 0:r.copy)==null?void 0:z.welcomeTitle)!=null?u:"Hello \u{1F44B}";let k=g("p","tvw-mt-2 tvw-text-sm tvw-text-cw-muted");k.textContent=(T=(b=r==null?void 0:r.copy)==null?void 0:b.welcomeSubtitle)!=null?T:"Ask anything about your account or products.",kt.append(Ct,k);let G=g("div","tvw-flex tvw-flex-col tvw-gap-3");ut.append(kt,G);let H=g("div","tvw-border-t-cw-divider tvw-bg-cw-surface tvw-px-6 tvw-py-4"),At=g("div","tvw-mb-3 tvw-flex tvw-flex-wrap tvw-gap-2"),Wt=((M=r==null?void 0:r.voiceRecognition)==null?void 0:M.enabled)===!0,jt=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined"),Rt=g("form",`tvw-flex tvw-items-end ${Wt&&jt?"tvw-gap-1":"tvw-gap-3"} tvw-rounded-2xl tvw-border tvw-border-gray-200 tvw-bg-cw-input-background tvw-px-4 tvw-py-3`);Rt.style.outline="none";let Q=g("textarea");Q.placeholder=(I=(x=r==null?void 0:r.copy)==null?void 0:x.inputPlaceholder)!=null?I:"Type your message\u2026",Q.className="tvw-min-h-[48px] tvw-flex-1 tvw-resize-none tvw-border-none tvw-bg-transparent tvw-text-sm tvw-text-cw-primary focus:tvw-outline-none focus:tvw-border-none",Q.rows=1;let da=(j=(W=r==null?void 0:r.theme)==null?void 0:W.inputFontFamily)!=null?j:"sans-serif",Na=(nt=(ot=r==null?void 0:r.theme)==null?void 0:ot.inputFontWeight)!=null?nt:"400",Kt=N=>{switch(N){case"serif":return'Georgia, "Times New Roman", Times, serif';case"mono":return'"Courier New", Courier, "Lucida Console", Monaco, monospace';case"sans-serif":default:return'-apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif'}};Q.style.fontFamily=Kt(da),Q.style.fontWeight=Na,Q.style.border="none",Q.style.outline="none",Q.style.borderWidth="0",Q.style.borderStyle="none",Q.style.borderColor="transparent",Q.addEventListener("focus",()=>{Q.style.border="none",Q.style.outline="none",Q.style.borderWidth="0",Q.style.borderStyle="none",Q.style.borderColor="transparent",Q.style.boxShadow="none"}),Q.addEventListener("blur",()=>{Q.style.border="none",Q.style.outline="none"});let rt=(ft=r==null?void 0:r.sendButton)!=null?ft:{},la=(at=rt.useIcon)!=null?at:!1,sa=(_=rt.iconText)!=null?_:"\u2191",Ga=rt.iconName,Za=(X=rt.tooltipText)!=null?X:"Send message",te=(Y=rt.showTooltip)!=null?Y:!1,$t=(Ht=rt.size)!=null?Ht:"40px",Jt=rt.backgroundColor,Mt=rt.textColor,ta=g("div","tvw-send-button-wrapper"),$=g("button",la?"tvw-rounded-button tvw-flex tvw-items-center tvw-justify-center disabled:tvw-opacity-50 tvw-cursor-pointer":"tvw-rounded-button tvw-bg-cw-accent tvw-px-4 tvw-py-2 tvw-text-sm tvw-font-semibold disabled:tvw-opacity-50 tvw-cursor-pointer");if($.type="submit",la){if($.style.width=$t,$.style.height=$t,$.style.minWidth=$t,$.style.minHeight=$t,$.style.fontSize="18px",$.style.lineHeight="1",$.innerHTML="",Ga){let N=parseFloat($t)||24,xt=Mt&&typeof Mt=="string"&&Mt.trim()?Mt.trim():"currentColor",Lt=vt(Ga,N,xt,2);Lt?($.appendChild(Lt),$.style.color=xt):($.textContent=sa,Mt?$.style.color=Mt:$.classList.add("tvw-text-white"))}else $.textContent=sa,Mt?$.style.color=Mt:$.classList.add("tvw-text-white");Jt?$.style.backgroundColor=Jt:$.classList.add("tvw-bg-cw-primary")}else $.textContent=(ea=(J=r==null?void 0:r.copy)==null?void 0:J.sendButtonLabel)!=null?ea:"Send",Mt?$.style.color=Mt:$.classList.add("tvw-text-white");if(rt.borderWidth&&($.style.borderWidth=rt.borderWidth,$.style.borderStyle="solid"),rt.borderColor&&($.style.borderColor=rt.borderColor),rt.paddingX?($.style.paddingLeft=rt.paddingX,$.style.paddingRight=rt.paddingX):($.style.paddingLeft="",$.style.paddingRight=""),rt.paddingY?($.style.paddingTop=rt.paddingY,$.style.paddingBottom=rt.paddingY):($.style.paddingTop="",$.style.paddingBottom=""),te&&Za){let N=g("div","tvw-send-button-tooltip");N.textContent=Za,ta.appendChild(N)}ta.appendChild($);let ht=(xo=r==null?void 0:r.voiceRecognition)!=null?xo:{},pa=ht.enabled===!0,Z=null,zt=null,$a=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined");if(pa&&$a){zt=g("div","tvw-send-button-wrapper"),Z=g("button","tvw-rounded-button tvw-flex tvw-items-center tvw-justify-center disabled:tvw-opacity-50 tvw-cursor-pointer"),Z.type="button",Z.setAttribute("aria-label","Start voice recognition");let N=(mo=ht.iconName)!=null?mo:"mic",xt=(Mo=ht.iconSize)!=null?Mo:$t,Lt=parseFloat(xt)||24,Qt=(go=ht.backgroundColor)!=null?go:Jt,qt=(vo=ht.iconColor)!=null?vo:Mt;Z.style.width=xt,Z.style.height=xt,Z.style.minWidth=xt,Z.style.minHeight=xt,Z.style.fontSize="18px",Z.style.lineHeight="1";let na=qt||"currentColor",Pa=vt(N,Lt,na,1.5);Pa?(Z.appendChild(Pa),Z.style.color=na):(Z.textContent="\u{1F3A4}",Z.style.color=na),Qt?Z.style.backgroundColor=Qt:Z.classList.add("tvw-bg-cw-primary"),qt?Z.style.color=qt:!qt&&!Mt&&Z.classList.add("tvw-text-white"),ht.borderWidth&&(Z.style.borderWidth=ht.borderWidth,Z.style.borderStyle="solid"),ht.borderColor&&(Z.style.borderColor=ht.borderColor),ht.paddingX&&(Z.style.paddingLeft=ht.paddingX,Z.style.paddingRight=ht.paddingX),ht.paddingY&&(Z.style.paddingTop=ht.paddingY,Z.style.paddingBottom=ht.paddingY),zt.appendChild(Z);let fa=(yo=ht.tooltipText)!=null?yo:"Start voice recognition";if(((wo=ht.showTooltip)!=null?wo:!1)&&fa){let ia=g("div","tvw-send-button-tooltip");ia.textContent=fa,zt.appendChild(ia)}}Rt.addEventListener("click",N=>{N.target!==$&&N.target!==ta&&N.target!==Z&&N.target!==zt&&Q.focus()}),Rt.append(Q),zt&&Rt.append(zt),Rt.append(ta);let aa=g("div","tvw-mt-2 tvw-text-right tvw-text-xs tvw-text-cw-muted"),Ma=(Co=r==null?void 0:r.statusIndicator)!=null?Co:{},bt=(So=Ma.visible)!=null?So:!0;return aa.style.display=bt?"":"none",aa.textContent=(Ao=Ma.idleText)!=null?Ao:"Online",H.append(At,Rt,aa),t.append(a,ut,H),{container:t,body:ut,messagesWrapper:G,suggestions:At,textarea:Q,sendButton:$,sendButtonWrapper:ta,micButton:Z,micButtonWrapper:zt,composerForm:Rt,statusText:aa,introTitle:Ct,introSubtitle:k,closeButton:y,closeButtonWrapper:E,clearChatButton:B,clearChatButtonWrapper:A,iconHolder:h}};var wS=()=>{let r=document.createElement("div");r.className="tvw-flex tvw-items-center tvw-space-x-1 tvw-h-5 tvw-mt-2";let e=document.createElement("div");e.className="tvw-bg-cw-primary tvw-animate-typing tvw-rounded-full tvw-h-1.5 tvw-w-1.5",e.style.animationDelay="0ms";let t=document.createElement("div");t.className="tvw-bg-cw-primary tvw-animate-typing tvw-rounded-full tvw-h-1.5 tvw-w-1.5",t.style.animationDelay="250ms";let a=document.createElement("div");a.className="tvw-bg-cw-primary tvw-animate-typing tvw-rounded-full tvw-h-1.5 tvw-w-1.5",a.style.animationDelay="500ms";let o=document.createElement("span");return o.className="tvw-sr-only",o.textContent="Loading",r.appendChild(e),r.appendChild(t),r.appendChild(a),r.appendChild(o),r},CS=(r,e)=>{let t=["tvw-max-w-[85%]","tvw-rounded-2xl","tvw-text-sm","tvw-leading-relaxed","tvw-shadow-sm"];r.role==="user"?t.push("tvw-ml-auto","tvw-bg-cw-accent","tvw-text-white","tvw-px-5","tvw-py-3"):t.push("tvw-bg-cw-surface","tvw-border","tvw-border-cw-message-border","tvw-text-cw-primary","tvw-px-5","tvw-py-3");let a=g("div",t.join(" ")),o=document.createElement("div");if(o.innerHTML=e({text:r.content,message:r,streaming:!!r.streaming}),a.appendChild(o),r.streaming&&r.role==="assistant"&&(!r.content||!r.content.trim())){let l=wS();a.appendChild(l)}return a};var SS=new Set,AS=r=>{let e=r.reasoning,t=g("div",["tvw-w-full","tvw-max-w-[85%]","tvw-rounded-2xl","tvw-bg-cw-surface","tvw-border","tvw-border-cw-message-border","tvw-text-cw-primary","tvw-shadow-sm","tvw-overflow-hidden","tvw-px-0","tvw-py-0"].join(" "));if(!e)return t;let a=SS.has(r.id),o=g("button","tvw-flex tvw-w-full tvw-items-center tvw-justify-between tvw-gap-3 tvw-bg-transparent tvw-px-4 tvw-py-3 tvw-text-left tvw-cursor-pointer tvw-border-none");o.type="button",o.setAttribute("aria-expanded",a?"true":"false");let l=g("div","tvw-flex tvw-flex-col tvw-text-left"),d=g("span","tvw-text-xs tvw-text-cw-primary");d.textContent="Thinking...",l.appendChild(d);let s=g("span","tvw-text-xs tvw-text-cw-primary");s.textContent=AA(e),l.appendChild(s),e.status==="complete"?d.style.display="none":d.style.display="";let p=g("div","tvw-flex tvw-items-center"),h=vt(a?"chevron-up":"chevron-down",16,"currentColor",2);h?p.appendChild(h):p.textContent=a?"Hide":"Show";let m=g("div","tvw-flex tvw-items-center tvw-ml-auto");m.append(p),o.append(l,m);let f=g("div","tvw-border-t tvw-border-gray-200 tvw-bg-gray-50 tvw-px-4 tvw-py-3");f.style.display=a?"":"none";let C=e.chunks.join(""),D=g("div","tvw-whitespace-pre-wrap tvw-text-xs tvw-leading-snug tvw-text-cw-muted");D.textContent=C||(e.status==="complete"?"No additional context was shared.":"Waiting for details\u2026"),f.appendChild(D);let U=()=>{o.setAttribute("aria-expanded",a?"true":"false"),p.innerHTML="";let E=vt(a?"chevron-up":"chevron-down",16,"currentColor",2);E?p.appendChild(E):p.textContent=a?"Hide":"Show",f.style.display=a?"":"none"},B=()=>{a=!a,a?SS.add(r.id):SS.delete(r.id),U()};return o.addEventListener("pointerdown",A=>{A.preventDefault(),B()}),o.addEventListener("keydown",A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),B())}),U(),t.append(o,f),t};var kS=new Set,bS=(r,e)=>{var B;let t=r.toolCall,a=(B=e==null?void 0:e.toolCall)!=null?B:{},o=g("div",["tvw-w-full","tvw-max-w-[85%]","tvw-rounded-2xl","tvw-bg-cw-surface","tvw-border","tvw-border-cw-message-border","tvw-text-cw-primary","tvw-shadow-sm","tvw-overflow-hidden","tvw-px-0","tvw-py-0"].join(" "));if(a.backgroundColor&&(o.style.backgroundColor=a.backgroundColor),a.borderColor&&(o.style.borderColor=a.borderColor),a.borderWidth&&(o.style.borderWidth=a.borderWidth),a.borderRadius&&(o.style.borderRadius=a.borderRadius),!t)return o;let l=kS.has(r.id),d=g("button","tvw-flex tvw-w-full tvw-items-center tvw-justify-between tvw-gap-3 tvw-bg-transparent tvw-px-4 tvw-py-3 tvw-text-left tvw-cursor-pointer tvw-border-none");d.type="button",d.setAttribute("aria-expanded",l?"true":"false"),a.headerBackgroundColor&&(d.style.backgroundColor=a.headerBackgroundColor),a.headerPaddingX&&(d.style.paddingLeft=a.headerPaddingX,d.style.paddingRight=a.headerPaddingX),a.headerPaddingY&&(d.style.paddingTop=a.headerPaddingY,d.style.paddingBottom=a.headerPaddingY);let s=g("div","tvw-flex tvw-flex-col tvw-text-left"),p=g("span","tvw-text-xs tvw-text-cw-primary");a.headerTextColor&&(p.style.color=a.headerTextColor),p.textContent=kA(t),s.appendChild(p);let c=g("div","tvw-flex tvw-items-center"),h=a.toggleTextColor||a.headerTextColor||"currentColor",m=vt(l?"chevron-up":"chevron-down",16,h,2);m?c.appendChild(m):c.textContent=l?"Hide":"Show";let f=g("div","tvw-flex tvw-items-center tvw-gap-2 tvw-ml-auto");f.append(c),d.append(s,f);let C=g("div","tvw-border-t tvw-border-gray-200 tvw-bg-gray-50 tvw-space-y-3 tvw-px-4 tvw-py-3");if(C.style.display=l?"":"none",a.contentBackgroundColor&&(C.style.backgroundColor=a.contentBackgroundColor),a.contentTextColor&&(C.style.color=a.contentTextColor),a.contentPaddingX&&(C.style.paddingLeft=a.contentPaddingX,C.style.paddingRight=a.contentPaddingX),a.contentPaddingY&&(C.style.paddingTop=a.contentPaddingY,C.style.paddingBottom=a.contentPaddingY),t.name){let A=g("div","tvw-text-xs tvw-text-cw-muted tvw-italic");a.contentTextColor?A.style.color=a.contentTextColor:a.headerTextColor&&(A.style.color=a.headerTextColor),A.textContent=t.name,C.appendChild(A)}if(t.args!==void 0){let A=g("div","tvw-space-y-1"),E=g("div","tvw-text-xs tvw-text-cw-muted");a.labelTextColor&&(E.style.color=a.labelTextColor),E.textContent="Arguments";let y=g("pre","tvw-max-h-48 tvw-overflow-auto tvw-whitespace-pre-wrap tvw-rounded-lg tvw-border tvw-border-gray-100 tvw-bg-white tvw-px-3 tvw-py-2 tvw-text-xs tvw-text-cw-primary");y.style.fontSize="0.75rem",y.style.lineHeight="1rem",a.codeBlockBackgroundColor&&(y.style.backgroundColor=a.codeBlockBackgroundColor),a.codeBlockBorderColor&&(y.style.borderColor=a.codeBlockBorderColor),a.codeBlockTextColor&&(y.style.color=a.codeBlockTextColor),y.textContent=xS(t.args),A.append(E,y),C.appendChild(A)}if(t.chunks&&t.chunks.length){let A=g("div","tvw-space-y-1"),E=g("div","tvw-text-xs tvw-text-cw-muted");a.labelTextColor&&(E.style.color=a.labelTextColor),E.textContent="Activity";let y=g("pre","tvw-max-h-48 tvw-overflow-auto tvw-whitespace-pre-wrap tvw-rounded-lg tvw-border tvw-border-gray-100 tvw-bg-white tvw-px-3 tvw-py-2 tvw-text-xs tvw-text-cw-primary");y.style.fontSize="0.75rem",y.style.lineHeight="1rem",a.codeBlockBackgroundColor&&(y.style.backgroundColor=a.codeBlockBackgroundColor),a.codeBlockBorderColor&&(y.style.borderColor=a.codeBlockBorderColor),a.codeBlockTextColor&&(y.style.color=a.codeBlockTextColor),y.textContent=t.chunks.join(`
|
|
64
64
|
`),A.append(E,y),C.appendChild(A)}if(t.status==="complete"&&t.result!==void 0){let A=g("div","tvw-space-y-1"),E=g("div","tvw-text-xs tvw-text-cw-muted");a.labelTextColor&&(E.style.color=a.labelTextColor),E.textContent="Result";let y=g("pre","tvw-max-h-48 tvw-overflow-auto tvw-whitespace-pre-wrap tvw-rounded-lg tvw-border tvw-border-gray-100 tvw-bg-white tvw-px-3 tvw-py-2 tvw-text-xs tvw-text-cw-primary");y.style.fontSize="0.75rem",y.style.lineHeight="1rem",a.codeBlockBackgroundColor&&(y.style.backgroundColor=a.codeBlockBackgroundColor),a.codeBlockBorderColor&&(y.style.borderColor=a.codeBlockBorderColor),a.codeBlockTextColor&&(y.style.color=a.codeBlockTextColor),y.textContent=xS(t.result),A.append(E,y),C.appendChild(A)}if(t.status==="complete"&&typeof t.duration=="number"){let A=g("div","tvw-text-xs tvw-text-cw-muted");a.contentTextColor&&(A.style.color=a.contentTextColor),A.textContent=`Duration: ${t.duration}ms`,C.appendChild(A)}let D=()=>{d.setAttribute("aria-expanded",l?"true":"false"),c.innerHTML="";let A=a.toggleTextColor||a.headerTextColor||"currentColor",E=vt(l?"chevron-up":"chevron-down",16,A,2);E?c.appendChild(E):c.textContent=l?"Hide":"Show",C.style.display=l?"":"none"},U=()=>{l=!l,l?kS.add(r.id):kS.delete(r.id),D()};return d.addEventListener("pointerdown",A=>{A.preventDefault(),U()}),d.addEventListener("keydown",A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),U())}),D(),o.append(d,C),o};var RA=r=>{let e=[];return{buttons:e,render:(a,o,l,d)=>{if(r.innerHTML="",e.length=0,!a||!a.length||(d!=null?d:o?o.getMessages():[]).some(m=>m.role==="user"))return;let c=document.createDocumentFragment(),h=o?o.isStreaming():!1;a.forEach(m=>{let f=g("button","tvw-rounded-button tvw-bg-cw-surface tvw-px-3 tvw-py-1.5 tvw-text-xs tvw-font-medium tvw-text-cw-muted hover:tvw-opacity-90 tvw-cursor-pointer tvw-border tvw-border-gray-200");f.type="button",f.textContent=m,f.disabled=h,f.addEventListener("click",()=>{!o||o.isStreaming()||(l.value="",o.sendMessage(m))}),c.appendChild(f),e.push(f)}),r.appendChild(c)}}};var FA={init:{title:"Schedule a Demo",description:"Share the basics and we'll follow up with a confirmation.",fields:[{name:"name",label:"Full name",placeholder:"Jane Doe",required:!0},{name:"email",label:"Work email",placeholder:"jane@example.com",type:"email",required:!0},{name:"notes",label:"What would you like to cover?",type:"textarea"}],submitLabel:"Submit details"},followup:{title:"Additional Information",description:"Provide any extra details to tailor the next steps.",fields:[{name:"company",label:"Company",placeholder:"Acme Inc."},{name:"context",label:"Context",type:"textarea",placeholder:"Share more about your use case"}],submitLabel:"Send"}},HS=(r,e,t,a)=>{let o=r.querySelectorAll("[data-tv-form]");o.length&&o.forEach(l=>{var D,U,B;if(l.dataset.enhanced==="true")return;let d=(D=l.dataset.tvForm)!=null?D:"init";l.dataset.enhanced="true";let s=(U=FA[d])!=null?U:FA.init;l.classList.add("tvw-form-card","tvw-space-y-4");let p=g("div","tvw-space-y-1"),c=g("h3","tvw-text-base tvw-font-semibold tvw-text-cw-primary");if(c.textContent=s.title,p.appendChild(c),s.description){let A=g("p","tvw-text-sm tvw-text-cw-muted");A.textContent=s.description,p.appendChild(A)}let h=document.createElement("form");h.className="tvw-form-grid tvw-space-y-3",s.fields.forEach(A=>{var L,lt;let E=g("label","tvw-form-field tvw-flex tvw-flex-col tvw-gap-1");E.htmlFor=`${e.id}-${d}-${A.name}`;let y=g("span","tvw-text-xs tvw-font-medium tvw-text-cw-muted");y.textContent=A.label,E.appendChild(y);let yt=(L=A.type)!=null?L:"text",q;yt==="textarea"?(q=document.createElement("textarea"),q.rows=3):(q=document.createElement("input"),q.type=yt),q.className="tvw-rounded-xl tvw-border tvw-border-gray-200 tvw-bg-white tvw-px-3 tvw-py-2 tvw-text-sm tvw-text-cw-primary focus:tvw-outline-none focus:tvw-border-cw-primary",q.id=`${e.id}-${d}-${A.name}`,q.name=A.name,q.placeholder=(lt=A.placeholder)!=null?lt:"",A.required&&(q.required=!0),E.appendChild(q),h.appendChild(E)});let m=g("div","tvw-flex tvw-items-center tvw-justify-between tvw-gap-2"),f=g("div","tvw-text-xs tvw-text-cw-muted tvw-min-h-[1.5rem]"),C=g("button","tvw-inline-flex tvw-items-center tvw-rounded-full tvw-bg-cw-primary tvw-px-4 tvw-py-2 tvw-text-sm tvw-font-semibold tvw-text-white disabled:tvw-opacity-60 tvw-cursor-pointer");C.type="submit",C.textContent=(B=s.submitLabel)!=null?B:"Submit",m.appendChild(f),m.appendChild(C),h.appendChild(m),l.replaceChildren(p,h),h.addEventListener("submit",async A=>{var q,L;A.preventDefault();let E=(q=t.formEndpoint)!=null?q:"/form",y=new FormData(h),yt={};y.forEach((lt,ct)=>{yt[ct]=lt}),yt.type=d,C.disabled=!0,f.textContent="Submitting\u2026";try{let lt=await fetch(E,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(yt)});if(!lt.ok)throw new Error(`Form submission failed (${lt.status})`);let ct=await lt.json();f.textContent=(L=ct.message)!=null?L:"Thanks! We'll be in touch soon.",ct.success&&ct.nextPrompt&&await a.sendMessage(String(ct.nextPrompt))}catch(lt){f.textContent=lt instanceof Error?lt.message:"Something went wrong. Please try again."}finally{C.disabled=!1}})})};var LS=class{constructor(){this.plugins=new Map}register(e){var t;this.plugins.has(e.id)&&console.warn(`Plugin "${e.id}" is already registered. Overwriting.`),this.plugins.set(e.id,e),(t=e.onRegister)==null||t.call(e)}unregister(e){var a;let t=this.plugins.get(e);t&&((a=t.onUnregister)==null||a.call(t),this.plugins.delete(e))}getAll(){return Array.from(this.plugins.values()).sort((e,t)=>{var a,o;return((a=t.priority)!=null?a:0)-((o=e.priority)!=null?o:0)})}getForInstance(e){let t=this.getAll();if(!e||e.length===0)return t;let a=new Set(e.map(l=>l.id));return[...t.filter(l=>!a.has(l.id)),...e].sort((l,d)=>{var s,p;return((s=d.priority)!=null?s:0)-((p=l.priority)!=null?p:0)})}clear(){this.plugins.forEach(e=>{var t;return(t=e.onUnregister)==null?void 0:t.call(e)}),this.plugins.clear()}},Ro=new LS;var Zt={apiUrl:"http://localhost:43111/api/chat/dispatch",theme:{primary:"#111827",accent:"#1d4ed8",surface:"#ffffff",muted:"#6b7280",container:"#f8fafc",border:"#f1f5f9",divider:"#f1f5f9",messageBorder:"#f1f5f9",inputBackground:"#ffffff",callToAction:"#000000",callToActionBackground:"#ffffff",sendButtonBackgroundColor:"#111827",sendButtonTextColor:"#ffffff",sendButtonBorderColor:"#60a5fa",closeButtonColor:"#6b7280",closeButtonBackgroundColor:"transparent",closeButtonBorderColor:"",clearChatIconColor:"#6b7280",clearChatBackgroundColor:"transparent",clearChatBorderColor:"transparent",micIconColor:"#111827",micBackgroundColor:"transparent",micBorderColor:"transparent",recordingIconColor:"#ffffff",recordingBackgroundColor:"#ef4444",recordingBorderColor:"transparent",inputFontFamily:"sans-serif",inputFontWeight:"400",radiusSm:"0.75rem",radiusMd:"1rem",radiusLg:"1.5rem",launcherRadius:"9999px",buttonRadius:"9999px"},launcher:{enabled:!0,title:"Chat Assistant",subtitle:"Here to help you get answers fast",agentIconText:"\u{1F4AC}",position:"bottom-right",width:"min(400px, calc(100vw - 24px))",autoExpand:!1,callToActionIconHidden:!1,agentIconSize:"40px",headerIconSize:"40px",closeButtonSize:"32px",callToActionIconName:"arrow-up-right",callToActionIconText:"",callToActionIconSize:"32px",callToActionIconPadding:"5px",callToActionIconColor:"#000000",callToActionIconBackgroundColor:"#ffffff",closeButtonColor:"#6b7280",closeButtonBackgroundColor:"transparent",clearChat:{iconColor:"#6b7280",backgroundColor:"transparent",borderColor:"transparent",enabled:!0,iconName:"refresh-cw",size:"29px",showTooltip:!0,tooltipText:"Clear chat",paddingX:"0px",paddingY:"0px"},headerIconHidden:!1},copy:{welcomeTitle:"Hello \u{1F44B}",welcomeSubtitle:"Ask anything about your account or products.",inputPlaceholder:"How can I help...",sendButtonLabel:"Send"},sendButton:{borderWidth:"0px",paddingX:"12px",paddingY:"10px",backgroundColor:"#111827",textColor:"#ffffff",borderColor:"#60a5fa",useIcon:!0,iconText:"\u2191",size:"40px",showTooltip:!0,tooltipText:"Send message",iconName:"send"},statusIndicator:{visible:!0,idleText:"Online",connectingText:"Connecting\u2026",connectedText:"Streaming\u2026",errorText:"Offline"},voiceRecognition:{enabled:!0,pauseDuration:2e3,iconName:"mic",iconSize:"39px",borderWidth:"0px",paddingX:"9px",paddingY:"14px",iconColor:"#111827",backgroundColor:"transparent",borderColor:"transparent",recordingIconColor:"#ffffff",recordingBackgroundColor:"#ef4444",recordingBorderColor:"transparent",showTooltip:!0,tooltipText:"Start voice recognition"},features:{showReasoning:!0,showToolCalls:!0},suggestionChips:["What can you help me with?","Tell me about your features","How does this work?"],debug:!1};function tS(r){var e,t,a;return r?{...Zt,...r,theme:{...Zt.theme,...r.theme},launcher:{...Zt.launcher,...r.launcher,clearChat:{...(e=Zt.launcher)==null?void 0:e.clearChat,...(t=r.launcher)==null?void 0:t.clearChat}},copy:{...Zt.copy,...r.copy},sendButton:{...Zt.sendButton,...r.sendButton},statusIndicator:{...Zt.statusIndicator,...r.statusIndicator},voiceRecognition:{...Zt.voiceRecognition,...r.voiceRecognition},features:{...Zt.features,...r.features},suggestionChips:(a=r.suggestionChips)!=null?a:Zt.suggestionChips}:Zt}var uo="vanilla-agent-chat-history",DA=r=>r!=null&&r.postprocessMessage?e=>r.postprocessMessage({text:e.text,message:e.message,streaming:e.streaming}):({text:e})=>Oo(e),aS=(r,e)=>{var Sa,Aa,ka,ba,Ha,La,Ta,Va,Ba;(!r.id||r.id!=="vanilla-agent-root")&&(r.id="vanilla-agent-root");let t=tS(e);mS(r,t);let a=Ro.getForInstance(t.plugins),o=(Aa=(Sa=t.launcher)==null?void 0:Sa.enabled)!=null?Aa:!0,l=(ba=(ka=t.launcher)==null?void 0:ka.autoExpand)!=null?ba:!1,d=l,s=o,p=o?l:!0,c=DA(t),h=(La=(Ha=t.features)==null?void 0:Ha.showReasoning)!=null?La:!0,m=(Va=(Ta=t.features)==null?void 0:Ta.showToolCalls)!=null?Va:!0,f=(Ba=t.statusIndicator)!=null?Ba:{},C=n=>{var P,i,R,v;return n==="idle"?(P=f.idleText)!=null?P:Pt.idle:n==="connecting"?(i=f.connectingText)!=null?i:Pt.connecting:n==="connected"?(R=f.connectedText)!=null?R:Pt.connected:n==="error"?(v=f.errorText)!=null?v:Pt.error:Pt[n]},{wrapper:D,panel:U}=BA(t),B=PA(t,o),{container:A,body:E,messagesWrapper:y,suggestions:yt,textarea:q,sendButton:L,sendButtonWrapper:lt,composerForm:ct,statusText:ut,introTitle:kt,introSubtitle:Ct,closeButton:k,iconHolder:G}=B,H=B.micButton,At=B.micButtonWrapper;U.appendChild(A),r.appendChild(D);let Wt=[],jt=RA(yt),_t=null,K,Rt=!1,Q=!0,da=0,Na=0,Kt=null,rt=!1,la=0,sa=!1,Ga=125,Za=2e3,te=5,$t=50,Jt=(n=!1)=>{if(!Q)return;let P=Date.now();rt&&P<la&&!n||(rt&&P>=la&&(rt=!1),!(!n&&!Rt)&&(P-Na<Ga||(Na=P,Kt&&cancelAnimationFrame(Kt),Kt=requestAnimationFrame(()=>{rt||!Q||(sa=!0,E.scrollTop=E.scrollHeight,da=E.scrollTop,requestAnimationFrame(()=>{sa=!1}),Kt=null)}))))},Mt=null,ta=()=>D.querySelector("#vanilla-agent-scroll-container")||E,$=(n,P=500)=>{let i=n.scrollTop,R=n.clientHeight,v=n.scrollHeight,S=v-i;if(i+R>=v-2||Math.abs(S)<5)return;Mt!==null&&(cancelAnimationFrame(Mt),Mt=null);let O=performance.now(),z=b=>1-Math.pow(1-b,3),u=b=>{let T=n.scrollHeight;T!==v&&(v=T,S=v-i);let M=b-O,x=Math.min(M/P,1),I=z(x),W=i+S*I;n.scrollTop=W,x<1?Mt=requestAnimationFrame(u):(n.scrollTop=n.scrollHeight,Mt=null)};Mt=requestAnimationFrame(u)},ht=(n,P,i)=>{n.innerHTML="";let R=document.createDocumentFragment();P.forEach(S=>{let w=null,O=a.find(u=>!!(S.variant==="reasoning"&&u.renderReasoning||S.variant==="tool"&&u.renderToolCall||!S.variant&&u.renderMessage));if(O)if(S.variant==="reasoning"&&S.reasoning&&O.renderReasoning){if(!h)return;w=O.renderReasoning({message:S,defaultRenderer:()=>AS(S),config:t})}else if(S.variant==="tool"&&S.toolCall&&O.renderToolCall){if(!m)return;w=O.renderToolCall({message:S,defaultRenderer:()=>bS(S,t),config:t})}else O.renderMessage&&(w=O.renderMessage({message:S,defaultRenderer:()=>{let u=CS(S,i);return S.role!=="user"&&HS(u,S,t,K),u},config:t}));if(!w)if(S.variant==="reasoning"&&S.reasoning){if(!h)return;w=AS(S)}else if(S.variant==="tool"&&S.toolCall){if(!m)return;w=bS(S,t)}else w=CS(S,i),S.role!=="user"&&HS(w,S,t,K);let z=document.createElement("div");z.className="tvw-flex",S.role==="user"&&z.classList.add("tvw-justify-end"),z.appendChild(w),R.appendChild(z)});let v=P.some(S=>S.role==="assistant"&&S.streaming);if(Rt&&P.some(S=>S.role==="user")&&!v){let S=wS(),w=document.createElement("div");w.className=["tvw-max-w-[85%]","tvw-rounded-2xl","tvw-text-sm","tvw-leading-relaxed","tvw-shadow-sm","tvw-bg-cw-surface","tvw-border","tvw-border-cw-message-border","tvw-text-cw-primary","tvw-px-5","tvw-py-3"].join(" "),w.appendChild(S);let O=document.createElement("div");O.className="tvw-flex",O.appendChild(w),R.appendChild(O)}n.appendChild(R),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let S=ta();$(S)})})},pa=()=>{o&&(p?(D.classList.remove("tvw-pointer-events-none","tvw-opacity-0"),U.classList.remove("tvw-scale-95","tvw-opacity-0"),U.classList.add("tvw-scale-100","tvw-opacity-100"),st&&(st.element.style.display="none")):(D.classList.add("tvw-pointer-events-none","tvw-opacity-0"),U.classList.remove("tvw-scale-100","tvw-opacity-100"),U.classList.add("tvw-scale-95","tvw-opacity-0"),st&&(st.element.style.display="")))},Z=n=>{o&&p!==n&&(p=n,pa(),p&&(Yt(),Jt(!0)))},zt=n=>{q.disabled=n,L.disabled=n,H&&(H.disabled=n),jt.buttons.forEach(P=>{P.disabled=n})},$a=()=>{var v,S,w,O,z,u,b,T,M,x,I,W,j,ot;kt.textContent=(S=(v=t.copy)==null?void 0:v.welcomeTitle)!=null?S:"Hello \u{1F44B}",Ct.textContent=(O=(w=t.copy)==null?void 0:w.welcomeSubtitle)!=null?O:"Ask anything about your account or products.",q.placeholder=(u=(z=t.copy)==null?void 0:z.inputPlaceholder)!=null?u:"How can I help...",((T=(b=t.sendButton)==null?void 0:b.useIcon)!=null?T:!1)||(L.textContent=(x=(M=t.copy)==null?void 0:M.sendButtonLabel)!=null?x:"Send");let P=(W=(I=t.theme)==null?void 0:I.inputFontFamily)!=null?W:"sans-serif",i=(ot=(j=t.theme)==null?void 0:j.inputFontWeight)!=null?ot:"400",R=nt=>{switch(nt){case"serif":return'Georgia, "Times New Roman", Times, serif';case"mono":return'"Courier New", Courier, "Lucida Console", Monaco, monospace';case"sans-serif":default:return'-apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif'}};q.style.fontFamily=R(P),q.style.fontWeight=i};K=new le(t,{onMessagesChanged(n){ht(y,n,c),K&&(n.some(i=>i.role==="user")?jt.render([],K,q,n):jt.render(t.suggestionChips,K,q,n)),Jt(!Rt)},onStatusChanged(n){var R;let P=(R=t.statusIndicator)!=null?R:{},i=v=>{var S,w,O,z;return v==="idle"?(S=P.idleText)!=null?S:Pt.idle:v==="connecting"?(w=P.connectingText)!=null?w:Pt.connecting:v==="connected"?(O=P.connectedText)!=null?O:Pt.connected:v==="error"?(z=P.errorText)!=null?z:Pt.error:Pt[v]};ut.textContent=i(n)},onStreamingChanged(n){Rt=n,zt(n),K&&ht(y,K.getMessages(),c),n||Jt(!0)}});let aa=n=>{n.preventDefault();let P=q.value.trim();P&&(q.value="",K.sendMessage(P))},Ma=n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),L.click())},bt=null,Bt=!1,Xt=null,Ut=null,ga=()=>typeof window=="undefined"?null:window.webkitSpeechRecognition||window.SpeechRecognition||null,va=()=>{var v,S,w,O;if(Bt||K.isStreaming())return;let n=ga();if(!n)return;bt=new n;let i=(S=((v=t.voiceRecognition)!=null?v:{}).pauseDuration)!=null?S:2e3;bt.continuous=!0,bt.interimResults=!0,bt.lang="en-US";let R=q.value;bt.onresult=z=>{let u="",b="";for(let M=0;M<z.results.length;M++){let x=z.results[M],I=x[0].transcript;x.isFinal?u+=I+" ":b=I}let T=R+u+b;q.value=T,Xt&&clearTimeout(Xt),(u||b)&&(Xt=window.setTimeout(()=>{let M=q.value.trim();M&&bt&&Bt&&(Et(),q.value="",K.sendMessage(M,{viaVoice:!0}))},i))},bt.onerror=z=>{z.error!=="no-speech"&&Et()},bt.onend=()=>{if(Bt){let z=q.value.trim();z&&z!==R.trim()&&(q.value="",K.sendMessage(z,{viaVoice:!0})),Et()}};try{if(bt.start(),Bt=!0,H){Ut={backgroundColor:H.style.backgroundColor,color:H.style.color,borderColor:H.style.borderColor};let z=(w=t.voiceRecognition)!=null?w:{},u=(O=z.recordingBackgroundColor)!=null?O:"#ef4444",b=z.recordingIconColor,T=z.recordingBorderColor;if(H.classList.add("tvw-voice-recording"),H.style.backgroundColor=u,b){H.style.color=b;let M=H.querySelector("svg");M&&M.setAttribute("stroke",b)}T&&(H.style.borderColor=T),H.setAttribute("aria-label","Stop voice recognition")}}catch{Et()}},Et=()=>{if(Bt){if(Bt=!1,Xt&&(clearTimeout(Xt),Xt=null),bt){try{bt.stop()}catch{}bt=null}if(H){if(H.classList.remove("tvw-voice-recording"),Ut){H.style.backgroundColor=Ut.backgroundColor,H.style.color=Ut.color,H.style.borderColor=Ut.borderColor;let n=H.querySelector("svg");n&&n.setAttribute("stroke",Ut.color||"currentColor"),Ut=null}H.setAttribute("aria-label","Start voice recognition")}}},Xa=(n,P)=>{var W,j,ot,nt,ft,at,_;if(!(typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined")))return null;let R=g("div","tvw-send-button-wrapper"),v=g("button","tvw-rounded-button tvw-flex tvw-items-center tvw-justify-center disabled:tvw-opacity-50 tvw-cursor-pointer");v.type="button",v.setAttribute("aria-label","Start voice recognition");let S=(W=n==null?void 0:n.iconName)!=null?W:"mic",w=(j=P==null?void 0:P.size)!=null?j:"40px",O=(ot=n==null?void 0:n.iconSize)!=null?ot:w,z=parseFloat(O)||24,u=(nt=n==null?void 0:n.backgroundColor)!=null?nt:P==null?void 0:P.backgroundColor,b=(ft=n==null?void 0:n.iconColor)!=null?ft:P==null?void 0:P.textColor;v.style.width=O,v.style.height=O,v.style.minWidth=O,v.style.minHeight=O,v.style.fontSize="18px",v.style.lineHeight="1";let T=b||"currentColor",M=vt(S,z,T,1.5);M?(v.appendChild(M),v.style.color=T):(v.textContent="\u{1F3A4}",v.style.color=T),u?v.style.backgroundColor=u:v.classList.add("tvw-bg-cw-primary"),b?v.style.color=b:!b&&!(P!=null&&P.textColor)&&v.classList.add("tvw-text-white"),n!=null&&n.borderWidth&&(v.style.borderWidth=n.borderWidth,v.style.borderStyle="solid"),n!=null&&n.borderColor&&(v.style.borderColor=n.borderColor),n!=null&&n.paddingX&&(v.style.paddingLeft=n.paddingX,v.style.paddingRight=n.paddingX),n!=null&&n.paddingY&&(v.style.paddingTop=n.paddingY,v.style.paddingBottom=n.paddingY),R.appendChild(v);let x=(at=n==null?void 0:n.tooltipText)!=null?at:"Start voice recognition";if(((_=n==null?void 0:n.showTooltip)!=null?_:!1)&&x){let X=g("div","tvw-send-button-tooltip");X.textContent=x,R.appendChild(X)}return{micButton:v,micButtonWrapper:R}},ha=()=>{if(Bt){let n=q.value.trim();Et(),n&&(q.value="",K.sendMessage(n))}else va()};H&&(H.addEventListener("click",ha),Wt.push(()=>{Et(),H&&H.removeEventListener("click",ha)}));let ya=()=>{Z(!p)},st=o?yS(t,ya):null;st&&r.appendChild(st.element),pa(),jt.render(t.suggestionChips,K,q),$a(),zt(K.isStreaming()),Jt(!0);let Yt=()=>{var w,O;if(!o){U.style.height="",U.style.width="";return}let n=(O=(w=t==null?void 0:t.launcher)==null?void 0:w.width)!=null?O:t==null?void 0:t.launcherWidth,P=n!=null?n:"min(400px, calc(100vw - 24px))";U.style.width=P,U.style.maxWidth=P;let i=window.innerHeight,v=Math.max(200,i-64),S=Math.min(640,v);U.style.height=`${S}px`};Yt(),window.addEventListener("resize",Yt),Wt.push(()=>window.removeEventListener("resize",Yt)),da=E.scrollTop;let wa=()=>{let n=E.scrollTop,P=E.scrollHeight,i=E.clientHeight,R=P-n-i,v=Math.abs(n-da);if(da=n,!sa&&!(v<=te)){if(!Q&&R<$t){rt=!1,Q=!0;return}Q&&R>$t&&(rt=!0,la=Date.now()+Za,Q=!1)}};E.addEventListener("scroll",wa,{passive:!0}),Wt.push(()=>E.removeEventListener("scroll",wa)),Wt.push(()=>{Kt&&cancelAnimationFrame(Kt)});let Ca=()=>{k&&(_t&&(k.removeEventListener("click",_t),_t=null),o?(k.style.display="",_t=()=>{p=!1,pa()},k.addEventListener("click",_t)):k.style.display="none")};return Ca(),(()=>{let{clearChatButton:n}=B;n&&n.addEventListener("click",()=>{K.clearMessages();try{localStorage.removeItem(uo),t.debug&&console.log(`[AgentWidget] Cleared default localStorage key: ${uo}`)}catch(i){console.error("[AgentWidget] Failed to clear default localStorage:",i)}if(t.clearChatHistoryStorageKey&&t.clearChatHistoryStorageKey!==uo)try{localStorage.removeItem(t.clearChatHistoryStorageKey),t.debug&&console.log(`[AgentWidget] Cleared custom localStorage key: ${t.clearChatHistoryStorageKey}`)}catch(i){console.error("[AgentWidget] Failed to clear custom localStorage:",i)}let P=new CustomEvent("vanilla-agent:clear-chat",{detail:{timestamp:new Date().toISOString()}});window.dispatchEvent(P)})})(),ct.addEventListener("submit",aa),q.addEventListener("keydown",Ma),Wt.push(()=>{ct.removeEventListener("submit",aa),q.removeEventListener("keydown",Ma)}),Wt.push(()=>{K.cancel()}),st&&Wt.push(()=>{st==null||st.destroy()}),{update(n){var xo,mo,Mo,go,vo,yo,wo,Co,So,Ao,N,xt,Lt,Qt,qt,na,Pa,fa,_a,ia,Fo,ko,St,ca,Ra,bo,ee,BS,PS,RS,FS,DS,zS,ES,qS,IS,OS,WS,US,NS,GS,ZS,$S,XS,_S,KS,JS,YS,QS;let P=t.toolCall;t={...t,...n},mS(r,t);let i=Ro.getForInstance(t.plugins);a.length=0,a.push(...i),o=(mo=(xo=t.launcher)==null?void 0:xo.enabled)!=null?mo:!0,l=(go=(Mo=t.launcher)==null?void 0:Mo.autoExpand)!=null?go:!1,h=(yo=(vo=t.features)==null?void 0:vo.showReasoning)!=null?yo:!0,m=(Co=(wo=t.features)==null?void 0:wo.showToolCalls)!=null?Co:!0,((So=t.launcher)==null?void 0:So.enabled)===!1&&st&&(st.destroy(),st=null),((Ao=t.launcher)==null?void 0:Ao.enabled)!==!1&&!st&&(st=yS(t,ya),r.appendChild(st.element)),st&&st.update(t),o!==s?o?Z(l):(p=!0,pa()):l!==d&&Z(l),d=l,s=o,Yt(),Ca(),JSON.stringify(n.toolCall)!==JSON.stringify(P)&&K&&ht(y,K.getMessages(),c);let w=(N=t.launcher)!=null?N:{},O=(xt=w.headerIconHidden)!=null?xt:!1,z=w.headerIconName,u=(Lt=w.headerIconSize)!=null?Lt:"48px";if(G){let V=A.querySelector(".tvw-border-b-cw-divider"),gt=V==null?void 0:V.querySelector(".tvw-flex-col");if(O)G.style.display="none",V&>&&!V.contains(gt)&&V.insertBefore(gt,V.firstChild);else{if(G.style.display="",G.style.height=u,G.style.width=u,V&>&&(V.contains(G)?G.nextSibling!==gt&&(G.remove(),V.insertBefore(G,gt)):V.insertBefore(G,gt)),z){let Tt=parseFloat(u)||24,pt=vt(z,Tt*.6,"#ffffff",2);pt?G.replaceChildren(pt):G.textContent=(Qt=w.agentIconText)!=null?Qt:"\u{1F4AC}"}else if(w.iconUrl){let Tt=G.querySelector("img");if(Tt)Tt.src=w.iconUrl,Tt.style.height=u,Tt.style.width=u;else{let pt=document.createElement("img");pt.src=w.iconUrl,pt.alt="",pt.className="tvw-rounded-xl tvw-object-cover",pt.style.height=u,pt.style.width=u,G.replaceChildren(pt)}}else{let Tt=G.querySelector("svg"),pt=G.querySelector("img");(Tt||pt)&&G.replaceChildren(),G.textContent=(qt=w.agentIconText)!=null?qt:"\u{1F4AC}"}let wt=G.querySelector("img");wt&&(wt.style.height=u,wt.style.width=u)}}if(k){let V=(na=w.closeButtonSize)!=null?na:"32px",gt=(Pa=w.closeButtonPlacement)!=null?Pa:"inline";k.style.height=V,k.style.width=V;let wt=gt==="top-right",Tt=k.classList.contains("tvw-absolute");if(wt!==Tt)if(k.remove(),wt)k.className="tvw-absolute tvw-top-4 tvw-right-4 tvw-z-50 tvw-inline-flex tvw-items-center tvw-justify-center tvw-rounded-full tvw-text-cw-muted hover:tvw-bg-gray-100 tvw-cursor-pointer tvw-border-none",A.style.position="relative",A.appendChild(k);else{k.className="tvw-ml-auto tvw-inline-flex tvw-items-center tvw-justify-center tvw-rounded-full tvw-text-cw-muted hover:tvw-bg-gray-100 tvw-cursor-pointer tvw-border-none";let et=A.querySelector(".tvw-border-b-cw-divider");et&&et.appendChild(k)}if(w.closeButtonColor?(k.style.color=w.closeButtonColor,k.classList.remove("tvw-text-cw-muted")):(k.style.color="",k.classList.add("tvw-text-cw-muted")),w.closeButtonBackgroundColor?(k.style.backgroundColor=w.closeButtonBackgroundColor,k.classList.remove("hover:tvw-bg-gray-100")):(k.style.backgroundColor="",k.classList.add("hover:tvw-bg-gray-100")),w.closeButtonBorderWidth||w.closeButtonBorderColor){let et=w.closeButtonBorderWidth||"0px",ra=w.closeButtonBorderColor||"transparent";k.style.border=`${et} solid ${ra}`,k.classList.remove("tvw-border-none")}else k.style.border="",k.classList.add("tvw-border-none");w.closeButtonBorderRadius?(k.style.borderRadius=w.closeButtonBorderRadius,k.classList.remove("tvw-rounded-full")):(k.style.borderRadius="",k.classList.add("tvw-rounded-full")),w.closeButtonPaddingX?(k.style.paddingLeft=w.closeButtonPaddingX,k.style.paddingRight=w.closeButtonPaddingX):(k.style.paddingLeft="",k.style.paddingRight=""),w.closeButtonPaddingY?(k.style.paddingTop=w.closeButtonPaddingY,k.style.paddingBottom=w.closeButtonPaddingY):(k.style.paddingTop="",k.style.paddingBottom="");let pt=(fa=w.closeButtonIconName)!=null?fa:"x",ua=(_a=w.closeButtonIconText)!=null?_a:"\xD7";k.innerHTML="";let It=vt(pt,"20px",w.closeButtonColor||"",2);It?k.appendChild(It):k.textContent=ua;let{closeButtonWrapper:Ft}=B,mt=(ia=w.closeButtonTooltipText)!=null?ia:"Close chat",Ot=(Fo=w.closeButtonShowTooltip)!=null?Fo:!0;if(k.setAttribute("aria-label",mt),Ft&&(Ft._cleanupTooltip&&(Ft._cleanupTooltip(),delete Ft._cleanupTooltip),Ot&&mt)){let et=null,ra=()=>{if(et||!k)return;et=g("div","tvw-clear-chat-tooltip"),et.textContent=mt;let jS=g("div");jS.className="tvw-clear-chat-tooltip-arrow",et.appendChild(jS);let eS=k.getBoundingClientRect();et.style.position="fixed",et.style.left=`${eS.left+eS.width/2}px`,et.style.top=`${eS.top-8}px`,et.style.transform="translate(-50%, -100%)",document.body.appendChild(et)},Nt=()=>{et&&et.parentNode&&(et.parentNode.removeChild(et),et=null)};Ft.addEventListener("mouseenter",ra),Ft.addEventListener("mouseleave",Nt),k.addEventListener("focus",ra),k.addEventListener("blur",Nt),Ft._cleanupTooltip=()=>{Nt(),Ft&&(Ft.removeEventListener("mouseenter",ra),Ft.removeEventListener("mouseleave",Nt)),k&&(k.removeEventListener("focus",ra),k.removeEventListener("blur",Nt))}}}let{clearChatButton:b,clearChatButtonWrapper:T}=B;if(b){let V=(ko=w.clearChat)!=null?ko:{},gt=(St=V.enabled)!=null?St:!0;if(T&&(T.style.display=gt?"":"none"),gt){let wt=(ca=V.size)!=null?ca:"32px";b.style.height=wt,b.style.width=wt;let Tt=(Ra=V.iconName)!=null?Ra:"refresh-cw",pt=(bo=V.iconColor)!=null?bo:"";b.innerHTML="";let ua=vt(Tt,"20px",pt||"",2);if(ua&&b.appendChild(ua),pt?(b.style.color=pt,b.classList.remove("tvw-text-cw-muted")):(b.style.color="",b.classList.add("tvw-text-cw-muted")),V.backgroundColor?(b.style.backgroundColor=V.backgroundColor,b.classList.remove("hover:tvw-bg-gray-100")):(b.style.backgroundColor="",b.classList.add("hover:tvw-bg-gray-100")),V.borderWidth||V.borderColor){let mt=V.borderWidth||"0px",Ot=V.borderColor||"transparent";b.style.border=`${mt} solid ${Ot}`,b.classList.remove("tvw-border-none")}else b.style.border="",b.classList.add("tvw-border-none");V.borderRadius?(b.style.borderRadius=V.borderRadius,b.classList.remove("tvw-rounded-full")):(b.style.borderRadius="",b.classList.add("tvw-rounded-full")),V.paddingX?(b.style.paddingLeft=V.paddingX,b.style.paddingRight=V.paddingX):(b.style.paddingLeft="",b.style.paddingRight=""),V.paddingY?(b.style.paddingTop=V.paddingY,b.style.paddingBottom=V.paddingY):(b.style.paddingTop="",b.style.paddingBottom="");let It=(ee=V.tooltipText)!=null?ee:"Clear chat",Ft=(BS=V.showTooltip)!=null?BS:!0;if(b.setAttribute("aria-label",It),T&&(T._cleanupTooltip&&(T._cleanupTooltip(),delete T._cleanupTooltip),Ft&&It)){let mt=null,Ot=()=>{if(mt||!b)return;mt=g("div","tvw-clear-chat-tooltip"),mt.textContent=It;let ra=g("div");ra.className="tvw-clear-chat-tooltip-arrow",mt.appendChild(ra);let Nt=b.getBoundingClientRect();mt.style.position="fixed",mt.style.left=`${Nt.left+Nt.width/2}px`,mt.style.top=`${Nt.top-8}px`,mt.style.transform="translate(-50%, -100%)",document.body.appendChild(mt)},et=()=>{mt&&mt.parentNode&&(mt.parentNode.removeChild(mt),mt=null)};T.addEventListener("mouseenter",Ot),T.addEventListener("mouseleave",et),b.addEventListener("focus",Ot),b.addEventListener("blur",et),T._cleanupTooltip=()=>{et(),T&&(T.removeEventListener("mouseenter",Ot),T.removeEventListener("mouseleave",et)),b&&(b.removeEventListener("focus",Ot),b.removeEventListener("blur",et))}}}}c=DA(t),K.updateConfig(t),ht(y,K.getMessages(),c),jt.render(t.suggestionChips,K,q),$a(),zt(K.isStreaming());let M=((PS=t.voiceRecognition)==null?void 0:PS.enabled)===!0,x=typeof window!="undefined"&&(typeof window.webkitSpeechRecognition!="undefined"||typeof window.SpeechRecognition!="undefined"),I=M&&x;if(ct.classList.remove("tvw-gap-1","tvw-gap-3"),ct.classList.add(I?"tvw-gap-1":"tvw-gap-3"),M&&x)if(!H||!At){let V=Xa(t.voiceRecognition,t.sendButton);V&&(H=V.micButton,At=V.micButtonWrapper,ct.insertBefore(At,lt),H.addEventListener("click",ha),H.disabled=K.isStreaming())}else{let V=(RS=t.voiceRecognition)!=null?RS:{},gt=(FS=t.sendButton)!=null?FS:{},wt=(DS=V.iconName)!=null?DS:"mic",Tt=(zS=gt.size)!=null?zS:"40px",pt=(ES=V.iconSize)!=null?ES:Tt,ua=parseFloat(pt)||24;H.style.width=pt,H.style.height=pt,H.style.minWidth=pt,H.style.minHeight=pt;let It=(IS=(qS=V.iconColor)!=null?qS:gt.textColor)!=null?IS:"currentColor";H.innerHTML="";let Ft=vt(wt,ua,It,2);Ft?H.appendChild(Ft):H.textContent="\u{1F3A4}";let mt=(OS=V.backgroundColor)!=null?OS:gt.backgroundColor;mt?(H.style.backgroundColor=mt,H.classList.remove("tvw-bg-cw-primary")):(H.style.backgroundColor="",H.classList.add("tvw-bg-cw-primary")),It?(H.style.color=It,H.classList.remove("tvw-text-white")):!It&&!gt.textColor&&(H.style.color="",H.classList.add("tvw-text-white")),V.borderWidth?(H.style.borderWidth=V.borderWidth,H.style.borderStyle="solid"):(H.style.borderWidth="",H.style.borderStyle=""),V.borderColor?H.style.borderColor=V.borderColor:H.style.borderColor="",V.paddingX?(H.style.paddingLeft=V.paddingX,H.style.paddingRight=V.paddingX):(H.style.paddingLeft="",H.style.paddingRight=""),V.paddingY?(H.style.paddingTop=V.paddingY,H.style.paddingBottom=V.paddingY):(H.style.paddingTop="",H.style.paddingBottom="");let Ot=At==null?void 0:At.querySelector(".tvw-send-button-tooltip"),et=(WS=V.tooltipText)!=null?WS:"Start voice recognition";if(((US=V.showTooltip)!=null?US:!1)&&et)if(Ot)Ot.textContent=et,Ot.style.display="";else{let Nt=document.createElement("div");Nt.className="tvw-send-button-tooltip",Nt.textContent=et,At==null||At.insertBefore(Nt,H)}else Ot&&(Ot.style.display="none");At.style.display="",H.disabled=K.isStreaming()}else H&&At&&(At.style.display="none",Bt&&Et());let W=(NS=t.sendButton)!=null?NS:{},j=(GS=W.useIcon)!=null?GS:!1,ot=(ZS=W.iconText)!=null?ZS:"\u2191",nt=W.iconName,ft=($S=W.tooltipText)!=null?$S:"Send message",at=(XS=W.showTooltip)!=null?XS:!1,_=(_S=W.size)!=null?_S:"40px",X=W.backgroundColor,Y=W.textColor;if(j){if(L.style.width=_,L.style.height=_,L.style.minWidth=_,L.style.minHeight=_,L.style.fontSize="18px",L.style.lineHeight="1",L.innerHTML="",nt){let V=parseFloat(_)||24,gt=Y&&typeof Y=="string"&&Y.trim()?Y.trim():"currentColor",wt=vt(nt,V,gt,2);wt?(L.appendChild(wt),L.style.color=gt):(L.textContent=ot,Y?L.style.color=Y:L.classList.add("tvw-text-white"))}else L.textContent=ot,Y?L.style.color=Y:L.classList.add("tvw-text-white");L.className="tvw-rounded-button tvw-flex tvw-items-center tvw-justify-center disabled:tvw-opacity-50 tvw-cursor-pointer",X?(L.style.backgroundColor=X,L.classList.remove("tvw-bg-cw-primary")):L.classList.add("tvw-bg-cw-primary")}else L.textContent=(JS=(KS=t.copy)==null?void 0:KS.sendButtonLabel)!=null?JS:"Send",L.style.width="",L.style.height="",L.style.minWidth="",L.style.minHeight="",L.style.fontSize="",L.style.lineHeight="",L.className="tvw-rounded-button tvw-bg-cw-accent tvw-px-4 tvw-py-2 tvw-text-sm tvw-font-semibold tvw-text-white disabled:tvw-opacity-50 tvw-cursor-pointer",X?(L.style.backgroundColor=X,L.classList.remove("tvw-bg-cw-accent")):L.classList.add("tvw-bg-cw-accent"),Y?L.style.color=Y:L.classList.add("tvw-text-white");W.borderWidth?(L.style.borderWidth=W.borderWidth,L.style.borderStyle="solid"):(L.style.borderWidth="",L.style.borderStyle=""),W.borderColor?L.style.borderColor=W.borderColor:L.style.borderColor="",W.paddingX?(L.style.paddingLeft=W.paddingX,L.style.paddingRight=W.paddingX):(L.style.paddingLeft="",L.style.paddingRight=""),W.paddingY?(L.style.paddingTop=W.paddingY,L.style.paddingBottom=W.paddingY):(L.style.paddingTop="",L.style.paddingBottom="");let Ht=lt==null?void 0:lt.querySelector(".tvw-send-button-tooltip");if(at&&ft)if(Ht)Ht.textContent=ft,Ht.style.display="";else{let V=document.createElement("div");V.className="tvw-send-button-tooltip",V.textContent=ft,lt==null||lt.insertBefore(V,L)}else Ht&&(Ht.style.display="none");let J=(YS=t.statusIndicator)!=null?YS:{},ea=(QS=J.visible)!=null?QS:!0;if(ut.style.display=ea?"":"none",K){let V=K.getStatus(),gt=wt=>{var Tt,pt,ua,It;return wt==="idle"?(Tt=J.idleText)!=null?Tt:Pt.idle:wt==="connecting"?(pt=J.connectingText)!=null?pt:Pt.connecting:wt==="connected"?(ua=J.connectedText)!=null?ua:Pt.connected:wt==="error"?(It=J.errorText)!=null?It:Pt.error:Pt[wt]};ut.textContent=gt(V)}},open(){o&&Z(!0)},close(){o&&Z(!1)},toggle(){o&&Z(!p)},clearChat(){K.clearMessages();try{localStorage.removeItem(uo),t.debug&&console.log(`[AgentWidget] Cleared default localStorage key: ${uo}`)}catch(P){console.error("[AgentWidget] Failed to clear default localStorage:",P)}if(t.clearChatHistoryStorageKey&&t.clearChatHistoryStorageKey!==uo)try{localStorage.removeItem(t.clearChatHistoryStorageKey),t.debug&&console.log(`[AgentWidget] Cleared custom localStorage key: ${t.clearChatHistoryStorageKey}`)}catch(P){console.error("[AgentWidget] Failed to clear custom localStorage:",P)}let n=new CustomEvent("vanilla-agent:clear-chat",{detail:{timestamp:new Date().toISOString()}});window.dispatchEvent(n)},setMessage(n){return!q||K.isStreaming()?!1:(!p&&o&&Z(!0),q.value=n,q.dispatchEvent(new Event("input",{bubbles:!0})),!0)},submitMessage(n){if(K.isStreaming())return!1;let P=(n==null?void 0:n.trim())||q.value.trim();return P?(!p&&o&&Z(!0),q.value="",K.sendMessage(P),!0):!1},startVoiceRecognition(){return Bt||K.isStreaming()||!ga()?!1:(!p&&o&&Z(!0),va(),!0)},stopVoiceRecognition(){return Bt?(Et(),!0):!1},injectTestMessage(n){!p&&o&&Z(!0),K.injectTestEvent(n)},destroy(){Wt.forEach(n=>n()),D.remove(),st==null||st.destroy(),_t&&k.removeEventListener("click",_t)}}};var TS={},Wk=r=>{if(typeof window=="undefined"||typeof document=="undefined")throw new Error("Chat widget can only be mounted in a browser environment");if(typeof r=="string"){let e=document.querySelector(r);if(!e)throw new Error(`Chat widget target "${r}" was not found`);return e}return r},Uk=()=>{try{if(typeof TS!="undefined"&&TS.url)return new URL("../widget.css",TS.url).href}catch{}return null},zA=r=>{let e=Uk(),t=()=>{if(!(r instanceof ShadowRoot)||r.querySelector("link[data-vanilla-agent]"))return;let a=document.head.querySelector("link[data-vanilla-agent]");if(!a)return;let o=a.cloneNode(!0);r.insertBefore(o,r.firstChild)};if(r instanceof ShadowRoot)if(e){let a=document.createElement("link");a.rel="stylesheet",a.href=e,a.setAttribute("data-vanilla-agent","true"),r.insertBefore(a,r.firstChild)}else t();else if(!document.head.querySelector("link[data-vanilla-agent]")&&e){let o=document.createElement("link");o.rel="stylesheet",o.href=e,o.setAttribute("data-vanilla-agent","true"),document.head.appendChild(o)}},VS=r=>{var p;let e=Wk(r.target),t=document.createElement("div");t.className="vanilla-agent-host",e.appendChild(t);let a=r.useShadowDom!==!1,o,l;if(a){let c=t.attachShadow({mode:"open"});l=c,o=document.createElement("div"),o.id="vanilla-agent-root",c.appendChild(o),zA(c)}else l=t,o=document.createElement("div"),o.id="vanilla-agent-root",t.appendChild(o),zA(t);let d=aS(o,r.config);(p=r.onReady)==null||p.call(r);let s={host:t,update(c){d.update(c)},open(){d.open()},close(){d.close()},toggle(){d.toggle()},clearChat(){d.clearChat()},setMessage(c){return d.setMessage(c)},submitMessage(c){return d.submitMessage(c)},startVoiceRecognition(){return d.startVoiceRecognition()},stopVoiceRecognition(){return d.stopVoiceRecognition()},injectTestMessage(c){d.injectTestMessage(c)},destroy(){d.destroy(),t.remove(),r.windowKey&&typeof window!="undefined"&&delete window[r.windowKey]}};return r.windowKey&&typeof window!="undefined"&&(window[r.windowKey]=s),s};var Nk=VS;return GA(Gk);})();
|
|
65
65
|
/*! Bundled license information:
|
|
66
66
|
|