@aiden-voice/widget 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -1
- package/dist/components/MessageList.d.ts +3 -1
- package/dist/config.d.ts +1 -0
- package/dist/controller.d.ts +4 -0
- package/dist/i18n/messages.d.ts +1 -0
- package/dist/storage.d.ts +2 -0
- package/dist/types.d.ts +16 -1
- package/dist/version.d.ts +1 -1
- package/dist/widget.iife.js +7 -7
- package/dist/widget.js +579 -505
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -142,6 +142,8 @@ throws synchronously, at call time, if you pass both or neither.
|
|
|
142
142
|
| `name` | Agent name for the panel header and the dialog's screen-reader label ("Chat with {name}"). Overrides the name configured in whoo-aiden; omit it to use that one. | whoo-aiden's, else `'Aiden'` |
|
|
143
143
|
| `title` | Full panel title, used for the header heading and the dialog's screen-reader label. Replaces the whole "Chat with {name}" string (e.g. `'Ask our concierge'`), with surrounding whitespace trimmed; the agent's messages are still labelled with its name. A blank value is ignored. | `'Chat with {name}'` |
|
|
144
144
|
| `greeting` | Welcome text shown in the panel before the first message. | none |
|
|
145
|
+
| `notice` | A notice, such as a disclaimer or terms of use, pinned at the top of the conversation. Unlike `greeting` it stays after the visitor writes, and comes back after "New conversation". Screen readers read it with the panel's title when the panel opens, until the visitor sends a first message. Supports `**bold**`, `_italic_`, `[links](https://...)` and `- ` lists; raw HTML shows as text. Blank values are ignored. See [Notice](#notice). | none |
|
|
146
|
+
| `requireNoticeAgreement` | Ask the visitor to agree to `notice` before chatting: an "I agree" button (the `agreeToNotice` message) replaces the message field until they do. Remembered for the tab session, and asked again if the notice text changes. Ignored, with a console warning, without a `notice`. See [Notice](#notice). | `false` |
|
|
145
147
|
| `launcherIconUrl` | Image shown on the launcher bubble instead of the default chat icon. `https:` or `data:image/` only. Until it loads, and permanently if it fails, the default icon shows. Alias of `theme.launcher.iconUrl`. | none (default icon) |
|
|
146
148
|
| `theme` | Colors, font and launcher icons. See [Theming](#theming). | defaults |
|
|
147
149
|
| `layout` | Launcher position and size, and panel size. See [Layout](#layout). | defaults |
|
|
@@ -155,6 +157,27 @@ throws synchronously, at call time, if you pass both or neither.
|
|
|
155
157
|
|
|
156
158
|
Some third-party overlays (accessibility toolbars, chat or cookie widgets) sit at the maximum possible z-index, `2147483647`, in the same corner. No `zIndex` value can beat that: at an equal level, whichever element comes later in the page wins, and those overlays are usually injected after the widget. Move the widget to the other corner with `position: 'bottom-left'` instead. (None of this applies while the panel fills the screen; see `zIndex`.)
|
|
157
159
|
|
|
160
|
+
|
|
161
|
+
## Notice
|
|
162
|
+
|
|
163
|
+
Use `notice` for text every visitor must be shown before chatting, such as a disclaimer, and `requireNoticeAgreement` to have them agree to it first:
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
init({
|
|
167
|
+
publishableKey: 'pk_...',
|
|
168
|
+
notice:
|
|
169
|
+
"**Welcome to Ask Aiden, our Guest Assistant!**\n\nAll information provided is for informational purposes only. By selecting \"I agree\", you accept our [Website Terms of Use](https://example.com/terms).",
|
|
170
|
+
requireNoticeAgreement: true,
|
|
171
|
+
})
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
- **Where it shows:** above the conversation (below `emptyStateImageUrl`, above `greeting`), outlined rather than in a chat bubble, since it isn't something the agent said. It never leaves the transcript. The panel opens scrolled to its first line until the visitor writes.
|
|
175
|
+
- **Screen readers:** the panel is described by the notice, so it's read with the title when the panel opens, until the visitor sends a first message (after that it would repeat on every open). It stays reachable as the first item of the conversation.
|
|
176
|
+
- **It isn't sent to the agent** and isn't saved with the conversation.
|
|
177
|
+
- **Agreement (`requireNoticeAgreement: true`):** until the visitor agrees, an "I agree" button takes the message field's place, and nothing can be sent. When the panel opens, focus is on the button, which the notice describes, so screen readers read the title, "I agree, button" and the notice; after agreeing, focus moves to the message field. The agreement lasts for the tab session (like the conversation), survives "New conversation", and is asked for again if you change the notice text. Change the label with `messages: { agreeToNotice: '...' }`; if you do, make the notice text match it.
|
|
178
|
+
- **No record is kept.** The agreement lives only in the visitor's browser (`sessionStorage`); the widget doesn't send it to whoo-aiden, so it is no proof of consent. Whether that, and the wording, is enough is a question for your legal counsel.
|
|
179
|
+
- **Write it in your content language,** like `greeting`. It's not translated.
|
|
180
|
+
|
|
158
181
|
## Language
|
|
159
182
|
|
|
160
183
|
The widget's own text (buttons, labels, status and error messages, and what screen readers announce) comes in eleven languages: English (`en`), French (`fr`), Spanish (`es`), Portuguese (`pt`), German (`de`), Italian (`it`), Japanese (`ja`), Simplified Chinese (`zh`), Russian (`ru`), Hindi (`hi`) and Arabic (`ar`).
|
|
@@ -163,7 +186,7 @@ The widget's own text (buttons, labels, status and error messages, and what scre
|
|
|
163
186
|
- **Regional tags** match their language: `fr-CA` is French, any `pt-*` gets Brazilian Portuguese, any `es-*` gets Latin American Spanish. Simplified Chinese matches `zh`, `zh-CN`, `zh-SG` and `zh-Hans`. Traditional Chinese (`zh-TW`, `zh-HK`, `zh-Hant`) is not supported and falls back to English.
|
|
164
187
|
- **Decided once, at `init()`.** If your single-page app changes `<html lang>` later, pass `language` (unmount and `init()` again to switch).
|
|
165
188
|
- **Arabic is right to left:** the panel's layout mirrors (the visitor's messages on the left). The corner set by `position` doesn't change.
|
|
166
|
-
- **Not translated:** the agent's replies (the model answers in whatever language it does), and `greeting`, `title` and `name`, which you write in the language you want. These are marked with the **content language**, not the widget's: `contentLanguage` if you pass it, else your page's `<html lang>` (any language, not just the eleven), else `language` if the page has no `lang`, else unknown. So on a Dutch page the widget's buttons are English, while replies and your Dutch greeting are read with a Dutch voice.
|
|
189
|
+
- **Not translated:** the agent's replies (the model answers in whatever language it does), and `greeting`, `notice`, `title` and `name`, which you write in the language you want. These are marked with the **content language**, not the widget's: `contentLanguage` if you pass it, else your page's `<html lang>` (any language, not just the eleven), else `language` if the page has no `lang`, else unknown. So on a Dutch page the widget's buttons are English, while replies and your Dutch greeting are read with a Dutch voice.
|
|
167
190
|
- **Direction:** each paragraph and list item of a message takes its direction from its own first letter, so an English reply in an Arabic widget, or the reverse, still reads correctly. A paragraph that starts with a Latin name ("Aiden …") in Arabic text is laid out left to right, as the bidi standard decides.
|
|
168
191
|
- **The widget marks its own language** (`lang` and `dir` on its root, naming the variant it ships: `pt-BR`, `es-419`, `zh-Hans`), so screen readers pronounce it correctly even on a page in another language.
|
|
169
192
|
- **Upgrading from a version before 0.8.0:** a page whose `<html lang>` is one of these languages now gets the widget in that language, where it was English before. Pass `language: 'en'` to keep it in English; replies and your own text keep your page's language for screen readers either way.
|
|
@@ -206,6 +229,8 @@ window.whooAidenWidget.init({
|
|
|
206
229
|
| `conversationCleared` | Conversation cleared | screen-reader announcement |
|
|
207
230
|
| `genericError` | Something went wrong, please try again. | error alert |
|
|
208
231
|
| `sessionExpired` | This chat session has expired. Reload the page to continue. | error alert |
|
|
232
|
+
| `opensInNewTab` | (opens in new tab) | screen readers only, after each link in a reply: every link in a reply opens in a new tab |
|
|
233
|
+
| `agreeToNotice` | I agree | button the visitor presses to agree to the `notice`, with `requireNoticeAgreement` |
|
|
209
234
|
|
|
210
235
|
**About the translations:** they were machine-drafted and cross-checked by independent AI agents (back-translation, critique, and rendering checks), not reviewed by native speakers. [docs/translation-verification.md](docs/translation-verification.md) records every check. If any wording reads wrong, override it with `messages`, and please tell us.
|
|
211
236
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { FeedbackCategory, Message, MessageFeedbackState } from '../controller';
|
|
2
2
|
import { WidgetMessages } from '../i18n/messages';
|
|
3
|
+
export declare const NOTICE_ID = "whoo-widget-notice";
|
|
3
4
|
type DraftChangeHandler = (messageId: string, correction: string, category: '' | FeedbackCategory) => void;
|
|
4
5
|
type SubmitHandler = (messageId: string, correction: string, category: '' | FeedbackCategory) => void;
|
|
5
|
-
export declare function MessageList({ messages, messageFeedback, announcement, emptyStateImage, agentName, showFeedback, isStreaming, isSlowResponse, onThumbsUp, onThumbsDown, onDraftChange, onSubmitDetailed, onCancelFeedback, text, contentLanguage, languageTag, announcementIsContent, }: {
|
|
6
|
+
export declare function MessageList({ messages, messageFeedback, announcement, emptyStateImage, notice, agentName, showFeedback, isStreaming, isSlowResponse, onThumbsUp, onThumbsDown, onDraftChange, onSubmitDetailed, onCancelFeedback, text, contentLanguage, languageTag, announcementIsContent, }: {
|
|
6
7
|
messages: Message[];
|
|
7
8
|
messageFeedback: Record<string, MessageFeedbackState>;
|
|
8
9
|
announcement: string | null;
|
|
@@ -10,6 +11,7 @@ export declare function MessageList({ messages, messageFeedback, announcement, e
|
|
|
10
11
|
url: string;
|
|
11
12
|
alt: string;
|
|
12
13
|
};
|
|
14
|
+
notice?: string;
|
|
13
15
|
agentName?: string;
|
|
14
16
|
showFeedback?: boolean;
|
|
15
17
|
isStreaming?: boolean;
|
package/dist/config.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const DEFAULT_Z_INDEX = 2147483000;
|
|
|
6
6
|
export declare function resolveZIndex(zIndex: unknown): number;
|
|
7
7
|
export declare const DEFAULT_AGENT_NAME = "Aiden";
|
|
8
8
|
export declare function trimmedName(name: unknown): string;
|
|
9
|
+
export declare function isBlankText(text: string): boolean;
|
|
9
10
|
export declare function validateConfig(config: WidgetConfig): void;
|
|
10
11
|
export declare function normalizeGetSessionToken(config: WidgetConfig): (() => string | Promise<string>) | undefined;
|
|
11
12
|
export declare function normalizeMessages(value: unknown): Partial<WidgetMessages>;
|
package/dist/controller.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export interface WidgetState {
|
|
|
33
33
|
announcement: string | null;
|
|
34
34
|
announcementIsContent: boolean;
|
|
35
35
|
isSlowResponse: boolean;
|
|
36
|
+
noticeAgreed: boolean;
|
|
36
37
|
draft: string;
|
|
37
38
|
}
|
|
38
39
|
type Listener = (state: WidgetState) => void;
|
|
@@ -55,6 +56,8 @@ export declare class WidgetController {
|
|
|
55
56
|
readonly launcherIconUrl: string | undefined;
|
|
56
57
|
readonly emptyStateImageUrl: string | undefined;
|
|
57
58
|
readonly emptyStateImageAlt: string;
|
|
59
|
+
readonly notice: string;
|
|
60
|
+
readonly requireNoticeAgreement: boolean;
|
|
58
61
|
readonly showFeedback: boolean;
|
|
59
62
|
readonly text: WidgetMessages;
|
|
60
63
|
readonly language: SupportedLanguage;
|
|
@@ -71,6 +74,7 @@ export declare class WidgetController {
|
|
|
71
74
|
private loadBranding;
|
|
72
75
|
open(): void;
|
|
73
76
|
resetConversation(): void;
|
|
77
|
+
agreeToNotice(): void;
|
|
74
78
|
setDraft(draft: string): void;
|
|
75
79
|
close(): void;
|
|
76
80
|
sendMessage(text: string): Promise<void>;
|
package/dist/i18n/messages.d.ts
CHANGED
package/dist/storage.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare function getStoredConversationId(identifier: string): string | null;
|
|
2
2
|
export declare function setStoredConversationId(identifier: string, conversationId: string): void;
|
|
3
|
+
export declare function hasAgreedToNotice(identifier: string, notice: string): boolean;
|
|
4
|
+
export declare function setAgreedToNotice(identifier: string, notice: string): void;
|
|
3
5
|
export declare function clearStoredConversationId(identifier: string): void;
|
package/dist/types.d.ts
CHANGED
|
@@ -96,7 +96,7 @@ export interface WidgetConfig {
|
|
|
96
96
|
messages?: Partial<WidgetMessages>;
|
|
97
97
|
/**
|
|
98
98
|
* The language of the conversation's content (replies, the visitor's
|
|
99
|
-
* messages, and your greeting, title, name and image text), as a BCP 47
|
|
99
|
+
* messages, and your greeting, notice, title, name and image text), as a BCP 47
|
|
100
100
|
* tag, so screen readers read it with the right voice. Defaults to the
|
|
101
101
|
* page's <html lang>, then to `language` when the page has none, else
|
|
102
102
|
* unknown. Separate from `language`, which only sets the widget's own
|
|
@@ -122,6 +122,21 @@ export interface WidgetConfig {
|
|
|
122
122
|
name?: string;
|
|
123
123
|
title?: string;
|
|
124
124
|
greeting?: string;
|
|
125
|
+
/**
|
|
126
|
+
* A notice (e.g. a disclaimer or terms of use) pinned at the top of the
|
|
127
|
+
* conversation. Unlike `greeting` it stays after the visitor sends a
|
|
128
|
+
* message, and screen readers read it when the panel opens until then.
|
|
129
|
+
* Supports **bold**, _italic_ and [links](https://...). Blank or non-string
|
|
130
|
+
* values are ignored.
|
|
131
|
+
*/
|
|
132
|
+
notice?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Require the visitor to agree to `notice` before chatting: the panel shows
|
|
135
|
+
* an "I agree" button (the `agreeToNotice` message) in place of the message
|
|
136
|
+
* field until they do. Remembered for the tab session, and asked again if
|
|
137
|
+
* the notice text changes. Ignored without a `notice`. Off by default.
|
|
138
|
+
*/
|
|
139
|
+
requireNoticeAgreement?: boolean;
|
|
125
140
|
/** Image shown on the launcher bubble instead of the default chat icon. Alias of `theme.launcher.iconUrl`, which wins if both are set. */
|
|
126
141
|
launcherIconUrl?: string;
|
|
127
142
|
/** Image shown above the greeting while the conversation is empty. */
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const WIDGET_VERSION = "0.9.
|
|
1
|
+
export declare const WIDGET_VERSION = "0.9.1";
|
package/dist/widget.iife.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var whooAidenWidget=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t={openChat:`Open chat`,closeChat:`Close chat`,chatWith:`Chat with {name}`,newConversation:`New conversation`,conversation:`Conversation`,you:`You`,message:`Message`,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
|
-
`)&&(
|
|
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)`,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=200,O=/url\(|[@;{}\\]/i;function k(e){if(!C(e)){if(typeof e==`string`){let t=e.trim();if(t&&t.length<=D&&!O.test(t))return t}m(`ignoring \`theme.fonts.family\` -- expected a font-family stack of at most ${D} characters, without url(), @, ;, {, } or \\.`)}}var A=[`chat`,`message`,`sparkle`],ee=[`chevron-down`,`close`],te=new WeakMap;function ne(e){let t={colors:{},fontFamily:void 0,launcher:{}};if(e==null)return t;if(!S(e))return v(e),t;let n=te.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=k(o.family));let s=w(e,`launcher`,`theme.launcher`);if(s){T(s,[`icon`,`iconUrl`,`openIcon`,`openIconUrl`],`theme.launcher`);let e=E(s.icon,A,`theme.launcher.icon`),n=r(s.iconUrl,`theme.launcher.iconUrl`),i=E(s.openIcon,ee,`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 te.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 re(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 ie=new WeakMap;function ae(e){let t={...j};if(e==null)return t;if(!S(e))return y(e),t;let n=ie.get(e);if(n)return n;T(e,[`offset`,`launcherSize`,`panel`],`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=re(M(e.launcherSize,`layout.launcherSize`,j.launcherSize),`layout.launcherSize`,24,120);let i=w(e,`panel`,`layout.panel`);return i&&(T(i,[`width`,`height`],`layout.panel`),t.panelWidth=re(M(i.width,`layout.panel.width`,j.panelWidth),`layout.panel.width`,280,1/0),t.panelHeight=re(M(i.height,`layout.panel.height`,j.panelHeight),`layout.panel.height`,320,1/0)),ie.set(e,t),t}var N,oe,P,se,ce,le,ue,de,fe,pe,me={},he=[],ge=/^m(i|n|o|s|text|space)$/,_e=Array.isArray,ve=he.slice,F=Object.assign;function I(e){e&&e.parentNode&&e.remove()}function L(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||++oe,__i:-1,__u:0};return!i&&N.vnode&&N.vnode(a),a}function R(e){return e.children}function ye(e,t){this.props=e,this.context=t,this.__g=0}function z(e,t){if(t==null)return e.__?z(e.__,e.__i+1):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:z(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)||ce++)&&se==N.debounceRendering||((se=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(le),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),Ae(c,r,i,n.__n,c.namespaceURI,32&i.__u?[a]:null,o,a||z(i),32&i.__u,s),r.__v=i.__v,r.__.__k[r.__i]=r,Me(o,r,s),i.__=i.__e=null,r.__e!=a&&be(r)))}finally{P.length=ce=0}}function Ce(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r.__k||he,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]||me,p.__i=d,g=Ae(e,p,f,i,a,o,s,c,l,u),m=p.__e,(f.ref!=p.ref||8&f.__u)&&(f.ref&&Pe(f.ref,null,p,f),p.ref&&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]=L(null,o):_e(o)?o=y[a]=L(R,{children:o}):o.constructor===void 0&&o.__b?o=y[a]=L(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=z(s)),Fe(s,s));return r}function Te(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=Te(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=z(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 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,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||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`)(e.__e||={})[t]=n,n&&r||(o=pe[t]||(pe[t]=ke(t)),(e.__a||={})[t]=fe,a=t!=(t=t.replace(de,`$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 ke(e){return function(t){if(this.__e){var n=this.__e[e];if(t[ue]==null)t[ue]=fe++;else if(t[ue]<this.__a[e])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=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)}),he.push.apply(h.__h,h.__k),h.__k=[],h.__h.length&&o.push(h),s=z(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),he.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===R&&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?z(n,0):null),s=Ce(e,_e(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(I),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(I)}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||me,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&&ve.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`&&ge.test(x))&&(i=`http://www.w3.org/1999/xhtml`),Ce(l,_e(p)?p:[p],t,n,r,i,a,o,a?a[0]:n.__k&&z(n,0),s,c),a&&a.some(I)),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,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 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,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]&&Fe(r[i],t,typeof e.type!=`function`||n&&!e.props.__P);(r=e.__e)&&(n||I(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=L(R,{children:[e]}),i=[],a=[],Ae(t,t.__k,r||me,me,t.namespaceURI,r?null:t.firstChild?ve.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 ce=0,e}},oe=0,ye.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),xe(this)))},ye.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),xe(this))},ye.prototype.render=R,P=[],ce=0,le=function(e,t){return e.__v.__b-t.__v.__b},ue=Symbol(),de=/(PointerCapture)$|Capture$/i,fe=0,pe={};var B,V,Re,ze,Be=Object.is,Ve=0,He=[],Ue=[],H=N,We=H.__b,Ge=H.__r,Ke=H.diffed,qe=H.__c,Je=H.unmount,Ye=H.__;function Xe(e,t){H.__h&&H.__h(V,e,Ve||t),Ve=0;var n=V.__H||(V.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Ze(e){return Ve=1,Qe(st,e)}function Qe(e,t,n){var r=Xe(B++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):st(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=V,!V.__f)){V.__f=!0;var i=V.shouldComponentUpdate;V.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,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(B++,3);!H.__s&&ot(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,V.__H.__h.push(n))}function U(e,t){var n=Xe(B++,4);!H.__s&&ot(n.__H,t)&&(n.__P=!1,n.__=e,n.u=t,V.__h.push(n))}function W(e){return Ve=5,et(function(){return{current:e}},[])}function et(e,t){var n=Xe(B++,7);return ot(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function tt(){var e;do{for(;e=Ue.shift();)try{G(e)}catch(t){H.__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(at),t.__h=[]}catch(n){t.__h=[],H.__e(n,e.__v)}}}while(Ue.length)}H.__b=function(e){V=null,We&&We(e)},H.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ye&&Ye(e,t)},H.__r=function(e){Ge&&Ge(e),B=0;var t=(V=e.__c).__H;t&&(Re==V?V.__h=[]:(t.__h.some(G),t.__h.some(at),B=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),Re=V},H.diffed=function(e){Ke&&Ke(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&it(He.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),Re=V=null},H.__c=function(e,t){t.some(function(e){try{e.__h.some(G),e.__h=e.__h.filter(function(e){return!e.__||at(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],H.__e(n,e.__v)}}),qe&&qe(e,t)},H.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,it(Ue.push(r))}else G(r)}catch(e){t=e}}),r.__H=void 0,t&&H.__e(t,r.__v))};var nt=typeof requestAnimationFrame==`function`;function rt(e){var t,n=function(){clearTimeout(r),nt&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);nt&&(t=requestAnimationFrame(n))}function it(e){e!=1&&ze==H.requestAnimationFrame||((ze=H.requestAnimationFrame)||rt)(tt)}function G(e){var t=V,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),V=t}function at(e){var t=V;e.__c=e.__(),V=t}function ot(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!Be(t,e[n])})}function st(e,t){return typeof t==`function`?t(e):t}var ct=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:--ct,__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 lt({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 ut({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 dt({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 ft({size:e=26}){return K(q,{name:`chevron-down`,size:e,children:K(`path`,{d:`M6 9l6 6 6-6`})})}function pt({size:e=18}){return K(q,{name:`close`,size:e,children:K(`path`,{d:`M6 6l12 12M18 6L6 18`})})}var mt=`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 ht({size:e=16}){return K(q,{name:`thumb-up`,size:e,children:K(`path`,{d:mt})})}function gt({size:e=16}){return K(q,{name:`thumb-down`,size:e,children:K(`path`,{d:mt,transform:`matrix(1 0 0 -1 0 24)`})})}var _t={chat:lt,message:ut,sparkle:dt},vt={"chevron-down":ft,close:pt};function yt({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`,_=_t[i]??lt,v=vt[o]??ft;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 bt={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)`,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`,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`,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`,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`,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:`メッセージ`,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:`消息`,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:`Сообщение`,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:`संदेश`,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:`الرسالة`,send:`إرسال`,lookingItUp:`جارٍ البحث عن المعلومات…`,goodResponse:`إجابة جيدة`,badResponse:`إجابة سيئة`,additionalFeedback:`ملاحظات إضافية`,feedbackPlaceholder:`ما المشكلة؟ (اختياري)`,feedbackCategory:`فئة الملاحظات`,selectReason:`اختر سببًا (اختياري)`,categoryFactual:`معلومات غير صحيحة`,categoryIncomplete:`إجابة غير مكتملة`,categoryTone:`أسلوب غير مناسب`,categoryOther:`أخرى`,submit:`إرسال الملاحظات`,cancel:`إلغاء`,feedbackThanks:`شكرًا على ملاحظاتك`,feedbackFailed:`تعذّر إرسال الملاحظات`,conversationCleared:`تم مسح المحادثة`,genericError:`حدث خطأ ما. يُرجى المحاولة مرة أخرى.`,sessionExpired:`انتهت صلاحية جلسة الدردشة هذه. يُرجى إعادة تحميل الصفحة للمتابعة.`,opensInNewTab:`(يُفتح في علامة تبويب جديدة)`,agreeToNotice:`أوافق`}},xt=Object.freeze(Object.keys(bt)),St={pt:`pt-BR`,es:`es-419`,zh:`zh-Hans`},Ct=new Set([`ar`]),wt=/^[a-z]{2,8}([-_][a-z0-9]{1,8})*$/i,Tt=/^zh[-_](hant|tw|hk|mo)(?=$|[-_])/i;function Et(e){return bt[e]}function Dt(e){let t=e.trim();if(!wt.test(t)||Tt.test(t))return null;let n=t.split(/[-_]/)[0].toLowerCase();return Object.hasOwn(bt,n)?n:null}function Ot(e,t){let n=null;return e!=null&&e!==``&&(n=typeof e==`string`?Dt(e):null,n||console.warn(`whoo-aiden-widget: ignoring \`language\` ${kt(e)} -- expected one of ${xt.join(`, `)} (or a regional tag like pt-BR). Using the page's language instead.`)),n??=typeof t==`string`?Dt(t):null,n??=`en`,{language:n,tag:St[n]??n,dir:Ct.has(n)?`rtl`:`ltr`}}function kt(e){return typeof e==`string`?JSON.stringify(e):`(a ${typeof e})`}function At(e){if(typeof e!=`string`)return null;let t=e.trim().replace(/_/g,`-`);return wt.test(t)?t:null}function jt(e,t,n){if(e!=null&&e!==``){let t=At(e);if(t)return t;console.warn(`whoo-aiden-widget: ignoring \`contentLanguage\` ${kt(e)} -- expected a language tag such as 'nl' or 'pt-BR'. Using the page's language instead.`)}return At(t)??At(n)??``}function Mt(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 Nt=`(max-width: 400px), (max-height: 420px)`,Pt=`data-fit-visible`,Ft=40;function It(e){let t=typeof window<`u`?window.visualViewport:null;if(!t)return()=>{};let n=()=>{e.removeAttribute(Pt),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<Ft){n();return}e.setAttribute(Pt,``),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 Lt(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 Rt=0,zt=``;function Bt(){Rt++===0&&(zt=document.documentElement.style.overflow,document.documentElement.style.overflow=`hidden`)}function Vt(){--Rt===0&&(document.documentElement.style.overflow=zt)}function Ht(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return()=>{};let e=window.matchMedia(Nt),t=!1,n=()=>{e.matches&&!t?(t=!0,Bt()):!e.matches&&t&&(t=!1,Vt())};n();let r=Lt(e,n);return()=>{r(),t&&(t=!1,Vt())}}function Ut(e){if(typeof window>`u`||typeof window.matchMedia!=`function`||typeof e.showModal!=`function`)return()=>{};let t=window.matchMedia(Nt),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(),Lt(t,r)}function Wt(e){return e.isComposing||e.keyCode===229}function Gt({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`&&!Wt(e)&&r()}}),K(`button`,{type:`button`,class:`whoo-widget-composer-send`,"aria-disabled":i,onClick:()=>{i||r()},children:o.send})]})}function Kt({message:e}){return K(`div`,{class:`whoo-widget-error-banner`,role:`alert`,children:e})}var qt=/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y,Jt=/\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y,Yt=/(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y,Xt=/\*([^*\s](?:[^*]*[^*\s])?)\*/y,Zt=/[ \t]*[*+-][ \t]+/y,Qt=/https?:\/\/\S+/y,$t=/[.,;:!?)\]}>]+$/;function en(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
|
+
`)&&(Zt.lastIndex=n,Zt.exec(e))){i(n),t.push({type:`text`,value:`• `,start:n,end:Zt.lastIndex}),n=Zt.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]!==`!`){qt.lastIndex=n;let a=qt.exec(e);if(a){i(n),t.push({type:`link`,text:a[1],url:a[2],start:n,end:qt.lastIndex}),n=qt.lastIndex,r=n;continue}}Jt.lastIndex=n;let a=Jt.exec(e);if(a){i(n),t.push({type:`bold`,value:a[1],start:n,end:Jt.lastIndex}),n=Jt.lastIndex,r=n;continue}Yt.lastIndex=n;let o=Yt.exec(e);if(o){i(n),t.push({type:`italic`,value:o[1],start:n,end:Yt.lastIndex}),n=Yt.lastIndex,r=n;continue}Xt.lastIndex=n;let s=Xt.exec(e);if(s){i(n),t.push({type:`italic`,value:s[1],start:n,end:Xt.lastIndex}),n=Xt.lastIndex,r=n;continue}Qt.lastIndex=n;let c=Qt.exec(e);if(c){let e=c[0].match($t),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 tn=/^[ \t]*[*+-][ \t]+(.*)$/,nn=/[\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 rn(e){let t=e.match(/\p{L}/u)?.[0];if(t)return nn.test(t)?`rtl`:`ltr`}function an(e){let t=[],n=[],r=[],i=()=>{n.length>0&&t.push({type:`text`,text:n.join(`
|
|
3
3
|
`)}),n=[]},a=()=>{r.length>0&&t.push({type:`list`,items:r}),r=[]};for(let t of e.split(`
|
|
4
|
-
`)){let e=t.match(
|
|
5
|
-
`),r=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(tn);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 en(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 on(e,t={}){let n=e.replace(/\r\n?/g,`
|
|
5
|
+
`),r=an(n);return r?r.map((e,n)=>e.type===`list`?K(`ul`,{class:`whoo-widget-list`,dir:rn(e.items.find(e=>rn(e))??``),children:e.items.map((e,n)=>K(`li`,{dir:rn(e),children:J(e,t)},n))},n):K(`span`,{children:J(e.text,t)},n)):J(n,t)}function sn(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 cn({state:e,containerRef:n,onThumbsUp:r,onThumbsDown:i,onDraftChange:a,onSubmitDetailed:o,onCancel:s,text:c=t,contentLanguage:l}){let u=e.correction??``,d=e.category??``,f=W(e.status),p=W(null),m=W(null);if(U(()=>{let t=f.current;if(f.current=e.status,t===e.status)return;if(e.status===`expanded`){p.current?.focus();return}if(t===`expanded`&&e.status===`idle`){m.current?.focus();return}let r=n?.current;if(!r)return;let i=r.getRootNode(),a=r.ownerDocument,o=i.activeElement;(o===null?a.activeElement===null||a.activeElement===a.body:o===a.body)&&r.focus()},[e.status,n]),e.status===`expanded`)return K(`div`,{class:`whoo-widget-feedback-form`,children:[K(`label`,{children:[K(`span`,{class:`whoo-widget-sr-only`,children:c.additionalFeedback}),K(`textarea`,{ref:p,class:`whoo-widget-feedback-textarea`,lang:l,value:u,onInput:e=>a(e.target.value,d),placeholder:c.feedbackPlaceholder})]}),K(`select`,{class:`whoo-widget-feedback-select`,"aria-label":c.feedbackCategory,value:d,onChange:e=>a(u,e.target.value),children:sn(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(ht,{})}),K(`button`,{ref:m,type:`button`,"aria-label":c.badResponse,"aria-disabled":h,onClick:()=>{h||i()},children:K(gt,{})})]}),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 ln({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 un({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)})}var dn=`whoo-widget-notice`;function fn({notice:e,text:t,contentLanguage:n,languageTag:r}){return K(`div`,{id:dn,class:`whoo-widget-notice`,role:`note`,children:K(`div`,{class:`whoo-widget-message-text`,dir:`auto`,lang:n,children:on(e,{linkCue:t.opensInNewTab,linkCueLang:r})})})}function pn({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(ln,{isSlowResponse:a,text:d}):K(`div`,{class:`whoo-widget-message-text`,dir:`auto`,lang:f,children:on(e.content,{linkCue:d.opensInNewTab,linkCueLang:p})}),r&&e.role===`assistant`&&h?K(cn,{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 mn({messages:e,messageFeedback:n,announcement:r,emptyStateImage:i,notice:a,agentName:o=u,showFeedback:s=!1,isStreaming:c=!1,isSlowResponse:l=!1,onThumbsUp:d,onThumbsDown:f,onDraftChange:p=()=>{},onSubmitDetailed:m,onCancelFeedback:h,text:g=t,contentLanguage:_,languageTag:v,announcementIsContent:y=!1}){let b=W(null),x=!!a&&!e.some(e=>e.role===`user`);return $e(()=>{let e=b.current;e&&(e.scrollTop=x?0:e.scrollHeight)},[e,l,x]),K(R,{children:[K(`section`,{class:`whoo-widget-message-list`,ref:b,"aria-label":g.conversation,tabIndex:0,children:[i?K(un,{...i,lang:_}):null,a?K(fn,{notice:a,text:g,contentLanguage:_,languageTag:v}):null,e.map((t,r)=>K(pn,{message:t,speaker:t.role===`user`?g.you:o,showFeedback:s,feedbackState:t.id?n[t.id]??{status:`idle`}:{status:`idle`},pending:c&&r===e.length-1&&t.role===`assistant`&&t.content===``,isSlowResponse:l,onThumbsUp:d,onThumbsDown:f,onDraftChange:p,onSubmitDetailed:m,onCancelFeedback:h,text:g,contentLanguage:_,languageTag:v},t.id??r))]}),K(`div`,{class:`whoo-widget-sr-only`,"aria-live":`polite`,"aria-atomic":`true`,lang:y?_:v,children:r??``})]})}var hn=`button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`;function gn(e){return Array.from(e.querySelectorAll(hn)).filter(e=>{let t=getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`})}function _n({state:e,controller:t,greeting:n}){let r=W(null),i=W(null),a=W(null),o=W(!1);U(()=>{(a.current??i.current)?.focus()},[]),U(()=>{e.noticeAgreed&&o.current&&(o.current=!1,i.current?.focus())},[e.noticeAgreed]),U(()=>{let e=r.current,n=e?It(e):()=>{},i=e?Ut(e):()=>{},a=()=>{e&&!e.open&&t.close()};e?.addEventListener(`close`,a);let o=Ht();return()=>{n(),i(),e?.removeEventListener(`close`,a),o()}},[]);let s=e=>{if(e.key===`Escape`&&!Wt(e)){e.preventDefault(),t.close();return}if(e.key!==`Tab`)return;let n=r.current;if(!n)return;let i=gn(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}=Mt(t.text.chatWith),h=e.messages.length===0&&n?[{role:`assistant`,content:n,id:null}]:e.messages,g=t.emptyStateImageUrl,_=e.messages.length===0&&g?{url:g,alt:t.emptyStateImageAlt}:void 0;return K(`dialog`,{open:!0,class:`whoo-widget-panel`,"aria-modal":`true`,"aria-labelledby":`whoo-widget-title`,"aria-describedby":t.notice&&e.noticeAgreed&&e.messages.length===0?dn:void 0,ref:r,onKeyDown:s,onCancel:e=>{e.preventDefault(),t.close()},children:[K(`div`,{class:`whoo-widget-header`,children:[u?K(`h2`,{id:`whoo-widget-title`,class:`whoo-widget-header-title`,lang:t.contentLanguage,dir:`auto`,children:u}):K(`h2`,{id:`whoo-widget-title`,class:`whoo-widget-header-title`,children:[f,m?K(`bdi`,{lang:t.contentLanguage,children:l}):null,p]}),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(pt,{})})]})]}),K(mn,{messages:h,messageFeedback:e.messageFeedback,announcement:e.announcement,emptyStateImage:_,notice:t.notice,agentName:l,showFeedback:t.showFeedback,isStreaming:e.isStreaming,isSlowResponse:e.isSlowResponse,onThumbsUp:e=>t.submitFeedback(e,`up`),onThumbsDown:e=>t.expandFeedback(e),onDraftChange:(e,n,r)=>t.setFeedbackDraft(e,n,r),onSubmitDetailed:(e,n,r)=>t.submitFeedback(e,`down`,n||void 0,r||void 0),onCancelFeedback:e=>t.cancelFeedback(e),text:t.text,contentLanguage:t.contentLanguage,languageTag:t.languageTag,announcementIsContent:e.announcementIsContent}),e.runtimeError&&K(Kt,{message:e.runtimeError}),e.noticeAgreed?K(Gt,{value:e.draft,onChange:e=>t.setDraft(e),onSend:c,disabled:e.isStreaming,inputRef:i,text:t.text,contentLanguage:t.contentLanguage}):K(`div`,{class:`whoo-widget-agreement`,children:K(`button`,{type:`button`,class:`whoo-widget-agreement-button`,ref:a,"aria-describedby":dn,autoFocus:!0,onClick:()=>{o.current=!0,t.agreeToNotice()},children:t.text.agreeToNotice})})]})}function vn({controller:e}){let[t,n]=Ze(e.getState()),r=W(null),i=W(t.isOpen);return $e(()=>(n(e.getState()),e.subscribe(n)),[e]),U(()=>{i.current&&!t.isOpen&&r.current?.focus(),i.current=t.isOpen},[t.isOpen]),t.initError||t.isInitializing?null:K(R,{children:[K(yt,{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(_n,{state:t,controller:e,greeting:e.config.greeting})]})}var yn=class extends Error{status;constructor(e,t){super(e),this.name=`WidgetApiError`,this.status=t}};function bn(e){if(typeof e!=`string`)return null;let t=e.trim();return t===``?null:t}async function xn(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 yn(`Failed to create widget session (${n.status})`,n.status);let r=await n.json();return{token:r.token,...Sn(r)}}function Sn(e){return{primaryColor:bn(e.primary_color),name:bn(e.name),accentColor:bn(e.accent_color),inkColor:bn(e.ink_color)}}async function Cn(e,t){let n=await fetch(`${e}/api/v1/widget/branding`,{headers:{Authorization:`Bearer ${t}`}});if(!n.ok)throw new yn(`Failed to load widget branding (${n.status})`,n.status);return Sn(await n.json())}async function wn(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 yn(`Feedback submission failed (${r.status})`,r.status)}async function*Tn(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 yn(`Chat request failed (${a.status})`,a.status);let o=a.body.getReader(),s=new TextDecoder,c=``;for(;;){let{done:e,value:t}=await o.read();if(e)break;c+=s.decode(t,{stream:!0});let n=c.indexOf(`
|
|
6
6
|
|
|
7
7
|
`);for(;n!==-1;){let e=c.slice(0,n);c=c.slice(n+2);let t=e.split(`
|
|
8
|
-
`).find(e=>e.startsWith(`data: `));if(i?.aborted)return;t&&(yield
|
|
8
|
+
`).find(e=>e.startsWith(`data: `));if(i?.aborted)return;t&&(yield En(JSON.parse(t.slice(6)))),n=c.indexOf(`
|
|
9
9
|
|
|
10
|
-
`)}}}function
|
|
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 En(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 Dn(e){return en(e.replace(/\r\n?/g,`
|
|
11
|
+
`)).map(e=>{switch(e.type){case`bold`:case`italic`:return Dn(e.value);case`link`:return e.text;default:return e.value}}).join(``)}var On=40,kn=120;function An(e){let t=[];for(let n of en(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 jn(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 Mn(e,t,n){let r=n?.wordIntervalMs??On,i=n?.tokenIntervalMs??kn,a=n?.signal,o=en(e),s=new Set(o.filter(e=>e.type!==`text`).map(e=>e.end)),c=jn(a),l=``;for(let n of An(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 Nn(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 Pn(e){let t=Nn(e)?.exp;return typeof t==`number`?t*1e3:null}function Fn(e,t=Date.now()){let n=Pn(e);return n!==null&&n<=t}function In(e,t=Date.now()){let n=Nn(e);return n?.exp==null?null:n.iat!=null&&n.exp>n.iat?t+(n.exp-n.iat)*1e3:n.exp*1e3}function Ln(e){return`whoo-aiden-widget:conversation:${e}`}function Rn(e){try{return window.sessionStorage.getItem(Ln(e))}catch{return null}}function zn(e,t){try{window.sessionStorage.setItem(Ln(e),t)}catch{}}function Bn(e){return`whoo-aiden-widget:notice-agreed:${e}`}function Vn(e,t){try{return window.sessionStorage.getItem(Bn(e))===t}catch{return!1}}function Hn(e,t){try{window.sessionStorage.setItem(Bn(e),t)}catch{}}function Un(e){try{window.sessionStorage.removeItem(Ln(e))}catch{}}var Wn=/^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;function Gn(e){if(Wn.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 Gn(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 Kn(e,t){let n=Math.max(e,t),r=Math.min(e,t);return(n+.05)/(r+.05)}function qn(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 Kn(n,X([0,0,0]))>=Kn(n,X([255,255,255]))?`#000000`:`#ffffff`}function Jn(e,t){let n=Y(e),r=Y(t);return!n||!r?NaN:Kn(X(n),X(r))}var Yn=a.primary,Xn=a.panel,Zn=a.assistantBubble,Qn=a.headerHover,$n=4.5;function er([e,t,n]){return`#${[e,t,n].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function tr(e,t=Xn){let n=Y(e),r=Y(t);if(!n||!r)return Yn;let i=X(r),a=e=>Kn(X(e),i)>=$n;if(a(n))return er(n);for(let e=.99;e>0;e-=.01){let t=n.map(t=>Math.round(t*e));if(a(t))return er(t)}return`#000000`}var nr=a.ink,rr=a.link;function Z(e){if(typeof e!=`string`||!e)return null;let t=Gn(e);return t?er(t.rgb):null}function ir(e){if(typeof e!=`string`||!e)return null;let t=Gn(e);return t?t.translucent?e.trim():er(t.rgb):null}var ar=[{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 or({color:e,inkColor:t,accentColor:n,overrides:r}){let o=typeof r==`object`&&r&&!Array.isArray(r)?r:{},s=e=>ir(o[e]),c=Z(e),l=s(`primary`),u=l??c??Yn,d=s(`primaryText`),f=d??tr(u,Qn),p=s(`onPrimary`)??qn(u),m=Z(t),h=s(`ink`)??(m?tr(m,Zn):nr),g=Z(n),_=s(`link`)??(g?tr(g,Zn):rr),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 ar)for(let r of t){if(!b[e]&&!b[r])continue;let t=Jn(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 sr(e,t,n=Yn){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=or({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 cr(e,{inkColor:t,accentColor:n}){let r=or({inkColor:t,accentColor:n});e.style.setProperty(`--whoo-widget-ink`,r.ink),e.style.setProperty(`--whoo-widget-link-color`,r.link)}function lr(e,t){let n=or({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 ur(e,t){e&&Z(e)===null&&console.warn(`[whoo-aiden-widget] Could not use ${Q(e)} as the ${t}; using the default.`)}function dr(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`&&Gn(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.`),fr({color:e.color,inkColor:e.inkColor,accentColor:e.accentColor,overrides:t},n)}function fr(e,t){for(let n of or(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 pr(e,t,n=new Set){sr(e,t.color??Yn),ur(t.inkColor,`ink color`),ur(t.accentColor,`accent color`),cr(e,{inkColor:t.inkColor,accentColor:t.accentColor});let r=ne(t.theme);dr(t,r.colors,n),lr(e,r.colors),r.fontFamily&&e.style.setProperty(`--whoo-widget-font`,r.fontFamily)}var mr=8e3,hr=3e3,gr=15e3,_r=class extends Error{name=`SessionUnavailableError`};function vr(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 yr(e,t){return e===`refused`?new xr(t):new _r}function br(e){let t=e?.status;return t===401||t===403||t===404}var xr=class extends Error{name=`SessionExpiredError`;constructor(e){super(e instanceof Error?e.message:`The session has expired.`)}};function Sr(e){return e?.status===401}function Cr(e,t){return new Promise(n=>{let r=setTimeout(n,t);e.then(()=>{clearTimeout(r),n()})})}var wr=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;showFeedback;text;language;languageTag;contentLanguage;dir;constructor(e){this.config=e;let t=ne(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.showFeedback=e.showFeedback===!0,this.storageIdentifier=e.publishableKey??`session-token-mode`,this.getSessionToken=h(e);let{language:i,tag:a,dir:o}=Ot(e.language,typeof document>`u`?void 0:document.documentElement.lang);this.language=i,this.languageTag=a,this.dir=o,this.contentLanguage=jt(e.contentLanguage,typeof document>`u`?void 0:document.documentElement.lang,e.language),this.text={...Et(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||Vn(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(Fn(this.config.sessionToken)){if(!(`token`in await this.renewToken()))throw Error(`The sessionToken has expired.`)}else this.sessionToken=this.config.sessionToken,this.sessionTokenExpiresAt=Pn(this.config.sessionToken)}else if(this.config.publishableKey){let{token:t,primaryColor:n,name:r,accentColor:i,inkColor:a}=await xn(e,this.config.publishableKey);this.sessionToken=t,this.sessionTokenExpiresAt=In(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=Rn(this.storageIdentifier),this.config.sessionToken&&await Cr(this.loadBranding(e),hr)}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=>Cn(e,t));this.setState({primaryColor:n,agentName:r,accentColor:i,inkColor:a})}catch(e){let t=e?.status;(e instanceof xr||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,Un(this.storageIdentifier),this.setState({messages:[],messageFeedback:{},runtimeError:null,isStreaming:!1,announcement:this.text.conversationCleared,announcementIsContent:!1})}agreeToNotice(){this.state.noticeAgreed||(Hn(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})},mr);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=Tn(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,zn(this.storageIdentifier,t.conversationId);else if(t.type===`delta`)this.clearSlowResponse(),t.verbatim&&!this.prefersReducedMotion?(await Mn(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,zn(this.storageIdentifier,t.conversationId)),t.messageId&&s({id:t.messageId}),r()&&this.setState({announcement:Dn(h),announcementIsContent:!0});else if(t.type===`error`){console.error(`[whoo-aiden-widget] chat error:`,t.error),h.trim()!==``&&r()&&this.setState({announcement:Dn(h),announcementIsContent:!0}),m(),l.abort();break}}}catch(e){u.aborted?u.reason===`close`&&r()&&!d&&p():e instanceof xr?(console.error(`[whoo-aiden-widget] chat request failed: the session has expired.`,e),m(this.text.sessionExpired)):e instanceof _r?(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=>wn(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}:vr(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`})},gr)});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 xn(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&&br(e)?`refused`:`unavailable`}}let r=typeof n==`string`?In(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 yr(n.failure);let{token:r}=n;try{return await e(r)}catch(n){if(!Sr(n))throw n;let i=this.sessionToken&&this.sessionToken!==r?{token:this.sessionToken}:await vr(this.renewToken(),t);if(!(`token`in i))throw yr(i.failure,n);try{return await e(i.token)}catch(e){throw Sr(e)?new xr(e):e}}}},$=20,Tr=12,Er=300,Dr=352;function Or(){try{return typeof CSS<`u`&&CSS.supports?.(`height`,`100dvh`)?`dvh`:`vh`}catch{return`vh`}}function kr(e,t){let{offsetX:n,offsetY:r,launcherSize:i,panelWidth:a,panelHeight:o}=ae(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-Er),t=Math.max($,window.innerHeight-i-Dr);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${Or()}`,l=`min(${n}px, max(${$}px, calc(100vw - ${Er}px)), calc(100vw - ${i}px))`,u=`min(${r}px, max(${$}px, calc(${c} - ${i+Dr}px)), calc(${c} - ${i}px))`,d=`calc(${u} + ${i}px + ${Tr}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 Ar=`: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-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{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);unicode-bidi:plaintext;border-radius:6px;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{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;border-radius:6px;padding:8px 16px;font-weight:600;display:block}.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-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 jr(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=Ar,n.appendChild(r);let i=document.createElement(`div`);n.appendChild(i);let a=new Set;pr(i,e,a),kr(i,e);let o=new wr(e);i.setAttribute(`lang`,o.languageTag),i.setAttribute(`dir`,o.dir);let s=Z(e.color)!==null,c=null,u=``,d=ne(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,sr(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;cr(i,{inkColor:a,accentColor:o}),p={...p,inkColor:a,accentColor:o},n=!0}n&&(lr(i,d),f&&fr({...p,overrides:d},a))}),o.init(),Le(K(vn,{controller:o}),i),document.body.appendChild(t),{unmount(){Le(null,i),t.remove()}}}function Mr(e){return p(e),jr(e)}return e.init=Mr,e})({});
|