@aiden-voice/widget 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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`,send:`Send`,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:`Conversation cleared`,genericError:`Something went wrong, please try again.`,sessionExpired:`This chat session has expired. Reload the page to continue.`,opensInNewTab:`(opens in new tab)`},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){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 p(e){console.warn(`whoo-aiden-widget: ${e}`)}function m(e){let{getSessionToken:t}=e;if(t!==void 0){if(typeof t!=`function`){p("ignoring `getSessionToken` -- expected a function that returns a session token.");return}if(!e.sessionToken){p("ignoring `getSessionToken` -- it is only used with `sessionToken`; with `publishableKey` the widget renews its session by itself.");return}return t}}var h=20;function g(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>=h&&n.delete(n.values().next().value),n.add(r)}p(e)}}var _=g("ignoring `theme` -- expected an object."),v=g("ignoring `layout` -- expected an object."),y=g("ignoring `messages` -- expected an object.");function b(e){if(e==null)return{};if(!x(e))return y(e),{};let t={};for(let r of Object.keys(e)){if(!n.includes(r)){p(`ignoring unknown option \`messages.${r}\`.`);continue}let i=e[r];if(typeof i!=`string`||/^[\p{White_Space}\p{Cf}\p{M}]*$/u.test(i)){p(`ignoring \`messages.${r}\` -- expected a non-blank string.`);continue}r===`chatWith`&&!i.includes(`{name}`)&&p("`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)||p(`ignoring inherited option \`messages.${t}\` -- only the object's own keys are used.`);return t}function x(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var S=e=>e==null||e===``;function C(e,t,n){let r=e[t];return r==null?null:x(r)?r:(p(`ignoring \`${n}\` -- expected an object.`),null)}function w(e,t,n){for(let r of Object.keys(e))t.includes(r)||p(`ignoring unknown option \`${n}.${r}\`.`)}function T(e,t,n){if(!S(e)){if(typeof e==`string`&&t.includes(e))return e;p(`ignoring \`${n}\` -- expected one of ${t.join(`, `)}.`)}}var E=200,D=/url\(|[@;{}\\]/i;function O(e){if(!S(e)){if(typeof e==`string`){let t=e.trim();if(t&&t.length<=E&&!D.test(t))return t}p(`ignoring \`theme.fonts.family\` -- expected a font-family stack of at most ${E} characters, without url(), @, ;, {, } or \\.`)}}var k=[`chat`,`message`,`sparkle`],A=[`chevron-down`,`close`],ee=new WeakMap;function te(e){let t={colors:{},fontFamily:void 0,launcher:{}};if(e==null)return t;if(!x(e))return _(e),t;let n=ee.get(e);if(n)return n;w(e,[`colors`,`fonts`,`launcher`],`theme`);let a=C(e,`colors`,`theme.colors`);if(a){w(a,i,`theme.colors`);for(let e of i){let n=a[e];S(n)||(typeof n==`string`?t.colors[e]=n:p(`ignoring \`theme.colors.${e}\` -- expected a CSS color string.`))}}let o=C(e,`fonts`,`theme.fonts`);o&&(w(o,[`family`],`theme.fonts`),t.fontFamily=O(o.family));let s=C(e,`launcher`,`theme.launcher`);if(s){w(s,[`icon`,`iconUrl`,`openIcon`,`openIconUrl`],`theme.launcher`);let e=T(s.icon,k,`theme.launcher.icon`),n=r(s.iconUrl,`theme.launcher.iconUrl`),i=T(s.openIcon,A,`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 ee.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:(p(`ignoring \`${t}\` -- expected a non-negative number of pixels; using ${n}.`),n)}function ne(e,t,n,r){let i=Math.min(r,Math.max(n,e));return i!==e&&p(`\`${t}\` ${e} is out of range (${r===1/0?`at least ${n}`:`${n}-${r}`}); using ${i}.`),i}var re=new WeakMap;function ie(e){let t={...j};if(e==null)return t;if(!x(e))return v(e),t;let n=re.get(e);if(n)return n;w(e,[`offset`,`launcherSize`,`panel`],`layout`);let r=C(e,`offset`,`layout.offset`);r&&(w(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=ne(M(e.launcherSize,`layout.launcherSize`,j.launcherSize),`layout.launcherSize`,24,120);let i=C(e,`panel`,`layout.panel`);return i&&(w(i,[`width`,`height`],`layout.panel`),t.panelWidth=ne(M(i.width,`layout.panel.width`,j.panelWidth),`layout.panel.width`,280,1/0),t.panelHeight=ne(M(i.height,`layout.panel.height`,j.panelHeight),`layout.panel.height`,320,1/0)),re.set(e,t),t}var N,ae,P,oe,se,ce,le,F,ue,de,fe,pe,I={},L=[],me=/^m(i|n|o|s|text|space)$/,he=Array.isArray,ge=L.slice,R=Object.assign;function _e(e){e&&e.parentNode&&e.remove()}function ve(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||++ae,__i:-1,__u:0};return!i&&N.vnode&&N.vnode(a),a}function z(e){return e.children}function ye(e,t){this.props=e,this.context=t,this.__g=0}function B(e,t){if(t==null)return e.__?B(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:B(e)}function be(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),be(e)}function xe(e){(8&e.__g||!(e.__g|=8)||!P.push(e)||se++)&&oe==N.debounceRendering||((oe=N.debounceRendering)||queueMicrotask)(Se)}function Se(){var e,t,n,r,i,a,o,s,c;try{for(t=1;P.length;)P.length>t&&P.sort(ce),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=R({constructor:void 0},i)).__v=i.__v+1,N.vnode&&N.vnode(r),Ae(c,r,i,n.__n,c.namespaceURI,32&i.__u?[a]:null,o,a||B(i),32&i.__u,s),r.__v=i.__v,r.__.__k[r.__i]=r,Me(o,r,s),i.__=i.__e=null,r.__e!=a&&be(r)))}finally{P.length=se=0}}function Ce(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r.__k||L,v=t.length;for(c=we(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=~p.__i&&_[p.__i]||I,p.__i=d,g=Ae(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&(f.ref!=p.ref||8&f.__u)&&(f.ref!=p.ref&&f.ref&&Pe(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h||=m,4&p.__u?(c=Te(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 we(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]=ve(null,o):he(o)?o=y[a]=ve(z,{children:o}):o.constructor===void 0&&o.__b?o=y[a]=ve(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=Ee(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=B(s)),Fe(s,s));return r}function Te(e,t,n,r){var i,a;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=Te(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=B(e))&&!t.parentNode&&(t=null),e.__e!=t&&(!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 Ee(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 De(e,t,n){n??=``,t[0]==`-`?e.setProperty(t,n):e[t]=n}function Oe(e,t,n,r,i){var a;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||De(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||De(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(ue,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),(e.__e||={})[t+a]=n,n?r?n[F]=r[F]:(n[F]=de,e.addEventListener(t,a?pe:fe,a)):e.removeEventListener(t,a?pe:fe,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 ke(e){return function(t){if(this.__e){var n=this.__e[t.type+e];if(t[le]==null)t[le]=de++;else if(t[le]<n[F])return;return n(N.event?N.event(t):t)}}}function Ae(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 ye(y,S),h.constructor=A,h.render=Ie),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=R({},h.__s)),R(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)}),L.push.apply(h.__h,h.__k),h.__k=[],h.__h.length&&o.push(h),s=B(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),L.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=R({},r,h.getChildContext())),b&&n.__c&&h.getSnapshotBeforeUpdate&&(v=h.getSnapshotBeforeUpdate(g,_)),T=u&&u.type===z&&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&&Fe(e,e)}),n.__k=null),s=n.__k?B(n,0):null),s=Ce(e,he(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(_e),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=0;O<a.length;O++)if(k=a[O]){if(k.nodeType==8){if(a[O]=null,k.data.startsWith(`$s`))E++||(D=k);else if(k.data.startsWith(`/$s`)&&!--E){s=k;break}}else E&&(a[O]=null)}}if(!D){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a&&(a[a.indexOf(s)]=null),D=s}t.__c.__z||(t.__c.__z=D),t.__e=s}else a&&a.some(_e)}else t.__e=n.__e;t.__k||=n.__k||[],e.then||je(t),N.__e(e,t,n)}}else s=t.__e=Ne(n.__e,t,n,r,i,a,o,c,l,e);return(u=N.diffed)&&u(t),128&t.__u?void 0:s}function je(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(je))}function Me(e,t,n){for(var r=0;r<n.length;)Pe(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 Ne(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y=n.props||I,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&&ge.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||Oe(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)||Oe(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`&&me.test(x))&&(i=`http://www.w3.org/1999/xhtml`),Ce(l,he(p)?p:[p],t,n,r,i,a,o,a?a[0]:n.__k&&B(n,0),s,c),a&&a.some(_e)),s&&x!=`textarea`||(u=`value`,x==`progress`&&h==null?e.removeAttribute(u):h==null||h===e[u]&&(x!=`progress`||h)||Oe(e,u,h,y[u],i),u=`checked`,g!=null&&g!=e[u]&&Oe(e,u,g,y[u],i))}else y===b||s&&e.data==b||(e.data=b);return e}function Pe(e,t,n){try{typeof e==`function`?(typeof e.__u==`function`&&e.__u(),(typeof e.__u!=`function`||t)&&(e.__u=e(t))):e.current=t}catch(e){N.__e(e,n)}}function Fe(e,t,n){var r,i;if(N.unmount&&N.unmount(e),!(r=e.ref)||r.current&&r.current!=e.__e||Pe(r,null,t),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]&&Fe(r[i],t,typeof e.type!=`function`||n&&!e.props.__P);(r=e.__e)&&(n||_e(r),r.__e&&(r.__e=null)),e.__e=e.__c=e.__=null}function Ie(e,t,n){return this.constructor(e,n)}function Le(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=ve(z,{children:[e]}),i=[],a=[],Ae(t,t.__k,r||I,I,t.namespaceURI,r?null:t.firstChild?ge.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a),Me(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 se=0,e}},ae=0,ye.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=R({},this.state)),typeof e==`function`&&(e=e(R({},n),this.props)),e&&(R(n,e),this.__v&&(t&&this.__k.push(t),xe(this)))},ye.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),xe(this))},ye.prototype.render=z,P=[],se=0,ce=function(e,t){return e.__v.__b-t.__v.__b},le=Symbol(),F=Symbol(),ue=/(PointerCapture)$|Capture$/i,de=0,fe=ke(!1),pe=ke(!0);var V,H,Re,ze,Be=Object.is,Ve=0,He=[],Ue=[],U=N,We=U.__b,Ge=U.__r,Ke=U.diffed,qe=U.__c,Je=U.unmount,Ye=U.__;function Xe(e,t){U.__h&&U.__h(H,e,Ve||t),Ve=0;var n=H.__H||(H.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Ze(e){return Ve=1,Qe(ct,e)}function Qe(e,t,n){var r=Xe(V++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ct(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);Be(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=H,!H.__f)){H.__f=!0;var i=H.shouldComponentUpdate;H.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,Be(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 $e(e,t){var n=Xe(V++,3);!U.__s&&st(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,H.__H.__h.push(n))}function et(e,t){var n=Xe(V++,4);!U.__s&&st(n.__H,t)&&(n.__P=!1,n.__=e,n.u=t,H.__h.push(n))}function W(e){return Ve=5,tt(function(){return{current:e}},[])}function tt(e,t){var n=Xe(V++,7);return st(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function nt(){var e;do{for(;e=Ue.shift();)try{G(e)}catch(t){U.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=He.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(G),t.__h.some(ot),t.__h=[]}catch(n){t.__h=[],U.__e(n,e.__v)}}}while(Ue.length)}U.__b=function(e){H=null,We&&We(e)},U.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ye&&Ye(e,t)},U.__r=function(e){Ge&&Ge(e),V=0;var t=(H=e.__c).__H;t&&(Re==H?H.__h=[]:(t.__h.some(G),t.__h.some(ot),V=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),Re=H},U.diffed=function(e){Ke&&Ke(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&at(He.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),Re=H=null},U.__c=function(e,t){t.some(function(e){try{e.__h.some(G),e.__h=e.__h.filter(function(e){return!e.__||ot(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],U.__e(n,e.__v)}}),qe&&qe(e,t)},U.unmount=function(e){Je&&Je(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,at(Ue.push(r))}else G(r)}catch(e){t=e}}),r.__H=void 0,t&&U.__e(t,r.__v))};var rt=typeof requestAnimationFrame==`function`;function it(e){var t,n=function(){clearTimeout(r),rt&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);rt&&(t=requestAnimationFrame(n))}function at(e){e!=1&&ze==U.requestAnimationFrame||((ze=U.requestAnimationFrame)||it)(nt)}function G(e){var t=H,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),H=t}function ot(e){var t=H;e.__c=e.__(),H=t}function st(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!Be(t,e[n])})}function ct(e,t){return typeof t==`function`?t(e):t}var lt=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:void 0,__v:--lt,__i:-1,__u:0};return(i||a)&&(l.__source=i,l.__self=a),N.vnode&&N.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 ut({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 dt({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 ft({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 pt({size:e=26}){return K(q,{name:`chevron-down`,size:e,children:K(`path`,{d:`M6 9l6 6 6-6`})})}function mt({size:e=18}){return K(q,{name:`close`,size:e,children:K(`path`,{d:`M6 6l12 12M18 6L6 18`})})}var ht=`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 gt({size:e=16}){return K(q,{name:`thumb-up`,size:e,children:K(`path`,{d:ht})})}function _t({size:e=16}){return K(q,{name:`thumb-down`,size:e,children:K(`path`,{d:ht,transform:`matrix(1 0 0 -1 0 24)`})})}var vt={chat:ut,message:dt,sparkle:ft},yt={"chevron-down":pt,close:mt};function bt({isOpen:e,onClick:n,iconUrl:r,icon:i=`chat`,openIconUrl:a,openIcon:o=`chevron-down`,buttonRef:s,text:c=t}){let[l,u]=Ze(`loading`),[d,f]=Ze(`loading`),p=r!==void 0&&l!==`failed`,m=a!==void 0&&d!==`failed`,h=p&&!e&&l===`loaded`,g=m&&e&&d===`loaded`,_=vt[i]??ut,v=yt[o]??pt;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 xt={en:t,fr:{openChat:`Ouvrir le chat`,closeChat:`Fermer le chat`,chatWith:`Discuter avec {name}`,newConversation:`Nouvelle conversation`,conversation:`Conversation`,you:`Vous`,message:`Message`,send:`Envoyer`,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:`Conversation effacée`,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)`},es:{openChat:`Abrir chat`,closeChat:`Cerrar chat`,chatWith:`Chat con {name}`,newConversation:`Nueva conversación`,conversation:`Conversación`,you:`Usted`,message:`Mensaje`,send:`Enviar`,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`,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)`},pt:{openChat:`Abrir chat`,closeChat:`Fechar chat`,chatWith:`Conversa com {name}`,newConversation:`Nova conversa`,conversation:`Conversa`,you:`Você`,message:`Mensagem`,send:`Enviar`,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`,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)`},de:{openChat:`Chat öffnen`,closeChat:`Chat schließen`,chatWith:`Chat mit {name}`,newConversation:`Neue Unterhaltung`,conversation:`Unterhaltung`,you:`Sie`,message:`Nachricht`,send:`Senden`,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`,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)`},it:{openChat:`Apri la chat`,closeChat:`Chiudi la chat`,chatWith:`Chat con {name}`,newConversation:`Nuova conversazione`,conversation:`Conversazione`,you:`Tu`,message:`Messaggio`,send:`Invia`,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`,genericError:`Si è verificato un errore. Riprovi.`,sessionExpired:`Questa sessione di chat è scaduta. Ricarichi la pagina per continuare.`,opensInNewTab:`(si apre in una nuova scheda)`},ja:{openChat:`チャットを開く`,closeChat:`チャットを閉じる`,chatWith:`{name}とチャット`,newConversation:`新しい会話`,conversation:`会話`,you:`あなた`,message:`メッセージ`,send:`送信`,lookingItUp:`確認しています…`,goodResponse:`良い回答`,badResponse:`良くない回答`,additionalFeedback:`追加のフィードバック`,feedbackPlaceholder:`何が問題でしたか?(任意)`,feedbackCategory:`フィードバックの種類`,selectReason:`理由を選択(任意)`,categoryFactual:`事実の誤り`,categoryIncomplete:`回答が不十分`,categoryTone:`不適切な口調`,categoryOther:`その他`,submit:`フィードバックを送信`,cancel:`キャンセル`,feedbackThanks:`フィードバックありがとうございます`,feedbackFailed:`フィードバックを送信できませんでした`,conversationCleared:`会話を消去しました`,genericError:`エラーが発生しました。もう一度お試しください。`,sessionExpired:`このチャットセッションの有効期限が切れました。続けるにはページを再読み込みしてください。`,opensInNewTab:`(新しいタブで開きます)`},zh:{openChat:`打开聊天`,closeChat:`关闭聊天`,chatWith:`与{name}聊天`,newConversation:`新对话`,conversation:`对话`,you:`您`,message:`消息`,send:`发送`,lookingItUp:`正在为您查找……`,goodResponse:`回答很好`,badResponse:`回答不好`,additionalFeedback:`补充反馈`,feedbackPlaceholder:`哪里有问题?(可选)`,feedbackCategory:`反馈类别`,selectReason:`选择原因(可选)`,categoryFactual:`事实错误`,categoryIncomplete:`回答不完整`,categoryTone:`语气不当`,categoryOther:`其他`,submit:`提交`,cancel:`取消`,feedbackThanks:`感谢您的反馈`,feedbackFailed:`反馈提交失败`,conversationCleared:`对话已清除`,genericError:`出了点问题,请重试。`,sessionExpired:`此聊天会话已过期。请刷新页面后继续。`,opensInNewTab:`(将在新标签页中打开)`},ru:{openChat:`Открыть чат`,closeChat:`Закрыть чат`,chatWith:`Чат с ассистентом {name}`,newConversation:`Новый диалог`,conversation:`Диалог`,you:`Вы`,message:`Сообщение`,send:`Отправить`,lookingItUp:`Ищу информацию…`,goodResponse:`Хороший ответ`,badResponse:`Плохой ответ`,additionalFeedback:`Дополнительный комментарий`,feedbackPlaceholder:`Что было не так? (необязательно)`,feedbackCategory:`Категория отзыва`,selectReason:`Выберите причину (необязательно)`,categoryFactual:`Фактическая ошибка`,categoryIncomplete:`Неполный ответ`,categoryTone:`Неподходящий тон`,categoryOther:`Другое`,submit:`Отправить отзыв`,cancel:`Отмена`,feedbackThanks:`Спасибо за отзыв`,feedbackFailed:`Не удалось отправить отзыв`,conversationCleared:`Диалог очищен`,genericError:`Что-то пошло не так. Попробуйте ещё раз.`,sessionExpired:`Срок действия сеанса чата истёк. Перезагрузите страницу, чтобы продолжить.`,opensInNewTab:`(откроется в новой вкладке)`},hi:{openChat:`चैट खोलें`,closeChat:`चैट बंद करें`,chatWith:`{name} से चैट करें`,newConversation:`नई बातचीत`,conversation:`बातचीत`,you:`आप`,message:`संदेश`,send:`भेजें`,lookingItUp:`आपके लिए जानकारी खोजी जा रही है…`,goodResponse:`अच्छा जवाब`,badResponse:`ख़राब जवाब`,additionalFeedback:`अतिरिक्त फ़ीडबैक`,feedbackPlaceholder:`क्या ग़लत था? (वैकल्पिक)`,feedbackCategory:`फ़ीडबैक की श्रेणी`,selectReason:`कारण चुनें (वैकल्पिक)`,categoryFactual:`तथ्यात्मक त्रुटि`,categoryIncomplete:`अधूरा जवाब`,categoryTone:`अनुचित लहजा`,categoryOther:`अन्य`,submit:`सबमिट करें`,cancel:`रद्द करें`,feedbackThanks:`आपके फ़ीडबैक के लिए धन्यवाद`,feedbackFailed:`फ़ीडबैक नहीं भेजा जा सका`,conversationCleared:`बातचीत मिटा दी गई`,genericError:`कुछ ग़लत हो गया। कृपया फिर से कोशिश करें।`,sessionExpired:`यह चैट सत्र समाप्त हो गया है। जारी रखने के लिए पेज को फिर से लोड करें।`,opensInNewTab:`(नए टैब में खुलता है)`},ar:{openChat:`فتح الدردشة`,closeChat:`إغلاق الدردشة`,chatWith:`الدردشة مع {name}`,newConversation:`محادثة جديدة`,conversation:`المحادثة`,you:`أنت`,message:`الرسالة`,send:`إرسال`,lookingItUp:`جارٍ البحث عن المعلومات…`,goodResponse:`إجابة جيدة`,badResponse:`إجابة سيئة`,additionalFeedback:`ملاحظات إضافية`,feedbackPlaceholder:`ما المشكلة؟ (اختياري)`,feedbackCategory:`فئة الملاحظات`,selectReason:`اختر سببًا (اختياري)`,categoryFactual:`معلومات غير صحيحة`,categoryIncomplete:`إجابة غير مكتملة`,categoryTone:`أسلوب غير مناسب`,categoryOther:`أخرى`,submit:`إرسال الملاحظات`,cancel:`إلغاء`,feedbackThanks:`شكرًا على ملاحظاتك`,feedbackFailed:`تعذّر إرسال الملاحظات`,conversationCleared:`تم مسح المحادثة`,genericError:`حدث خطأ ما. يُرجى المحاولة مرة أخرى.`,sessionExpired:`انتهت صلاحية جلسة الدردشة هذه. يُرجى إعادة تحميل الصفحة للمتابعة.`,opensInNewTab:`(يُفتح في علامة تبويب جديدة)`}},St=Object.freeze(Object.keys(xt)),Ct={pt:`pt-BR`,es:`es-419`,zh:`zh-Hans`},wt=new Set([`ar`]),Tt=/^[a-z]{2,8}([-_][a-z0-9]{1,8})*$/i,Et=/^zh[-_](hant|tw|hk|mo)(?=$|[-_])/i;function Dt(e){return xt[e]}function Ot(e){let t=e.trim();if(!Tt.test(t)||Et.test(t))return null;let n=t.split(/[-_]/)[0].toLowerCase();return Object.hasOwn(xt,n)?n:null}function kt(e,t){let n=null;return e!=null&&e!==``&&(n=typeof e==`string`?Ot(e):null,n||console.warn(`whoo-aiden-widget: ignoring \`language\` ${At(e)} -- expected one of ${St.join(`, `)} (or a regional tag like pt-BR). Using the page's language instead.`)),n??=typeof t==`string`?Ot(t):null,n??=`en`,{language:n,tag:Ct[n]??n,dir:wt.has(n)?`rtl`:`ltr`}}function At(e){return typeof e==`string`?JSON.stringify(e):`(a ${typeof e})`}function jt(e){if(typeof e!=`string`)return null;let t=e.trim().replace(/_/g,`-`);return Tt.test(t)?t:null}function Mt(e,t,n){if(e!=null&&e!==``){let t=jt(e);if(t)return t;console.warn(`whoo-aiden-widget: ignoring \`contentLanguage\` ${At(e)} -- expected a language tag such as 'nl' or 'pt-BR'. Using the page's language instead.`)}return jt(t)??jt(n)??``}function Nt(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}}var Pt=`(max-width: 400px), (max-height: 420px)`,Ft=`data-fit-visible`,It=40;function Lt(e){let t=typeof window<`u`?window.visualViewport:null;if(!t)return()=>{};let n=()=>{e.removeAttribute(Ft),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<It){n();return}e.setAttribute(Ft,``),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 Rt(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 zt=0,Bt=``;function Vt(){zt++===0&&(Bt=document.documentElement.style.overflow,document.documentElement.style.overflow=`hidden`)}function Ht(){--zt===0&&(document.documentElement.style.overflow=Bt)}function Ut(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return()=>{};let e=window.matchMedia(Pt),t=!1,n=()=>{e.matches&&!t?(t=!0,Vt()):!e.matches&&t&&(t=!1,Ht())};n();let r=Rt(e,n);return()=>{r(),t&&(t=!1,Ht())}}function Wt(e){if(typeof window>`u`||typeof window.matchMedia!=`function`||typeof e.showModal!=`function`)return()=>{};let t=window.matchMedia(Pt),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(),Rt(t,r)}function Gt(e){return e.isComposing||e.keyCode===229}function Kt({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,value:e,readOnly:i,"aria-disabled":i,ref:a,onInput:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!Gt(e)&&r()}}),K(`button`,{type:`button`,class:`whoo-widget-composer-send`,"aria-disabled":i,onClick:()=>{i||r()},children:o.send})]})}function qt({message:e}){return K(`div`,{class:`whoo-widget-error-banner`,role:`alert`,children:e})}var Jt=/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y,Yt=/\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y,Xt=/(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y,Zt=/\*([^*\s](?:[^*]*[^*\s])?)\*/y,Qt=/[ \t]*[*+-][ \t]+/y,$t=/https?:\/\/\S+/y,en=/[.,;:!?)\]}>]+$/;function tn(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
- `)&&(Qt.lastIndex=n,Qt.exec(e))){i(n),t.push({type:`text`,value:`• `,start:n,end:Qt.lastIndex}),n=Qt.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]!==`!`){Jt.lastIndex=n;let a=Jt.exec(e);if(a){i(n),t.push({type:`link`,text:a[1],url:a[2],start:n,end:Jt.lastIndex}),n=Jt.lastIndex,r=n;continue}}Yt.lastIndex=n;let a=Yt.exec(e);if(a){i(n),t.push({type:`bold`,value:a[1],start:n,end:Yt.lastIndex}),n=Yt.lastIndex,r=n;continue}Xt.lastIndex=n;let o=Xt.exec(e);if(o){i(n),t.push({type:`italic`,value:o[1],start:n,end:Xt.lastIndex}),n=Xt.lastIndex,r=n;continue}Zt.lastIndex=n;let s=Zt.exec(e);if(s){i(n),t.push({type:`italic`,value:s[1],start:n,end:Zt.lastIndex}),n=Zt.lastIndex,r=n;continue}$t.lastIndex=n;let c=$t.exec(e);if(c){let e=c[0].match(en),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 nn=/^[ \t]*[*+-][ \t]+(.*)$/,rn=/[\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 an(e){let t=e.match(/\p{L}/u)?.[0];if(t)return rn.test(t)?`rtl`:`ltr`}function on(e){let t=[],n=[],r=[],i=()=>{n.length>0&&t.push({type:`text`,text:n.join(`
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`,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:`Conversation 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`,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:`Conversation effacée`,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`,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`,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`,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`,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`,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`,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`,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`,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:`送信`,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:`发送`,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:`Отправить`,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:`भेजें`,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:`إرسال`,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}}var zt=`(max-width: 400px), (max-height: 420px)`,Bt=`data-fit-visible`,Vt=40;function Ht(e){let t=typeof window<`u`?window.visualViewport:null;if(!t)return()=>{};let n=()=>{e.removeAttribute(Bt),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<Vt){n();return}e.setAttribute(Bt,``),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 Ut(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 Wt=0,Gt=``;function Kt(){Wt++===0&&(Gt=document.documentElement.style.overflow,document.documentElement.style.overflow=`hidden`)}function qt(){--Wt===0&&(document.documentElement.style.overflow=Gt)}function Jt(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return()=>{};let e=window.matchMedia(zt),t=!1,n=()=>{e.matches&&!t?(t=!0,Kt()):!e.matches&&t&&(t=!1,qt())};n();let r=Ut(e,n);return()=>{r(),t&&(t=!1,qt())}}function Yt(e){if(typeof window>`u`||typeof window.matchMedia!=`function`||typeof e.showModal!=`function`)return()=>{};let t=window.matchMedia(zt),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(),Ut(t,r)}function Xt(e){return e.isComposing||e.keyCode===229}function Zt({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`&&!Xt(e)&&r()}}),W(`button`,{type:`button`,class:`whoo-widget-composer-send`,"aria-disabled":i,onClick:()=>{i||r()},children:o.send})]})}function Qt({message:e}){return W(`div`,{class:`whoo-widget-error-banner`,role:`alert`,children:e})}var $t=/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y,en=/\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y,tn=/(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y,nn=/\*([^*\s](?:[^*]*[^*\s])?)\*/y,rn=/[ \t]*[*+-][ \t]+/y,an=/https?:\/\/\S+/y,on=/[.,;:!?)\]}>]+$/;function sn(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
+ `)&&(rn.lastIndex=n,rn.exec(e))){i(n),t.push({type:`text`,value:`• `,start:n,end:rn.lastIndex}),n=rn.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]!==`!`){$t.lastIndex=n;let a=$t.exec(e);if(a){i(n),t.push({type:`link`,text:a[1],url:a[2],start:n,end:$t.lastIndex}),n=$t.lastIndex,r=n;continue}}en.lastIndex=n;let a=en.exec(e);if(a){i(n),t.push({type:`bold`,value:a[1],start:n,end:en.lastIndex}),n=en.lastIndex,r=n;continue}tn.lastIndex=n;let o=tn.exec(e);if(o){i(n),t.push({type:`italic`,value:o[1],start:n,end:tn.lastIndex}),n=tn.lastIndex,r=n;continue}nn.lastIndex=n;let s=nn.exec(e);if(s){i(n),t.push({type:`italic`,value:s[1],start:n,end:nn.lastIndex}),n=nn.lastIndex,r=n;continue}an.lastIndex=n;let c=an.exec(e);if(c){let e=c[0].match(on),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 cn=/^[ \t]*[*+-][ \t]+(.*)$/,ln=/[\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 un(e){let t=e.match(/\p{L}/u)?.[0];if(t)return ln.test(t)?`rtl`:`ltr`}function dn(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(nn);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 tn(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 sn(e,t={}){let n=e.replace(/\r\n?/g,`
5
- `),r=on(n);return r?r.map((e,n)=>e.type===`list`?K(`ul`,{class:`whoo-widget-list`,dir:an(e.items.find(e=>an(e))??``),children:e.items.map((e,n)=>K(`li`,{dir:an(e),children:J(e,t)},n))},n):K(`span`,{children:J(e.text,t)},n)):J(n,t)}function cn(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 ln({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(et(()=>{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:cn(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(gt,{})}),K(`button`,{ref:m,type:`button`,"aria-label":c.badResponse,"aria-disabled":h,onClick:()=>{h||i()},children:K(_t,{})})]}),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 un({isSlowResponse:e,text:t}){return K(`div`,{class:`whoo-widget-pending`,role:`status`,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 dn({url:e,alt:t,lang:n}){let[r,i]=Ze(!1);return r?null:K(`img`,{class:`whoo-widget-empty-state-image`,src:e,alt:t,lang:n,referrerpolicy:`no-referrer`,onError:()=>i(!0)})}function fn({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(un,{isSlowResponse:a,text:d}):K(`div`,{class:`whoo-widget-message-text`,dir:`auto`,lang:f,children:sn(e.content,{linkCue:d.opensInNewTab,linkCueLang:p})}),r&&e.role===`assistant`&&h?K(ln,{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 pn({messages:e,messageFeedback:n,announcement:r,emptyStateImage:i,agentName:a=u,showFeedback:o=!1,isStreaming:s=!1,isSlowResponse:c=!1,onThumbsUp:l,onThumbsDown:d,onDraftChange:f=()=>{},onSubmitDetailed:p,onCancelFeedback:m,text:h=t,contentLanguage:g,languageTag:_,announcementIsContent:v=!1}){let y=W(null);return $e(()=>{let e=y.current;e&&(e.scrollTop=e.scrollHeight)},[e,c]),K(z,{children:[K(`section`,{class:`whoo-widget-message-list`,ref:y,"aria-label":h.conversation,tabIndex:0,children:[i?K(dn,{...i,lang:g}):null,e.map((t,r)=>K(fn,{message:t,speaker:t.role===`user`?h.you:a,showFeedback:o,feedbackState:t.id?n[t.id]??{status:`idle`}:{status:`idle`},pending:s&&r===e.length-1&&t.role===`assistant`&&t.content===``,isSlowResponse:c,onThumbsUp:l,onThumbsDown:d,onDraftChange:f,onSubmitDetailed:p,onCancelFeedback:m,text:h,contentLanguage:g,languageTag:_},t.id??r))]}),K(`div`,{class:`whoo-widget-sr-only`,"aria-live":`polite`,"aria-atomic":`true`,lang:v?g:_,children:r??``})]})}var mn=`button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`;function hn(e){return Array.from(e.querySelectorAll(mn)).filter(e=>{let t=getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`})}function gn({state:e,controller:t,greeting:n}){let r=W(null),i=W(null);et(()=>{i.current?.focus()},[]),et(()=>{let e=r.current,n=e?Lt(e):()=>{},i=e?Wt(e):()=>{},a=()=>{e&&!e.open&&t.close()};e?.addEventListener(`close`,a);let o=Ut();return()=>{n(),i(),e?.removeEventListener(`close`,a),o()}},[]);let a=e=>{if(e.key===`Escape`&&!Gt(e)){e.preventDefault(),t.close();return}if(e.key!==`Tab`)return;let n=r.current;if(!n)return;let i=hn(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()},o=()=>{let n=e.draft.trim();n&&!e.isStreaming&&(t.setDraft(``),t.sendMessage(n))},s=d(t.config.name)||e.agentName||`Aiden`,c=d(t.config.title),{before:l,after:u,hasName:f}=Nt(t.text.chatWith),p=e.messages.length===0&&n?[{role:`assistant`,content:n,id:null}]:e.messages,m=t.emptyStateImageUrl,h=e.messages.length===0&&m?{url:m,alt:t.emptyStateImageAlt}:void 0;return K(`dialog`,{open:!0,class:`whoo-widget-panel`,"aria-modal":`true`,"aria-labelledby":`whoo-widget-title`,ref:r,onKeyDown:a,onCancel:e=>{e.preventDefault(),t.close()},children:[K(`div`,{class:`whoo-widget-header`,children:[c?K(`h2`,{id:`whoo-widget-title`,class:`whoo-widget-header-title`,lang:t.contentLanguage,dir:`auto`,children:c}):K(`h2`,{id:`whoo-widget-title`,class:`whoo-widget-header-title`,children:[l,f?K(`bdi`,{lang:t.contentLanguage,children:s}):null,u]}),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(mt,{})})]})]}),K(pn,{messages:p,messageFeedback:e.messageFeedback,announcement:e.announcement,emptyStateImage:h,agentName:s,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(qt,{message:e.runtimeError}),K(Kt,{value:e.draft,onChange:e=>t.setDraft(e),onSend:o,disabled:e.isStreaming,inputRef:i,text:t.text,contentLanguage:t.contentLanguage})]})}function _n({controller:e}){let[t,n]=Ze(e.getState()),r=W(null),i=W(t.isOpen);return $e(()=>(n(e.getState()),e.subscribe(n)),[e]),et(()=>{i.current&&!t.isOpen&&r.current?.focus(),i.current=t.isOpen},[t.isOpen]),t.initError||t.isInitializing?null:K(z,{children:[K(bt,{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(gn,{state:t,controller:e,greeting:e.config.greeting})]})}var vn=class extends Error{status;constructor(e,t){super(e),this.name=`WidgetApiError`,this.status=t}};function yn(e){if(typeof e!=`string`)return null;let t=e.trim();return t===``?null:t}async function bn(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 vn(`Failed to create widget session (${n.status})`,n.status);let r=await n.json();return{token:r.token,...xn(r)}}function xn(e){return{primaryColor:yn(e.primary_color),name:yn(e.name),accentColor:yn(e.accent_color),inkColor:yn(e.ink_color)}}async function Sn(e,t){let n=await fetch(`${e}/api/v1/widget/branding`,{headers:{Authorization:`Bearer ${t}`}});if(!n.ok)throw new vn(`Failed to load widget branding (${n.status})`,n.status);return xn(await n.json())}async function Cn(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 vn(`Feedback submission failed (${r.status})`,r.status)}async function*wn(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 vn(`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(cn);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 K(e,t={}){return sn(e).map((e,n)=>{switch(e.type){case`bold`:return W(`strong`,{children:K(e.value,t)},n);case`italic`:return W(`em`,{children:K(e.value,t)},n);case`link`:return W(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:[e.text,W(`span`,{class:`whoo-widget-sr-only`,lang:t.linkCueLang,children:[` `,t.linkCue??`(opens in new tab)`]})]},n);default:return e.value}})}function fn(e,t={}){let n=e.replace(/\r\n?/g,`
5
+ `),r=dn(n);return r?r.map((e,n)=>e.type===`list`?W(`ul`,{class:`whoo-widget-list`,dir:un(e.items.find(e=>un(e))??``),children:e.items.map((e,n)=>W(`li`,{dir:un(e),children:K(e,t)},n))},n):W(`span`,{children:K(e.text,t)},n)):K(n,t)}function pn(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 mn({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:pn(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 hn({isSlowResponse:e,text:t}){return W(`div`,{class:`whoo-widget-pending`,role:`status`,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 gn({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 _n=`whoo-widget-notice`;function vn({notice:e,placement:t=`top`,text:n,contentLanguage:r,languageTag:i}){return t===`footer`?W(`div`,{id:_n,class:`whoo-widget-notice-footer`,role:`note`,tabIndex:0,children:W(`div`,{class:`whoo-widget-message-text`,dir:`auto`,lang:r,children:fn(e,{linkCue:n.opensInNewTab,linkCueLang:i})})}):W(`div`,{id:_n,class:`whoo-widget-notice`,role:`note`,children:W(`div`,{class:`whoo-widget-message-text`,dir:`auto`,lang:r,children:fn(e,{linkCue:n.opensInNewTab,linkCueLang:i})})})}function yn({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(hn,{isSlowResponse:a,text:d}):W(`div`,{class:`whoo-widget-message-text`,dir:`auto`,lang:f,children:fn(e.content,{linkCue:d.opensInNewTab,linkCueLang:p})}),r&&e.role===`assistant`&&h?W(mn,{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 bn({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(gn,{...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(vn,{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:fn(o,{linkCue:v.opensInNewTab,linkCueLang:b})}):null]}):null,e.map((t,r)=>W(yn,{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`,"aria-live":`polite`,"aria-atomic":`true`,lang:x?y:b,children:r??``})]})}var xn=`button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`;function Sn(e){return Array.from(e.querySelectorAll(xn)).filter(e=>{let t=getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`})}function Cn({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?Ht(e):()=>{},i=e?Yt(e):()=>{},a=()=>{e&&!e.open&&t.close()};e?.addEventListener(`close`,a);let o=Jt();return()=>{n(),i(),e?.removeEventListener(`close`,a),o()}},[]);let s=e=>{if(e.key===`Escape`&&!Xt(e)){e.preventDefault(),t.close();return}if(e.key!==`Tab`)return;let n=r.current;if(!n)return;let i=Sn(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=d(t.config.name)||e.agentName||`Aiden`,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?_n: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(bn,{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(Qt,{message:e.runtimeError}),e.noticeAgreed?W(Zt,{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":_n,autoFocus:!0,onClick:()=>{o.current=!0,t.agreeToNotice()},children:t.text.agreeToNotice})}),v?W(vn,{notice:t.notice,placement:`footer`,text:t.text,contentLanguage:t.contentLanguage,languageTag:t.languageTag}):null]})}function wn({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(Cn,{state:t,controller:e,greeting:e.config.greeting})]})}var Tn=class extends Error{status;constructor(e,t){super(e),this.name=`WidgetApiError`,this.status=t}};function En(e){if(typeof e!=`string`)return null;let t=e.trim();return t===``?null:t}async function Dn(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 Tn(`Failed to create widget session (${n.status})`,n.status);let r=await n.json();return{token:r.token,...On(r)}}function On(e){return{primaryColor:En(e.primary_color),name:En(e.name),accentColor:En(e.accent_color),inkColor:En(e.ink_color)}}async function kn(e,t){let n=await fetch(`${e}/api/v1/widget/branding`,{headers:{Authorization:`Bearer ${t}`}});if(!n.ok)throw new Tn(`Failed to load widget branding (${n.status})`,n.status);return On(await n.json())}async function An(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 Tn(`Feedback submission failed (${r.status})`,r.status)}async function*jn(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 Tn(`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 Tn(JSON.parse(t.slice(6)))),n=c.indexOf(`
8
+ `).find(e=>e.startsWith(`data: `));if(i?.aborted)return;t&&(yield Mn(JSON.parse(t.slice(6)))),n=c.indexOf(`
9
9
 
10
- `)}}}function Tn(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 En(e){return tn(e.replace(/\r\n?/g,`
11
- `)).map(e=>{switch(e.type){case`bold`:case`italic`:return En(e.value);case`link`:return e.text;default:return e.value}}).join(``)}var Dn=40,On=120;function kn(e){let t=[];for(let n of tn(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 An(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 jn(e,t,n){let r=n?.wordIntervalMs??Dn,i=n?.tokenIntervalMs??On,a=n?.signal,o=tn(e),s=new Set(o.filter(e=>e.type!==`text`).map(e=>e.end)),c=An(a),l=``;for(let n of kn(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 Mn(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 Nn(e){let t=Mn(e)?.exp;return typeof t==`number`?t*1e3:null}function Pn(e,t=Date.now()){let n=Nn(e);return n!==null&&n<=t}function Fn(e,t=Date.now()){let n=Mn(e);return n?.exp==null?null:n.iat!=null&&n.exp>n.iat?t+(n.exp-n.iat)*1e3:n.exp*1e3}function In(e){return`whoo-aiden-widget:conversation:${e}`}function Ln(e){try{return window.sessionStorage.getItem(In(e))}catch{return null}}function Rn(e,t){try{window.sessionStorage.setItem(In(e),t)}catch{}}function zn(e){try{window.sessionStorage.removeItem(In(e))}catch{}}var Bn=/^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;function Vn(e){if(Bn.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 Vn(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 Hn(e,t){let n=Math.max(e,t),r=Math.min(e,t);return(n+.05)/(r+.05)}function Un(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 Hn(n,X([0,0,0]))>=Hn(n,X([255,255,255]))?`#000000`:`#ffffff`}function Wn(e,t){let n=Y(e),r=Y(t);return!n||!r?NaN:Hn(X(n),X(r))}var Gn=a.primary,Kn=a.panel,qn=a.assistantBubble,Jn=a.headerHover,Yn=4.5;function Xn([e,t,n]){return`#${[e,t,n].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function Zn(e,t=Kn){let n=Y(e),r=Y(t);if(!n||!r)return Gn;let i=X(r),a=e=>Hn(X(e),i)>=Yn;if(a(n))return Xn(n);for(let e=.99;e>0;e-=.01){let t=n.map(t=>Math.round(t*e));if(a(t))return Xn(t)}return`#000000`}var Qn=a.ink,$n=a.link;function Z(e){if(typeof e!=`string`||!e)return null;let t=Vn(e);return t?Xn(t.rgb):null}function er(e){if(typeof e!=`string`||!e)return null;let t=Vn(e);return t?t.translucent?e.trim():Xn(t.rgb):null}var tr=[{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`],required:4.5},{role:`muted`,against:[`assistantBubble`],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 nr({color:e,inkColor:t,accentColor:n,overrides:r}){let o=typeof r==`object`&&r&&!Array.isArray(r)?r:{},s=e=>er(o[e]),c=Z(e),l=s(`primary`),u=l??c??Gn,d=s(`primaryText`),f=d??Zn(u,Jn),p=s(`onPrimary`)??Un(u),m=Z(t),h=s(`ink`)??(m?Zn(m,qn):Qn),g=Z(n),_=s(`link`)??(g?Zn(g,qn):$n),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 tr)for(let r of t){if(!b[e]&&!b[r])continue;let t=Wn(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 rr(e,t,n=Gn){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=nr({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 ir(e,{inkColor:t,accentColor:n}){let r=nr({inkColor:t,accentColor:n});e.style.setProperty(`--whoo-widget-ink`,r.ink),e.style.setProperty(`--whoo-widget-link-color`,r.link)}function ar(e,t){let n=nr({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 or(e,t){e&&Z(e)===null&&console.warn(`[whoo-aiden-widget] Could not use ${Q(e)} as the ${t}; using the default.`)}function sr(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`&&Vn(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.`),cr({color:e.color,inkColor:e.inkColor,accentColor:e.accentColor,overrides:t},n)}function cr(e,t){for(let n of nr(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 lr(e,t,n=new Set){rr(e,t.color??Gn),or(t.inkColor,`ink color`),or(t.accentColor,`accent color`),ir(e,{inkColor:t.inkColor,accentColor:t.accentColor});let r=te(t.theme);sr(t,r.colors,n),ar(e,r.colors),r.fontFamily&&e.style.setProperty(`--whoo-widget-font`,r.fontFamily)}var ur=8e3,dr=3e3,fr=15e3,pr=class extends Error{name=`SessionUnavailableError`};function mr(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 hr(e,t){return e===`refused`?new _r(t):new pr}function gr(e){let t=e?.status;return t===401||t===403||t===404}var _r=class extends Error{name=`SessionExpiredError`;constructor(e){super(e instanceof Error?e.message:`The session has expired.`)}};function vr(e){return e?.status===401}function yr(e,t){return new Promise(n=>{let r=setTimeout(n,t);e.then(()=>{clearTimeout(r),n()})})}var br=class{config;state;listeners=new Set;sessionToken=null;sessionTokenExpiresAt=null;tokenRenewal=null;renewalGeneration=0;sendEpoch=0;getSessionToken;conversationId=null;storageIdentifier;activeRequestController=null;slowResponseTimer=null;prefersReducedMotion;launcher;launcherIconUrl;emptyStateImageUrl;emptyStateImageAlt;showFeedback;text;language;languageTag;contentLanguage;dir;constructor(e){this.config=e;let t=te(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.showFeedback=e.showFeedback===!0,this.storageIdentifier=e.publishableKey??`session-token-mode`,this.getSessionToken=m(e);let{language:i,tag:a,dir:o}=kt(e.language,typeof document>`u`?void 0:document.documentElement.lang);this.language=i,this.languageTag=a,this.dir=o,this.contentLanguage=Mt(e.contentLanguage,typeof document>`u`?void 0:document.documentElement.lang,e.language),this.text={...Dt(i),...b(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,draft:``}}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}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(Pn(this.config.sessionToken)){if(!(`token`in await this.renewToken()))throw Error(`The sessionToken has expired.`)}else this.sessionToken=this.config.sessionToken,this.sessionTokenExpiresAt=Nn(this.config.sessionToken)}else if(this.config.publishableKey){let{token:t,primaryColor:n,name:r,accentColor:i,inkColor:a}=await bn(e,this.config.publishableKey);this.sessionToken=t,this.sessionTokenExpiresAt=Fn(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=Ln(this.storageIdentifier),this.config.sessionToken&&await yr(this.loadBranding(e),dr)}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=>Sn(e,t));this.setState({primaryColor:n,agentName:r,accentColor:i,inkColor:a})}catch(e){let t=e?.status;(e instanceof _r||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,announcement:this.text.conversationCleared,announcementIsContent:!1})}setDraft(e){this.setState({draft:e})}close(){this.activeRequestController?.abort(`close`),this.activeRequestController=null,this.clearSlowResponse(),this.setState({isOpen:!1})}async sendMessage(e){if(!this.sessionToken)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,announcement:null});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})},ur);let f=!1,p=()=>{this.state.draft===``&&(f=!0,this.setState({draft:e}))},m=(e=this.text.genericError)=>{r()&&(this.setState({runtimeError:e}),p())},h=``;try{let{stream:n,first:i}=await this.withSession(async n=>{d=!0;let r=wn(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,Rn(this.storageIdentifier,t.conversationId);else if(t.type===`delta`)this.clearSlowResponse(),t.verbatim&&!this.prefersReducedMotion?(await jn(t.delta,e=>c(e),{signal:u}),h=t.delta):t.verbatim?(h=t.delta,c(h)):(h+=t.delta,c(h));else if(t.type===`done`)t.conversationId&&(this.conversationId=t.conversationId,Rn(this.storageIdentifier,t.conversationId)),t.messageId&&s({id:t.messageId}),r()&&this.setState({announcement:En(h),announcementIsContent:!0});else if(t.type===`error`){console.error(`[whoo-aiden-widget] chat error:`,t.error),h.trim()!==``&&r()&&this.setState({announcement:En(h),announcementIsContent:!0}),m(),l.abort();break}}}catch(e){u.aborted?u.reason===`close`&&r()&&!d&&p():e instanceof _r?(console.error(`[whoo-aiden-widget] chat request failed: the session has expired.`,e),m(this.text.sessionExpired)):e instanceof pr?(console.error(`[whoo-aiden-widget] chat request failed: no session could be had.`),m()):(console.error(`[whoo-aiden-widget] chat request failed:`,e),m())}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(),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=>Cn(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}:mr(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`})},fr)});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 bn(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&&gr(e)?`refused`:`unavailable`}}let r=typeof n==`string`?Fn(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 hr(n.failure);let{token:r}=n;try{return await e(r)}catch(n){if(!vr(n))throw n;let i=this.sessionToken&&this.sessionToken!==r?{token:this.sessionToken}:await mr(this.renewToken(),t);if(!(`token`in i))throw hr(i.failure,n);try{return await e(i.token)}catch(e){throw vr(e)?new _r(e):e}}}},$=20,xr=12,Sr=300,Cr=352;function wr(){try{return typeof CSS<`u`&&CSS.supports?.(`height`,`100dvh`)?`dvh`:`vh`}catch{return`vh`}}function Tr(e,t){let{offsetX:n,offsetY:r,launcherSize:i,panelWidth:a,panelHeight:o}=ie(t.layout),s=e=>typeof t.layout?.offset?.[e]==`number`;if(typeof window<`u`&&window.innerWidth>0&&window.innerHeight>0){let e=Math.max($,window.innerWidth-Sr),t=Math.max($,window.innerHeight-i-Cr);s(`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.`),s(`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 c=`100${wr()}`,l=`min(${n}px, max(${$}px, calc(100vw - ${Sr}px)), calc(100vw - ${i}px))`,u=`min(${r}px, max(${$}px, calc(${c} - ${i+Cr}px)), calc(${c} - ${i}px))`,d=`calc(${u} + ${i}px + ${xr}px)`,f=t.position===`bottom-left`,p=(t,n)=>e.style.setProperty(t,n);p(`--whoo-widget-inset-left`,f?l:`auto`),p(`--whoo-widget-inset-right`,f?`auto`:l),p(`--whoo-widget-inset-bottom`,u),p(`--whoo-widget-launcher-size`,`${i}px`),p(`--whoo-widget-panel-bottom`,d),p(`--whoo-widget-panel-width`,`${a}px`),p(`--whoo-widget-panel-height`,`${o}px`),p(`--whoo-widget-panel-max-width`,`calc(100vw - ${l} - ${$}px)`),p(`--whoo-widget-panel-max-height`,`calc(${c} - ${d} - ${$}px)`)}var Er=`: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);font-family:var(--whoo-widget-font,-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);color:inherit;border:none;border-radius:12px;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-title{color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;flex:auto;min-width:0;margin:0;font-size:15px;font-weight:600}.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}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.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);unicode-bidi:plaintext;border-radius:6px;flex:1;min-width:0;padding:8px;font-size:16px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.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-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}`;function Dr(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=Er,n.appendChild(r);let i=document.createElement(`div`);n.appendChild(i);let a=new Set;lr(i,e,a),Tr(i,e);let o=new br(e);i.setAttribute(`lang`,o.languageTag),i.setAttribute(`dir`,o.dir);let s=Z(e.color)!==null,c=null,u=``,d=te(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,rr(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;ir(i,{inkColor:a,accentColor:o}),p={...p,inkColor:a,accentColor:o},n=!0}n&&(ar(i,d),f&&cr({...p,overrides:d},a))}),o.init(),Le(K(_n,{controller:o}),i),document.body.appendChild(t),{unmount(){Le(null,i),t.remove()}}}function Or(e){return f(e),Dr(e)}return e.init=Or,e})({});
10
+ `)}}}function Mn(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 Nn(e){return sn(e.replace(/\r\n?/g,`
11
+ `)).map(e=>{switch(e.type){case`bold`:case`italic`:return Nn(e.value);case`link`:return e.text;default:return e.value}}).join(``)}var Pn=40,Fn=120;function In(e){let t=[];for(let n of sn(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 Ln(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 Rn(e,t,n){let r=n?.wordIntervalMs??Pn,i=n?.tokenIntervalMs??Fn,a=n?.signal,o=sn(e),s=new Set(o.filter(e=>e.type!==`text`).map(e=>e.end)),c=Ln(a),l=``;for(let n of In(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 zn(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 Bn(e){let t=zn(e)?.exp;return typeof t==`number`?t*1e3:null}function Vn(e,t=Date.now()){let n=Bn(e);return n!==null&&n<=t}function Hn(e,t=Date.now()){let n=zn(e);return n?.exp==null?null:n.iat!=null&&n.exp>n.iat?t+(n.exp-n.iat)*1e3:n.exp*1e3}function Un(e){return`whoo-aiden-widget:conversation:${e}`}function Wn(e){try{return window.sessionStorage.getItem(Un(e))}catch{return null}}function Gn(e,t){try{window.sessionStorage.setItem(Un(e),t)}catch{}}function Kn(e){return`whoo-aiden-widget:notice-agreed:${e}`}function qn(e,t){try{return window.sessionStorage.getItem(Kn(e))===t}catch{return!1}}function Jn(e,t){try{window.sessionStorage.setItem(Kn(e),t)}catch{}}function Yn(e){try{window.sessionStorage.removeItem(Un(e))}catch{}}var Xn=/^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;function Zn(e){if(Xn.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 Zn(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 Qn(e,t){let n=Math.max(e,t),r=Math.min(e,t);return(n+.05)/(r+.05)}function $n(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 Qn(n,J([0,0,0]))>=Qn(n,J([255,255,255]))?`#000000`:`#ffffff`}function er(e,t){let n=q(e),r=q(t);return!n||!r?NaN:Qn(J(n),J(r))}var tr=a.primary,nr=a.panel,rr=a.assistantBubble,ir=a.headerHover,ar=4.5;function Y([e,t,n]){return`#${[e,t,n].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function or(e,t=nr){let n=q(e),r=q(t);if(!n||!r)return tr;let i=J(r),a=e=>Qn(J(e),i)>=ar;if(a(n))return Y(n);for(let e=.99;e>0;e-=.01){let t=n.map(t=>Math.round(t*e));if(a(t))return Y(t)}return`#000000`}var sr=a.ink,cr=a.link;function X(e){if(typeof e!=`string`||!e)return null;let t=Zn(e);return t?Y(t.rgb):null}function lr(e){if(typeof e!=`string`||!e)return null;let t=Zn(e);return t?t.translucent?e.trim():Y(t.rgb):null}var ur=[{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 dr({color:e,inkColor:t,accentColor:n,overrides:r}){let o=typeof r==`object`&&r&&!Array.isArray(r)?r:{},s=e=>lr(o[e]),c=X(e),l=s(`primary`),u=l??c??tr,d=s(`primaryText`),f=d??or(u,ir),p=s(`onPrimary`)??$n(u),m=X(t),h=s(`ink`)??(m?or(m,rr):sr),g=X(n),_=s(`link`)??(g?or(g,rr):cr),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 ur)for(let r of t){if(!b[e]&&!b[r])continue;let t=er(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 fr(e,t,n=tr){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=dr({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 pr(e,{inkColor:t,accentColor:n}){let r=dr({inkColor:t,accentColor:n});e.style.setProperty(`--whoo-widget-ink`,r.ink),e.style.setProperty(`--whoo-widget-link-color`,r.link)}function mr(e,t){let n=dr({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 hr(e,t){e&&X(e)===null&&console.warn(`[whoo-aiden-widget] Could not use ${Z(e)} as the ${t}; using the default.`)}function gr(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`&&Zn(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.`),_r({color:e.color,inkColor:e.inkColor,accentColor:e.accentColor,overrides:t},n)}function _r(e,t){for(let n of dr(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 vr(e,t,n=new Set){fr(e,t.color??tr),hr(t.inkColor,`ink color`),hr(t.accentColor,`accent color`),pr(e,{inkColor:t.inkColor,accentColor:t.accentColor});let r=oe(t.theme);gr(t,r.colors,n),mr(e,r.colors),r.fontFamily&&e.style.setProperty(`--whoo-widget-font`,r.fontFamily)}var yr=8e3,br=3e3,xr=15e3,Sr=class extends Error{name=`SessionUnavailableError`};function Cr(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 wr(e,t){return e===`refused`?new Q(t):new Sr}function Tr(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 Er(e){return e?.status===401}function Dr(e,t){return new Promise(n=>{let r=setTimeout(n,t);e.then(()=>{clearTimeout(r),n()})})}var Or=class{config;state;listeners=new Set;sessionToken=null;sessionTokenExpiresAt=null;tokenRenewal=null;renewalGeneration=0;sendEpoch=0;getSessionToken;conversationId=null;storageIdentifier;activeRequestController=null;slowResponseTimer=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||qn(this.storageIdentifier,this.notice),draft:``}}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}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(Vn(this.config.sessionToken)){if(!(`token`in await this.renewToken()))throw Error(`The sessionToken has expired.`)}else this.sessionToken=this.config.sessionToken,this.sessionTokenExpiresAt=Bn(this.config.sessionToken)}else if(this.config.publishableKey){let{token:t,primaryColor:n,name:r,accentColor:i,inkColor:a}=await Dn(e,this.config.publishableKey);this.sessionToken=t,this.sessionTokenExpiresAt=Hn(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=Wn(this.storageIdentifier),this.config.sessionToken&&await Dr(this.loadBranding(e),br)}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=>kn(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,Yn(this.storageIdentifier),this.setState({messages:[],messageFeedback:{},runtimeError:null,isStreaming:!1,announcement:this.text.conversationCleared,announcementIsContent:!1})}agreeToNotice(){this.state.noticeAgreed||(Jn(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.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,announcement:null});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})},yr);let f=!1,p=()=>{this.state.draft===``&&(f=!0,this.setState({draft:e}))},m=(e=this.text.genericError)=>{r()&&(this.setState({runtimeError:e}),p())},h=``;try{let{stream:n,first:i}=await this.withSession(async n=>{d=!0;let r=jn(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,Gn(this.storageIdentifier,t.conversationId);else if(t.type===`delta`)this.clearSlowResponse(),t.verbatim&&!this.prefersReducedMotion?(await Rn(t.delta,e=>c(e),{signal:u}),h=t.delta):t.verbatim?(h=t.delta,c(h)):(h+=t.delta,c(h));else if(t.type===`done`)t.conversationId&&(this.conversationId=t.conversationId,Gn(this.storageIdentifier,t.conversationId)),t.messageId&&s({id:t.messageId}),r()&&this.setState({announcement:Nn(h),announcementIsContent:!0});else if(t.type===`error`){console.error(`[whoo-aiden-widget] chat error:`,t.error),h.trim()!==``&&r()&&this.setState({announcement:Nn(h),announcementIsContent:!0}),m(),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),m(this.text.sessionExpired)):e instanceof Sr?(console.error(`[whoo-aiden-widget] chat request failed: no session could be had.`),m()):(console.error(`[whoo-aiden-widget] chat request failed:`,e),m())}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(),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=>An(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}:Cr(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`})},xr)});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 Dn(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&&Tr(e)?`refused`:`unavailable`}}let r=typeof n==`string`?Hn(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 wr(n.failure);let{token:r}=n;try{return await e(r)}catch(n){if(!Er(n))throw n;let i=this.sessionToken&&this.sessionToken!==r?{token:this.sessionToken}:await Cr(this.renewToken(),t);if(!(`token`in i))throw wr(i.failure,n);try{return await e(i.token)}catch(e){throw Er(e)?new Q(e):e}}}},$=20,kr=12,Ar=300,jr=352;function Mr(){try{return typeof CSS<`u`&&CSS.supports?.(`height`,`100dvh`)?`dvh`:`vh`}catch{return`vh`}}function Nr(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-Ar),t=Math.max($,window.innerHeight-i-jr);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${Mr()}`,u=`min(${n}px, max(${$}px, calc(100vw - ${Ar}px)), calc(100vw - ${i}px))`,d=`min(${r}px, max(${$}px, calc(${l} - ${i+jr}px)), calc(${l} - ${i}px))`,f=`calc(${d} + ${i}px + ${kr}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 Pr=`: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 Fr(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=Pr,n.appendChild(r);let i=document.createElement(`div`);n.appendChild(i);let a=new Set;vr(i,e,a),Nr(i,e);let o=new Or(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,fr(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;pr(i,{inkColor:a,accentColor:o}),p={...p,inkColor:a,accentColor:o},n=!0}n&&(mr(i,d),f&&_r({...p,overrides:d},a))}),o.init(),Ue(W(wn,{controller:o}),i),document.body.appendChild(t),{unmount(){Ue(null,i),t.remove()}}}function Ir(e){return p(e),Fr(e)}return e.init=Ir,e})({});