@aiden-voice/widget 0.10.1 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/version.d.ts +1 -1
- package/dist/widget.iife.js +7 -7
- package/dist/widget.js +616 -648
- package/package.json +1 -1
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const WIDGET_VERSION = "0.10.
|
|
1
|
+
export declare const WIDGET_VERSION = "0.10.2";
|
package/dist/widget.iife.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var whooAidenWidget=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t={openChat:`Open chat`,closeChat:`Close chat`,chatWith:`Chat with {name}`,newConversation:`New conversation`,conversation:`Conversation`,you:`You`,message:`Message`,messagePlaceholder:`Type a message…`,send:`Send`,messageSent:`Message sent. {name} is preparing a response.`,lookingItUp:`Looking that up for you…`,goodResponse:`Good response`,badResponse:`Bad response`,additionalFeedback:`Additional feedback`,feedbackPlaceholder:`What was wrong? (optional)`,feedbackCategory:`Feedback category`,selectReason:`Select a reason (optional)`,categoryFactual:`Factual error`,categoryIncomplete:`Incomplete`,categoryTone:`Off tone`,categoryOther:`Other`,submit:`Submit`,cancel:`Cancel`,feedbackThanks:`Thanks for the feedback`,feedbackFailed:`Couldn't send feedback`,conversationCleared:`New conversation started. Previous messages were cleared.`,genericError:`Something went wrong, please try again.`,sessionExpired:`This chat session has expired. Reload the page to continue.`,opensInNewTab:`(opens in new tab)`,agreeToNotice:`I agree`},n=Object.keys(t);function r(e,t){if(e!=null&&e!==``){if(typeof e==`string`)try{let t=new URL(e);if(t.protocol===`https:`||t.protocol===`data:`&&t.pathname.toLowerCase().startsWith(`image/`))return e}catch{}console.warn(`whoo-aiden-widget: ignoring \`${t}\` -- only https: and data:image/ URLs are allowed.`)}}var i=[`primary`,`onPrimary`,`primaryText`,`ink`,`link`,`text`,`panel`,`border`,`headerHover`,`assistantBubble`,`muted`,`typingDots`,`errorBackground`,`errorText`,`inputBorder`,`focusRing`],a={primary:`#4f46e5`,onPrimary:`#ffffff`,primaryText:`#4f46e5`,ink:`#111111`,link:`#0000ee`,text:`#111111`,panel:`#ffffff`,border:`#e5e5e5`,headerHover:`#f3f4f6`,assistantBubble:`#f0f0f0`,muted:`#4b5563`,typingDots:`#6b7280`,errorBackground:`#fee2e2`,errorText:`#991b1b`,inputBorder:`#6b7280`,focusRing:`#111827`},o={primary:`--whoo-widget-color`,onPrimary:`--whoo-widget-text-on-color`,primaryText:`--whoo-widget-color-text`,ink:`--whoo-widget-ink`,link:`--whoo-widget-link-color`,text:`--whoo-widget-text`,panel:`--whoo-widget-panel`,border:`--whoo-widget-border`,headerHover:`--whoo-widget-header-hover`,assistantBubble:`--whoo-widget-assistant-bubble`,muted:`--whoo-widget-muted`,typingDots:`--whoo-widget-typing-dots`,errorBackground:`--whoo-widget-error-bg`,errorText:`--whoo-widget-error-text`,inputBorder:`--whoo-widget-input-border`,focusRing:`--whoo-widget-focus-ring`},s=2147483e3,c=2147483647;function l(e){return e===void 0?s:Number.isInteger(e)&&Math.abs(e)<=c?e:(console.warn(`whoo-aiden-widget: ignoring zIndex ${String(e)} (expected an integer between -${c} and ${c}); using ${s}.`),s)}var u=`Aiden`;function d(e){return typeof e==`string`?e.trim():``}function f(e){return/^[\p{White_Space}\p{Cf}\p{M}]*$/u.test(e)}function p(e){if((typeof e.publishableKey==`string`&&e.publishableKey.length>0)==(typeof e.sessionToken==`string`&&e.sessionToken.length>0))throw Error("whoo-aiden-widget: init() requires exactly one of `publishableKey` or `sessionToken`, not both or neither.")}function m(e){console.warn(`whoo-aiden-widget: ${e}`)}function h(e){let{getSessionToken:t}=e;if(t!==void 0){if(typeof t!=`function`)m("ignoring `getSessionToken` -- expected a function that returns a session token.");else if(!e.sessionToken)m("ignoring `getSessionToken` -- it is only used with `sessionToken`; with `publishableKey` the widget renews its session by itself.");else return t}}var g=20;function _(e){let t=new WeakSet,n=new Set;return r=>{if(typeof r==`object`&&r||typeof r==`function`){if(t.has(r))return;t.add(r)}else{if(n.has(r))return;n.size>=g&&n.delete(n.values().next().value),n.add(r)}m(e)}}var v=_("ignoring `theme` -- expected an object."),y=_("ignoring `layout` -- expected an object."),b=_("ignoring `messages` -- expected an object.");function x(e){if(e==null)return{};if(!S(e))return b(e),{};let t={};for(let r of Object.keys(e)){if(!n.includes(r)){m(`ignoring unknown option \`messages.${r}\`.`);continue}let i=e[r];typeof i!=`string`||f(i)?m(`ignoring \`messages.${r}\` -- expected a non-blank string.`):(r===`chatWith`&&!i.includes(`{name}`)&&m("`messages.chatWith` has no {name}, so the agent name is not shown in the title. For a fixed title, use the `title` option."),t[r]=i)}for(let t in e)Object.hasOwn(e,t)||m(`ignoring inherited option \`messages.${t}\` -- only the object's own keys are used.`);return t}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var C=e=>e==null||e===``;function w(e,t,n){let r=e[t];return r==null?null:S(r)?r:(m(`ignoring \`${n}\` -- expected an object.`),null)}function T(e,t,n){for(let r of Object.keys(e))t.includes(r)||m(`ignoring unknown option \`${n}.${r}\`.`)}function E(e,t,n){if(!C(e)){if(typeof e==`string`&&t.includes(e))return e;m(`ignoring \`${n}\` -- expected one of ${t.join(`, `)}.`)}}var D=[`bubble`,`centered`],O=[`top`,`footer`];function k(e){return E(e,D,`greetingStyle`)??`bubble`}function A(e){return E(e,O,`noticePlacement`)??`top`}var ee=200,te=/url\(|[@;{}\\]/i;function ne(e){if(!C(e)){if(typeof e==`string`){let t=e.trim();if(t&&t.length<=ee&&!te.test(t))return t}m(`ignoring \`theme.fonts.family\` -- expected a font-family stack of at most ${ee} characters, without url(), @, ;, {, } or \\.`)}}var re=[`chat`,`message`,`sparkle`],ie=[`chevron-down`,`close`],ae=new WeakMap;function oe(e){let t={colors:{},fontFamily:void 0,launcher:{}};if(e==null)return t;if(!S(e))return v(e),t;let n=ae.get(e);if(n)return n;T(e,[`colors`,`fonts`,`launcher`],`theme`);let a=w(e,`colors`,`theme.colors`);if(a){T(a,i,`theme.colors`);for(let e of i){let n=a[e];C(n)||(typeof n==`string`?t.colors[e]=n:m(`ignoring \`theme.colors.${e}\` -- expected a CSS color string.`))}}let o=w(e,`fonts`,`theme.fonts`);o&&(T(o,[`family`],`theme.fonts`),t.fontFamily=ne(o.family));let s=w(e,`launcher`,`theme.launcher`);if(s){T(s,[`icon`,`iconUrl`,`openIcon`,`openIconUrl`],`theme.launcher`);let e=E(s.icon,re,`theme.launcher.icon`),n=r(s.iconUrl,`theme.launcher.iconUrl`),i=E(s.openIcon,ie,`theme.launcher.openIcon`),a=r(s.openIconUrl,`theme.launcher.openIconUrl`);e&&(t.launcher.icon=e),n&&(t.launcher.iconUrl=n),i&&(t.launcher.openIcon=i),a&&(t.launcher.openIconUrl=a)}return ae.set(e,t),t}var j={offsetX:20,offsetY:20,launcherSize:56,panelWidth:360,panelHeight:480};function M(e,t,n){return e==null?n:typeof e==`number`&&Number.isFinite(e)&&e>=0?e:(m(`ignoring \`${t}\` -- expected a non-negative number of pixels; using ${n}.`),n)}function se(e,t,n,r){let i=Math.min(r,Math.max(n,e));return i!==e&&m(`\`${t}\` ${e} is out of range (${r===1/0?`at least ${n}`:`${n}-${r}`}); using ${i}.`),i}var ce=new WeakMap;function le(e){let t={...j};if(e==null)return t;if(!S(e))return y(e),t;let n=ce.get(e);if(n)return n;T(e,[`offset`,`launcherSize`,`panel`,`cornerRadius`],`layout`);let r=w(e,`offset`,`layout.offset`);r&&(T(r,[`x`,`y`],`layout.offset`),t.offsetX=M(r.x,`layout.offset.x`,j.offsetX),t.offsetY=M(r.y,`layout.offset.y`,j.offsetY)),t.launcherSize=se(M(e.launcherSize,`layout.launcherSize`,j.launcherSize),`layout.launcherSize`,24,120);let i=w(e,`panel`,`layout.panel`);i&&(T(i,[`width`,`height`],`layout.panel`),t.panelWidth=se(M(i.width,`layout.panel.width`,j.panelWidth),`layout.panel.width`,280,1/0),t.panelHeight=se(M(i.height,`layout.panel.height`,j.panelHeight),`layout.panel.height`,320,1/0));let a=e.cornerRadius;return typeof a==`number`&&Number.isFinite(a)&&a>=0?t.cornerRadius=se(a,`layout.cornerRadius`,0,32):C(a)||m("ignoring `layout.cornerRadius` -- expected a non-negative number of pixels."),ce.set(e,t),t}var N,ue,P,de,fe,pe,me,he,ge,_e,ve={},ye=[],be=/^m(i|n|o|s|text|space)$/,xe=Array.isArray,Se=ye.slice,F=Object.assign;function Ce(e){e&&e.parentNode&&e.remove()}function we(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i||++ue,__i:-1,__u:0};return!i&&N.vnode&&N.vnode(a),a}function I(e){return e.children}function Te(e,t){this.props=e,this.context=t,this.__g=0}function L(e,t){if(t==null)return e.__?L(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:L(e)}function Ee(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),Ee(e)}function De(e){(8&e.__g||!(e.__g|=8)||!P.push(e)||fe++)&&de==N.debounceRendering||((de=N.debounceRendering)||queueMicrotask)(Oe)}function Oe(){var e,t,n,r,i,a,o,s,c;try{for(t=1;P.length;)P.length>t&&P.sort(pe),e=P.shift(),t=P.length,8&e.__g&&(r=void 0,i=void 0,a=(i=(n=e).__v).__e,o=[],s=[],(c=n.__P)&&((r=F({constructor:void 0},i)).__v=i.__v+1,N.vnode&&N.vnode(r),Ie(c,r,i,n.__n,c.namespaceURI,32&i.__u?[a]:null,o,a||L(i),32&i.__u,s),r.__v=i.__v,r.__.__k[r.__i]=r,Re(o,r,s),i.__=i.__e=null,r.__e!=a&&Ee(r)))}finally{P.length=fe=0}}function ke(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r.__k||ye,v=t.length;for(c=Ae(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=~p.__i&&_[p.__i]||ve,p.__i=d,g=Ie(e,p,f,i,a,o,s,c,l,u),m=p.__e,(f.ref!=p.ref||8&f.__u)&&(f.ref&&Be(f.ref,null,p,f),p.ref&&u.push(p.ref,p.__c||m,p)),h||=m,4&p.__u?(c=je(p,c,e,!f.__v),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function Ae(e,t,n,r,i){var a,o,s,c,l,u,d,f,p,m,h=n.length,g=h,_=0,v=!1,y=e.__k=Array(i);for(a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o!=`object`||o.constructor==String?o=y[a]=we(null,o):xe(o)?o=y[a]=we(I,{children:o}):o.constructor===void 0&&o.__b?o=y[a]=we(o.type,o.props,o.key,o.ref,o.__v):y[a]=o,c=a+_,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=Me(o,n,c,g))&&(g--,(s=n[l])&&(s.__u|=2)),s&&s.__v?(o.__u|=2,l==c-1?_--:l==c+1?_++:l!=c&&(l>c?_--:_++,v=!0)):(~l||(i>h?_--:i<h&&_++),typeof o.type!=`function`&&(o.__u|=4))):y[a]=null;if(v){for(u=[],d=[],a=0;a<i;a++)if((o=y[a])&&2&o.__u){for(f=0,p=u.length;f<p;)u[m=f+p>>1]<o.__i?f=m+1:p=m;u[f]=o.__i,d[a]=f+1}for(_=u.length;a--;)d[a]&&(d[a]==_?_--:y[a].__u|=4)}if(g)for(a=0;a<h;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=L(s)),Ve(s,s));return r}function je(e,t,n,r){var i,a,o;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=je(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=L(e))&&!t.parentNode&&(t=null),o=t;o&&o.nodeType==8;)o=o.nextSibling;for(e.__e!=o&&(!r&&n.moveBefore&&e.__e.parentNode?n.moveBefore(e.__e,t):n.insertBefore(e.__e,t||null)),t=e.__e;(t&&=t.nextSibling)&&t.nodeType==8;);return t}function Me(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function Ne(e,t,n){n??=``,t[0]==`-`?e.setProperty(t,n):e[t]=n}function Pe(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||Ne(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||Ne(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)(e.__e||={})[t]=n,n&&r||(o=_e[t]||(_e[t]=Fe(t)),(e.__a||={})[t]=ge,a=t!=(t=t.replace(he,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),n?e.addEventListener(t,o,a):e.removeEventListener(t,o,a));else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function Fe(e){return function(t){if(this.__e){var n=this.__e[e];if(t[me]==null)t[me]=ge++;else if(t[me]<this.__a[e])return;return n(N.event?N.event(t):t)}}}function Ie(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A=t.type;if(t.constructor!==void 0)return null;if(128&n.__u&&(c=32&n.__u,u=n.__c.__z)){if(t.__u|=c,d=a=[],u.nodeType==8)for(f=1,p=u.nextSibling;p;p=p.nextSibling){if(p.nodeType==8){if(p.data.startsWith(`$s`))f++;else if(p.data.startsWith(`/$s`)&&!--f)break}a.push(p)}else a.push(u);s=a[0]}(u=N.__b)&&u(t);n:if(typeof A==`function`){m=o.length;try{if(y=t.props,b=(u=A.prototype)&&u.render,x=(u=A.contextType)&&r[u.__c],S=u?x?x.props.value:u.__:r,n.__c?2&(h=t.__c=n.__c).__g&&(h.__g|=1):(b?t.__c=h=new A(y,S):(t.__c=h=new Te(y,S),h.constructor=A,h.render=He),x&&x.sub(h),h.state||(h.state={}),h.__n=r,h.__g|=8,h.__h=[],h.__k=[]),b&&(h.__s||(h.__s=h.state),A.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=F({},h.__s)),F(h.__s,A.getDerivedStateFromProps(y,h.__s)))),g=h.props,_=h.state,h.__v=t,n.__c){if(b&&!A.getDerivedStateFromProps&&y!==g&&h.componentWillReceiveProps&&h.componentWillReceiveProps(y,S),t.__v==n.__v&&!(8&h.__g)||!(4&h.__g)&&h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(y,h.__s,S)){t.__v!=n.__v&&(h.props=y,h.state=h.__s,h.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),ye.push.apply(h.__h,h.__k),h.__k=[],h.__h.length&&o.push(h),s=L(n);break n}h.componentWillUpdate&&h.componentWillUpdate(y,h.__s,S),b&&h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(g,_,v)})}else b&&!A.getDerivedStateFromProps&&h.componentWillMount&&h.componentWillMount(),b&&h.componentDidMount&&h.__h.push(h.componentDidMount);if(h.context=S,h.props=y,h.__P=e,h.__g&=-5,C=N.__r,w=0,b)h.state=h.__s,h.__g&=-9,C&&C(t),u=h.render(h.props,h.state,h.context),ye.push.apply(h.__h,h.__k),h.__k=[];else do h.__g&=-9,C&&C(t),u=h.render(h.props,h.state,h.context),h.state=h.__s;while(8&h.__g&&++w<25);h.state=h.__s,h.getChildContext&&(r=F({},r,h.getChildContext())),b&&n.__c&&h.getSnapshotBeforeUpdate&&(v=h.getSnapshotBeforeUpdate(g,_)),T=u&&u.type===I&&u.key==null?u.props.children:u,y.__P&&(u=s,i=(e=y.__P).namespaceURI,c=a=null,n.props&&n.props.__P!=e&&(n.__k.some(function(e){e&&Ve(e,e)}),n.__k=null),s=n.__k?L(n,0):null),s=ke(e,xe(T)?T:[T],t,n,r,i,a,o,s,c,l),y.__P&&(t.__e=null,s=u),t.__u&=-161,128&n.__u&&(h.__z=null),d&&d.some(Ce),h.__h.length&&o.push(h),1&h.__g&&(h.__g&=-4)}catch(e){if(o.length=m,t.__v=null,c||a){if(e.then){if(E=0,t.__u|=c?160:128,a){for(~(O=a.indexOf(s||void 0))||(O=a.length);(k=a[O-1])&&k.nodeType==8;)O--;for(;O<a.length;O++)if(k=a[O]){if(a[O]=null,k.nodeType==8){if(k.data.startsWith(`$s`))E++||(D=k);else if(E&&k.data.startsWith(`/$s`)&&!--E){s=k;break}}else if(!E)break}}if(!D){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;D=s}t.__c.__z||(t.__c.__z=D),t.__e=s}else a&&a.some(Ce)}else t.__e=n.__e;t.__k||=n.__k||[],e.then||Le(t),N.__e(e,t,n)}}else s=t.__e=ze(n.__e,t,n,r,i,a,o,c,l,e);return(u=N.diffed)&&u(t),128&t.__u?void 0:s}function Le(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(Le))}function Re(e,t,n){for(var r=0;r<n.length;)Be(n[r++],n[r++],n[r++]);N.__c&&N.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){N.__e(e,t.__v)}})}function ze(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y=n.props||ve,b=t.props,x=t.type;if(x==`svg`?i=`http://www.w3.org/2000/svg`:x==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a){for(u=0;u<a.length;u++)if((m=a[u])&&(x?m.localName==x:m.nodeType==3)){e=m,a[u]=null;break}}if(!e){if(_=l.ownerDocument||document,!x)return _.createTextNode(b);e=_.createElementNS(i,x,b.is&&b),s&&=(N.__m&&N.__m(t,a),!1),a=null}if(x){if(l=x==`template`?e.content:e,a=x==`textarea`&&b.defaultValue!=null?null:a&&Se.call(l.childNodes),!s&&a)for(y={},u=0;u<e.attributes.length;u++)y[(m=e.attributes[u]).name]=m.value;for(u in y)m=y[u],u==`dangerouslySetInnerHTML`?f=m:u==`children`||u in b||u==`value`&&`defaultValue`in b||u==`checked`&&`defaultChecked`in b||Pe(e,u,null,m,i);for(u in v=1&n.__u,b)m=b[u],u==`children`?p=m:u==`dangerouslySetInnerHTML`?d=m:u==`value`?h=m:u==`checked`?g=m:s&&typeof m!=`function`||!(y[u]!==m||v&&m!=null)||Pe(e,u,m,y[u],i);d?(s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[]):(f&&(e.textContent=``),(x==`foreignObject`||i==`http://www.w3.org/1998/Math/MathML`&&be.test(x))&&(i=`http://www.w3.org/1999/xhtml`),ke(l,xe(p)?p:[p],t,n,r,i,a,o,a?a[0]:n.__k&&L(n,0),s,c),a&&a.some(Ce)),s&&x!=`textarea`||(u=`value`,x==`progress`&&h==null?e.removeAttribute(u):h==null||h===e[u]&&(x!=`progress`||h)||Pe(e,u,h,y[u],i),u=`checked`,g!=null&&g!=e[u]&&Pe(e,u,g,y[u],i))}else y===b||s&&e.data==b||(e.data=b);return e}function Be(e,t,n,r){try{typeof e==`function`?t?t.__x=e(t)||1:(r&&=r.__c||r.__e)&&(t=r.__x)&&(r.__x=null,typeof t==`function`?t():e(null)):e.current=t}catch(e){N.__e(e,n)}}function Ve(e,t,n){var r,i;if(N.unmount&&N.unmount(e),!(r=e.ref)||r.current&&r.current!=e.__e||Be(r,null,t,e),r=e.__c){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){N.__e(e,t)}r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Ve(r[i],t,typeof e.type!=`function`||n&&!e.props.__P);(r=e.__e)&&(n||Ce(r),r.__e&&(r.__e=null)),e.__e=e.__c=e.__=null}function He(e,t,n){return this.constructor(e,n)}function Ue(e,t){var n,r,i,a;N.__&&N.__(e,t),t.nodeType==9&&(t=t.documentElement),r=(n=e&&32&e.__u)?null:t.__k,t.__k=we(I,{children:[e]}),i=[],a=[],Ie(t,t.__k,r||ve,ve,t.namespaceURI,r?null:t.firstChild?Se.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a),Re(i,t.__k,a),t.__k.props.children=null}N={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((a=i.constructor)&&a.getDerivedStateFromError&&(i.setState(a.getDerivedStateFromError(e)),o=8&i.__g),i.componentDidCatch&&(i.componentDidCatch(e,r||{}),o=8&i.__g),o)return void(i.__g|=2)}catch(t){e=t,o=0}}throw fe=0,e}},ue=0,Te.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=F({},this.state)),typeof e==`function`&&(e=e(F({},n),this.props)),e&&(F(n,e),this.__v&&(t&&this.__k.push(t),De(this)))},Te.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),De(this))},Te.prototype.render=I,P=[],fe=0,pe=function(e,t){return e.__v.__b-t.__v.__b},me=Symbol(),he=/(PointerCapture)$|Capture$/i,ge=0,_e={};var R,z,We,Ge,Ke=Object.is,qe=0,Je=[],Ye=[],B=N,Xe=B.__b,Ze=B.__r,Qe=B.diffed,$e=B.__c,et=B.unmount,tt=B.__;function nt(e,t){B.__h&&B.__h(z,e,qe||t),qe=0;var n=z.__H||(z.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function rt(e){return qe=1,it(pt,e)}function it(e,t,n){var r=nt(R++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):pt(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);Ke(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=z,!z.__f)){z.__f=!0;var i=z.shouldComponentUpdate;z.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,Ke(e.__[0],e.__N[0])||(o=!0))}),i){var s=i.call(this,e,t,n);return a?s||o:s}return!a||o}}return r.__}function at(e,t){var n=nt(R++,3);!B.__s&&ft(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,z.__H.__h.push(n))}function V(e,t){var n=nt(R++,4);!B.__s&&ft(n.__H,t)&&(n.__P=!1,n.__=e,n.u=t,z.__h.push(n))}function H(e){return qe=5,ot(function(){return{current:e}},[])}function ot(e,t){var n=nt(R++,7);return ft(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function st(){var e;do{for(;e=Ye.shift();)try{U(e)}catch(t){B.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=Je.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(U),t.__h.some(dt),t.__h=[]}catch(n){t.__h=[],B.__e(n,e.__v)}}}while(Ye.length)}B.__b=function(e){z=null,Xe&&Xe(e)},B.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),tt&&tt(e,t)},B.__r=function(e){Ze&&Ze(e),R=0;var t=(z=e.__c).__H;t&&(We==z?z.__h=[]:(t.__h.some(U),t.__h.some(dt),R=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),We=z},B.diffed=function(e){Qe&&Qe(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&ut(Je.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),We=z=null},B.__c=function(e,t){t.some(function(e){try{e.__h.some(U),e.__h=e.__h.filter(function(e){return!e.__||dt(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],B.__e(n,e.__v)}}),$e&&$e(e,t)},B.unmount=function(e){et&&et(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n&&=n.__c}r.__P=n,ut(Ye.push(r))}else U(r)}catch(e){t=e}}),r.__H=void 0,t&&B.__e(t,r.__v))};var ct=typeof requestAnimationFrame==`function`;function lt(e){var t,n=function(){clearTimeout(r),ct&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ct&&(t=requestAnimationFrame(n))}function ut(e){e!=1&&Ge==B.requestAnimationFrame||((Ge=B.requestAnimationFrame)||lt)(st)}function U(e){var t=z,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),z=t}function dt(e){var t=z;e.__c=e.__(),z=t}function ft(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!Ke(t,e[n])})}function pt(e,t){return typeof t==`function`?t(e):t}var mt=0;Array.isArray;function W(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--mt,__i:-1,__u:0};return(i||a)&&(l.__source=i,l.__self=a),N.vnode&&N.vnode(l),l}function G({name:e,size:t,children:n}){return W(`svg`,{"data-icon":e,"aria-hidden":`true`,focusable:`false`,width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,children:n})}function ht({size:e=26}){return W(G,{name:`chat`,size:e,children:[W(`path`,{d:`M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 4v-4h0A1.5 1.5 0 0 1 4 14.5z`}),W(`path`,{d:`M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01`,"stroke-width":`2.5`})]})}function gt({size:e=26}){return W(G,{name:`message`,size:e,children:W(`path`,{d:`M21 11.5a8.5 8.5 0 0 1-12.4 7.5L3 20.5l1.6-5.1A8.5 8.5 0 1 1 21 11.5z`})})}function _t({size:e=26}){return W(G,{name:`sparkle`,size:e,children:[W(`path`,{d:`M11 3l1.9 5.1L18 10l-5.1 1.9L11 17l-1.9-5.1L4 10l5.1-1.9z`}),W(`path`,{d:`M19 15l.7 1.8 1.8.7-1.8.7L19 20l-.7-1.8-1.8-.7 1.8-.7z`})]})}function vt({size:e=26}){return W(G,{name:`chevron-down`,size:e,children:W(`path`,{d:`M6 9l6 6 6-6`})})}function yt({size:e=18}){return W(G,{name:`close`,size:e,children:W(`path`,{d:`M6 6l12 12M18 6L6 18`})})}var bt=`M7 11v9M7 11l3.5-7.2A1.8 1.8 0 0 1 14 4.6V9h4.6a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.4 20H7M7 11H4.5A1.5 1.5 0 0 0 3 12.5v6A1.5 1.5 0 0 0 4.5 20H7`;function xt({size:e=16}){return W(G,{name:`thumb-up`,size:e,children:W(`path`,{d:bt})})}function St({size:e=16}){return W(G,{name:`thumb-down`,size:e,children:W(`path`,{d:bt,transform:`matrix(1 0 0 -1 0 24)`})})}var Ct={chat:ht,message:gt,sparkle:_t},wt={"chevron-down":vt,close:yt};function Tt({isOpen:e,onClick:n,iconUrl:r,icon:i=`chat`,openIconUrl:a,openIcon:o=`chevron-down`,buttonRef:s,text:c=t}){let[l,u]=rt(`loading`),[d,f]=rt(`loading`),p=r!==void 0&&l!==`failed`,m=a!==void 0&&d!==`failed`,h=p&&!e&&l===`loaded`,g=m&&e&&d===`loaded`,_=Ct[i]??ht,v=wt[o]??vt;return W(`button`,{type:`button`,class:`whoo-widget-launcher`,onClick:n,"aria-label":e?c.closeChat:c.openChat,ref:s,children:[e?g?null:W(v,{}):h?null:W(_,{}),p?W(`img`,{class:`whoo-widget-launcher-icon-image`,src:r,alt:``,referrerpolicy:`no-referrer`,hidden:!h,onLoad:()=>u(`loaded`),onError:()=>u(`failed`)}):null,m?W(`img`,{class:`whoo-widget-launcher-icon-image`,src:a,alt:``,referrerpolicy:`no-referrer`,hidden:!g,onLoad:()=>f(`loaded`),onError:()=>f(`failed`)}):null]})}var Et={en:t,fr:{openChat:`Ouvrir le chat`,closeChat:`Fermer le chat`,chatWith:`Discuter avec {name}`,newConversation:`Nouvelle conversation`,conversation:`Conversation`,you:`Vous`,message:`Message`,messagePlaceholder:`Écrivez un message…`,send:`Envoyer`,messageSent:`Message envoyé. {name} prépare une réponse.`,lookingItUp:`Je recherche l’information pour vous…`,goodResponse:`Réponse utile`,badResponse:`Réponse peu utile`,additionalFeedback:`Commentaire supplémentaire`,feedbackPlaceholder:`Qu’est-ce qui n’allait pas ? (facultatif)`,feedbackCategory:`Catégorie du commentaire`,selectReason:`Choisissez un motif (facultatif)`,categoryFactual:`Erreur factuelle`,categoryIncomplete:`Réponse incomplète`,categoryTone:`Ton inapproprié`,categoryOther:`Autre`,submit:`Envoyer le commentaire`,cancel:`Annuler`,feedbackThanks:`Merci pour votre commentaire`,feedbackFailed:`Impossible d’envoyer votre commentaire`,conversationCleared:`Nouvelle conversation démarrée. Les messages précédents ont été effacés.`,genericError:`Une erreur s’est produite. Veuillez réessayer.`,sessionExpired:`Cette session de chat a expiré. Rechargez la page pour continuer.`,opensInNewTab:`(s’ouvre dans un nouvel onglet)`,agreeToNotice:`J’accepte`},es:{openChat:`Abrir chat`,closeChat:`Cerrar chat`,chatWith:`Chat con {name}`,newConversation:`Nueva conversación`,conversation:`Conversación`,you:`Usted`,message:`Mensaje`,messagePlaceholder:`Escriba un mensaje…`,send:`Enviar`,messageSent:`Mensaje enviado. {name} está preparando una respuesta.`,lookingItUp:`Estoy buscando esa información…`,goodResponse:`Buena respuesta`,badResponse:`Mala respuesta`,additionalFeedback:`Comentarios adicionales`,feedbackPlaceholder:`¿Qué estuvo mal? (opcional)`,feedbackCategory:`Tipo de problema`,selectReason:`Seleccione un motivo (opcional)`,categoryFactual:`Información incorrecta`,categoryIncomplete:`Respuesta incompleta`,categoryTone:`Tono inadecuado`,categoryOther:`Otro`,submit:`Enviar comentarios`,cancel:`Cancelar`,feedbackThanks:`Gracias por sus comentarios`,feedbackFailed:`No se pudieron enviar sus comentarios`,conversationCleared:`Se inició una nueva conversación. Se borraron los mensajes anteriores.`,genericError:`Algo salió mal. Inténtelo de nuevo.`,sessionExpired:`Esta sesión de chat expiró. Vuelva a cargar la página para continuar.`,opensInNewTab:`(se abre en una pestaña nueva)`,agreeToNotice:`Acepto`},pt:{openChat:`Abrir chat`,closeChat:`Fechar chat`,chatWith:`Conversa com {name}`,newConversation:`Nova conversa`,conversation:`Conversa`,you:`Você`,message:`Mensagem`,messagePlaceholder:`Digite uma mensagem…`,send:`Enviar`,messageSent:`Mensagem enviada. {name} está preparando uma resposta.`,lookingItUp:`Estou buscando essa informação…`,goodResponse:`Boa resposta`,badResponse:`Resposta ruim`,additionalFeedback:`Comentários adicionais`,feedbackPlaceholder:`O que estava errado? (opcional)`,feedbackCategory:`Categoria do feedback`,selectReason:`Selecione um motivo (opcional)`,categoryFactual:`Informação incorreta`,categoryIncomplete:`Resposta incompleta`,categoryTone:`Tom inadequado`,categoryOther:`Outro`,submit:`Enviar feedback`,cancel:`Cancelar`,feedbackThanks:`Agradecemos seu feedback`,feedbackFailed:`Não foi possível enviar o feedback`,conversationCleared:`Nova conversa iniciada. As mensagens anteriores foram apagadas.`,genericError:`Algo deu errado. Tente novamente.`,sessionExpired:`Esta sessão de chat expirou. Recarregue a página para continuar.`,opensInNewTab:`(abre em uma nova aba)`,agreeToNotice:`Concordo`},de:{openChat:`Chat öffnen`,closeChat:`Chat schließen`,chatWith:`Chat mit {name}`,newConversation:`Neue Unterhaltung`,conversation:`Unterhaltung`,you:`Sie`,message:`Nachricht`,messagePlaceholder:`Nachricht eingeben…`,send:`Senden`,messageSent:`Nachricht gesendet. {name} bereitet eine Antwort vor.`,lookingItUp:`Ich suche die Informationen für Sie heraus…`,goodResponse:`Gute Antwort`,badResponse:`Schlechte Antwort`,additionalFeedback:`Zusätzliches Feedback`,feedbackPlaceholder:`Was war falsch? (optional)`,feedbackCategory:`Feedback-Kategorie`,selectReason:`Grund auswählen (optional)`,categoryFactual:`Faktenfehler`,categoryIncomplete:`Unvollständig`,categoryTone:`Unpassender Ton`,categoryOther:`Sonstiges`,submit:`Absenden`,cancel:`Abbrechen`,feedbackThanks:`Danke für Ihr Feedback`,feedbackFailed:`Feedback konnte nicht gesendet werden`,conversationCleared:`Neue Unterhaltung gestartet. Die bisherigen Nachrichten wurden gelöscht.`,genericError:`Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut.`,sessionExpired:`Diese Chat-Sitzung ist abgelaufen. Laden Sie die Seite neu, um fortzufahren.`,opensInNewTab:`(öffnet sich in neuem Tab)`,agreeToNotice:`Ich stimme zu`},it:{openChat:`Apri la chat`,closeChat:`Chiudi la chat`,chatWith:`Chat con {name}`,newConversation:`Nuova conversazione`,conversation:`Conversazione`,you:`Tu`,message:`Messaggio`,messagePlaceholder:`Scrivi un messaggio…`,send:`Invia`,messageSent:`Messaggio inviato. {name} sta preparando una risposta.`,lookingItUp:`Sto cercando le informazioni richieste…`,goodResponse:`Risposta utile`,badResponse:`Risposta non utile`,additionalFeedback:`Commenti aggiuntivi`,feedbackPlaceholder:`Che cosa non andava? (facoltativo)`,feedbackCategory:`Categoria del feedback`,selectReason:`Seleziona un motivo (facoltativo)`,categoryFactual:`Informazione errata`,categoryIncomplete:`Risposta incompleta`,categoryTone:`Tono non adeguato`,categoryOther:`Altro`,submit:`Invia feedback`,cancel:`Annulla`,feedbackThanks:`Grazie per il feedback`,feedbackFailed:`Impossibile inviare il feedback`,conversationCleared:`Nuova conversazione avviata. I messaggi precedenti sono stati cancellati.`,genericError:`Si è verificato un errore. Riprovi.`,sessionExpired:`Questa sessione di chat è scaduta. Ricarichi la pagina per continuare.`,opensInNewTab:`(si apre in una nuova scheda)`,agreeToNotice:`Accetto`},ja:{openChat:`チャットを開く`,closeChat:`チャットを閉じる`,chatWith:`{name}とチャット`,newConversation:`新しい会話`,conversation:`会話`,you:`あなた`,message:`メッセージ`,messagePlaceholder:`メッセージを入力…`,send:`送信`,messageSent:`メッセージを送信しました。{name}が回答を準備しています。`,lookingItUp:`確認しています…`,goodResponse:`良い回答`,badResponse:`良くない回答`,additionalFeedback:`追加のフィードバック`,feedbackPlaceholder:`何が問題でしたか?(任意)`,feedbackCategory:`フィードバックの種類`,selectReason:`理由を選択(任意)`,categoryFactual:`事実の誤り`,categoryIncomplete:`回答が不十分`,categoryTone:`不適切な口調`,categoryOther:`その他`,submit:`フィードバックを送信`,cancel:`キャンセル`,feedbackThanks:`フィードバックありがとうございます`,feedbackFailed:`フィードバックを送信できませんでした`,conversationCleared:`新しい会話を開始しました。以前のメッセージは消去されました。`,genericError:`エラーが発生しました。もう一度お試しください。`,sessionExpired:`このチャットセッションの有効期限が切れました。続けるにはページを再読み込みしてください。`,opensInNewTab:`(新しいタブで開きます)`,agreeToNotice:`同意する`},zh:{openChat:`打开聊天`,closeChat:`关闭聊天`,chatWith:`与{name}聊天`,newConversation:`新对话`,conversation:`对话`,you:`您`,message:`消息`,messagePlaceholder:`输入消息…`,send:`发送`,messageSent:`消息已发送。{name}正在准备回复。`,lookingItUp:`正在为您查找……`,goodResponse:`回答很好`,badResponse:`回答不好`,additionalFeedback:`补充反馈`,feedbackPlaceholder:`哪里有问题?(可选)`,feedbackCategory:`反馈类别`,selectReason:`选择原因(可选)`,categoryFactual:`事实错误`,categoryIncomplete:`回答不完整`,categoryTone:`语气不当`,categoryOther:`其他`,submit:`提交`,cancel:`取消`,feedbackThanks:`感谢您的反馈`,feedbackFailed:`反馈提交失败`,conversationCleared:`已开始新对话。之前的消息已清除。`,genericError:`出了点问题,请重试。`,sessionExpired:`此聊天会话已过期。请刷新页面后继续。`,opensInNewTab:`(将在新标签页中打开)`,agreeToNotice:`我同意`},ru:{openChat:`Открыть чат`,closeChat:`Закрыть чат`,chatWith:`Чат с ассистентом {name}`,newConversation:`Новый диалог`,conversation:`Диалог`,you:`Вы`,message:`Сообщение`,messagePlaceholder:`Введите сообщение…`,send:`Отправить`,messageSent:`Сообщение отправлено. {name} готовит ответ.`,lookingItUp:`Ищу информацию…`,goodResponse:`Хороший ответ`,badResponse:`Плохой ответ`,additionalFeedback:`Дополнительный комментарий`,feedbackPlaceholder:`Что было не так? (необязательно)`,feedbackCategory:`Категория отзыва`,selectReason:`Выберите причину (необязательно)`,categoryFactual:`Фактическая ошибка`,categoryIncomplete:`Неполный ответ`,categoryTone:`Неподходящий тон`,categoryOther:`Другое`,submit:`Отправить отзыв`,cancel:`Отмена`,feedbackThanks:`Спасибо за отзыв`,feedbackFailed:`Не удалось отправить отзыв`,conversationCleared:`Начат новый диалог. Предыдущие сообщения удалены.`,genericError:`Что-то пошло не так. Попробуйте ещё раз.`,sessionExpired:`Срок действия сеанса чата истёк. Перезагрузите страницу, чтобы продолжить.`,opensInNewTab:`(откроется в новой вкладке)`,agreeToNotice:`Принимаю`},hi:{openChat:`चैट खोलें`,closeChat:`चैट बंद करें`,chatWith:`{name} से चैट करें`,newConversation:`नई बातचीत`,conversation:`बातचीत`,you:`आप`,message:`संदेश`,messagePlaceholder:`संदेश लिखें…`,send:`भेजें`,messageSent:`संदेश भेज दिया गया। {name} द्वारा जवाब तैयार किया जा रहा है।`,lookingItUp:`आपके लिए जानकारी खोजी जा रही है…`,goodResponse:`अच्छा जवाब`,badResponse:`ख़राब जवाब`,additionalFeedback:`अतिरिक्त फ़ीडबैक`,feedbackPlaceholder:`क्या ग़लत था? (वैकल्पिक)`,feedbackCategory:`फ़ीडबैक की श्रेणी`,selectReason:`कारण चुनें (वैकल्पिक)`,categoryFactual:`तथ्यात्मक त्रुटि`,categoryIncomplete:`अधूरा जवाब`,categoryTone:`अनुचित लहजा`,categoryOther:`अन्य`,submit:`सबमिट करें`,cancel:`रद्द करें`,feedbackThanks:`आपके फ़ीडबैक के लिए धन्यवाद`,feedbackFailed:`फ़ीडबैक नहीं भेजा जा सका`,conversationCleared:`नई बातचीत शुरू हुई। पिछले संदेश मिटा दिए गए।`,genericError:`कुछ ग़लत हो गया। कृपया फिर से कोशिश करें।`,sessionExpired:`यह चैट सत्र समाप्त हो गया है। जारी रखने के लिए पेज को फिर से लोड करें।`,opensInNewTab:`(नए टैब में खुलता है)`,agreeToNotice:`मैं सहमत हूँ`},ar:{openChat:`فتح الدردشة`,closeChat:`إغلاق الدردشة`,chatWith:`الدردشة مع {name}`,newConversation:`محادثة جديدة`,conversation:`المحادثة`,you:`أنت`,message:`الرسالة`,messagePlaceholder:`كتابة رسالة…`,send:`إرسال`,messageSent:`تم إرسال الرسالة. جارٍ إعداد الرد من قِبل {name}.`,lookingItUp:`جارٍ البحث عن المعلومات…`,goodResponse:`إجابة جيدة`,badResponse:`إجابة سيئة`,additionalFeedback:`ملاحظات إضافية`,feedbackPlaceholder:`ما المشكلة؟ (اختياري)`,feedbackCategory:`فئة الملاحظات`,selectReason:`اختر سببًا (اختياري)`,categoryFactual:`معلومات غير صحيحة`,categoryIncomplete:`إجابة غير مكتملة`,categoryTone:`أسلوب غير مناسب`,categoryOther:`أخرى`,submit:`إرسال الملاحظات`,cancel:`إلغاء`,feedbackThanks:`شكرًا على ملاحظاتك`,feedbackFailed:`تعذّر إرسال الملاحظات`,conversationCleared:`بدأت محادثة جديدة. تم مسح الرسائل السابقة.`,genericError:`حدث خطأ ما. يُرجى المحاولة مرة أخرى.`,sessionExpired:`انتهت صلاحية جلسة الدردشة هذه. يُرجى إعادة تحميل الصفحة للمتابعة.`,opensInNewTab:`(يُفتح في علامة تبويب جديدة)`,agreeToNotice:`أوافق`}},Dt=Object.freeze(Object.keys(Et)),Ot={pt:`pt-BR`,es:`es-419`,zh:`zh-Hans`},kt=new Set([`ar`]),At=/^[a-z]{2,8}([-_][a-z0-9]{1,8})*$/i,jt=/^zh[-_](hant|tw|hk|mo)(?=$|[-_])/i;function Mt(e){return Et[e]}function Nt(e){let t=e.trim();if(!At.test(t)||jt.test(t))return null;let n=t.split(/[-_]/)[0].toLowerCase();return Object.hasOwn(Et,n)?n:null}function Pt(e,t){let n=null;return e!=null&&e!==``&&(n=typeof e==`string`?Nt(e):null,n||console.warn(`whoo-aiden-widget: ignoring \`language\` ${Ft(e)} -- expected one of ${Dt.join(`, `)} (or a regional tag like pt-BR). Using the page's language instead.`)),n??=typeof t==`string`?Nt(t):null,n??=`en`,{language:n,tag:Ot[n]??n,dir:kt.has(n)?`rtl`:`ltr`}}function Ft(e){return typeof e==`string`?JSON.stringify(e):`(a ${typeof e})`}function It(e){if(typeof e!=`string`)return null;let t=e.trim().replace(/_/g,`-`);return At.test(t)?t:null}function Lt(e,t,n){if(e!=null&&e!==``){let t=It(e);if(t)return t;console.warn(`whoo-aiden-widget: ignoring \`contentLanguage\` ${Ft(e)} -- expected a language tag such as 'nl' or 'pt-BR'. Using the page's language instead.`)}return It(t)??It(n)??``}function Rt(e){let t=e.indexOf(`{name}`);return t===-1?{before:e,after:``,hasName:!1}:{before:e.slice(0,t),after:e.slice(t+6),hasName:!0}}function zt(e,t){return e.split(`{name}`).join(t.name)}var Bt=`(max-width: 400px), (max-height: 420px)`,Vt=`data-fit-visible`,Ht=40;function Ut(e){let t=typeof window<`u`?window.visualViewport:null;if(!t)return()=>{};let n=()=>{e.removeAttribute(Vt),e.style.removeProperty(`--whoo-widget-visible-top`),e.style.removeProperty(`--whoo-widget-visible-height`)},r=()=>{let r=document.documentElement.clientHeight,i=Math.abs(t.scale-1)>.01,a=r-t.height;if(i||r===0||a<Ht){n();return}e.setAttribute(Vt,``),e.style.setProperty(`--whoo-widget-visible-top`,`${Math.max(0,t.offsetTop)}px`),e.style.setProperty(`--whoo-widget-visible-height`,`${t.height}px`);let o=e.getRootNode().activeElement;o&&e.contains(o)&&typeof o.scrollIntoView==`function`&&o.scrollIntoView({block:`nearest`})};return r(),t.addEventListener(`resize`,r),t.addEventListener(`scroll`,r),()=>{t.removeEventListener(`resize`,r),t.removeEventListener(`scroll`,r),n()}}function Wt(e,t){return typeof e.addEventListener==`function`?(e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)):typeof e.addListener==`function`?(e.addListener(t),()=>e.removeListener(t)):()=>{}}var Gt=0,Kt=``;function qt(){Gt++===0&&(Kt=document.documentElement.style.overflow,document.documentElement.style.overflow=`hidden`)}function Jt(){--Gt===0&&(document.documentElement.style.overflow=Kt)}function Yt(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return()=>{};let e=window.matchMedia(Bt),t=!1,n=()=>{e.matches&&!t?(t=!0,qt()):!e.matches&&t&&(t=!1,Jt())};n();let r=Wt(e,n);return()=>{r(),t&&(t=!1,Jt())}}function Xt(e){if(typeof window>`u`||typeof window.matchMedia!=`function`||typeof e.showModal!=`function`)return()=>{};let t=window.matchMedia(Bt),n=!1,r=()=>{if(t.matches===n||!e.isConnected)return;n=t.matches;let r=e.getRootNode().activeElement;e.close(),n?e.showModal():e.show(),r&&e.contains(r)&&r.focus({preventScroll:!0})};return r(),Wt(t,r)}function Zt(e){return e.isComposing||e.keyCode===229}function Qt({value:e,onChange:n,onSend:r,disabled:i,inputRef:a,text:o=t,contentLanguage:s}){return W(`div`,{class:`whoo-widget-composer`,children:[W(`label`,{class:`whoo-widget-sr-only`,for:`whoo-widget-composer-input`,children:o.message}),W(`input`,{id:`whoo-widget-composer-input`,class:`whoo-widget-composer-input`,lang:s,autoFocus:!0,placeholder:o.messagePlaceholder,value:e,readOnly:i,"aria-disabled":i,ref:a,onInput:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!Zt(e)&&r()}}),W(`button`,{type:`button`,class:`whoo-widget-composer-send`,"aria-disabled":i,onClick:()=>{i||r()},children:o.send})]})}function $t({message:e}){return W(`div`,{class:`whoo-widget-error-banner`,role:`alert`,children:e})}var en=/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y,tn=/\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y,nn=/(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y,rn=/\*([^*\s](?:[^*]*[^*\s])?)\*/y,an=/[ \t]*[*+-][ \t]+/y,on=/https?:\/\/\S+/y,sn=/[.,;:!?)\]}>]+$/;function cn(e){let t=[],n=0,r=0,i=n=>{n>r&&t.push({type:`text`,value:e.slice(r,n),start:r,end:n})};for(;n<e.length;){if((n===0||e[n-1]===`
|
|
2
|
-
`)&&(
|
|
1
|
+
var whooAidenWidget=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t={openChat:`Open chat`,closeChat:`Close chat`,chatWith:`Chat with {name}`,newConversation:`New conversation`,conversation:`Conversation`,you:`You`,message:`Message`,messagePlaceholder:`Type a message…`,send:`Send`,messageSent:`Message sent. {name} is preparing a response.`,lookingItUp:`Looking that up for you…`,goodResponse:`Good response`,badResponse:`Bad response`,additionalFeedback:`Additional feedback`,feedbackPlaceholder:`What was wrong? (optional)`,feedbackCategory:`Feedback category`,selectReason:`Select a reason (optional)`,categoryFactual:`Factual error`,categoryIncomplete:`Incomplete`,categoryTone:`Off tone`,categoryOther:`Other`,submit:`Submit`,cancel:`Cancel`,feedbackThanks:`Thanks for the feedback`,feedbackFailed:`Couldn't send feedback`,conversationCleared:`New conversation started. Previous messages were cleared.`,genericError:`Something went wrong, please try again.`,sessionExpired:`This chat session has expired. Reload the page to continue.`,opensInNewTab:`(opens in new tab)`,agreeToNotice:`I agree`},n=Object.keys(t);function r(e,t){if(e!=null&&e!==``){if(typeof e==`string`)try{let t=new URL(e);if(t.protocol===`https:`||t.protocol===`data:`&&t.pathname.toLowerCase().startsWith(`image/`))return e}catch{}console.warn(`whoo-aiden-widget: ignoring \`${t}\` -- only https: and data:image/ URLs are allowed.`)}}var i=[`primary`,`onPrimary`,`primaryText`,`ink`,`link`,`text`,`panel`,`border`,`headerHover`,`assistantBubble`,`muted`,`typingDots`,`errorBackground`,`errorText`,`inputBorder`,`focusRing`],a={primary:`#4f46e5`,onPrimary:`#ffffff`,primaryText:`#4f46e5`,ink:`#111111`,link:`#0000ee`,text:`#111111`,panel:`#ffffff`,border:`#e5e5e5`,headerHover:`#f3f4f6`,assistantBubble:`#f0f0f0`,muted:`#4b5563`,typingDots:`#6b7280`,errorBackground:`#fee2e2`,errorText:`#991b1b`,inputBorder:`#6b7280`,focusRing:`#111827`},o={primary:`--whoo-widget-color`,onPrimary:`--whoo-widget-text-on-color`,primaryText:`--whoo-widget-color-text`,ink:`--whoo-widget-ink`,link:`--whoo-widget-link-color`,text:`--whoo-widget-text`,panel:`--whoo-widget-panel`,border:`--whoo-widget-border`,headerHover:`--whoo-widget-header-hover`,assistantBubble:`--whoo-widget-assistant-bubble`,muted:`--whoo-widget-muted`,typingDots:`--whoo-widget-typing-dots`,errorBackground:`--whoo-widget-error-bg`,errorText:`--whoo-widget-error-text`,inputBorder:`--whoo-widget-input-border`,focusRing:`--whoo-widget-focus-ring`},s=2147483e3,c=2147483647;function l(e){return e===void 0?s:Number.isInteger(e)&&Math.abs(e)<=c?e:(console.warn(`whoo-aiden-widget: ignoring zIndex ${String(e)} (expected an integer between -${c} and ${c}); using ${s}.`),s)}var u=`Aiden`;function d(e){return typeof e==`string`?e.trim():``}function f(e){return/^[\p{White_Space}\p{Cf}\p{M}]*$/u.test(e)}function p(e){if((typeof e.publishableKey==`string`&&e.publishableKey.length>0)==(typeof e.sessionToken==`string`&&e.sessionToken.length>0))throw Error("whoo-aiden-widget: init() requires exactly one of `publishableKey` or `sessionToken`, not both or neither.")}function m(e){console.warn(`whoo-aiden-widget: ${e}`)}function h(e){let{getSessionToken:t}=e;if(t!==void 0){if(typeof t!=`function`)m("ignoring `getSessionToken` -- expected a function that returns a session token.");else if(!e.sessionToken)m("ignoring `getSessionToken` -- it is only used with `sessionToken`; with `publishableKey` the widget renews its session by itself.");else return t}}var g=20;function _(e){let t=new WeakSet,n=new Set;return r=>{if(typeof r==`object`&&r||typeof r==`function`){if(t.has(r))return;t.add(r)}else{if(n.has(r))return;n.size>=g&&n.delete(n.values().next().value),n.add(r)}m(e)}}var v=_("ignoring `theme` -- expected an object."),y=_("ignoring `layout` -- expected an object."),b=_("ignoring `messages` -- expected an object.");function x(e){if(e==null)return{};if(!S(e))return b(e),{};let t={};for(let r of Object.keys(e)){if(!n.includes(r)){m(`ignoring unknown option \`messages.${r}\`.`);continue}let i=e[r];typeof i!=`string`||f(i)?m(`ignoring \`messages.${r}\` -- expected a non-blank string.`):(r===`chatWith`&&!i.includes(`{name}`)&&m("`messages.chatWith` has no {name}, so the agent name is not shown in the title. For a fixed title, use the `title` option."),t[r]=i)}for(let t in e)Object.hasOwn(e,t)||m(`ignoring inherited option \`messages.${t}\` -- only the object's own keys are used.`);return t}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var C=e=>e==null||e===``;function w(e,t,n){let r=e[t];return r==null?null:S(r)?r:(m(`ignoring \`${n}\` -- expected an object.`),null)}function T(e,t,n){for(let r of Object.keys(e))t.includes(r)||m(`ignoring unknown option \`${n}.${r}\`.`)}function E(e,t,n){if(!C(e)){if(typeof e==`string`&&t.includes(e))return e;m(`ignoring \`${n}\` -- expected one of ${t.join(`, `)}.`)}}var D=[`bubble`,`centered`],O=[`top`,`footer`];function ee(e){return E(e,D,`greetingStyle`)??`bubble`}function te(e){return E(e,O,`noticePlacement`)??`top`}var ne=200,re=/url\(|[@;{}\\]/i;function ie(e){if(!C(e)){if(typeof e==`string`){let t=e.trim();if(t&&t.length<=ne&&!re.test(t))return t}m(`ignoring \`theme.fonts.family\` -- expected a font-family stack of at most ${ne} characters, without url(), @, ;, {, } or \\.`)}}var ae=[`chat`,`message`,`sparkle`],oe=[`chevron-down`,`close`],se=new WeakMap;function ce(e){let t={colors:{},fontFamily:void 0,launcher:{}};if(e==null)return t;if(!S(e))return v(e),t;let n=se.get(e);if(n)return n;T(e,[`colors`,`fonts`,`launcher`],`theme`);let a=w(e,`colors`,`theme.colors`);if(a){T(a,i,`theme.colors`);for(let e of i){let n=a[e];C(n)||(typeof n==`string`?t.colors[e]=n:m(`ignoring \`theme.colors.${e}\` -- expected a CSS color string.`))}}let o=w(e,`fonts`,`theme.fonts`);o&&(T(o,[`family`],`theme.fonts`),t.fontFamily=ie(o.family));let s=w(e,`launcher`,`theme.launcher`);if(s){T(s,[`icon`,`iconUrl`,`openIcon`,`openIconUrl`],`theme.launcher`);let e=E(s.icon,ae,`theme.launcher.icon`),n=r(s.iconUrl,`theme.launcher.iconUrl`),i=E(s.openIcon,oe,`theme.launcher.openIcon`),a=r(s.openIconUrl,`theme.launcher.openIconUrl`);e&&(t.launcher.icon=e),n&&(t.launcher.iconUrl=n),i&&(t.launcher.openIcon=i),a&&(t.launcher.openIconUrl=a)}return se.set(e,t),t}var k={offsetX:20,offsetY:20,launcherSize:56,panelWidth:360,panelHeight:480};function A(e,t,n){return e==null?n:typeof e==`number`&&Number.isFinite(e)&&e>=0?e:(m(`ignoring \`${t}\` -- expected a non-negative number of pixels; using ${n}.`),n)}function j(e,t,n,r){let i=Math.min(r,Math.max(n,e));return i!==e&&m(`\`${t}\` ${e} is out of range (${r===1/0?`at least ${n}`:`${n}-${r}`}); using ${i}.`),i}var le=new WeakMap;function ue(e){let t={...k};if(e==null)return t;if(!S(e))return y(e),t;let n=le.get(e);if(n)return n;T(e,[`offset`,`launcherSize`,`panel`,`cornerRadius`],`layout`);let r=w(e,`offset`,`layout.offset`);r&&(T(r,[`x`,`y`],`layout.offset`),t.offsetX=A(r.x,`layout.offset.x`,k.offsetX),t.offsetY=A(r.y,`layout.offset.y`,k.offsetY)),t.launcherSize=j(A(e.launcherSize,`layout.launcherSize`,k.launcherSize),`layout.launcherSize`,24,120);let i=w(e,`panel`,`layout.panel`);i&&(T(i,[`width`,`height`],`layout.panel`),t.panelWidth=j(A(i.width,`layout.panel.width`,k.panelWidth),`layout.panel.width`,280,1/0),t.panelHeight=j(A(i.height,`layout.panel.height`,k.panelHeight),`layout.panel.height`,320,1/0));let a=e.cornerRadius;return typeof a==`number`&&Number.isFinite(a)&&a>=0?t.cornerRadius=j(a,`layout.cornerRadius`,0,32):C(a)||m("ignoring `layout.cornerRadius` -- expected a non-negative number of pixels."),le.set(e,t),t}var M,de,N,fe,pe,me,P,he,ge,_e,F=Symbol.for(`pv`),ve={},ye=[],be=/^m(i|n|o|s|text|space)$/,xe=Array.isArray,Se=ye.slice,I=Object.assign;function L(e){e&&e.parentNode&&e.remove()}function Ce(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:F,__v:i||++de,__i:-1,__u:0};return!i&&M.vnode&&M.vnode(a),a}function R(e){return e.children}function we(e,t){this.props=e,this.context=t,this.__g=0}function z(e,t){if(t==null)return e.__&&z(e.__,e.__i+1);for(var n;t<e.__k.length;t++)if((n=e.__k[t])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:z(e)}function Te(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),Te(e)}function Ee(e){(8&e.__g||(e.__g|=8,N.push(e),pe++))&&fe==M.debounceRendering||((fe=M.debounceRendering)||queueMicrotask)(De)}function De(){var e,t,n,r,i,a,o,s,c;try{for(t=1;N.length;)N.length>t&&N.sort(me),e=N.shift(),t=N.length,8&e.__g&&(r=void 0,i=void 0,a=(i=(n=e).__v).__e,o=[],s=[],(c=n.__P)&&((r=I({constructor:F},i)).__v=i.__v+1,M.vnode&&M.vnode(r),Fe(c,r,i,n.__n,c.namespaceURI,32&i.__u?[a]:null,o,a||z(i),32&i.__u,s),r.__v=i.__v,r.__.__k[r.__i]=r,Re(o,r,s),i.__=i.__e=null,r.__e!=a&&Te(r)))}finally{(pe=N.length)&&(fe||queueMicrotask)(De)}}function Oe(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r.__k||ye,v=t.length;for(c=ke(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=~p.__i&&_[p.__i]||ve,p.__i=d,g=Fe(e,p,f,i,a,o,s,c,l,u),m=p.__e,(f.ref!=p.ref||8&f.__u)&&(f.ref&&Be(f.ref,null,p,f),p.ref&&u.push(p.ref,p.__c||m,p)),h||=m,4&p.__u?(c=Ae(p,c,e,!f.__v),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-21);return n.__e=h,c}function ke(e,t,n,r,i){var a,o,s,c,l,u,d,f,p,m=n.length,h=m,g=0,_=0,v=e.__k=Array(i);for(a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o!=`object`||o.constructor===String?o=v[a]=Ce(null,o):xe(o)?o=v[a]=Ce(R,{children:o}):o.constructor===F&&o.__b?o=v[a]=Ce(o.type,o.props,o.key,o.ref,o.__v):v[a]=o,c=a+g,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=je(o,n,c,h))&&(h--,(s=n[l])&&(s.__u|=2)),s&&s.__v?(o.__u|=16,l==c-1?g--:l==c+1?g++:l!=c&&(l>c?g--:g++,_=1)):(~l||(i>m?g--:i<m&&g++),typeof o.type!=`function`&&(o.__u|=4))):v[a]=null;if(_){for(u=[],d=[],a=0;a<i;a++)if((o=v[a])&&16&o.__u){for(g=0,f=u.length;g<f;)u[p=g+f>>1]<o.__i?g=p+1:f=p;u[g]=o.__i,d[a]=g+1}for(g=u.length;a--;)d[a]&&(d[a]==g?g--:v[a].__u|=4)}if(h)for(a=0;a<m;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=z(s)),Ve(s,s));return r}function Ae(e,t,n,r){var i,a,o,s;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=Ae(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=z(e))&&!t.parentNode&&(t=null),o=e.__e,s=t;s&&s.nodeType==8;)s=s.nextSibling;for(o!=s&&(!r&&n.moveBefore&&o.parentNode?n.moveBefore(o,t):n.insertBefore(o,t||null)),t=o;(t&&=t.nextSibling)&&t.nodeType==8&&!t.data.startsWith(`$s`););return t}function je(e,t,n,r){var i,a=e.key,o=e.type,s=t[n],c=s&&!(2&s.__u);if(s===null&&a==null||c&&a==s.key&&o==s.type)return n;if(r>+!!c){for(i=n-1;i>=0;i--)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i;for(i=n+1;i<t.length;i++)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i}return-1}function Me(e,t,n){n??=``,t[0]==`-`?e.setProperty(t,n):e[t]=n}function Ne(e,t,n,r,i){var a,o;if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||Me(e.style,t);if(n)for(t in n)r&&n[t]==r[t]||Me(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)(e.__e||={})[t]=n,n&&r||(o=_e[t]||(_e[t]=Pe(t)),(e.__a||={})[t]=ge,a=t!=(t=t.replace(he,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),n?e.addEventListener(t,o,a):e.removeEventListener(t,o,a));else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;return}catch{}if(typeof n==`function`)return;n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n)}}function Pe(e){return function(t){var n=this.__e;if(n){if(n=n[e],t[P]==null)t[P]=ge++;else if(t[P]<this.__a[e])return;return n(M.event?M.event(t):t)}}}function Fe(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O=t.type;if(t.constructor!==F)return null;128&n.__u&&(c=32&n.__u,u=n.__c.__z)&&(t.__u|=c,d=a=[],u.nodeType==8?s=Ie(u,a):a.push(u),s=a[0]||s),(u=M.__b)&&u(t);n:if(typeof O==`function`){f=o.length;try{if(_=t.props,v=(u=O.prototype)&&u.render,y=(u=O.contextType)&&r[u.__c],b=u?y?y.props.value:u.__:r,(p=n.__c)?(t.__c=p,2&p.__g&&(p.__g|=1)):(v?t.__c=p=new O(_,b):(t.__c=p=new we(_,b),p.constructor=O,p.render=He),y&&y.sub(p),p.state||(p.state={}),p.__n=r,p.__g|=8,p.__h=[],p.__k=[]),v&&(p.__s||(p.__s=p.state),O.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=I({},p.__s)),I(p.__s,O.getDerivedStateFromProps(_,p.__s)))),m=p.props,h=p.state,p.__v=t,n.__c){if(_!==m&&v&&!O.getDerivedStateFromProps&&p.componentWillReceiveProps&&p.componentWillReceiveProps(_,b),t.__v==n.__v&&!(8&p.__g)||!(4&p.__g)&&p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(_,p.__s,b)){t.__v!=n.__v&&(p.props=_,p.state=p.__s,p.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),ye.push.apply(p.__h,p.__k),p.__k=[],p.__h.length&&o.push(p),s=z(n);break n}p.componentWillUpdate&&p.componentWillUpdate(_,p.__s,b),v&&p.componentDidUpdate&&p.__h.push(function(){p.componentDidUpdate(m,h,g)})}else v&&!O.getDerivedStateFromProps&&p.componentWillMount&&p.componentWillMount(),v&&p.componentDidMount&&p.__h.push(p.componentDidMount);if(p.context=b,p.props=_,p.__P=e,p.__g&=-5,x=M.__r,S=0,v)p.state=p.__s,p.__g&=-9,x&&x(t),u=p.render(p.props,p.state,p.context),ye.push.apply(p.__h,p.__k),p.__k=[];else do p.__g&=-9,x&&x(t),u=p.render(p.props,p.state,p.context),p.state=p.__s;while(8&p.__g&&++S<25);p.state=p.__s,p.getChildContext&&(r=I({},r,p.getChildContext())),v&&n.__c&&p.getSnapshotBeforeUpdate&&(g=p.getSnapshotBeforeUpdate(m,h)),C=u&&u.type===R&&u.key==null?u.props.children:u,_.__P&&(u=s,i=(e=_.__P).namespaceURI,c=a=null,n.props&&n.props.__P!=e&&(n.__k.some(function(e){e&&Ve(e,e)}),n.__k=null),s=n.__k?z(n,0):null),s=Oe(e,xe(C)?C:[C],t,n,r,i,a,o,s,c,l),_.__P&&(t.__e=null,s=u),t.__u&=-161,d&&d.some(L),p.__h.length&&o.push(p),1&p.__g&&(p.__g&=-4)}catch(e){if(o.length=f,t.__v=null,c||a){if(e.then){if(w=0,t.__u|=128|c,a){for(~(E=a.indexOf(s||void 0))||(E=a.length);(D=a[E-1])&&D.nodeType==8;)E--;for(;E<a.length;E++)if(D=a[E]){if(a[E]=null,D.nodeType==8){if(D.data.startsWith(`$s`))w++||(T=D);else if(w&&D.data.startsWith(`/$s`)&&!--w)break}else if(!w)break}}if(!T){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;T=s}(u=Ie(T=t.__c.__z||(t.__c.__z=T)))?(t.__e=T,s=u):t.__e=s,s&&=s.nextSibling}else a&&a.some(L)}else t.__e=n.__e;t.__k||=n.__k||[],e.then||Le(t),M.__e(e,t,n)}}else s=t.__e=ze(n.__e,t,n,r,i,a,o,c,l,e);return(u=M.diffed)&&u(t),s}function Ie(e,t){if(e&&e.nodeType==8&&e.data.startsWith(`$s`))for(var n=1;e=e.nextSibling;){if(e.nodeType==8){if(e.data.startsWith(`$s`))n++;else if(e.data.startsWith(`/$s`)&&!--n)return e}t&&t.push(e)}}function Le(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(Le))}function Re(e,t,n){for(var r=0;r<n.length;)Be(n[r++],n[r++],n[r++]);M.__c&&M.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){M.__e(e,t.__v)}})}function ze(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y=n.props||ve,b=t.props,x=t.type;if(x==`svg`?i=`http://www.w3.org/2000/svg`:x==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a){for(u=0;u<a.length;u++)if((m=a[u])&&(x?m.localName==x:m.nodeType==3)){e=m,a[u]=null;break}}if(!e){if(_=l.ownerDocument||document,!x)return _.createTextNode(b);e=_.createElementNS(i,x,b.is&&b),s&&=(M.__m&&M.__m(t,a),!1),a=null}if(x){if(l=x==`template`&&e.content||e,a=x==`textarea`&&b.defaultValue!=null?null:a&&Se.call(l.childNodes),!s&&a)for(y={},u=0;u<e.attributes.length;u++)y[(m=e.attributes[u]).name]=m.value;for(u in y)m=y[u],u==`dangerouslySetInnerHTML`?f=m:u==`children`||u in b||u==`value`&&`defaultValue`in b||u==`checked`&&`defaultChecked`in b||Ne(e,u,null,m,i);for(u in v=1&n.__u,b)m=b[u],u==`children`?p=m:u==`dangerouslySetInnerHTML`?d=m:u==`value`?h=m:u==`checked`?g=m:s&&typeof m!=`function`||!(y[u]!==m||v&&m!=null)||Ne(e,u,m,y[u],i);d?(s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[]):(f&&(e.textContent=``),(x==`foreignObject`||i==`http://www.w3.org/1998/Math/MathML`&&be.test(x))&&(i=`http://www.w3.org/1999/xhtml`),Oe(l,xe(p)?p:[p],t,n,r,i,a,o,a?a[0]:n.__k&&z(n,0),s,c),a&&a.some(L)),s&&x!=`textarea`||(u=`value`,x==`progress`&&h==null?e.removeAttribute(u):h==null||h===e[u]&&(x!=`progress`||h)||Ne(e,u,h,y[u],i),u=`checked`,g!=null&&g!=e[u]&&Ne(e,u,g,y[u],i))}else y===b||s&&e.data==b||(e.data=b);return e}function Be(e,t,n,r){try{typeof e==`function`?t?t.__x=e(t)||1:(r&&=r.__c||r.__e)&&(t=r.__x)&&(r.__x=null,typeof t==`function`?t():e(null)):e.current=t}catch(e){M.__e(e,n)}}function Ve(e,t,n){var r,i,a,o;if(M.unmount&&M.unmount(e),!(r=e.ref)||r.current&&r.current!=e.__e||Be(r,null,t,e),r=e.__c){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){M.__e(e,t)}r.__P=r.__n=null}if(r=e.__k)for(o=0;o<r.length;o++)r[o]&&Ve(r[o],t,typeof e.type!=`function`||n&&!e.props.__P);!n&&(r=e.__c)&&(r=r.__z)&&(i=Ie(r,a=[]))&&(r==e.__e&&a.some(L),L(i),L(r)),(r=e.__e)&&(n||L(r),r.__e&&(r.__e=null)),e.__e=e.__c=e.__=null}function He(e,t,n){return this.constructor(e,n)}function Ue(e,t){var n,r,i,a;M.__&&M.__(e,t),t.nodeType==9&&(t=t.documentElement),r=(n=e&&32&e.__u)?null:t.__k,t.__k=Ce(R,{children:[e]}),i=[],a=[],Fe(t,t.__k,r||ve,ve,t.namespaceURI,r?null:t.firstChild?Se.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a),Re(i,t.__k,a),t.__k.props.children=null}M={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((o=(a=i.constructor)&&a.getDerivedStateFromError)&&i.setState(a.getDerivedStateFromError(e)),i.componentDidCatch&&(i.componentDidCatch(e,r||{}),o=1),o&&8&i.__g)return void(i.__g|=2)}catch(t){e=t}}throw pe=0,e}},de=0,we.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=I({},this.state)),typeof e==`function`&&(e=e(I({},n),this.props)),e&&(I(n,e),this.__v&&(t&&this.__k.push(t),Ee(this)))},we.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),Ee(this))},we.prototype.render=R,N=[],pe=0,me=function(e,t){return e.__v.__b-t.__v.__b},P=Symbol(),he=/(PointerCapture)$|Capture$/i,ge=0,_e={};var B,V,We,Ge,Ke=Object.is,qe=0,Je=[],Ye=[],H=M,Xe=H.__b,Ze=H.__r,Qe=H.diffed,$e=H.__c,et=H.unmount,tt=H.__;function nt(e,t){H.__h&&H.__h(V,e,qe||t),qe=0;var n=V.__H||(V.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function rt(e){return qe=1,it(pt,e)}function it(e,t,n){var r=nt(B++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):pt(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);Ke(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=V,!V.__f)){V.__f=!0;var i=V.shouldComponentUpdate;V.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,Ke(e.__[0],e.__N[0])||(o=!0))}),i){var s=i.call(this,e,t,n);return a?s||o:s}return!a||o}}return r.__}function at(e,t){var n=nt(B++,3);!H.__s&&ft(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,V.__H.__h.push(n))}function U(e,t){var n=nt(B++,4);!H.__s&&ft(n.__H,t)&&(n.__P=!1,n.__=e,n.u=t,V.__h.push(n))}function W(e){return qe=5,ot(function(){return{current:e}},[])}function ot(e,t){var n=nt(B++,7);return ft(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function st(){var e;do{for(;e=Ye.shift();)try{G(e)}catch(t){H.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=Je.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(G),t.__h.some(dt),t.__h=[]}catch(n){t.__h=[],H.__e(n,e.__v)}}}while(Ye.length)}H.__b=function(e){V=null,Xe&&Xe(e)},H.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),tt&&tt(e,t)},H.__r=function(e){Ze&&Ze(e),B=0;var t=(V=e.__c).__H;t&&(We==V?V.__h=[]:(t.__h.some(G),t.__h.some(dt),B=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),We=V},H.diffed=function(e){Qe&&Qe(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&ut(Je.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),We=V=null},H.__c=function(e,t){t.some(function(e){try{e.__h.some(G),e.__h=e.__h.filter(function(e){return!e.__||dt(e)})}catch(t){e.__h=[function(){throw t}]}}),$e&&$e(e,t)},H.unmount=function(e){et&&et(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n&&=n.__c}r.__P=n,ut(Ye.push(r))}else G(r)}catch(e){t=e}}),r.__H=void 0,t&&H.__e(t,r.__v))};var ct=typeof requestAnimationFrame==`function`;function lt(e){var t,n=function(){clearTimeout(r),ct&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ct&&(t=requestAnimationFrame(n))}function ut(e){e!=1&&Ge==H.requestAnimationFrame||((Ge=H.requestAnimationFrame)||lt)(st)}function G(e){var t=V,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),V=t}function dt(e){var t=V;e.__c=e.__(),V=t}function ft(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!Ke(t,e[n])})}function pt(e,t){return typeof t==`function`?t(e):t}var mt=Symbol.for(`pv`),ht=0;Array.isArray;function K(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:mt,__v:--ht,__i:-1,__u:0};return(i||a)&&(l.__source=i,l.__self=a),M.vnode&&M.vnode(l),l}function q({name:e,size:t,children:n}){return K(`svg`,{"data-icon":e,"aria-hidden":`true`,focusable:`false`,width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,children:n})}function gt({size:e=26}){return K(q,{name:`chat`,size:e,children:[K(`path`,{d:`M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 4v-4h0A1.5 1.5 0 0 1 4 14.5z`}),K(`path`,{d:`M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01`,"stroke-width":`2.5`})]})}function _t({size:e=26}){return K(q,{name:`message`,size:e,children:K(`path`,{d:`M21 11.5a8.5 8.5 0 0 1-12.4 7.5L3 20.5l1.6-5.1A8.5 8.5 0 1 1 21 11.5z`})})}function vt({size:e=26}){return K(q,{name:`sparkle`,size:e,children:[K(`path`,{d:`M11 3l1.9 5.1L18 10l-5.1 1.9L11 17l-1.9-5.1L4 10l5.1-1.9z`}),K(`path`,{d:`M19 15l.7 1.8 1.8.7-1.8.7L19 20l-.7-1.8-1.8-.7 1.8-.7z`})]})}function yt({size:e=26}){return K(q,{name:`chevron-down`,size:e,children:K(`path`,{d:`M6 9l6 6 6-6`})})}function bt({size:e=18}){return K(q,{name:`close`,size:e,children:K(`path`,{d:`M6 6l12 12M18 6L6 18`})})}var xt=`M7 11v9M7 11l3.5-7.2A1.8 1.8 0 0 1 14 4.6V9h4.6a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.4 20H7M7 11H4.5A1.5 1.5 0 0 0 3 12.5v6A1.5 1.5 0 0 0 4.5 20H7`;function St({size:e=16}){return K(q,{name:`thumb-up`,size:e,children:K(`path`,{d:xt})})}function Ct({size:e=16}){return K(q,{name:`thumb-down`,size:e,children:K(`path`,{d:xt,transform:`matrix(1 0 0 -1 0 24)`})})}var wt={chat:gt,message:_t,sparkle:vt},Tt={"chevron-down":yt,close:bt};function Et({isOpen:e,onClick:n,iconUrl:r,icon:i=`chat`,openIconUrl:a,openIcon:o=`chevron-down`,buttonRef:s,text:c=t}){let[l,u]=rt(`loading`),[d,f]=rt(`loading`),p=r!==void 0&&l!==`failed`,m=a!==void 0&&d!==`failed`,h=p&&!e&&l===`loaded`,g=m&&e&&d===`loaded`,_=wt[i]??gt,v=Tt[o]??yt;return K(`button`,{type:`button`,class:`whoo-widget-launcher`,onClick:n,"aria-label":e?c.closeChat:c.openChat,ref:s,children:[e?g?null:K(v,{}):h?null:K(_,{}),p?K(`img`,{class:`whoo-widget-launcher-icon-image`,src:r,alt:``,referrerpolicy:`no-referrer`,hidden:!h,onLoad:()=>u(`loaded`),onError:()=>u(`failed`)}):null,m?K(`img`,{class:`whoo-widget-launcher-icon-image`,src:a,alt:``,referrerpolicy:`no-referrer`,hidden:!g,onLoad:()=>f(`loaded`),onError:()=>f(`failed`)}):null]})}var Dt={en:t,fr:{openChat:`Ouvrir le chat`,closeChat:`Fermer le chat`,chatWith:`Discuter avec {name}`,newConversation:`Nouvelle conversation`,conversation:`Conversation`,you:`Vous`,message:`Message`,messagePlaceholder:`Écrivez un message…`,send:`Envoyer`,messageSent:`Message envoyé. {name} prépare une réponse.`,lookingItUp:`Je recherche l’information pour vous…`,goodResponse:`Réponse utile`,badResponse:`Réponse peu utile`,additionalFeedback:`Commentaire supplémentaire`,feedbackPlaceholder:`Qu’est-ce qui n’allait pas ? (facultatif)`,feedbackCategory:`Catégorie du commentaire`,selectReason:`Choisissez un motif (facultatif)`,categoryFactual:`Erreur factuelle`,categoryIncomplete:`Réponse incomplète`,categoryTone:`Ton inapproprié`,categoryOther:`Autre`,submit:`Envoyer le commentaire`,cancel:`Annuler`,feedbackThanks:`Merci pour votre commentaire`,feedbackFailed:`Impossible d’envoyer votre commentaire`,conversationCleared:`Nouvelle conversation démarrée. Les messages précédents ont été effacés.`,genericError:`Une erreur s’est produite. Veuillez réessayer.`,sessionExpired:`Cette session de chat a expiré. Rechargez la page pour continuer.`,opensInNewTab:`(s’ouvre dans un nouvel onglet)`,agreeToNotice:`J’accepte`},es:{openChat:`Abrir chat`,closeChat:`Cerrar chat`,chatWith:`Chat con {name}`,newConversation:`Nueva conversación`,conversation:`Conversación`,you:`Usted`,message:`Mensaje`,messagePlaceholder:`Escriba un mensaje…`,send:`Enviar`,messageSent:`Mensaje enviado. {name} está preparando una respuesta.`,lookingItUp:`Estoy buscando esa información…`,goodResponse:`Buena respuesta`,badResponse:`Mala respuesta`,additionalFeedback:`Comentarios adicionales`,feedbackPlaceholder:`¿Qué estuvo mal? (opcional)`,feedbackCategory:`Tipo de problema`,selectReason:`Seleccione un motivo (opcional)`,categoryFactual:`Información incorrecta`,categoryIncomplete:`Respuesta incompleta`,categoryTone:`Tono inadecuado`,categoryOther:`Otro`,submit:`Enviar comentarios`,cancel:`Cancelar`,feedbackThanks:`Gracias por sus comentarios`,feedbackFailed:`No se pudieron enviar sus comentarios`,conversationCleared:`Se inició una nueva conversación. Se borraron los mensajes anteriores.`,genericError:`Algo salió mal. Inténtelo de nuevo.`,sessionExpired:`Esta sesión de chat expiró. Vuelva a cargar la página para continuar.`,opensInNewTab:`(se abre en una pestaña nueva)`,agreeToNotice:`Acepto`},pt:{openChat:`Abrir chat`,closeChat:`Fechar chat`,chatWith:`Conversa com {name}`,newConversation:`Nova conversa`,conversation:`Conversa`,you:`Você`,message:`Mensagem`,messagePlaceholder:`Digite uma mensagem…`,send:`Enviar`,messageSent:`Mensagem enviada. {name} está preparando uma resposta.`,lookingItUp:`Estou buscando essa informação…`,goodResponse:`Boa resposta`,badResponse:`Resposta ruim`,additionalFeedback:`Comentários adicionais`,feedbackPlaceholder:`O que estava errado? (opcional)`,feedbackCategory:`Categoria do feedback`,selectReason:`Selecione um motivo (opcional)`,categoryFactual:`Informação incorreta`,categoryIncomplete:`Resposta incompleta`,categoryTone:`Tom inadequado`,categoryOther:`Outro`,submit:`Enviar feedback`,cancel:`Cancelar`,feedbackThanks:`Agradecemos seu feedback`,feedbackFailed:`Não foi possível enviar o feedback`,conversationCleared:`Nova conversa iniciada. As mensagens anteriores foram apagadas.`,genericError:`Algo deu errado. Tente novamente.`,sessionExpired:`Esta sessão de chat expirou. Recarregue a página para continuar.`,opensInNewTab:`(abre em uma nova aba)`,agreeToNotice:`Concordo`},de:{openChat:`Chat öffnen`,closeChat:`Chat schließen`,chatWith:`Chat mit {name}`,newConversation:`Neue Unterhaltung`,conversation:`Unterhaltung`,you:`Sie`,message:`Nachricht`,messagePlaceholder:`Nachricht eingeben…`,send:`Senden`,messageSent:`Nachricht gesendet. {name} bereitet eine Antwort vor.`,lookingItUp:`Ich suche die Informationen für Sie heraus…`,goodResponse:`Gute Antwort`,badResponse:`Schlechte Antwort`,additionalFeedback:`Zusätzliches Feedback`,feedbackPlaceholder:`Was war falsch? (optional)`,feedbackCategory:`Feedback-Kategorie`,selectReason:`Grund auswählen (optional)`,categoryFactual:`Faktenfehler`,categoryIncomplete:`Unvollständig`,categoryTone:`Unpassender Ton`,categoryOther:`Sonstiges`,submit:`Absenden`,cancel:`Abbrechen`,feedbackThanks:`Danke für Ihr Feedback`,feedbackFailed:`Feedback konnte nicht gesendet werden`,conversationCleared:`Neue Unterhaltung gestartet. Die bisherigen Nachrichten wurden gelöscht.`,genericError:`Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut.`,sessionExpired:`Diese Chat-Sitzung ist abgelaufen. Laden Sie die Seite neu, um fortzufahren.`,opensInNewTab:`(öffnet sich in neuem Tab)`,agreeToNotice:`Ich stimme zu`},it:{openChat:`Apri la chat`,closeChat:`Chiudi la chat`,chatWith:`Chat con {name}`,newConversation:`Nuova conversazione`,conversation:`Conversazione`,you:`Tu`,message:`Messaggio`,messagePlaceholder:`Scrivi un messaggio…`,send:`Invia`,messageSent:`Messaggio inviato. {name} sta preparando una risposta.`,lookingItUp:`Sto cercando le informazioni richieste…`,goodResponse:`Risposta utile`,badResponse:`Risposta non utile`,additionalFeedback:`Commenti aggiuntivi`,feedbackPlaceholder:`Che cosa non andava? (facoltativo)`,feedbackCategory:`Categoria del feedback`,selectReason:`Seleziona un motivo (facoltativo)`,categoryFactual:`Informazione errata`,categoryIncomplete:`Risposta incompleta`,categoryTone:`Tono non adeguato`,categoryOther:`Altro`,submit:`Invia feedback`,cancel:`Annulla`,feedbackThanks:`Grazie per il feedback`,feedbackFailed:`Impossibile inviare il feedback`,conversationCleared:`Nuova conversazione avviata. I messaggi precedenti sono stati cancellati.`,genericError:`Si è verificato un errore. Riprovi.`,sessionExpired:`Questa sessione di chat è scaduta. Ricarichi la pagina per continuare.`,opensInNewTab:`(si apre in una nuova scheda)`,agreeToNotice:`Accetto`},ja:{openChat:`チャットを開く`,closeChat:`チャットを閉じる`,chatWith:`{name}とチャット`,newConversation:`新しい会話`,conversation:`会話`,you:`あなた`,message:`メッセージ`,messagePlaceholder:`メッセージを入力…`,send:`送信`,messageSent:`メッセージを送信しました。{name}が回答を準備しています。`,lookingItUp:`確認しています…`,goodResponse:`良い回答`,badResponse:`良くない回答`,additionalFeedback:`追加のフィードバック`,feedbackPlaceholder:`何が問題でしたか?(任意)`,feedbackCategory:`フィードバックの種類`,selectReason:`理由を選択(任意)`,categoryFactual:`事実の誤り`,categoryIncomplete:`回答が不十分`,categoryTone:`不適切な口調`,categoryOther:`その他`,submit:`フィードバックを送信`,cancel:`キャンセル`,feedbackThanks:`フィードバックありがとうございます`,feedbackFailed:`フィードバックを送信できませんでした`,conversationCleared:`新しい会話を開始しました。以前のメッセージは消去されました。`,genericError:`エラーが発生しました。もう一度お試しください。`,sessionExpired:`このチャットセッションの有効期限が切れました。続けるにはページを再読み込みしてください。`,opensInNewTab:`(新しいタブで開きます)`,agreeToNotice:`同意する`},zh:{openChat:`打开聊天`,closeChat:`关闭聊天`,chatWith:`与{name}聊天`,newConversation:`新对话`,conversation:`对话`,you:`您`,message:`消息`,messagePlaceholder:`输入消息…`,send:`发送`,messageSent:`消息已发送。{name}正在准备回复。`,lookingItUp:`正在为您查找……`,goodResponse:`回答很好`,badResponse:`回答不好`,additionalFeedback:`补充反馈`,feedbackPlaceholder:`哪里有问题?(可选)`,feedbackCategory:`反馈类别`,selectReason:`选择原因(可选)`,categoryFactual:`事实错误`,categoryIncomplete:`回答不完整`,categoryTone:`语气不当`,categoryOther:`其他`,submit:`提交`,cancel:`取消`,feedbackThanks:`感谢您的反馈`,feedbackFailed:`反馈提交失败`,conversationCleared:`已开始新对话。之前的消息已清除。`,genericError:`出了点问题,请重试。`,sessionExpired:`此聊天会话已过期。请刷新页面后继续。`,opensInNewTab:`(将在新标签页中打开)`,agreeToNotice:`我同意`},ru:{openChat:`Открыть чат`,closeChat:`Закрыть чат`,chatWith:`Чат с ассистентом {name}`,newConversation:`Новый диалог`,conversation:`Диалог`,you:`Вы`,message:`Сообщение`,messagePlaceholder:`Введите сообщение…`,send:`Отправить`,messageSent:`Сообщение отправлено. {name} готовит ответ.`,lookingItUp:`Ищу информацию…`,goodResponse:`Хороший ответ`,badResponse:`Плохой ответ`,additionalFeedback:`Дополнительный комментарий`,feedbackPlaceholder:`Что было не так? (необязательно)`,feedbackCategory:`Категория отзыва`,selectReason:`Выберите причину (необязательно)`,categoryFactual:`Фактическая ошибка`,categoryIncomplete:`Неполный ответ`,categoryTone:`Неподходящий тон`,categoryOther:`Другое`,submit:`Отправить отзыв`,cancel:`Отмена`,feedbackThanks:`Спасибо за отзыв`,feedbackFailed:`Не удалось отправить отзыв`,conversationCleared:`Начат новый диалог. Предыдущие сообщения удалены.`,genericError:`Что-то пошло не так. Попробуйте ещё раз.`,sessionExpired:`Срок действия сеанса чата истёк. Перезагрузите страницу, чтобы продолжить.`,opensInNewTab:`(откроется в новой вкладке)`,agreeToNotice:`Принимаю`},hi:{openChat:`चैट खोलें`,closeChat:`चैट बंद करें`,chatWith:`{name} से चैट करें`,newConversation:`नई बातचीत`,conversation:`बातचीत`,you:`आप`,message:`संदेश`,messagePlaceholder:`संदेश लिखें…`,send:`भेजें`,messageSent:`संदेश भेज दिया गया। {name} द्वारा जवाब तैयार किया जा रहा है।`,lookingItUp:`आपके लिए जानकारी खोजी जा रही है…`,goodResponse:`अच्छा जवाब`,badResponse:`ख़राब जवाब`,additionalFeedback:`अतिरिक्त फ़ीडबैक`,feedbackPlaceholder:`क्या ग़लत था? (वैकल्पिक)`,feedbackCategory:`फ़ीडबैक की श्रेणी`,selectReason:`कारण चुनें (वैकल्पिक)`,categoryFactual:`तथ्यात्मक त्रुटि`,categoryIncomplete:`अधूरा जवाब`,categoryTone:`अनुचित लहजा`,categoryOther:`अन्य`,submit:`सबमिट करें`,cancel:`रद्द करें`,feedbackThanks:`आपके फ़ीडबैक के लिए धन्यवाद`,feedbackFailed:`फ़ीडबैक नहीं भेजा जा सका`,conversationCleared:`नई बातचीत शुरू हुई। पिछले संदेश मिटा दिए गए।`,genericError:`कुछ ग़लत हो गया। कृपया फिर से कोशिश करें।`,sessionExpired:`यह चैट सत्र समाप्त हो गया है। जारी रखने के लिए पेज को फिर से लोड करें।`,opensInNewTab:`(नए टैब में खुलता है)`,agreeToNotice:`मैं सहमत हूँ`},ar:{openChat:`فتح الدردشة`,closeChat:`إغلاق الدردشة`,chatWith:`الدردشة مع {name}`,newConversation:`محادثة جديدة`,conversation:`المحادثة`,you:`أنت`,message:`الرسالة`,messagePlaceholder:`كتابة رسالة…`,send:`إرسال`,messageSent:`تم إرسال الرسالة. جارٍ إعداد الرد من قِبل {name}.`,lookingItUp:`جارٍ البحث عن المعلومات…`,goodResponse:`إجابة جيدة`,badResponse:`إجابة سيئة`,additionalFeedback:`ملاحظات إضافية`,feedbackPlaceholder:`ما المشكلة؟ (اختياري)`,feedbackCategory:`فئة الملاحظات`,selectReason:`اختر سببًا (اختياري)`,categoryFactual:`معلومات غير صحيحة`,categoryIncomplete:`إجابة غير مكتملة`,categoryTone:`أسلوب غير مناسب`,categoryOther:`أخرى`,submit:`إرسال الملاحظات`,cancel:`إلغاء`,feedbackThanks:`شكرًا على ملاحظاتك`,feedbackFailed:`تعذّر إرسال الملاحظات`,conversationCleared:`بدأت محادثة جديدة. تم مسح الرسائل السابقة.`,genericError:`حدث خطأ ما. يُرجى المحاولة مرة أخرى.`,sessionExpired:`انتهت صلاحية جلسة الدردشة هذه. يُرجى إعادة تحميل الصفحة للمتابعة.`,opensInNewTab:`(يُفتح في علامة تبويب جديدة)`,agreeToNotice:`أوافق`}},Ot=Object.freeze(Object.keys(Dt)),kt={pt:`pt-BR`,es:`es-419`,zh:`zh-Hans`},At=new Set([`ar`]),jt=/^[a-z]{2,8}([-_][a-z0-9]{1,8})*$/i,Mt=/^zh[-_](hant|tw|hk|mo)(?=$|[-_])/i;function Nt(e){return Dt[e]}function Pt(e){let t=e.trim();if(!jt.test(t)||Mt.test(t))return null;let n=t.split(/[-_]/)[0].toLowerCase();return Object.hasOwn(Dt,n)?n:null}function Ft(e,t){let n=null;return e!=null&&e!==``&&(n=typeof e==`string`?Pt(e):null,n||console.warn(`whoo-aiden-widget: ignoring \`language\` ${It(e)} -- expected one of ${Ot.join(`, `)} (or a regional tag like pt-BR). Using the page's language instead.`)),n??=typeof t==`string`?Pt(t):null,n??=`en`,{language:n,tag:kt[n]??n,dir:At.has(n)?`rtl`:`ltr`}}function It(e){return typeof e==`string`?JSON.stringify(e):`(a ${typeof e})`}function Lt(e){if(typeof e!=`string`)return null;let t=e.trim().replace(/_/g,`-`);return jt.test(t)?t:null}function Rt(e,t,n){if(e!=null&&e!==``){let t=Lt(e);if(t)return t;console.warn(`whoo-aiden-widget: ignoring \`contentLanguage\` ${It(e)} -- expected a language tag such as 'nl' or 'pt-BR'. Using the page's language instead.`)}return Lt(t)??Lt(n)??``}function zt(e){let t=e.indexOf(`{name}`);return t===-1?{before:e,after:``,hasName:!1}:{before:e.slice(0,t),after:e.slice(t+6),hasName:!0}}function Bt(e,t){return e.split(`{name}`).join(t.name)}var Vt=`(max-width: 400px), (max-height: 420px)`,Ht=`data-fit-visible`,Ut=40;function Wt(e){let t=typeof window<`u`?window.visualViewport:null;if(!t)return()=>{};let n=()=>{e.removeAttribute(Ht),e.style.removeProperty(`--whoo-widget-visible-top`),e.style.removeProperty(`--whoo-widget-visible-height`)},r=()=>{let r=document.documentElement.clientHeight,i=Math.abs(t.scale-1)>.01,a=r-t.height;if(i||r===0||a<Ut){n();return}e.setAttribute(Ht,``),e.style.setProperty(`--whoo-widget-visible-top`,`${Math.max(0,t.offsetTop)}px`),e.style.setProperty(`--whoo-widget-visible-height`,`${t.height}px`);let o=e.getRootNode().activeElement;o&&e.contains(o)&&typeof o.scrollIntoView==`function`&&o.scrollIntoView({block:`nearest`})};return r(),t.addEventListener(`resize`,r),t.addEventListener(`scroll`,r),()=>{t.removeEventListener(`resize`,r),t.removeEventListener(`scroll`,r),n()}}function Gt(e,t){return typeof e.addEventListener==`function`?(e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)):typeof e.addListener==`function`?(e.addListener(t),()=>e.removeListener(t)):()=>{}}var Kt=0,qt=``;function Jt(){Kt++===0&&(qt=document.documentElement.style.overflow,document.documentElement.style.overflow=`hidden`)}function Yt(){--Kt===0&&(document.documentElement.style.overflow=qt)}function Xt(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return()=>{};let e=window.matchMedia(Vt),t=!1,n=()=>{e.matches&&!t?(t=!0,Jt()):!e.matches&&t&&(t=!1,Yt())};n();let r=Gt(e,n);return()=>{r(),t&&(t=!1,Yt())}}function Zt(e){if(typeof window>`u`||typeof window.matchMedia!=`function`||typeof e.showModal!=`function`)return()=>{};let t=window.matchMedia(Vt),n=!1,r=()=>{if(t.matches===n||!e.isConnected)return;n=t.matches;let r=e.getRootNode().activeElement;e.close(),n?e.showModal():e.show(),r&&e.contains(r)&&r.focus({preventScroll:!0})};return r(),Gt(t,r)}function Qt(e){return e.isComposing||e.keyCode===229}function $t({value:e,onChange:n,onSend:r,disabled:i,inputRef:a,text:o=t,contentLanguage:s}){return K(`div`,{class:`whoo-widget-composer`,children:[K(`label`,{class:`whoo-widget-sr-only`,for:`whoo-widget-composer-input`,children:o.message}),K(`input`,{id:`whoo-widget-composer-input`,class:`whoo-widget-composer-input`,lang:s,autoFocus:!0,placeholder:o.messagePlaceholder,value:e,readOnly:i,"aria-disabled":i,ref:a,onInput:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!Qt(e)&&r()}}),K(`button`,{type:`button`,class:`whoo-widget-composer-send`,"aria-disabled":i,onClick:()=>{i||r()},children:o.send})]})}function en({message:e}){return K(`div`,{class:`whoo-widget-error-banner`,role:`alert`,children:e})}var tn=/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y,nn=/\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y,rn=/(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y,an=/\*([^*\s](?:[^*]*[^*\s])?)\*/y,on=/[ \t]*[*+-][ \t]+/y,sn=/https?:\/\/\S+/y,cn=/[.,;:!?)\]}>]+$/;function ln(e){let t=[],n=0,r=0,i=n=>{n>r&&t.push({type:`text`,value:e.slice(r,n),start:r,end:n})};for(;n<e.length;){if((n===0||e[n-1]===`
|
|
2
|
+
`)&&(on.lastIndex=n,on.exec(e))){i(n),t.push({type:`text`,value:`• `,start:n,end:on.lastIndex}),n=on.lastIndex,r=n;continue}if(e[n]===`!`&&n+1<e.length&&e[n+1]===`[`){let t=/!\[([^\]]*)\]\(([^)]*)\)/y;t.lastIndex=n;let r=t.exec(e);if(r){n+=r[0].length;continue}}if(e[n-1]!==`!`){tn.lastIndex=n;let a=tn.exec(e);if(a){i(n),t.push({type:`link`,text:a[1],url:a[2],start:n,end:tn.lastIndex}),n=tn.lastIndex,r=n;continue}}nn.lastIndex=n;let a=nn.exec(e);if(a){i(n),t.push({type:`bold`,value:a[1],start:n,end:nn.lastIndex}),n=nn.lastIndex,r=n;continue}rn.lastIndex=n;let o=rn.exec(e);if(o){i(n),t.push({type:`italic`,value:o[1],start:n,end:rn.lastIndex}),n=rn.lastIndex,r=n;continue}an.lastIndex=n;let s=an.exec(e);if(s){i(n),t.push({type:`italic`,value:s[1],start:n,end:an.lastIndex}),n=an.lastIndex,r=n;continue}sn.lastIndex=n;let c=sn.exec(e);if(c){let e=c[0].match(cn),a=e?c[0].slice(0,c[0].length-e[0].length):c[0];if(a.length>0){i(n),t.push({type:`link`,text:a,url:a,start:n,end:n+a.length}),n+=a.length,r=n;continue}}n+=1}return i(e.length),t}var un=/^[ \t]*[*+-][ \t]+(.*)$/,dn=/[\p{Script=Arabic}\p{Script=Hebrew}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Nko}\p{Script=Adlam}\p{Script=Samaritan}\p{Script=Mandaic}\p{Script=Hanifi_Rohingya}\p{Script=Mende_Kikakui}]/u;function fn(e){let t=e.match(/\p{L}/u)?.[0];if(t)return dn.test(t)?`rtl`:`ltr`}function pn(e){let t=[],n=[],r=[],i=()=>{n.length>0&&t.push({type:`text`,text:n.join(`
|
|
3
3
|
`)}),n=[]},a=()=>{r.length>0&&t.push({type:`list`,items:r}),r=[]};for(let t of e.split(`
|
|
4
|
-
`)){let e=t.match(
|
|
5
|
-
`),r=fn(n);return r?r.map((e,n)=>e.type===`list`?W(`ul`,{class:`whoo-widget-list`,dir:dn(e.items.find(e=>dn(e))??``),children:e.items.map((e,n)=>W(`li`,{dir:dn(e),children:K(e,t)},n))},n):W(`span`,{children:K(e.text,t)},n)):K(n,t)}function mn(e){return[{value:``,label:e.selectReason},{value:`factual`,label:e.categoryFactual},{value:`incomplete`,label:e.categoryIncomplete},{value:`tone`,label:e.categoryTone},{value:`other`,label:e.categoryOther}]}function hn({state:e,containerRef:n,onThumbsUp:r,onThumbsDown:i,onDraftChange:a,onSubmitDetailed:o,onCancel:s,text:c=t,contentLanguage:l}){let u=e.correction??``,d=e.category??``,f=H(e.status),p=H(null),m=H(null);if(V(()=>{let t=f.current;if(f.current=e.status,t===e.status)return;if(e.status===`expanded`){p.current?.focus();return}if(t===`expanded`&&e.status===`idle`){m.current?.focus();return}let r=n?.current;if(!r)return;let i=r.getRootNode(),a=r.ownerDocument,o=i.activeElement;(o===null?a.activeElement===null||a.activeElement===a.body:o===a.body)&&r.focus()},[e.status,n]),e.status===`expanded`)return W(`div`,{class:`whoo-widget-feedback-form`,children:[W(`label`,{children:[W(`span`,{class:`whoo-widget-sr-only`,children:c.additionalFeedback}),W(`textarea`,{ref:p,class:`whoo-widget-feedback-textarea`,lang:l,value:u,onInput:e=>a(e.target.value,d),placeholder:c.feedbackPlaceholder})]}),W(`select`,{class:`whoo-widget-feedback-select`,"aria-label":c.feedbackCategory,value:d,onChange:e=>a(u,e.target.value),children:mn(c).map(e=>W(`option`,{value:e.value,children:e.label},e.value))}),W(`div`,{class:`whoo-widget-feedback-form-buttons`,children:[W(`button`,{type:`button`,class:`whoo-widget-feedback-submit`,onClick:()=>o(u,d),children:c.submit}),W(`button`,{type:`button`,class:`whoo-widget-feedback-cancel`,onClick:s,children:c.cancel})]})]});let h=e.status===`submitting`,g=e.status===`submitted`;return W(`div`,{class:`whoo-widget-feedback`,children:[g?null:W(`div`,{class:`whoo-widget-feedback-buttons`,children:[W(`button`,{type:`button`,"aria-label":c.goodResponse,"aria-disabled":h,onClick:()=>{h||r()},children:W(xt,{})}),W(`button`,{ref:m,type:`button`,"aria-label":c.badResponse,"aria-disabled":h,onClick:()=>{h||i()},children:W(St,{})})]}),W(`div`,{role:`status`,class:g?`whoo-widget-feedback-submitted`:e.status===`error`?`whoo-widget-feedback-error`:void 0,children:g?c.feedbackThanks:e.status===`error`?c.feedbackFailed:null})]})}function gn({isSlowResponse:e,text:t}){return W(`div`,{class:`whoo-widget-pending`,children:[W(`span`,{class:`whoo-widget-typing`,"aria-hidden":`true`,children:[W(`span`,{}),W(`span`,{}),W(`span`,{})]}),e?W(`span`,{class:`whoo-widget-pending-text`,children:t.lookingItUp}):null]})}function _n({url:e,alt:t,lang:n}){let[r,i]=rt(!1);return r?null:W(`img`,{class:`whoo-widget-empty-state-image`,src:e,alt:t,lang:n,referrerpolicy:`no-referrer`,onError:()=>i(!0)})}var vn=`whoo-widget-notice`;function yn({notice:e,placement:t=`top`,text:n,contentLanguage:r,languageTag:i}){return t===`footer`?W(`div`,{id:vn,class:`whoo-widget-notice-footer`,role:`note`,tabIndex:0,children:W(`div`,{class:`whoo-widget-message-text`,dir:`auto`,lang:r,children:pn(e,{linkCue:n.opensInNewTab,linkCueLang:i})})}):W(`div`,{id:vn,class:`whoo-widget-notice`,role:`note`,children:W(`div`,{class:`whoo-widget-message-text`,dir:`auto`,lang:r,children:pn(e,{linkCue:n.opensInNewTab,linkCueLang:i})})})}function bn({message:e,speaker:t,feedbackState:n,showFeedback:r,pending:i,isSlowResponse:a,onThumbsUp:o,onThumbsDown:s,onDraftChange:c,onSubmitDetailed:l,onCancelFeedback:u,text:d,contentLanguage:f,languageTag:p}){let m=H(null),h=e.id;return W(`div`,{ref:m,tabIndex:-1,class:`whoo-widget-message whoo-widget-message--${e.role}`,children:[W(`span`,{class:`whoo-widget-sr-only`,children:[e.role===`assistant`?W(`span`,{lang:f,children:t}):t,`:`,` `]}),i?W(gn,{isSlowResponse:a,text:d}):W(`div`,{class:`whoo-widget-message-text`,dir:`auto`,lang:f,children:pn(e.content,{linkCue:d.opensInNewTab,linkCueLang:p})}),r&&e.role===`assistant`&&h?W(hn,{state:n,containerRef:m,onThumbsUp:()=>o(h),onThumbsDown:()=>s(h),onDraftChange:(e,t)=>c(h,e,t),onSubmitDetailed:(e,t)=>l(h,e,t),onCancel:()=>u(h),text:d,contentLanguage:f}):null]})}function xn({messages:e,messageFeedback:n,announcement:r,emptyStateImage:i,centerEmptyState:a=!1,centeredGreeting:o,notice:s,agentName:c=u,showFeedback:l=!1,isStreaming:d=!1,isSlowResponse:f=!1,onThumbsUp:p,onThumbsDown:m,onDraftChange:h=()=>{},onSubmitDetailed:g,onCancelFeedback:_,text:v=t,contentLanguage:y,languageTag:b,announcementIsContent:x=!1}){let S=H(null),C=!!s&&!e.some(e=>e.role===`user`);at(()=>{let e=S.current;e&&(e.scrollTop=C?0:e.scrollHeight)},[e,f,C]);let w=i?W(_n,{...i,lang:y}):null,T=a&&e.length===0&&(i||o);return W(I,{children:[W(`section`,{class:`whoo-widget-message-list${T?` whoo-widget-message-list--centered`:``}`,ref:S,"aria-label":v.conversation,tabIndex:0,children:[a?null:w,s?W(yn,{notice:s,text:v,contentLanguage:y,languageTag:b}):null,T?W(`div`,{class:`whoo-widget-empty-state`,children:[w,o?W(`div`,{class:`whoo-widget-empty-state-greeting whoo-widget-message-text`,dir:`auto`,lang:y,children:pn(o,{linkCue:v.opensInNewTab,linkCueLang:b})}):null]}):null,e.map((t,r)=>W(bn,{message:t,speaker:t.role===`user`?v.you:c,showFeedback:l,feedbackState:t.id?n[t.id]??{status:`idle`}:{status:`idle`},pending:d&&r===e.length-1&&t.role===`assistant`&&t.content===``,isSlowResponse:f,onThumbsUp:p,onThumbsDown:m,onDraftChange:h,onSubmitDetailed:g,onCancelFeedback:_,text:v,contentLanguage:y,languageTag:b},t.id??r))]}),W(`div`,{class:`whoo-widget-sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,lang:x?y:b,children:r??``})]})}var Sn=`button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`;function Cn(e){return Array.from(e.querySelectorAll(Sn)).filter(e=>{let t=getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`})}function wn({state:e,controller:t,greeting:n}){let r=H(null),i=H(null),a=H(null),o=H(!1);V(()=>{(a.current??i.current)?.focus()},[]),V(()=>{e.noticeAgreed&&o.current&&(o.current=!1,i.current?.focus())},[e.noticeAgreed]),V(()=>{let e=r.current,n=e?Ut(e):()=>{},i=e?Xt(e):()=>{},a=()=>{e&&!e.open&&t.close()};e?.addEventListener(`close`,a);let o=Yt();return()=>{n(),i(),e?.removeEventListener(`close`,a),o()}},[]);let s=e=>{if(e.key===`Escape`&&!Zt(e)){e.preventDefault(),t.close();return}if(e.key!==`Tab`)return;let n=r.current;if(!n)return;let i=Cn(n);if(i.length===0)return;let a=n.getRootNode().activeElement;e.preventDefault();let o=i.length-1,s,c=a?i.indexOf(a):-1;if(c!==-1)s=(c+(e.shiftKey?-1:1)+i.length)%i.length;else if(a&&a!==n&&n.contains(a)){let t=i.findIndex(e=>a.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING);s=e.shiftKey?t<=0?o:t-1:t===-1?0:t}else s=e.shiftKey?o:0;i[s].focus()},c=()=>{let n=e.draft.trim();n&&!e.isStreaming&&(t.setDraft(``),t.sendMessage(n))},l=t.resolvedAgentName,u=d(t.config.title),{before:f,after:p,hasName:m}=Rt(t.text.chatWith),h=t.greetingStyle===`centered`,g=e.messages.length===0&&n&&!h?[{role:`assistant`,content:n,id:null}]:e.messages,_=e.messages.length===0&&h?n:void 0,v=t.notice!==``&&t.noticePlacement===`footer`,y=t.emptyStateImageUrl,b=e.messages.length===0&&y?{url:y,alt:t.emptyStateImageAlt}:void 0;return W(`dialog`,{open:!0,class:`whoo-widget-panel`,"aria-modal":`true`,"aria-labelledby":`whoo-widget-title`,"aria-describedby":t.notice&&e.noticeAgreed&&e.messages.length===0?vn:void 0,ref:r,onKeyDown:s,onCancel:e=>{e.preventDefault(),t.close()},children:[W(`div`,{class:`whoo-widget-header`,children:[W(`div`,{class:`whoo-widget-header-titles`,children:[u?W(`h2`,{id:`whoo-widget-title`,class:`whoo-widget-header-title`,lang:t.contentLanguage,dir:`auto`,children:u}):W(`h2`,{id:`whoo-widget-title`,class:`whoo-widget-header-title`,children:[f,m?W(`bdi`,{lang:t.contentLanguage,children:l}):null,p]}),t.subtitle?W(`p`,{class:`whoo-widget-header-subtitle`,lang:t.contentLanguage,dir:`auto`,children:t.subtitle}):null]}),W(`div`,{class:`whoo-widget-header-actions`,children:[e.messages.length>0&&W(`button`,{type:`button`,class:`whoo-widget-header-reset`,onClick:()=>{t.resetConversation(),i.current?.focus()},children:t.text.newConversation}),W(`button`,{type:`button`,class:`whoo-widget-header-close`,"aria-label":t.text.closeChat,onClick:()=>t.close(),children:W(yt,{})})]})]}),W(xn,{messages:g,messageFeedback:e.messageFeedback,announcement:e.announcement,emptyStateImage:b,centerEmptyState:h,centeredGreeting:_,notice:v?void 0:t.notice,agentName:l,showFeedback:t.showFeedback,isStreaming:e.isStreaming,isSlowResponse:e.isSlowResponse,onThumbsUp:e=>t.submitFeedback(e,`up`),onThumbsDown:e=>t.expandFeedback(e),onDraftChange:(e,n,r)=>t.setFeedbackDraft(e,n,r),onSubmitDetailed:(e,n,r)=>t.submitFeedback(e,`down`,n||void 0,r||void 0),onCancelFeedback:e=>t.cancelFeedback(e),text:t.text,contentLanguage:t.contentLanguage,languageTag:t.languageTag,announcementIsContent:e.announcementIsContent}),e.runtimeError&&W($t,{message:e.runtimeError}),e.noticeAgreed?W(Qt,{value:e.draft,onChange:e=>t.setDraft(e),onSend:c,disabled:e.isStreaming,inputRef:i,text:t.text,contentLanguage:t.contentLanguage}):W(`div`,{class:`whoo-widget-agreement`,children:W(`button`,{type:`button`,class:`whoo-widget-agreement-button`,ref:a,"aria-describedby":vn,autoFocus:!0,onClick:()=>{o.current=!0,t.agreeToNotice()},children:t.text.agreeToNotice})}),v?W(yn,{notice:t.notice,placement:`footer`,text:t.text,contentLanguage:t.contentLanguage,languageTag:t.languageTag}):null]})}function Tn({controller:e}){let[t,n]=rt(e.getState()),r=H(null),i=H(t.isOpen);return at(()=>(n(e.getState()),e.subscribe(n)),[e]),V(()=>{i.current&&!t.isOpen&&r.current?.focus(),i.current=t.isOpen},[t.isOpen]),t.initError||t.isInitializing?null:W(I,{children:[W(Tt,{isOpen:t.isOpen,onClick:()=>t.isOpen?e.close():e.open(),iconUrl:e.launcher.iconUrl,icon:e.launcher.icon,openIconUrl:e.launcher.openIconUrl,openIcon:e.launcher.openIcon,buttonRef:r,text:e.text}),t.isOpen&&W(wn,{state:t,controller:e,greeting:e.config.greeting})]})}var En=class extends Error{status;constructor(e,t){super(e),this.name=`WidgetApiError`,this.status=t}};function Dn(e){if(typeof e!=`string`)return null;let t=e.trim();return t===``?null:t}async function On(e,t){let n=await fetch(`${e}/api/v1/widget/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({publishable_key:t})});if(!n.ok)throw new En(`Failed to create widget session (${n.status})`,n.status);let r=await n.json();return{token:r.token,...kn(r)}}function kn(e){return{primaryColor:Dn(e.primary_color),name:Dn(e.name),accentColor:Dn(e.accent_color),inkColor:Dn(e.ink_color)}}async function An(e,t){let n=await fetch(`${e}/api/v1/widget/branding`,{headers:{Authorization:`Bearer ${t}`}});if(!n.ok)throw new En(`Failed to load widget branding (${n.status})`,n.status);return kn(await n.json())}async function jn(e,t,n){let r=await fetch(`${e}/api/v1/widget/feedback`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t}`},body:JSON.stringify({message_id:n.messageId,rating:n.rating,correction:n.correction??null,category:n.category??null})});if(!r.ok)throw new En(`Feedback submission failed (${r.status})`,r.status)}async function*Mn(e,t,n,r,i){let a=await fetch(`${e}/api/v1/widget/chat`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t}`},body:JSON.stringify({conversation_id:n,message:r}),signal:i});if(!a.ok||!a.body)throw new En(`Chat request failed (${a.status})`,a.status);let o=a.body.getReader(),s=new TextDecoder,c=``;for(;;){let{done:e,value:t}=await o.read();if(e)break;c+=s.decode(t,{stream:!0});let n=c.indexOf(`
|
|
4
|
+
`)){let e=t.match(un);e?(i(),r.push(e[1])):(a(),n.push(t))}return i(),a(),t.some(e=>e.type===`list`)?t.flatMap((e,n)=>{if(e.type===`list`)return[e];let{text:r}=e;return t[n-1]?.type===`list`&&(r=r.replace(/^(?:[ \t]*\n)+/,``)),t[n+1]?.type===`list`&&(r=r.replace(/(?:\n[ \t]*)+$/,``)),r.trim()===``?[]:[{type:`text`,text:r}]}):null}function J(e,t={}){return ln(e).map((e,n)=>{switch(e.type){case`bold`:return K(`strong`,{children:J(e.value,t)},n);case`italic`:return K(`em`,{children:J(e.value,t)},n);case`link`:return K(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:[e.text,K(`span`,{class:`whoo-widget-sr-only`,lang:t.linkCueLang,children:[` `,t.linkCue??`(opens in new tab)`]})]},n);default:return e.value}})}function mn(e,t={}){let n=e.replace(/\r\n?/g,`
|
|
5
|
+
`),r=pn(n);return r?r.map((e,n)=>e.type===`list`?K(`ul`,{class:`whoo-widget-list`,dir:fn(e.items.find(e=>fn(e))??``),children:e.items.map((e,n)=>K(`li`,{dir:fn(e),children:J(e,t)},n))},n):K(`span`,{children:J(e.text,t)},n)):J(n,t)}function hn(e){return[{value:``,label:e.selectReason},{value:`factual`,label:e.categoryFactual},{value:`incomplete`,label:e.categoryIncomplete},{value:`tone`,label:e.categoryTone},{value:`other`,label:e.categoryOther}]}function gn({state:e,containerRef:n,onThumbsUp:r,onThumbsDown:i,onDraftChange:a,onSubmitDetailed:o,onCancel:s,text:c=t,contentLanguage:l}){let u=e.correction??``,d=e.category??``,f=W(e.status),p=W(null),m=W(null);if(U(()=>{let t=f.current;if(f.current=e.status,t===e.status)return;if(e.status===`expanded`){p.current?.focus();return}if(t===`expanded`&&e.status===`idle`){m.current?.focus();return}let r=n?.current;if(!r)return;let i=r.getRootNode(),a=r.ownerDocument,o=i.activeElement;(o===null?a.activeElement===null||a.activeElement===a.body:o===a.body)&&r.focus()},[e.status,n]),e.status===`expanded`)return K(`div`,{class:`whoo-widget-feedback-form`,children:[K(`label`,{children:[K(`span`,{class:`whoo-widget-sr-only`,children:c.additionalFeedback}),K(`textarea`,{ref:p,class:`whoo-widget-feedback-textarea`,lang:l,value:u,onInput:e=>a(e.target.value,d),placeholder:c.feedbackPlaceholder})]}),K(`select`,{class:`whoo-widget-feedback-select`,"aria-label":c.feedbackCategory,value:d,onChange:e=>a(u,e.target.value),children:hn(c).map(e=>K(`option`,{value:e.value,children:e.label},e.value))}),K(`div`,{class:`whoo-widget-feedback-form-buttons`,children:[K(`button`,{type:`button`,class:`whoo-widget-feedback-submit`,onClick:()=>o(u,d),children:c.submit}),K(`button`,{type:`button`,class:`whoo-widget-feedback-cancel`,onClick:s,children:c.cancel})]})]});let h=e.status===`submitting`,g=e.status===`submitted`;return K(`div`,{class:`whoo-widget-feedback`,children:[g?null:K(`div`,{class:`whoo-widget-feedback-buttons`,children:[K(`button`,{type:`button`,"aria-label":c.goodResponse,"aria-disabled":h,onClick:()=>{h||r()},children:K(St,{})}),K(`button`,{ref:m,type:`button`,"aria-label":c.badResponse,"aria-disabled":h,onClick:()=>{h||i()},children:K(Ct,{})})]}),K(`div`,{role:`status`,class:g?`whoo-widget-feedback-submitted`:e.status===`error`?`whoo-widget-feedback-error`:void 0,children:g?c.feedbackThanks:e.status===`error`?c.feedbackFailed:null})]})}function _n({isSlowResponse:e,text:t}){return K(`div`,{class:`whoo-widget-pending`,children:[K(`span`,{class:`whoo-widget-typing`,"aria-hidden":`true`,children:[K(`span`,{}),K(`span`,{}),K(`span`,{})]}),e?K(`span`,{class:`whoo-widget-pending-text`,children:t.lookingItUp}):null]})}function vn({url:e,alt:t,lang:n}){let[r,i]=rt(!1);return r?null:K(`img`,{class:`whoo-widget-empty-state-image`,src:e,alt:t,lang:n,referrerpolicy:`no-referrer`,onError:()=>i(!0)})}var yn=`whoo-widget-notice`;function bn({notice:e,placement:t=`top`,text:n,contentLanguage:r,languageTag:i}){return t===`footer`?K(`div`,{id:yn,class:`whoo-widget-notice-footer`,role:`note`,tabIndex:0,children:K(`div`,{class:`whoo-widget-message-text`,dir:`auto`,lang:r,children:mn(e,{linkCue:n.opensInNewTab,linkCueLang:i})})}):K(`div`,{id:yn,class:`whoo-widget-notice`,role:`note`,children:K(`div`,{class:`whoo-widget-message-text`,dir:`auto`,lang:r,children:mn(e,{linkCue:n.opensInNewTab,linkCueLang:i})})})}function xn({message:e,speaker:t,feedbackState:n,showFeedback:r,pending:i,isSlowResponse:a,onThumbsUp:o,onThumbsDown:s,onDraftChange:c,onSubmitDetailed:l,onCancelFeedback:u,text:d,contentLanguage:f,languageTag:p}){let m=W(null),h=e.id;return K(`div`,{ref:m,tabIndex:-1,class:`whoo-widget-message whoo-widget-message--${e.role}`,children:[K(`span`,{class:`whoo-widget-sr-only`,children:[e.role===`assistant`?K(`span`,{lang:f,children:t}):t,`:`,` `]}),i?K(_n,{isSlowResponse:a,text:d}):K(`div`,{class:`whoo-widget-message-text`,dir:`auto`,lang:f,children:mn(e.content,{linkCue:d.opensInNewTab,linkCueLang:p})}),r&&e.role===`assistant`&&h?K(gn,{state:n,containerRef:m,onThumbsUp:()=>o(h),onThumbsDown:()=>s(h),onDraftChange:(e,t)=>c(h,e,t),onSubmitDetailed:(e,t)=>l(h,e,t),onCancel:()=>u(h),text:d,contentLanguage:f}):null]})}function Sn({messages:e,messageFeedback:n,announcement:r,emptyStateImage:i,centerEmptyState:a=!1,centeredGreeting:o,notice:s,agentName:c=u,showFeedback:l=!1,isStreaming:d=!1,isSlowResponse:f=!1,onThumbsUp:p,onThumbsDown:m,onDraftChange:h=()=>{},onSubmitDetailed:g,onCancelFeedback:_,text:v=t,contentLanguage:y,languageTag:b,announcementIsContent:x=!1}){let S=W(null),C=!!s&&!e.some(e=>e.role===`user`);at(()=>{let e=S.current;e&&(e.scrollTop=C?0:e.scrollHeight)},[e,f,C]);let w=i?K(vn,{...i,lang:y}):null,T=a&&e.length===0&&(i||o);return K(R,{children:[K(`section`,{class:`whoo-widget-message-list${T?` whoo-widget-message-list--centered`:``}`,ref:S,"aria-label":v.conversation,tabIndex:0,children:[a?null:w,s?K(bn,{notice:s,text:v,contentLanguage:y,languageTag:b}):null,T?K(`div`,{class:`whoo-widget-empty-state`,children:[w,o?K(`div`,{class:`whoo-widget-empty-state-greeting whoo-widget-message-text`,dir:`auto`,lang:y,children:mn(o,{linkCue:v.opensInNewTab,linkCueLang:b})}):null]}):null,e.map((t,r)=>K(xn,{message:t,speaker:t.role===`user`?v.you:c,showFeedback:l,feedbackState:t.id?n[t.id]??{status:`idle`}:{status:`idle`},pending:d&&r===e.length-1&&t.role===`assistant`&&t.content===``,isSlowResponse:f,onThumbsUp:p,onThumbsDown:m,onDraftChange:h,onSubmitDetailed:g,onCancelFeedback:_,text:v,contentLanguage:y,languageTag:b},t.id??r))]}),K(`div`,{class:`whoo-widget-sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,lang:x?y:b,children:r??``})]})}var Cn=`button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`;function wn(e){return Array.from(e.querySelectorAll(Cn)).filter(e=>{let t=getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`})}function Tn({state:e,controller:t,greeting:n}){let r=W(null),i=W(null),a=W(null),o=W(!1);U(()=>{(a.current??i.current)?.focus()},[]),U(()=>{e.noticeAgreed&&o.current&&(o.current=!1,i.current?.focus())},[e.noticeAgreed]),U(()=>{let e=r.current,n=e?Wt(e):()=>{},i=e?Zt(e):()=>{},a=()=>{e&&!e.open&&t.close()};e?.addEventListener(`close`,a);let o=Xt();return()=>{n(),i(),e?.removeEventListener(`close`,a),o()}},[]);let s=e=>{if(e.key===`Escape`&&!Qt(e)){e.preventDefault(),t.close();return}if(e.key!==`Tab`)return;let n=r.current;if(!n)return;let i=wn(n);if(i.length===0)return;let a=n.getRootNode().activeElement;e.preventDefault();let o=i.length-1,s,c=a?i.indexOf(a):-1;if(c!==-1)s=(c+(e.shiftKey?-1:1)+i.length)%i.length;else if(a&&a!==n&&n.contains(a)){let t=i.findIndex(e=>a.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING);s=e.shiftKey?t<=0?o:t-1:t===-1?0:t}else s=e.shiftKey?o:0;i[s].focus()},c=()=>{let n=e.draft.trim();n&&!e.isStreaming&&(t.setDraft(``),t.sendMessage(n))},l=t.resolvedAgentName,u=d(t.config.title),{before:f,after:p,hasName:m}=zt(t.text.chatWith),h=t.greetingStyle===`centered`,g=e.messages.length===0&&n&&!h?[{role:`assistant`,content:n,id:null}]:e.messages,_=e.messages.length===0&&h?n:void 0,v=t.notice!==``&&t.noticePlacement===`footer`,y=t.emptyStateImageUrl,b=e.messages.length===0&&y?{url:y,alt:t.emptyStateImageAlt}:void 0;return K(`dialog`,{open:!0,class:`whoo-widget-panel`,"aria-modal":`true`,"aria-labelledby":`whoo-widget-title`,"aria-describedby":t.notice&&e.noticeAgreed&&e.messages.length===0?yn:void 0,ref:r,onKeyDown:s,onCancel:e=>{e.preventDefault(),t.close()},children:[K(`div`,{class:`whoo-widget-header`,children:[K(`div`,{class:`whoo-widget-header-titles`,children:[u?K(`h2`,{id:`whoo-widget-title`,class:`whoo-widget-header-title`,lang:t.contentLanguage,dir:`auto`,children:u}):K(`h2`,{id:`whoo-widget-title`,class:`whoo-widget-header-title`,children:[f,m?K(`bdi`,{lang:t.contentLanguage,children:l}):null,p]}),t.subtitle?K(`p`,{class:`whoo-widget-header-subtitle`,lang:t.contentLanguage,dir:`auto`,children:t.subtitle}):null]}),K(`div`,{class:`whoo-widget-header-actions`,children:[e.messages.length>0&&K(`button`,{type:`button`,class:`whoo-widget-header-reset`,onClick:()=>{t.resetConversation(),i.current?.focus()},children:t.text.newConversation}),K(`button`,{type:`button`,class:`whoo-widget-header-close`,"aria-label":t.text.closeChat,onClick:()=>t.close(),children:K(bt,{})})]})]}),K(Sn,{messages:g,messageFeedback:e.messageFeedback,announcement:e.announcement,emptyStateImage:b,centerEmptyState:h,centeredGreeting:_,notice:v?void 0:t.notice,agentName:l,showFeedback:t.showFeedback,isStreaming:e.isStreaming,isSlowResponse:e.isSlowResponse,onThumbsUp:e=>t.submitFeedback(e,`up`),onThumbsDown:e=>t.expandFeedback(e),onDraftChange:(e,n,r)=>t.setFeedbackDraft(e,n,r),onSubmitDetailed:(e,n,r)=>t.submitFeedback(e,`down`,n||void 0,r||void 0),onCancelFeedback:e=>t.cancelFeedback(e),text:t.text,contentLanguage:t.contentLanguage,languageTag:t.languageTag,announcementIsContent:e.announcementIsContent}),e.runtimeError&&K(en,{message:e.runtimeError}),e.noticeAgreed?K($t,{value:e.draft,onChange:e=>t.setDraft(e),onSend:c,disabled:e.isStreaming,inputRef:i,text:t.text,contentLanguage:t.contentLanguage}):K(`div`,{class:`whoo-widget-agreement`,children:K(`button`,{type:`button`,class:`whoo-widget-agreement-button`,ref:a,"aria-describedby":yn,autoFocus:!0,onClick:()=>{o.current=!0,t.agreeToNotice()},children:t.text.agreeToNotice})}),v?K(bn,{notice:t.notice,placement:`footer`,text:t.text,contentLanguage:t.contentLanguage,languageTag:t.languageTag}):null]})}function En({controller:e}){let[t,n]=rt(e.getState()),r=W(null),i=W(t.isOpen);return at(()=>(n(e.getState()),e.subscribe(n)),[e]),U(()=>{i.current&&!t.isOpen&&r.current?.focus(),i.current=t.isOpen},[t.isOpen]),t.initError||t.isInitializing?null:K(R,{children:[K(Et,{isOpen:t.isOpen,onClick:()=>t.isOpen?e.close():e.open(),iconUrl:e.launcher.iconUrl,icon:e.launcher.icon,openIconUrl:e.launcher.openIconUrl,openIcon:e.launcher.openIcon,buttonRef:r,text:e.text}),t.isOpen&&K(Tn,{state:t,controller:e,greeting:e.config.greeting})]})}var Dn=class extends Error{status;constructor(e,t){super(e),this.name=`WidgetApiError`,this.status=t}};function On(e){if(typeof e!=`string`)return null;let t=e.trim();return t===``?null:t}async function kn(e,t){let n=await fetch(`${e}/api/v1/widget/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({publishable_key:t})});if(!n.ok)throw new Dn(`Failed to create widget session (${n.status})`,n.status);let r=await n.json();return{token:r.token,...An(r)}}function An(e){return{primaryColor:On(e.primary_color),name:On(e.name),accentColor:On(e.accent_color),inkColor:On(e.ink_color)}}async function jn(e,t){let n=await fetch(`${e}/api/v1/widget/branding`,{headers:{Authorization:`Bearer ${t}`}});if(!n.ok)throw new Dn(`Failed to load widget branding (${n.status})`,n.status);return An(await n.json())}async function Mn(e,t,n){let r=await fetch(`${e}/api/v1/widget/feedback`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t}`},body:JSON.stringify({message_id:n.messageId,rating:n.rating,correction:n.correction??null,category:n.category??null})});if(!r.ok)throw new Dn(`Feedback submission failed (${r.status})`,r.status)}async function*Nn(e,t,n,r,i){let a=await fetch(`${e}/api/v1/widget/chat`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t}`},body:JSON.stringify({conversation_id:n,message:r}),signal:i});if(!a.ok||!a.body)throw new Dn(`Chat request failed (${a.status})`,a.status);let o=a.body.getReader(),s=new TextDecoder,c=``;for(;;){let{done:e,value:t}=await o.read();if(e)break;c+=s.decode(t,{stream:!0});let n=c.indexOf(`
|
|
6
6
|
|
|
7
7
|
`);for(;n!==-1;){let e=c.slice(0,n);c=c.slice(n+2);let t=e.split(`
|
|
8
|
-
`).find(e=>e.startsWith(`data: `));if(i?.aborted)return;t&&(yield
|
|
8
|
+
`).find(e=>e.startsWith(`data: `));if(i?.aborted)return;t&&(yield Pn(JSON.parse(t.slice(6)))),n=c.indexOf(`
|
|
9
9
|
|
|
10
|
-
`)}}}function
|
|
11
|
-
`)).map(e=>{switch(e.type){case`bold`:case`italic`:return Pn(e.value);case`link`:return e.text;default:return e.value}}).join(``)}var Fn=40,In=120;function Ln(e){let t=[];for(let n of cn(e))if(n.type===`text`){let e=n.value.split(/(\s+)/),r=n.start;for(let n of e)r+=n.length,n.trim().length>0&&t.push(r)}else t.push(n.end);return t}function Rn(e){let t=null;return e?.addEventListener(`abort`,()=>{t?.()},{once:!0}),function(e){return new Promise(n=>{let r=setTimeout(()=>{t=null,n()},e);t=()=>{clearTimeout(r),t=null,n()}})}}async function zn(e,t,n){let r=n?.wordIntervalMs??Fn,i=n?.tokenIntervalMs??In,a=n?.signal,o=cn(e),s=new Set(o.filter(e=>e.type!==`text`).map(e=>e.end)),c=Rn(a),l=``;for(let n of Ln(e))if(a?.aborted||(l=e.slice(0,n),t(l),await c(s.has(n)?i:r),a?.aborted))return;l!==e&&t(e)}function Bn(e){let t=e.split(`.`);if(t.length!==3||t.some(e=>e===``))return null;let n=t[1];try{let e=n.replace(/-/g,`+`).replace(/_/g,`/`),t=JSON.parse(atob(e.padEnd(Math.ceil(e.length/4)*4,`=`))),r=e=>typeof e==`number`&&Number.isFinite(e)?e:null,{exp:i,iat:a}=t??{};return{exp:r(i),iat:r(a)}}catch{return null}}function Vn(e){let t=Bn(e)?.exp;return typeof t==`number`?t*1e3:null}function Hn(e,t=Date.now()){let n=Vn(e);return n!==null&&n<=t}function Un(e,t=Date.now()){let n=Bn(e);return n?.exp==null?null:n.iat!=null&&n.exp>n.iat?t+(n.exp-n.iat)*1e3:n.exp*1e3}function Wn(e){return`whoo-aiden-widget:conversation:${e}`}function Gn(e){try{return window.sessionStorage.getItem(Wn(e))}catch{return null}}function Kn(e,t){try{window.sessionStorage.setItem(Wn(e),t)}catch{}}function qn(e){return`whoo-aiden-widget:notice-agreed:${e}`}function Jn(e,t){try{return window.sessionStorage.getItem(qn(e))===t}catch{return!1}}function Yn(e,t){try{window.sessionStorage.setItem(qn(e),t)}catch{}}function Xn(e){try{window.sessionStorage.removeItem(Wn(e))}catch{}}var Zn=/^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;function Qn(e){if(Zn.test(e.trim()))return null;let t=document.createElement(`div`);if(t.style.color=e,t.style.color===``)return null;let n=document.createElement(`div`);n.attachShadow({mode:`open`}).appendChild(t),document.body.appendChild(n);let r=getComputedStyle(t).color;n.remove();let i=r.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/);if(!i)return null;let a=i[4]===void 0?1:Number(i[4]);return{rgb:[Number(i[1]),Number(i[2]),Number(i[3])].map(e=>Math.round(e*a+255*(1-a))),translucent:a<1}}function q(e){return Qn(e)?.rgb??null}function J([e,t,n]){let r=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function $n(e,t){let n=Math.max(e,t),r=Math.min(e,t);return(n+.05)/(r+.05)}function er(e){let t=q(e);if(!t)return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`),`#ffffff`;let n=J(t);return $n(n,J([0,0,0]))>=$n(n,J([255,255,255]))?`#000000`:`#ffffff`}function tr(e,t){let n=q(e),r=q(t);return!n||!r?NaN:$n(J(n),J(r))}var Y=a.primary,nr=a.panel,rr=a.assistantBubble,ir=a.headerHover,ar=4.5;function or([e,t,n]){return`#${[e,t,n].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function sr(e,t=nr){let n=q(e),r=q(t);if(!n||!r)return Y;let i=J(r),a=e=>$n(J(e),i)>=ar;if(a(n))return or(n);for(let e=.99;e>0;e-=.01){let t=n.map(t=>Math.round(t*e));if(a(t))return or(t)}return`#000000`}var cr=a.ink,lr=a.link;function X(e){if(typeof e!=`string`||!e)return null;let t=Qn(e);return t?or(t.rgb):null}function ur(e){if(typeof e!=`string`||!e)return null;let t=Qn(e);return t?t.translucent?e.trim():or(t.rgb):null}var dr=[{role:`onPrimary`,against:[`primary`],required:4.5},{role:`primaryText`,against:[`panel`,`headerHover`],required:4.5},{role:`ink`,against:[`assistantBubble`,`panel`],required:4.5},{role:`link`,against:[`assistantBubble`,`panel`],required:4.5},{role:`muted`,against:[`assistantBubble`,`panel`],required:4.5},{role:`text`,against:[`panel`,`assistantBubble`],required:4.5},{role:`errorText`,against:[`errorBackground`],required:4.5},{role:`typingDots`,against:[`assistantBubble`],required:3},{role:`inputBorder`,against:[`panel`],required:3},{role:`focusRing`,against:[`panel`],required:3}];function fr({color:e,inkColor:t,accentColor:n,overrides:r}){let o=typeof r==`object`&&r&&!Array.isArray(r)?r:{},s=e=>ur(o[e]),c=X(e),l=s(`primary`),u=l??c??Y,d=s(`primaryText`),f=d??sr(u,ir),p=s(`onPrimary`)??er(u),m=X(t),h=s(`ink`)??(m?sr(m,rr):cr),g=X(n),_=s(`link`)??(g?sr(g,rr):lr),v=e=>s(e)??a[e],y={primary:u,onPrimary:p,primaryText:f,ink:h,link:_,text:v(`text`),panel:v(`panel`),border:v(`border`),headerHover:v(`headerHover`),assistantBubble:v(`assistantBubble`),muted:v(`muted`),typingDots:v(`typingDots`),errorBackground:v(`errorBackground`),errorText:v(`errorText`),inputBorder:v(`inputBorder`),focusRing:v(`focusRing`)},b=Object.fromEntries(i.map(e=>[e,s(e)!==null])),x=[];for(let{role:e,against:t,required:n}of dr)for(let r of t){if(!b[e]&&!b[r])continue;let t=tr(y[e],y[r]);Number.isFinite(t)&&t<n&&x.push({role:e,against:r,value:y[e],ratio:t,required:n,overridden:b[e]})}return{primary:u,textOnPrimary:p,primaryAsText:f,ink:h,link:_,adjusted:{primary:l===null&&d===null&&c!==null&&f!==u,ink:!b.ink&&m!==null&&h!==m,link:!b.link&&g!==null&&_!==g},roles:y,overridden:b,contrastWarnings:x}}function Z(e){return typeof e==`string`?`"${e}"`:`a ${typeof e} value`}function pr(e,t,n=Y){let r=t;X(t)===null&&(console.warn(`[whoo-aiden-widget] Could not use ${Z(t)} as the theme color; falling back to ${Z(n)}.`),r=n);let i=fr({color:r});e.style.setProperty(`--whoo-widget-color`,i.primary),e.style.setProperty(`--whoo-widget-text-on-color`,i.textOnPrimary),e.style.setProperty(`--whoo-widget-color-text`,i.primaryAsText)}function mr(e,{inkColor:t,accentColor:n}){let r=fr({inkColor:t,accentColor:n});e.style.setProperty(`--whoo-widget-ink`,r.ink),e.style.setProperty(`--whoo-widget-link-color`,r.link)}function hr(e,t){let n=fr({overrides:t});for(let t of i){let r=n.overridden.primary&&(t===`onPrimary`||t===`primaryText`);(n.overridden[t]||r)&&e.style.setProperty(o[t],n.roles[t])}}function gr(e,t){e&&X(e)===null&&console.warn(`[whoo-aiden-widget] Could not use ${Z(e)} as the ${t}; using the default.`)}function _r(e,t,n){for(let e of i){let n=t[e];n&&X(n)===null&&console.warn(`[whoo-aiden-widget] Could not use ${Z(n)} as theme.colors.${e}; using the calculated color.`)}let r=t.primary;typeof r==`string`&&Qn(r)?.translucent&&console.warn(`[whoo-aiden-widget] theme.colors.primary ${Z(r)} is translucent. The launcher shows your page through it, so its icon may be unreadable over dark content; pass a solid color.`),vr({color:e.color,inkColor:e.inkColor,accentColor:e.accentColor,overrides:t},n)}function vr(e,t){for(let n of fr(e).contrastWarnings){let{role:e,against:r,value:i,ratio:a,required:o,overridden:s}=n,c=`${e}|${r}|${i}`;t.has(c)||(t.add(c),console.warn(s?`[whoo-aiden-widget] theme.colors.${e} (${i}) has ${a.toFixed(2)}:1 contrast against the ${r} color; ${o}:1 is recommended. Using it as given.`:`[whoo-aiden-widget] the ${e} color (${i}) has ${a.toFixed(2)}:1 contrast against your theme.colors.${r}; ${o}:1 is recommended. Override theme.colors.${e} too.`))}}function yr(e,t,n=new Set){pr(e,t.color??Y),gr(t.inkColor,`ink color`),gr(t.accentColor,`accent color`),mr(e,{inkColor:t.inkColor,accentColor:t.accentColor});let r=oe(t.theme);_r(t,r.colors,n),hr(e,r.colors),r.fontFamily&&e.style.setProperty(`--whoo-widget-font`,r.fontFamily)}var br=8e3,xr=3e3,Sr=15e3,Cr=class extends Error{name=`SessionUnavailableError`};function wr(e,t){return t?new Promise((n,r)=>{let i=()=>r(new DOMException(`Aborted`,`AbortError`));if(t.aborted)return i();t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})}):e}function Tr(e,t){return e===`refused`?new Q(t):new Cr}function Er(e){let t=e?.status;return t===401||t===403||t===404}var Q=class extends Error{name=`SessionExpiredError`;constructor(e){super(e instanceof Error?e.message:`The session has expired.`)}};function Dr(e){return e?.status===401}function Or(e,t){return new Promise(n=>{let r=setTimeout(n,t);e.then(()=>{clearTimeout(r),n()})})}var kr=class{config;state;listeners=new Set;sessionToken=null;sessionTokenExpiresAt=null;tokenRenewal=null;renewalGeneration=0;sendEpoch=0;getSessionToken;conversationId=null;storageIdentifier;activeRequestController=null;slowResponseTimer=null;announcementTimer=null;prefersReducedMotion;launcher;launcherIconUrl;emptyStateImageUrl;emptyStateImageAlt;notice;requireNoticeAgreement;noticePlacement;subtitle;greetingStyle;showFeedback;text;language;languageTag;contentLanguage;dir;constructor(e){this.config=e;let t=oe(e.theme).launcher,n=t.iconUrl??r(e.launcherIconUrl,`launcherIconUrl`);this.launcher={...t,...n?{iconUrl:n}:{}},this.launcherIconUrl=n,this.emptyStateImageUrl=r(e.emptyStateImageUrl,`emptyStateImageUrl`),this.emptyStateImageAlt=typeof e.emptyStateImageAlt==`string`?e.emptyStateImageAlt.trim():``,this.notice=typeof e.notice==`string`&&!f(e.notice)?e.notice.trim():``,this.requireNoticeAgreement=e.requireNoticeAgreement===!0&&this.notice!==``,e.requireNoticeAgreement===!0&&!this.notice&&console.warn("whoo-aiden-widget: `requireNoticeAgreement` has no effect without a `notice`, so it is ignored."),this.noticePlacement=A(e.noticePlacement),this.subtitle=typeof e.subtitle==`string`&&!f(e.subtitle)?e.subtitle.trim():``,this.greetingStyle=k(e.greetingStyle),this.showFeedback=e.showFeedback===!0,this.storageIdentifier=e.publishableKey??`session-token-mode`,this.getSessionToken=h(e);let{language:i,tag:a,dir:o}=Pt(e.language,typeof document>`u`?void 0:document.documentElement.lang);this.language=i,this.languageTag=a,this.dir=o,this.contentLanguage=Lt(e.contentLanguage,typeof document>`u`?void 0:document.documentElement.lang,e.language),this.text={...Mt(i),...x(e.messages)},this.prefersReducedMotion=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,this.state={isOpen:!1,messages:[],isStreaming:!1,initError:null,isInitializing:!1,runtimeError:null,messageFeedback:{},primaryColor:null,agentName:null,accentColor:null,inkColor:null,announcement:null,announcementIsContent:!1,isSlowResponse:!1,noticeAgreed:!this.requireNoticeAgreement||Jn(this.storageIdentifier,this.notice),draft:``}}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}get resolvedAgentName(){return d(this.config.name)||this.state.agentName||`Aiden`}announce(e,t=!1,n=!1){this.announcementTimer!==null&&(clearTimeout(this.announcementTimer),this.announcementTimer=null),n&&e!==null&&this.state.announcement!==e?this.setState({announcement:e,announcementIsContent:t}):(this.state.announcement!==null&&this.setState({announcement:null}),e!==null&&(this.announcementTimer=setTimeout(()=>{this.announcementTimer=null,this.setState({announcement:e,announcementIsContent:t})},250)))}clearSlowResponse(){this.slowResponseTimer!==null&&(clearTimeout(this.slowResponseTimer),this.slowResponseTimer=null),this.state.isSlowResponse&&this.setState({isSlowResponse:!1})}setState(e){this.state={...this.state,...e};for(let e of this.listeners)e(this.state)}async init(){this.setState({isInitializing:!0});try{await this.start()}finally{this.setState({isInitializing:!1})}}async start(){let e=this.config.apiBaseUrl??`https://api.aidenvoice.com`;try{if(this.config.sessionToken){if(Hn(this.config.sessionToken)){if(!(`token`in await this.renewToken()))throw Error(`The sessionToken has expired.`)}else this.sessionToken=this.config.sessionToken,this.sessionTokenExpiresAt=Vn(this.config.sessionToken)}else if(this.config.publishableKey){let{token:t,primaryColor:n,name:r,accentColor:i,inkColor:a}=await On(e,this.config.publishableKey);this.sessionToken=t,this.sessionTokenExpiresAt=Un(t),this.setState({primaryColor:n,agentName:r,accentColor:i,inkColor:a})}else throw Error(`WidgetConfig must include exactly one of publishableKey or sessionToken`)}catch(e){console.error(`[whoo-aiden-widget] initialization failed:`,e),this.setState({initError:e instanceof Error?e.message:String(e)});return}this.conversationId=Gn(this.storageIdentifier),this.config.sessionToken&&await Or(this.loadBranding(e),xr)}async loadBranding(e){try{let t=this.config;if(X(t.color)&&X(t.inkColor)&&X(t.accentColor)&&d(t.name))return;let{primaryColor:n,name:r,accentColor:i,inkColor:a}=await this.withSession(t=>An(e,t));this.setState({primaryColor:n,agentName:r,accentColor:i,inkColor:a})}catch(e){let t=e?.status;(e instanceof Q||t===401||t===403)&&(this.state.isInitializing?(console.error(`[whoo-aiden-widget] initialization failed:`,e),this.setState({initError:e instanceof Error?e.message:String(e)})):(console.error(`[whoo-aiden-widget] the session was refused after start-up:`,e),this.setState({runtimeError:this.text.sessionExpired})))}}open(){this.setState({isOpen:!0})}resetConversation(){this.sendEpoch+=1,this.activeRequestController?.abort(`reset`),this.activeRequestController=null,this.clearSlowResponse(),this.conversationId=null,Xn(this.storageIdentifier),this.setState({messages:[],messageFeedback:{},runtimeError:null,isStreaming:!1}),this.announce(this.text.conversationCleared)}agreeToNotice(){this.state.noticeAgreed||(Yn(this.storageIdentifier,this.notice),this.setState({noticeAgreed:!0}))}setDraft(e){this.setState({draft:e})}close(){this.activeRequestController?.abort(`close`),this.activeRequestController=null,this.clearSlowResponse(),this.announce(null),this.setState({isOpen:!1})}async sendMessage(e){if(!this.sessionToken||!this.state.noticeAgreed)return;let t=this.config.apiBaseUrl??`https://api.aidenvoice.com`;this.sendEpoch+=1;let n=this.sendEpoch,r=()=>n===this.sendEpoch,i={role:`user`,content:e,id:null},a={role:`assistant`,content:``,id:null};this.setState({messages:[...this.state.messages,i,a],isStreaming:!0,runtimeError:null}),this.announce(zt(this.text.messageSent,{name:this.resolvedAgentName}),!1,!0);let o=a,s=e=>{let t=o;o={...o,...e},this.setState({messages:this.state.messages.map(e=>e===t?o:e)})},c=e=>s({content:e}),l=new AbortController;this.activeRequestController=l;let{signal:u}=l,d=!1;this.slowResponseTimer=setTimeout(()=>{this.slowResponseTimer=null,this.setState({isSlowResponse:!0}),r()&&this.announce(this.text.lookingItUp)},br);let f=!1,p=()=>{this.state.draft===``&&(f=!0,this.setState({draft:e}))},m=!1,h=e=>{m=!0,this.announce(Pn(e),!0)},g=(e=this.text.genericError)=>{r()&&(m||(m=!0,this.announce(null)),this.setState({runtimeError:e}),p())},_=``;try{let{stream:n,first:i}=await this.withSession(async n=>{d=!0;let r=Mn(t,n,this.conversationId,e,u);return{stream:r,first:await r.next()}},u);for(let e=i;!e.done&&!u.aborted&&r();e=await n.next()){let t=e.value;if(t.type===`conversation_id`)this.conversationId=t.conversationId,Kn(this.storageIdentifier,t.conversationId);else if(t.type===`delta`)this.clearSlowResponse(),t.verbatim&&!this.prefersReducedMotion?(await zn(t.delta,e=>c(e),{signal:u}),_=t.delta):t.verbatim?(_=t.delta,c(_)):(_+=t.delta,c(_));else if(t.type===`done`)t.conversationId&&(this.conversationId=t.conversationId,Kn(this.storageIdentifier,t.conversationId)),t.messageId&&s({id:t.messageId}),r()&&h(_);else if(t.type===`error`){console.error(`[whoo-aiden-widget] chat error:`,t.error),_.trim()!==``&&r()&&h(_),g(),l.abort();break}}}catch(e){u.aborted?u.reason===`close`&&r()&&!d&&p():e instanceof Q?(console.error(`[whoo-aiden-widget] chat request failed: the session has expired.`,e),g(this.text.sessionExpired)):e instanceof Cr?(console.error(`[whoo-aiden-widget] chat request failed: no session could be had.`),g()):(console.error(`[whoo-aiden-widget] chat request failed:`,e),g())}finally{let e=o.id===null&&o.content.trim()===``,t=this.state.messages.filter(t=>!(e&&t===o)&&!(e&&f&&t===i)),n=t.length!==this.state.messages.length;r()?(this.activeRequestController=null,this.clearSlowResponse(),m||(!u.aborted&&_.trim()!==``?h(_):this.announce(null)),this.setState({isStreaming:!1,...n?{messages:t}:{}})):n&&this.setState({messages:t})}}expandFeedback(e){let{correction:t,category:n}=this.state.messageFeedback[e]??{};this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`expanded`,correction:t,category:n}}})}setFeedbackDraft(e,t,n){this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{...this.state.messageFeedback[e],correction:t,category:n}}})}cancelFeedback(e){this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`idle`}}})}async submitFeedback(e,t,n,r){if(!this.sessionToken)return;let i=this.config.apiBaseUrl??`https://api.aidenvoice.com`;this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`submitting`,rating:t}}});try{await this.withSession(a=>jn(i,a,{messageId:e,rating:t,correction:n,category:r})),this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`submitted`,rating:t}}})}catch(i){console.error(`[whoo-aiden-widget] feedback submission failed:`,i),this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`error`,rating:t,correction:n,category:r}}})}}async currentToken(e){let t=this.sessionToken,n=this.sessionTokenExpiresAt;return t&&(n===null||n-Date.now()>6e4)?{token:t}:wr(this.renewToken(),e)}renewToken(){return this.tokenRenewal??=this.fetchNewToken().finally(()=>{this.tokenRenewal=null}),this.tokenRenewal}async fetchNewToken(){let e=++this.renewalGeneration,t,n=new Promise(e=>{t=setTimeout(()=>{console.error(`[whoo-aiden-widget] could not renew the session: it took too long.`),e({failure:`unavailable`})},Sr)});try{return await Promise.race([this.obtainToken(e),n])}finally{clearTimeout(t)}}async obtainToken(e){let t=this.config.apiBaseUrl??`https://api.aidenvoice.com`,n;try{if(this.config.publishableKey)n=(await On(t,this.config.publishableKey)).token;else if(this.getSessionToken)n=await this.getSessionToken();else return{failure:`refused`}}catch(e){return console.error(`[whoo-aiden-widget] could not renew the session:`,e),{failure:this.config.publishableKey&&Er(e)?`refused`:`unavailable`}}let r=typeof n==`string`?Un(n):null;return typeof n!=`string`||n===``||r!==null&&r<=Date.now()?(console.error(`[whoo-aiden-widget] could not renew the session: no usable token was returned.`),{failure:`refused`}):(e===this.renewalGeneration&&(this.sessionToken=n,this.sessionTokenExpiresAt=r),{token:n})}async withSession(e,t){let n=await this.currentToken(t);if(!(`token`in n))throw Tr(n.failure);let{token:r}=n;try{return await e(r)}catch(n){if(!Dr(n))throw n;let i=this.sessionToken&&this.sessionToken!==r?{token:this.sessionToken}:await wr(this.renewToken(),t);if(!(`token`in i))throw Tr(i.failure,n);try{return await e(i.token)}catch(e){throw Dr(e)?new Q(e):e}}}},$=20,Ar=12,jr=300,Mr=352;function Nr(){try{return typeof CSS<`u`&&CSS.supports?.(`height`,`100dvh`)?`dvh`:`vh`}catch{return`vh`}}function Pr(e,t){let{offsetX:n,offsetY:r,launcherSize:i,panelWidth:a,panelHeight:o,cornerRadius:s}=le(t.layout),c=e=>typeof t.layout?.offset?.[e]==`number`;if(typeof window<`u`&&window.innerWidth>0&&window.innerHeight>0){let e=Math.max($,window.innerWidth-jr),t=Math.max($,window.innerHeight-i-Mr);c(`x`)&&(n>e||n>window.innerWidth-i)&&console.warn(`whoo-aiden-widget: \`layout.offset.x\` ${n} leaves no room for the launcher and panel in this viewport; it is held back.`),c(`y`)&&(r>t||r>window.innerHeight-i)&&console.warn(`whoo-aiden-widget: \`layout.offset.y\` ${r} leaves no room for the launcher and panel in this viewport; it is held back.`)}let l=`100${Nr()}`,u=`min(${n}px, max(${$}px, calc(100vw - ${jr}px)), calc(100vw - ${i}px))`,d=`min(${r}px, max(${$}px, calc(${l} - ${i+Mr}px)), calc(${l} - ${i}px))`,f=`calc(${d} + ${i}px + ${Ar}px)`,p=t.position===`bottom-left`,m=(t,n)=>e.style.setProperty(t,n);m(`--whoo-widget-inset-left`,p?u:`auto`),m(`--whoo-widget-inset-right`,p?`auto`:u),m(`--whoo-widget-inset-bottom`,d),m(`--whoo-widget-launcher-size`,`${i}px`),m(`--whoo-widget-panel-bottom`,f),m(`--whoo-widget-panel-width`,`${a}px`),m(`--whoo-widget-panel-height`,`${o}px`),m(`--whoo-widget-panel-max-width`,`calc(100vw - ${u} - ${$}px)`),m(`--whoo-widget-panel-max-height`,`calc(${l} - ${f} - ${$}px)`),s===void 0?e.style.removeProperty(`--whoo-widget-corner-radius`):m(`--whoo-widget-corner-radius`,`${s}px`)}var Fr=`:host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:var(--whoo-widget-inset-bottom,20px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-launcher-size,56px);height:var(--whoo-widget-launcher-size,56px);background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{width:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);height:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);display:block}.whoo-widget-launcher-icon-image{width:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);height:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);object-fit:cover;border-radius:50%}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:var(--whoo-widget-panel-bottom,88px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-panel-width,360px);height:var(--whoo-widget-panel-height,480px);max-width:var(--whoo-widget-panel-max-width,calc(100vw - 40px));max-height:var(--whoo-widget-panel-max-height,calc(100vh - 108px));background:var(--whoo-widget-panel,#fff);border-radius:var(--whoo-widget-corner-radius,12px);font-family:var(--whoo-widget-font,-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);color:inherit;border:none;flex-direction:column;margin:0;padding:0;display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}button,input,textarea,select{font-family:inherit}.whoo-widget-panel:not([open]){display:none}.whoo-widget-panel::backdrop{background:0 0}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + max(8px, var(--whoo-widget-visible-height,100%) - 8px - var(--whoo-widget-panel-height,480px)));height:min(var(--whoo-widget-panel-height,480px), calc(var(--whoo-widget-visible-height,100%) - 16px));max-height:none;bottom:auto}@media (width<=400px),(height<=420px){.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + 8px);height:calc(var(--whoo-widget-visible-height,100%) - 16px)}}.whoo-widget-header{border-bottom:1px solid var(--whoo-widget-border,#e5e5e5);flex-wrap:wrap;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;max-height:50%;padding-block:8px;padding-inline:16px 8px;display:flex;overflow-y:auto}.whoo-widget-header-titles{flex:10em;min-width:0}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;margin:0;font-size:15px;font-weight:600}.whoo-widget-header-subtitle{color:var(--whoo-widget-muted,#4b5563);overflow-wrap:anywhere;margin:2px 0 0;font-size:13px}.whoo-widget-header-actions{background:var(--whoo-widget-panel,#fff);flex-shrink:0;align-items:center;gap:4px;margin-inline-start:auto;display:flex;position:sticky;bottom:0}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:var(--whoo-widget-header-hover,#f3f4f6)}.whoo-widget-message-list{overscroll-behavior:contain;flex:1;min-height:0;padding:12px;overflow-y:auto}.whoo-widget-message-list:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:-2px;box-shadow:inset 0 0 0 4px var(--whoo-widget-panel,#fff)}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}.whoo-widget-message-list--centered{flex-direction:column;display:flex}.whoo-widget-empty-state{margin-block:auto}.whoo-widget-empty-state-greeting{color:var(--whoo-widget-ink,#111);text-align:center;overflow-wrap:anywhere;white-space:pre-line}.whoo-widget-empty-state-greeting a{color:var(--whoo-widget-link-color,#00e)}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-notice{border:1px solid var(--whoo-widget-border,#e5e5e5);color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;margin-bottom:12px;padding:8px 12px}.whoo-widget-notice a,.whoo-widget-notice-footer a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-message{overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-message-text,.whoo-widget-message-text li{unicode-bidi:plaintext}.whoo-widget-list{margin:4px 0;padding-inline-start:0}.whoo-widget-list li{margin-inline-start:20px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-inline-start:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{background:var(--whoo-widget-assistant-bubble,#f0f0f0);color:var(--whoo-widget-ink,#111)}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:var(--whoo-widget-typing-dots,#6b7280);border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{background:var(--whoo-widget-error-bg,#fee2e2);color:var(--whoo-widget-error-text,#991b1b);padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid var(--whoo-widget-border,#e5e5e5);gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:var(--whoo-widget-corner-radius,6px);unicode-bidi:plaintext;flex:1;min-width:0;padding:8px;font-size:16px}.whoo-widget-agreement{border-top:1px solid var(--whoo-widget-border,#e5e5e5);padding:12px}.whoo-widget-agreement-button{border-radius:var(--whoo-widget-corner-radius,6px);background:var(--whoo-widget-color,#4f46e5);width:100%;min-height:44px;color:var(--whoo-widget-text-on-color,#fff);overflow-wrap:anywhere;cursor:pointer;border:none;padding:8px 16px;font-weight:600;display:block}.whoo-widget-composer-send{border-radius:var(--whoo-widget-corner-radius,6px);background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;padding:8px 16px}.whoo-widget-composer-input::placeholder{color:var(--whoo-widget-muted,#4b5563);opacity:1}.whoo-widget-notice-footer{overscroll-behavior:contain;border-top:1px solid var(--whoo-widget-border,#e5e5e5);min-height:0;max-height:25%;color:var(--whoo-widget-muted,#4b5563);text-align:center;overflow-wrap:anywhere;white-space:pre-line;flex:0 auto;padding:8px 16px;font-size:12px;line-height:1.4;overflow-y:auto}.whoo-widget-notice-footer:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:-2px;box-shadow:inset 0 0 0 4px var(--whoo-widget-panel,#fff)}.whoo-widget-composer-send[aria-disabled=true],.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:var(--whoo-widget-muted,#4b5563);background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:var(--whoo-widget-text,#111);background:#0000000f}.whoo-widget-feedback-buttons button[aria-disabled=true]{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;border:1px solid var(--whoo-widget-input-border,#6b7280);resize:vertical;unicode-bidi:plaintext;border-radius:6px;width:100%;padding:6px;font-size:16px}.whoo-widget-feedback-select{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;height:2em;min-height:24px;padding:4px;font-size:16px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{border:1px solid var(--whoo-widget-input-border,#6b7280);background:var(--whoo-widget-panel,#fff);color:var(--whoo-widget-text,#111);cursor:pointer;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:var(--whoo-widget-muted,#4b5563);margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:var(--whoo-widget-error-text,#991b1b);font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:2px;box-shadow:0 0 0 4px var(--whoo-widget-panel,#fff)}@media (forced-colors:active){.whoo-widget-message{border:1px solid canvastext}.whoo-widget-launcher,.whoo-widget-header-close,.whoo-widget-header-reset,.whoo-widget-composer-send,.whoo-widget-agreement-button,.whoo-widget-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}`;function Ir(e){let t=document.createElement(`div`);t.id=`whoo-aiden-widget-host`,t.style.position=`relative`,t.style.zIndex=String(l(e.zIndex));let n=t.attachShadow({mode:`open`}),r=document.createElement(`style`);r.textContent=Fr,n.appendChild(r);let i=document.createElement(`div`);n.appendChild(i);let a=new Set;yr(i,e,a),Pr(i,e);let o=new kr(e);i.setAttribute(`lang`,o.languageTag),i.setAttribute(`dir`,o.dir);let s=X(e.color)!==null,c=null,u=``,d=oe(e.theme).colors,f=Object.keys(d).length>0,p={color:e.color,inkColor:e.inkColor,accentColor:e.accentColor};return o.subscribe(t=>{let n=!1;!s&&t.primaryColor&&t.primaryColor!==c&&(c=t.primaryColor,pr(i,t.primaryColor,e.color),X(t.primaryColor)&&(p={...p,color:t.primaryColor}),n=!0);let r=`${t.inkColor}|${t.accentColor}`;if((t.inkColor||t.accentColor)&&r!==u){u=r;let a=X(e.inkColor)?e.inkColor:t.inkColor,o=X(e.accentColor)?e.accentColor:t.accentColor;mr(i,{inkColor:a,accentColor:o}),p={...p,inkColor:a,accentColor:o},n=!0}n&&(hr(i,d),f&&vr({...p,overrides:d},a))}),o.init(),Ue(W(Tn,{controller:o}),i),document.body.appendChild(t),{unmount(){Ue(null,i),t.remove()}}}function Lr(e){return p(e),Ir(e)}return e.init=Lr,e})({});
|
|
10
|
+
`)}}}function Pn(e){return typeof e.error==`string`?{type:`error`,error:e.error,conversationId:e.conversation_id}:e.done===!0?{type:`done`,conversationId:e.conversation_id,messageId:e.message_id??null}:typeof e.delta==`string`?e.verbatim===!0?{type:`delta`,delta:e.delta,verbatim:!0}:{type:`delta`,delta:e.delta}:{type:`conversation_id`,conversationId:e.conversation_id}}function Fn(e){return ln(e.replace(/\r\n?/g,`
|
|
11
|
+
`)).map(e=>{switch(e.type){case`bold`:case`italic`:return Fn(e.value);case`link`:return e.text;default:return e.value}}).join(``)}var In=40,Ln=120;function Rn(e){let t=[];for(let n of ln(e))if(n.type===`text`){let e=n.value.split(/(\s+)/),r=n.start;for(let n of e)r+=n.length,n.trim().length>0&&t.push(r)}else t.push(n.end);return t}function zn(e){let t=null;return e?.addEventListener(`abort`,()=>{t?.()},{once:!0}),function(e){return new Promise(n=>{let r=setTimeout(()=>{t=null,n()},e);t=()=>{clearTimeout(r),t=null,n()}})}}async function Bn(e,t,n){let r=n?.wordIntervalMs??In,i=n?.tokenIntervalMs??Ln,a=n?.signal,o=ln(e),s=new Set(o.filter(e=>e.type!==`text`).map(e=>e.end)),c=zn(a),l=``;for(let n of Rn(e))if(a?.aborted||(l=e.slice(0,n),t(l),await c(s.has(n)?i:r),a?.aborted))return;l!==e&&t(e)}function Vn(e){let t=e.split(`.`);if(t.length!==3||t.some(e=>e===``))return null;let n=t[1];try{let e=n.replace(/-/g,`+`).replace(/_/g,`/`),t=JSON.parse(atob(e.padEnd(Math.ceil(e.length/4)*4,`=`))),r=e=>typeof e==`number`&&Number.isFinite(e)?e:null,{exp:i,iat:a}=t??{};return{exp:r(i),iat:r(a)}}catch{return null}}function Hn(e){let t=Vn(e)?.exp;return typeof t==`number`?t*1e3:null}function Un(e,t=Date.now()){let n=Hn(e);return n!==null&&n<=t}function Wn(e,t=Date.now()){let n=Vn(e);return n?.exp==null?null:n.iat!=null&&n.exp>n.iat?t+(n.exp-n.iat)*1e3:n.exp*1e3}function Gn(e){return`whoo-aiden-widget:conversation:${e}`}function Kn(e){try{return window.sessionStorage.getItem(Gn(e))}catch{return null}}function qn(e,t){try{window.sessionStorage.setItem(Gn(e),t)}catch{}}function Jn(e){return`whoo-aiden-widget:notice-agreed:${e}`}function Yn(e,t){try{return window.sessionStorage.getItem(Jn(e))===t}catch{return!1}}function Xn(e,t){try{window.sessionStorage.setItem(Jn(e),t)}catch{}}function Zn(e){try{window.sessionStorage.removeItem(Gn(e))}catch{}}var Qn=/^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;function $n(e){if(Qn.test(e.trim()))return null;let t=document.createElement(`div`);if(t.style.color=e,t.style.color===``)return null;let n=document.createElement(`div`);n.attachShadow({mode:`open`}).appendChild(t),document.body.appendChild(n);let r=getComputedStyle(t).color;n.remove();let i=r.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/);if(!i)return null;let a=i[4]===void 0?1:Number(i[4]);return{rgb:[Number(i[1]),Number(i[2]),Number(i[3])].map(e=>Math.round(e*a+255*(1-a))),translucent:a<1}}function Y(e){return $n(e)?.rgb??null}function X([e,t,n]){let r=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function er(e,t){let n=Math.max(e,t),r=Math.min(e,t);return(n+.05)/(r+.05)}function tr(e){let t=Y(e);if(!t)return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`),`#ffffff`;let n=X(t);return er(n,X([0,0,0]))>=er(n,X([255,255,255]))?`#000000`:`#ffffff`}function nr(e,t){let n=Y(e),r=Y(t);return!n||!r?NaN:er(X(n),X(r))}var rr=a.primary,ir=a.panel,ar=a.assistantBubble,or=a.headerHover,sr=4.5;function cr([e,t,n]){return`#${[e,t,n].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function lr(e,t=ir){let n=Y(e),r=Y(t);if(!n||!r)return rr;let i=X(r),a=e=>er(X(e),i)>=sr;if(a(n))return cr(n);for(let e=.99;e>0;e-=.01){let t=n.map(t=>Math.round(t*e));if(a(t))return cr(t)}return`#000000`}var ur=a.ink,dr=a.link;function Z(e){if(typeof e!=`string`||!e)return null;let t=$n(e);return t?cr(t.rgb):null}function fr(e){if(typeof e!=`string`||!e)return null;let t=$n(e);return t?t.translucent?e.trim():cr(t.rgb):null}var pr=[{role:`onPrimary`,against:[`primary`],required:4.5},{role:`primaryText`,against:[`panel`,`headerHover`],required:4.5},{role:`ink`,against:[`assistantBubble`,`panel`],required:4.5},{role:`link`,against:[`assistantBubble`,`panel`],required:4.5},{role:`muted`,against:[`assistantBubble`,`panel`],required:4.5},{role:`text`,against:[`panel`,`assistantBubble`],required:4.5},{role:`errorText`,against:[`errorBackground`],required:4.5},{role:`typingDots`,against:[`assistantBubble`],required:3},{role:`inputBorder`,against:[`panel`],required:3},{role:`focusRing`,against:[`panel`],required:3}];function mr({color:e,inkColor:t,accentColor:n,overrides:r}){let o=typeof r==`object`&&r&&!Array.isArray(r)?r:{},s=e=>fr(o[e]),c=Z(e),l=s(`primary`),u=l??c??rr,d=s(`primaryText`),f=d??lr(u,or),p=s(`onPrimary`)??tr(u),m=Z(t),h=s(`ink`)??(m?lr(m,ar):ur),g=Z(n),_=s(`link`)??(g?lr(g,ar):dr),v=e=>s(e)??a[e],y={primary:u,onPrimary:p,primaryText:f,ink:h,link:_,text:v(`text`),panel:v(`panel`),border:v(`border`),headerHover:v(`headerHover`),assistantBubble:v(`assistantBubble`),muted:v(`muted`),typingDots:v(`typingDots`),errorBackground:v(`errorBackground`),errorText:v(`errorText`),inputBorder:v(`inputBorder`),focusRing:v(`focusRing`)},b=Object.fromEntries(i.map(e=>[e,s(e)!==null])),x=[];for(let{role:e,against:t,required:n}of pr)for(let r of t){if(!b[e]&&!b[r])continue;let t=nr(y[e],y[r]);Number.isFinite(t)&&t<n&&x.push({role:e,against:r,value:y[e],ratio:t,required:n,overridden:b[e]})}return{primary:u,textOnPrimary:p,primaryAsText:f,ink:h,link:_,adjusted:{primary:l===null&&d===null&&c!==null&&f!==u,ink:!b.ink&&m!==null&&h!==m,link:!b.link&&g!==null&&_!==g},roles:y,overridden:b,contrastWarnings:x}}function Q(e){return typeof e==`string`?`"${e}"`:`a ${typeof e} value`}function hr(e,t,n=rr){let r=t;Z(t)===null&&(console.warn(`[whoo-aiden-widget] Could not use ${Q(t)} as the theme color; falling back to ${Q(n)}.`),r=n);let i=mr({color:r});e.style.setProperty(`--whoo-widget-color`,i.primary),e.style.setProperty(`--whoo-widget-text-on-color`,i.textOnPrimary),e.style.setProperty(`--whoo-widget-color-text`,i.primaryAsText)}function gr(e,{inkColor:t,accentColor:n}){let r=mr({inkColor:t,accentColor:n});e.style.setProperty(`--whoo-widget-ink`,r.ink),e.style.setProperty(`--whoo-widget-link-color`,r.link)}function _r(e,t){let n=mr({overrides:t});for(let t of i){let r=n.overridden.primary&&(t===`onPrimary`||t===`primaryText`);(n.overridden[t]||r)&&e.style.setProperty(o[t],n.roles[t])}}function vr(e,t){e&&Z(e)===null&&console.warn(`[whoo-aiden-widget] Could not use ${Q(e)} as the ${t}; using the default.`)}function yr(e,t,n){for(let e of i){let n=t[e];n&&Z(n)===null&&console.warn(`[whoo-aiden-widget] Could not use ${Q(n)} as theme.colors.${e}; using the calculated color.`)}let r=t.primary;typeof r==`string`&&$n(r)?.translucent&&console.warn(`[whoo-aiden-widget] theme.colors.primary ${Q(r)} is translucent. The launcher shows your page through it, so its icon may be unreadable over dark content; pass a solid color.`),br({color:e.color,inkColor:e.inkColor,accentColor:e.accentColor,overrides:t},n)}function br(e,t){for(let n of mr(e).contrastWarnings){let{role:e,against:r,value:i,ratio:a,required:o,overridden:s}=n,c=`${e}|${r}|${i}`;t.has(c)||(t.add(c),console.warn(s?`[whoo-aiden-widget] theme.colors.${e} (${i}) has ${a.toFixed(2)}:1 contrast against the ${r} color; ${o}:1 is recommended. Using it as given.`:`[whoo-aiden-widget] the ${e} color (${i}) has ${a.toFixed(2)}:1 contrast against your theme.colors.${r}; ${o}:1 is recommended. Override theme.colors.${e} too.`))}}function xr(e,t,n=new Set){hr(e,t.color??rr),vr(t.inkColor,`ink color`),vr(t.accentColor,`accent color`),gr(e,{inkColor:t.inkColor,accentColor:t.accentColor});let r=ce(t.theme);yr(t,r.colors,n),_r(e,r.colors),r.fontFamily&&e.style.setProperty(`--whoo-widget-font`,r.fontFamily)}var Sr=8e3,Cr=3e3,wr=15e3,Tr=class extends Error{name=`SessionUnavailableError`};function Er(e,t){return t?new Promise((n,r)=>{let i=()=>r(new DOMException(`Aborted`,`AbortError`));if(t.aborted)return i();t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})}):e}function Dr(e,t){return e===`refused`?new kr(t):new Tr}function Or(e){let t=e?.status;return t===401||t===403||t===404}var kr=class extends Error{name=`SessionExpiredError`;constructor(e){super(e instanceof Error?e.message:`The session has expired.`)}};function Ar(e){return e?.status===401}function jr(e,t){return new Promise(n=>{let r=setTimeout(n,t);e.then(()=>{clearTimeout(r),n()})})}var Mr=class{config;state;listeners=new Set;sessionToken=null;sessionTokenExpiresAt=null;tokenRenewal=null;renewalGeneration=0;sendEpoch=0;getSessionToken;conversationId=null;storageIdentifier;activeRequestController=null;slowResponseTimer=null;announcementTimer=null;prefersReducedMotion;launcher;launcherIconUrl;emptyStateImageUrl;emptyStateImageAlt;notice;requireNoticeAgreement;noticePlacement;subtitle;greetingStyle;showFeedback;text;language;languageTag;contentLanguage;dir;constructor(e){this.config=e;let t=ce(e.theme).launcher,n=t.iconUrl??r(e.launcherIconUrl,`launcherIconUrl`);this.launcher={...t,...n?{iconUrl:n}:{}},this.launcherIconUrl=n,this.emptyStateImageUrl=r(e.emptyStateImageUrl,`emptyStateImageUrl`),this.emptyStateImageAlt=typeof e.emptyStateImageAlt==`string`?e.emptyStateImageAlt.trim():``,this.notice=typeof e.notice==`string`&&!f(e.notice)?e.notice.trim():``,this.requireNoticeAgreement=e.requireNoticeAgreement===!0&&this.notice!==``,e.requireNoticeAgreement===!0&&!this.notice&&console.warn("whoo-aiden-widget: `requireNoticeAgreement` has no effect without a `notice`, so it is ignored."),this.noticePlacement=te(e.noticePlacement),this.subtitle=typeof e.subtitle==`string`&&!f(e.subtitle)?e.subtitle.trim():``,this.greetingStyle=ee(e.greetingStyle),this.showFeedback=e.showFeedback===!0,this.storageIdentifier=e.publishableKey??`session-token-mode`,this.getSessionToken=h(e);let{language:i,tag:a,dir:o}=Ft(e.language,typeof document>`u`?void 0:document.documentElement.lang);this.language=i,this.languageTag=a,this.dir=o,this.contentLanguage=Rt(e.contentLanguage,typeof document>`u`?void 0:document.documentElement.lang,e.language),this.text={...Nt(i),...x(e.messages)},this.prefersReducedMotion=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,this.state={isOpen:!1,messages:[],isStreaming:!1,initError:null,isInitializing:!1,runtimeError:null,messageFeedback:{},primaryColor:null,agentName:null,accentColor:null,inkColor:null,announcement:null,announcementIsContent:!1,isSlowResponse:!1,noticeAgreed:!this.requireNoticeAgreement||Yn(this.storageIdentifier,this.notice),draft:``}}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}get resolvedAgentName(){return d(this.config.name)||this.state.agentName||`Aiden`}announce(e,t=!1,n=!1){this.announcementTimer!==null&&(clearTimeout(this.announcementTimer),this.announcementTimer=null),n&&e!==null&&this.state.announcement!==e?this.setState({announcement:e,announcementIsContent:t}):(this.state.announcement!==null&&this.setState({announcement:null}),e!==null&&(this.announcementTimer=setTimeout(()=>{this.announcementTimer=null,this.setState({announcement:e,announcementIsContent:t})},250)))}clearSlowResponse(){this.slowResponseTimer!==null&&(clearTimeout(this.slowResponseTimer),this.slowResponseTimer=null),this.state.isSlowResponse&&this.setState({isSlowResponse:!1})}setState(e){this.state={...this.state,...e};for(let e of this.listeners)e(this.state)}async init(){this.setState({isInitializing:!0});try{await this.start()}finally{this.setState({isInitializing:!1})}}async start(){let e=this.config.apiBaseUrl??`https://api.aidenvoice.com`;try{if(this.config.sessionToken){if(Un(this.config.sessionToken)){if(!(`token`in await this.renewToken()))throw Error(`The sessionToken has expired.`)}else this.sessionToken=this.config.sessionToken,this.sessionTokenExpiresAt=Hn(this.config.sessionToken)}else if(this.config.publishableKey){let{token:t,primaryColor:n,name:r,accentColor:i,inkColor:a}=await kn(e,this.config.publishableKey);this.sessionToken=t,this.sessionTokenExpiresAt=Wn(t),this.setState({primaryColor:n,agentName:r,accentColor:i,inkColor:a})}else throw Error(`WidgetConfig must include exactly one of publishableKey or sessionToken`)}catch(e){console.error(`[whoo-aiden-widget] initialization failed:`,e),this.setState({initError:e instanceof Error?e.message:String(e)});return}this.conversationId=Kn(this.storageIdentifier),this.config.sessionToken&&await jr(this.loadBranding(e),Cr)}async loadBranding(e){try{let t=this.config;if(Z(t.color)&&Z(t.inkColor)&&Z(t.accentColor)&&d(t.name))return;let{primaryColor:n,name:r,accentColor:i,inkColor:a}=await this.withSession(t=>jn(e,t));this.setState({primaryColor:n,agentName:r,accentColor:i,inkColor:a})}catch(e){let t=e?.status;(e instanceof kr||t===401||t===403)&&(this.state.isInitializing?(console.error(`[whoo-aiden-widget] initialization failed:`,e),this.setState({initError:e instanceof Error?e.message:String(e)})):(console.error(`[whoo-aiden-widget] the session was refused after start-up:`,e),this.setState({runtimeError:this.text.sessionExpired})))}}open(){this.setState({isOpen:!0})}resetConversation(){this.sendEpoch+=1,this.activeRequestController?.abort(`reset`),this.activeRequestController=null,this.clearSlowResponse(),this.conversationId=null,Zn(this.storageIdentifier),this.setState({messages:[],messageFeedback:{},runtimeError:null,isStreaming:!1}),this.announce(this.text.conversationCleared)}agreeToNotice(){this.state.noticeAgreed||(Xn(this.storageIdentifier,this.notice),this.setState({noticeAgreed:!0}))}setDraft(e){this.setState({draft:e})}close(){this.activeRequestController?.abort(`close`),this.activeRequestController=null,this.clearSlowResponse(),this.announce(null),this.setState({isOpen:!1})}async sendMessage(e){if(!this.sessionToken||!this.state.noticeAgreed)return;let t=this.config.apiBaseUrl??`https://api.aidenvoice.com`;this.sendEpoch+=1;let n=this.sendEpoch,r=()=>n===this.sendEpoch,i={role:`user`,content:e,id:null},a={role:`assistant`,content:``,id:null};this.setState({messages:[...this.state.messages,i,a],isStreaming:!0,runtimeError:null}),this.announce(Bt(this.text.messageSent,{name:this.resolvedAgentName}),!1,!0);let o=a,s=e=>{let t=o;o={...o,...e},this.setState({messages:this.state.messages.map(e=>e===t?o:e)})},c=e=>s({content:e}),l=new AbortController;this.activeRequestController=l;let{signal:u}=l,d=!1;this.slowResponseTimer=setTimeout(()=>{this.slowResponseTimer=null,this.setState({isSlowResponse:!0}),r()&&this.announce(this.text.lookingItUp)},Sr);let f=!1,p=()=>{this.state.draft===``&&(f=!0,this.setState({draft:e}))},m=!1,h=e=>{m=!0,this.announce(Fn(e),!0)},g=(e=this.text.genericError)=>{r()&&(m||(m=!0,this.announce(null)),this.setState({runtimeError:e}),p())},_=``;try{let{stream:n,first:i}=await this.withSession(async n=>{d=!0;let r=Nn(t,n,this.conversationId,e,u);return{stream:r,first:await r.next()}},u);for(let e=i;!e.done&&!u.aborted&&r();e=await n.next()){let t=e.value;if(t.type===`conversation_id`)this.conversationId=t.conversationId,qn(this.storageIdentifier,t.conversationId);else if(t.type===`delta`)this.clearSlowResponse(),t.verbatim&&!this.prefersReducedMotion?(await Bn(t.delta,e=>c(e),{signal:u}),_=t.delta):t.verbatim?(_=t.delta,c(_)):(_+=t.delta,c(_));else if(t.type===`done`)t.conversationId&&(this.conversationId=t.conversationId,qn(this.storageIdentifier,t.conversationId)),t.messageId&&s({id:t.messageId}),r()&&h(_);else if(t.type===`error`){console.error(`[whoo-aiden-widget] chat error:`,t.error),_.trim()!==``&&r()&&h(_),g(),l.abort();break}}}catch(e){u.aborted?u.reason===`close`&&r()&&!d&&p():e instanceof kr?(console.error(`[whoo-aiden-widget] chat request failed: the session has expired.`,e),g(this.text.sessionExpired)):e instanceof Tr?(console.error(`[whoo-aiden-widget] chat request failed: no session could be had.`),g()):(console.error(`[whoo-aiden-widget] chat request failed:`,e),g())}finally{let e=o.id===null&&o.content.trim()===``,t=this.state.messages.filter(t=>!(e&&t===o)&&!(e&&f&&t===i)),n=t.length!==this.state.messages.length;r()?(this.activeRequestController=null,this.clearSlowResponse(),m||(!u.aborted&&_.trim()!==``?h(_):this.announce(null)),this.setState({isStreaming:!1,...n?{messages:t}:{}})):n&&this.setState({messages:t})}}expandFeedback(e){let{correction:t,category:n}=this.state.messageFeedback[e]??{};this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`expanded`,correction:t,category:n}}})}setFeedbackDraft(e,t,n){this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{...this.state.messageFeedback[e],correction:t,category:n}}})}cancelFeedback(e){this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`idle`}}})}async submitFeedback(e,t,n,r){if(!this.sessionToken)return;let i=this.config.apiBaseUrl??`https://api.aidenvoice.com`;this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`submitting`,rating:t}}});try{await this.withSession(a=>Mn(i,a,{messageId:e,rating:t,correction:n,category:r})),this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`submitted`,rating:t}}})}catch(i){console.error(`[whoo-aiden-widget] feedback submission failed:`,i),this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`error`,rating:t,correction:n,category:r}}})}}async currentToken(e){let t=this.sessionToken,n=this.sessionTokenExpiresAt;return t&&(n===null||n-Date.now()>6e4)?{token:t}:Er(this.renewToken(),e)}renewToken(){return this.tokenRenewal??=this.fetchNewToken().finally(()=>{this.tokenRenewal=null}),this.tokenRenewal}async fetchNewToken(){let e=++this.renewalGeneration,t,n=new Promise(e=>{t=setTimeout(()=>{console.error(`[whoo-aiden-widget] could not renew the session: it took too long.`),e({failure:`unavailable`})},wr)});try{return await Promise.race([this.obtainToken(e),n])}finally{clearTimeout(t)}}async obtainToken(e){let t=this.config.apiBaseUrl??`https://api.aidenvoice.com`,n;try{if(this.config.publishableKey)n=(await kn(t,this.config.publishableKey)).token;else if(this.getSessionToken)n=await this.getSessionToken();else return{failure:`refused`}}catch(e){return console.error(`[whoo-aiden-widget] could not renew the session:`,e),{failure:this.config.publishableKey&&Or(e)?`refused`:`unavailable`}}let r=typeof n==`string`?Wn(n):null;return typeof n!=`string`||n===``||r!==null&&r<=Date.now()?(console.error(`[whoo-aiden-widget] could not renew the session: no usable token was returned.`),{failure:`refused`}):(e===this.renewalGeneration&&(this.sessionToken=n,this.sessionTokenExpiresAt=r),{token:n})}async withSession(e,t){let n=await this.currentToken(t);if(!(`token`in n))throw Dr(n.failure);let{token:r}=n;try{return await e(r)}catch(n){if(!Ar(n))throw n;let i=this.sessionToken&&this.sessionToken!==r?{token:this.sessionToken}:await Er(this.renewToken(),t);if(!(`token`in i))throw Dr(i.failure,n);try{return await e(i.token)}catch(e){throw Ar(e)?new kr(e):e}}}},$=20,Nr=12,Pr=300,Fr=352;function Ir(){try{return typeof CSS<`u`&&CSS.supports?.(`height`,`100dvh`)?`dvh`:`vh`}catch{return`vh`}}function Lr(e,t){let{offsetX:n,offsetY:r,launcherSize:i,panelWidth:a,panelHeight:o,cornerRadius:s}=ue(t.layout),c=e=>typeof t.layout?.offset?.[e]==`number`;if(typeof window<`u`&&window.innerWidth>0&&window.innerHeight>0){let e=Math.max($,window.innerWidth-Pr),t=Math.max($,window.innerHeight-i-Fr);c(`x`)&&(n>e||n>window.innerWidth-i)&&console.warn(`whoo-aiden-widget: \`layout.offset.x\` ${n} leaves no room for the launcher and panel in this viewport; it is held back.`),c(`y`)&&(r>t||r>window.innerHeight-i)&&console.warn(`whoo-aiden-widget: \`layout.offset.y\` ${r} leaves no room for the launcher and panel in this viewport; it is held back.`)}let l=`100${Ir()}`,u=`min(${n}px, max(${$}px, calc(100vw - ${Pr}px)), calc(100vw - ${i}px))`,d=`min(${r}px, max(${$}px, calc(${l} - ${i+Fr}px)), calc(${l} - ${i}px))`,f=`calc(${d} + ${i}px + ${Nr}px)`,p=t.position===`bottom-left`,m=(t,n)=>e.style.setProperty(t,n);m(`--whoo-widget-inset-left`,p?u:`auto`),m(`--whoo-widget-inset-right`,p?`auto`:u),m(`--whoo-widget-inset-bottom`,d),m(`--whoo-widget-launcher-size`,`${i}px`),m(`--whoo-widget-panel-bottom`,f),m(`--whoo-widget-panel-width`,`${a}px`),m(`--whoo-widget-panel-height`,`${o}px`),m(`--whoo-widget-panel-max-width`,`calc(100vw - ${u} - ${$}px)`),m(`--whoo-widget-panel-max-height`,`calc(${l} - ${f} - ${$}px)`),s===void 0?e.style.removeProperty(`--whoo-widget-corner-radius`):m(`--whoo-widget-corner-radius`,`${s}px`)}var Rr=`:host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:var(--whoo-widget-inset-bottom,20px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-launcher-size,56px);height:var(--whoo-widget-launcher-size,56px);background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{width:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);height:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);display:block}.whoo-widget-launcher-icon-image{width:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);height:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);object-fit:cover;border-radius:50%}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:var(--whoo-widget-panel-bottom,88px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-panel-width,360px);height:var(--whoo-widget-panel-height,480px);max-width:var(--whoo-widget-panel-max-width,calc(100vw - 40px));max-height:var(--whoo-widget-panel-max-height,calc(100vh - 108px));background:var(--whoo-widget-panel,#fff);border-radius:var(--whoo-widget-corner-radius,12px);font-family:var(--whoo-widget-font,-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);color:inherit;border:none;flex-direction:column;margin:0;padding:0;display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}button,input,textarea,select{font-family:inherit}.whoo-widget-panel:not([open]){display:none}.whoo-widget-panel::backdrop{background:0 0}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + max(8px, var(--whoo-widget-visible-height,100%) - 8px - var(--whoo-widget-panel-height,480px)));height:min(var(--whoo-widget-panel-height,480px), calc(var(--whoo-widget-visible-height,100%) - 16px));max-height:none;bottom:auto}@media (width<=400px),(height<=420px){.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + 8px);height:calc(var(--whoo-widget-visible-height,100%) - 16px)}}.whoo-widget-header{border-bottom:1px solid var(--whoo-widget-border,#e5e5e5);flex-wrap:wrap;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;max-height:50%;padding-block:8px;padding-inline:16px 8px;display:flex;overflow-y:auto}.whoo-widget-header-titles{flex:10em;min-width:0}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;margin:0;font-size:15px;font-weight:600}.whoo-widget-header-subtitle{color:var(--whoo-widget-muted,#4b5563);overflow-wrap:anywhere;margin:2px 0 0;font-size:13px}.whoo-widget-header-actions{background:var(--whoo-widget-panel,#fff);flex-shrink:0;align-items:center;gap:4px;margin-inline-start:auto;display:flex;position:sticky;bottom:0}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:var(--whoo-widget-header-hover,#f3f4f6)}.whoo-widget-message-list{overscroll-behavior:contain;flex:1;min-height:0;padding:12px;overflow-y:auto}.whoo-widget-message-list:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:-2px;box-shadow:inset 0 0 0 4px var(--whoo-widget-panel,#fff)}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}.whoo-widget-message-list--centered{flex-direction:column;display:flex}.whoo-widget-empty-state{margin-block:auto}.whoo-widget-empty-state-greeting{color:var(--whoo-widget-ink,#111);text-align:center;overflow-wrap:anywhere;white-space:pre-line}.whoo-widget-empty-state-greeting a{color:var(--whoo-widget-link-color,#00e)}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-notice{border:1px solid var(--whoo-widget-border,#e5e5e5);color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;margin-bottom:12px;padding:8px 12px}.whoo-widget-notice a,.whoo-widget-notice-footer a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-message{overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-message-text,.whoo-widget-message-text li{unicode-bidi:plaintext}.whoo-widget-list{margin:4px 0;padding-inline-start:0}.whoo-widget-list li{margin-inline-start:20px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-inline-start:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{background:var(--whoo-widget-assistant-bubble,#f0f0f0);color:var(--whoo-widget-ink,#111)}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:var(--whoo-widget-typing-dots,#6b7280);border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{background:var(--whoo-widget-error-bg,#fee2e2);color:var(--whoo-widget-error-text,#991b1b);padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid var(--whoo-widget-border,#e5e5e5);gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:var(--whoo-widget-corner-radius,6px);unicode-bidi:plaintext;flex:1;min-width:0;padding:8px;font-size:16px}.whoo-widget-agreement{border-top:1px solid var(--whoo-widget-border,#e5e5e5);padding:12px}.whoo-widget-agreement-button{border-radius:var(--whoo-widget-corner-radius,6px);background:var(--whoo-widget-color,#4f46e5);width:100%;min-height:44px;color:var(--whoo-widget-text-on-color,#fff);overflow-wrap:anywhere;cursor:pointer;border:none;padding:8px 16px;font-weight:600;display:block}.whoo-widget-composer-send{border-radius:var(--whoo-widget-corner-radius,6px);background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;padding:8px 16px}.whoo-widget-composer-input::placeholder{color:var(--whoo-widget-muted,#4b5563);opacity:1}.whoo-widget-notice-footer{overscroll-behavior:contain;border-top:1px solid var(--whoo-widget-border,#e5e5e5);min-height:0;max-height:25%;color:var(--whoo-widget-muted,#4b5563);text-align:center;overflow-wrap:anywhere;white-space:pre-line;flex:0 auto;padding:8px 16px;font-size:12px;line-height:1.4;overflow-y:auto}.whoo-widget-notice-footer:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:-2px;box-shadow:inset 0 0 0 4px var(--whoo-widget-panel,#fff)}.whoo-widget-composer-send[aria-disabled=true],.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:var(--whoo-widget-muted,#4b5563);background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:var(--whoo-widget-text,#111);background:#0000000f}.whoo-widget-feedback-buttons button[aria-disabled=true]{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;border:1px solid var(--whoo-widget-input-border,#6b7280);resize:vertical;unicode-bidi:plaintext;border-radius:6px;width:100%;padding:6px;font-size:16px}.whoo-widget-feedback-select{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;height:2em;min-height:24px;padding:4px;font-size:16px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{border:1px solid var(--whoo-widget-input-border,#6b7280);background:var(--whoo-widget-panel,#fff);color:var(--whoo-widget-text,#111);cursor:pointer;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:var(--whoo-widget-muted,#4b5563);margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:var(--whoo-widget-error-text,#991b1b);font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:2px;box-shadow:0 0 0 4px var(--whoo-widget-panel,#fff)}@media (forced-colors:active){.whoo-widget-message{border:1px solid canvastext}.whoo-widget-launcher,.whoo-widget-header-close,.whoo-widget-header-reset,.whoo-widget-composer-send,.whoo-widget-agreement-button,.whoo-widget-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}`;function zr(e){let t=document.createElement(`div`);t.id=`whoo-aiden-widget-host`,t.style.position=`relative`,t.style.zIndex=String(l(e.zIndex));let n=t.attachShadow({mode:`open`}),r=document.createElement(`style`);r.textContent=Rr,n.appendChild(r);let i=document.createElement(`div`);n.appendChild(i);let a=new Set;xr(i,e,a),Lr(i,e);let o=new Mr(e);i.setAttribute(`lang`,o.languageTag),i.setAttribute(`dir`,o.dir);let s=Z(e.color)!==null,c=null,u=``,d=ce(e.theme).colors,f=Object.keys(d).length>0,p={color:e.color,inkColor:e.inkColor,accentColor:e.accentColor};return o.subscribe(t=>{let n=!1;!s&&t.primaryColor&&t.primaryColor!==c&&(c=t.primaryColor,hr(i,t.primaryColor,e.color),Z(t.primaryColor)&&(p={...p,color:t.primaryColor}),n=!0);let r=`${t.inkColor}|${t.accentColor}`;if((t.inkColor||t.accentColor)&&r!==u){u=r;let a=Z(e.inkColor)?e.inkColor:t.inkColor,o=Z(e.accentColor)?e.accentColor:t.accentColor;gr(i,{inkColor:a,accentColor:o}),p={...p,inkColor:a,accentColor:o},n=!0}n&&(_r(i,d),f&&br({...p,overrides:d},a))}),o.init(),Ue(K(En,{controller:o}),i),document.body.appendChild(t),{unmount(){Ue(null,i),t.remove()}}}function Br(e){return p(e),zr(e)}return e.init=Br,e})({});
|