@webority/chat-react 0.150.0 → 0.151.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.
Files changed (2) hide show
  1. package/dist/chat-react.js +1 -1
  2. package/package.json +10 -10
@@ -11,4 +11,4 @@ table { border-collapse: collapse; margin: 0 0 6pt; max-width: 100% }
11
11
  caption { text-align: left; font-weight: 600 }
12
12
  th, td { border: 1px solid currentColor; padding: 2pt 6pt; text-align: left; vertical-align: top }
13
13
  thead { display: table-header-group }
14
- `;function X(e,t,n){let r=e.createElement(t);return n!==void 0&&(r.textContent=n),r}function Xe(e,t){if(t.kind===`paragraph`)return X(e,`p`,t.text);if(t.kind===`list`){let n=X(e,t.ordered?`ol`:`ul`);for(let r of t.items)n.append(X(e,`li`,r));return n}let n=X(e,`table`);if(t.title!==null&&n.append(X(e,`caption`,t.title)),t.head.length>0){let r=X(e,`thead`),i=X(e,`tr`);for(let n of t.head)i.append(X(e,`th`,n));r.append(i),n.append(r)}let r=X(e,`tbody`);for(let n of t.rows){let t=X(e,`tr`);for(let r of n)t.append(X(e,`td`,r));r.append(t)}return n.append(r),n}function Ze(e){return`CSSStyleSheet`in e&&typeof e.CSSStyleSheet==`function`}function Qe(e,t){if(Ze(e)&&`adoptedStyleSheets`in t){let n=new e.CSSStyleSheet;n.replaceSync(Ye),t.adoptedStyleSheets=[n];return}let n=X(t,`style`,Ye);t.head.append(n)}function $e(e,t={}){let n=t.lang||document.documentElement.lang||`en`,r=document.createElement(`iframe`);r.title=`Print`,r.setAttribute(`aria-hidden`,`true`),r.tabIndex=-1;let i=r.style;i.position=`fixed`,i.right=`0`,i.bottom=`0`,i.width=`0`,i.height=`0`,i.border=`0`,document.body.append(r);let a=r.contentWindow,o=r.contentDocument;if(!a||!o)return r.remove(),!1;o.open(),o.write(`<!doctype html><title></title>`),o.close(),o.title=e.title,o.documentElement.lang=n,Qe(a,o),o.body.append(X(o,`h1`,e.title));let s=t.printedOn??e.dateText;if(s!=null){let e=X(o,`p`,s);e.className=`date`,o.body.append(e)}for(let t of e.entries){let e=X(o,`section`);e.append(X(o,`h2`,t.speaker));for(let n of t.blocks)e.append(Xe(o,n));o.body.append(e)}let c=()=>{r.isConnected&&r.remove(),clearTimeout(l)};a.addEventListener(`afterprint`,c);let l=setTimeout(c,Je);return a.focus(),a.print(),!0}var et=3e3;function tt(e,t){let[n,r]=A(null),i=k(void 0),a=k(!1);T(()=>(a.current=!0,()=>{a.current=!1,clearTimeout(i.current)}),[]);function o(e){a.current&&(clearTimeout(i.current),r(e),i.current=setTimeout(()=>r(null),et))}let s={labels:t,title:e.title,figureText:e.features.FigureText,...e.profile?{assistantName:e.profile.assistant.name}:{}},c=e.features.Share&&typeof navigator<`u`&&typeof navigator.share==`function`,l=e.features.Print&&typeof document<`u`;async function u(e,n){let r=F(e,s);if(r.entries.length===0)return;let i={title:r.title,text:pe(r,{heading:n,speakers:n})};if(typeof navigator.canShare==`function`&&!navigator.canShare(i))o(t.shareFailed);else try{await navigator.share(i)}catch(e){(typeof e==`object`&&e&&`name`in e?e.name:void 0)!==`AbortError`&&o(t.shareFailed)}}function d(e){let n=F(e,s);n.entries.length!==0&&($e(n,{printedOn:t.printedOn(B((/* @__PURE__ */ new Date()).toISOString()))})||o(t.printFailed))}return{canShare:c,canPrint:l,notice:n,shareReply:e=>u([e],!1),printReply:e=>d([e]),shareConversation:()=>u(e.messages,!0),printConversation:()=>d(e.messages)}}function nt({chat:e,labels:t}){let n=tt(e,t),r=e.streaming||e.thinking,i=e.messages.some(e=>e.stored&&(e.author.kind===`Assistant`||e.author.kind===`Agent`||e.author.kind===`Script`)&&ce(e.parts)!==``);return r||e.loading||e.conversationId===null||!i||!n.canShare&&!n.canPrint?null:/* @__PURE__ */ q(G,{children:[n.canShare&&/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.shareConversation,title:t.shareConversation,onClick:()=>n.shareConversation(),children:/* @__PURE__ */ K(l,{name:`share`,size:18,"aria-hidden":`true`})}),n.canPrint&&/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.printConversation,title:t.printConversation,onClick:()=>n.printConversation(),children:/* @__PURE__ */ K(l,{name:`printer`,size:18,"aria-hidden":`true`})}),n.notice!==null&&/* @__PURE__ */ K(`span`,{className:`wui-chat-action-notice`,role:`status`,children:n.notice})]})}var rt=`https://policies.google.com/privacy`,it=`https://policies.google.com/terms`;function at({chat:e,labels:t}){let n=e.profile;if(!n)return null;let r=n.footer.disclaimer||t.disclaimer,i=n.footer.privacyText,a=ie(n.footer.privacyUrl)?n.footer.privacyUrl:null,o=n.footer.assuranceText,s=ue(n);if(!r&&!i&&!a&&!o&&!s)return null;let c=[];return r&&c.push(/* @__PURE__ */ K(`p`,{className:`wui-chat-footer-text`,children:r},`disclaimer`)),a?c.push(/* @__PURE__ */ K(`p`,{className:`wui-chat-footer-privacy`,children:/* @__PURE__ */ K(`a`,{className:`wui-chat-footer-link`,href:a,children:i||t.footerPrivacyFallback})},`privacy`)):i&&c.push(/* @__PURE__ */ K(`p`,{className:`wui-chat-footer-privacy`,children:i},`privacy`)),o&&c.push(/* @__PURE__ */ K(`p`,{className:`wui-chat-footer-text`,children:o},`assurance`)),s&&c.push(/* @__PURE__ */ q(`p`,{className:`wui-chat-footer-captcha`,children:[t.captchaNoticeBefore,/* @__PURE__ */ K(`a`,{className:`wui-chat-footer-link`,href:rt,target:`_blank`,rel:`noopener noreferrer`,children:t.captchaPrivacyPolicy}),t.captchaNoticeAnd,/* @__PURE__ */ K(`a`,{className:`wui-chat-footer-link`,href:it,target:`_blank`,rel:`noopener noreferrer`,children:t.captchaTerms}),t.captchaNoticeAfter]},`captcha`)),/* @__PURE__ */ K(`div`,{className:`wui-chat-footer`,children:c})}var ot=Object.freeze({items:[],totalCount:null,loading:!1,error:null,hasMore:!1}),st=()=>()=>{};function ct({chat:e,labels:t,onOpen:r}){let[i,a]=A(null),o=i!==null&&i.client===e.client?i.list:null,s=C(e=>o?o.subscribe(e):st(),[o]),c=C(()=>o?o.getState():ot,[o]),u=j(s,c),[d,f]=A(null),[p,m]=A(``),[h,g]=A(!1),[_,v]=A(null),[y,b]=A(!1),x=k(null),S=k(!1),[w,E]=A(!1);T(()=>{let t=L({client:e.client});return a({client:e.client,list:t}),t.load(),()=>t.dispose()},[e.client]),T(()=>{d!==null&&x.current?.focus()},[d]);function D(e){f(e.publicId),m(e.title||``),g(!1)}async function O(e){if(!(S.current||p.trim()===``)){if(o===null)throw Error(`The conversation list is not loaded, so no row can be renamed.`);S.current=!0,E(!0);try{await o.rename(e,p),f(null)}catch{g(!0)}finally{S.current=!1,E(!1)}}}async function M(t){if(!S.current){if(o===null)throw Error(`The conversation list is not loaded, so no row can be deleted.`);S.current=!0,E(!0);try{await o.remove(t),v(null),b(!1),t===e.conversationId&&e.newConversation()}catch{b(!0)}finally{S.current=!1,E(!1)}}}let N=!u.loading&&u.error===null&&u.totalCount!==null&&u.items.length===0;return/* @__PURE__ */ q(`div`,{className:`wui-chat-history`,children:[u.error&&/* @__PURE__ */ q(`p`,{className:`wui-chat-history-error`,role:`alert`,children:[t.loadFailed,` `,/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>o?.load(),children:t.retry})]}),u.loading&&u.items.length===0&&/* @__PURE__ */ K(`p`,{className:`wui-chat-history-empty`,role:`status`,children:t.loadingConversation}),N&&/* @__PURE__ */ q(`p`,{className:`wui-chat-history-empty`,children:[/* @__PURE__ */ K(`span`,{children:t.historyEmptyTitle}),` `,/* @__PURE__ */ K(`span`,{children:t.historyEmptyText})]}),u.items.length>0&&/* @__PURE__ */ K(`ul`,{className:`wui-chat-history-list`,"aria-label":t.history,children:u.items.map(i=>d===i.publicId?/* @__PURE__ */ q(`li`,{className:`wui-chat-history-row wui-chat-history-row--editing`,children:[/* @__PURE__ */ K(`input`,{ref:x,className:`wui-chat-history-input`,"aria-label":t.conversationTitle,maxLength:120,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&e.keyCode!==229&&O(i.publicId).catch(e=>globalThis.reportError?.(e)),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),f(null))}}),/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,disabled:w||p.trim()===``,onClick:()=>O(i.publicId).catch(e=>globalThis.reportError?.(e)),children:t.renameSave}),/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>f(null),children:t.cancel}),h&&/* @__PURE__ */ K(`p`,{className:`wui-chat-history-error`,role:`alert`,children:t.renameFailed})]},i.publicId):_===i.publicId?/* @__PURE__ */ q(`li`,{className:`wui-chat-history-row wui-chat-history-row--confirm`,children:[/* @__PURE__ */ K(`p`,{children:t.deleteConfirmTitle}),/* @__PURE__ */ K(`p`,{children:t.deleteConfirmMessage}),/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,tone:`danger`,disabled:w,onClick:()=>M(i.publicId).catch(e=>globalThis.reportError?.(e)),children:t.deleteConfirm}),/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>v(null),children:t.cancel}),y&&/* @__PURE__ */ K(`p`,{className:`wui-chat-history-error`,role:`alert`,children:t.deleteFailed})]},i.publicId):/* @__PURE__ */ q(`li`,{className:`wui-chat-history-row`,children:[/* @__PURE__ */ q(`button`,{type:`button`,className:`wui-chat-history-open`,onClick:()=>{e.openConversation(i.publicId).catch(e=>globalThis.reportError?.(e)),r()},children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-history-title`,children:i.title||t.untitled}),/* @__PURE__ */ K(`span`,{className:`wui-chat-history-time`,children:B(i.lastActivityDateTimeUtc)})]}),e.features.Rename&&/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.rename,title:t.rename,onClick:()=>D(i),children:/* @__PURE__ */ K(l,{name:`pencil`,size:18,"aria-hidden":`true`})}),e.features.Delete&&/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.deleteChat,title:t.deleteChat,onClick:()=>{b(!1),v(i.publicId)},children:/* @__PURE__ */ K(l,{name:`trash`,size:18,"aria-hidden":`true`})})]},i.publicId))}),!u.loading&&u.hasMore&&/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`soft`,onClick:()=>o?.loadMore(),children:t.loadMore})]})}var lt=/* @__PURE__ */ new Map([[`Open`,`info`],[`InProgress`,`info`],[`WaitingOnCustomer`,`warning`],[`Resolved`,`success`]]);function ut(e){let t=(e??``).trim().split(/\s+/).filter(Boolean);if(t.length===0)return`?`;let n=Array.from(t[0]??``)[0]??``;return t.length===1?n.toUpperCase():`${n}${Array.from(t[t.length-1]??``)[0]??``}`.toUpperCase()}function dt(e){return lt.get(e)??`neutral`}function ft(e){for(let t=e.length-1;t>=0;--t){let n=e[t]?.author;if(n&&n.kind===`Agent`&&typeof n.displayName==`string`&&n.displayName.trim()!==``)return n.displayName}return null}function pt(e,t){return e.conversationState===`WaitingForAgent`?t.statusWaitingForAgent:e.conversationState===`WithAgent`?t.statusWithAgent(ft(e.messages)??t.handoffAgentFallback):null}function mt(e){return e.features.HumanHandoff===!0&&e.conversationState===`Open`&&e.messages.some(e=>e.author.kind===`Visitor`||e.author.kind===`Customer`)&&!e.streaming&&!e.thinking}function ht(e){if(typeof e==`object`&&e&&`message`in e)return typeof e.message==`string`?e.message:void 0}function gt({chat:e,labels:t}){let[r,i]=A(!1),[a,o]=A(null),s=e.live===`Lost`,c=mt(e);if(!c&&!s)return null;async function l(){i(!0),o(null);try{await e.requestHandoff()}catch(e){o(ht(e)||t.errorGeneric)}finally{i(!1)}}return/* @__PURE__ */ q(G,{children:[s&&/* @__PURE__ */ q(`p`,{className:`wui-chat-live-status`,role:`status`,children:[t.liveLost,` `,/* @__PURE__ */ K(n,{variant:`ghost`,size:`sm`,onClick:()=>e.session.resumeLive(),children:t.retry})]}),c&&/* @__PURE__ */ q(`div`,{className:`wui-chat-live-actions`,children:[/* @__PURE__ */ K(n,{variant:`outline`,size:`sm`,leftIcon:`user`,className:`wui-chat-handoff-request`,disabled:r,onClick:l,children:t.talkToPerson}),a&&/* @__PURE__ */ K(`p`,{className:`wui-chat-live-error`,role:`alert`,children:a})]})]})}var _t=Object.freeze({state:`idle`,answer:null,pillVisible:!1,resetsDateTimeUtc:null,offline:!1}),vt=()=>void 0,yt=()=>_t;function bt({request:e,enabled:t=!0}){let n=k(e);n.current=e;let[r,i]=A(null);T(()=>{let e=R({request:e=>{if(!(e instanceof AbortSignal))throw Error(`The explain engine did not pass an AbortSignal.`);return n.current(e)}});return i(e),()=>e.dispose()},[]);let a=C(e=>r?r.subscribe(e):vt,[r]),o=j(a,r?r.getSnapshot:yt),s=C(()=>{t&&r?.ask()},[t,r]),c=C(()=>r?.reset(),[r]),l=t?o:_t;return{state:l.state,answer:l.answer,pillVisible:l.pillVisible,resetsDateTimeUtc:l.resetsDateTimeUtc,offline:l.offline,ask:s,reset:c}}function xt(e){if(typeof e!=`string`||e===``)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}var St=20,Ct=Object.freeze({items:[],totalCount:null,loading:!1,error:null,hasMore:!1}),wt=()=>void 0,Tt=()=>Ct;function Et(e,t){let n=Date.parse(e);if(Number.isNaN(n))return``;let r=(Date.now()-n)/1e3;if(r<60)return t.justNow;let i=new Intl.RelativeTimeFormat(void 0,{numeric:`auto`});return r<3600?i.format(-Math.floor(r/60),`minute`):r<86400?i.format(-Math.floor(r/3600),`hour`):r<604800?i.format(-Math.floor(r/86400),`day`):xt(e)}function Dt({chat:e,labels:t,open:n}){let i=e.features.History===!0,a=e.client,[o,s]=A(null);T(()=>{if(!i)return;let e=L({client:a,pageSize:St});return s(e),()=>e.dispose()},[a,i]);let c=C(e=>o?o.subscribe(e):wt,[o]),l=j(c,o?o.getState:Tt);T(()=>{n&&o&&o.load().catch(e=>globalThis.reportError?.(e))},[n,o]);let u=e.features.ResumeLast?e.lastConversation?.publicId:void 0,d=l.items.filter(e=>e.publicId!==u).slice(0,St);return!i||l.error||d.length===0?null:/* @__PURE__ */ K(`div`,{className:`wui-chat-empty-rows wui-chat-past`,role:`group`,"aria-label":t.history,children:d.map(n=>/* @__PURE__ */ q(r,{className:`wui-chat-empty-row`,bodyClassName:`wui-chat-empty-row-body`,padding:`sm`,onClick:()=>e.openConversation(n.publicId).catch(e=>globalThis.reportError?.(e)),children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-empty-row-title`,children:n.title||t.earlierChat}),/* @__PURE__ */ K(`span`,{className:`wui-chat-empty-row-time`,title:xt(n.lastActivityDateTimeUtc)||void 0,children:Et(n.lastActivityDateTimeUtc,t)})]},n.publicId))})}var Ot=3;function kt({chat:e,labels:n,onOpenTicket:i}){return!e.features.OpenTickets||e.openTickets.length===0?null:/* @__PURE__ */ K(`div`,{className:`wui-chat-open-tickets`,role:`group`,"aria-label":n.openTickets,children:e.openTickets.slice(0,Ot).map(e=>{let a=/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-empty-row-label`,children:n.ticketAria(e.number)}),/* @__PURE__ */ K(`span`,{className:`wui-chat-empty-row-title`,children:e.subject}),/* @__PURE__ */ K(t,{className:`wui-chat-empty-row-status`,tone:dt(e.status),children:n.ticketStatus(e.status)||e.status})]});return i?/* @__PURE__ */ K(r,{className:`wui-chat-empty-row`,bodyClassName:`wui-chat-empty-row-body`,padding:`sm`,onClick:()=>i({ticketId:e.ticketId,number:e.number}),children:a},e.ticketId):/* @__PURE__ */ K(r,{className:`wui-chat-empty-row`,bodyClassName:`wui-chat-empty-row-body`,padding:`sm`,children:a},e.ticketId)})})}var At={Primary:`wui-chat-starter--primary`,Cta:`wui-chat-starter--cta`},jt=e=>({"--wui-chat-i":e});function Mt({chat:e,labels:t,onOpenTicket:n}){let i=e.profile;if(!i)return null;let a=i.assistant.intro,o=e.features.Starters&&!e.streaming&&e.starters.length>0,s=e.features.ResumeLast&&!e.features.History?e.lastConversation:null;return/* @__PURE__ */ q(`div`,{className:`wui-chat-empty`,role:`group`,"aria-label":t.emptyTitle,children:[/* @__PURE__ */ q(`div`,{className:`wui-chat-empty-hero`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-orb`,"aria-hidden":`true`}),e.greeting?/* @__PURE__ */ K(`h2`,{className:`wui-chat-greeting`,children:e.greeting}):null,a?/* @__PURE__ */ K(`p`,{className:`wui-chat-empty-intro`,children:a}):null]}),o&&/* @__PURE__ */ K(`div`,{className:`wui-chat-starters`,role:`group`,"aria-label":t.starters,children:e.starters.map((t,n)=>/* @__PURE__ */ q(`button`,{type:`button`,className:[`wui-chat-starter`,t.variant===null?void 0:At[t.variant]].filter(Boolean).join(` `),style:jt(n),onClick:()=>e.submit(t.message).catch(e=>globalThis.reportError?.(e)),children:[t.icon?/* @__PURE__ */ K(`span`,{className:`wui-chat-starter-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ K(l,{name:t.icon,size:16})}):null,t.label]},t.id))}),s&&/* @__PURE__ */ K(`div`,{className:`wui-chat-empty-rows`,children:/* @__PURE__ */ q(r,{className:`wui-chat-empty-row`,bodyClassName:`wui-chat-empty-row-body`,padding:`sm`,onClick:()=>e.resumeLast().catch(e=>globalThis.reportError?.(e)),children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-empty-row-label`,children:t.resumeLast}),/* @__PURE__ */ K(`span`,{className:`wui-chat-empty-row-title`,children:s.title||t.untitled}),/* @__PURE__ */ K(`span`,{className:`wui-chat-empty-row-time`,children:B(s.lastActivityDateTimeUtc)})]})}),/* @__PURE__ */ K(kt,{chat:e,labels:t,onOpenTicket:n})]})}function Nt({chat:e,labels:t}){let n=e.agentTyping;if(!n)return null;let r=typeof n==`object`&&n.displayName||ft(e.messages)||t.agent;return/* @__PURE__ */ K(`li`,{className:`wui-chat-message wui-chat-message--agent wui-chat-message--typing`,children:/* @__PURE__ */ q(`div`,{className:`wui-chat-typing`,role:`status`,children:[/* @__PURE__ */ q(`span`,{className:`wui-chat-typing-dots`,"aria-hidden":`true`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-typing-dot`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-typing-dot`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-typing-dot`})]}),/* @__PURE__ */ K(`span`,{className:`visually-hidden`,children:t.agentTyping(r)})]})})}function Pt({author:e,labels:t}){if(e.kind!==`Agent`)return null;let n=typeof e.avatarUrl==`string`&&e.avatarUrl!==``?e.avatarUrl:null;return/* @__PURE__ */ q(`div`,{className:`wui-chat-agent-head`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-avatar`,"aria-hidden":`true`,children:n?/* @__PURE__ */ K(`img`,{src:n,alt:``}):ut(e.displayName)}),/* @__PURE__ */ K(`span`,{className:`wui-chat-agent-name`,children:e.displayName||t.agent}),/* @__PURE__ */ K(`span`,{className:`wui-chat-agent-role wui-chat-agent-tag`,children:t.agent})]})}var Ft=null;function It({speech:e,enabled:t}){let n=!!(t&&e?.readAloud),[r,i]=A(!1),[a,o]=A(!1),s=k(null),c=k(null),l=k(!1);return T(()=>(l.current=!0,()=>{l.current=!1,s.current?.abort(),s.current=null,Ft===c.current&&(Ft=null),c.current=null}),[]),{available:n,speaking:r,failed:a,toggle:C(t=>{if(s.current){s.current.abort();return}if(!e||t.trim()===``)return;Ft?.();let n=new AbortController;s.current=n;let r=()=>n.abort();Ft=r,c.current=r,i(!0),o(!1),e.speak(t,{signal:n.signal}).catch(()=>{!n.signal.aborted&&l.current&&o(!0)}).finally(()=>{s.current===n&&(s.current=null),Ft===r&&(Ft=null),l.current&&i(!1)})},[e])}}var Lt=/* @__PURE__ */ new Set([`Assistant`,`Agent`,`Script`]),Rt=6e3,zt={tone:`neutral`};function Bt(e){let t=ce(e).replace(/ ?\[\d+\]/g,``).replace(/\s+/g,` `).trim();if(t.length<=Rt)return t;let n=t.slice(0,Rt),r=n.lastIndexOf(`. `);return r===-1?n.trim():n.slice(0,r+1)}function Vt({chat:t,labels:n,message:r}){let i=It({speech:He(t),enabled:t.features.ReadAloud});if(!i.available||r.streaming||!Lt.has(r.author.kind))return null;let a=r.parts.filter(e=>e.kind===`Text`),o=Bt(t.features.FigureText?a.map(e=>({...e,text:fe(e.text)})):a);if(o.trim()===``)return null;let s=i.speaking?n.readAloudStop:n.readAloud;return/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(e,{icon:`volume-high`,label:s,size:16,...i.speaking?zt:{},"aria-pressed":i.speaking,onClick:()=>i.toggle(o)}),i.failed&&/* @__PURE__ */ K(`span`,{className:`wui-chat-action-notice`,role:`status`,children:n.readAloudFailed})]})}function Ht(e){return e===`wchat:muted`?globalThis.localStorage:globalThis.sessionStorage}var Ut=/* @__PURE__ */ new Map,Wt={get(e){let t=Ut.get(e);if(t!==void 0)return t;try{return Ht(e)?.getItem(e)??null}catch{return null}},set(e,t){try{Ht(e)?.setItem(e,t),Ut.delete(e)}catch{Ut.set(e,t)}}};async function Gt(e){if(!navigator.clipboard?.writeText)return Kt(e);try{return await navigator.clipboard.writeText(e),!0}catch{return Kt(e)}}function Kt(e){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();try{return document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}async function qt(e,t){try{let n=await e.getAttachment(t.attachmentId),r=URL.createObjectURL(new Blob([n],{type:t.contentType}));return window.open(r,`_blank`,`noopener`),setTimeout(()=>URL.revokeObjectURL(r),6e4),!0}catch(e){return globalThis.reportError?.(e),!1}}function Jt(e){/^https?:\/\//i.test(e)?window.open(e,`_blank`,`noopener`):window.location.assign(e)}function Yt(e){for(let t=e?.parentElement;t&&t!==document.body;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t}return null}function Xt(e){let t=0;for(let n of e.parts)n.kind===`Text`&&(t+=n.text.length);return`${e.id}:${e.parts.length}:${t}`}function Zt(e){return e===`Reduced`?`wui-chat--reduced`:``}var Qt=[`Up`,`Down`],$t={Up:`check`,Down:`x`},en={tone:`neutral`};function tn({chat:t,message:r,labels:i,isLast:a,isLastVisitor:o}){let{features:s}=t,[c,l]=A(!1),[u,d]=A(!1),[f,p]=A(!1),m=tt(t,i),h=t.streaming||t.thinking;if(T(()=>{if(!c)return;let e=setTimeout(()=>l(!1),2e3);return()=>clearTimeout(e)},[c]),r.streaming)return null;let g=r.author.kind===`Assistant`||r.author.kind===`Agent`||r.author.kind===`Script`,_=g?ce(r.parts):``,v=g&&_!==``&&s.Copy,y=g&&_!==``&&s.ReadAloud,b=g&&_!==``&&s.Share&&m.canShare,x=g&&_!==``&&s.Print&&m.canPrint,S=a&&r.author.kind===`Assistant`&&!t.streaming&&!t.thinking&&s.Regenerate&&t.messages.some(e=>e.author.kind===`Visitor`&&e.stored),C=o&&s.Edit&&!h,w=s.Rating&&r.stored&&(r.author.kind===`Assistant`||r.author.kind===`Agent`);if(!v&&!y&&!b&&!x&&!S&&!C&&!w)return null;async function E(e){d(!1);try{await t.rate(r.id,e),p(!0)}catch{d(!0)}}return/* @__PURE__ */ q(G,{children:[v&&/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`copy`,onClick:async()=>{let e=await Gt(_);l(e)},children:c?i.copied:i.copy}),y&&/* @__PURE__ */ K(Vt,{chat:t,labels:i,message:r}),b&&/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`share`,disabled:h,onClick:()=>m.shareReply(r).catch(e=>globalThis.reportError?.(e)),children:i.share}),x&&/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`printer`,disabled:h,onClick:()=>m.printReply(r),children:i.print}),S&&/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`refresh`,onClick:()=>t.regenerate().catch(e=>globalThis.reportError?.(e)),children:i.regenerate}),C&&/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`pencil`,onClick:()=>t.startEdit(r.id),children:i.edit}),w&&/* @__PURE__ */ q(`div`,{className:`wui-chat-rating`,role:`group`,"aria-label":`${i.rateUp} / ${i.rateDown}`,children:[Qt.map(t=>/* @__PURE__ */ K(e,{icon:$t[t],label:t===`Up`?i.rateUp:i.rateDown,size:16,...r.rating===t?en:{},"aria-pressed":r.rating===t,onClick:()=>E(t)},t)),u&&/* @__PURE__ */ K(`span`,{role:`status`,children:i.ratingFailed}),f&&!u&&/* @__PURE__ */ K(`span`,{role:`status`,children:i.rated})]}),m.notice!==null&&/* @__PURE__ */ K(`span`,{className:`wui-chat-action-notice`,role:`status`,children:m.notice})]})}function nn({view:e}){return/* @__PURE__ */ q(`div`,{className:`wui-chat-loader-orb`,children:[/* @__PURE__ */ q(`span`,{className:`wui-chat-loader-orb-mark`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-orb-glow`,"aria-hidden":`true`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-orb-disc`,"aria-hidden":`true`})]}),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-orb-label`,children:e.label})]})}var rn=150;function an({view:e,motion:t}){let n=t===`Reduced`,[r,i]=A(()=>({id:0,label:e.label,previous:null}));e.label!==r.label&&i({id:r.id+1,label:e.label,previous:{id:r.id,label:r.label}}),T(()=>{if(!r.previous)return;let e=setTimeout(()=>i(e=>({...e,previous:null})),rn);return()=>clearTimeout(e)},[r.previous]);let a=n?null:r.previous;return/* @__PURE__ */ q(`div`,{className:`wui-chat-loader-phrases`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-phrases-orb`,"aria-hidden":`true`}),/* @__PURE__ */ q(`span`,{className:`wui-chat-loader-phrases-stage`,children:[a&&/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-phrases-text wui-chat-loader-phrases-text--out`,children:a.label},`out-${a.id}`),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-phrases-text wui-chat-loader-phrases-text--in`,children:r.label},`in-${r.id}`)]})]})}var on=[`92%`,`78%`,`85%`,`40%`];function sn({view:e}){return/* @__PURE__ */ q(`div`,{className:`wui-chat-loader-skeleton`,children:[/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-skeleton-label`,children:e.label}),/* @__PURE__ */ q(`div`,{className:`wui-chat-loader-skeleton-body`,children:[on.map(e=>/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-skeleton-line`,"aria-hidden":`true`,style:{width:e}},e)),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-skeleton-table`,"aria-hidden":`true`})]})]})}function cn(e,t){return e<t?`done`:e===t?`active`:`pending`}function ln(e){let t=/* @__PURE__ */ new Map;return e.map(e=>{let n=(t.get(e)??0)+1;return t.set(e,n),{key:`${e}\u0000${n}`,text:e}})}function un({state:e}){return e===`done`?/* @__PURE__ */ K(`svg`,{viewBox:`0 0 16 16`,className:`wui-chat-loader-steps-check`,"aria-hidden":`true`,children:/* @__PURE__ */ K(`path`,{d:`M3 8.5 6.5 12 13 4.5`,pathLength:1})}):e===`active`?/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-steps-ring`,"aria-hidden":`true`}):/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-steps-dot`,"aria-hidden":`true`})}function dn({view:e}){return/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-steps`,children:/* @__PURE__ */ K(`ol`,{className:`wui-chat-loader-steps-list`,children:ln(e.steps).map(({key:t,text:n},r)=>{let i=cn(r,e.activeIndex);return/* @__PURE__ */ q(`li`,{className:`wui-chat-loader-steps-item`,"data-state":i,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-steps-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ K(un,{state:i})}),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-steps-text`,children:n})]},t)})})})}var fn=500;function pn(e){if(!P.some(t=>t===e))throw Error(`ChatLoader style must be one of ${P.join(`, `)}, got "${e}".`)}function mn({style:e,view:t,motion:n}){return e===`Phrases`?/* @__PURE__ */ K(an,{view:t,motion:n}):K(e===`Orb`?nn:e===`Skeleton`?sn:dn,{view:t})}function hn({style:e=`Steps`,steps:t=[],phrases:n,intervalMs:r,announce:i,motion:a=`On`}){let o=a===`Reduced`,[s,c]=A({style:e,count:0}),[l,u]=A(!1);if(T(()=>{if(o)return;let t=setInterval(()=>c(t=>({style:e,count:t.count+1})),r);return()=>clearInterval(t)},[e,r,o]),T(()=>{let e=setTimeout(()=>u(!0),fn);return()=>clearTimeout(e)},[]),pn(e),!(r>0))throw Error(`ChatLoader needs intervalMs, a positive number of milliseconds.`);s.style!==e&&c({style:e,count:0});let d=o?0:s.count,f=ae(e,t,n,d);return/* @__PURE__ */ q(`div`,{className:o?`wui-chat-loader wui-chat-loader--reduced`:`wui-chat-loader`,role:`status`,"aria-label":f.label,children:[/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-body`,children:/* @__PURE__ */ K(mn,{style:e,view:f,motion:a})}),/* @__PURE__ */ K(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:l?i:``})]})}function gn({motion:e,mark:t}){return/* @__PURE__ */ q(`div`,{className:e===`Reduced`?`wui-chat-loader-typing wui-chat-loader--reduced`:`wui-chat-loader-typing`,"aria-hidden":`true`,children:[t===`None`?null:/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-typing-orb`,"aria-hidden":`true`}),/* @__PURE__ */ q(`span`,{className:`wui-chat-loader-typing-dots`,"aria-hidden":`true`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-typing-dot`,"aria-hidden":`true`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-typing-dot`,"aria-hidden":`true`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-typing-dot`,"aria-hidden":`true`})]})]})}var _n=`ChatLeadCapture`,vn=/^https?:\/\//i,yn={strong:`strong`,em:`em`,strike:`s`};function bn(e){return e in yn}function xn(e,t={next:0}){return e.map(e=>{let n=t.next++;if(e.type===`text`||e.type===`citation`)return e.text;if(e.type===`link`){let r=xn(e.children,t);return vn.test(e.href)?/* @__PURE__ */ K(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,children:r},n):/* @__PURE__ */ K(y,{children:r},n)}if(e.type===`code`)return/* @__PURE__ */ K(`code`,{children:e.text},n);if(bn(e.type)){let r=yn[e.type];return/* @__PURE__ */ K(r,{children:xn(e.children,t)},n)}return null})}function Sn(e,t){return e.state===`Repeat`?e.decidedDateTimeUtc?t.actionRepeat(B(e.decidedDateTimeUtc)):t.actionDone:{Confirmed:t.actionConfirmed,Done:t.actionDone,Rejected:t.actionRejected,Expired:t.actionExpired,Failed:t.actionFailed}[e.state]}function Cn(e){let t=e.indexOf(`: `);return t<0?{term:e,detail:null}:{term:e.slice(0,t),detail:e.slice(t+2)}}function wn(e,t){return{id:e,label:t,action:`Send`,target:null,navigateAfterMs:null,icon:null,variant:null}}function Tn(e){if(typeof e==`object`&&e&&`message`in e)return e.message?String(e.message):void 0}function En({part:e,turn:t}){let{labels:r,features:i}=t,a=i.LeadRecap&&e.actionKind===_n,o=e.state===`Pending`,s=e.editFields??[],c=a&&s.length>0,l=a&&e.confirmLabel||r.actionConfirm,u=a&&e.rejectLabel||r.actionDismiss,[d,f]=A(null),[p,m]=A(null),[h,g]=A(!1),_=E(),v=k(null),y=k(null),b=d!==null;T(()=>{h&&y.current?.querySelector(`[role="menuitem"]`)?.focus()},[h]);async function x(e,t){m(null),f(e);try{await t()}catch(e){m(Tn(e)||r.actionFailed),f(null)}}function S(e){g(!1),v.current?.focus(),t.chooseQuickReply(wn(`lead.edit:${e.id}`,e.label))}function C(e){let t=[...e.currentTarget.querySelectorAll(`[role="menuitem"]`)],n=e.target,r=n instanceof HTMLElement?t.indexOf(n):-1;e.key===`Escape`?(e.preventDefault(),g(!1),v.current?.focus()):e.key===`ArrowDown`?(e.preventDefault(),t[(r+1)%t.length]?.focus()):e.key===`ArrowUp`?(e.preventDefault(),t[r<=0?t.length-1:r-1]?.focus()):e.key===`Home`?(e.preventDefault(),t[0]?.focus()):e.key===`End`?(e.preventDefault(),t[t.length-1]?.focus()):e.key===`Tab`&&g(!1)}return/* @__PURE__ */ q(`div`,{className:`wui-chat-action wui-chat-action--${e.state.toLowerCase()}`,children:[/* @__PURE__ */ K(`strong`,{className:`wui-chat-action-title`,children:e.title}),e.lines.length>0&&(a?/* @__PURE__ */ K(`dl`,{className:`wui-chat-action-lines`,children:e.lines.map(e=>{let{term:t,detail:n}=Cn(e);return/* @__PURE__ */ q(`div`,{className:`wui-chat-action-line`,children:[/* @__PURE__ */ K(`dt`,{children:t}),n!==null&&/* @__PURE__ */ K(`dd`,{children:n})]},e)})}):/* @__PURE__ */ K(`ul`,{className:`wui-chat-action-lines`,children:e.lines.map(e=>/* @__PURE__ */ K(`li`,{children:e},e))})),a&&e.consentText&&/* @__PURE__ */ K(`p`,{className:`wui-chat-action-consent`,children:xn(Oe(e.consentText))}),e.note&&/* @__PURE__ */ K(`p`,{className:`wui-chat-action-note`,children:e.note}),!o&&/* @__PURE__ */ q(`p`,{className:`wui-chat-action-status wui-chat-action-status--${e.state.toLowerCase()}`,children:[Sn(e,r),e.state===`Done`&&e.decidedDateTimeUtc&&/* @__PURE__ */ q(G,{children:[` `,/* @__PURE__ */ K(`time`,{dateTime:e.decidedDateTimeUtc,children:B(e.decidedDateTimeUtc)})]})]}),(o||c)&&/* @__PURE__ */ q(`div`,{className:`wui-chat-action-buttons`,children:[o&&/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(n,{size:`sm`,disabled:b,onClick:()=>x(`confirm`,()=>t.confirmAction(e.actionId)),children:d===`confirm`?r.actionWorking:l}),/* @__PURE__ */ K(n,{variant:`soft`,size:`sm`,disabled:b,onClick:()=>x(`reject`,()=>t.rejectAction(e.actionId)),children:u})]}),c&&/* @__PURE__ */ K(n,{ref:v,variant:`soft`,size:`sm`,className:`wui-chat-action-edit`,"aria-haspopup":`menu`,"aria-expanded":h,"aria-controls":h?_:void 0,disabled:!o||b,onClick:()=>g(e=>!e),children:r.editSomething})]}),c&&h&&/* @__PURE__ */ K(`ul`,{id:_,ref:y,className:`list-group wui-chat-action-menu`,role:`menu`,"aria-label":r.editSomething,onKeyDown:C,children:s.map(e=>/* @__PURE__ */ K(`li`,{role:`none`,children:/* @__PURE__ */ K(`button`,{className:`list-group-item list-group-item-action wui-chat-action-menu-item`,type:`button`,role:`menuitem`,tabIndex:-1,onClick:()=>S(e),children:e.label})},e.id))}),p&&/* @__PURE__ */ K(`p`,{className:`wui-chat-action-error`,role:`alert`,children:p})]})}function Z({text:e,enabled:t}){if(!t||typeof e!=`string`)return e;let n=0;return/* @__PURE__ */ K(G,{children:de(e).map(e=>{let t=`${n}-${e.kind}`;return n+=e.text.length,e.kind===`sub`?/* @__PURE__ */ K(`sub`,{children:e.text},t):e.kind===`sup`?/* @__PURE__ */ K(`sup`,{children:e.text},t):/* @__PURE__ */ K(y,{children:e.text},t)})})}function Dn(e,t){return t&&typeof e==`string`?fe(e):e}var On={Bar:`column`,Line:`line`,Donut:`donut`},kn=8,An=4;function jn({part:e,turn:t}){let[r,a]=A(`chart`),o=t.features.FigureText,s=e.chartType===`Donut`?e.series.slice(0,1):e.series.slice(0,kn),c=s.map(e=>new Map(e.points.map(e=>[e.label,e.value]))),l=[...new Set(s.flatMap(e=>e.points.map(e=>e.label)))].map(e=>{let t={label:Dn(e,o)};return c.forEach((n,r)=>{t[`s${r}`]=n.get(e)??null}),t}),u=e.unit?Dn(e.unit,o):null,d=s.map((e,t)=>{let n=Dn(e.name,o);return{key:`s${t}`,label:n,format:{style:`number`}}}),f=e.chartType!==`Donut`&&u?{label:u}:void 0,p=Math.max(0,...s.map(e=>e.points.length)),m=e.chartType===`Bar`&&p>An?300:240;return/* @__PURE__ */ q(`figure`,{className:`wui-chat-chart`,children:[e.title?/* @__PURE__ */ K(`figcaption`,{className:`wui-chat-rich-title`,children:/* @__PURE__ */ K(Z,{text:e.title,enabled:o})}):null,/* @__PURE__ */ K(i,{type:On[e.chartType],title:(e.title?Dn(e.title,o):``)||t.labels.chart,data:l,x:{key:`label`},series:d,...f===void 0?{}:{y:f},height:m,view:r,errorText:t.labels.chartLoadFailed}),l.length>0&&/* @__PURE__ */ K(n,{variant:`link`,size:`sm`,className:`wui-chat-chart-toggle`,"aria-pressed":r===`table`,onClick:()=>a(r===`table`?`chart`:`table`),children:r===`table`?t.labels.chartShowChart:t.labels.chartShowTable})]})}var Mn={Neutral:`neutral`,Positive:`success`,Caution:`warning`,Negative:`danger`},Nn=/* @__PURE__ */ new Set([`Positive`,`Caution`,`Negative`]),Pn=.001;function Fn(e){return e<=3?3:e===4?4:5}function In(e){let t=0;return e.map(e=>{let n=`${t}-${e.kind}`;return t+=e.text.length,e.kind===`sub`?/* @__PURE__ */ K(`sub`,{children:e.text},n):e.kind===`sup`?/* @__PURE__ */ K(`sup`,{children:e.text},n):/* @__PURE__ */ K(`span`,{children:e.text},n)})}function Ln(e,t){let n=e.value!==0&&Math.abs(e.value)<Pn?In(H(e.value)):je(e.value),r=Nn.has(e.status)?/* @__PURE__ */ K(`span`,{className:`visually-hidden`,children:t.figureStatus(e.status)}):null;return e.unit?/* @__PURE__ */ q(G,{children:[n,` `,/* @__PURE__ */ K(`span`,{className:`wui-chat-figure-unit`,children:In(de(e.unit))}),r]}):/* @__PURE__ */ q(G,{children:[n,r]})}function Rn({part:e,turn:t}){if(e.figures.length===0)return null;let n=Fn(e.figures.length),r=e.figures.map(e=>({label:/* @__PURE__ */ K(Z,{text:e.label,enabled:!0}),value:Ln(e,t.labels),tone:Mn[e.status]}));return/* @__PURE__ */ K(`div`,{className:`wui-chat-figures`,role:`group`,"aria-label":t.labels.figures,children:/* @__PURE__ */ K(p,{className:`wui-chat-figures-strip`,size:`sm`,columns:n,items:r})})}function zn({part:e,turn:t}){let n=/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(`span`,{children:/* @__PURE__ */ K(l,{name:`document-text`,size:16})}),/* @__PURE__ */ K(`span`,{className:`wui-chat-file-name`,children:e.fileName}),/* @__PURE__ */ K(`span`,{className:`wui-chat-file-size`,children:U(e.length)})]});return/* @__PURE__ */ K(`div`,{className:`wui-chat-file`,children:t.openAttachment?/* @__PURE__ */ K(`button`,{className:`wui-chat-file-chip`,type:`button`,"aria-label":t.labels.fileOpen(e.fileName),onClick:()=>t.openAttachment?.(e),children:n}):/* @__PURE__ */ K(`span`,{className:`wui-chat-file-chip`,children:n})})}var Bn=/* @__PURE__ */ new Set([`Requested`,`Waiting`,`Joined`]);function Vn({part:e,turn:t}){if(t.handoffSettled===!0&&(e.state===`Requested`||e.state===`Waiting`))return null;let{labels:n}=t,r=e.agent?.displayName||null,i=e.agent?.avatarUrl||null,a=e.state.toLowerCase(),o=t.isLast&&(e.state===`Requested`||e.state===`Waiting`);return/* @__PURE__ */ q(`div`,{className:`wui-chat-handoff wui-chat-handoff--${a}${o?` wui-chat-handoff--live`:``}`,role:t.isLast&&Bn.has(e.state)?`status`:void 0,children:[e.state===`Requested`&&/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ q(`span`,{className:`wui-chat-handoff-pulses`,"aria-hidden":`true`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-pulse`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-pulse`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-pulse`})]}),/* @__PURE__ */ K(`p`,{className:`wui-chat-handoff-text`,children:n.handoffRequested})]}),e.state===`Waiting`&&/* @__PURE__ */ q(G,{children:[typeof e.queuePosition!=`number`&&/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ q(`span`,{className:`wui-chat-handoff-pulses`,"aria-hidden":`true`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-pulse`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-pulse`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-pulse`})]}),/* @__PURE__ */ K(`p`,{className:`wui-chat-handoff-text`,children:n.handoffWaiting})]}),typeof e.queuePosition==`number`&&/* @__PURE__ */ K(`p`,{className:`wui-chat-handoff-queue`,children:n.handoffQueued(e.queuePosition)}),/* @__PURE__ */ K(`p`,{className:`wui-chat-handoff-note`,children:n.handoffQueuedText})]}),e.state===`Joined`&&/* @__PURE__ */ q(G,{children:[i?/* @__PURE__ */ K(`img`,{className:`wui-chat-handoff-avatar`,src:i,alt:``,"aria-hidden":`true`,width:32,height:32}):/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-avatar`,"aria-hidden":`true`,children:ut(r)}),/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-online`,"aria-hidden":`true`}),/* @__PURE__ */ K(`strong`,{className:`wui-chat-handoff-title`,children:n.handoffJoined(r??n.handoffAgentFallback)}),/* @__PURE__ */ K(`p`,{className:`wui-chat-handoff-text`,children:n.handoffJoinedText(r??n.handoffAgentFallback)})]}),e.state===`Left`&&/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(`strong`,{className:`wui-chat-handoff-title`,children:n.handoffLeft(r??n.handoffAgentFallback)}),/* @__PURE__ */ K(`p`,{className:`wui-chat-handoff-text`,children:n.handoffLeftText})]}),e.state===`Ended`&&/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(`p`,{className:`wui-chat-handoff-text`,children:n.handoffEnded}),/* @__PURE__ */ K(`p`,{className:`wui-chat-handoff-text`,children:n.handoffEndedText})]})]})}function Hn({part:e,loadAttachmentUrl:t,turn:r}){let[i,a]=A({status:`loading`,url:null}),o=k(0),s=C(e=>{let n=++o.current;a({status:`loading`,url:null}),t(e).then(e=>{o.current===n&&a({status:`ready`,url:e})},()=>{o.current===n&&a({status:`failed`,url:null})})},[t]);return T(()=>(s(e.attachmentId),()=>{o.current++}),[s,e.attachmentId]),i.status===`loading`?/* @__PURE__ */ q(`div`,{className:`wui-chat-image-loading`,role:`status`,children:[/* @__PURE__ */ K(`span`,{className:`visually-hidden`,children:r.labels.imageLoading}),/* @__PURE__ */ K(g,{height:160,radius:8})]}):i.status===`failed`?/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(`p`,{className:`wui-chat-image-error`,role:`status`,children:r.labels.imageFailed}),/* @__PURE__ */ K(n,{variant:`soft`,tone:`primary`,size:`sm`,onClick:()=>s(e.attachmentId),children:r.labels.retry})]}):/* @__PURE__ */ K(d,{className:`wui-chat-image-view`,label:r.labels.imageViewer,items:[{key:e.attachmentId,src:i.url,alt:e.alt,name:e.alt}],download:!1,layout:`single`})}function Un({part:e,turn:t}){let n=e.width&&e.height?{aspectRatio:`${e.width} / ${e.height}`}:void 0;return typeof t.loadAttachmentUrl==`function`?/* @__PURE__ */ K(`figure`,{className:`wui-chat-image`,style:n,children:/* @__PURE__ */ K(Hn,{part:e,loadAttachmentUrl:t.loadAttachmentUrl,turn:t},e.attachmentId)}):/* @__PURE__ */ K(`figure`,{className:`wui-chat-image`,style:n,children:/* @__PURE__ */ K(`span`,{className:`wui-chat-image-alt`,children:e.alt})})}var Wn={Email:{type:`email`,autoComplete:`email`},Phone:{type:`tel`,autoComplete:`tel`},Name:{type:`text`,autoComplete:`name`},Company:{type:`text`,autoComplete:`organization`},Text:{type:`text`,autoComplete:void 0}},Gn=new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`,month:`short`,hour:`numeric`,minute:`2-digit`});function Kn(e,t){return e.state===`Answered`?e.answeredSummary||t.inputAnswered:e.state===`Skipped`?t.inputSkipped:t.inputExpired}function qn(e){return e.type===`Consent`?!1:e.type===`MultiChoice`?[]:``}function Jn(e){return Object.fromEntries(e.map(e=>[e.key,qn(e)]))}function Yn(e){return typeof e==`string`?e:``}function Xn(e){return typeof e==`object`?e:[]}function Zn(e,t){let n=Yn(t);return e.secret?n:n.trim()}function Qn(e,t,n){return e.required?e.type===`Consent`?t?null:n.inputConsentRequired:e.type===`MultiChoice`?Xn(t).length>0?null:n.inputRequired:Zn(e,t)?null:n.inputRequired:null}function $n(e,t){if(e.type===`Consent`)return t?`true`:`false`;if(e.type===`MultiChoice`){let n=Xn(t);return JSON.stringify((e.options??[]).map(e=>e.id).filter(e=>n.includes(e)))}return e.type===`Choice`||e.type===`TimeSlot`?Yn(t):Zn(e,t)}function er({field:e,value:t,error:r,file:i,disabled:o,id:s,labels:c,onChange:l,onFile:d,onRemove:f,controlRef:p}){let m=`${s}-error`,g=m,v=r?`true`:void 0,y=e.required||void 0,b=/* @__PURE__ */ K(`p`,{className:`wui-chat-field-error`,id:m,role:`alert`,hidden:!r,children:r}),x=e.required?null:/* @__PURE__ */ K(`span`,{className:`wui-chat-field-hint`,children:c.inputOptional});if(e.type===`Choice`){let n=`${s}-label`;return/* @__PURE__ */ q(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ K(`span`,{className:`form-label`,id:n,children:e.label}),x,/* @__PURE__ */ K(`div`,{role:`radiogroup`,"aria-labelledby":n,"aria-invalid":v,"aria-describedby":g,children:(e.options??[]).map((n,r)=>{let i=`${s}-${n.id}`;return/* @__PURE__ */ K(h,{id:i,name:e.key,value:n.id,label:n.label,checked:t===n.id,disabled:o,onChange:()=>l(n.id),ref:r===0?p:void 0},n.id)})}),b]})}if(e.type===`MultiChoice`){let n=`${s}-label`;return/* @__PURE__ */ q(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ K(`span`,{className:`form-label`,id:n,children:e.label}),x,/* @__PURE__ */ K(`div`,{className:`wui-chat-input-choices`,role:`group`,"aria-labelledby":n,"aria-invalid":v,"aria-describedby":g,children:(e.options??[]).map((n,r)=>{let i=`${s}-${n.id}`;return/* @__PURE__ */ K(a,{id:i,name:e.key,value:n.id,label:n.label,checked:Xn(t).includes(n.id),disabled:o,onChange:e=>l(e.target.checked?[...Xn(t),n.id]:Xn(t).filter(e=>e!==n.id)),ref:r===0?p:void 0},n.id)})}),b]})}if(e.type===`TimeSlot`){let r=`${s}-label`;return/* @__PURE__ */ q(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ K(`span`,{className:`form-label`,id:r,children:e.label}),x,/* @__PURE__ */ K(`div`,{className:`wui-chat-input-slots d-flex flex-wrap gap-2`,role:`radiogroup`,"aria-labelledby":r,"aria-invalid":v,"aria-describedby":g,children:(e.slots??[]).map((r,i)=>{let a=`${s}-${r.id}`,c=`${a}-label`;return/* @__PURE__ */ q(`div`,{className:`wui-chat-input-slot`,children:[/* @__PURE__ */ K(`input`,{className:`btn-check`,type:`radio`,id:a,name:e.key,value:r.id,checked:t===r.id,disabled:o,"aria-labelledby":c,onChange:()=>l(r.id),ref:i===0?p:void 0}),/* @__PURE__ */ K(n,{as:`label`,id:c,variant:`soft`,className:`wui-chat-input-slot`,disabled:o,onClick:()=>l(r.id),children:Gn.format(new Date(r.startDateTimeUtc))})]},r.id)})}),b]})}if(e.type===`File`){let t=i?.status===`uploading`,r=`${s}-label`;return/* @__PURE__ */ q(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ K(`label`,{className:`form-label`,id:r,htmlFor:s,children:e.label}),x,/* @__PURE__ */ K(`span`,{className:t?`wui-chat-input-file-status`:`visually-hidden`,"aria-live":`polite`,children:t?c.attachmentUploading:``}),/* @__PURE__ */ K(`div`,{role:`group`,"aria-labelledby":r,children:i?/* @__PURE__ */ q(`div`,{className:`wui-chat-input-file`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-input-file-name`,children:i.name}),/* @__PURE__ */ K(n,{variant:`link`,type:`button`,disabled:o,onClick:f,ref:p,children:c.inputRemoveFile(i.name)})]}):/* @__PURE__ */ K(u,{controlOnly:!0,className:`wui-chat-input-control`,type:`file`,id:s,name:e.key,accept:e.accept?.join(`,`),disabled:o,"aria-label":c.inputChooseFile,"aria-required":y,"aria-invalid":v,"aria-describedby":g,onChange:e=>{let t=e.target.files?.[0];t&&d(t)},ref:p})}),b]})}if(e.type===`Consent`)return/* @__PURE__ */ q(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ K(a,{id:s,name:e.key,label:e.consentText||e.label,checked:t===!0,disabled:o,"aria-invalid":v,"aria-describedby":g,onChange:e=>l(e.target.checked),ref:p}),b]});let S=Wn[e.type],C=e.type===`LongText`&&!e.secret?/* @__PURE__ */ K(_,{controlOnly:!0,className:`wui-chat-input-control`,id:s,name:e.key,rows:3,value:Yn(t),placeholder:e.placeholder??void 0,maxLength:e.maxLength??void 0,disabled:o,"aria-required":y,"aria-invalid":v,"aria-describedby":g,onChange:e=>l(e.target.value),ref:p}):/* @__PURE__ */ K(u,{controlOnly:!0,className:`wui-chat-input-control`,id:s,name:e.key,type:e.secret?`password`:S?.type,autoComplete:e.secret?`off`:S?.autoComplete,value:Yn(t),placeholder:e.placeholder??void 0,maxLength:e.maxLength??void 0,disabled:o,"aria-required":y,"aria-invalid":v,"aria-describedby":g,onChange:e=>l(e.target.value),ref:p});return/* @__PURE__ */ q(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ K(`label`,{className:`form-label`,htmlFor:s,children:e.label}),x,C,b]})}function tr({part:e,turn:t}){let{labels:r,features:i}=t,a=E(),[o,s]=A(()=>Jn(e.fields)),[l,u]=A({}),[d,f]=A(null),[p,m]=A(!1),[h,g]=A(null),[_,v]=A({}),y=k({}),b=k({});T(()=>{h?.key!==void 0&&y.current[h.key]?.focus()},[h]);let x=e.fields.length===1?e.fields[0]:void 0,S=i.LeadShortcuts&&x!==void 0&&!x.required,C=i.LeadShortcuts&&e.cancellable,w=Object.keys(_).find(e=>_[e]?.status===`uploading`);function D(t){return e.fields.find(e=>t[e.key])?.key??e.fields[0]?.key}function O(e,t){s(n=>({...n,[e]:t}))}function j(e){let t=o[e];if(t===void 0)throw Error(`The input form has no value for field "${e}".`);return t}async function M(e,n){let i={};b.current[e]=i,v(t=>({...t,[e]:{status:`uploading`,name:n.name}})),O(e,``),u(t=>({...t,[e]:void 0}));let a;try{a=await t.uploadInputFile(n)}catch{if(b.current[e]!==i)return;v(t=>({...t,[e]:{status:`failed`,name:n.name}})),u(t=>({...t,[e]:r.attachmentFailed}));return}b.current[e]===i&&(O(e,a),v(t=>({...t,[e]:{status:`ready`,name:n.name}})),u(t=>({...t,[e]:void 0})))}function N(e){b.current[e]=null,O(e,``),v(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e))),u(t=>({...t,[e]:void 0}))}async function ee(){if(w!==void 0)return u(e=>({...e,[w]:r.attachmentUploading})),g({key:w}),!1;let n={};for(let t of e.fields){let e=t.type===`File`&&_[t.key]?.status===`failed`?r.attachmentFailed:Qn(t,j(t.key),r);e&&(n[t.key]=e)}if(f(null),u(n),Object.keys(n).length>0)return g({key:D(n)}),!1;m(!0);let i=Object.fromEntries(e.fields.map(e=>[e.key,$n(e,j(e.key))])),a;try{a=await t.answerInput(e.requestId,i)}catch{a={ok:!1,errors:{},message:r.errorGeneric}}if(a.ok)return!0;let o=Object.entries(a.errors).filter(([t])=>!e.fields.some(e=>e.key===t)).map(([,e])=>e),s=[a.message,...o].filter(Boolean);return u(a.errors),f(s.length>0?s.join(` `):null),m(!1),g({key:D(a.errors)}),!1}return/* @__PURE__ */ q(c,{className:`wui-chat-input-form`,noValidate:!0,"aria-label":e.title||e.submitLabel,onSubmit:ee,children:[e.title&&/* @__PURE__ */ K(`h3`,{className:`wui-chat-input-title`,children:e.title}),e.fields.map(e=>/* @__PURE__ */ K(er,{field:e,value:j(e.key),error:l[e.key],file:_[e.key],disabled:p,id:`${a}-${e.key}`,labels:r,onChange:t=>O(e.key,t),onFile:t=>M(e.key,t),onRemove:()=>N(e.key),controlRef:t=>{y.current[e.key]=t}},e.key)),/* @__PURE__ */ K(`p`,{className:`wui-chat-input-error`,role:`status`,hidden:!d,children:d}),/* @__PURE__ */ q(`div`,{className:`d-flex flex-wrap gap-2`,children:[/* @__PURE__ */ K(n,{type:`submit`,disabled:p,children:p?r.inputSubmitting:e.submitLabel}),S&&/* @__PURE__ */ K(n,{variant:`soft`,disabled:p,onClick:()=>t.skipInput(e.requestId),children:r.skip}),C&&/* @__PURE__ */ K(n,{variant:`link`,type:`button`,disabled:p,onClick:()=>t.cancelLead(),children:r.cancel})]}),e.allowTyped&&/* @__PURE__ */ K(`p`,{className:`wui-chat-input-typed`,children:r.typeAnswer})]})}function nr({part:e,turn:t}){let n=`wui-chat-input-request wui-chat-input-request--${e.state.toLowerCase()}`;return/* @__PURE__ */ K(`div`,{className:n,children:e.state===`Open`?/* @__PURE__ */ K(tr,{part:e,turn:t},e.requestId):/* @__PURE__ */ K(`p`,{className:`wui-chat-input-summary`,children:Kn(e,t.labels)})})}var rr=/* @__PURE__ */ new Set([`ActionLimitReached`,`ConversationTooLong`]),ir={AssistantUnavailable:`danger`},ar={info:`info`,warning:`alert-triangle`,danger:`alert-circle`};function or({part:e,turn:t}){let n=ir[e.code]??(rr.has(e.code)?`warning`:`info`),r=e.code===`NeedsNewerApp`?t.labels.needsNewerApp:e.text;return/* @__PURE__ */ q(`div`,{className:`wui-chat-notice wui-chat-notice--${n}`,role:n===`danger`?`alert`:`status`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-notice-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ K(l,{name:ar[n],size:16})}),/* @__PURE__ */ K(`span`,{className:`wui-chat-notice-text`,children:r})]})}var sr=x({resolveLink:null,linkComponent:void 0});function cr(){return w(sr)}var lr={Primary:`wui-chat-quick-reply--primary`,Cta:`wui-chat-quick-reply--cta`};function ur(e){return e===null?void 0:lr[e]}function dr(e,t){return e.action===`Navigate`?!!t.features.LinkHandoff:e.action!==`Open`||!!e.target&&!!t.openTarget}function fr(e,t){return[`wui-chat-quick-reply`,ur(e.variant),t].filter(Boolean).join(` `)}function pr(e,t,n){return e.target===null||!W(e.target,t.handoffHosts)?null:n?n(e.target)??null:e.target}function mr(e){return e.icon?/* @__PURE__ */ K(`span`,{className:`wui-chat-quick-reply-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ K(l,{name:e.icon,size:16})}):null}function hr(e,t,n,r){return/* @__PURE__ */ q(`button`,{type:`button`,className:r,style:n,onClick:n=>{if(e.action===`Open`){if(!t.openTarget)throw Error(`An Open quick reply needs turn.openTarget, and the turn has none.`);e.target&&t.openTarget(e.target)}else t.chooseQuickReply(e),n.currentTarget.closest(`.wui-chat`)?.querySelector(`.wui-chat-input`)?.focus()},children:[mr(e),/* @__PURE__ */ K(`span`,{className:`wui-chat-quick-reply-label`,children:e.label})]},e.id)}function gr(e,t,n){if(!t.features.SuggestedReplies||!t.isLast||t.busy||e.replies.length===0)return null;let r=e.placement===`Composer`?`wui-chat-quick-replies wui-chat-quick-replies--composer`:`wui-chat-quick-replies`,i=e.replies.filter(e=>dr(e,t));if(i.length===0)return null;let a=t.openTarget??(e=>globalThis.location.assign(e)),o=e.placement===`Composer`?void 0:i.find(e=>e.id===N&&e.action===`Send`);return/* @__PURE__ */ q(`div`,{className:o?`${r} wui-chat-quick-replies--offer`:r,role:`group`,"aria-label":t.labels.quickReplies,children:[o&&/* @__PURE__ */ q(`div`,{className:`wui-chat-offer`,children:[/* @__PURE__ */ K(`div`,{className:`wui-chat-offer-title`,children:o.label}),hr(o,t,{"--wui-chat-i":0},fr({...o,variant:`Primary`},`wui-chat-offer-action`))]}),i.map((e,r)=>{if(e===o)return null;let i={"--wui-chat-i":r};if(e.action===`Navigate`){let r=pr(e,t,n);if(r===null)return/* @__PURE__ */ K(`span`,{className:`wui-chat-quick-reply-label`,style:i,children:e.label},e.id);if(typeof t.beginHandoff!=`function`)return null;let o=()=>a(r);return/* @__PURE__ */ q(`button`,{type:`button`,disabled:t.handoffPause,className:fr(e,t.handoffPause?`wui-chat-quick-reply--quiet`:void 0),style:i,onClick:()=>t.beginHandoff(e,o),children:[mr(e),/* @__PURE__ */ K(`span`,{className:`wui-chat-quick-reply-label`,children:t.handoffPause?t.labels.handoffMoment:e.label})]},e.id)}return hr(e,t,i,fr(e,o?`wui-chat-quick-reply--quiet`:void 0))})]})}function _r({part:e,turn:t}){let{resolveLink:n}=cr(),r=gr(e,t,n),i=k(null),[a,o]=A(null),s=k(null);return D(()=>{r?i.current=r:i.current&&=(o(i.current),null)}),T(()=>{if(!a)return;let e=s.current,t=e?.ownerDocument.defaultView;if(!t||!e){o(null);return}let n=Number.parseFloat(t.getComputedStyle(e).animationDuration)*1e3;if(!(n>0)){o(null);return}let r=t.setTimeout(()=>o(null),n);return()=>t.clearTimeout(r)},[a]),r||(a?b(a,{ref:s,className:`${a.props.className} wui-chat-quick-replies--leaving`,"aria-hidden":`true`}):null)}var vr=/* @__PURE__ */ new Set([`Integer`,`Decimal`,`MoneyMinor`,`Percent`]);function yr(e){return e.value===null||e.value===void 0||e.value===``?ke():e.type===`Date`?Ae(e.value,{pattern:`day`}):e.type===`DateTimeUtc`?J(e.value):re(e.value,e.type,null)}function br({part:e,turn:t}){let r=E(),i=t.features.FigureText,a=e.fields.map((e,t)=>({key:String(t),label:/* @__PURE__ */ K(Z,{text:e.label,enabled:i}),value:/* @__PURE__ */ K(`span`,{className:vr.has(e.type)?`wui-chat-num`:void 0,children:/* @__PURE__ */ K(Z,{text:yr(e),enabled:i})})})),o=!!e.target&&typeof t.openRecord==`function`;return/* @__PURE__ */ q(`article`,{className:`wui-chat-record`,"aria-labelledby":r,children:[/* @__PURE__ */ q(`header`,{className:`wui-chat-record-head`,children:[/* @__PURE__ */ K(`h3`,{className:`wui-chat-record-title`,id:r,children:/* @__PURE__ */ K(Z,{text:e.title,enabled:i})}),e.subtitle?/* @__PURE__ */ K(`span`,{className:`wui-chat-record-subtitle`,children:/* @__PURE__ */ K(Z,{text:e.subtitle,enabled:i})}):null]}),e.fields.length>0?/* @__PURE__ */ K(s,{className:`wui-chat-record-fields`,columns:1,size:`sm`,layout:`summary`,items:a}):null,o?/* @__PURE__ */ K(`div`,{className:`wui-chat-record-actions`,children:/* @__PURE__ */ K(n,{className:`wui-chat-record-open`,size:`sm`,type:`button`,"aria-label":t.labels.recordOpenFor(fe(e.title)),onClick:()=>t.openRecord?.(e),children:t.labels.recordOpen})}):null]})}var xr=/^https?:\/\//i;function Sr({source:e}){return/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-source-marker`,children:e.marker}),/* @__PURE__ */ K(`span`,{className:`wui-chat-source-title`,children:e.title})]})}function Cr({part:e,turn:t}){return!t.features.Sources||e.sources.length===0?null:/* @__PURE__ */ q(`div`,{className:`wui-chat-sources`,children:[/* @__PURE__ */ K(`p`,{className:`wui-chat-sources-label`,children:t.labels.sources}),/* @__PURE__ */ K(`ul`,{className:`wui-chat-sources-list`,"aria-label":t.labels.sources,children:e.sources.map(e=>/* @__PURE__ */ K(`li`,{children:xr.test(e.url??``)?/* @__PURE__ */ K(`a`,{className:`wui-chat-source`,href:e.url??void 0,target:`_blank`,rel:`noopener noreferrer`,"aria-label":t.labels.openSource(e.title),"data-marker":e.marker,children:/* @__PURE__ */ K(Sr,{source:e})}):/* @__PURE__ */ K(`span`,{className:`wui-chat-source`,tabIndex:-1,"data-marker":e.marker,children:/* @__PURE__ */ K(Sr,{source:e})})},e.marker))})]})}var wr=/* @__PURE__ */ new Set([`Integer`,`Decimal`,`MoneyMinor`,`Percent`]),Tr=50,Er=25,Dr={align:`num`},Or={rowHeader:!0};function kr(e,t,n,r){return e==null?null:t.type===`Text`&&e!==``?/* @__PURE__ */ K(Z,{text:e,enabled:r}):re(e,t.type,n)}function Ar({part:e,turn:t}){let[r,i]=A(!1),a=t.features.FigureText,s=e.columns.map((e,t)=>({key:`c${t}`,label:/* @__PURE__ */ K(Z,{text:e.label,enabled:a}),...wr.has(e.type)?Dr:{},...t===0&&e.type===`Text`?Or:{}})),c=e.rows.map((t,n)=>{let r={id:n};return e.columns.forEach((n,i)=>{r[`c${i}`]=kr(t[i],n,e.currency,a)}),r}),l=r?c:c.slice(0,Er),u=l.length>Tr,d=e.title?Dn(e.title,a):t.labels.table;return/* @__PURE__ */ q(`figure`,{className:`wui-chat-table`,children:[e.title?/* @__PURE__ */ K(`figcaption`,{className:`wui-chat-table-title`,children:/* @__PURE__ */ K(Z,{text:e.title,enabled:a})}):null,/* @__PURE__ */ K(`div`,{className:`table-wrap wui-chat-table-wrap`,role:`region`,tabIndex:0,"aria-label":d,children:/* @__PURE__ */ K(o,{density:`cozy`,columns:s,rows:l,rowKey:(e,t)=>t,empty:t.labels.tableEmpty,...u?{maxHeight:360}:{},virtual:u})}),!r&&c.length>Er&&/* @__PURE__ */ K(n,{variant:`soft`,tone:`primary`,size:`sm`,className:`wui-chat-table-more`,onClick:()=>i(!0),children:t.labels.tableShowAll(c.length)})]})}var jr=/* @__PURE__ */ new Set([`Visitor`,`Customer`]),Mr=/^\d+$/;function Nr({part:e,message:t,turn:n}){let{resolveLink:r,linkComponent:i}=cr(),a=n.features.FigureText,o=n.features.Sources===!0;if(jr.has(t.author.kind))return/* @__PURE__ */ K(`div`,{className:t.restored?`wui-chat-bubble`:`wui-chat-bubble wui-chat-part-enter`,children:/* @__PURE__ */ K(Z,{text:e.text,enabled:a})});let s=n.handoffHosts,c=e=>W(e,s)?e:r?r(e):null,l=o&&n.openCitation?e=>n.openCitation?.(Number(e)):void 0,u=o?n.isCitation??(e=>Mr.test(e)):()=>!1;return/* @__PURE__ */ K(f,{value:e.text,links:`app`,headings:`text`,className:t.restored?`wui-chat-text`:`wui-chat-text wui-chat-part-enter`,resolveLink:c,linkComponent:i,isCitation:u,...a?{figureText:de}:{},...l?{onOpenCitation:l}:{}})}function Pr({part:e,turn:r}){let{labels:i}=r,a=i.ticketStatus(e.status);return/* @__PURE__ */ q(`article`,{className:`wui-chat-ticket`,"aria-label":i.ticketAria(e.number),children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-ticket-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ K(l,{name:`tag`,size:20})}),/* @__PURE__ */ q(`div`,{className:`wui-chat-ticket-body`,children:[/* @__PURE__ */ q(`div`,{className:`wui-chat-ticket-head`,children:[/* @__PURE__ */ K(`b`,{className:`wui-chat-ticket-number`,children:i.ticketAria(e.number)}),a&&/* @__PURE__ */ K(t,{className:`wui-chat-ticket-status`,tone:dt(e.status),children:a})]}),/* @__PURE__ */ K(`strong`,{className:`wui-chat-ticket-title`,children:e.subject})]}),r.openTicket&&/* @__PURE__ */ K(n,{variant:`outline`,size:`sm`,className:`wui-chat-ticket-open`,onClick:()=>r.openTicket?.(e),children:i.ticketView})]})}var Fr=40,Ir=null;function Lr({part:e,turn:t}){let[n,r]=A(!1),[i,a]=A(!1),[o,s]=A(!1),[c,u]=A(!1),[d,f]=A(0),p=k(null),m=k(null),h=k(!1),g=O(()=>me(`${e.attachmentId}|${e.durationMs}`,Fr).map((e,t)=>({id:`bar-${t}`,position:t,height:e})),[e.attachmentId,e.durationMs]),_=C(()=>{p.current?.pause(),Ir===_&&(Ir=null),a(!1)},[]);if(T(()=>(h.current=!0,()=>{h.current=!1,p.current?.pause(),m.current&&URL.revokeObjectURL(m.current),Ir===_&&(Ir=null)}),[_]),!t.features.VoiceClips)return e.transcript?/* @__PURE__ */ K(`p`,{className:`wui-chat-clip-transcript`,children:e.transcript}):null;async function v(){if(i)_();else{r(!0),s(!1);try{if(!p.current){let n=await t.readAttachment(e.attachmentId);if(!h.current)return;m.current=URL.createObjectURL(new Blob([n]));let r=new Audio(m.current);r.addEventListener(`timeupdate`,()=>f(r.currentTime)),r.addEventListener(`ended`,()=>{a(!1),f(0),r.currentTime=0,Ir===_&&(Ir=null)}),r.addEventListener(`error`,()=>{s(!0),a(!1)}),p.current=r}Ir?.(),await p.current.play(),Ir=_,a(!0)}catch{s(!0)}finally{h.current&&r(!1)}}}let y=e.durationMs/1e3,b=Math.floor((y>0?Math.min(1,d/y):0)*Fr);return/* @__PURE__ */ q(`div`,{className:`wui-chat-clip`,role:`group`,"aria-label":t.labels.voiceClip,children:[/* @__PURE__ */ q(`div`,{className:`wui-chat-clip-row`,children:[/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-clip-play`,"aria-label":i?t.labels.voiceClipPause:t.labels.voiceClipPlay,"aria-busy":n,disabled:n,onClick:v,children:/* @__PURE__ */ K(l,{name:i?`pause`:`play`,size:16,"aria-hidden":`true`})}),/* @__PURE__ */ K(`div`,{className:`wui-chat-clip-wave`,"aria-hidden":`true`,children:g.map(({id:e,position:t,height:n})=>{let r={"--wui-chat-bar-height":`${Math.round(n*100)}%`};return/* @__PURE__ */ K(`span`,{className:t<b?`wui-chat-clip-bar wui-chat-clip-bar--played`:`wui-chat-clip-bar`,style:r},e)})}),/* @__PURE__ */ K(`span`,{className:`wui-chat-clip-time`,children:t.labels.voiceClipTime(V(d),V(Math.max(1,Math.round(y))))})]}),o&&/* @__PURE__ */ K(`p`,{className:`wui-chat-clip-error`,role:`status`,children:t.labels.voiceClipFailed}),e.transcript?/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-clip-toggle`,"aria-expanded":c,onClick:()=>u(!c),children:c?t.labels.voiceClipHideTranscript:t.labels.voiceClipShowTranscript}),c&&/* @__PURE__ */ K(`p`,{className:`wui-chat-clip-transcript`,children:e.transcript})]}):null]})}function Rr(e,t){return e.kind===t}function Q(e,t){function n(n){if(!Rr(n.part,e))throw Error(`renderer for ${e} received a ${n.part.kind} part`);return S(t,{part:n.part,message:n.message,turn:n.turn})}return n}var zr=/* @__PURE__ */ new WeakMap;function Br(e,t){let n=zr.get(t)??/* @__PURE__ */ new Map,r=n.get(e);if(r)return r;function i(n){if(!Rr(n.part,e))throw Error(`renderer for ${e} received a ${n.part.kind} part`);return S(t,{part:n.part,message:n.message,turn:n.turn})}return n.set(e,i),zr.set(t,n),i}var Vr={Text:Q(`Text`,Nr),Sources:Q(`Sources`,Cr),QuickReplies:Q(`QuickReplies`,_r),InputRequest:Q(`InputRequest`,nr),Action:Q(`Action`,En),Notice:Q(`Notice`,or),Table:Q(`Table`,Ar),Chart:Q(`Chart`,jn),Figures:Q(`Figures`,Rn),RecordCard:Q(`RecordCard`,br),Image:Q(`Image`,Un),File:Q(`File`,zn),Ticket:Q(`Ticket`,Pr),Handoff:Q(`Handoff`,Vn),VoiceClip:Q(`VoiceClip`,Lr)};function $(e,t){let n=t?.[e];return n?Br(e,n):Vr[e]}function Hr(e){return{Text:$(`Text`,e),Sources:$(`Sources`,e),QuickReplies:$(`QuickReplies`,e),InputRequest:$(`InputRequest`,e),Action:$(`Action`,e),Notice:$(`Notice`,e),Table:$(`Table`,e),Chart:$(`Chart`,e),Figures:$(`Figures`,e),RecordCard:$(`RecordCard`,e),Image:$(`Image`,e),File:$(`File`,e),Ticket:$(`Ticket`,e),Handoff:$(`Handoff`,e),VoiceClip:$(`VoiceClip`,e)}}var Ur=48,Wr={Visitor:`you`,Customer:`you`,Agent:`agent`,Assistant:`assistant`,Script:`assistant`,System:`assistant`};function Gr(e,t){let n=e.author.kind;return e.author.displayName&&n!==`Visitor`&&n!==`Customer`?e.author.displayName:t[Wr[n]??`assistant`]}function Kr(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(r!==void 0&&t(r))return n}return-1}function qr(e,t){let n=/* @__PURE__ */ new Map,r=[];for(let i of e){let e=t(i),a=n.get(e)??0;n.set(e,a+1),r.push({key:`${e}#${a}`,item:i})}return r}function Jr({chat:e,labels:t,renderers:r,layoutParts:i,loader:a,motion:o,onOpenAttachment:s,onOpenTarget:c,onOpenTicket:l,onNavigate:u}){let d=k(null),f=k(!0),p=k(/* @__PURE__ */ new Map),m=O(()=>Hr(r),[r]),h=u??e.onNavigate,g=e.pending?.authorKind,_=g===`Agent`||g===`Customer`?`None`:a===`Orb`?`Orb`:`Assistant`,v=e.messages.at(-1),b=e.messages.find(e=>!(e.streaming&&e.parts.length===0)),x=e.greeting&&b&&(b.author.kind===`Visitor`||b.author.kind===`Customer`)?{id:`greeting`,createdDateTimeUtc:b.createdDateTimeUtc,author:{kind:`Assistant`,displayName:null,avatarUrl:null},parts:[{kind:`Text`,text:e.greeting}],sequence:null,rating:null,ratingNote:null,stored:!1,streaming:!1,restored:!1}:null,S=x?[x,...e.messages]:e.messages,C=S.filter(e=>!(e.streaming&&e.parts.length===0)),w=!e.streaming&&(e.turnError!==null||e.stopped),E=e.turnError?.code===`daily_limit`,D=typeof e.turnError?.code==`string`&&e.turnError.code.endsWith(`feature_off`),A=e.pending?.typing===!0,j=`${v?Xt(v):``}|${e.thinking}|${A}|${w}`,M=Kr(e.messages,e=>e.author.kind===`Visitor`&&e.stored),N=e.profile?.experience.pacing,ee=e.profile?.assistant.name??``;T(()=>{if(!j)return;let e=Yt(d.current);e&&(e.scrollTop=e.scrollHeight,f.current=!0)},[j]),T(()=>{let e=d.current;if(!e||typeof ResizeObserver!=`function`)return;let t=null,n=()=>{t&&(f.current=t.scrollHeight-t.scrollTop-t.clientHeight<=Ur)},r=new ResizeObserver(()=>{let r=Yt(e);r!==t&&(t?.removeEventListener(`scroll`,n),t=r,t?.addEventListener(`scroll`,n,{passive:!0})),t&&f.current&&(t.scrollTop=t.scrollHeight)});return r.observe(e),()=>{t?.removeEventListener(`scroll`,n),r.disconnect()}},[]);function P(e,t){p.current.get(e)?.querySelector(`[data-marker="${t}"]`)?.focus()}function F(e,t,n,r){let i=m[n.kind];return/* @__PURE__ */ K(`div`,{className:`wui-chat-part wui-chat-part--${n.kind.toLowerCase()}`,children:/* @__PURE__ */ K(i,{part:n,message:e,turn:t})},r)}return/* @__PURE__ */ K(`div`,{role:`log`,"aria-live":`polite`,"aria-label":t.thread,children:/* @__PURE__ */ q(`ol`,{ref:d,className:`wui-chat-thread`,children:[S.map((n,r)=>{if(n.streaming&&n.parts.length===0)return null;let a=z(e.session,{messageId:n.id,labels:t,openAttachment:s??(t=>qt(e.client,t)),openTarget:c??Jt,...l?{openTicket:l}:{},openCitation:e=>P(n.id,e),onNavigate:h}),o=n===x,u=x?r-1:r,d=C[C.indexOf(n)-1],f=n.author.kind===`Agent`&&d?.author.kind===`Agent`&&(d.author.displayName??``)===(n.author.displayName??``),m=i?i(n):null,g=ne(n.createdDateTimeUtc,t),_=d===void 0||ne(d.createdDateTimeUtc,t)!==g;return/* @__PURE__ */ q(y,{children:[_?/* @__PURE__ */ K(`li`,{className:`wui-chat-day`,role:`presentation`,children:/* @__PURE__ */ K(`span`,{children:g})}):null,/* @__PURE__ */ q(`li`,{ref:e=>{e?p.current.set(n.id,e):p.current.delete(n.id)},className:`wui-chat-message wui-chat-message--${n.author.kind.toLowerCase()}`,"aria-busy":n.streaming?`true`:void 0,"data-restored":n.restored?``:void 0,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-author visually-hidden`,children:`${Gr(n,t)}: `}),f?null:/* @__PURE__ */ K(Pt,{author:n.author,labels:t}),/* @__PURE__ */ K(`div`,{className:`wui-chat-message-body`,children:m?qr(m,e=>Array.isArray(e)?`group`:`part`).map(({key:e,item:t})=>/* @__PURE__ */ K(`div`,{className:`wui-chat-part-group`,children:qr(Array.isArray(t)?t:[t],e=>e.kind).map(({key:e,item:t})=>F(n,a,t,e))},e)):qr(n.parts,e=>e.kind).map(({key:e,item:t})=>F(n,a,t,e))}),o?null:/* @__PURE__ */ K(`div`,{className:`wui-chat-message-actions`,children:/* @__PURE__ */ K(tn,{chat:e,message:n,labels:t,isLast:n===v,isLastVisitor:!o&&u===M})})]})]},n.id)}),/* @__PURE__ */ K(Nt,{chat:e,labels:t}),A&&/* @__PURE__ */ K(`li`,{className:`wui-chat-message wui-chat-message--assistant wui-chat-message--loading`,children:/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-slot`,children:/* @__PURE__ */ K(gn,{motion:o??`On`,mark:_})})}),e.thinking&&/* @__PURE__ */ K(`li`,{className:`wui-chat-message wui-chat-message--assistant wui-chat-message--loading`,children:/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-slot`,children:/* @__PURE__ */ K(hn,{style:a??`Steps`,steps:e.steps,phrases:N?.thinkingPhrases??[],intervalMs:N?.phraseIntervalMs??2500,announce:t.preparingAnswer(ee),motion:o??`On`})})}),w&&/* @__PURE__ */ q(`li`,{className:`wui-chat-message wui-chat-message--system wui-chat-message--error`,children:[E?/* @__PURE__ */ q(`p`,{className:`wui-chat-error wui-chat-error--info`,role:`status`,children:[e.turnError?.message,e.turnError?.resetsDateTimeUtc?` ${t.dailyLimitRefresh(xt(e.turnError.resetsDateTimeUtc))}`:``]}):/* @__PURE__ */ K(`p`,{className:`wui-chat-error`,role:`alert`,children:e.turnError?.message??t.stopped}),e.features.Retry&&!E&&!D&&/* @__PURE__ */ K(`div`,{className:`wui-chat-message-actions`,children:/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>e.retry().catch(e=>globalThis.reportError?.(e)),children:t.retry})})]})]})})}var Yr=e=>e===`Assistant`||e===`Script`||e===`Agent`;function Xr(e,t,n){if(t){e.wasLoading=!0;for(let t of n)e.seen.add(t.id);return[]}if(e.wasLoading||!e.seeded){e.wasLoading=!1,e.seeded=!0;for(let t of n)e.seen.add(t.id);return[]}let r=[];for(let t of n)e.seen.has(t.id)||(e.seen.add(t.id),r.push(t));return r}function Zr(e){let t=e.features.Sounds?e.profile?.experience.sound??null:null,n=k(null),r=k(e);r.current=e;let i=k(e.open),a=k({seen:/* @__PURE__ */ new Set,seeded:!1,wasLoading:!1}),o=t!==null&&(t.open||t.sent||t.reply||t.vibrate);T(()=>{if(!o)return;let e=_e(t,Wt);return n.current=e,e.setMuted(r.current.muted),()=>{e.destroy(),n.current=null}},[o,t]);let{open:s,loading:c,messages:l,muted:u}=e;T(()=>{n.current?.setMuted(u)},[u]),T(()=>{let e=n.current,o=i.current;i.current=s;let u=Xr(a.current,c,l);if(e){s&&!o&&e.play(`open`);for(let n of u){if(n.restored||n.parts.some(e=>e.kind===`Notice`))continue;let i=n.author.kind;i===`Visitor`?n.stored||e.play(`sent`):Yr(i)&&(e.play(`reply`),t?.vibrate&&Te(t.vibrateMs,r.current.muted))}}},[s,c,l,t])}function Qr({chat:e,labels:t,layout:n,onClose:r,panelId:i,inputRef:a,ariaLabelOverride:o,renderers:s,layoutParts:c,loader:u,motion:d,onOpenAttachment:f,onOpenTarget:p,onOpenTicket:m,onNavigate:h,resolveLink:g=null,linkComponent:_,onSwitch:v,open:y=!0,renderEmpty:b,sendIcon:x=`arrow-up`}){let[S,C]=A(`chat`),w=O(()=>({resolveLink:g,linkComponent:_}),[g,_]);Zr(e);let{features:T}=e,E=e.profile,D=S===`history`&&T.History===!0,k=e.messages.length>0,j=n===`launcher`||n===`docked`,M=E?.experience.sound,N=!!(T.Sounds&&M?.muteControl),ee=j?`dialog`:`region`,P=o??E?.assistant.name??t.panelTitle,F=T.PanelSwitch===!0,I=e.messages.some(e=>e.author.kind===`Visitor`||e.author.kind===`Customer`),L=n===`full-page`||I,te=F&&typeof v==`function`&&(n===`docked`||n===`full-page`),R=n===`full-page`&&F&&typeof r==`function`;function z(){C(`chat`),r?.()}function B(){if(e.profileError)return/* @__PURE__ */ K(`p`,{className:`wui-chat-profile-error`,role:`alert`,children:e.profileError.message});if(!E&&(n===`full-page`||n===`embedded`)||e.loading)return/* @__PURE__ */ K(`p`,{role:`status`,"aria-busy":`true`,children:t.loadingConversation});if(e.loadError)return/* @__PURE__ */ K(`p`,{className:`wui-chat-profile-error`,role:`alert`,children:e.loadError.message});if(!k){let n=/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(Mt,{chat:e,labels:t,onOpenTicket:m}),T.History&&/* @__PURE__ */ K(Dt,{chat:e,labels:t,open:y})]});return b?b({chat:e,labels:t,open:y,defaultEmpty:n}):n}return/* @__PURE__ */ K(sr.Provider,{value:w,children:/* @__PURE__ */ K(Jr,{chat:e,labels:t,renderers:s,layoutParts:c,loader:u,motion:d,onOpenAttachment:f,onOpenTarget:p,onOpenTicket:m,onNavigate:h})})}return/* @__PURE__ */ q(`section`,{id:i,className:`wui-chat-panel`,role:ee,"aria-label":P,children:[/* @__PURE__ */ q(`header`,{className:`wui-chat-header`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-orb`,"aria-hidden":`true`}),/* @__PURE__ */ q(`div`,{className:`wui-chat-header-text`,children:[/* @__PURE__ */ K(`strong`,{className:`wui-chat-title`,children:E?.assistant.name??``}),/* @__PURE__ */ K(`span`,{className:`wui-chat-status`,children:pt(e,t)??t.headerStatus})]}),/* @__PURE__ */ q(`div`,{className:`wui-chat-header-actions`,children:[!D&&/* @__PURE__ */ K(nt,{chat:e,labels:t}),T.History&&(D?/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.backToChat,title:t.backToChat,onClick:()=>C(`chat`),children:/* @__PURE__ */ K(l,{name:`arrow-left`,size:18,"aria-hidden":`true`})}):/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.history,title:t.history,onClick:()=>C(`history`),children:/* @__PURE__ */ K(l,{name:`history`,size:18,"aria-hidden":`true`})})),N&&/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":e.muted?t.unmuteSounds:t.muteSounds,title:e.muted?t.unmuteSounds:t.muteSounds,onClick:()=>e.session.setMuted(!e.muted),children:/* @__PURE__ */ K(l,{name:e.muted?`volume-mute`:`volume-high`,size:18,"aria-hidden":`true`})}),!D&&L&&/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.newChat,title:t.newChat,disabled:e.streaming||e.thinking,onClick:()=>e.newConversation(),children:/* @__PURE__ */ K(l,{name:`plus`,size:18,"aria-hidden":`true`})}),te&&/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn wui-chat-icon-btn--switch`,"aria-label":n===`docked`?t.openFullScreen:t.openSidePanel,title:n===`docked`?t.openFullScreen:t.openSidePanel,disabled:e.streaming||e.thinking,onClick:()=>v(),children:/* @__PURE__ */ K(l,{name:n===`docked`?`maximize-4`:`panel-left-open`,size:18,"aria-hidden":`true`})}),(j||R)&&/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn wui-chat-close-btn`,"aria-label":t.close,title:t.close,onClick:z,children:/* @__PURE__ */ K(l,{name:`x`,size:18,"aria-hidden":`true`})})]})]}),/* @__PURE__ */ K(`div`,{className:`wui-chat-body`,children:D?/* @__PURE__ */ K(ct,{chat:e,labels:t,onOpen:()=>C(`chat`)}):B()}),!D&&/* @__PURE__ */ q(`div`,{className:`wui-chat-foot`,children:[/* @__PURE__ */ K(gt,{chat:e,labels:t}),/* @__PURE__ */ K(qe,{chat:e,labels:t,maxLength:E?.limits.maxMessageLength??4e3,inputRef:a,sendIcon:x}),/* @__PURE__ */ K(at,{chat:e,labels:t})]})]})}function $r(e,t){let n=k(!1);T(()=>{n.current||(n.current=!0,typeof t?.conversationId==`string`&&t.conversationId!==``&&e.openConversation(t.conversationId).catch(e=>globalThis.reportError?.(e)),typeof t?.draft==`string`&&t.draft!==``&&e.session.open({draft:t.draft}))},[e,t])}function ei(e,t){let[n,r]=A(!1);return T(()=>{let n=De(e,t??null);r(n.reduced);let i=n.subscribe(()=>r(n.reduced));return()=>{i(),n.destroy()}},[e,t]),n}function ti({chat:e,labels:t,renderers:n,layoutParts:r,loader:i,motion:a=`On`,onOpenAttachment:o,onOpenTarget:s,onNavigate:c,resolveLink:l,linkComponent:u,className:d,style:f,theme:p,look:m,onOpenSidePanel:h,onClose:g,renderEmpty:_,handoff:v}){let y=k(null);$r(e,v??null);let b=e.features.PanelSwitch===!0&&typeof h==`function`?()=>{let t={conversationId:e.conversationId,draft:y.current?.value??``,from:`full-page`,to:`docked`};Ce(()=>h(t),{target:`docked`}).catch(e=>globalThis.reportError?.(e))}:void 0;return/* @__PURE__ */ K(ni,{layout:`full-page`,chat:e,labelOverrides:t,renderers:n,layoutParts:r,loader:i,motion:a,onOpenAttachment:o,onOpenTarget:s,onNavigate:c,resolveLink:l,linkComponent:u,className:d,style:f,theme:p,look:m,inputRef:y,onSwitch:b,onClose:g,renderEmpty:_})}function ni({layout:e,chat:t,labelOverrides:n,renderers:r,layoutParts:i,loader:a,motion:o,onOpenAttachment:s,onOpenTarget:c,onNavigate:l,resolveLink:u=null,linkComponent:d,className:f,style:p,theme:m,look:h,inputRef:g,onSwitch:_,onClose:v,renderEmpty:y}){let b=O(()=>oe(n),[n]),x=O(()=>se(h),[h]),S=ei(x,t.profile?.experience??null),C=o===`Reduced`||S?`Reduced`:`On`;if(t.profile!==null&&!t.features.VisitorChat)return null;let w=[`wui-chat`,`wui-chat--${e}`,Zt(C),x.input.sendReveal===`Always`?`wui-chat--send-always`:null,x.input.ring===!1?`wui-chat--input-ring-off`:null,x.panel.replyAvatars===!1?`wui-chat--reply-avatars-off`:null,x.expressive?`wui-chat--expressive`:null,f].filter(Boolean).join(` `),T=x.avatar?{"--wui-chat-avatar":`url(${JSON.stringify(x.avatar)})`,"--wui-chat-typing-mark":`url(${JSON.stringify(x.avatar)})`,...p}:p;return/* @__PURE__ */ K(`div`,{className:w,style:T,"data-state":`open`,"data-theme":m===`auto`?void 0:m,children:/* @__PURE__ */ K(Qr,{chat:t,labels:b,layout:e,sendIcon:x.input.sendIcon,panelId:void 0,renderers:r,layoutParts:i,loader:a,motion:C,onOpenAttachment:s,onOpenTarget:c,onNavigate:l,resolveLink:u,linkComponent:d,inputRef:g,onSwitch:_,onClose:v,renderEmpty:y})})}function ri({labels:e,...t}){return/* @__PURE__ */ K(ni,{...t,labelOverrides:e,layout:`embedded`})}var ii=`a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`;function ai(e){return e!=null&&`focus`in e}function oi(e){let t=k(null);return T(()=>{let n=document.activeElement,r=t.current?.querySelector(ii);return ai(r)&&r.focus({preventScroll:!0}),()=>{let t=e.current??n;ai(t)&&t.focus({preventScroll:!0})}},[e]),T(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let n=0,r=new ResizeObserver(()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>window.dispatchEvent(new Event(`scroll`)))});return r.observe(e),()=>{cancelAnimationFrame(n),r.disconnect()}},[]),t}function si({x:e,labels:t,renderAnswer:r,renderFoot:i,askDraft:a,chat:o,close:s,triggerRef:c}){let l=oi(c),{state:u,answer:d,pillVisible:f,resetsDateTimeUtc:p}=e,m=null;if((u===`thinking`||u===`slow`)&&f)m=/* @__PURE__ */ q(`div`,{className:`wui-chat-explain-pill`,role:`status`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-explain-pill-dot`,"aria-hidden":`true`}),/* @__PURE__ */ K(`span`,{children:u===`slow`?t.explainSlow:t.thinking})]});else if(u===`answered`)m=/* @__PURE__ */ K(`div`,{className:`wui-chat-explain-answer`,children:r({answer:d,labels:t,close:s})});else if(u===`empty`)m=/* @__PURE__ */ K(`p`,{className:`wui-chat-explain-note`,children:t.explainEmpty});else if(u===`capacity`){let e=xt(p);m=/* @__PURE__ */ K(`p`,{className:`wui-chat-explain-notice wui-chat-explain-notice--info`,role:`status`,children:e?t.explainCapacity(e):t.explainCapacityNoDate})}else u===`error`&&(m=/* @__PURE__ */ q(`div`,{className:`wui-chat-explain-notice wui-chat-explain-notice--error`,role:`alert`,children:[/* @__PURE__ */ K(`p`,{children:t.explainError}),/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>e.ask(),children:t.explainRetry})]}));let h=typeof a==`string`&&a!==``&&typeof o.session?.open==`function`?a:null;return/* @__PURE__ */ q(`div`,{ref:l,className:`wui-chat-explain`,children:[m,/* @__PURE__ */ q(`div`,{className:`wui-chat-explain-foot`,children:[i?.({close:s}),h!==null&&/* @__PURE__ */ K(n,{className:`wui-chat-explain-more`,size:`sm`,variant:`ghost`,onClick:()=>{s(),o.session.open({draft:h})},children:t.explainAskMore}),/* @__PURE__ */ K(`p`,{className:`wui-chat-explain-note`,children:t.explainNotCounted})]})]})}function ci({chat:e,request:t,renderAnswer:n,label:r,renderFoot:i,askDraft:a,labels:o,placement:s=`auto`,className:c,triggerContent:u}){let d=O(()=>oe(o),[o]),[f,p]=A(!1),h=bt({request:t,enabled:e.features.Explain===!0}),g=k(null),_=k(!1);if(T(()=>{if(!f)return;let e=e=>{let t=e.target;_.current=t instanceof Element&&t.closest(`.wui-chat-panel`)!==null};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[f]),!e.features.Explain)return null;function y(e){!e&&(_.current||document.querySelector(`.wui-chat--docked[data-open=true]`))?_.current=!1:(p(e),e?h.ask():h.reset())}function b(){p(!1),h.reset()}let x=/* @__PURE__ */ q(`button`,{type:`button`,className:[`wui-chat-explain-trigger`,f?`wui-chat-explain-trigger--open`:null].filter(Boolean).join(` `),"aria-haspopup":`dialog`,"aria-label":d.explainTriggerLabel(r),disabled:h.offline,onClick:e=>{g.current=e.currentTarget},children:[/* @__PURE__ */ K(l,{name:`magic-star`,size:14,"aria-hidden":`true`}),u??d.explainTrigger]});return h.offline?/* @__PURE__ */ K(v,{content:d.explainOffline,children:/* @__PURE__ */ K(`span`,{className:`wui-chat-explain-offline`,children:x})}):/* @__PURE__ */ K(m,{trigger:x,title:r,placement:s,open:f,onOpenChange:y,role:`dialog`,className:[`wui-chat-explain-pop`,c].filter(Boolean).join(` `),children:f?/* @__PURE__ */ K(si,{x:h,labels:d,renderAnswer:n,renderFoot:i,askDraft:a,chat:e,close:b,triggerRef:g}):null})}function li({chat:e,labels:t,enabled:n,onActivate:r}){let i=e.profile?le(e.profile,e.features):null,[a,o]=A(!1),[s,c]=A(!1),[u,d]=A(!1),f=(i?.delaySeconds??0)*1e3;return T(()=>{if(!n||!i||s){o(!1);return}if(u)return;let e=setTimeout(()=>{o(!0),d(!0)},f);return()=>clearTimeout(e)},[n,i,f,s,u]),!a||!i||s?null:/* @__PURE__ */ q(`div`,{className:`wui-chat-nudge`,role:`status`,children:[/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-nudge-text`,onClick:r,children:i.text}),/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-nudge-close`,"aria-label":t.nudgeDismiss,onClick:()=>c(!0),children:/* @__PURE__ */ K(l,{name:`x`,size:14,"aria-hidden":`true`})})]})}function ui(e,t,n,r){T(()=>{let i=e.current;if(!r||!i||!n)return;let a=he(t,n,i);return()=>a.destroy()},[e,t,n,r])}var di=620,fi=300,pi=`wchat:peeked`,mi=576,hi=200;function gi(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function _i(e){return e?.querySelector(`:scope > .wui-chat-panel`)??null}function vi(e){let[t,n]=A(()=>globalThis.innerWidth<=e);return T(()=>{let t=()=>n(globalThis.innerWidth<=e);return t(),globalThis.addEventListener(`resize`,t),()=>globalThis.removeEventListener(`resize`,t)},[e]),t}function yi({chat:e,layout:t,labels:n,renderers:r,layoutParts:i,loader:a,motion:o=`On`,onOpenAttachment:s,onOpenTarget:c,onNavigate:u,resolveLink:d=null,linkComponent:f,className:p,style:m,theme:h,icon:g=`chat`,look:_,open:v,defaultOpen:y=!1,onOpenChange:b,position:x=`end`,offsetX:S=24,offsetY:w=24,panelId:j,switchConfig:M=null,renderEmpty:N}){let ee=E(),P=j??ee,F=O(()=>oe(n),[n]),I=O(()=>se(_),[_]),L=e.profile,te=e.features,R=v!==void 0,z=R?v:e.open,B=ei(I,L?.experience??null),ne=o===`Reduced`||B?`Reduced`:`On`,re=I.panel.motion===`None`?0:fi,V=L!==null&&te.VisitorChat,H=t===`launcher`||t===`docked`,U=vi(I.phone.maxWidthPx),W=L?.experience.launcher??null,ie=I.launcher.style===`Pill`?`pill`:`round`,ae=I.launcher.labelReveal===`Expand`?`expand`:`bubble`,ce=I.launcher.idle===`None`?`none`:gi(I.launcher.idle),le=I.launcher.entrance===`None`?null:gi(I.launcher.entrance),ue=W?.hideWhileOpen===!0||I.expressive===!0,de=W?.peek===!0,fe=W?.peekSeconds??3,pe=e.messages.length>0,me=k(null),he=k(null),ge=k(null),_e=k(null),ve=k(!1),Te=k(z),Ee=k(z),De=k(!1),G=k(b);G.current=b;let[Oe,ke]=A(z?`open`:`closed`),[Ae,J]=A(null),[je,Me]=A(null),Y=Ae??(le&&!U?`entering`:`idle`);ui(me,I.avoid,W,t===`launcher`&&V);let Ne=C(e=>{Te.current!==e&&(Te.current=e,G.current?.(e))},[]),Pe=C((t,n)=>{ve.current=t,Ne(t),R||(t?e.session.open({trigger:`manual`}):e.session.close(n))},[R,e.session,Ne]);T(()=>{R&&(v&&!e.open&&e.session.open({trigger:`manual`}),!v&&e.open&&e.session.close(`button`))},[R,v,e.open,e.session]),T(()=>{!R&&y&&e.session.open({trigger:`manual`})},[R,y,e.session]),T(()=>{Ne(e.open)},[e.open,Ne]),T(()=>{if(z){ke(e=>e===`open`?e:`opening`);let e=setTimeout(()=>ke(`open`),di);return()=>clearTimeout(e)}ke(e=>e===`closed`?e:`closing`);let e=setTimeout(()=>ke(`closed`),re);return()=>clearTimeout(e)},[z,re]),T(()=>{Ee.current!==z&&(Ee.current=z,Me(z?`wui-chat-launcher--opening`:`wui-chat-launcher--closing`))},[z]),D(()=>{if(Oe!==`opening`)return;let e=_i(he.current),t=ge.current;e&&t&&be(e,t.getBoundingClientRect())},[Oe]),T(()=>{if(!ue){J(e=>e===`hidden`?`idle`:e);return}if(z){J(`hidden`);return}if(Ae!==`hidden`)return;let e=_i(he.current)?.contains(document.activeElement)??!1,t=setTimeout(()=>{De.current=e,J(`idle`)},hi);return()=>clearTimeout(t)},[z,ue,Ae]),T(()=>{Y===`idle`&&De.current&&(De.current=!1,Se(ge.current))},[Y]);let Fe=k(!1);T(()=>{let e=Fe.current;Fe.current=z,z||!e||ue||Se(ge.current)},[z,ue]),T(()=>{z&&J(e=>e===`peeking`?`idle`:e)},[z]),T(()=>{V&&Y===`idle`&&de&&!B&&!z&&(globalThis.innerWidth<mi||globalThis.sessionStorage.getItem(pi)!==null||(globalThis.sessionStorage.setItem(pi,`1`),J(`peeking`)))},[V,Y,de,B,z]),T(()=>{if(Y!==`peeking`)return;let e=setTimeout(()=>J(e=>e===`peeking`?`idle`:e),fe*1e3);return()=>clearTimeout(e)},[Y,fe]);let Ie=k(Pe);Ie.current=Pe,T(()=>{if(!z||!H)return;let e=e=>{e.key===`Escape`&&Ie.current(!1,`escape`)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[z,H]),T(()=>{let e=_i(he.current);if(!V||!H||!e)return;let t=t=>we(e,t);return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[V,H]),T(()=>{if(!z||U||!ve.current)return;let e=setTimeout(()=>_e.current?.focus(),400);return()=>clearTimeout(e)},[z,U]),T(()=>{let e=_i(he.current);if(!V||!z||!U||!H||!e)return;let t=ye(e,I);return()=>t.destroy()},[V,z,U,H,I]),T(()=>{let e=he.current?.querySelector(`.wui-chat-thread`);if(V&&z&&U&&H&&pe&&e)return xe(e)},[V,z,U,H,pe]),T(()=>{if(t!==`docked`||!z||typeof document>`u`)return;let e=document.documentElement,n=document.getElementById(P);e.dataset.wchatDocked=``;let r=null;if(n){let t=()=>e.style.setProperty(`--wchat-docked-width`,`${n.getBoundingClientRect().width}px`);t(),typeof ResizeObserver<`u`&&(r=new ResizeObserver(t),r.observe(n))}return()=>{r?.disconnect(),e.removeAttribute(`data-wchat-docked`),e.style.removeProperty(`--wchat-docked-width`)}},[t,z,P]);let Le=M?.preload,Re=k(!1);if(T(()=>{z&&!Re.current&&(Re.current=!0,Promise.allSettled([new Promise(e=>e(Le?.()))]).then(e=>{for(let t of e)t.status===`rejected`&&globalThis.reportError?.(t.reason)}))},[z,Le]),!V)return null;let ze=M?()=>{let n={conversationId:e.conversationId,draft:_e.current?.value??``,from:t,to:M.target};Ce(()=>(Pe(!1,`button`),M.onSwitch(n)),{target:M.target}).catch(e=>globalThis.reportError?.(e))}:void 0,Be=[`wui-chat`,`wui-chat--${t}`,`wui-chat--${x}`,Zt(ne),H&&U?`wui-chat--phone`:null,I.phone.mode===`Sheet`?`wui-chat--sheet`:null,I.input.sendReveal===`Always`?`wui-chat--send-always`:null,I.input.ring===!1?`wui-chat--input-ring-off`:null,I.panel.motion===`Gentle`?`wui-chat--panel-motion-gentle`:null,I.panel.motion===`None`?`wui-chat--panel-motion-none`:null,I.panel.height===`Content`?`wui-chat--panel-height-content`:null,I.panel.replyAvatars===!1?`wui-chat--reply-avatars-off`:null,I.expressive?`wui-chat--expressive`:null,p].filter(Boolean).join(` `),Ve={...I.avatar?{"--wui-chat-avatar":`url(${JSON.stringify(I.avatar)})`,"--wui-chat-typing-mark":`url(${JSON.stringify(I.avatar)})`}:null,"--wui-chat-offset-x":`${S}px`,"--wui-chat-offset-y":`${w}px`,"--wui-chat-width":`${I.panel.widthPx}px`,"--wui-chat-panel-max-height":`${I.panel.maxHeightPx}px`,"--wui-chat-bottom-gap":`${I.panel.bottomGapPx}px`,"--wui-chat-sheet-height":`${I.phone.sheetHeightDvh}dvh`,"--wui-chat-sheet-max-height":`${I.phone.sheetMaxHeightPx}px`,...m},He=[`wui-chat-launcher-wrap`,Y===`entering`&&le?`wui-chat-launcher--entrance-${le}`:null,Y===`idle`&&ce!==`none`&&(ce!==`ring`||ie===`pill`)?`wui-chat-launcher--idle-${ce}`:null].filter(Boolean).join(` `),Ue=[`wui-chat-launcher`,`wui-chat-launcher--${ie}`,ie===`pill`&&I.launcher.compact?`wui-chat-launcher--compact`:null,I.launcher.mark===`Icon`?null:`wui-chat-launcher--mark-${gi(I.launcher.mark)}`,`wui-chat-launcher--reveal-${ae}`,je].filter(Boolean).join(` `),We=t===`launcher`&&!z&&te.Nudges,Ge=z?F.launcherClose:W?.hoverLabel||F.launcher;return/* @__PURE__ */ q(`div`,{ref:he,className:Be,style:Ve,"data-state":Oe,"data-open":z?`true`:`false`,"data-theme":h===`auto`?void 0:h,children:[/* @__PURE__ */ q(`div`,{ref:me,className:He,"data-launcher":Y,inert:Y===`hidden`,onAnimationEnd:e=>{e.target===e.currentTarget&&Y===`entering`&&J(`idle`)},children:[/* @__PURE__ */ K(li,{chat:e,labels:F,enabled:We,onActivate:()=>Pe(!0,`launcher`)}),/* @__PURE__ */ q(`button`,{ref:ge,type:`button`,className:Ue,"aria-haspopup":`dialog`,"aria-expanded":z,"aria-controls":P,"aria-label":Ge,onClick:()=>Pe(!z,`launcher`),onAnimationEnd:e=>{e.target===e.currentTarget&&Me(null)},children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-launcher-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ K(l,{name:g,size:24,"aria-hidden":`true`})}),/* @__PURE__ */ K(`span`,{className:`wui-chat-launcher-close`,"aria-hidden":`true`,children:/* @__PURE__ */ K(l,{name:`x`,size:20,"aria-hidden":`true`})}),/* @__PURE__ */ K(`span`,{className:`wui-chat-launcher-label`,children:Ge})]}),/* @__PURE__ */ K(`span`,{className:`wui-chat-launcher-bubble`,"aria-hidden":`true`,children:W?.hoverLabel||F.launcher})]}),/* @__PURE__ */ K(Qr,{chat:e,labels:F,layout:t,sendIcon:I.input.sendIcon,panelId:P,inputRef:_e,onClose:()=>Pe(!1,`button`),onSwitch:ze,open:z,renderEmpty:N,renderers:r,layoutParts:i,loader:a,motion:ne,onOpenAttachment:s,onOpenTarget:c,onNavigate:u,resolveLink:d,linkComponent:f})]})}function bi({enabled:e,settings:t,look:n,session:r,isOpen:i,panelId:a}){let o=k(i);o.current=i,T(()=>{if(!e||!t)return;let i=Ee(t,n,{open:()=>r.open({trigger:`auto`}),isOpen:()=>o.current,panelRect:()=>document.getElementById(a)?.getBoundingClientRect()??null});return()=>i.cancel()},[e,t,n,r,a])}function xi(e){let{chat:t,look:n}=e,r=E(),i=O(()=>se(n),[n]);return bi({enabled:t.features.AutoOpen&&t.profile!==null,settings:t.profile?.experience.autoOpen??null,look:i,session:t.session,isOpen:t.open,panelId:r}),/* @__PURE__ */ K(yi,{...e,layout:`launcher`,panelId:r})}function Si({onOpenFullScreen:e,preloadFullPage:t,...n}){let r=n.chat.features.PanelSwitch===!0&&typeof e==`function`?{onSwitch:e,target:`full-page`,preload:t}:null;return/* @__PURE__ */ K(yi,{...n,layout:`docked`,switchConfig:r})}var Ci=`https://www.google.com/recaptcha/api.js?render=`;function wi(e){return e!==void 0&&typeof e.ready==`function`&&typeof e.execute==`function`}var Ti=/* @__PURE__ */ new Map;function Ei(e){let t=Ti.get(e);if(t)return t;let n=new Promise((t,n)=>{let r=globalThis.grecaptcha;if(wi(r)){t(r);return}let i=document.createElement(`script`);i.src=Ci+encodeURIComponent(e),i.async=!0;let a=t=>{Ti.delete(e),n(Object.assign(Error(t),{code:`captcha_unavailable`}))};i.addEventListener(`load`,()=>{let e=globalThis.grecaptcha;e===void 0||typeof e.ready!=`function`?a(`The reCAPTCHA script loaded without grecaptcha.`):e.ready(()=>{let e=globalThis.grecaptcha;wi(e)?t(e):a(`reCAPTCHA became ready without execute.`)})}),i.addEventListener(`error`,()=>{Ti.delete(e),n(/* @__PURE__ */ Error(`The reCAPTCHA script did not load.`))}),document.head.append(i)});return Ti.set(e,n),n}async function Di(e,t){let n=await Ei(e);await new Promise(e=>n.ready(e));let r=await n.execute(e,{action:t});if(!r)throw Object.assign(/* @__PURE__ */ Error(`reCAPTCHA returned no token.`),{code:`captcha_unavailable`});return r}var Oi=e=>{if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(()=>e());return()=>cancelAnimationFrame(t)}let t=setTimeout(e,16);return()=>clearTimeout(t)},ki=se();function Ai(e){let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`The chat narrowing must be an object of feature switches.`);let n={};for(let e of M){let r=Reflect.get(t,e);if(r!==void 0){if(typeof r==`boolean`)n[e]=r;else throw TypeError(`The chat narrowing for "${e}" must be true or false.`)}}let r=new Set(M);for(let e of Object.keys(t))if(!r.has(e))throw TypeError(`"${e}" is not a chat feature.`);return n}function ji(e){let{client:t,screen:n,layout:r,narrow:i,conversationId:a,behaviour:o,attribution:s,prefs:c,pageContext:l,getCaptchaToken:u,onEvent:d,onError:f,onNavigate:p}=e,m=k(l);m.current=l;let h=k(u);h.current=u;let g=k(d);g.current=d;let _=k(f);_.current=f;let v=k(a);v.current=a;let y=k(o);y.current=o;let b=k(s);b.current=s;let x=k(c);x.current=c;let S=JSON.stringify(i??{}),w=k(null),E=k(!1),D=k(null),[M,N]=A(null);T(()=>{D.current=null;let e=I(t,{...n===void 0?{}:{screen:n},...r===void 0?{}:{layout:r},narrow:Ai(S),...v.current?{conversationId:v.current}:{},pageContext:()=>m.current,behaviour:()=>{let e=w.current;return e?.getState().features.BehaviourStarters?y.current?y.current():(D.current||=ge(e.getState().profile?.start.behaviour?.servicePathPrefixes??[]),D.current()):null},attribution:()=>b.current?.()??null,prefs:x.current??Wt,schedule:Oi,reducedMotion:()=>E.current,getCaptchaToken:async e=>{if(h.current)return h.current(e);let t=w.current?.getState().profile?.captcha;return t?.siteKey?Di(t.siteKey,e):null},onEvent:(e,t)=>g.current?.(e,t),onError:e=>_.current?.(e)});return w.current=e,N({client:t,screen:n,layout:r,narrowKey:S,session:e}),()=>{w.current=null,e.dispose()}},[t,n,r,S]);let P=M!==null&&M.client===t&&M.screen===n&&M.layout===r&&M.narrowKey===S?M.session:ee,F=j(P.subscribe,P.getState);E.current=ei(ki,F.profile?.experience??null);let L=O(()=>({load:()=>P.load(),submit:e=>P.submit(e),chooseQuickReply:e=>P.chooseQuickReply(e),answerInput:(e,t)=>P.answerInput(e,t),confirmAction:e=>P.confirmAction(e),rejectAction:(e,t)=>P.rejectAction(e,t),stop:()=>P.stop(),retry:()=>P.retry(),regenerate:()=>P.regenerate(),notifyTyping:()=>P.notifyTyping(),requestHandoff:e=>P.requestHandoff(e),startEdit:e=>P.startEdit(e),cancelEdit:()=>P.cancelEdit(),attach:e=>P.attach(e),removeAttachment:e=>P.removeAttachment(e),openConversation:e=>P.openConversation(e),resumeLast:()=>P.resumeLast(),newConversation:()=>P.newConversation(),rate:(e,t,n)=>P.rate(e,t,n),reset:()=>P.reset()}),[P]),te=C((e,t)=>g.current?.(e,t),[]);return{...F,...L,session:P,client:t,emit:te,onNavigate:p}}export{qe as ChatComposer,nt as ChatConversationActions,ri as ChatEmbed,ci as ChatExplain,at as ChatFooter,xi as ChatLauncher,hn as ChatLoader,kt as ChatOpenTickets,ti as ChatPage,Si as ChatPanel,Dt as ChatPastChats,Vt as ChatReadAloudButton,Jr as ChatThread,pn as assertChatLoaderStyle,Vr as defaultRenderers,xt as formatResetTime,ji as useChat,Be as useChatDictation,bt as useChatExplain,$r as useChatHandoff,It as useChatReadAloud,tt as useTranscriptActions};
14
+ `;function X(e,t,n){let r=e.createElement(t);return n!==void 0&&(r.textContent=n),r}function Xe(e,t){if(t.kind===`paragraph`)return X(e,`p`,t.text);if(t.kind===`list`){let n=X(e,t.ordered?`ol`:`ul`);for(let r of t.items)n.append(X(e,`li`,r));return n}let n=X(e,`table`);if(t.title!==null&&n.append(X(e,`caption`,t.title)),t.head.length>0){let r=X(e,`thead`),i=X(e,`tr`);for(let n of t.head)i.append(X(e,`th`,n));r.append(i),n.append(r)}let r=X(e,`tbody`);for(let n of t.rows){let t=X(e,`tr`);for(let r of n)t.append(X(e,`td`,r));r.append(t)}return n.append(r),n}function Ze(e){return`CSSStyleSheet`in e&&typeof e.CSSStyleSheet==`function`}function Qe(e,t){if(Ze(e)&&`adoptedStyleSheets`in t){let n=new e.CSSStyleSheet;n.replaceSync(Ye),t.adoptedStyleSheets=[n];return}let n=X(t,`style`,Ye);t.head.append(n)}function $e(e,t={}){let n=t.lang||document.documentElement.lang||`en`,r=document.createElement(`iframe`);r.title=`Print`,r.setAttribute(`aria-hidden`,`true`),r.tabIndex=-1;let i=r.style;i.position=`fixed`,i.right=`0`,i.bottom=`0`,i.width=`0`,i.height=`0`,i.border=`0`,document.body.append(r);let a=r.contentWindow,o=r.contentDocument;if(!a||!o)return r.remove(),!1;o.open(),o.write(`<!doctype html><title></title>`),o.close(),o.title=e.title,o.documentElement.lang=n,Qe(a,o),o.body.append(X(o,`h1`,e.title));let s=t.printedOn??e.dateText;if(s!=null){let e=X(o,`p`,s);e.className=`date`,o.body.append(e)}for(let t of e.entries){let e=X(o,`section`);e.append(X(o,`h2`,t.speaker));for(let n of t.blocks)e.append(Xe(o,n));o.body.append(e)}let c=()=>{r.isConnected&&r.remove(),clearTimeout(l)};a.addEventListener(`afterprint`,c);let l=setTimeout(c,Je);return a.focus(),a.print(),!0}var et=3e3;function tt(e,t){let[n,r]=A(null),i=k(void 0),a=k(!1);T(()=>(a.current=!0,()=>{a.current=!1,clearTimeout(i.current)}),[]);function o(e){a.current&&(clearTimeout(i.current),r(e),i.current=setTimeout(()=>r(null),et))}let s={labels:t,title:e.title,figureText:e.features.FigureText,...e.profile?{assistantName:e.profile.assistant.name}:{}},c=e.features.Share&&typeof navigator<`u`&&typeof navigator.share==`function`,l=e.features.Print&&typeof document<`u`;async function u(e,n){let r=F(e,s);if(r.entries.length===0)return;let i={title:r.title,text:pe(r,{heading:n,speakers:n})};if(typeof navigator.canShare==`function`&&!navigator.canShare(i))o(t.shareFailed);else try{await navigator.share(i)}catch(e){(typeof e==`object`&&e&&`name`in e?e.name:void 0)!==`AbortError`&&o(t.shareFailed)}}function d(e){let n=F(e,s);n.entries.length!==0&&($e(n,{printedOn:t.printedOn(B((/* @__PURE__ */ new Date()).toISOString()))})||o(t.printFailed))}return{canShare:c,canPrint:l,notice:n,shareReply:e=>u([e],!1),printReply:e=>d([e]),shareConversation:()=>u(e.messages,!0),printConversation:()=>d(e.messages)}}function nt({chat:e,labels:t}){let n=tt(e,t),r=e.streaming||e.thinking,i=e.messages.some(e=>e.stored&&(e.author.kind===`Assistant`||e.author.kind===`Agent`||e.author.kind===`Script`)&&ce(e.parts)!==``);return r||e.loading||e.conversationId===null||!i||!n.canShare&&!n.canPrint?null:/* @__PURE__ */ q(G,{children:[n.canShare&&/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.shareConversation,title:t.shareConversation,onClick:()=>n.shareConversation(),children:/* @__PURE__ */ K(l,{name:`share`,size:18,"aria-hidden":`true`})}),n.canPrint&&/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.printConversation,title:t.printConversation,onClick:()=>n.printConversation(),children:/* @__PURE__ */ K(l,{name:`printer`,size:18,"aria-hidden":`true`})}),n.notice!==null&&/* @__PURE__ */ K(`span`,{className:`wui-chat-action-notice`,role:`status`,children:n.notice})]})}var rt=`https://policies.google.com/privacy`,it=`https://policies.google.com/terms`;function at({chat:e,labels:t}){let n=e.profile;if(!n)return null;let r=n.footer.disclaimer||t.disclaimer,i=n.footer.privacyText,a=ie(n.footer.privacyUrl)?n.footer.privacyUrl:null,o=n.footer.assuranceText,s=ue(n);if(!r&&!i&&!a&&!o&&!s)return null;let c=[];return r&&c.push(/* @__PURE__ */ K(`p`,{className:`wui-chat-footer-text`,children:r},`disclaimer`)),a?c.push(/* @__PURE__ */ K(`p`,{className:`wui-chat-footer-privacy`,children:/* @__PURE__ */ K(`a`,{className:`wui-chat-footer-link`,href:a,children:i||t.footerPrivacyFallback})},`privacy`)):i&&c.push(/* @__PURE__ */ K(`p`,{className:`wui-chat-footer-privacy`,children:i},`privacy`)),o&&c.push(/* @__PURE__ */ K(`p`,{className:`wui-chat-footer-text`,children:o},`assurance`)),s&&c.push(/* @__PURE__ */ q(`p`,{className:`wui-chat-footer-captcha`,children:[t.captchaNoticeBefore,/* @__PURE__ */ K(`a`,{className:`wui-chat-footer-link`,href:rt,target:`_blank`,rel:`noopener noreferrer`,children:t.captchaPrivacyPolicy}),t.captchaNoticeAnd,/* @__PURE__ */ K(`a`,{className:`wui-chat-footer-link`,href:it,target:`_blank`,rel:`noopener noreferrer`,children:t.captchaTerms}),t.captchaNoticeAfter]},`captcha`)),/* @__PURE__ */ K(`div`,{className:`wui-chat-footer`,children:c})}var ot=Object.freeze({items:[],totalCount:null,loading:!1,error:null,hasMore:!1}),st=()=>()=>{};function ct({chat:e,labels:t,onOpen:r}){let[i,a]=A(null),o=i!==null&&i.client===e.client?i.list:null,s=C(e=>o?o.subscribe(e):st(),[o]),c=C(()=>o?o.getState():ot,[o]),u=j(s,c),[d,f]=A(null),[p,m]=A(``),[h,g]=A(!1),[_,v]=A(null),[y,b]=A(!1),x=k(null),S=k(!1),[w,E]=A(!1);T(()=>{let t=L({client:e.client});return a({client:e.client,list:t}),t.load(),()=>t.dispose()},[e.client]),T(()=>{d!==null&&x.current?.focus()},[d]);function D(e){f(e.publicId),m(e.title||``),g(!1)}async function O(e){if(!(S.current||p.trim()===``)){if(o===null)throw Error(`The conversation list is not loaded, so no row can be renamed.`);S.current=!0,E(!0);try{await o.rename(e,p),f(null)}catch{g(!0)}finally{S.current=!1,E(!1)}}}async function M(t){if(!S.current){if(o===null)throw Error(`The conversation list is not loaded, so no row can be deleted.`);S.current=!0,E(!0);try{await o.remove(t),v(null),b(!1),t===e.conversationId&&e.newConversation()}catch{b(!0)}finally{S.current=!1,E(!1)}}}let N=!u.loading&&u.error===null&&u.totalCount!==null&&u.items.length===0;return/* @__PURE__ */ q(`div`,{className:`wui-chat-history`,children:[u.error&&/* @__PURE__ */ q(`p`,{className:`wui-chat-history-error`,role:`alert`,children:[t.loadFailed,` `,/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>o?.load(),children:t.retry})]}),u.loading&&u.items.length===0&&/* @__PURE__ */ K(`p`,{className:`wui-chat-history-empty`,role:`status`,children:t.loadingConversation}),N&&/* @__PURE__ */ q(`p`,{className:`wui-chat-history-empty`,children:[/* @__PURE__ */ K(`span`,{children:t.historyEmptyTitle}),` `,/* @__PURE__ */ K(`span`,{children:t.historyEmptyText})]}),u.items.length>0&&/* @__PURE__ */ K(`ul`,{className:`wui-chat-history-list`,"aria-label":t.history,children:u.items.map(i=>d===i.publicId?/* @__PURE__ */ q(`li`,{className:`wui-chat-history-row wui-chat-history-row--editing`,children:[/* @__PURE__ */ K(`input`,{ref:x,className:`wui-chat-history-input`,"aria-label":t.conversationTitle,maxLength:120,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&e.keyCode!==229&&O(i.publicId).catch(e=>globalThis.reportError?.(e)),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),f(null))}}),/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,disabled:w||p.trim()===``,onClick:()=>O(i.publicId).catch(e=>globalThis.reportError?.(e)),children:t.renameSave}),/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>f(null),children:t.cancel}),h&&/* @__PURE__ */ K(`p`,{className:`wui-chat-history-error`,role:`alert`,children:t.renameFailed})]},i.publicId):_===i.publicId?/* @__PURE__ */ q(`li`,{className:`wui-chat-history-row wui-chat-history-row--confirm`,children:[/* @__PURE__ */ K(`p`,{children:t.deleteConfirmTitle}),/* @__PURE__ */ K(`p`,{children:t.deleteConfirmMessage}),/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,tone:`danger`,disabled:w,onClick:()=>M(i.publicId).catch(e=>globalThis.reportError?.(e)),children:t.deleteConfirm}),/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>v(null),children:t.cancel}),y&&/* @__PURE__ */ K(`p`,{className:`wui-chat-history-error`,role:`alert`,children:t.deleteFailed})]},i.publicId):/* @__PURE__ */ q(`li`,{className:`wui-chat-history-row`,children:[/* @__PURE__ */ q(`button`,{type:`button`,className:`wui-chat-history-open`,onClick:()=>{e.openConversation(i.publicId).catch(e=>globalThis.reportError?.(e)),r()},children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-history-title`,children:i.title||t.untitled}),/* @__PURE__ */ K(`span`,{className:`wui-chat-history-time`,children:B(i.lastActivityDateTimeUtc)})]}),e.features.Rename&&/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.rename,title:t.rename,onClick:()=>D(i),children:/* @__PURE__ */ K(l,{name:`pencil`,size:18,"aria-hidden":`true`})}),e.features.Delete&&/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.deleteChat,title:t.deleteChat,onClick:()=>{b(!1),v(i.publicId)},children:/* @__PURE__ */ K(l,{name:`trash`,size:18,"aria-hidden":`true`})})]},i.publicId))}),!u.loading&&u.hasMore&&/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`soft`,onClick:()=>o?.loadMore(),children:t.loadMore})]})}var lt=/* @__PURE__ */ new Map([[`Open`,`info`],[`InProgress`,`info`],[`WaitingOnCustomer`,`warning`],[`Resolved`,`success`]]);function ut(e){let t=(e??``).trim().split(/\s+/).filter(Boolean);if(t.length===0)return`?`;let n=Array.from(t[0]??``)[0]??``;return t.length===1?n.toUpperCase():`${n}${Array.from(t[t.length-1]??``)[0]??``}`.toUpperCase()}function dt(e){return lt.get(e)??`neutral`}function ft(e){for(let t=e.length-1;t>=0;--t){let n=e[t]?.author;if(n&&n.kind===`Agent`&&typeof n.displayName==`string`&&n.displayName.trim()!==``)return n.displayName}return null}function pt(e,t){return e.conversationState===`WaitingForAgent`?t.statusWaitingForAgent:e.conversationState===`WithAgent`?t.statusWithAgent(ft(e.messages)??t.handoffAgentFallback):null}function mt(e){return e.features.HumanHandoff===!0&&e.conversationState===`Open`&&e.messages.some(e=>e.author.kind===`Visitor`||e.author.kind===`Customer`)&&!e.streaming&&!e.thinking}function ht(e){if(typeof e==`object`&&e&&`message`in e)return typeof e.message==`string`?e.message:void 0}function gt({chat:e,labels:t}){let[r,i]=A(!1),[a,o]=A(null),s=e.live===`Lost`,c=mt(e);if(!c&&!s)return null;async function l(){i(!0),o(null);try{await e.requestHandoff()}catch(e){o(ht(e)||t.errorGeneric)}finally{i(!1)}}return/* @__PURE__ */ q(G,{children:[s&&/* @__PURE__ */ q(`p`,{className:`wui-chat-live-status`,role:`status`,children:[t.liveLost,` `,/* @__PURE__ */ K(n,{variant:`ghost`,size:`sm`,onClick:()=>e.session.resumeLive(),children:t.retry})]}),c&&/* @__PURE__ */ q(`div`,{className:`wui-chat-live-actions`,children:[/* @__PURE__ */ K(n,{variant:`outline`,size:`sm`,leftIcon:`user`,className:`wui-chat-handoff-request`,disabled:r,onClick:l,children:t.talkToPerson}),a&&/* @__PURE__ */ K(`p`,{className:`wui-chat-live-error`,role:`alert`,children:a})]})]})}var _t=Object.freeze({state:`idle`,answer:null,pillVisible:!1,resetsDateTimeUtc:null,offline:!1}),vt=()=>void 0,yt=()=>_t;function bt({request:e,enabled:t=!0}){let n=k(e);n.current=e;let[r,i]=A(null);T(()=>{let e=R({request:e=>{if(!(e instanceof AbortSignal))throw Error(`The explain engine did not pass an AbortSignal.`);return n.current(e)}});return i(e),()=>e.dispose()},[]);let a=C(e=>r?r.subscribe(e):vt,[r]),o=j(a,r?r.getSnapshot:yt),s=C(()=>{t&&r?.ask()},[t,r]),c=C(()=>r?.reset(),[r]),l=t?o:_t;return{state:l.state,answer:l.answer,pillVisible:l.pillVisible,resetsDateTimeUtc:l.resetsDateTimeUtc,offline:l.offline,ask:s,reset:c}}function xt(e){if(typeof e!=`string`||e===``)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}var St=20,Ct=Object.freeze({items:[],totalCount:null,loading:!1,error:null,hasMore:!1}),wt=()=>void 0,Tt=()=>Ct;function Et(e,t){let n=Date.parse(e);if(Number.isNaN(n))return``;let r=(Date.now()-n)/1e3;if(r<60)return t.justNow;let i=new Intl.RelativeTimeFormat(void 0,{numeric:`auto`});return r<3600?i.format(-Math.floor(r/60),`minute`):r<86400?i.format(-Math.floor(r/3600),`hour`):r<604800?i.format(-Math.floor(r/86400),`day`):xt(e)}function Dt({chat:e,labels:t,open:n}){let i=e.features.History===!0,a=e.client,[o,s]=A(null);T(()=>{if(!i)return;let e=L({client:a,pageSize:St});return s(e),()=>e.dispose()},[a,i]);let c=C(e=>o?o.subscribe(e):wt,[o]),l=j(c,o?o.getState:Tt);T(()=>{n&&o&&o.load().catch(e=>globalThis.reportError?.(e))},[n,o]);let u=e.features.ResumeLast?e.lastConversation?.publicId:void 0,d=l.items.filter(e=>e.publicId!==u).slice(0,St);return!i||l.error||d.length===0?null:/* @__PURE__ */ K(`div`,{className:`wui-chat-empty-rows wui-chat-past`,role:`group`,"aria-label":t.history,children:d.map(n=>/* @__PURE__ */ q(r,{className:`wui-chat-empty-row`,bodyClassName:`wui-chat-empty-row-body`,padding:`sm`,onClick:()=>e.openConversation(n.publicId).catch(e=>globalThis.reportError?.(e)),children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-empty-row-title`,children:n.title||t.earlierChat}),/* @__PURE__ */ K(`span`,{className:`wui-chat-empty-row-time`,title:xt(n.lastActivityDateTimeUtc)||void 0,children:Et(n.lastActivityDateTimeUtc,t)})]},n.publicId))})}var Ot=3;function kt({chat:e,labels:n,onOpenTicket:i}){return!e.features.OpenTickets||e.openTickets.length===0?null:/* @__PURE__ */ K(`div`,{className:`wui-chat-open-tickets`,role:`group`,"aria-label":n.openTickets,children:e.openTickets.slice(0,Ot).map(e=>{let a=/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-empty-row-label`,children:n.ticketAria(e.number)}),/* @__PURE__ */ K(`span`,{className:`wui-chat-empty-row-title`,children:e.subject}),/* @__PURE__ */ K(t,{className:`wui-chat-empty-row-status`,tone:dt(e.status),children:n.ticketStatus(e.status)||e.status})]});return i?/* @__PURE__ */ K(r,{className:`wui-chat-empty-row`,bodyClassName:`wui-chat-empty-row-body`,padding:`sm`,onClick:()=>i({ticketId:e.ticketId,number:e.number}),children:a},e.ticketId):/* @__PURE__ */ K(r,{className:`wui-chat-empty-row`,bodyClassName:`wui-chat-empty-row-body`,padding:`sm`,children:a},e.ticketId)})})}var At={Primary:`wui-chat-starter--primary`,Cta:`wui-chat-starter--cta`},jt=e=>({"--wui-chat-i":e});function Mt({chat:e,labels:t,onOpenTicket:n}){let i=e.profile;if(!i)return null;let a=i.assistant.intro,o=e.features.Starters&&!e.streaming&&e.starters.length>0,s=e.features.ResumeLast&&!e.features.History?e.lastConversation:null;return/* @__PURE__ */ q(`div`,{className:`wui-chat-empty`,role:`group`,"aria-label":t.emptyTitle,children:[/* @__PURE__ */ q(`div`,{className:`wui-chat-empty-hero`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-orb`,"aria-hidden":`true`}),e.greeting?/* @__PURE__ */ K(`h2`,{className:`wui-chat-greeting`,children:e.greeting}):null,a?/* @__PURE__ */ K(`p`,{className:`wui-chat-empty-intro`,children:a}):null]}),o&&/* @__PURE__ */ K(`div`,{className:`wui-chat-starters`,role:`group`,"aria-label":t.starters,children:e.starters.map((t,n)=>/* @__PURE__ */ q(`button`,{type:`button`,className:[`wui-chat-starter`,t.variant===null?void 0:At[t.variant]].filter(Boolean).join(` `),style:jt(n),onClick:()=>e.submit(t.message).catch(e=>globalThis.reportError?.(e)),children:[t.icon?/* @__PURE__ */ K(`span`,{className:`wui-chat-starter-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ K(l,{name:t.icon,size:16})}):null,t.label]},t.id))}),s&&/* @__PURE__ */ K(`div`,{className:`wui-chat-empty-rows`,children:/* @__PURE__ */ q(r,{className:`wui-chat-empty-row`,bodyClassName:`wui-chat-empty-row-body`,padding:`sm`,onClick:()=>e.resumeLast().catch(e=>globalThis.reportError?.(e)),children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-empty-row-label`,children:t.resumeLast}),/* @__PURE__ */ K(`span`,{className:`wui-chat-empty-row-title`,children:s.title||t.untitled}),/* @__PURE__ */ K(`span`,{className:`wui-chat-empty-row-time`,children:B(s.lastActivityDateTimeUtc)})]})}),/* @__PURE__ */ K(kt,{chat:e,labels:t,onOpenTicket:n})]})}function Nt({chat:e,labels:t}){let n=e.agentTyping;if(!n)return null;let r=typeof n==`object`&&n.displayName||ft(e.messages)||t.agent;return/* @__PURE__ */ K(`li`,{className:`wui-chat-message wui-chat-message--agent wui-chat-message--typing`,children:/* @__PURE__ */ q(`div`,{className:`wui-chat-typing`,role:`status`,children:[/* @__PURE__ */ q(`span`,{className:`wui-chat-typing-dots`,"aria-hidden":`true`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-typing-dot`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-typing-dot`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-typing-dot`})]}),/* @__PURE__ */ K(`span`,{className:`visually-hidden`,children:t.agentTyping(r)})]})})}function Pt({author:e,labels:t}){if(e.kind!==`Agent`)return null;let n=typeof e.avatarUrl==`string`&&e.avatarUrl!==``?e.avatarUrl:null;return/* @__PURE__ */ q(`div`,{className:`wui-chat-agent-head`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-avatar`,"aria-hidden":`true`,children:n?/* @__PURE__ */ K(`img`,{src:n,alt:``}):ut(e.displayName)}),/* @__PURE__ */ K(`span`,{className:`wui-chat-agent-name`,children:e.displayName||t.agent}),/* @__PURE__ */ K(`span`,{className:`wui-chat-agent-role wui-chat-agent-tag`,children:t.agent})]})}var Ft=null;function It({speech:e,enabled:t}){let n=!!(t&&e?.readAloud),[r,i]=A(!1),[a,o]=A(!1),s=k(null),c=k(null),l=k(!1);return T(()=>(l.current=!0,()=>{l.current=!1,s.current?.abort(),s.current=null,Ft===c.current&&(Ft=null),c.current=null}),[]),{available:n,speaking:r,failed:a,toggle:C(t=>{if(s.current){s.current.abort();return}if(!e||t.trim()===``)return;Ft?.();let n=new AbortController;s.current=n;let r=()=>n.abort();Ft=r,c.current=r,i(!0),o(!1),e.speak(t,{signal:n.signal}).catch(()=>{!n.signal.aborted&&l.current&&o(!0)}).finally(()=>{s.current===n&&(s.current=null),Ft===r&&(Ft=null),l.current&&i(!1)})},[e])}}var Lt=/* @__PURE__ */ new Set([`Assistant`,`Agent`,`Script`]),Rt=6e3,zt={tone:`neutral`};function Bt(e){let t=ce(e).replace(/ ?\[\d+\]/g,``).replace(/\s+/g,` `).trim();if(t.length<=Rt)return t;let n=t.slice(0,Rt),r=n.lastIndexOf(`. `);return r===-1?n.trim():n.slice(0,r+1)}function Vt({chat:t,labels:n,message:r}){let i=It({speech:He(t),enabled:t.features.ReadAloud});if(!i.available||r.streaming||!Lt.has(r.author.kind))return null;let a=r.parts.filter(e=>e.kind===`Text`),o=Bt(t.features.FigureText?a.map(e=>({...e,text:fe(e.text)})):a);if(o.trim()===``)return null;let s=i.speaking?n.readAloudStop:n.readAloud;return/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(e,{icon:`volume-high`,label:s,size:16,...i.speaking?zt:{},"aria-pressed":i.speaking,onClick:()=>i.toggle(o)}),i.failed&&/* @__PURE__ */ K(`span`,{className:`wui-chat-action-notice`,role:`status`,children:n.readAloudFailed})]})}function Ht(e){return e===`wchat:muted`?globalThis.localStorage:globalThis.sessionStorage}var Ut=/* @__PURE__ */ new Map,Wt={get(e){let t=Ut.get(e);if(t!==void 0)return t;try{return Ht(e)?.getItem(e)??null}catch{return null}},set(e,t){try{Ht(e)?.setItem(e,t),Ut.delete(e)}catch{Ut.set(e,t)}}};async function Gt(e){if(!navigator.clipboard?.writeText)return Kt(e);try{return await navigator.clipboard.writeText(e),!0}catch{return Kt(e)}}function Kt(e){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();try{return document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}async function qt(e,t){try{let n=await e.getAttachment(t.attachmentId),r=URL.createObjectURL(new Blob([n],{type:t.contentType}));return window.open(r,`_blank`,`noopener`),setTimeout(()=>URL.revokeObjectURL(r),6e4),!0}catch(e){return globalThis.reportError?.(e),!1}}function Jt(e){/^https?:\/\//i.test(e)?window.open(e,`_blank`,`noopener`):window.location.assign(e)}function Yt(e){for(let t=e?.parentElement;t&&t!==document.body;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t}return null}function Xt(e){let t=0;for(let n of e.parts)n.kind===`Text`&&(t+=n.text.length);return`${e.id}:${e.parts.length}:${t}`}function Zt(e){return e===`Reduced`?`wui-chat--reduced`:``}var Qt=[`Up`,`Down`],$t={Up:`check`,Down:`x`},en={tone:`neutral`};function tn({chat:t,message:r,labels:i,isLast:a,isLastVisitor:o}){let{features:s}=t,[c,l]=A(!1),[u,d]=A(!1),[f,p]=A(!1),m=tt(t,i),h=t.streaming||t.thinking;if(T(()=>{if(!c)return;let e=setTimeout(()=>l(!1),2e3);return()=>clearTimeout(e)},[c]),r.streaming)return null;let g=r.author.kind===`Assistant`||r.author.kind===`Agent`||r.author.kind===`Script`,_=g?ce(r.parts):``,v=g&&_!==``&&s.Copy,y=g&&_!==``&&s.ReadAloud,b=g&&_!==``&&s.Share&&m.canShare,x=g&&_!==``&&s.Print&&m.canPrint,S=a&&r.author.kind===`Assistant`&&!t.streaming&&!t.thinking&&s.Regenerate&&t.messages.some(e=>e.author.kind===`Visitor`&&e.stored),C=o&&s.Edit&&!h,w=s.Rating&&r.stored&&(r.author.kind===`Assistant`||r.author.kind===`Agent`);if(!v&&!y&&!b&&!x&&!S&&!C&&!w)return null;async function E(e){d(!1);try{await t.rate(r.id,e),p(!0)}catch{d(!0)}}return/* @__PURE__ */ q(G,{children:[v&&/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`copy`,onClick:async()=>{let e=await Gt(_);l(e)},children:c?i.copied:i.copy}),y&&/* @__PURE__ */ K(Vt,{chat:t,labels:i,message:r}),b&&/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`share`,disabled:h,onClick:()=>m.shareReply(r).catch(e=>globalThis.reportError?.(e)),children:i.share}),x&&/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`printer`,disabled:h,onClick:()=>m.printReply(r),children:i.print}),S&&/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`refresh`,onClick:()=>t.regenerate().catch(e=>globalThis.reportError?.(e)),children:i.regenerate}),C&&/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,leftIcon:`pencil`,onClick:()=>t.startEdit(r.id),children:i.edit}),w&&/* @__PURE__ */ q(`div`,{className:`wui-chat-rating`,role:`group`,"aria-label":`${i.rateUp} / ${i.rateDown}`,children:[Qt.map(t=>/* @__PURE__ */ K(e,{icon:$t[t],label:t===`Up`?i.rateUp:i.rateDown,size:16,...r.rating===t?en:{},"aria-pressed":r.rating===t,onClick:()=>E(t)},t)),u&&/* @__PURE__ */ K(`span`,{role:`status`,children:i.ratingFailed}),f&&!u&&/* @__PURE__ */ K(`span`,{role:`status`,children:i.rated})]}),m.notice!==null&&/* @__PURE__ */ K(`span`,{className:`wui-chat-action-notice`,role:`status`,children:m.notice})]})}function nn({view:e}){return/* @__PURE__ */ q(`div`,{className:`wui-chat-loader-orb`,children:[/* @__PURE__ */ q(`span`,{className:`wui-chat-loader-orb-mark`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-orb-glow`,"aria-hidden":`true`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-orb-disc`,"aria-hidden":`true`})]}),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-orb-label`,children:e.label})]})}var rn=150;function an({view:e,motion:t}){let n=t===`Reduced`,[r,i]=A(()=>({id:0,label:e.label,previous:null}));e.label!==r.label&&i({id:r.id+1,label:e.label,previous:{id:r.id,label:r.label}}),T(()=>{if(!r.previous)return;let e=setTimeout(()=>i(e=>({...e,previous:null})),rn);return()=>clearTimeout(e)},[r.previous]);let a=n?null:r.previous;return/* @__PURE__ */ q(`div`,{className:`wui-chat-loader-phrases`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-phrases-orb`,"aria-hidden":`true`}),/* @__PURE__ */ q(`span`,{className:`wui-chat-loader-phrases-stage`,children:[a&&/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-phrases-text wui-chat-loader-phrases-text--out`,children:a.label},`out-${a.id}`),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-phrases-text wui-chat-loader-phrases-text--in`,children:r.label},`in-${r.id}`)]})]})}var on=[`92%`,`78%`,`85%`,`40%`];function sn({view:e}){return/* @__PURE__ */ q(`div`,{className:`wui-chat-loader-skeleton`,children:[/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-skeleton-label`,children:e.label}),/* @__PURE__ */ q(`div`,{className:`wui-chat-loader-skeleton-body`,children:[on.map(e=>/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-skeleton-line`,"aria-hidden":`true`,style:{width:e}},e)),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-skeleton-table`,"aria-hidden":`true`})]})]})}function cn(e,t){return e<t?`done`:e===t?`active`:`pending`}function ln(e){let t=/* @__PURE__ */ new Map;return e.map(e=>{let n=(t.get(e)??0)+1;return t.set(e,n),{key:`${e}\u0000${n}`,text:e}})}function un({state:e}){return e===`done`?/* @__PURE__ */ K(`svg`,{viewBox:`0 0 16 16`,className:`wui-chat-loader-steps-check`,"aria-hidden":`true`,children:/* @__PURE__ */ K(`path`,{d:`M3 8.5 6.5 12 13 4.5`,pathLength:1})}):e===`active`?/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-steps-ring`,"aria-hidden":`true`}):/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-steps-dot`,"aria-hidden":`true`})}function dn({view:e}){return/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-steps`,children:/* @__PURE__ */ K(`ol`,{className:`wui-chat-loader-steps-list`,children:ln(e.steps).map(({key:t,text:n},r)=>{let i=cn(r,e.activeIndex);return/* @__PURE__ */ q(`li`,{className:`wui-chat-loader-steps-item`,"data-state":i,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-steps-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ K(un,{state:i})}),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-steps-text`,children:n})]},t)})})})}var fn=500;function pn(e){if(!P.some(t=>t===e))throw Error(`ChatLoader style must be one of ${P.join(`, `)}, got "${e}".`)}function mn({style:e,view:t,motion:n}){return e===`Phrases`?/* @__PURE__ */ K(an,{view:t,motion:n}):K(e===`Orb`?nn:e===`Skeleton`?sn:dn,{view:t})}function hn({style:e=`Steps`,steps:t=[],phrases:n,intervalMs:r,announce:i,motion:a=`On`}){let o=a===`Reduced`,[s,c]=A({style:e,count:0}),[l,u]=A(!1);if(T(()=>{if(o)return;let t=setInterval(()=>c(t=>({style:e,count:t.count+1})),r);return()=>clearInterval(t)},[e,r,o]),T(()=>{let e=setTimeout(()=>u(!0),fn);return()=>clearTimeout(e)},[]),pn(e),!(r>0))throw Error(`ChatLoader needs intervalMs, a positive number of milliseconds.`);s.style!==e&&c({style:e,count:0});let d=o?0:s.count,f=ae(e,t,n,d);return/* @__PURE__ */ q(`div`,{className:o?`wui-chat-loader wui-chat-loader--reduced`:`wui-chat-loader`,role:`status`,"aria-label":f.label,children:[/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-body`,children:/* @__PURE__ */ K(mn,{style:e,view:f,motion:a})}),/* @__PURE__ */ K(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:l?i:``})]})}function gn({motion:e,mark:t}){return/* @__PURE__ */ q(`div`,{className:e===`Reduced`?`wui-chat-loader-typing wui-chat-loader--reduced`:`wui-chat-loader-typing`,"aria-hidden":`true`,children:[t===`None`?null:/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-typing-orb`,"aria-hidden":`true`}),/* @__PURE__ */ q(`span`,{className:`wui-chat-loader-typing-dots`,"aria-hidden":`true`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-typing-dot`,"aria-hidden":`true`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-typing-dot`,"aria-hidden":`true`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-loader-typing-dot`,"aria-hidden":`true`})]})]})}var _n=`ChatLeadCapture`,vn=/^https?:\/\//i,yn={strong:`strong`,em:`em`,strike:`s`};function bn(e){return e in yn}function xn(e,t={next:0}){return e.map(e=>{let n=t.next++;if(e.type===`text`||e.type===`citation`)return e.text;if(e.type===`link`){let r=xn(e.children,t);return vn.test(e.href)?/* @__PURE__ */ K(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,children:r},n):/* @__PURE__ */ K(y,{children:r},n)}if(e.type===`code`)return/* @__PURE__ */ K(`code`,{children:e.text},n);if(bn(e.type)){let r=yn[e.type];return/* @__PURE__ */ K(r,{children:xn(e.children,t)},n)}return null})}function Sn(e,t){return e.state===`Repeat`?e.decidedDateTimeUtc?t.actionRepeat(B(e.decidedDateTimeUtc)):t.actionDone:{Confirmed:t.actionConfirmed,Done:t.actionDone,Rejected:t.actionRejected,Expired:t.actionExpired,Failed:t.actionFailed}[e.state]}function Cn(e){let t=e.indexOf(`: `);return t<0?{term:e,detail:null}:{term:e.slice(0,t),detail:e.slice(t+2)}}function wn(e,t){return{id:e,label:t,action:`Send`,target:null,navigateAfterMs:null,icon:null,variant:null}}function Tn(e){if(typeof e==`object`&&e&&`message`in e)return e.message?String(e.message):void 0}function En({part:e,turn:t}){let{labels:r,features:i}=t,a=i.LeadRecap&&e.actionKind===_n,o=e.state===`Pending`,s=e.editFields??[],c=a&&s.length>0,l=a&&e.confirmLabel||r.actionConfirm,u=a&&e.rejectLabel||r.actionDismiss,[d,f]=A(null),[p,m]=A(null),[h,g]=A(!1),_=E(),v=k(null),y=k(null),b=d!==null;T(()=>{h&&y.current?.querySelector(`[role="menuitem"]`)?.focus()},[h]);async function x(e,t){m(null),f(e);try{await t()}catch(e){m(Tn(e)||r.actionFailed),f(null)}}function S(e){g(!1),v.current?.focus(),t.chooseQuickReply(wn(`lead.edit:${e.id}`,e.label))}function C(e){let t=[...e.currentTarget.querySelectorAll(`[role="menuitem"]`)],n=e.target,r=n instanceof HTMLElement?t.indexOf(n):-1;e.key===`Escape`?(e.preventDefault(),g(!1),v.current?.focus()):e.key===`ArrowDown`?(e.preventDefault(),t[(r+1)%t.length]?.focus()):e.key===`ArrowUp`?(e.preventDefault(),t[r<=0?t.length-1:r-1]?.focus()):e.key===`Home`?(e.preventDefault(),t[0]?.focus()):e.key===`End`?(e.preventDefault(),t[t.length-1]?.focus()):e.key===`Tab`&&g(!1)}return/* @__PURE__ */ q(`div`,{className:`wui-chat-action wui-chat-action--${e.state.toLowerCase()}`,children:[/* @__PURE__ */ K(`strong`,{className:`wui-chat-action-title`,children:e.title}),e.lines.length>0&&(a?/* @__PURE__ */ K(`dl`,{className:`wui-chat-action-lines`,children:e.lines.map(e=>{let{term:t,detail:n}=Cn(e);return/* @__PURE__ */ q(`div`,{className:`wui-chat-action-line`,children:[/* @__PURE__ */ K(`dt`,{children:t}),n!==null&&/* @__PURE__ */ K(`dd`,{children:n})]},e)})}):/* @__PURE__ */ K(`ul`,{className:`wui-chat-action-lines`,children:e.lines.map(e=>/* @__PURE__ */ K(`li`,{children:e},e))})),a&&e.consentText&&/* @__PURE__ */ K(`p`,{className:`wui-chat-action-consent`,children:xn(Oe(e.consentText))}),e.note&&/* @__PURE__ */ K(`p`,{className:`wui-chat-action-note`,children:e.note}),!o&&/* @__PURE__ */ q(`p`,{className:`wui-chat-action-status wui-chat-action-status--${e.state.toLowerCase()}`,children:[Sn(e,r),e.state===`Done`&&e.decidedDateTimeUtc&&/* @__PURE__ */ q(G,{children:[` `,/* @__PURE__ */ K(`time`,{dateTime:e.decidedDateTimeUtc,children:B(e.decidedDateTimeUtc)})]})]}),(o||c)&&/* @__PURE__ */ q(`div`,{className:`wui-chat-action-buttons`,children:[o&&/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(n,{size:`sm`,disabled:b,onClick:()=>x(`confirm`,()=>t.confirmAction(e.actionId)),children:d===`confirm`?r.actionWorking:l}),/* @__PURE__ */ K(n,{variant:`soft`,size:`sm`,disabled:b,onClick:()=>x(`reject`,()=>t.rejectAction(e.actionId)),children:u})]}),c&&/* @__PURE__ */ K(n,{ref:v,variant:`soft`,size:`sm`,className:`wui-chat-action-edit`,"aria-haspopup":`menu`,"aria-expanded":h,"aria-controls":h?_:void 0,disabled:!o||b,onClick:()=>g(e=>!e),children:r.editSomething})]}),c&&h&&/* @__PURE__ */ K(`ul`,{id:_,ref:y,className:`list-group wui-chat-action-menu`,role:`menu`,"aria-label":r.editSomething,onKeyDown:C,children:s.map(e=>/* @__PURE__ */ K(`li`,{role:`none`,children:/* @__PURE__ */ K(`button`,{className:`list-group-item list-group-item-action wui-chat-action-menu-item`,type:`button`,role:`menuitem`,tabIndex:-1,onClick:()=>S(e),children:e.label})},e.id))}),p&&/* @__PURE__ */ K(`p`,{className:`wui-chat-action-error`,role:`alert`,children:p})]})}function Z({text:e,enabled:t}){if(!t||typeof e!=`string`)return e;let n=0;return/* @__PURE__ */ K(G,{children:de(e).map(e=>{let t=`${n}-${e.kind}`;return n+=e.text.length,e.kind===`sub`?/* @__PURE__ */ K(`sub`,{children:e.text},t):e.kind===`sup`?/* @__PURE__ */ K(`sup`,{children:e.text},t):/* @__PURE__ */ K(y,{children:e.text},t)})})}function Dn(e,t){return t&&typeof e==`string`?fe(e):e}var On={Bar:`column`,Line:`line`,Donut:`donut`},kn=8,An=4;function jn({part:e,turn:t}){let[r,a]=A(`chart`),o=t.features.FigureText,s=e.chartType===`Donut`?e.series.slice(0,1):e.series.slice(0,kn),c=s.map(e=>new Map(e.points.map(e=>[e.label,e.value]))),l=[...new Set(s.flatMap(e=>e.points.map(e=>e.label)))].map(e=>{let t={label:Dn(e,o)};return c.forEach((n,r)=>{t[`s${r}`]=n.get(e)??null}),t}),u=e.unit?Dn(e.unit,o):null,d=s.map((e,t)=>{let n=Dn(e.name,o);return{key:`s${t}`,label:n,format:{style:`number`}}}),f=e.chartType!==`Donut`&&u?{label:u}:void 0,p=Math.max(0,...s.map(e=>e.points.length)),m=e.chartType===`Bar`&&p>An?300:240;return/* @__PURE__ */ q(`figure`,{className:`wui-chat-chart`,children:[e.title?/* @__PURE__ */ K(`figcaption`,{className:`wui-chat-rich-title`,children:/* @__PURE__ */ K(Z,{text:e.title,enabled:o})}):null,/* @__PURE__ */ K(i,{type:On[e.chartType],title:(e.title?Dn(e.title,o):``)||t.labels.chart,data:l,x:{key:`label`},series:d,...f===void 0?{}:{y:f},height:m,view:r,errorText:t.labels.chartLoadFailed}),l.length>0&&/* @__PURE__ */ K(n,{variant:`link`,size:`sm`,className:`wui-chat-chart-toggle`,"aria-pressed":r===`table`,onClick:()=>a(r===`table`?`chart`:`table`),children:r===`table`?t.labels.chartShowChart:t.labels.chartShowTable})]})}var Mn={Neutral:`neutral`,Positive:`success`,Caution:`warning`,Negative:`danger`},Nn=/* @__PURE__ */ new Set([`Positive`,`Caution`,`Negative`]),Pn=.001;function Fn(e){return e<=3?3:e===4?4:5}function In(e){let t=0;return e.map(e=>{let n=`${t}-${e.kind}`;return t+=e.text.length,e.kind===`sub`?/* @__PURE__ */ K(`sub`,{children:e.text},n):e.kind===`sup`?/* @__PURE__ */ K(`sup`,{children:e.text},n):/* @__PURE__ */ K(`span`,{children:e.text},n)})}function Ln(e,t){let n=e.value!==0&&Math.abs(e.value)<Pn?In(H(e.value)):je(e.value),r=Nn.has(e.status)?/* @__PURE__ */ K(`span`,{className:`visually-hidden`,children:t.figureStatus(e.status)}):null;return e.unit?/* @__PURE__ */ q(G,{children:[n,` `,/* @__PURE__ */ K(`span`,{className:`wui-chat-figure-unit`,children:In(de(e.unit))}),r]}):/* @__PURE__ */ q(G,{children:[n,r]})}function Rn({part:e,turn:t}){if(e.figures.length===0)return null;let n=Fn(e.figures.length),r=e.figures.map(e=>({label:/* @__PURE__ */ K(Z,{text:e.label,enabled:!0}),value:Ln(e,t.labels),tone:Mn[e.status]}));return/* @__PURE__ */ K(`div`,{className:`wui-chat-figures`,role:`group`,"aria-label":t.labels.figures,children:/* @__PURE__ */ K(p,{className:`wui-chat-figures-strip`,size:`sm`,columns:n,items:r})})}function zn({part:e,turn:t}){let n=/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(`span`,{children:/* @__PURE__ */ K(l,{name:`document-text`,size:16})}),/* @__PURE__ */ K(`span`,{className:`wui-chat-file-name`,children:e.fileName}),/* @__PURE__ */ K(`span`,{className:`wui-chat-file-size`,children:U(e.length)})]});return/* @__PURE__ */ K(`div`,{className:`wui-chat-file`,children:t.openAttachment?/* @__PURE__ */ K(`button`,{className:`wui-chat-file-chip`,type:`button`,"aria-label":t.labels.fileOpen(e.fileName),onClick:()=>t.openAttachment?.(e),children:n}):/* @__PURE__ */ K(`span`,{className:`wui-chat-file-chip`,children:n})})}var Bn=/* @__PURE__ */ new Set([`Requested`,`Waiting`,`Joined`]);function Vn({part:e,turn:t}){if(t.handoffSettled===!0&&(e.state===`Requested`||e.state===`Waiting`))return null;let{labels:n}=t,r=e.agent?.displayName||null,i=e.agent?.avatarUrl||null,a=e.state.toLowerCase(),o=t.isLast&&(e.state===`Requested`||e.state===`Waiting`);return/* @__PURE__ */ q(`div`,{className:`wui-chat-handoff wui-chat-handoff--${a}${o?` wui-chat-handoff--live`:``}`,role:t.isLast&&Bn.has(e.state)?`status`:void 0,children:[e.state===`Requested`&&/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ q(`span`,{className:`wui-chat-handoff-pulses`,"aria-hidden":`true`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-pulse`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-pulse`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-pulse`})]}),/* @__PURE__ */ K(`p`,{className:`wui-chat-handoff-text`,children:n.handoffRequested})]}),e.state===`Waiting`&&/* @__PURE__ */ q(G,{children:[typeof e.queuePosition!=`number`&&/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ q(`span`,{className:`wui-chat-handoff-pulses`,"aria-hidden":`true`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-pulse`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-pulse`}),/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-pulse`})]}),/* @__PURE__ */ K(`p`,{className:`wui-chat-handoff-text`,children:n.handoffWaiting})]}),typeof e.queuePosition==`number`&&/* @__PURE__ */ K(`p`,{className:`wui-chat-handoff-queue`,children:n.handoffQueued(e.queuePosition)}),/* @__PURE__ */ K(`p`,{className:`wui-chat-handoff-note`,children:n.handoffQueuedText})]}),e.state===`Joined`&&/* @__PURE__ */ q(G,{children:[i?/* @__PURE__ */ K(`img`,{className:`wui-chat-handoff-avatar`,src:i,alt:``,"aria-hidden":`true`,width:32,height:32}):/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-avatar`,"aria-hidden":`true`,children:ut(r)}),/* @__PURE__ */ K(`span`,{className:`wui-chat-handoff-online`,"aria-hidden":`true`}),/* @__PURE__ */ K(`strong`,{className:`wui-chat-handoff-title`,children:n.handoffJoined(r??n.handoffAgentFallback)}),/* @__PURE__ */ K(`p`,{className:`wui-chat-handoff-text`,children:n.handoffJoinedText(r??n.handoffAgentFallback)})]}),e.state===`Left`&&/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(`strong`,{className:`wui-chat-handoff-title`,children:n.handoffLeft(r??n.handoffAgentFallback)}),/* @__PURE__ */ K(`p`,{className:`wui-chat-handoff-text`,children:n.handoffLeftText})]}),e.state===`Ended`&&/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(`p`,{className:`wui-chat-handoff-text`,children:n.handoffEnded}),/* @__PURE__ */ K(`p`,{className:`wui-chat-handoff-text`,children:n.handoffEndedText})]})]})}function Hn({part:e,loadAttachmentUrl:t,turn:r}){let[i,a]=A({status:`loading`,url:null}),o=k(0),s=C(e=>{let n=++o.current;a({status:`loading`,url:null}),t(e).then(e=>{o.current===n&&a({status:`ready`,url:e})},()=>{o.current===n&&a({status:`failed`,url:null})})},[t]);return T(()=>(s(e.attachmentId),()=>{o.current++}),[s,e.attachmentId]),i.status===`loading`?/* @__PURE__ */ q(`div`,{className:`wui-chat-image-loading`,role:`status`,children:[/* @__PURE__ */ K(`span`,{className:`visually-hidden`,children:r.labels.imageLoading}),/* @__PURE__ */ K(g,{height:160,radius:8})]}):i.status===`failed`?/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(`p`,{className:`wui-chat-image-error`,role:`status`,children:r.labels.imageFailed}),/* @__PURE__ */ K(n,{variant:`soft`,tone:`primary`,size:`sm`,onClick:()=>s(e.attachmentId),children:r.labels.retry})]}):/* @__PURE__ */ K(d,{className:`wui-chat-image-view`,label:r.labels.imageViewer,items:[{key:e.attachmentId,src:i.url,alt:e.alt,name:e.alt}],download:!1,layout:`single`})}function Un({part:e,turn:t}){let n=e.width&&e.height?{aspectRatio:`${e.width} / ${e.height}`}:void 0;return typeof t.loadAttachmentUrl==`function`?/* @__PURE__ */ K(`figure`,{className:`wui-chat-image`,style:n,children:/* @__PURE__ */ K(Hn,{part:e,loadAttachmentUrl:t.loadAttachmentUrl,turn:t},e.attachmentId)}):/* @__PURE__ */ K(`figure`,{className:`wui-chat-image`,style:n,children:/* @__PURE__ */ K(`span`,{className:`wui-chat-image-alt`,children:e.alt})})}var Wn={Email:{type:`email`,autoComplete:`email`},Phone:{type:`tel`,autoComplete:`tel`},Name:{type:`text`,autoComplete:`name`},Company:{type:`text`,autoComplete:`organization`},Text:{type:`text`,autoComplete:void 0}},Gn=new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`,month:`short`,hour:`numeric`,minute:`2-digit`});function Kn(e,t){return e.state===`Answered`?e.answeredSummary||t.inputAnswered:e.state===`Skipped`?t.inputSkipped:t.inputExpired}function qn(e){return e.type===`Consent`?!1:e.type===`MultiChoice`?[]:``}function Jn(e){return Object.fromEntries(e.map(e=>[e.key,qn(e)]))}function Yn(e){return typeof e==`string`?e:``}function Xn(e){return typeof e==`object`?e:[]}function Zn(e,t){let n=Yn(t);return e.secret?n:n.trim()}function Qn(e,t,n){return e.required?e.type===`Consent`?t?null:n.inputConsentRequired:e.type===`MultiChoice`?Xn(t).length>0?null:n.inputRequired:Zn(e,t)?null:n.inputRequired:null}function $n(e,t){if(e.type===`Consent`)return t?`true`:`false`;if(e.type===`MultiChoice`){let n=Xn(t);return JSON.stringify((e.options??[]).map(e=>e.id).filter(e=>n.includes(e)))}return e.type===`Choice`||e.type===`TimeSlot`?Yn(t):Zn(e,t)}function er({field:e,value:t,error:r,file:i,disabled:o,id:s,labels:c,onChange:l,onFile:d,onRemove:f,controlRef:p}){let m=`${s}-error`,g=m,v=r?`true`:void 0,y=e.required||void 0,b=/* @__PURE__ */ K(`p`,{className:`wui-chat-field-error`,id:m,role:`alert`,hidden:!r,children:r}),x=e.required?null:/* @__PURE__ */ K(`span`,{className:`wui-chat-field-hint`,children:c.inputOptional});if(e.type===`Choice`){let n=`${s}-label`;return/* @__PURE__ */ q(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ K(`span`,{className:`form-label`,id:n,children:e.label}),x,/* @__PURE__ */ K(`div`,{role:`radiogroup`,"aria-labelledby":n,"aria-invalid":v,"aria-describedby":g,children:(e.options??[]).map((n,r)=>{let i=`${s}-${n.id}`;return/* @__PURE__ */ K(h,{id:i,name:e.key,value:n.id,label:n.label,checked:t===n.id,disabled:o,onChange:()=>l(n.id),ref:r===0?p:void 0},n.id)})}),b]})}if(e.type===`MultiChoice`){let n=`${s}-label`;return/* @__PURE__ */ q(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ K(`span`,{className:`form-label`,id:n,children:e.label}),x,/* @__PURE__ */ K(`div`,{className:`wui-chat-input-choices`,role:`group`,"aria-labelledby":n,"aria-invalid":v,"aria-describedby":g,children:(e.options??[]).map((n,r)=>{let i=`${s}-${n.id}`;return/* @__PURE__ */ K(a,{id:i,name:e.key,value:n.id,label:n.label,checked:Xn(t).includes(n.id),disabled:o,onChange:e=>l(e.target.checked?[...Xn(t),n.id]:Xn(t).filter(e=>e!==n.id)),ref:r===0?p:void 0},n.id)})}),b]})}if(e.type===`TimeSlot`){let r=`${s}-label`;return/* @__PURE__ */ q(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ K(`span`,{className:`form-label`,id:r,children:e.label}),x,/* @__PURE__ */ K(`div`,{className:`wui-chat-input-slots d-flex flex-wrap gap-2`,role:`radiogroup`,"aria-labelledby":r,"aria-invalid":v,"aria-describedby":g,children:(e.slots??[]).map((r,i)=>{let a=`${s}-${r.id}`,c=`${a}-label`;return/* @__PURE__ */ q(`div`,{className:`wui-chat-input-slot`,children:[/* @__PURE__ */ K(`input`,{className:`btn-check`,type:`radio`,id:a,name:e.key,value:r.id,checked:t===r.id,disabled:o,"aria-labelledby":c,onChange:()=>l(r.id),ref:i===0?p:void 0}),/* @__PURE__ */ K(n,{as:`label`,id:c,variant:`soft`,className:`wui-chat-input-slot`,disabled:o,onClick:()=>l(r.id),children:Gn.format(new Date(r.startDateTimeUtc))})]},r.id)})}),b]})}if(e.type===`File`){let t=i?.status===`uploading`,r=`${s}-label`;return/* @__PURE__ */ q(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ K(`label`,{className:`form-label`,id:r,htmlFor:s,children:e.label}),x,/* @__PURE__ */ K(`span`,{className:t?`wui-chat-input-file-status`:`visually-hidden`,"aria-live":`polite`,children:t?c.attachmentUploading:``}),/* @__PURE__ */ K(`div`,{role:`group`,"aria-labelledby":r,children:i?/* @__PURE__ */ q(`div`,{className:`wui-chat-input-file`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-input-file-name`,children:i.name}),/* @__PURE__ */ K(n,{variant:`link`,type:`button`,disabled:o,onClick:f,ref:p,children:c.inputRemoveFile(i.name)})]}):/* @__PURE__ */ K(u,{controlOnly:!0,className:`wui-chat-input-control`,type:`file`,id:s,name:e.key,accept:e.accept?.join(`,`),disabled:o,"aria-label":c.inputChooseFile,"aria-required":y,"aria-invalid":v,"aria-describedby":g,onChange:e=>{let t=e.target.files?.[0];t&&d(t)},ref:p})}),b]})}if(e.type===`Consent`)return/* @__PURE__ */ q(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ K(a,{id:s,name:e.key,label:e.consentText||e.label,checked:t===!0,disabled:o,"aria-invalid":v,"aria-describedby":g,onChange:e=>l(e.target.checked),ref:p}),b]});let S=Wn[e.type],C=e.type===`LongText`&&!e.secret?/* @__PURE__ */ K(_,{controlOnly:!0,className:`wui-chat-input-control`,id:s,name:e.key,rows:3,value:Yn(t),placeholder:e.placeholder??void 0,maxLength:e.maxLength??void 0,disabled:o,"aria-required":y,"aria-invalid":v,"aria-describedby":g,onChange:e=>l(e.target.value),ref:p}):/* @__PURE__ */ K(u,{controlOnly:!0,className:`wui-chat-input-control`,id:s,name:e.key,type:e.secret?`password`:S?.type,autoComplete:e.secret?`off`:S?.autoComplete,value:Yn(t),placeholder:e.placeholder??void 0,maxLength:e.maxLength??void 0,disabled:o,"aria-required":y,"aria-invalid":v,"aria-describedby":g,onChange:e=>l(e.target.value),ref:p});return/* @__PURE__ */ q(`div`,{className:`wui-chat-field`,"data-key":e.key,children:[/* @__PURE__ */ K(`label`,{className:`form-label`,htmlFor:s,children:e.label}),x,C,b]})}function tr({part:e,turn:t}){let{labels:r,features:i}=t,a=E(),[o,s]=A(()=>Jn(e.fields)),[l,u]=A({}),[d,f]=A(null),[p,m]=A(!1),[h,g]=A(null),[_,v]=A({}),y=k({}),b=k({});T(()=>{h?.key!==void 0&&y.current[h.key]?.focus()},[h]);let x=e.fields.length===1?e.fields[0]:void 0,S=i.LeadShortcuts&&x!==void 0&&!x.required,C=i.LeadShortcuts&&e.cancellable,w=Object.keys(_).find(e=>_[e]?.status===`uploading`);function D(t){return e.fields.find(e=>t[e.key])?.key??e.fields[0]?.key}function O(e,t){s(n=>({...n,[e]:t}))}function j(e){let t=o[e];if(t===void 0)throw Error(`The input form has no value for field "${e}".`);return t}async function M(e,n){let i={};b.current[e]=i,v(t=>({...t,[e]:{status:`uploading`,name:n.name}})),O(e,``),u(t=>({...t,[e]:void 0}));let a;try{a=await t.uploadInputFile(n)}catch{if(b.current[e]!==i)return;v(t=>({...t,[e]:{status:`failed`,name:n.name}})),u(t=>({...t,[e]:r.attachmentFailed}));return}b.current[e]===i&&(O(e,a),v(t=>({...t,[e]:{status:`ready`,name:n.name}})),u(t=>({...t,[e]:void 0})))}function N(e){b.current[e]=null,O(e,``),v(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e))),u(t=>({...t,[e]:void 0}))}async function ee(){if(w!==void 0)return u(e=>({...e,[w]:r.attachmentUploading})),g({key:w}),!1;let n={};for(let t of e.fields){let e=t.type===`File`&&_[t.key]?.status===`failed`?r.attachmentFailed:Qn(t,j(t.key),r);e&&(n[t.key]=e)}if(f(null),u(n),Object.keys(n).length>0)return g({key:D(n)}),!1;m(!0);let i=Object.fromEntries(e.fields.map(e=>[e.key,$n(e,j(e.key))])),a;try{a=await t.answerInput(e.requestId,i)}catch{a={ok:!1,errors:{},message:r.errorGeneric}}if(a.ok)return!0;let o=Object.entries(a.errors).filter(([t])=>!e.fields.some(e=>e.key===t)).map(([,e])=>e),s=[a.message,...o].filter(Boolean);return u(a.errors),f(s.length>0?s.join(` `):null),m(!1),g({key:D(a.errors)}),!1}return/* @__PURE__ */ q(c,{className:`wui-chat-input-form`,noValidate:!0,"aria-label":e.title||e.submitLabel,onSubmit:ee,children:[e.title&&/* @__PURE__ */ K(`h3`,{className:`wui-chat-input-title`,children:e.title}),e.fields.map(e=>/* @__PURE__ */ K(er,{field:e,value:j(e.key),error:l[e.key],file:_[e.key],disabled:p,id:`${a}-${e.key}`,labels:r,onChange:t=>O(e.key,t),onFile:t=>M(e.key,t),onRemove:()=>N(e.key),controlRef:t=>{y.current[e.key]=t}},e.key)),/* @__PURE__ */ K(`p`,{className:`wui-chat-input-error`,role:`status`,hidden:!d,children:d}),/* @__PURE__ */ q(`div`,{className:`d-flex flex-wrap gap-2`,children:[/* @__PURE__ */ K(n,{type:`submit`,disabled:p,children:p?r.inputSubmitting:e.submitLabel}),S&&/* @__PURE__ */ K(n,{variant:`soft`,disabled:p,onClick:()=>t.skipInput(e.requestId),children:r.skip}),C&&/* @__PURE__ */ K(n,{variant:`link`,type:`button`,disabled:p,onClick:()=>t.cancelLead(),children:r.cancel})]}),e.allowTyped&&/* @__PURE__ */ K(`p`,{className:`wui-chat-input-typed`,children:r.typeAnswer})]})}function nr({part:e,turn:t}){let n=`wui-chat-input-request wui-chat-input-request--${e.state.toLowerCase()}`;return/* @__PURE__ */ K(`div`,{className:n,children:e.state===`Open`?/* @__PURE__ */ K(tr,{part:e,turn:t},e.requestId):/* @__PURE__ */ K(`p`,{className:`wui-chat-input-summary`,children:Kn(e,t.labels)})})}var rr=/* @__PURE__ */ new Set([`ActionLimitReached`,`ConversationTooLong`]),ir={AssistantUnavailable:`danger`},ar={info:`info`,warning:`alert-triangle`,danger:`alert-circle`};function or({part:e,turn:t}){let n=ir[e.code]??(rr.has(e.code)?`warning`:`info`),r=e.code===`NeedsNewerApp`?t.labels.needsNewerApp:e.text;return/* @__PURE__ */ q(`div`,{className:`wui-chat-notice wui-chat-notice--${n}`,role:n===`danger`?`alert`:`status`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-notice-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ K(l,{name:ar[n],size:16})}),/* @__PURE__ */ K(`span`,{className:`wui-chat-notice-text`,children:r})]})}var sr=x({resolveLink:null,linkComponent:void 0});function cr(){return w(sr)}var lr={Primary:`wui-chat-quick-reply--primary`,Cta:`wui-chat-quick-reply--cta`};function ur(e){return e===null?void 0:lr[e]}function dr(e,t){return e.action===`Navigate`?!!t.features.LinkHandoff:e.action!==`Open`||!!e.target&&!!t.openTarget}function fr(e,t){return[`wui-chat-quick-reply`,ur(e.variant),t].filter(Boolean).join(` `)}function pr(e,t,n){return e.target===null||!W(e.target,t.handoffHosts)?null:n?n(e.target)??null:e.target}function mr(e){return e.icon?/* @__PURE__ */ K(`span`,{className:`wui-chat-quick-reply-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ K(l,{name:e.icon,size:16})}):null}function hr(e,t,n,r){return/* @__PURE__ */ q(`button`,{type:`button`,className:r,style:n,onClick:n=>{if(e.action===`Open`){if(!t.openTarget)throw Error(`An Open quick reply needs turn.openTarget, and the turn has none.`);e.target&&t.openTarget(e.target)}else t.chooseQuickReply(e),n.currentTarget.closest(`.wui-chat`)?.querySelector(`.wui-chat-input`)?.focus()},children:[mr(e),/* @__PURE__ */ K(`span`,{className:`wui-chat-quick-reply-label`,children:e.label})]},e.id)}function gr(e,t,n){if(!t.features.SuggestedReplies||!t.isLast||t.busy||e.replies.length===0)return null;let r=e.placement===`Composer`?`wui-chat-quick-replies wui-chat-quick-replies--composer`:`wui-chat-quick-replies`,i=e.replies.filter(e=>dr(e,t));if(i.length===0)return null;let a=t.openTarget??(e=>globalThis.location.assign(e)),o=e.placement===`Composer`?void 0:i.find(e=>e.id===N&&e.action===`Send`);return/* @__PURE__ */ q(`div`,{className:o?`${r} wui-chat-quick-replies--offer`:r,role:`group`,"aria-label":t.labels.quickReplies,children:[o&&/* @__PURE__ */ q(`div`,{className:`wui-chat-offer`,children:[/* @__PURE__ */ K(`div`,{className:`wui-chat-offer-title`,children:o.label}),hr(o,t,{"--wui-chat-i":0},fr({...o,variant:`Primary`},`wui-chat-offer-action`))]}),i.map((e,r)=>{if(e===o)return null;let i={"--wui-chat-i":r};if(e.action===`Navigate`){let r=pr(e,t,n);if(r===null)return/* @__PURE__ */ K(`span`,{className:`wui-chat-quick-reply-label`,style:i,children:e.label},e.id);if(typeof t.beginHandoff!=`function`)return null;let o=()=>a(r);return/* @__PURE__ */ q(`button`,{type:`button`,disabled:t.handoffPause,className:fr(e,t.handoffPause?`wui-chat-quick-reply--quiet`:void 0),style:i,onClick:()=>t.beginHandoff(e,o),children:[mr(e),/* @__PURE__ */ K(`span`,{className:`wui-chat-quick-reply-label`,children:t.handoffPause?t.labels.handoffMoment:e.label})]},e.id)}return hr(e,t,i,fr(e,o?`wui-chat-quick-reply--quiet`:void 0))})]})}function _r({part:e,turn:t}){let{resolveLink:n}=cr(),r=gr(e,t,n),i=k(null),[a,o]=A(null),s=k(null);return D(()=>{r?i.current=r:i.current&&=(o(i.current),null)}),T(()=>{if(!a)return;let e=s.current,t=e?.ownerDocument.defaultView;if(!t||!e){o(null);return}let n=Number.parseFloat(t.getComputedStyle(e).animationDuration)*1e3;if(!(n>0)){o(null);return}let r=t.setTimeout(()=>o(null),n);return()=>t.clearTimeout(r)},[a]),r||(a?b(a,{ref:s,className:`${a.props.className} wui-chat-quick-replies--leaving`,"aria-hidden":`true`}):null)}var vr=/* @__PURE__ */ new Set([`Integer`,`Decimal`,`MoneyMinor`,`Percent`]);function yr(e){return e.value===null||e.value===void 0||e.value===``?ke():e.type===`Date`?Ae(e.value,{pattern:`day`}):e.type===`DateTimeUtc`?J(e.value):re(e.value,e.type,null)}function br({part:e,turn:t}){let r=E(),i=t.features.FigureText,a=e.fields.map((e,t)=>({key:String(t),label:/* @__PURE__ */ K(Z,{text:e.label,enabled:i}),value:/* @__PURE__ */ K(`span`,{className:vr.has(e.type)?`wui-chat-num`:void 0,children:/* @__PURE__ */ K(Z,{text:yr(e),enabled:i})})})),o=!!e.target&&typeof t.openRecord==`function`;return/* @__PURE__ */ q(`article`,{className:`wui-chat-record`,"aria-labelledby":r,children:[/* @__PURE__ */ q(`header`,{className:`wui-chat-record-head`,children:[/* @__PURE__ */ K(`h3`,{className:`wui-chat-record-title`,id:r,children:/* @__PURE__ */ K(Z,{text:e.title,enabled:i})}),e.subtitle?/* @__PURE__ */ K(`span`,{className:`wui-chat-record-subtitle`,children:/* @__PURE__ */ K(Z,{text:e.subtitle,enabled:i})}):null]}),e.fields.length>0?/* @__PURE__ */ K(s,{className:`wui-chat-record-fields`,columns:1,size:`sm`,layout:`summary`,items:a}):null,o?/* @__PURE__ */ K(`div`,{className:`wui-chat-record-actions`,children:/* @__PURE__ */ K(n,{className:`wui-chat-record-open`,size:`sm`,type:`button`,"aria-label":t.labels.recordOpenFor(fe(e.title)),onClick:()=>t.openRecord?.(e),children:t.labels.recordOpen})}):null]})}var xr=/^https?:\/\//i;function Sr({source:e}){return/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-source-marker`,children:e.marker}),/* @__PURE__ */ K(`span`,{className:`wui-chat-source-title`,children:e.title})]})}function Cr({part:e,turn:t}){return!t.features.Sources||e.sources.length===0?null:/* @__PURE__ */ q(`div`,{className:`wui-chat-sources`,children:[/* @__PURE__ */ K(`p`,{className:`wui-chat-sources-label`,children:t.labels.sources}),/* @__PURE__ */ K(`ul`,{className:`wui-chat-sources-list`,"aria-label":t.labels.sources,children:e.sources.map(e=>/* @__PURE__ */ K(`li`,{children:xr.test(e.url??``)?/* @__PURE__ */ K(`a`,{className:`wui-chat-source`,href:e.url??void 0,target:`_blank`,rel:`noopener noreferrer`,"aria-label":t.labels.openSource(e.title),"data-marker":e.marker,children:/* @__PURE__ */ K(Sr,{source:e})}):/* @__PURE__ */ K(`span`,{className:`wui-chat-source`,tabIndex:-1,"data-marker":e.marker,children:/* @__PURE__ */ K(Sr,{source:e})})},e.marker))})]})}var wr=/* @__PURE__ */ new Set([`Integer`,`Decimal`,`MoneyMinor`,`Percent`]),Tr=50,Er=25,Dr={align:`num`},Or={rowHeader:!0};function kr(e,t,n,r){return e==null?null:t.type===`Text`&&e!==``?/* @__PURE__ */ K(Z,{text:e,enabled:r}):re(e,t.type,n)}function Ar({part:e,turn:t}){let[r,i]=A(!1),a=t.features.FigureText,s=e.columns.map((e,t)=>({key:`c${t}`,label:/* @__PURE__ */ K(Z,{text:e.label,enabled:a}),...wr.has(e.type)?Dr:{},...t===0&&e.type===`Text`?Or:{}})),c=e.rows.map((t,n)=>{let r={id:n};return e.columns.forEach((n,i)=>{r[`c${i}`]=kr(t[i],n,e.currency,a)}),r}),l=r?c:c.slice(0,Er),u=l.length>Tr,d=e.title?Dn(e.title,a):t.labels.table;return/* @__PURE__ */ q(`figure`,{className:`wui-chat-table`,children:[e.title?/* @__PURE__ */ K(`figcaption`,{className:`wui-chat-table-title`,children:/* @__PURE__ */ K(Z,{text:e.title,enabled:a})}):null,/* @__PURE__ */ K(`div`,{className:`table-wrap wui-chat-table-wrap`,role:`region`,tabIndex:0,"aria-label":d,children:/* @__PURE__ */ K(o,{density:`cozy`,columns:s,rows:l,rowKey:(e,t)=>t,empty:t.labels.tableEmpty,...u?{maxHeight:360}:{},virtual:u})}),!r&&c.length>Er&&/* @__PURE__ */ K(n,{variant:`soft`,tone:`primary`,size:`sm`,className:`wui-chat-table-more`,onClick:()=>i(!0),children:t.labels.tableShowAll(c.length)})]})}var jr=/* @__PURE__ */ new Set([`Visitor`,`Customer`]),Mr=/^\d+$/;function Nr({part:e,message:t,turn:n}){let{resolveLink:r,linkComponent:i}=cr(),a=n.features.FigureText,o=n.features.Sources===!0;if(jr.has(t.author.kind))return/* @__PURE__ */ K(`div`,{className:t.restored?`wui-chat-bubble`:`wui-chat-bubble wui-chat-part-enter`,children:/* @__PURE__ */ K(Z,{text:e.text,enabled:a})});let s=n.handoffHosts,c=e=>W(e,s)?e:r?r(e):null,l=o&&n.openCitation?e=>n.openCitation?.(Number(e)):void 0,u=o?n.isCitation??(e=>Mr.test(e)):()=>!1;return/* @__PURE__ */ K(f,{value:e.text,links:`app`,headings:`text`,className:t.restored?`wui-chat-text`:`wui-chat-text wui-chat-part-enter`,resolveLink:c,linkComponent:i,isCitation:u,...a?{figureText:de}:{},...l?{onOpenCitation:l}:{}})}function Pr({part:e,turn:r}){let{labels:i}=r,a=i.ticketStatus(e.status);return/* @__PURE__ */ q(`article`,{className:`wui-chat-ticket`,"aria-label":i.ticketAria(e.number),children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-ticket-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ K(l,{name:`tag`,size:20})}),/* @__PURE__ */ q(`div`,{className:`wui-chat-ticket-body`,children:[/* @__PURE__ */ q(`div`,{className:`wui-chat-ticket-head`,children:[/* @__PURE__ */ K(`b`,{className:`wui-chat-ticket-number`,children:i.ticketAria(e.number)}),a&&/* @__PURE__ */ K(t,{className:`wui-chat-ticket-status`,tone:dt(e.status),children:a})]}),/* @__PURE__ */ K(`strong`,{className:`wui-chat-ticket-title`,children:e.subject})]}),r.openTicket&&/* @__PURE__ */ K(n,{variant:`outline`,size:`sm`,className:`wui-chat-ticket-open`,onClick:()=>r.openTicket?.(e),children:i.ticketView})]})}var Fr=40,Ir=null;function Lr({part:e,turn:t}){let[n,r]=A(!1),[i,a]=A(!1),[o,s]=A(!1),[c,u]=A(!1),[d,f]=A(0),p=k(null),m=k(null),h=k(!1),g=O(()=>me(`${e.attachmentId}|${e.durationMs}`,Fr).map((e,t)=>({id:`bar-${t}`,position:t,height:e})),[e.attachmentId,e.durationMs]),_=C(()=>{p.current?.pause(),Ir===_&&(Ir=null),a(!1)},[]);if(T(()=>(h.current=!0,()=>{h.current=!1,p.current?.pause(),m.current&&URL.revokeObjectURL(m.current),Ir===_&&(Ir=null)}),[_]),!t.features.VoiceClips)return e.transcript?/* @__PURE__ */ K(`p`,{className:`wui-chat-clip-transcript`,children:e.transcript}):null;async function v(){if(i)_();else{r(!0),s(!1);try{if(!p.current){let n=await t.readAttachment(e.attachmentId);if(!h.current)return;m.current=URL.createObjectURL(new Blob([n]));let r=new Audio(m.current);r.addEventListener(`timeupdate`,()=>f(r.currentTime)),r.addEventListener(`ended`,()=>{a(!1),f(0),r.currentTime=0,Ir===_&&(Ir=null)}),r.addEventListener(`error`,()=>{s(!0),a(!1)}),p.current=r}Ir?.(),await p.current.play(),Ir=_,a(!0)}catch{s(!0)}finally{h.current&&r(!1)}}}let y=e.durationMs/1e3,b=Math.floor((y>0?Math.min(1,d/y):0)*Fr);return/* @__PURE__ */ q(`div`,{className:`wui-chat-clip`,role:`group`,"aria-label":t.labels.voiceClip,children:[/* @__PURE__ */ q(`div`,{className:`wui-chat-clip-row`,children:[/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-clip-play`,"aria-label":i?t.labels.voiceClipPause:t.labels.voiceClipPlay,"aria-busy":n,disabled:n,onClick:v,children:/* @__PURE__ */ K(l,{name:i?`pause`:`play`,size:16,"aria-hidden":`true`})}),/* @__PURE__ */ K(`div`,{className:`wui-chat-clip-wave`,"aria-hidden":`true`,children:g.map(({id:e,position:t,height:n})=>{let r={"--wui-chat-bar-height":`${Math.round(n*100)}%`};return/* @__PURE__ */ K(`span`,{className:t<b?`wui-chat-clip-bar wui-chat-clip-bar--played`:`wui-chat-clip-bar`,style:r},e)})}),/* @__PURE__ */ K(`span`,{className:`wui-chat-clip-time`,children:t.labels.voiceClipTime(V(d),V(Math.max(1,Math.round(y))))})]}),o&&/* @__PURE__ */ K(`p`,{className:`wui-chat-clip-error`,role:`status`,children:t.labels.voiceClipFailed}),e.transcript?/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-clip-toggle`,"aria-expanded":c,onClick:()=>u(!c),children:c?t.labels.voiceClipHideTranscript:t.labels.voiceClipShowTranscript}),c&&/* @__PURE__ */ K(`p`,{className:`wui-chat-clip-transcript`,children:e.transcript})]}):null]})}function Rr(e,t){return e.kind===t}function Q(e,t){function n(n){if(!Rr(n.part,e))throw Error(`renderer for ${e} received a ${n.part.kind} part`);return S(t,{part:n.part,message:n.message,turn:n.turn})}return n}var zr=/* @__PURE__ */ new WeakMap;function Br(e,t){let n=zr.get(t)??/* @__PURE__ */ new Map,r=n.get(e);if(r)return r;function i(n){if(!Rr(n.part,e))throw Error(`renderer for ${e} received a ${n.part.kind} part`);return S(t,{part:n.part,message:n.message,turn:n.turn})}return n.set(e,i),zr.set(t,n),i}var Vr={Text:Q(`Text`,Nr),Sources:Q(`Sources`,Cr),QuickReplies:Q(`QuickReplies`,_r),InputRequest:Q(`InputRequest`,nr),Action:Q(`Action`,En),Notice:Q(`Notice`,or),Table:Q(`Table`,Ar),Chart:Q(`Chart`,jn),Figures:Q(`Figures`,Rn),RecordCard:Q(`RecordCard`,br),Image:Q(`Image`,Un),File:Q(`File`,zn),Ticket:Q(`Ticket`,Pr),Handoff:Q(`Handoff`,Vn),VoiceClip:Q(`VoiceClip`,Lr)};function $(e,t){let n=t?.[e];return n?Br(e,n):Vr[e]}function Hr(e){return{Text:$(`Text`,e),Sources:$(`Sources`,e),QuickReplies:$(`QuickReplies`,e),InputRequest:$(`InputRequest`,e),Action:$(`Action`,e),Notice:$(`Notice`,e),Table:$(`Table`,e),Chart:$(`Chart`,e),Figures:$(`Figures`,e),RecordCard:$(`RecordCard`,e),Image:$(`Image`,e),File:$(`File`,e),Ticket:$(`Ticket`,e),Handoff:$(`Handoff`,e),VoiceClip:$(`VoiceClip`,e)}}var Ur=48,Wr={Visitor:`you`,Customer:`you`,Agent:`agent`,Assistant:`assistant`,Script:`assistant`,System:`assistant`};function Gr(e,t){let n=e.author.kind;return e.author.displayName&&n!==`Visitor`&&n!==`Customer`?e.author.displayName:t[Wr[n]??`assistant`]}function Kr(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(r!==void 0&&t(r))return n}return-1}function qr(e,t){let n=/* @__PURE__ */ new Map,r=[];for(let i of e){let e=t(i),a=n.get(e)??0;n.set(e,a+1),r.push({key:`${e}#${a}`,item:i})}return r}function Jr({chat:e,labels:t,renderers:r,layoutParts:i,loader:a,motion:o,onOpenAttachment:s,onOpenTarget:c,onOpenTicket:l,onNavigate:u}){let d=k(null),f=k(!0),p=k(/* @__PURE__ */ new Map),m=O(()=>Hr(r),[r]),h=u??e.onNavigate,g=e.pending?.authorKind,_=g===`Agent`||g===`Customer`?`None`:a===`Orb`?`Orb`:`Assistant`,v=e.messages.at(-1),b=e.messages.find(e=>!(e.streaming&&e.parts.length===0)),x=e.greeting&&b&&(b.author.kind===`Visitor`||b.author.kind===`Customer`)?{id:`greeting`,createdDateTimeUtc:b.createdDateTimeUtc,author:{kind:`Assistant`,displayName:null,avatarUrl:null},parts:[{kind:`Text`,text:e.greeting}],sequence:null,rating:null,ratingNote:null,stored:!1,streaming:!1,restored:!1}:null,S=x?[x,...e.messages]:e.messages,C=S.filter(e=>!(e.streaming&&e.parts.length===0)),w=!e.streaming&&(e.turnError!==null||e.stopped),E=e.turnError?.code===`daily_limit`,D=typeof e.turnError?.code==`string`&&e.turnError.code.endsWith(`feature_off`),A=e.pending?.typing===!0,j=`${v?Xt(v):``}|${e.thinking}|${A}|${w}`,M=Kr(e.messages,e=>e.author.kind===`Visitor`&&e.stored),N=e.profile?.experience.pacing,ee=e.profile?.assistant.name??``;T(()=>{if(!j)return;let e=Yt(d.current);e&&(e.scrollTop=e.scrollHeight,f.current=!0)},[j]),T(()=>{let e=d.current;if(!e||typeof ResizeObserver!=`function`)return;let t=null,n=()=>{t&&(f.current=t.scrollHeight-t.scrollTop-t.clientHeight<=Ur)},r=new ResizeObserver(()=>{let r=Yt(e);r!==t&&(t?.removeEventListener(`scroll`,n),t=r,t?.addEventListener(`scroll`,n,{passive:!0})),t&&f.current&&(t.scrollTop=t.scrollHeight)});return r.observe(e),()=>{t?.removeEventListener(`scroll`,n),r.disconnect()}},[]);function P(e,t){p.current.get(e)?.querySelector(`[data-marker="${t}"]`)?.focus()}function F(e,t,n,r){let i=m[n.kind];return/* @__PURE__ */ K(`div`,{className:`wui-chat-part wui-chat-part--${n.kind.toLowerCase()}`,children:/* @__PURE__ */ K(i,{part:n,message:e,turn:t})},r)}return/* @__PURE__ */ K(`div`,{role:`log`,"aria-live":`polite`,"aria-label":t.thread,children:/* @__PURE__ */ q(`ol`,{ref:d,className:`wui-chat-thread`,children:[S.map((n,r)=>{if(n.streaming&&n.parts.length===0)return null;let a=z(e.session,{messageId:n.id,labels:t,openAttachment:s??(t=>qt(e.client,t)),openTarget:c??Jt,...l?{openTicket:l}:{},openCitation:e=>P(n.id,e),onNavigate:h}),o=n===x,u=x?r-1:r,d=C[C.indexOf(n)-1],f=n.author.kind===`Agent`&&d?.author.kind===`Agent`&&(d.author.displayName??``)===(n.author.displayName??``),m=i?i(n):null,g=ne(n.createdDateTimeUtc,t),_=d===void 0||ne(d.createdDateTimeUtc,t)!==g;return/* @__PURE__ */ q(y,{children:[_?/* @__PURE__ */ K(`li`,{className:`wui-chat-day`,role:`presentation`,children:/* @__PURE__ */ K(`span`,{children:g})}):null,/* @__PURE__ */ q(`li`,{ref:e=>{e?p.current.set(n.id,e):p.current.delete(n.id)},className:`wui-chat-message wui-chat-message--${n.author.kind.toLowerCase()}`,"aria-busy":n.streaming?`true`:void 0,"data-restored":n.restored?``:void 0,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-author visually-hidden`,children:`${Gr(n,t)}: `}),f?null:/* @__PURE__ */ K(Pt,{author:n.author,labels:t}),/* @__PURE__ */ K(`div`,{className:`wui-chat-message-body`,children:m?qr(m,e=>Array.isArray(e)?`group`:`part`).map(({key:e,item:t})=>/* @__PURE__ */ K(`div`,{className:`wui-chat-part-group`,children:qr(Array.isArray(t)?t:[t],e=>e.kind).map(({key:e,item:t})=>F(n,a,t,e))},e)):qr(n.parts,e=>e.kind).map(({key:e,item:t})=>F(n,a,t,e))}),o?null:/* @__PURE__ */ K(`div`,{className:`wui-chat-message-actions`,children:/* @__PURE__ */ K(tn,{chat:e,message:n,labels:t,isLast:n===v,isLastVisitor:!o&&u===M})})]})]},n.id)}),/* @__PURE__ */ K(Nt,{chat:e,labels:t}),A&&/* @__PURE__ */ K(`li`,{className:`wui-chat-message wui-chat-message--assistant wui-chat-message--loading`,children:/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-slot`,children:/* @__PURE__ */ K(gn,{motion:o??`On`,mark:_})})}),e.thinking&&/* @__PURE__ */ K(`li`,{className:`wui-chat-message wui-chat-message--assistant wui-chat-message--loading`,children:/* @__PURE__ */ K(`div`,{className:`wui-chat-loader-slot`,children:/* @__PURE__ */ K(hn,{style:a??`Steps`,steps:e.steps,phrases:N?.thinkingPhrases??[],intervalMs:N?.phraseIntervalMs??2500,announce:t.preparingAnswer(ee),motion:o??`On`})})}),w&&/* @__PURE__ */ q(`li`,{className:`wui-chat-message wui-chat-message--system wui-chat-message--error`,children:[E?/* @__PURE__ */ q(`p`,{className:`wui-chat-error wui-chat-error--info`,role:`status`,children:[e.turnError?.message,e.turnError?.resetsDateTimeUtc?` ${t.dailyLimitRefresh(xt(e.turnError.resetsDateTimeUtc))}`:``]}):/* @__PURE__ */ K(`p`,{className:`wui-chat-error`,role:`alert`,children:e.turnError?.message??t.stopped}),e.features.Retry&&!E&&!D&&/* @__PURE__ */ K(`div`,{className:`wui-chat-message-actions`,children:/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>e.retry().catch(e=>globalThis.reportError?.(e)),children:t.retry})})]})]})})}var Yr=e=>e===`Assistant`||e===`Script`||e===`Agent`;function Xr(e,t,n){if(t){e.wasLoading=!0;for(let t of n)e.seen.add(t.id);return[]}if(e.wasLoading||!e.seeded){e.wasLoading=!1,e.seeded=!0;for(let t of n)e.seen.add(t.id);return[]}let r=[];for(let t of n)e.seen.has(t.id)||(e.seen.add(t.id),r.push(t));return r}function Zr(e){let t=e.features.Sounds?e.profile?.experience.sound??null:null,n=k(null),r=k(e);r.current=e;let i=k(e.open),a=k({seen:/* @__PURE__ */ new Set,seeded:!1,wasLoading:!1}),o=t!==null&&(t.open||t.sent||t.reply||t.vibrate);T(()=>{if(!o)return;let e=_e(t,Wt);return n.current=e,e.setMuted(r.current.muted),()=>{e.destroy(),n.current=null}},[o,t]);let{open:s,loading:c,messages:l,muted:u}=e;T(()=>{n.current?.setMuted(u)},[u]),T(()=>{let e=n.current,o=i.current;i.current=s;let u=Xr(a.current,c,l);if(e){s&&!o&&e.play(`open`);for(let n of u){if(n.restored||n.parts.some(e=>e.kind===`Notice`))continue;let i=n.author.kind;i===`Visitor`?n.stored||e.play(`sent`):Yr(i)&&(e.play(`reply`),t?.vibrate&&Te(t.vibrateMs,r.current.muted))}}},[s,c,l,t])}function Qr({chat:e,labels:t,layout:n,onClose:r,panelId:i,inputRef:a,ariaLabelOverride:o,renderers:s,layoutParts:c,loader:u,motion:d,onOpenAttachment:f,onOpenTarget:p,onOpenTicket:m,onNavigate:h,resolveLink:g=null,linkComponent:_,onSwitch:v,open:y=!0,renderEmpty:b,sendIcon:x=`arrow-up`}){let[S,C]=A(`chat`),w=O(()=>({resolveLink:g,linkComponent:_}),[g,_]);Zr(e);let{features:T}=e,E=e.profile,D=S===`history`&&T.History===!0,k=e.messages.length>0,j=n===`launcher`||n===`docked`,M=E?.experience.sound,N=!!(T.Sounds&&M?.muteControl),ee=j?`dialog`:`region`,P=o??E?.assistant.name??t.panelTitle,F=T.PanelSwitch===!0,I=e.messages.some(e=>e.author.kind===`Visitor`||e.author.kind===`Customer`),L=n===`full-page`||I,te=F&&typeof v==`function`&&(n===`docked`||n===`full-page`),R=n===`full-page`&&F&&typeof r==`function`;function z(){C(`chat`),r?.()}function B(){if(e.profileError)return/* @__PURE__ */ K(`p`,{className:`wui-chat-profile-error`,role:`alert`,children:e.profileError.message});if(!E&&(n===`full-page`||n===`embedded`)||e.loading)return/* @__PURE__ */ K(`p`,{role:`status`,"aria-busy":`true`,children:t.loadingConversation});if(e.loadError)return/* @__PURE__ */ K(`p`,{className:`wui-chat-profile-error`,role:`alert`,children:e.loadError.message});if(!k){let n=/* @__PURE__ */ q(G,{children:[/* @__PURE__ */ K(Mt,{chat:e,labels:t,onOpenTicket:m}),T.History&&/* @__PURE__ */ K(Dt,{chat:e,labels:t,open:y})]});return b?b({chat:e,labels:t,open:y,defaultEmpty:n}):n}return/* @__PURE__ */ K(sr.Provider,{value:w,children:/* @__PURE__ */ K(Jr,{chat:e,labels:t,renderers:s,layoutParts:c,loader:u,motion:d,onOpenAttachment:f,onOpenTarget:p,onOpenTicket:m,onNavigate:h})})}return/* @__PURE__ */ q(`section`,{id:i,className:`wui-chat-panel`,role:ee,"aria-label":P,children:[/* @__PURE__ */ q(`header`,{className:`wui-chat-header`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-orb`,"aria-hidden":`true`}),/* @__PURE__ */ q(`div`,{className:`wui-chat-header-text`,children:[/* @__PURE__ */ K(`strong`,{className:`wui-chat-title`,children:E?.assistant.name??``}),/* @__PURE__ */ K(`span`,{className:`wui-chat-status`,children:pt(e,t)??t.headerStatus})]}),/* @__PURE__ */ q(`div`,{className:`wui-chat-header-actions`,children:[!D&&/* @__PURE__ */ K(nt,{chat:e,labels:t}),T.History&&(D?/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.backToChat,title:t.backToChat,onClick:()=>C(`chat`),children:/* @__PURE__ */ K(l,{name:`arrow-left`,size:18,"aria-hidden":`true`})}):/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.history,title:t.history,onClick:()=>C(`history`),children:/* @__PURE__ */ K(l,{name:`history`,size:18,"aria-hidden":`true`})})),N&&/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":e.muted?t.unmuteSounds:t.muteSounds,title:e.muted?t.unmuteSounds:t.muteSounds,onClick:()=>e.session.setMuted(!e.muted),children:/* @__PURE__ */ K(l,{name:e.muted?`volume-mute`:`volume-high`,size:18,"aria-hidden":`true`})}),!D&&L&&/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn`,"aria-label":t.newChat,title:t.newChat,disabled:e.streaming||e.thinking,onClick:()=>e.newConversation(),children:/* @__PURE__ */ K(l,{name:`plus`,size:18,"aria-hidden":`true`})}),te&&/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn wui-chat-icon-btn--switch`,"aria-label":n===`docked`?t.openFullScreen:t.openSidePanel,title:n===`docked`?t.openFullScreen:t.openSidePanel,disabled:e.streaming||e.thinking,onClick:()=>v(),children:/* @__PURE__ */ K(l,{name:n===`docked`?`maximize-4`:`panel-left-open`,size:18,"aria-hidden":`true`})}),(j||R)&&/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-icon-btn wui-chat-close-btn`,"aria-label":t.close,title:t.close,onClick:z,children:/* @__PURE__ */ K(l,{name:`x`,size:18,"aria-hidden":`true`})})]})]}),/* @__PURE__ */ K(`div`,{className:`wui-chat-body`,children:D?/* @__PURE__ */ K(ct,{chat:e,labels:t,onOpen:()=>C(`chat`)}):B()}),!D&&/* @__PURE__ */ q(`div`,{className:`wui-chat-foot`,children:[/* @__PURE__ */ K(gt,{chat:e,labels:t}),/* @__PURE__ */ K(qe,{chat:e,labels:t,maxLength:E?.limits.maxMessageLength??4e3,inputRef:a,sendIcon:x}),/* @__PURE__ */ K(at,{chat:e,labels:t})]})]})}function $r(e,t){let n=k(!1);T(()=>{n.current||(n.current=!0,typeof t?.conversationId==`string`&&t.conversationId!==``&&e.openConversation(t.conversationId).catch(e=>globalThis.reportError?.(e)),typeof t?.draft==`string`&&t.draft!==``&&e.session.open({draft:t.draft}))},[e,t])}function ei(e,t){let[n,r]=A(!1);return T(()=>{let n=De(e,t??null);r(n.reduced);let i=n.subscribe(()=>r(n.reduced));return()=>{i(),n.destroy()}},[e,t]),n}function ti({chat:e,labels:t,renderers:n,layoutParts:r,loader:i,motion:a=`On`,onOpenAttachment:o,onOpenTarget:s,onNavigate:c,resolveLink:l,linkComponent:u,className:d,style:f,theme:p,look:m,onOpenSidePanel:h,onClose:g,renderEmpty:_,handoff:v}){let y=k(null);$r(e,v??null);let b=e.features.PanelSwitch===!0&&typeof h==`function`?()=>{let t={conversationId:e.conversationId,draft:y.current?.value??``,from:`full-page`,to:`docked`};Ce(()=>h(t),{target:`docked`}).catch(e=>globalThis.reportError?.(e))}:void 0;return/* @__PURE__ */ K(ni,{layout:`full-page`,chat:e,labelOverrides:t,renderers:n,layoutParts:r,loader:i,motion:a,onOpenAttachment:o,onOpenTarget:s,onNavigate:c,resolveLink:l,linkComponent:u,className:d,style:f,theme:p,look:m,inputRef:y,onSwitch:b,onClose:g,renderEmpty:_})}function ni({layout:e,chat:t,labelOverrides:n,renderers:r,layoutParts:i,loader:a,motion:o,onOpenAttachment:s,onOpenTarget:c,onNavigate:l,resolveLink:u=null,linkComponent:d,className:f,style:p,theme:m,look:h,inputRef:g,onSwitch:_,onClose:v,renderEmpty:y}){let b=O(()=>oe(n),[n]),x=O(()=>se(h),[h]),S=ei(x,t.profile?.experience??null),C=o===`Reduced`||S?`Reduced`:`On`;if(t.profile!==null&&!t.features.VisitorChat)return null;let w=[`wui-chat`,`wui-chat--${e}`,Zt(C),x.input.sendReveal===`Always`?`wui-chat--send-always`:null,x.input.ring===!1?`wui-chat--input-ring-off`:null,x.panel.replyAvatars===!1?`wui-chat--reply-avatars-off`:null,x.expressive?`wui-chat--expressive`:null,f].filter(Boolean).join(` `),T=x.avatar?{"--wui-chat-avatar":`url(${JSON.stringify(x.avatar)})`,"--wui-chat-typing-mark":`url(${JSON.stringify(x.avatar)})`,...p}:p;return/* @__PURE__ */ K(`div`,{className:w,style:T,"data-state":`open`,"data-theme":m===`auto`?void 0:m,children:/* @__PURE__ */ K(Qr,{chat:t,labels:b,layout:e,sendIcon:x.input.sendIcon,panelId:void 0,renderers:r,layoutParts:i,loader:a,motion:C,onOpenAttachment:s,onOpenTarget:c,onNavigate:l,resolveLink:u,linkComponent:d,inputRef:g,onSwitch:_,onClose:v,renderEmpty:y})})}function ri({labels:e,...t}){return/* @__PURE__ */ K(ni,{...t,labelOverrides:e,layout:`embedded`})}var ii=`a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`;function ai(e){return e!=null&&`focus`in e}function oi(e){let t=k(null);return T(()=>{let n=document.activeElement,r=t.current?.querySelector(ii);return ai(r)&&r.focus({preventScroll:!0}),()=>{let t=e.current??n;ai(t)&&t.focus({preventScroll:!0})}},[e]),T(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let n=0,r=new ResizeObserver(()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>window.dispatchEvent(new Event(`scroll`)))});return r.observe(e),()=>{cancelAnimationFrame(n),r.disconnect()}},[]),t}function si({x:e,labels:t,renderAnswer:r,renderFoot:i,askDraft:a,chat:o,close:s,triggerRef:c}){let l=oi(c),{state:u,answer:d,pillVisible:f,resetsDateTimeUtc:p}=e,m=null;if((u===`thinking`||u===`slow`)&&f)m=/* @__PURE__ */ q(`div`,{className:`wui-chat-explain-pill`,role:`status`,children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-explain-pill-dot`,"aria-hidden":`true`}),/* @__PURE__ */ K(`span`,{children:u===`slow`?t.explainSlow:t.thinking})]});else if(u===`answered`)m=/* @__PURE__ */ K(`div`,{className:`wui-chat-explain-answer`,children:r({answer:d,labels:t,close:s})});else if(u===`empty`)m=/* @__PURE__ */ K(`p`,{className:`wui-chat-explain-note`,children:t.explainEmpty});else if(u===`capacity`){let e=xt(p);m=/* @__PURE__ */ K(`p`,{className:`wui-chat-explain-notice wui-chat-explain-notice--info`,role:`status`,children:e?t.explainCapacity(e):t.explainCapacityNoDate})}else u===`error`&&(m=/* @__PURE__ */ q(`div`,{className:`wui-chat-explain-notice wui-chat-explain-notice--error`,role:`alert`,children:[/* @__PURE__ */ K(`p`,{children:t.explainError}),/* @__PURE__ */ K(n,{className:`wui-chat-action-btn`,size:`sm`,variant:`ghost`,onClick:()=>e.ask(),children:t.explainRetry})]}));let h=typeof a==`string`&&a!==``&&typeof o.session?.open==`function`?a:null;return/* @__PURE__ */ q(`div`,{ref:l,className:`wui-chat-explain`,children:[m,/* @__PURE__ */ q(`div`,{className:`wui-chat-explain-foot`,children:[i?.({close:s}),h!==null&&/* @__PURE__ */ K(n,{className:`wui-chat-explain-more`,size:`sm`,variant:`ghost`,onClick:()=>{s(),o.session.open({draft:h})},children:t.explainAskMore}),/* @__PURE__ */ K(`p`,{className:`wui-chat-explain-note`,children:t.explainNotCounted})]})]})}function ci({chat:e,request:t,renderAnswer:n,label:r,renderFoot:i,askDraft:a,labels:o,placement:s=`auto`,className:c,triggerContent:u}){let d=O(()=>oe(o),[o]),[f,p]=A(!1),h=bt({request:t,enabled:e.features.Explain===!0}),g=k(null),_=k(!1);if(T(()=>{if(!f)return;let e=e=>{let t=e.target;_.current=t instanceof Element&&t.closest(`.wui-chat-panel`)!==null};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[f]),!e.features.Explain)return null;function y(e){!e&&(_.current||document.querySelector(`.wui-chat--docked[data-open=true]`))?_.current=!1:(p(e),e?h.ask():h.reset())}function b(){p(!1),h.reset()}let x=/* @__PURE__ */ q(`button`,{type:`button`,className:[`wui-chat-explain-trigger`,f?`wui-chat-explain-trigger--open`:null].filter(Boolean).join(` `),"aria-haspopup":`dialog`,"aria-label":d.explainTriggerLabel(r),disabled:h.offline,onClick:e=>{g.current=e.currentTarget},children:[/* @__PURE__ */ K(l,{name:`magic-star`,size:14,"aria-hidden":`true`}),u??d.explainTrigger]});return h.offline?/* @__PURE__ */ K(v,{content:d.explainOffline,children:/* @__PURE__ */ K(`span`,{className:`wui-chat-explain-offline`,children:x})}):/* @__PURE__ */ K(m,{trigger:x,title:r,placement:s,open:f,onOpenChange:y,role:`dialog`,className:[`wui-chat-explain-pop`,c].filter(Boolean).join(` `),children:f?/* @__PURE__ */ K(si,{x:h,labels:d,renderAnswer:n,renderFoot:i,askDraft:a,chat:e,close:b,triggerRef:g}):null})}function li({chat:e,labels:t,enabled:n,onActivate:r}){let i=e.profile?le(e.profile,e.features):null,[a,o]=A(!1),[s,c]=A(!1),[u,d]=A(!1),f=(i?.delaySeconds??0)*1e3;return T(()=>{if(!n||!i||s){o(!1);return}if(u)return;let e=setTimeout(()=>{o(!0),d(!0)},f);return()=>clearTimeout(e)},[n,i,f,s,u]),!a||!i||s?null:/* @__PURE__ */ q(`div`,{className:`wui-chat-nudge`,role:`status`,children:[/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-nudge-text`,onClick:r,children:i.text}),/* @__PURE__ */ K(`button`,{type:`button`,className:`wui-chat-nudge-close`,"aria-label":t.nudgeDismiss,onClick:()=>c(!0),children:/* @__PURE__ */ K(l,{name:`x`,size:14,"aria-hidden":`true`})})]})}function ui(e,t,n,r){T(()=>{let i=e.current;if(!r||!i||!n)return;let a=he(t,n,i);return()=>a.destroy()},[e,t,n,r])}var di=620,fi=300,pi=`wchat:peeked`,mi=576,hi=200;function gi(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function _i(e){return e?.querySelector(`:scope > .wui-chat-panel`)??null}function vi(e){let[t,n]=A(()=>globalThis.innerWidth<=e);return T(()=>{let t=()=>n(globalThis.innerWidth<=e);return t(),globalThis.addEventListener(`resize`,t),()=>globalThis.removeEventListener(`resize`,t)},[e]),t}function yi({chat:e,layout:t,labels:n,renderers:r,layoutParts:i,loader:a,motion:o=`On`,onOpenAttachment:s,onOpenTarget:c,onNavigate:u,resolveLink:d=null,linkComponent:f,className:p,style:m,theme:h,icon:g=`chat`,look:_,open:v,defaultOpen:y=!1,onOpenChange:b,position:x=`end`,offsetX:S=24,offsetY:w=24,panelId:j,switchConfig:M=null,renderEmpty:N}){let ee=E(),P=j??ee,F=O(()=>oe(n),[n]),I=O(()=>se(_),[_]),L=e.profile,te=e.features,R=v!==void 0,z=R?v:e.open,B=ei(I,L?.experience??null),ne=o===`Reduced`||B?`Reduced`:`On`,re=I.panel.motion===`None`?0:fi,V=L!==null&&te.VisitorChat,H=t===`launcher`||t===`docked`,U=vi(I.phone.maxWidthPx),W=L?.experience.launcher??null,ie=I.launcher.style===`Pill`?`pill`:`round`,ae=I.launcher.labelReveal===`Expand`?`expand`:`bubble`,ce=I.launcher.idle===`None`?`none`:gi(I.launcher.idle),le=I.launcher.entrance===`None`?null:gi(I.launcher.entrance),ue=W?.hideWhileOpen===!0||I.expressive===!0,de=W?.peek===!0,fe=W?.peekSeconds??3,pe=e.messages.length>0,me=k(null),he=k(null),ge=k(null),_e=k(null),ve=k(!1),Te=k(z),Ee=k(z),De=k(!1),G=k(b);G.current=b;let[Oe,ke]=A(z?`open`:`closed`),[Ae,J]=A(null),[je,Me]=A(null),Y=Ae??(le&&!U?`entering`:`idle`);ui(me,I.avoid,W,t===`launcher`&&V);let Ne=C(e=>{Te.current!==e&&(Te.current=e,G.current?.(e))},[]),Pe=C((t,n)=>{ve.current=t,Ne(t),R||(t?e.session.open({trigger:`manual`}):e.session.close(n))},[R,e.session,Ne]);T(()=>{R&&(v&&!e.open&&e.session.open({trigger:`manual`}),!v&&e.open&&e.session.close(`button`))},[R,v,e.open,e.session]),T(()=>{!R&&y&&e.session.open({trigger:`manual`})},[R,y,e.session]),T(()=>{Ne(e.open)},[e.open,Ne]),T(()=>{if(z){ke(e=>e===`open`?e:`opening`);let e=setTimeout(()=>ke(`open`),di);return()=>clearTimeout(e)}ke(e=>e===`closed`?e:`closing`);let e=setTimeout(()=>ke(`closed`),re);return()=>clearTimeout(e)},[z,re]),T(()=>{Ee.current!==z&&(Ee.current=z,Me(z?`wui-chat-launcher--opening`:`wui-chat-launcher--closing`))},[z]),D(()=>{if(Oe!==`opening`)return;let e=_i(he.current),t=ge.current;e&&t&&be(e,t.getBoundingClientRect())},[Oe]),T(()=>{if(!ue){J(e=>e===`hidden`?`idle`:e);return}if(z){J(`hidden`);return}if(Ae!==`hidden`)return;let e=_i(he.current)?.contains(document.activeElement)??!1,t=setTimeout(()=>{De.current=e,J(`idle`)},hi);return()=>clearTimeout(t)},[z,ue,Ae]),T(()=>{Y===`idle`&&De.current&&(De.current=!1,Se(ge.current))},[Y]);let Fe=k(!1);T(()=>{let e=Fe.current;Fe.current=z,z||!e||ue||Se(ge.current)},[z,ue]),T(()=>{z&&J(e=>e===`peeking`?`idle`:e)},[z]),T(()=>{V&&Y===`idle`&&de&&!B&&!z&&(globalThis.innerWidth<mi||globalThis.sessionStorage.getItem(pi)!==null||(globalThis.sessionStorage.setItem(pi,`1`),J(`peeking`)))},[V,Y,de,B,z]),T(()=>{if(Y!==`peeking`)return;let e=setTimeout(()=>J(e=>e===`peeking`?`idle`:e),fe*1e3);return()=>clearTimeout(e)},[Y,fe]);let Ie=k(Pe);Ie.current=Pe,T(()=>{if(!z||!H)return;let e=e=>{e.key===`Escape`&&Ie.current(!1,`escape`)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[z,H]),T(()=>{let e=_i(he.current);if(!V||!H||!e)return;let t=t=>we(e,t);return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[V,H]),T(()=>{if(!z||U||!ve.current)return;let e=setTimeout(()=>_e.current?.focus(),400);return()=>clearTimeout(e)},[z,U]),T(()=>{let e=_i(he.current);if(!V||!z||!U||!H||!e)return;let t=ye(e,I);return()=>t.destroy()},[V,z,U,H,I]),T(()=>{let e=he.current?.querySelector(`.wui-chat-thread`);if(V&&z&&U&&H&&pe&&e)return xe(e)},[V,z,U,H,pe]),T(()=>{if(t!==`docked`||!z||typeof document>`u`)return;let e=document.documentElement,n=document.getElementById(P);e.dataset.wchatDocked=``;let r=null;if(n){let t=()=>e.style.setProperty(`--wchat-docked-width`,`${n.getBoundingClientRect().width}px`);t(),typeof ResizeObserver<`u`&&(r=new ResizeObserver(t),r.observe(n))}return()=>{r?.disconnect(),e.removeAttribute(`data-wchat-docked`),e.style.removeProperty(`--wchat-docked-width`)}},[t,z,P]);let Le=M?.preload,Re=k(!1);if(T(()=>{z&&!Re.current&&(Re.current=!0,Promise.allSettled([new Promise(e=>e(Le?.()))]).then(e=>{for(let t of e)t.status===`rejected`&&globalThis.reportError?.(t.reason)}))},[z,Le]),!V)return null;let ze=M?()=>{let n={conversationId:e.conversationId,draft:_e.current?.value??``,from:t,to:M.target};Ce(()=>(Pe(!1,`button`),M.onSwitch(n)),{target:M.target}).catch(e=>globalThis.reportError?.(e))}:void 0,Be=[`wui-chat`,`wui-chat--${t}`,`wui-chat--${x}`,Zt(ne),H&&U?`wui-chat--phone`:null,I.phone.mode===`Sheet`?`wui-chat--sheet`:null,I.input.sendReveal===`Always`?`wui-chat--send-always`:null,I.input.ring===!1?`wui-chat--input-ring-off`:null,I.panel.motion===`Gentle`?`wui-chat--panel-motion-gentle`:null,I.panel.motion===`None`?`wui-chat--panel-motion-none`:null,I.panel.height===`Content`?`wui-chat--panel-height-content`:null,I.panel.replyAvatars===!1?`wui-chat--reply-avatars-off`:null,I.expressive?`wui-chat--expressive`:null,p].filter(Boolean).join(` `),Ve={...I.avatar?{"--wui-chat-avatar":`url(${JSON.stringify(I.avatar)})`,"--wui-chat-typing-mark":`url(${JSON.stringify(I.avatar)})`}:null,"--wui-chat-offset-x":`${S}px`,"--wui-chat-offset-y":`${w}px`,"--wui-chat-width":`${I.panel.widthPx}px`,"--wui-chat-panel-max-height":`${I.panel.maxHeightPx}px`,"--wui-chat-bottom-gap":`${I.panel.bottomGapPx}px`,"--wui-chat-sheet-height":`${I.phone.sheetHeightDvh}dvh`,"--wui-chat-sheet-max-height":`${I.phone.sheetMaxHeightPx}px`,...m},He=[`wui-chat-launcher-wrap`,Y===`entering`&&le?`wui-chat-launcher--entrance-${le}`:null,Y===`idle`&&ce!==`none`&&(ce!==`ring`||ie===`pill`)?`wui-chat-launcher--idle-${ce}`:null].filter(Boolean).join(` `),Ue=[`wui-chat-launcher`,`wui-chat-launcher--${ie}`,ie===`pill`&&I.launcher.compact?`wui-chat-launcher--compact`:null,I.launcher.mark===`Icon`?null:`wui-chat-launcher--mark-${gi(I.launcher.mark)}`,`wui-chat-launcher--reveal-${ae}`,je].filter(Boolean).join(` `),We=t===`launcher`&&!z&&te.Nudges,Ge=z?F.launcherClose:W?.hoverLabel||F.launcher;return/* @__PURE__ */ q(`div`,{ref:he,className:Be,style:Ve,"data-state":Oe,"data-open":z?`true`:`false`,"data-theme":h===`auto`?void 0:h,children:[/* @__PURE__ */ q(`div`,{ref:me,className:He,"data-launcher":Y,inert:Y===`hidden`,onAnimationEnd:e=>{e.target===e.currentTarget&&Y===`entering`&&J(`idle`)},children:[/* @__PURE__ */ K(li,{chat:e,labels:F,enabled:We,onActivate:()=>Pe(!0,`launcher`)}),/* @__PURE__ */ q(`button`,{ref:ge,type:`button`,className:Ue,"aria-haspopup":`dialog`,"aria-expanded":z,"aria-controls":P,"aria-label":Ge,onClick:()=>Pe(!z,`launcher`),onAnimationEnd:e=>{e.target===e.currentTarget&&Me(null)},children:[/* @__PURE__ */ K(`span`,{className:`wui-chat-launcher-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ K(l,{name:g,size:24,"aria-hidden":`true`})}),/* @__PURE__ */ K(`span`,{className:`wui-chat-launcher-close`,"aria-hidden":`true`,children:/* @__PURE__ */ K(l,{name:`x`,size:20,"aria-hidden":`true`})}),/* @__PURE__ */ K(`span`,{className:`wui-chat-launcher-label`,children:Ge})]}),/* @__PURE__ */ K(`span`,{className:`wui-chat-launcher-bubble`,"aria-hidden":`true`,children:W?.hoverLabel||F.launcher})]}),/* @__PURE__ */ K(Qr,{chat:e,labels:F,layout:t,sendIcon:I.input.sendIcon,panelId:P,inputRef:_e,onClose:()=>Pe(!1,`button`),onSwitch:ze,open:z,renderEmpty:N,renderers:r,layoutParts:i,loader:a,motion:ne,onOpenAttachment:s,onOpenTarget:c,onNavigate:u,resolveLink:d,linkComponent:f})]})}function bi({enabled:e,settings:t,look:n,session:r,isOpen:i,panelId:a}){let o=k(i);o.current=i,T(()=>{if(!e||!t)return;let i=Ee(t,n,{open:()=>r.open({trigger:`auto`}),isOpen:()=>o.current,panelRect:()=>document.getElementById(a)?.getBoundingClientRect()??null});return()=>i.cancel()},[e,t,n,r,a])}function xi(e){let{chat:t,look:n}=e,r=E(),i=O(()=>se(n),[n]);return bi({enabled:t.features.AutoOpen&&t.profile!==null,settings:t.profile?.experience.autoOpen??null,look:i,session:t.session,isOpen:t.open,panelId:r}),/* @__PURE__ */ K(yi,{...e,layout:`launcher`,panelId:r})}function Si({onOpenFullScreen:e,preloadFullPage:t,...n}){let r=n.chat.features.PanelSwitch===!0&&typeof e==`function`?{onSwitch:e,target:`full-page`,preload:t}:null;return/* @__PURE__ */ K(yi,{...n,layout:`docked`,switchConfig:r})}var Ci=`https://www.google.com/recaptcha/api.js?render=`;function wi(e){return e!==void 0&&typeof e.ready==`function`&&typeof e.execute==`function`}var Ti=/* @__PURE__ */ new Map;function Ei(e){let t=Ti.get(e);if(t!==void 0)return t;let n=new Promise((t,n)=>{let r=globalThis.grecaptcha;if(wi(r)){t(r);return}let i=document.createElement(`script`);i.src=Ci+encodeURIComponent(e),i.async=!0;let a=t=>{Ti.delete(e),n(Object.assign(Error(t),{code:`captcha_unavailable`}))};i.addEventListener(`load`,()=>{let e=globalThis.grecaptcha;e===void 0||typeof e.ready!=`function`?a(`The reCAPTCHA script loaded without grecaptcha.`):e.ready(()=>{let e=globalThis.grecaptcha;wi(e)?t(e):a(`reCAPTCHA became ready without execute.`)})}),i.addEventListener(`error`,()=>{Ti.delete(e),n(/* @__PURE__ */ Error(`The reCAPTCHA script did not load.`))}),document.head.append(i)});return Ti.set(e,n),n}async function Di(e,t){let n=await Ei(e);await new Promise(e=>n.ready(e));let r=await n.execute(e,{action:t});if(!r)throw Object.assign(/* @__PURE__ */ Error(`reCAPTCHA returned no token.`),{code:`captcha_unavailable`});return r}var Oi=e=>{if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(()=>e());return()=>cancelAnimationFrame(t)}let t=setTimeout(e,16);return()=>clearTimeout(t)},ki=se();function Ai(e){let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`The chat narrowing must be an object of feature switches.`);let n={};for(let e of M){let r=Reflect.get(t,e);if(r!==void 0){if(typeof r==`boolean`)n[e]=r;else throw TypeError(`The chat narrowing for "${e}" must be true or false.`)}}let r=new Set(M);for(let e of Object.keys(t))if(!r.has(e))throw TypeError(`"${e}" is not a chat feature.`);return n}function ji(e){let{client:t,screen:n,layout:r,narrow:i,conversationId:a,behaviour:o,attribution:s,prefs:c,pageContext:l,getCaptchaToken:u,onEvent:d,onError:f,onNavigate:p}=e,m=k(l);m.current=l;let h=k(u);h.current=u;let g=k(d);g.current=d;let _=k(f);_.current=f;let v=k(a);v.current=a;let y=k(o);y.current=o;let b=k(s);b.current=s;let x=k(c);x.current=c;let S=JSON.stringify(i??{}),w=k(null),E=k(!1),D=k(null),[M,N]=A(null);T(()=>{D.current=null;let e=I(t,{...n===void 0?{}:{screen:n},...r===void 0?{}:{layout:r},narrow:Ai(S),...v.current?{conversationId:v.current}:{},pageContext:()=>m.current,behaviour:()=>{let e=w.current;return e?.getState().features.BehaviourStarters?y.current?y.current():(D.current||=ge(e.getState().profile?.start.behaviour?.servicePathPrefixes??[]),D.current()):null},attribution:()=>b.current?.()??null,prefs:x.current??Wt,schedule:Oi,reducedMotion:()=>E.current,getCaptchaToken:async e=>{if(h.current)return h.current(e);let t=w.current?.getState().profile?.captcha;return t?.siteKey?Di(t.siteKey,e):null},onEvent:(e,t)=>g.current?.(e,t),onError:e=>_.current?.(e)});return w.current=e,N({client:t,screen:n,layout:r,narrowKey:S,session:e}),()=>{w.current=null,e.dispose()}},[t,n,r,S]);let P=M!==null&&M.client===t&&M.screen===n&&M.layout===r&&M.narrowKey===S?M.session:ee,F=j(P.subscribe,P.getState);E.current=ei(ki,F.profile?.experience??null);let L=O(()=>({load:()=>P.load(),submit:e=>P.submit(e),chooseQuickReply:e=>P.chooseQuickReply(e),answerInput:(e,t)=>P.answerInput(e,t),confirmAction:e=>P.confirmAction(e),rejectAction:(e,t)=>P.rejectAction(e,t),stop:()=>P.stop(),retry:()=>P.retry(),regenerate:()=>P.regenerate(),notifyTyping:()=>P.notifyTyping(),requestHandoff:e=>P.requestHandoff(e),startEdit:e=>P.startEdit(e),cancelEdit:()=>P.cancelEdit(),attach:e=>P.attach(e),removeAttachment:e=>P.removeAttachment(e),openConversation:e=>P.openConversation(e),resumeLast:()=>P.resumeLast(),newConversation:()=>P.newConversation(),rate:(e,t,n)=>P.rate(e,t,n),reset:()=>P.reset()}),[P]),te=C((e,t)=>g.current?.(e,t),[]);return{...F,...L,session:P,client:t,emit:te,onNavigate:p}}export{qe as ChatComposer,nt as ChatConversationActions,ri as ChatEmbed,ci as ChatExplain,at as ChatFooter,xi as ChatLauncher,hn as ChatLoader,kt as ChatOpenTickets,ti as ChatPage,Si as ChatPanel,Dt as ChatPastChats,Vt as ChatReadAloudButton,Jr as ChatThread,pn as assertChatLoaderStyle,Vr as defaultRenderers,xt as formatResetTime,ji as useChat,Be as useChatDictation,bt as useChatExplain,$r as useChatHandoff,It as useChatReadAloud,tt as useTranscriptActions};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/chat-react",
3
- "version": "0.150.0",
3
+ "version": "0.151.0",
4
4
  "description": "The Webority Chat React screens: launcher, docked, full-page and embedded shells, thread, composer, one renderer per message part kind and the useChat hook, built on @webority/chat-core and @webority/ui-react.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "type": "module",
@@ -26,10 +26,10 @@
26
26
  },
27
27
  "sideEffects": false,
28
28
  "peerDependencies": {
29
- "@webority/chat-core": "0.150.0",
30
- "@webority/chat-elements": "0.150.0",
31
- "@webority/markdown-core": "^0.171.0",
32
- "@webority/ui-react": "^0.171.0",
29
+ "@webority/chat-core": "0.151.0",
30
+ "@webority/chat-elements": "0.151.0",
31
+ "@webority/markdown-core": "^0.173.0",
32
+ "@webority/ui-react": "^0.173.0",
33
33
  "react": "^19.0.0",
34
34
  "react-dom": "^19.0.0",
35
35
  "react-router": "^8.5.1"
@@ -43,11 +43,11 @@
43
43
  "@vitejs/plugin-react": "^6.3.0",
44
44
  "@vitest/coverage-v8": "5.1.0",
45
45
  "@webority/analytics": "0.40.11",
46
- "@webority/chat-core": "0.150.0",
47
- "@webority/chat-elements": "0.150.0",
48
- "@webority/markdown-core": "0.171.2",
49
- "@webority/ui-elements": "0.171.2",
50
- "@webority/ui-react": "0.171.2",
46
+ "@webority/chat-core": "0.151.0",
47
+ "@webority/chat-elements": "0.151.0",
48
+ "@webority/markdown-core": "0.173.0",
49
+ "@webority/ui-elements": "0.173.0",
50
+ "@webority/ui-react": "0.173.0",
51
51
  "bootstrap": "5.3.9",
52
52
  "jsdom": "30.1.1",
53
53
  "react": "19.3.1",