@webority/chat-elements 0.136.0 → 0.137.1

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.
@@ -66,6 +66,7 @@ export declare class WuiChat extends Base {
66
66
  };
67
67
  };
68
68
  _captchaToken: any;
69
+ _attribution: any;
69
70
  _openAttachmentProp: any;
70
71
  _openCitationProp: any;
71
72
  _openTargetProp: any;
@@ -126,6 +127,7 @@ export declare class WuiChat extends Base {
126
127
  _onNavigateProp: any;
127
128
  _header: {
128
129
  el: any;
130
+ conversation: any;
129
131
  paint: (view: any) => void;
130
132
  } | undefined;
131
133
  _starters: {
@@ -190,6 +192,8 @@ export declare class WuiChat extends Base {
190
192
  set pageContext(value: any);
191
193
  get compact(): any;
192
194
  set compact(value: any);
195
+ get expressive(): any;
196
+ set expressive(value: any);
193
197
  get open(): any;
194
198
  set open(value: any);
195
199
  get renderers(): {
@@ -216,6 +220,8 @@ export declare class WuiChat extends Base {
216
220
  set layoutParts(value: any);
217
221
  get getCaptchaToken(): any;
218
222
  set getCaptchaToken(value: any);
223
+ get attribution(): any;
224
+ set attribution(value: any);
219
225
  get openAttachment(): any;
220
226
  set openAttachment(value: any);
221
227
  get openCitation(): any;
@@ -1,4 +1,5 @@
1
1
  export declare function createHeader(handlers: any): {
2
2
  el: any;
3
+ conversation: any;
3
4
  paint: (view: any) => void;
4
5
  };
@@ -2,22 +2,25 @@
2
2
  * Appends the Share and Print buttons of one reply to its actions container.
3
3
  * @param {HTMLElement} container the div.wui-chat-message-actions
4
4
  * @param {object} message a ChatLiveMessage whose author is Assistant, Agent or Script
5
- * @param {{ labels: object, features: object, title: string }} context
5
+ * @param {{ labels: object, features: object, title: string, assistantName: string | undefined, busy: boolean }} context
6
6
  */
7
7
  export declare function appendReplyActions(container: HTMLElement, message: object, context: {
8
8
  labels: object;
9
9
  features: object;
10
10
  title: string;
11
+ assistantName: string | undefined;
12
+ busy: boolean;
11
13
  }): void;
12
14
  /**
13
- * Paints the Share and Print buttons of the whole conversation into the li the thread made.
14
- * @param {HTMLElement} item the li.wui-chat-conversation-actions
15
+ * Paints the Share and Print buttons of the whole conversation into the header's container.
16
+ * @param {HTMLElement} item the span.wui-chat-header-conversation
15
17
  * @param {object} state the ChatSessionState
16
- * @param {{ labels: object, features: object, title: string, getState: () => object }} context
18
+ * @param {{ labels: object, features: object, title: string, getState: () => object, iconOnly?: boolean }} context iconOnly draws icon buttons
17
19
  */
18
20
  export declare function paintConversationActions(item: HTMLElement, state: object, context: {
19
21
  labels: object;
20
22
  features: object;
21
23
  title: string;
22
24
  getState: () => object;
25
+ iconOnly?: boolean;
23
26
  }): void;
@@ -0,0 +1 @@
1
+ import{ChatSpeechError as e,ChatSpeechError as t,createExplain as n,mergeLabels as r}from"@webority/chat-core";import{glyphSvg as i}from"@webority/ui-elements/helpers";var a=`(prefers-reduced-motion: reduce)`;function o(e,t){let n=e.style.animation;e.style.animation=`none`;let r=e.getBoundingClientRect();e.style.animation=n,e.style.transformOrigin=`${t.left+t.width/2-r.left}px ${t.top+t.height/2-r.top}px`}function s(e,t){let n=typeof window.matchMedia==`function`?window.matchMedia(a):null,r=/* @__PURE__ */ new Set,i=()=>e.motion===`Reduced`||t?.motion===!1||n?.matches===!0,o=i();function s(){let e=i();if(e!==o){o=e;for(let e of r)e(o)}}return n?.addEventListener(`change`,s),{get reduced(){return o},subscribe(e){return r.add(e),()=>{r.delete(e)}},destroy(){n?.removeEventListener(`change`,s),r.clear()}}}var c=`AppButton`,l={primary:`btn-primary`,secondary:`btn-soft-primary`,ghost:`btn-ghost-primary`,outline:`btn-outline-primary`,neutral:`btn-soft-neutral`,danger:`btn-danger`};function u(e,t,n){let r=document.createElement(e);if(t&&(r.className=t),n)for(let[e,t]of Object.entries(n))t!=null&&r.setAttribute(e,t);return r}function d(e,t=16){let n=i(e,{size:t});if(!n)return u(`span`,`d-inline-flex`);let r=document.createElement(`template`);return r.innerHTML=n,r.content.firstElementChild??u(`span`,`d-inline-flex`)}function f(e=`primary`,t=`md`){if(!Object.hasOwn(l,e))throw Error(`Unknown button variant "${e}". Use one of ${Object.keys(l).join(`, `)}.`);return`btn ${l[e]}${t===`sm`?` btn-sm`:``}`}function p(e,t,n,r){let i=u(`button`,`${f(e,`sm`)} wui-chat-action-btn`,{type:`button`});return i.dataset.wui=c,n&&i.append(d(n,14)),i.append(document.createTextNode(t)),i.addEventListener(`click`,r),i}function m(e,t,n){let r=u(`button`,`wui-chat-icon-btn`,{type:`button`,"aria-label":e,title:e});return r.append(d(t,20)),r.addEventListener(`click`,n),r}function h(e,t){let n=e.getAttribute(t);if(n!=null&&n!==``)try{return JSON.parse(n)}catch{throw Error(`<wui-chat ${t}> must be valid JSON.`)}}function g(e){let t=null;return n=>{let r=e.dataset.state;if((!n||r!==`open`&&r!==`opening`)&&(n||r!==`closed`&&r!==`closing`)){if(clearTimeout(t),n)e.dataset.state=`opening`,t=setTimeout(()=>{e.dataset.state=`open`},620);else{e.dataset.state=`closing`;let n=e.classList.contains(`wui-chat--panel-motion-none`)?0:300;t=setTimeout(()=>{e.dataset.state=`closed`},n)}}}}function _(e,t){t.position!==void 0&&(e.classList.toggle(`wui-chat--end`,t.position===`end`),e.classList.toggle(`wui-chat--start`,t.position===`start`)),t.reduced!==void 0&&e.classList.toggle(`wui-chat--reduced`,!!t.reduced),t.expressive!==void 0&&e.classList.toggle(`wui-chat--expressive`,t.expressive===!0),t.sendReveal!==void 0&&e.classList.toggle(`wui-chat--send-always`,t.sendReveal===`Always`),t.inputRing!==void 0&&e.classList.toggle(`wui-chat--input-ring-off`,t.inputRing===!1),t.panelMotion!==void 0&&(e.classList.toggle(`wui-chat--panel-motion-gentle`,t.panelMotion===`Gentle`),e.classList.toggle(`wui-chat--panel-motion-none`,t.panelMotion===`None`)),t.offsetX!==void 0&&e.style.setProperty(`--wui-chat-offset-x`,`${t.offsetX}px`),t.offsetY!==void 0&&e.style.setProperty(`--wui-chat-offset-y`,`${t.offsetY}px`),t.width!==void 0&&e.style.setProperty(`--wui-chat-width`,t.width),t.maxHeight!==void 0&&e.style.setProperty(`--wui-chat-panel-max-height`,`${t.maxHeight}px`),t.bottomGap!==void 0&&e.style.setProperty(`--wui-chat-bottom-gap`,`${t.bottomGap}px`),t.panelHeight!==void 0&&e.classList.toggle(`wui-chat--panel-height-content`,t.panelHeight===`Content`),t.avatar!==void 0&&(t.avatar?(e.style.setProperty(`--wui-chat-avatar`,`url(${JSON.stringify(t.avatar)})`),e.style.setProperty(`--wui-chat-typing-mark`,`url(${JSON.stringify(t.avatar)})`)):(e.style.removeProperty(`--wui-chat-avatar`),e.style.removeProperty(`--wui-chat-typing-mark`))),t.replyAvatars!==void 0&&e.classList.toggle(`wui-chat--reply-avatars-off`,t.replyAvatars===!1)}var v=[`Text`,`Sources`,`QuickReplies`,`InputRequest`,`Action`,`Notice`,`Table`,`Chart`,`Figures`,`RecordCard`,`Image`,`File`,`Ticket`,`Handoff`,`VoiceClip`],y={launcher:`wui-chat--launcher`,docked:`wui-chat--docked`,"full-page":`wui-chat--full-page`,embedded:`wui-chat--embedded`};function b(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function x({id:e,layout:t,position:n,role:r,launcher:i,onToggle:a}){let s=u(`div`,`wui-chat ${y[t]} wui-chat--${n}`),c=u(`section`,`wui-chat-panel`,{id:e,role:r}),l=i?g(s):null;s.dataset.state=i?`closed`:`open`;let f=null,p=null,m=null,h=null,v=null,x=null,S=null,C=`round`,w=!1,T=`bubble`,E=null,D=null,O=!1,k=`icon`,A=!1;function j(){let e=f.dataset.launcher,t=[`wui-chat-launcher-wrap`];e===`entering`&&E&&t.push(`wui-chat-launcher--entrance-${E}`),e===`idle`&&D&&D!==`none`&&(D!==`ring`||C===`pill`)&&t.push(`wui-chat-launcher--idle-${D}`),f.className=t.join(` `)}function M(){let e=[...p.classList].filter(e=>e.endsWith(`--opening`)||e.endsWith(`--closing`)),t=[`wui-chat-launcher`,`wui-chat-launcher--${C}`];C===`pill`&&w&&t.push(`wui-chat-launcher--compact`),k!==`icon`&&t.push(`wui-chat-launcher--mark-${k}`),t.push(`wui-chat-launcher--reveal-${T}`,...e),p.className=t.join(` `)}function N(){v&&x&&(v.textContent=S||x.launcher)}function P(){if(!p||!x)return;let e=A?x.launcherClose:S||x.launcher;p.setAttribute(`aria-label`,e),h.textContent=e}if(i){f=u(`div`,`wui-chat-launcher-wrap`),f.dataset.launcher=`idle`,p=u(`button`,`wui-chat-launcher`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-controls":e}),m=u(`span`,`wui-chat-launcher-icon`,{"aria-hidden":`true`}),m.append(d(`chat`,24));let t=u(`span`,`wui-chat-launcher-close`,{"aria-hidden":`true`});t.append(d(`x`,24)),h=u(`span`,`wui-chat-launcher-label`),p.append(m,t,h),p.addEventListener(`click`,()=>a()),p.addEventListener(`animationend`,e=>{e.target===p&&p.classList.remove(`wui-chat-launcher--opening`,`wui-chat-launcher--closing`)}),v=u(`span`,`wui-chat-launcher-bubble`,{"aria-hidden":`true`}),f.append(p,v),f.addEventListener(`animationend`,e=>{e.target===f&&f.dataset.launcher===`entering`&&(f.dataset.launcher=`idle`,j())}),M(),j(),s.append(f,c)}else s.append(c);function F(e){if(!l)return;let t=e&&!A&&p!==null,n=t?p.getBoundingClientRect():null;e!==A&&p&&(p.classList.remove(`wui-chat-launcher--opening`,`wui-chat-launcher--closing`),p.classList.add(e?`wui-chat-launcher--opening`:`wui-chat-launcher--closing`)),A=e,l(e),t&&o(c,n),p&&(p.setAttribute(`aria-expanded`,String(e)),P())}function I(e){x=e,p&&(P(),N())}function L(e){if(_(s,e),e.theme!==void 0&&(e.theme===`light`||e.theme===`dark`?s.dataset.theme=e.theme:delete s.dataset.theme),!p)return;e.launcherStyle!==void 0&&(C=e.launcherStyle===`Pill`?`pill`:`round`),e.compact!==void 0&&(w=e.compact),e.labelReveal!==void 0&&(T=e.labelReveal===`Expand`?`expand`:`bubble`),e.entrance!==void 0&&(E=e.entrance===`None`?null:b(e.entrance)),e.idle!==void 0&&(D=e.idle===`None`?`none`:b(e.idle)),e.phone!==void 0&&(O=e.phone),e.hoverLabel!==void 0&&(S=e.hoverLabel||null),e.launcherMark!==void 0&&(k=b(e.launcherMark)),e.icon!==void 0&&e.icon!==m.dataset.icon&&(m.dataset.icon=e.icon,m.replaceChildren(d(e.icon,24)));let t=e.launcherState??f.dataset.launcher;O&&t===`entering`&&(t=`idle`),t===`entering`&&!E&&(t=`idle`),f.dataset.launcher=t,M(),j(),N(),P()}return{root:s,panel:c,setOpen:F,setLabels:I,setAppearance:L,nudgeHost:f,launcherButton:p,role:r}}var S=1e4,C=2e3,w=3e5,T=/* @__PURE__ */ new Set([`NotAllowedError`,`SecurityError`,`PermissionDeniedError`]),E=/* @__PURE__ */ new Set([`NotFoundError`,`OverconstrainedError`,`NotReadableError`]);function D(e){return T.has(e?.name)?new t(`Blocked`,e.message):E.has(e?.name)?new t(`NoMicrophone`,e.message):O(e)}function O(e){return e instanceof t?e:new t(`Failed`,e?.message??String(e))}var k=null;function A(){return globalThis.SpeechSDK?globalThis.SpeechSDK:(k===null&&(k=import(`microsoft-cognitiveservices-speech-sdk`).then(e=>e.SpeechConfig?e:e.default).catch(e=>{throw k=null,e})),k)}function j(){return globalThis.document?.documentElement?.lang||globalThis.navigator?.language||`en-US`}function M(e){let n=e.getToken,r=e.loadSdk??A,i=e.getLanguage??j,a=typeof navigator<`u`&&typeof navigator.mediaDevices?.getUserMedia==`function`,o=typeof window<`u`&&window.isSecureContext===!0,s=a&&o,c=typeof window<`u`,l=null,u=null,d=null;function f(){return l!==null&&Date.parse(l.expiresDateTimeUtc)-Date.now()>6e4?Promise.resolve(l):(u===null&&(u=Promise.resolve().then(()=>n()).then(e=>(l=e,u=null,e),e=>{throw u=null,O(e)})),u)}function p(){return d===null&&(d=Promise.resolve().then(()=>r()).then(e=>{if(!e?.SpeechConfig)throw new t(`Unavailable`,`Speech is not available in this browser.`);return e}).catch(e=>{throw d=null,O(e)})),d}function m(e={}){let{signal:n,onText:r,onEnd:a}=e;if(n?.aborted)return a?.(),Promise.resolve();let o,c,l=new Promise((e,t)=>{o=e,c=t}),u=!1,d=!1,m=null,h=!1,g=``,_=[],v=null,y=null,b=null,x=()=>{clearTimeout(v),clearTimeout(y),clearTimeout(b)},T=e=>{if(!u){u=!0,x(),n?.removeEventListener(`abort`,E);try{m?.close()}finally{try{a?.()}finally{e?c(e):o()}}}};async function E(){if(!(u||d)){if(d=!0,x(),m!==null)try{await new Promise(e=>m.stopContinuousRecognitionAsync(e,e))}catch{}T(null)}}let k=()=>[..._,g].filter(e=>e!==``).join(` `).trim(),A=(e,t)=>{h||(h=!0,clearTimeout(v)),clearTimeout(y),y=setTimeout(E,C),r?.(k(),t)};async function j(){if(n?.addEventListener(`abort`,E),!s){T(new t(`Unavailable`,`Dictation is not available in this browser.`));return}let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){T(D(e));return}for(let e of r.getTracks())e.stop();if(!u)try{let n=await p(),r=await f();if(u)return;let a=n.SpeechConfig.fromAuthorizationToken(r.token,r.region);if(a.speechRecognitionLanguage=e.language||i(),a.setProperty(n.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,String(S)),m=new n.SpeechRecognizer(a,n.AudioConfig.fromDefaultMicrophoneInput()),m.recognizing=(e,t)=>{if(u)return;let n=t.result?.text;n&&(g=n,A(n,!1))},m.recognized=(e,r)=>{if(u)return;let{reason:i,text:a}=r.result;i===n.ResultReason.RecognizedSpeech&&a?(_.push(a),g=``,A(a,!0)):i===n.ResultReason.NoMatch&&n.NoMatchDetails.fromResult(r.result).reason===n.NoMatchReason.InitialSilenceTimeout&&T(new t(`NoSpeech`,`No speech was heard.`))},m.canceled=(e,r)=>{u||(r.reason===n.CancellationReason.Error?T(new t(`Failed`,r.errorDetails)):T(null))},m.sessionStopped=()=>T(null),await new Promise((e,t)=>m.startContinuousRecognitionAsync(e,t)),u)return;e.onStarted?.(),v=setTimeout(()=>{h||T(new t(`NoSpeech`,`No speech was heard.`))},S),b=setTimeout(E,w)}catch(e){T(O(e))}}return j(),l}async function h(e,n={}){let{signal:r}=n;if(!r?.aborted)try{let a=await p(),o=await f();if(r?.aborted)return;let s=a.SpeechConfig.fromAuthorizationToken(o.token,o.region);s.speechSynthesisLanguage=n.language||i();let c=new a.SpeakerAudioDestination,l=new a.SpeechSynthesizer(s,a.AudioConfig.fromSpeakerOutput(c));await new Promise((n,i)=>{let o=!1,s=()=>{r?.removeEventListener(`abort`,f),l.close(),c.close()},u=()=>{o||(o=!0,s(),n())},d=e=>{o||(o=!0,s(),i(O(e)))};function f(){c.pause(),u()}r?.addEventListener(`abort`,f),c.onAudioEnd=u;try{l.speakTextAsync(e,e=>{e.reason!==a.ResultReason.SynthesizingAudioCompleted&&d(new t(`Failed`,`The reply could not be synthesised.`))},e=>d(e))}catch(e){d(e)}})}catch(e){throw O(e)}}return{dictation:s,readAloud:c,streamsText:!0,startDictation:m,speak:h}}var N=6e4,P=60*N,F=48*P;function I(e){if(typeof e!=`string`||e===``)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function L(e,t=Date.now(),n=void 0){let r=I(e);if(r===null)return``;let i=t-r,a=Math.abs(i),o=i>=0,s=new Intl.RelativeTimeFormat(n,{numeric:`auto`});if(a<N)return s.format(0,`second`);if(a<P){let e=Math.floor(a/N);return s.format(o?-e:e,`minute`)}if(a<F){let e=Math.floor(a/P);return s.format(o?-e:e,`hour`)}return new Intl.DateTimeFormat(n,{day:`numeric`,month:`short`,year:`numeric`}).format(new Date(r))}function R(e,t=void 0){let n=I(e);return n===null?``:new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(n))}var z=`data-wui-printing`,B=`data-wui-print-hide`,V=`data-wui-print-path`,H=`data-wui-print-target`,U=/* @__PURE__ */ new Set([`script`,`style`,`link`,`template`]),W=null;function G(){if(W!==null){for(let e of W.marked)e.removeAttribute(B),e.removeAttribute(V),e.removeAttribute(H);W.heading.remove(),document.documentElement.removeAttribute(z),window.removeEventListener(`afterprint`,W.onAfterPrint),W=null}}function K(e,t,n,r,i){G();let a=e.querySelector(`.wui-chat-panel`);if(a===null)throw Error(`print needs the wui-chat root`);let o=[];for(let e=a;e!==document.documentElement;e=e.parentElement){e.setAttribute(V,``),o.push(e);for(let t of e.parentElement.children)t===e||U.has(t.localName)||(t.setAttribute(B,``),o.push(t))}for(let e of n)e.setAttribute(B,``),o.push(e);r!==null&&(r.setAttribute(H,``),o.push(r));let s=document.createElement(`div`);s.className=`wui-chat-print-heading`;let c=document.createElement(`h1`);c.textContent=i.title;let l=document.createElement(`p`);l.textContent=i.printedOn,s.append(c,l),a.prepend(s),document.documentElement.setAttribute(z,t);let u=()=>G();window.addEventListener(`afterprint`,u,{once:!0}),W={marked:o,heading:s,onAfterPrint:u};try{window.print()}catch(e){throw G(),e}}function q(e,t){K(e,`conversation`,[],null,t)}function ee(e,t,n){if(!e.contains(t))throw Error(`printReply needs a message inside the wui-chat root`);K(e,`reply`,Array.from(e.querySelectorAll(`li.wui-chat-message`)).filter(e=>e!==t),t,n)}function J(){return typeof navigator<`u`&&typeof navigator.share==`function`}async function te({title:e,text:t}){if(!J())return`failed`;try{return await navigator.share({title:e,text:t}),`shared`}catch(e){return e?.name===`AbortError`?`cancelled`:`failed`}}var ne=`wchat:auto-opened`,re=`wchat:dismissed`,ie=`button, a[href], input, select, textarea`,ae=`input, textarea`;function Y(e){return!e.closest(`.wui-chat`)}function oe(e){return e instanceof Element&&e.matches(ae)&&Y(e)}function se(){return[...document.querySelectorAll(ae)].some(e=>Y(e)&&e.value!==e.defaultValue)}function ce(e){return e.length!==0&&[...document.querySelectorAll(e.join(`,`))].some(e=>{let t=e.getBoundingClientRect();return t.width>0&&t.height>0})}function le(e){return e?[...document.querySelectorAll(ie)].some(t=>{if(!Y(t))return!1;let n=t.getBoundingClientRect();return n.width===0||n.height===0?!1:n.left<e.right&&n.right>e.left&&n.top<e.bottom&&n.bottom>e.top}):!1}function ue(e,t,n){if(e.oncePerSession&&sessionStorage.getItem(ne)||e.rememberDismissal&&sessionStorage.getItem(re)||window.innerWidth<e.skipBelowWidthPx)return!0;let r=window.location.pathname;if(e.skipPathPrefixes.some(e=>r.startsWith(e)))return!0;let i=t.avoid.autoOpenOptOutSelector;return i&&document.querySelector(i)||e.skipWhenFormTouched&&se()||n.isOpen()?!0:e.skipWhenCoversControl&&le(n.panelRect())}function de(e){return oe(document.activeElement)||ce(e.avoid.menuSelectors)||ce(e.avoid.autoOpenBusySelectors)}function fe(e,t,n){let r=0;function i(){r=0,ue(e,t,n)||(de(t)?r=setTimeout(i,e.busyRetrySeconds*1e3):(sessionStorage.setItem(ne,`1`),n.open()))}return r=setTimeout(i,e.delaySeconds*1e3),{cancel(){clearTimeout(r),r=0}}}var pe=.4,me=20;function X(e){let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function he(e){let t=e.match(/[\d.]+/g);if(!t||t.length<3)return null;let[n,r,i]=t.slice(0,3).map(Number);return{r:n,g:r,b:i,alpha:t.length>3?Number(t[3])/(e.includes(`%`)?100:1):1}}function ge({r:e,g:t,b:n}){return .2126*X(e)+.7152*X(t)+.0722*X(n)}function _e(e,t){let n=e.getBoundingClientRect(),r=document.elementsFromPoint?.(n.left+n.width/2,n.top+n.height/2)??[],i=t.length?t.join(`,`):null;for(let t of r){if(e.contains(t))continue;if(i&&t.closest(i))return!0;let n=he(getComputedStyle(t).backgroundColor);if(n&&n.alpha>0)return ge(n)<pe}return!1}function ve(e){return e.length===0?[]:[...document.querySelectorAll(e.join(`,`))]}function ye(e){let t=0;for(let n of e){let e=n.getBoundingClientRect();e.height!==0&&(t=Math.max(t,window.innerHeight-e.top))}return t>0?t+me:0}function be(e){if(e.length===0)return!1;for(let t of document.querySelectorAll(e.join(`,`))){let e=t.getBoundingClientRect();if(e.width>0&&e.height>0)return!0}return!1}function xe(e,t,n){let r=n.ownerDocument.documentElement,i=0,a=!1,o=null;function s(){i=0;let s=t.liftAboveFooter?ve(e.liftSelectors):[];if(o)for(let e of s)o.observe(e);n.style.setProperty(`--wui-chat-lift`,`${ye(s)}px`);let c=n.getBoundingClientRect(),l=c.height===0?0:Math.round(window.innerHeight-c.top);r.style.setProperty(`--wui-chat-launcher-block`,`${l}px`);let u=t.stepAsideForMenus&&be(e.menuSelectors);u&&!a?(n.dataset.launcher=`hidden`,n.inert=!0,a=!0):!u&&a&&(n.dataset.launcher=`idle`,n.inert=!1,a=!1);let d=t.switchOnDark&&_e(n,e.darkSelectors);d&&n.dataset.onDark===void 0&&(n.dataset.onDark=``),!d&&n.dataset.onDark!==void 0&&delete n.dataset.onDark}function c(){i||=requestAnimationFrame(s)}typeof ResizeObserver==`function`&&(o=new ResizeObserver(c));let l=new MutationObserver(c);return l.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`open`,`data-menu-open`]}),document.addEventListener(`scroll`,c,{capture:!0,passive:!0}),window.addEventListener(`resize`,c),window.addEventListener(`load`,c),n.addEventListener(`animationend`,c),c(),{destroy(){i&&cancelAnimationFrame(i),i=0,o?.disconnect(),l.disconnect(),document.removeEventListener(`scroll`,c,{capture:!0}),window.removeEventListener(`resize`,c),window.removeEventListener(`load`,c),n.removeEventListener(`animationend`,c),a&&=(n.inert=!1,!1),delete n.dataset.onDark,n.style.removeProperty(`--wui-chat-lift`),r.style.removeProperty(`--wui-chat-launcher-block`)}}}var Z=`wchat:session-start`,Se=`wchat:pages`,Ce=`wchat:services`;function we(e){let t=sessionStorage.getItem(e);return t?JSON.parse(t):[]}function Te(e,t){sessionStorage.setItem(e,JSON.stringify(t))}function Ee(e,t){let n=t.find(t=>e.startsWith(t));return n===void 0?null:e.slice(n.length).replace(/^\/+|\/+$/g,``)||null}function De(e){sessionStorage.getItem(Z)||sessionStorage.setItem(Z,String(Date.now()));let t=0;function n(){let e=document.documentElement.scrollHeight;if(e<=0)return;let n=(window.scrollY+window.innerHeight)/e*100;n>t&&(t=n)}return window.addEventListener(`scroll`,n,{passive:!0}),function(){n();let r=window.location.pathname,i=we(Se);i.includes(r)||(i.push(r),Te(Se,i));let a=Ee(r,e),o=we(Ce);return a!==null&&(o=o.filter(e=>e!==a),o.push(a),o=o.slice(-10),Te(Ce,o)),{timeOnSiteSeconds:Math.floor((Date.now()-Number(sessionStorage.getItem(Z)))/1e3),scrollPercent:Math.min(100,Math.floor(t)),pagesViewed:i.length,viewedServices:o}}}var Q=8,Oe=`(min-width: 992px)`,ke=`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`,Ae=[`aria-haspopup`,`aria-expanded`,`aria-controls`,`aria-disabled`,`data-offline`,`title`],je=0;function Me(e,t,n){n==null?e.removeAttribute(t):e.setAttribute(t,n)}function Ne(e){let{trigger:t,request:i,isEmpty:a,renderAnswer:o,renderFooter:s,session:c,timings:l,onStateChange:d,returnFocusTo:f}=e??{};if(!(t instanceof HTMLElement))throw TypeError(`createExplainPopover needs a "trigger" element.`);if(typeof i!=`function`)throw TypeError(`createExplainPopover needs a "request" function.`);if(typeof o!=`function`)throw TypeError(`createExplainPopover needs a "renderAnswer" function.`);je+=1;let h=e.title??``,g=e.showNotCounted??!0,_=`wui-chat-explain-${je}`,v=()=>r(e.labels??{}),y=()=>({labels:v(),close:W}),b=n({request:i,isEmpty:a,...l}),x=Object.fromEntries(Ae.map(e=>[e,t.getAttribute(e)])),S=t.hidden,C;t.setAttribute(`aria-haspopup`,`dialog`),t.setAttribute(`aria-expanded`,`false`),t.setAttribute(`aria-controls`,_);let w=null,T=null,E=null,D,O=null,k=[],A=[],j=()=>c?.getState().features.Explain===!1;function M(){b.getSnapshot().offline?(C===void 0&&(C=t.getAttribute(`title`)),t.setAttribute(`title`,v().explainOffline),t.setAttribute(`aria-disabled`,`true`),t.setAttribute(`data-offline`,``)):(C!==void 0&&Me(t,`title`,C),C=void 0,t.removeAttribute(`aria-disabled`),t.removeAttribute(`data-offline`)),c&&(t.hidden=j())}function N(e){if(T.replaceChildren(),e.pillVisible){let t=u(`span`,`wui-chat-explain-pill`),n=u(`span`,`wui-chat-orb`,{"aria-hidden":`true`}),r=u(`span`);r.textContent=e.state===`slow`?v().explainSlow:v().thinking,t.append(n,r);let i=u(`div`,`wui-chat-explain-thinking`,{role:`status`});i.append(t),T.append(i)}else if(e.state===`answered`){e.answer!==D&&(E=o(e.answer,y())??null,D=e.answer);let t=u(`div`,`wui-chat-explain-answer`);E&&t.append(E),T.append(t)}else if(e.state===`empty`){let e=u(`p`,`wui-chat-explain-text`);e.textContent=v().explainEmpty,T.append(e)}else if(e.state===`capacity`){let t=u(`div`,`wui-chat-explain-alert wui-chat-explain-alert--warning`,{role:`status`}),n=u(`p`);n.textContent=e.resetsDateTimeUtc?v().explainCapacity(R(e.resetsDateTimeUtc)):v().explainCapacityNoDate,t.append(n),T.append(t)}else if(e.state===`error`){let e=u(`div`,`wui-chat-explain-alert wui-chat-explain-alert--error`,{role:`alert`}),t=u(`p`);t.textContent=v().explainError,e.append(t,p(`ghost`,v().retry,`rotate-ccw`,()=>b.ask())),T.append(e)}}function P(){let e=w.querySelector(`.wui-chat-explain-foot`);e.replaceChildren();let t=s?.(y());if(t&&e.append(t),g){let t=u(`p`,`wui-chat-explain-note`);t.textContent=v().explainNotCounted,e.append(t)}}function F(){if(!w)return;let e=b.getSnapshot();w.dataset.state=e.state,N(e),P(),d?.(e)}function I(){if(!w)return;if(!t.isConnected){W({restoreFocus:!1});return}let e=document.documentElement.getAttribute(`data-wui-chat-docked`);if((e===`end`||e===`start`)&&globalThis.matchMedia?.(Oe)?.matches===!0){w.dataset.beside=e,w.style.left=``,w.style.top=``,w.style.maxHeight=``;return}delete w.dataset.beside,w.style.position=`fixed`;let n=t.getBoundingClientRect(),r=w.offsetWidth,i=w.offsetHeight,a=globalThis.innerHeight-n.bottom-Q,o=a<i&&n.top>a,s=o?n.top-Q:a,c=o?Math.max(Q,n.top-i-Q):n.bottom+Q,l=Math.max(Q,Math.min(n.left,globalThis.innerWidth-r-Q));w.style.top=`${c}px`,w.style.left=`${l}px`,w.style.maxHeight=s<i?`${Math.max(0,s)}px`:``}function L(e){e.key===`Escape`&&(document.documentElement.hasAttribute(`data-wui-chat-docked`)||(e.stopPropagation(),W()))}function z(e){let n=e.target;w.contains(n)||t.contains(n)||n instanceof Element&&n.closest(`.wui-chat-panel`)||W({restoreFocus:!1})}function B(e){e.target instanceof Node&&w.contains(e.target)||I()}function V(){b.getSnapshot().offline||G()}function H(){for(let[e,t,n,r]of k)e.removeEventListener(t,n,r);k=[];for(let e of A)e.disconnect();A=[]}function U(){if(w||j()||b.getSnapshot().offline)return;w=u(`div`,`wui-chat-explain`,{role:`dialog`,"aria-label":h,popover:`manual`,id:_});let e=u(`header`,`wui-chat-explain-head`),n=u(`strong`,`wui-chat-explain-title`);n.textContent=h,O=m(v().close,`x`,()=>W()),O.classList.add(`wui-chat-explain-close`),e.append(n,O),T=u(`div`,`wui-chat-explain-body`,{"aria-live":`polite`}),w.append(e,T,u(`div`,`wui-chat-explain-foot`)),w.dataset.state=b.getSnapshot().state,document.body.append(w);try{w.showPopover?.()}catch{}t.setAttribute(`aria-expanded`,`true`),b.ask(),I(),(w.querySelector(ke)??O).focus({preventScroll:!0}),k=[[document,`keydown`,L,!0],[document,`pointerdown`,z,!0],[window,`resize`,I,!1],[document,`scroll`,B,!0]];for(let[e,t,n,r]of k)e.addEventListener(t,n,r);if(typeof ResizeObserver==`function`){let e=new ResizeObserver(()=>I());e.observe(w),A.push(e)}let r=new MutationObserver(()=>I());r.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-wui-chat-docked`]}),A.push(r)}function W(e={restoreFocus:!0}){w&&(b.reset(),H(),w.remove(),w=null,T=null,E=null,D=void 0,O=null,t.setAttribute(`aria-expanded`,`false`),M(),e?.restoreFocus!==!1&&(f?.()??t).focus({preventScroll:!0}))}function G(){w?W():U()}let K=b.subscribe(()=>{M(),b.getSnapshot().offline&&w?W():F()}),q=c?.subscribe(()=>{M(),j()&&w&&W({restoreFocus:!1})});return t.addEventListener(`click`,V),M(),{open:U,close:W,toggle:G,isOpen:()=>w!==null,destroy(){W({restoreFocus:!1}),K(),q?.(),b.dispose(),t.removeEventListener(`click`,V);for(let e of Ae)Me(t,e,x[e]);t.hidden=S}}}var Pe=`a[href],button:not([disabled]),input:not([disabled]):not([type='hidden']),select:not([disabled]),textarea:not([disabled]),[tabindex]`;function Fe(e,t){if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(Pe)].filter(e=>e.tabIndex>=0&&!e.hidden);if(n.length===0){t.preventDefault();return}let r=n[0],i=n[n.length-1],a=e.ownerDocument.activeElement,o=e.contains(a);t.shiftKey?o&&a!==r||(t.preventDefault(),i.focus()):o&&a!==i||(t.preventDefault(),r.focus())}function Ie(e){e?.isConnected&&e.focus()}function Le(e,t){t||typeof navigator>`u`||typeof navigator.vibrate!=`function`||navigator.vibrate(e)}var Re=`wui-chat-lock`,ze=`wui-chat-scroll-lock`;function Be(e){let t=e.ownerDocument,n=[t.documentElement,t.body],r=e.style.overscrollBehavior;for(let e of n)e.classList.add(Re);e.setAttribute(`data-lenis-prevent`,``),e.style.overscrollBehavior=`contain`,window.dispatchEvent(new CustomEvent(ze,{detail:{locked:!0}}));let i=!0;return function(){if(i){i=!1;for(let e of n)e.classList.remove(Re);e.removeAttribute(`data-lenis-prevent`),e.style.overscrollBehavior=r,window.dispatchEvent(new CustomEvent(ze,{detail:{locked:!1}}))}}}var Ve={open:{from:420,to:920,seconds:.16,peak:.16},reply:{from:680,to:540,seconds:.11,peak:.06},sent:{from:540,to:760,seconds:.09,peak:.05}},He=[`pointerdown`,`keydown`,`touchstart`],Ue=`wchat:muted`,We=1e-4;function Ge(e,t){let n=t.get(Ue)===`1`,r=null;function i(){for(let e of He)document.removeEventListener(e,a)}function a(){let e=globalThis.AudioContext||globalThis.webkitAudioContext;!r&&e&&(r=new e),r?.state===`suspended`&&r.resume(),i()}for(let e of He)document.addEventListener(e,a);return{play(t){let i=Ve[t];if(!i||n||!r||!e[t]||!(e.volume>0))return;let a=r.currentTime,o=r.createOscillator(),s=r.createGain();o.type=`sine`,o.frequency.setValueAtTime(i.from,a),o.frequency.linearRampToValueAtTime(i.to,a+i.seconds),s.gain.setValueAtTime(i.peak*e.volume,a),s.gain.exponentialRampToValueAtTime(We,a+i.seconds),o.connect(s),s.connect(r.destination),o.start(a),o.stop(a+i.seconds)},setMuted(e){n=!!e,t.set(Ue,n?`1`:`0`)},isMuted(){return n},destroy(){i(),r?.close(),r=null}}}function Ke(e,t={}){return M({getToken:()=>e.getSpeechToken(),getLanguage:t.language?()=>t.language:void 0})}var qe=2e3,Je=500,Ye=32,$=16,Xe=`data-wui-chat-switching`;function Ze(e){return new Promise(t=>setTimeout(t,e))}function Qe(e,t){return typeof e!=`function`||e()?Promise.resolve():new Promise(n=>{let r=0,i=()=>{e()||r>=t?n():(r+=$,setTimeout(i,$))};setTimeout(i,$)})}async function $e(e,t={}){let n=t.reduced??globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;if(typeof document.startViewTransition!=`function`||n){await e();return}let r=document.documentElement;r.setAttribute(Xe,``);try{let n=()=>!t.target||document.querySelector(`.wui-chat--${t.target}`)!==null,r=()=>(typeof t.pageReady!=`function`||t.pageReady())&&n(),i=document.startViewTransition(async()=>{await e(),await Qe(t.routeReady,qe),await Qe(r,Je),await Ze(Ye)});i.ready.catch(()=>{});try{await i.updateCallbackDone}finally{await i.finished.catch(()=>{})}}finally{r.removeAttribute(Xe)}}var et=100,tt=12,nt=220,rt=640;function it(e,t){let n=t.phone.mode===`Sheet`,r=window.visualViewport,i=0;function a(){e.style.removeProperty(`bottom`),e.style.removeProperty(`max-height`)}function o(){if(i=0,window.innerWidth>t.phone.maxWidthPx){a();return}if(!r)return;let o=Math.max(0,window.innerHeight-r.height-r.offsetTop),s=r.height-tt;n&&(s=Math.min(rt,Math.max(nt,s))),e.style.bottom=`${o}px`,e.style.maxHeight=`${s}px`}function s(){clearTimeout(i),i=setTimeout(o,et)}return r?.addEventListener(`resize`,s),r?.addEventListener(`scroll`,s),window.addEventListener(`resize`,s),window.addEventListener(`orientationchange`,s),o(),{destroy(){clearTimeout(i),r?.removeEventListener(`resize`,s),r?.removeEventListener(`scroll`,s),window.removeEventListener(`resize`,s),window.removeEventListener(`orientationchange`,s),a()}}}export{h as A,D as C,u as D,x as E,o as M,s as N,m as O,M as S,f as T,q as _,Ge as a,L as b,Ie as c,De as d,xe as f,G as g,te as h,Ke as i,p as j,d as k,Fe as l,J as m,it as n,Be as o,fe as p,$e as r,Le as s,e as t,Ne as u,ee as v,v as w,t as x,R as y};
package/dist/web.js CHANGED
@@ -1 +1 @@
1
- export{t as ChatSpeechError,m as canShareText,f as createAvoidance,S as createAzureSpeech,d as createBehaviourCollector,u as createExplainPopover,a as createSound,i as createWebSpeech,g as endPrint,n as fitToViewport,y as fullMoment,M as growFromButton,o as lockPageScroll,C as microphoneError,_ as printConversation,v as printReply,b as relativeMoment,c as returnFocus,h as shareText,r as switchPanel,l as trapTab,s as vibrate,p as watchAutoOpen,N as watchReducedMotion}from"./web-B31MaWW8.js";
1
+ export{t as ChatSpeechError,m as canShareText,f as createAvoidance,S as createAzureSpeech,d as createBehaviourCollector,u as createExplainPopover,a as createSound,i as createWebSpeech,g as endPrint,n as fitToViewport,y as fullMoment,M as growFromButton,o as lockPageScroll,C as microphoneError,_ as printConversation,v as printReply,b as relativeMoment,c as returnFocus,h as shareText,r as switchPanel,l as trapTab,s as vibrate,p as watchAutoOpen,N as watchReducedMotion}from"./web-DthZEUJn.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/chat-elements",
3
- "version": "0.136.0",
3
+ "version": "0.137.1",
4
4
  "description": "The Webority Chat web elements: the <wui-chat> custom element and one custom element per message part kind, the chat styles on @webority/theme tokens, and the global bundle that Razor pages load.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "type": "module",
@@ -37,10 +37,10 @@
37
37
  "./src/renderers/*.js"
38
38
  ],
39
39
  "peerDependencies": {
40
- "@webority/chat-core": "0.136.0",
41
- "@webority/markdown-core": "^0.133.0",
42
- "@webority/theme": "^0.133.0",
43
- "@webority/ui-elements": "^0.133.0",
40
+ "@webority/chat-core": "0.137.1",
41
+ "@webority/markdown-core": "^0.134.0",
42
+ "@webority/theme": "^0.134.0",
43
+ "@webority/ui-elements": "^0.134.0",
44
44
  "microsoft-cognitiveservices-speech-sdk": "^1.53.0"
45
45
  },
46
46
  "peerDependenciesMeta": {
@@ -49,9 +49,9 @@
49
49
  }
50
50
  },
51
51
  "devDependencies": {
52
- "@webority/chat-core": "0.136.0",
53
- "@webority/theme": "0.133.0",
54
- "@webority/ui-elements": "0.133.0",
52
+ "@webority/chat-core": "0.137.1",
53
+ "@webority/theme": "0.134.0",
54
+ "@webority/ui-elements": "0.134.0",
55
55
  "@vitest/coverage-v8": "5.0.1",
56
56
  "bootstrap": "5.3.3",
57
57
  "jsdom": "30.1.1",
@@ -1 +0,0 @@
1
- import{ChatSpeechError as e,ChatSpeechError as t,createExplain as n,mergeLabels as r}from"@webority/chat-core";import{glyphSvg as i}from"@webority/ui-elements/helpers";var a=`(prefers-reduced-motion: reduce)`;function o(e,t){let n=e.style.animation;e.style.animation=`none`;let r=e.getBoundingClientRect();e.style.animation=n,e.style.transformOrigin=`${t.left+t.width/2-r.left}px ${t.top+t.height/2-r.top}px`}function s(e,t){let n=typeof window.matchMedia==`function`?window.matchMedia(a):null,r=/* @__PURE__ */ new Set,i=()=>e.motion===`Reduced`||t?.motion===!1||n?.matches===!0,o=i();function s(){let e=i();if(e!==o){o=e;for(let e of r)e(o)}}return n?.addEventListener(`change`,s),{get reduced(){return o},subscribe(e){return r.add(e),()=>{r.delete(e)}},destroy(){n?.removeEventListener(`change`,s),r.clear()}}}var c=`AppButton`,l={primary:`btn-primary`,secondary:`btn-soft-primary`,ghost:`btn-ghost-primary`,outline:`btn-outline-primary`,neutral:`btn-soft-neutral`,danger:`btn-danger`};function u(e,t,n){let r=document.createElement(e);if(t&&(r.className=t),n)for(let[e,t]of Object.entries(n))t!=null&&r.setAttribute(e,t);return r}function d(e,t=16){let n=i(e,{size:t});if(!n)return u(`span`,`d-inline-flex`);let r=document.createElement(`template`);return r.innerHTML=n,r.content.firstElementChild??u(`span`,`d-inline-flex`)}function f(e=`primary`,t=`md`){if(!Object.hasOwn(l,e))throw Error(`Unknown button variant "${e}". Use one of ${Object.keys(l).join(`, `)}.`);return`btn ${l[e]}${t===`sm`?` btn-sm`:``}`}function p(e,t,n,r){let i=u(`button`,`${f(e,`sm`)} wui-chat-action-btn`,{type:`button`});return i.dataset.wui=c,n&&i.append(d(n,14)),i.append(document.createTextNode(t)),i.addEventListener(`click`,r),i}function m(e,t,n){let r=u(`button`,`wui-chat-icon-btn`,{type:`button`,"aria-label":e,title:e});return r.append(d(t,20)),r.addEventListener(`click`,n),r}function h(e,t){let n=e.getAttribute(t);if(n!=null&&n!==``)try{return JSON.parse(n)}catch{throw Error(`<wui-chat ${t}> must be valid JSON.`)}}function g(e){let t=null;return n=>{let r=e.dataset.state;if((!n||r!==`open`&&r!==`opening`)&&(n||r!==`closed`&&r!==`closing`)){if(clearTimeout(t),n)e.dataset.state=`opening`,t=setTimeout(()=>{e.dataset.state=`open`},620);else{e.dataset.state=`closing`;let n=e.classList.contains(`wui-chat--panel-motion-none`)?0:300;t=setTimeout(()=>{e.dataset.state=`closed`},n)}}}}function _(e,t){t.position!==void 0&&(e.classList.toggle(`wui-chat--end`,t.position===`end`),e.classList.toggle(`wui-chat--start`,t.position===`start`)),t.reduced!==void 0&&e.classList.toggle(`wui-chat--reduced`,!!t.reduced),t.sendReveal!==void 0&&e.classList.toggle(`wui-chat--send-always`,t.sendReveal===`Always`),t.inputRing!==void 0&&e.classList.toggle(`wui-chat--input-ring-off`,t.inputRing===!1),t.panelMotion!==void 0&&(e.classList.toggle(`wui-chat--panel-motion-gentle`,t.panelMotion===`Gentle`),e.classList.toggle(`wui-chat--panel-motion-none`,t.panelMotion===`None`)),t.offsetX!==void 0&&e.style.setProperty(`--wui-chat-offset-x`,`${t.offsetX}px`),t.offsetY!==void 0&&e.style.setProperty(`--wui-chat-offset-y`,`${t.offsetY}px`),t.width!==void 0&&e.style.setProperty(`--wui-chat-width`,t.width),t.maxHeight!==void 0&&e.style.setProperty(`--wui-chat-panel-max-height`,`${t.maxHeight}px`),t.bottomGap!==void 0&&e.style.setProperty(`--wui-chat-bottom-gap`,`${t.bottomGap}px`),t.panelHeight!==void 0&&e.classList.toggle(`wui-chat--panel-height-content`,t.panelHeight===`Content`),t.avatar!==void 0&&(t.avatar?e.style.setProperty(`--wui-chat-avatar`,`url(${JSON.stringify(t.avatar)})`):e.style.removeProperty(`--wui-chat-avatar`)),t.replyAvatars!==void 0&&e.classList.toggle(`wui-chat--reply-avatars-off`,t.replyAvatars===!1)}var v=[`Text`,`Sources`,`QuickReplies`,`InputRequest`,`Action`,`Notice`,`Table`,`Chart`,`Figures`,`RecordCard`,`Image`,`File`,`Ticket`,`Handoff`,`VoiceClip`],y={launcher:`wui-chat--launcher`,docked:`wui-chat--docked`,"full-page":`wui-chat--full-page`,embedded:`wui-chat--embedded`};function b(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function x({id:e,layout:t,position:n,role:r,launcher:i,onToggle:a}){let s=u(`div`,`wui-chat ${y[t]} wui-chat--${n}`),c=u(`section`,`wui-chat-panel`,{id:e,role:r}),l=i?g(s):null;s.dataset.state=i?`closed`:`open`;let f=null,p=null,m=null,h=null,v=null,x=null,S=null,C=`round`,w=!1,T=`bubble`,E=null,D=null,O=!1,k=`icon`,A=!1;function j(){let e=f.dataset.launcher,t=[`wui-chat-launcher-wrap`];e===`entering`&&E&&t.push(`wui-chat-launcher--entrance-${E}`),e===`idle`&&D&&D!==`none`&&(D!==`ring`||C===`pill`)&&t.push(`wui-chat-launcher--idle-${D}`),f.className=t.join(` `)}function M(){let e=[...p.classList].filter(e=>e.endsWith(`--opening`)||e.endsWith(`--closing`)),t=[`wui-chat-launcher`,`wui-chat-launcher--${C}`];C===`pill`&&w&&t.push(`wui-chat-launcher--compact`),k!==`icon`&&t.push(`wui-chat-launcher--mark-${k}`),t.push(`wui-chat-launcher--reveal-${T}`,...e),p.className=t.join(` `)}function N(){v&&x&&(v.textContent=S||x.launcher)}function P(){if(!p||!x)return;let e=A?x.launcherClose:S||x.launcher;p.setAttribute(`aria-label`,e),h.textContent=e}if(i){f=u(`div`,`wui-chat-launcher-wrap`),f.dataset.launcher=`idle`,p=u(`button`,`wui-chat-launcher`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-controls":e}),m=u(`span`,`wui-chat-launcher-icon`,{"aria-hidden":`true`}),m.append(d(`chat`,24));let t=u(`span`,`wui-chat-launcher-close`,{"aria-hidden":`true`});t.append(d(`x`,24)),h=u(`span`,`wui-chat-launcher-label`),p.append(m,t,h),p.addEventListener(`click`,()=>a()),p.addEventListener(`animationend`,e=>{e.target===p&&p.classList.remove(`wui-chat-launcher--opening`,`wui-chat-launcher--closing`)}),v=u(`span`,`wui-chat-launcher-bubble`,{"aria-hidden":`true`}),f.append(p,v),f.addEventListener(`animationend`,e=>{e.target===f&&f.dataset.launcher===`entering`&&(f.dataset.launcher=`idle`,j())}),M(),j(),s.append(f,c)}else s.append(c);function F(e){if(!l)return;let t=e&&!A&&p!==null,n=t?p.getBoundingClientRect():null;e!==A&&p&&(p.classList.remove(`wui-chat-launcher--opening`,`wui-chat-launcher--closing`),p.classList.add(e?`wui-chat-launcher--opening`:`wui-chat-launcher--closing`)),A=e,l(e),t&&o(c,n),p&&(p.setAttribute(`aria-expanded`,String(e)),P())}function I(e){x=e,p&&(P(),N())}function L(e){if(_(s,e),e.theme!==void 0&&(e.theme===`light`||e.theme===`dark`?s.dataset.theme=e.theme:delete s.dataset.theme),!p)return;e.launcherStyle!==void 0&&(C=e.launcherStyle===`Pill`?`pill`:`round`),e.compact!==void 0&&(w=e.compact),e.labelReveal!==void 0&&(T=e.labelReveal===`Expand`?`expand`:`bubble`),e.entrance!==void 0&&(E=e.entrance===`None`?null:b(e.entrance)),e.idle!==void 0&&(D=e.idle===`None`?`none`:b(e.idle)),e.phone!==void 0&&(O=e.phone),e.hoverLabel!==void 0&&(S=e.hoverLabel||null),e.launcherMark!==void 0&&(k=b(e.launcherMark)),e.icon!==void 0&&e.icon!==m.dataset.icon&&(m.dataset.icon=e.icon,m.replaceChildren(d(e.icon,24)));let t=e.launcherState??f.dataset.launcher;O&&t===`entering`&&(t=`idle`),t===`entering`&&!E&&(t=`idle`),f.dataset.launcher=t,M(),j(),N(),P()}return{root:s,panel:c,setOpen:F,setLabels:I,setAppearance:L,nudgeHost:f,launcherButton:p,role:r}}var S=1e4,C=2e3,w=3e5,T=/* @__PURE__ */ new Set([`NotAllowedError`,`SecurityError`,`PermissionDeniedError`]),E=/* @__PURE__ */ new Set([`NotFoundError`,`OverconstrainedError`,`NotReadableError`]);function D(e){return T.has(e?.name)?new t(`Blocked`,e.message):E.has(e?.name)?new t(`NoMicrophone`,e.message):O(e)}function O(e){return e instanceof t?e:new t(`Failed`,e?.message??String(e))}var k=null;function A(){return globalThis.SpeechSDK?globalThis.SpeechSDK:(k===null&&(k=import(`microsoft-cognitiveservices-speech-sdk`).then(e=>e.SpeechConfig?e:e.default).catch(e=>{throw k=null,e})),k)}function j(){return globalThis.document?.documentElement?.lang||globalThis.navigator?.language||`en-US`}function M(e){let n=e.getToken,r=e.loadSdk??A,i=e.getLanguage??j,a=typeof navigator<`u`&&typeof navigator.mediaDevices?.getUserMedia==`function`,o=typeof window<`u`&&window.isSecureContext===!0,s=a&&o,c=typeof window<`u`,l=null,u=null,d=null;function f(){return l!==null&&Date.parse(l.expiresDateTimeUtc)-Date.now()>6e4?Promise.resolve(l):(u===null&&(u=Promise.resolve().then(()=>n()).then(e=>(l=e,u=null,e),e=>{throw u=null,O(e)})),u)}function p(){return d===null&&(d=Promise.resolve().then(()=>r()).then(e=>{if(!e?.SpeechConfig)throw new t(`Unavailable`,`Speech is not available in this browser.`);return e}).catch(e=>{throw d=null,O(e)})),d}function m(e={}){let{signal:n,onText:r,onEnd:a}=e;if(n?.aborted)return a?.(),Promise.resolve();let o,c,l=new Promise((e,t)=>{o=e,c=t}),u=!1,d=!1,m=null,h=!1,g=``,_=[],v=null,y=null,b=null,x=()=>{clearTimeout(v),clearTimeout(y),clearTimeout(b)},T=e=>{if(!u){u=!0,x(),n?.removeEventListener(`abort`,E);try{m?.close()}finally{try{a?.()}finally{e?c(e):o()}}}};async function E(){if(!(u||d)){if(d=!0,x(),m!==null)try{await new Promise(e=>m.stopContinuousRecognitionAsync(e,e))}catch{}T(null)}}let k=()=>[..._,g].filter(e=>e!==``).join(` `).trim(),A=(e,t)=>{h||(h=!0,clearTimeout(v)),clearTimeout(y),y=setTimeout(E,C),r?.(k(),t)};async function j(){if(n?.addEventListener(`abort`,E),!s){T(new t(`Unavailable`,`Dictation is not available in this browser.`));return}let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){T(D(e));return}for(let e of r.getTracks())e.stop();if(!u)try{let n=await p(),r=await f();if(u)return;let a=n.SpeechConfig.fromAuthorizationToken(r.token,r.region);if(a.speechRecognitionLanguage=e.language||i(),a.setProperty(n.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,String(S)),m=new n.SpeechRecognizer(a,n.AudioConfig.fromDefaultMicrophoneInput()),m.recognizing=(e,t)=>{if(u)return;let n=t.result?.text;n&&(g=n,A(n,!1))},m.recognized=(e,r)=>{if(u)return;let{reason:i,text:a}=r.result;i===n.ResultReason.RecognizedSpeech&&a?(_.push(a),g=``,A(a,!0)):i===n.ResultReason.NoMatch&&n.NoMatchDetails.fromResult(r.result).reason===n.NoMatchReason.InitialSilenceTimeout&&T(new t(`NoSpeech`,`No speech was heard.`))},m.canceled=(e,r)=>{u||(r.reason===n.CancellationReason.Error?T(new t(`Failed`,r.errorDetails)):T(null))},m.sessionStopped=()=>T(null),await new Promise((e,t)=>m.startContinuousRecognitionAsync(e,t)),u)return;e.onStarted?.(),v=setTimeout(()=>{h||T(new t(`NoSpeech`,`No speech was heard.`))},S),b=setTimeout(E,w)}catch(e){T(O(e))}}return j(),l}async function h(e,n={}){let{signal:r}=n;if(!r?.aborted)try{let a=await p(),o=await f();if(r?.aborted)return;let s=a.SpeechConfig.fromAuthorizationToken(o.token,o.region);s.speechSynthesisLanguage=n.language||i();let c=new a.SpeakerAudioDestination,l=new a.SpeechSynthesizer(s,a.AudioConfig.fromSpeakerOutput(c));await new Promise((n,i)=>{let o=!1,s=()=>{r?.removeEventListener(`abort`,f),l.close(),c.close()},u=()=>{o||(o=!0,s(),n())},d=e=>{o||(o=!0,s(),i(O(e)))};function f(){c.pause(),u()}r?.addEventListener(`abort`,f),c.onAudioEnd=u;try{l.speakTextAsync(e,e=>{e.reason!==a.ResultReason.SynthesizingAudioCompleted&&d(new t(`Failed`,`The reply could not be synthesised.`))},e=>d(e))}catch(e){d(e)}})}catch(e){throw O(e)}}return{dictation:s,readAloud:c,streamsText:!0,startDictation:m,speak:h}}var N=6e4,P=60*N,F=48*P;function I(e){if(typeof e!=`string`||e===``)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function L(e,t=Date.now(),n=void 0){let r=I(e);if(r===null)return``;let i=t-r,a=Math.abs(i),o=i>=0,s=new Intl.RelativeTimeFormat(n,{numeric:`auto`});if(a<N)return s.format(0,`second`);if(a<P){let e=Math.floor(a/N);return s.format(o?-e:e,`minute`)}if(a<F){let e=Math.floor(a/P);return s.format(o?-e:e,`hour`)}return new Intl.DateTimeFormat(n,{day:`numeric`,month:`short`,year:`numeric`}).format(new Date(r))}function R(e,t=void 0){let n=I(e);return n===null?``:new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(n))}var z=`data-wui-printing`,B=`data-wui-print-hide`,V=`data-wui-print-path`,H=`data-wui-print-target`,U=/* @__PURE__ */ new Set([`script`,`style`,`link`,`template`]),W=null;function G(){if(W!==null){for(let e of W.marked)e.removeAttribute(B),e.removeAttribute(V),e.removeAttribute(H);W.heading.remove(),document.documentElement.removeAttribute(z),window.removeEventListener(`afterprint`,W.onAfterPrint),W=null}}function K(e,t,n,r,i){G();let a=e.querySelector(`.wui-chat-panel`);if(a===null)throw Error(`print needs the wui-chat root`);let o=[];for(let e=a;e!==document.documentElement;e=e.parentElement){e.setAttribute(V,``),o.push(e);for(let t of e.parentElement.children)t===e||U.has(t.localName)||(t.setAttribute(B,``),o.push(t))}for(let e of n)e.setAttribute(B,``),o.push(e);r!==null&&(r.setAttribute(H,``),o.push(r));let s=document.createElement(`div`);s.className=`wui-chat-print-heading`;let c=document.createElement(`h1`);c.textContent=i.title;let l=document.createElement(`p`);l.textContent=i.printedOn,s.append(c,l),a.prepend(s),document.documentElement.setAttribute(z,t);let u=()=>G();window.addEventListener(`afterprint`,u,{once:!0}),W={marked:o,heading:s,onAfterPrint:u};try{window.print()}catch(e){throw G(),e}}function q(e,t){K(e,`conversation`,[],null,t)}function ee(e,t,n){if(!e.contains(t))throw Error(`printReply needs a message inside the wui-chat root`);K(e,`reply`,Array.from(e.querySelectorAll(`li.wui-chat-message`)).filter(e=>e!==t),t,n)}function J(){return typeof navigator<`u`&&typeof navigator.share==`function`}async function te({title:e,text:t}){if(!J())return`failed`;try{return await navigator.share({title:e,text:t}),`shared`}catch(e){return e?.name===`AbortError`?`cancelled`:`failed`}}var ne=`wchat:auto-opened`,re=`wchat:dismissed`,ie=`button, a[href], input, select, textarea`,ae=`input, textarea`;function Y(e){return!e.closest(`.wui-chat`)}function oe(e){return e instanceof Element&&e.matches(ae)&&Y(e)}function se(){return[...document.querySelectorAll(ae)].some(e=>Y(e)&&e.value!==e.defaultValue)}function ce(e){return e.length!==0&&[...document.querySelectorAll(e.join(`,`))].some(e=>{let t=e.getBoundingClientRect();return t.width>0&&t.height>0})}function le(e){return e?[...document.querySelectorAll(ie)].some(t=>{if(!Y(t))return!1;let n=t.getBoundingClientRect();return n.width===0||n.height===0?!1:n.left<e.right&&n.right>e.left&&n.top<e.bottom&&n.bottom>e.top}):!1}function ue(e,t,n){if(e.oncePerSession&&sessionStorage.getItem(ne)||e.rememberDismissal&&sessionStorage.getItem(re)||window.innerWidth<e.skipBelowWidthPx)return!0;let r=window.location.pathname;if(e.skipPathPrefixes.some(e=>r.startsWith(e)))return!0;let i=t.avoid.autoOpenOptOutSelector;return i&&document.querySelector(i)||e.skipWhenFormTouched&&se()||n.isOpen()?!0:e.skipWhenCoversControl&&le(n.panelRect())}function de(e){return oe(document.activeElement)||ce(e.avoid.menuSelectors)||ce(e.avoid.autoOpenBusySelectors)}function fe(e,t,n){let r=0;function i(){r=0,ue(e,t,n)||(de(t)?r=setTimeout(i,e.busyRetrySeconds*1e3):(sessionStorage.setItem(ne,`1`),n.open()))}return r=setTimeout(i,e.delaySeconds*1e3),{cancel(){clearTimeout(r),r=0}}}var pe=.4,me=20;function X(e){let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function he(e){let t=e.match(/[\d.]+/g);if(!t||t.length<3)return null;let[n,r,i]=t.slice(0,3).map(Number);return{r:n,g:r,b:i,alpha:t.length>3?Number(t[3])/(e.includes(`%`)?100:1):1}}function ge({r:e,g:t,b:n}){return .2126*X(e)+.7152*X(t)+.0722*X(n)}function _e(e,t){let n=e.getBoundingClientRect(),r=document.elementsFromPoint?.(n.left+n.width/2,n.top+n.height/2)??[],i=t.length?t.join(`,`):null;for(let t of r){if(e.contains(t))continue;if(i&&t.closest(i))return!0;let n=he(getComputedStyle(t).backgroundColor);if(n&&n.alpha>0)return ge(n)<pe}return!1}function ve(e){return e.length===0?[]:[...document.querySelectorAll(e.join(`,`))]}function ye(e){let t=0;for(let n of e){let e=n.getBoundingClientRect();e.height!==0&&(t=Math.max(t,window.innerHeight-e.top))}return t>0?t+me:0}function be(e){if(e.length===0)return!1;for(let t of document.querySelectorAll(e.join(`,`))){let e=t.getBoundingClientRect();if(e.width>0&&e.height>0)return!0}return!1}function xe(e,t,n){let r=n.ownerDocument.documentElement,i=0,a=!1,o=null;function s(){i=0;let s=t.liftAboveFooter?ve(e.liftSelectors):[];if(o)for(let e of s)o.observe(e);n.style.setProperty(`--wui-chat-lift`,`${ye(s)}px`);let c=n.getBoundingClientRect(),l=c.height===0?0:Math.round(window.innerHeight-c.top);r.style.setProperty(`--wui-chat-launcher-block`,`${l}px`);let u=t.stepAsideForMenus&&be(e.menuSelectors);u&&!a?(n.dataset.launcher=`hidden`,n.inert=!0,a=!0):!u&&a&&(n.dataset.launcher=`idle`,n.inert=!1,a=!1);let d=t.switchOnDark&&_e(n,e.darkSelectors);d&&n.dataset.onDark===void 0&&(n.dataset.onDark=``),!d&&n.dataset.onDark!==void 0&&delete n.dataset.onDark}function c(){i||=requestAnimationFrame(s)}typeof ResizeObserver==`function`&&(o=new ResizeObserver(c));let l=new MutationObserver(c);return l.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`open`,`data-menu-open`]}),document.addEventListener(`scroll`,c,{capture:!0,passive:!0}),window.addEventListener(`resize`,c),window.addEventListener(`load`,c),n.addEventListener(`animationend`,c),c(),{destroy(){i&&cancelAnimationFrame(i),i=0,o?.disconnect(),l.disconnect(),document.removeEventListener(`scroll`,c,{capture:!0}),window.removeEventListener(`resize`,c),window.removeEventListener(`load`,c),n.removeEventListener(`animationend`,c),a&&=(n.inert=!1,!1),delete n.dataset.onDark,n.style.removeProperty(`--wui-chat-lift`),r.style.removeProperty(`--wui-chat-launcher-block`)}}}var Z=`wchat:session-start`,Se=`wchat:pages`,Ce=`wchat:services`;function we(e){let t=sessionStorage.getItem(e);return t?JSON.parse(t):[]}function Te(e,t){sessionStorage.setItem(e,JSON.stringify(t))}function Ee(e,t){let n=t.find(t=>e.startsWith(t));return n===void 0?null:e.slice(n.length).replace(/^\/+|\/+$/g,``)||null}function De(e){sessionStorage.getItem(Z)||sessionStorage.setItem(Z,String(Date.now()));let t=0;function n(){let e=document.documentElement.scrollHeight;if(e<=0)return;let n=(window.scrollY+window.innerHeight)/e*100;n>t&&(t=n)}return window.addEventListener(`scroll`,n,{passive:!0}),function(){n();let r=window.location.pathname,i=we(Se);i.includes(r)||(i.push(r),Te(Se,i));let a=Ee(r,e),o=we(Ce);return a!==null&&(o=o.filter(e=>e!==a),o.push(a),o=o.slice(-10),Te(Ce,o)),{timeOnSiteSeconds:Math.floor((Date.now()-Number(sessionStorage.getItem(Z)))/1e3),scrollPercent:Math.min(100,Math.floor(t)),pagesViewed:i.length,viewedServices:o}}}var Q=8,Oe=`(min-width: 992px)`,ke=`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`,Ae=[`aria-haspopup`,`aria-expanded`,`aria-controls`,`aria-disabled`,`data-offline`,`title`],je=0;function Me(e,t,n){n==null?e.removeAttribute(t):e.setAttribute(t,n)}function Ne(e){let{trigger:t,request:i,isEmpty:a,renderAnswer:o,renderFooter:s,session:c,timings:l,onStateChange:d,returnFocusTo:f}=e??{};if(!(t instanceof HTMLElement))throw TypeError(`createExplainPopover needs a "trigger" element.`);if(typeof i!=`function`)throw TypeError(`createExplainPopover needs a "request" function.`);if(typeof o!=`function`)throw TypeError(`createExplainPopover needs a "renderAnswer" function.`);je+=1;let h=e.title??``,g=e.showNotCounted??!0,_=`wui-chat-explain-${je}`,v=()=>r(e.labels??{}),y=()=>({labels:v(),close:W}),b=n({request:i,isEmpty:a,...l}),x=Object.fromEntries(Ae.map(e=>[e,t.getAttribute(e)])),S=t.hidden,C;t.setAttribute(`aria-haspopup`,`dialog`),t.setAttribute(`aria-expanded`,`false`),t.setAttribute(`aria-controls`,_);let w=null,T=null,E=null,D,O=null,k=[],A=[],j=()=>c?.getState().features.Explain===!1;function M(){b.getSnapshot().offline?(C===void 0&&(C=t.getAttribute(`title`)),t.setAttribute(`title`,v().explainOffline),t.setAttribute(`aria-disabled`,`true`),t.setAttribute(`data-offline`,``)):(C!==void 0&&Me(t,`title`,C),C=void 0,t.removeAttribute(`aria-disabled`),t.removeAttribute(`data-offline`)),c&&(t.hidden=j())}function N(e){if(T.replaceChildren(),e.pillVisible){let t=u(`span`,`wui-chat-explain-pill`),n=u(`span`,`wui-chat-orb`,{"aria-hidden":`true`}),r=u(`span`);r.textContent=e.state===`slow`?v().explainSlow:v().thinking,t.append(n,r);let i=u(`div`,`wui-chat-explain-thinking`,{role:`status`});i.append(t),T.append(i)}else if(e.state===`answered`){e.answer!==D&&(E=o(e.answer,y())??null,D=e.answer);let t=u(`div`,`wui-chat-explain-answer`);E&&t.append(E),T.append(t)}else if(e.state===`empty`){let e=u(`p`,`wui-chat-explain-text`);e.textContent=v().explainEmpty,T.append(e)}else if(e.state===`capacity`){let t=u(`div`,`wui-chat-explain-alert wui-chat-explain-alert--warning`,{role:`status`}),n=u(`p`);n.textContent=e.resetsDateTimeUtc?v().explainCapacity(R(e.resetsDateTimeUtc)):v().explainCapacityNoDate,t.append(n),T.append(t)}else if(e.state===`error`){let e=u(`div`,`wui-chat-explain-alert wui-chat-explain-alert--error`,{role:`alert`}),t=u(`p`);t.textContent=v().explainError,e.append(t,p(`ghost`,v().retry,`rotate-ccw`,()=>b.ask())),T.append(e)}}function P(){let e=w.querySelector(`.wui-chat-explain-foot`);e.replaceChildren();let t=s?.(y());if(t&&e.append(t),g){let t=u(`p`,`wui-chat-explain-note`);t.textContent=v().explainNotCounted,e.append(t)}}function F(){if(!w)return;let e=b.getSnapshot();w.dataset.state=e.state,N(e),P(),d?.(e)}function I(){if(!w)return;if(!t.isConnected){W({restoreFocus:!1});return}let e=document.documentElement.getAttribute(`data-wui-chat-docked`);if((e===`end`||e===`start`)&&globalThis.matchMedia?.(Oe)?.matches===!0){w.dataset.beside=e,w.style.left=``,w.style.top=``,w.style.maxHeight=``;return}delete w.dataset.beside,w.style.position=`fixed`;let n=t.getBoundingClientRect(),r=w.offsetWidth,i=w.offsetHeight,a=globalThis.innerHeight-n.bottom-Q,o=a<i&&n.top>a,s=o?n.top-Q:a,c=o?Math.max(Q,n.top-i-Q):n.bottom+Q,l=Math.max(Q,Math.min(n.left,globalThis.innerWidth-r-Q));w.style.top=`${c}px`,w.style.left=`${l}px`,w.style.maxHeight=s<i?`${Math.max(0,s)}px`:``}function L(e){e.key===`Escape`&&(document.documentElement.hasAttribute(`data-wui-chat-docked`)||(e.stopPropagation(),W()))}function z(e){let n=e.target;w.contains(n)||t.contains(n)||n instanceof Element&&n.closest(`.wui-chat-panel`)||W({restoreFocus:!1})}function B(e){e.target instanceof Node&&w.contains(e.target)||I()}function V(){b.getSnapshot().offline||G()}function H(){for(let[e,t,n,r]of k)e.removeEventListener(t,n,r);k=[];for(let e of A)e.disconnect();A=[]}function U(){if(w||j()||b.getSnapshot().offline)return;w=u(`div`,`wui-chat-explain`,{role:`dialog`,"aria-label":h,popover:`manual`,id:_});let e=u(`header`,`wui-chat-explain-head`),n=u(`strong`,`wui-chat-explain-title`);n.textContent=h,O=m(v().close,`x`,()=>W()),O.classList.add(`wui-chat-explain-close`),e.append(n,O),T=u(`div`,`wui-chat-explain-body`,{"aria-live":`polite`}),w.append(e,T,u(`div`,`wui-chat-explain-foot`)),w.dataset.state=b.getSnapshot().state,document.body.append(w);try{w.showPopover?.()}catch{}t.setAttribute(`aria-expanded`,`true`),b.ask(),I(),(w.querySelector(ke)??O).focus({preventScroll:!0}),k=[[document,`keydown`,L,!0],[document,`pointerdown`,z,!0],[window,`resize`,I,!1],[document,`scroll`,B,!0]];for(let[e,t,n,r]of k)e.addEventListener(t,n,r);if(typeof ResizeObserver==`function`){let e=new ResizeObserver(()=>I());e.observe(w),A.push(e)}let r=new MutationObserver(()=>I());r.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-wui-chat-docked`]}),A.push(r)}function W(e={restoreFocus:!0}){w&&(b.reset(),H(),w.remove(),w=null,T=null,E=null,D=void 0,O=null,t.setAttribute(`aria-expanded`,`false`),M(),e?.restoreFocus!==!1&&(f?.()??t).focus({preventScroll:!0}))}function G(){w?W():U()}let K=b.subscribe(()=>{M(),b.getSnapshot().offline&&w?W():F()}),q=c?.subscribe(()=>{M(),j()&&w&&W({restoreFocus:!1})});return t.addEventListener(`click`,V),M(),{open:U,close:W,toggle:G,isOpen:()=>w!==null,destroy(){W({restoreFocus:!1}),K(),q?.(),b.dispose(),t.removeEventListener(`click`,V);for(let e of Ae)Me(t,e,x[e]);t.hidden=S}}}var Pe=`a[href],button:not([disabled]),input:not([disabled]):not([type='hidden']),select:not([disabled]),textarea:not([disabled]),[tabindex]`;function Fe(e,t){if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(Pe)].filter(e=>e.tabIndex>=0&&!e.hidden);if(n.length===0){t.preventDefault();return}let r=n[0],i=n[n.length-1],a=e.ownerDocument.activeElement,o=e.contains(a);t.shiftKey?o&&a!==r||(t.preventDefault(),i.focus()):o&&a!==i||(t.preventDefault(),r.focus())}function Ie(e){e?.isConnected&&e.focus()}function Le(e,t){t||typeof navigator>`u`||typeof navigator.vibrate!=`function`||navigator.vibrate(e)}var Re=`wui-chat-lock`,ze=`wui-chat-scroll-lock`;function Be(e){let t=e.ownerDocument,n=[t.documentElement,t.body],r=e.style.overscrollBehavior;for(let e of n)e.classList.add(Re);e.setAttribute(`data-lenis-prevent`,``),e.style.overscrollBehavior=`contain`,window.dispatchEvent(new CustomEvent(ze,{detail:{locked:!0}}));let i=!0;return function(){if(i){i=!1;for(let e of n)e.classList.remove(Re);e.removeAttribute(`data-lenis-prevent`),e.style.overscrollBehavior=r,window.dispatchEvent(new CustomEvent(ze,{detail:{locked:!1}}))}}}var Ve={open:{from:420,to:920,seconds:.16,peak:.16},reply:{from:680,to:540,seconds:.11,peak:.06},sent:{from:540,to:760,seconds:.09,peak:.05}},He=[`pointerdown`,`keydown`,`touchstart`],Ue=`wchat:muted`,We=1e-4;function Ge(e,t){let n=t.get(Ue)===`1`,r=null;function i(){for(let e of He)document.removeEventListener(e,a)}function a(){let e=globalThis.AudioContext||globalThis.webkitAudioContext;!r&&e&&(r=new e),r?.state===`suspended`&&r.resume(),i()}for(let e of He)document.addEventListener(e,a);return{play(t){let i=Ve[t];if(!i||n||!r||!e[t]||!(e.volume>0))return;let a=r.currentTime,o=r.createOscillator(),s=r.createGain();o.type=`sine`,o.frequency.setValueAtTime(i.from,a),o.frequency.linearRampToValueAtTime(i.to,a+i.seconds),s.gain.setValueAtTime(i.peak*e.volume,a),s.gain.exponentialRampToValueAtTime(We,a+i.seconds),o.connect(s),s.connect(r.destination),o.start(a),o.stop(a+i.seconds)},setMuted(e){n=!!e,t.set(Ue,n?`1`:`0`)},isMuted(){return n},destroy(){i(),r?.close(),r=null}}}function Ke(e,t={}){return M({getToken:()=>e.getSpeechToken(),getLanguage:t.language?()=>t.language:void 0})}var qe=2e3,Je=500,Ye=32,$=16,Xe=`data-wui-chat-switching`;function Ze(e){return new Promise(t=>setTimeout(t,e))}function Qe(e,t){return typeof e!=`function`||e()?Promise.resolve():new Promise(n=>{let r=0,i=()=>{e()||r>=t?n():(r+=$,setTimeout(i,$))};setTimeout(i,$)})}async function $e(e,t={}){let n=t.reduced??globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;if(typeof document.startViewTransition!=`function`||n){await e();return}let r=document.documentElement;r.setAttribute(Xe,``);try{let n=()=>!t.target||document.querySelector(`.wui-chat--${t.target}`)!==null,r=()=>(typeof t.pageReady!=`function`||t.pageReady())&&n(),i=document.startViewTransition(async()=>{await e(),await Qe(t.routeReady,qe),await Qe(r,Je),await Ze(Ye)});i.ready.catch(()=>{});try{await i.updateCallbackDone}finally{await i.finished.catch(()=>{})}}finally{r.removeAttribute(Xe)}}var et=100,tt=12,nt=220,rt=640;function it(e,t){let n=t.phone.mode===`Sheet`,r=window.visualViewport,i=0;function a(){e.style.removeProperty(`bottom`),e.style.removeProperty(`max-height`)}function o(){if(i=0,window.innerWidth>t.phone.maxWidthPx){a();return}if(!r)return;let o=Math.max(0,window.innerHeight-r.height-r.offsetTop),s=r.height-tt;n&&(s=Math.min(rt,Math.max(nt,s))),e.style.bottom=`${o}px`,e.style.maxHeight=`${s}px`}function s(){clearTimeout(i),i=setTimeout(o,et)}return r?.addEventListener(`resize`,s),r?.addEventListener(`scroll`,s),window.addEventListener(`resize`,s),window.addEventListener(`orientationchange`,s),o(),{destroy(){clearTimeout(i),r?.removeEventListener(`resize`,s),r?.removeEventListener(`scroll`,s),window.removeEventListener(`resize`,s),window.removeEventListener(`orientationchange`,s),a()}}}export{h as A,D as C,u as D,x as E,o as M,s as N,m as O,M as S,f as T,q as _,Ge as a,L as b,Ie as c,De as d,xe as f,G as g,te as h,Ke as i,p as j,d as k,Fe as l,J as m,it as n,Be as o,fe as p,$e as r,Le as s,e as t,Ne as u,ee as v,v as w,t as x,R as y};