@trillet-ai/web-sdk 1.9.2 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,31 +1,256 @@
1
1
  import {
2
2
  TrilletAgent
3
- } from "../chunk-FSJ42TKR.js";
4
- import "../chunk-3MH6DJZ6.js";
3
+ } from "../chunk-IASKK2IK.js";
4
+ import {
5
+ apiUrl
6
+ } from "../chunk-CVTVHUNZ.js";
5
7
 
6
- // src/widget/config.ts
7
- var DEFAULT_ORB_COLOR_1 = "#2792dc";
8
- var DEFAULT_ORB_COLOR_2 = "#9ce6e6";
9
- var DEFAULT_COPY = {
10
- startCallText: "Start a call",
11
- endCallText: "End call",
12
- messageText: "Message",
13
- switchToTextText: "Switch to text mode",
14
- switchToVoiceText: "Switch to voice mode",
15
- listeningText: "Listening\u2026",
16
- speakingText: "Speaking\u2026",
17
- expandText: "Expand",
18
- collapseText: "Collapse",
19
- recaptchaText: "Verify you are human to start"
8
+ // src/widget/i18n.ts
9
+ var WIDGET_LANGUAGES = ["en", "de", "fr", "it"];
10
+ var WIDGET_COPY = {
11
+ en: {
12
+ startCallText: "Start a call",
13
+ startChatText: "Start chat",
14
+ endCallText: "End call",
15
+ endChatText: "End chat",
16
+ endConversationText: "End conversation",
17
+ messageText: "Message",
18
+ callLabel: "Call",
19
+ chatLabel: "Chat",
20
+ switchToTextText: "Switch to text mode",
21
+ switchToVoiceText: "Switch to voice mode",
22
+ listeningText: "Listening\u2026",
23
+ speakingText: "Speaking\u2026",
24
+ expandText: "Expand",
25
+ collapseText: "Collapse",
26
+ recaptchaText: "Verify you are human to start",
27
+ inputPlaceholder: "Type a message\u2026",
28
+ askAnything: "Ask anything\u2026",
29
+ askNamed: "Ask {name} anything\u2026",
30
+ chooseModePrompt: "How would you like to talk?",
31
+ talkToUs: "Talk to us now",
32
+ connecting: "Connecting\u2026",
33
+ online: "Online",
34
+ callEnded: "Call ended",
35
+ chatEnded: "This chat has ended.",
36
+ startNewChat: "Start a new chat",
37
+ backToChat: "Back to chat",
38
+ chatWithNamed: "Chat with {name}",
39
+ chat: "Chat",
40
+ send: "Send",
41
+ close: "Close",
42
+ typing: "Typing",
43
+ muteMic: "Mute microphone",
44
+ unmuteMic: "Unmute microphone",
45
+ terms: "Terms",
46
+ termsTitle: "Before we start",
47
+ termsAccept: "Agree and continue",
48
+ termsDecline: "Not now",
49
+ feedbackQuestion: "How was this conversation?",
50
+ feedbackThanks: "Thanks for the feedback.",
51
+ errorNotEnabled: "Chat is not enabled on this website.",
52
+ errorUnavailable: "Chat is not available right now.",
53
+ errorTooMany: "Too many chats right now. Please try again shortly.",
54
+ errorGeneric: "Could not connect. Please try again.",
55
+ feedbackGood: "Good",
56
+ feedbackBad: "Not good",
57
+ openChat: "Open the chat",
58
+ minimize: "Minimize",
59
+ typeInstead: "Type instead",
60
+ showConversation: "Show the conversation",
61
+ talkInstead: "Talk instead"
62
+ },
63
+ de: {
64
+ startCallText: "Anruf starten",
65
+ startChatText: "Chat starten",
66
+ endCallText: "Anruf beenden",
67
+ endChatText: "Chat beenden",
68
+ endConversationText: "Gespr\xE4ch beenden",
69
+ messageText: "Nachricht",
70
+ callLabel: "Anrufen",
71
+ chatLabel: "Chat",
72
+ switchToTextText: "Zum Textmodus wechseln",
73
+ switchToVoiceText: "Zum Sprachmodus wechseln",
74
+ listeningText: "H\xF6rt zu\u2026",
75
+ speakingText: "Spricht\u2026",
76
+ expandText: "Erweitern",
77
+ collapseText: "Verkleinern",
78
+ recaptchaText: "Bitte best\xE4tigen Sie, dass Sie ein Mensch sind",
79
+ inputPlaceholder: "Nachricht eingeben\u2026",
80
+ askAnything: "Stellen Sie Ihre Frage\u2026",
81
+ askNamed: "Ihre Frage an {name}\u2026",
82
+ chooseModePrompt: "Wie m\xF6chten Sie mit uns sprechen?",
83
+ talkToUs: "Jetzt mit uns sprechen",
84
+ connecting: "Verbindung wird hergestellt\u2026",
85
+ online: "Online",
86
+ callEnded: "Anruf beendet",
87
+ chatEnded: "Dieser Chat wurde beendet.",
88
+ startNewChat: "Neuen Chat starten",
89
+ backToChat: "Zur\xFCck zum Chat",
90
+ chatWithNamed: "Chat mit {name}",
91
+ chat: "Chat",
92
+ send: "Senden",
93
+ close: "Ausblenden",
94
+ typing: "Schreibt",
95
+ muteMic: "Mikrofon stummschalten",
96
+ unmuteMic: "Mikrofon einschalten",
97
+ terms: "Nutzungsbedingungen",
98
+ termsTitle: "Bevor wir beginnen",
99
+ termsAccept: "Zustimmen und fortfahren",
100
+ termsDecline: "Nicht jetzt",
101
+ feedbackQuestion: "Wie war dieses Gespr\xE4ch?",
102
+ feedbackThanks: "Danke f\xFCr Ihr Feedback.",
103
+ errorNotEnabled: "Der Chat ist auf dieser Website nicht aktiviert.",
104
+ errorUnavailable: "Der Chat ist im Moment nicht verf\xFCgbar.",
105
+ errorTooMany: "Gerade sind zu viele Chats aktiv. Bitte versuchen Sie es gleich nochmals.",
106
+ errorGeneric: "Verbindung fehlgeschlagen. Bitte versuchen Sie es nochmals.",
107
+ feedbackGood: "Gut",
108
+ feedbackBad: "Nicht gut",
109
+ openChat: "Chat \xF6ffnen",
110
+ minimize: "Minimieren",
111
+ typeInstead: "Lieber schreiben",
112
+ showConversation: "Gespr\xE4ch anzeigen",
113
+ talkInstead: "Lieber sprechen"
114
+ },
115
+ fr: {
116
+ startCallText: "D\xE9marrer un appel",
117
+ startChatText: "D\xE9marrer le chat",
118
+ endCallText: "Terminer l'appel",
119
+ endChatText: "Terminer le chat",
120
+ endConversationText: "Terminer la conversation",
121
+ messageText: "Message",
122
+ callLabel: "Appeler",
123
+ chatLabel: "Chat",
124
+ switchToTextText: "Passer au mode texte",
125
+ switchToVoiceText: "Passer au mode vocal",
126
+ listeningText: "\xC9coute\u2026",
127
+ speakingText: "Parle\u2026",
128
+ expandText: "Agrandir",
129
+ collapseText: "R\xE9duire",
130
+ recaptchaText: "Veuillez confirmer que vous \xEAtes humain",
131
+ inputPlaceholder: "\xC9crivez un message\u2026",
132
+ askAnything: "Posez votre question\u2026",
133
+ askNamed: "Votre question pour {name}\u2026",
134
+ chooseModePrompt: "Comment souhaitez-vous \xE9changer ?",
135
+ talkToUs: "Parlez-nous maintenant",
136
+ connecting: "Connexion\u2026",
137
+ online: "En ligne",
138
+ callEnded: "Appel termin\xE9",
139
+ chatEnded: "Ce chat est termin\xE9.",
140
+ startNewChat: "D\xE9marrer un nouveau chat",
141
+ backToChat: "Retour au chat",
142
+ chatWithNamed: "Chat avec {name}",
143
+ chat: "Chat",
144
+ send: "Envoyer",
145
+ close: "Fermer",
146
+ typing: "En train d'\xE9crire",
147
+ muteMic: "Couper le micro",
148
+ unmuteMic: "Activer le micro",
149
+ terms: "Conditions",
150
+ termsTitle: "Avant de commencer",
151
+ termsAccept: "Accepter et continuer",
152
+ termsDecline: "Pas maintenant",
153
+ feedbackQuestion: "Comment s\u2019est pass\xE9e cette conversation ?",
154
+ feedbackThanks: "Merci pour votre retour.",
155
+ errorNotEnabled: "Le chat n'est pas activ\xE9 sur ce site.",
156
+ errorUnavailable: "Le chat n'est pas disponible pour le moment.",
157
+ errorTooMany: "Trop de chats en cours. Veuillez r\xE9essayer dans un instant.",
158
+ errorGeneric: "Connexion impossible. Veuillez r\xE9essayer.",
159
+ feedbackGood: "Bien",
160
+ feedbackBad: "Pas bien",
161
+ openChat: "Ouvrir le chat",
162
+ minimize: "R\xE9duire",
163
+ typeInstead: "\xC9crire plut\xF4t",
164
+ showConversation: "Afficher la conversation",
165
+ talkInstead: "Parler plut\xF4t"
166
+ },
167
+ it: {
168
+ startCallText: "Avvia una chiamata",
169
+ startChatText: "Avvia la chat",
170
+ endCallText: "Termina la chiamata",
171
+ endChatText: "Termina la chat",
172
+ endConversationText: "Termina la conversazione",
173
+ messageText: "Messaggio",
174
+ callLabel: "Chiama",
175
+ chatLabel: "Chat",
176
+ switchToTextText: "Passa alla modalit\xE0 testo",
177
+ switchToVoiceText: "Passa alla modalit\xE0 vocale",
178
+ listeningText: "In ascolto\u2026",
179
+ speakingText: "Sta parlando\u2026",
180
+ expandText: "Espandi",
181
+ collapseText: "Riduci",
182
+ recaptchaText: "Confermi di non essere un robot",
183
+ inputPlaceholder: "Scriva un messaggio\u2026",
184
+ askAnything: "Faccia la sua domanda\u2026",
185
+ askNamed: "La sua domanda per {name}\u2026",
186
+ chooseModePrompt: "Come preferisce comunicare?",
187
+ talkToUs: "Parli con noi ora",
188
+ connecting: "Connessione in corso\u2026",
189
+ online: "Online",
190
+ callEnded: "Chiamata terminata",
191
+ chatEnded: "Questa chat \xE8 terminata.",
192
+ startNewChat: "Avvia una nuova chat",
193
+ backToChat: "Torna alla chat",
194
+ chatWithNamed: "Chat con {name}",
195
+ chat: "Chat",
196
+ send: "Invia",
197
+ close: "Chiudi",
198
+ typing: "Sta scrivendo",
199
+ muteMic: "Disattiva microfono",
200
+ unmuteMic: "Attiva microfono",
201
+ terms: "Condizioni",
202
+ termsTitle: "Prima di iniziare",
203
+ termsAccept: "Accetta e continua",
204
+ termsDecline: "Non ora",
205
+ feedbackQuestion: "Com\u2019\xE8 andata questa conversazione?",
206
+ feedbackThanks: "Grazie per il feedback.",
207
+ errorNotEnabled: "La chat non \xE8 attiva su questo sito.",
208
+ errorUnavailable: "La chat non \xE8 disponibile al momento.",
209
+ errorTooMany: "Troppe chat in corso. Riprovi tra poco.",
210
+ errorGeneric: "Connessione non riuscita. Riprovi.",
211
+ feedbackGood: "Bene",
212
+ feedbackBad: "Non bene",
213
+ openChat: "Apri la chat",
214
+ minimize: "Riduci a icona",
215
+ typeInstead: "Preferisco scrivere",
216
+ showConversation: "Mostra la conversazione",
217
+ talkInstead: "Preferisco parlare"
218
+ }
20
219
  };
220
+ function normalizeLanguage(tag) {
221
+ if (!tag) return null;
222
+ const base = tag.trim().toLowerCase().split(/[-_]/)[0];
223
+ return WIDGET_LANGUAGES.includes(base) ? base : null;
224
+ }
225
+ function resolveLanguage(attr, remote, pageLang) {
226
+ var _a, _b, _c;
227
+ return (_c = (_b = (_a = normalizeLanguage(attr)) != null ? _a : normalizeLanguage(remote)) != null ? _b : normalizeLanguage(pageLang)) != null ? _c : "en";
228
+ }
229
+ function fillName(template, name) {
230
+ return template.replace("{name}", name);
231
+ }
232
+
233
+ // src/widget/config.ts
21
234
  var OBSERVED_ATTRIBUTES = [
22
235
  "agent-id",
23
236
  "signed-url-endpoint",
24
237
  "workspace-id",
238
+ "api-base",
239
+ "remote-config",
240
+ "greeting",
241
+ "input-placeholder",
242
+ "suggested-prompts",
243
+ "theme",
244
+ "bg-color",
245
+ "text-color",
246
+ "btn-text-color",
247
+ "terms",
248
+ "feedback",
25
249
  "agent-name",
26
250
  "call-flow-name",
27
251
  "workspace-name",
28
252
  "avatar",
253
+ "avatar-style",
29
254
  "avatar-image-url",
30
255
  // convai alias -> avatar
31
256
  "orb-color",
@@ -37,7 +262,11 @@ var OBSERVED_ATTRIBUTES = [
37
262
  "action-text",
38
263
  "start-call-text",
39
264
  "end-call-text",
265
+ "end-chat-text",
266
+ "language",
40
267
  "message-text",
268
+ "call-label",
269
+ "chat-label",
41
270
  "switch-to-text-text",
42
271
  "switch-to-voice-text",
43
272
  "listening-text",
@@ -84,6 +313,25 @@ function parseNumberAttr(value) {
84
313
  const n = Number(value);
85
314
  return Number.isFinite(n) ? n : void 0;
86
315
  }
316
+ var HEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
317
+ function hexOrUndefined(value) {
318
+ return value && HEX.test(value.trim()) ? value.trim() : void 0;
319
+ }
320
+ function parsePromptsAttr(value) {
321
+ if (value === null) return void 0;
322
+ const trimmed = value.trim();
323
+ if (!trimmed) return [];
324
+ if (trimmed.startsWith("[")) {
325
+ try {
326
+ const parsed = JSON.parse(trimmed);
327
+ if (Array.isArray(parsed)) return parsed.map(String).map((p) => p.trim()).filter(Boolean);
328
+ } catch (e) {
329
+ console.warn("[trillet-widget] Failed to parse suggested-prompts:", value);
330
+ }
331
+ return [];
332
+ }
333
+ return trimmed.split("|").map((p) => p.trim()).filter(Boolean);
334
+ }
87
335
  function resolveVariant(raw) {
88
336
  switch (raw) {
89
337
  case "expanded":
@@ -96,53 +344,79 @@ function resolveVariant(raw) {
96
344
  return "compact";
97
345
  }
98
346
  }
99
- function configFromElement(el) {
100
- const get = (name) => el.getAttribute(name);
101
- const variant = resolveVariant(get("variant"));
102
- const modeRaw = get("mode");
347
+ function configFromElement(el, remote) {
348
+ var _a, _b, _c;
349
+ const r = remote || {};
350
+ const get = (name, fallback) => {
351
+ var _a2;
352
+ return (_a2 = el.getAttribute(name)) != null ? _a2 : fallback || null;
353
+ };
354
+ const variant = resolveVariant(get("variant", r.variant));
355
+ const modeRaw = get("mode", r.mode);
103
356
  const mode = modeRaw === "text" ? "text" : modeRaw === "both" ? "both" : "voice";
104
- const placementRaw = get("placement");
357
+ const placementRaw = get("placement", r.placement);
105
358
  const placement = PLACEMENTS.includes(placementRaw) ? placementRaw : "bottom-right";
359
+ const pageLang = typeof document !== "undefined" ? (_a = document.documentElement) == null ? void 0 : _a.lang : null;
360
+ const language = resolveLanguage(el.getAttribute("language"), r.language, pageLang);
361
+ const copy = WIDGET_COPY[language];
106
362
  const isText = mode === "text";
107
- const startDefault = isText ? "Start chat" : DEFAULT_COPY.startCallText;
108
- const endDefault = isText ? "End chat" : DEFAULT_COPY.endCallText;
363
+ const startDefault = r.startCallText || (isText ? copy.startChatText : copy.startCallText);
364
+ const endDefault = isText ? get("end-chat-text") || copy.endChatText : copy.endCallText;
109
365
  const brand = {};
110
- const brandLogo = get("brand-logo");
111
- const brandColor = get("brand-color");
112
- const brandName = get("brand-name");
366
+ const brandLogo = get("brand-logo", r.brandLogo);
367
+ const brandColor = get("brand-color", r.brandColor);
368
+ const brandName = get("brand-name", r.brandName);
113
369
  if (brandLogo) brand.logo = brandLogo;
114
370
  if (brandColor) brand.primaryColor = brandColor;
115
371
  if (brandName) brand.name = brandName;
116
372
  const orbColor = get("orb-color") || void 0;
117
- const orbColor1 = get("avatar-orb-color-1") || orbColor || void 0;
118
- const orbColor2 = get("avatar-orb-color-2") || void 0;
373
+ const orbColor1 = get("avatar-orb-color-1", r.orbColor1) || orbColor || void 0;
374
+ const orbColor2 = get("avatar-orb-color-2", r.orbColor2) || void 0;
375
+ const styleRaw = get("avatar-style", r.avatarStyle);
376
+ const avatarStyle = styleRaw === "orb" || styleRaw === "image" || styleRaw === "initials" ? styleRaw : void 0;
119
377
  return {
120
378
  agentId: get("agent-id") || "",
121
379
  signedUrlEndpoint: get("signed-url-endpoint") || void 0,
122
380
  workspaceId: get("workspace-id") || void 0,
381
+ apiBase: get("api-base") || void 0,
382
+ remoteConfig: get("remote-config") !== "false",
123
383
  // Header identity overrides — empty string/absent => treated as "not set".
124
- agentName: get("agent-name") || void 0,
384
+ agentName: get("agent-name", r.title) || void 0,
125
385
  callFlowName: get("call-flow-name") || void 0,
126
386
  workspaceName: get("workspace-name") || void 0,
127
387
  // convai `avatar-image-url` is an alias of our `avatar`.
128
- avatar: get("avatar") || get("avatar-image-url") || void 0,
388
+ avatarStyle,
389
+ avatar: get("avatar") || get("avatar-image-url") || r.avatar || void 0,
129
390
  orbColor,
130
391
  orbColor1,
131
392
  orbColor2,
132
393
  variant,
133
394
  placement,
134
395
  dismissible: parseBoolAttr(get("dismissible")),
135
- actionText: get("action-text") || void 0,
396
+ language,
397
+ copy,
398
+ actionText: get("action-text", r.launcherText) || void 0,
136
399
  startCallText: get("start-call-text") || startDefault,
137
400
  endCallText: get("end-call-text") || endDefault,
138
- messageText: get("message-text") || DEFAULT_COPY.messageText,
139
- switchToTextText: get("switch-to-text-text") || DEFAULT_COPY.switchToTextText,
140
- switchToVoiceText: get("switch-to-voice-text") || DEFAULT_COPY.switchToVoiceText,
141
- listeningText: get("listening-text") || DEFAULT_COPY.listeningText,
142
- speakingText: get("speaking-text") || DEFAULT_COPY.speakingText,
143
- expandText: get("expand-text") || DEFAULT_COPY.expandText,
144
- collapseText: get("collapse-text") || DEFAULT_COPY.collapseText,
145
- recaptchaText: get("recaptcha-text") || DEFAULT_COPY.recaptchaText,
401
+ messageText: get("message-text", r.messageText) || copy.messageText,
402
+ callLabel: get("call-label") || copy.callLabel,
403
+ chatLabel: get("chat-label") || copy.chatLabel,
404
+ switchToTextText: get("switch-to-text-text") || copy.switchToTextText,
405
+ switchToVoiceText: get("switch-to-voice-text") || copy.switchToVoiceText,
406
+ listeningText: get("listening-text") || copy.listeningText,
407
+ speakingText: get("speaking-text") || copy.speakingText,
408
+ expandText: get("expand-text") || copy.expandText,
409
+ collapseText: get("collapse-text") || copy.collapseText,
410
+ recaptchaText: get("recaptcha-text") || copy.recaptchaText,
411
+ greeting: get("greeting", r.greeting) || void 0,
412
+ inputPlaceholder: get("input-placeholder", r.inputPlaceholder) || copy.inputPlaceholder,
413
+ suggestedPrompts: (_c = (_b = parsePromptsAttr(el.getAttribute("suggested-prompts"))) != null ? _b : r.suggestedPrompts) != null ? _c : [],
414
+ theme: get("theme", r.theme) === "dark" ? "dark" : "light",
415
+ backgroundColor: hexOrUndefined(get("bg-color", r.backgroundColor)),
416
+ textColor: hexOrUndefined(get("text-color", r.textColor)),
417
+ buttonTextColor: hexOrUndefined(get("btn-text-color", r.buttonTextColor)),
418
+ termsText: get("terms", r.termsText) || void 0,
419
+ feedback: get("feedback", r.feedback) === "end" ? "end" : "none",
146
420
  mode,
147
421
  // convai `dynamic-variables` is an alias of our `variables`.
148
422
  variables: parseJsonAttr(get("variables") || get("dynamic-variables")),
@@ -158,494 +432,571 @@ var WIDGET_STYLES = (
158
432
  /* css */
159
433
  `
160
434
  :host {
161
- /* Positioning: default bottom-right. The host can override by setting
162
- position-related CSS on the trillet-widget element directly, or via the
163
- placement attribute (see :host([placement=...]) rules below). */
164
435
  position: fixed;
165
- right: 24px;
166
- bottom: 24px;
436
+ right: 20px;
437
+ bottom: 20px;
167
438
  z-index: 2147483000;
168
439
 
169
- /* Theming tokens (overridden at runtime via setProperty). */
170
- --trillet-accent: #2792dc;
171
- --trillet-orb-1: #2792dc;
172
- --trillet-orb-2: #9ce6e6;
173
- --trillet-surface: #ffffff;
174
- --trillet-on-surface: #0b0b0f;
175
- --trillet-muted: #6b7280;
176
- --trillet-border: rgba(0, 0, 0, 0.08);
177
- --trillet-shadow: 0 12px 48px rgba(0, 0, 0, 0.20);
440
+ --tw-accent: #0062e9;
441
+ --tw-on-accent: #ffffff;
442
+ --tw-surface: #ffffff;
443
+ --tw-raised: #f7f9fc;
444
+ --tw-ink: #1e293b;
445
+ --tw-muted: #64748b;
446
+ --tw-line: #e2e8f0;
447
+ --tw-danger: #dc2626;
448
+ --tw-online: #16a34a;
449
+ --tw-orb-1: #0062e9;
450
+ --tw-orb-2: #27a3fd;
451
+ --tw-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 12px 32px -6px rgba(15, 23, 42, 0.14);
452
+ --tw-level: 0;
178
453
 
179
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
180
- font-size: 14px;
181
- line-height: 1.4;
182
- color: var(--trillet-on-surface);
454
+ font-family: inherit;
455
+ font-size: 15px;
456
+ line-height: 1.5;
457
+ color: var(--tw-ink);
458
+ -webkit-font-smoothing: antialiased;
459
+ }
460
+
461
+ :host([data-theme="dark"]) {
462
+ --tw-surface: #0f1b2d;
463
+ --tw-raised: #172437;
464
+ --tw-ink: #e8edf4;
465
+ --tw-muted: #94a3b8;
466
+ --tw-line: #23324a;
467
+ --tw-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -8px rgba(0, 0, 0, 0.55);
183
468
  }
184
469
 
185
470
  :host([hidden]) { display: none; }
186
471
 
187
- /* ---- placement attribute (fixed positioning on the host element) ----
188
- Kept in the shadow stylesheet (low specificity) so raw CSS on the
189
- trillet-widget element still overrides it. */
190
- :host([placement="bottom-right"]) { top: auto; bottom: 24px; left: auto; right: 24px; }
191
- :host([placement="bottom-left"]) { top: auto; bottom: 24px; right: auto; left: 24px; }
192
- :host([placement="bottom"]) { top: auto; bottom: 24px; left: 50%; right: auto; transform: translateX(-50%); }
193
- :host([placement="top-right"]) { bottom: auto; top: 24px; left: auto; right: 24px; }
194
- :host([placement="top-left"]) { bottom: auto; top: 24px; right: auto; left: 24px; }
195
- :host([placement="top"]) { bottom: auto; top: 24px; left: 50%; right: auto; transform: translateX(-50%); }
472
+ /* ---- Placement (fixed on the host; raw CSS on the element still wins) ---- */
473
+ :host([data-placement="bottom-right"]) { top: auto; bottom: 20px; left: auto; right: 20px; }
474
+ :host([data-placement="bottom-left"]) { top: auto; bottom: 20px; right: auto; left: 20px; }
475
+ :host([data-placement="bottom"]) { top: auto; bottom: 20px; left: 50%; right: auto; transform: translateX(-50%); }
476
+ :host([data-placement="top-right"]) { bottom: auto; top: 20px; left: auto; right: 20px; }
477
+ :host([data-placement="top-left"]) { bottom: auto; top: 20px; right: auto; left: 20px; }
478
+ :host([data-placement="top"]) { bottom: auto; top: 20px; left: 50%; right: auto; transform: translateX(-50%); }
196
479
 
197
480
  * { box-sizing: border-box; }
198
-
199
- .tw-root {
200
- display: flex;
201
- flex-direction: column;
202
- align-items: flex-end;
203
- gap: 12px;
481
+ button { font: inherit; color: inherit; }
482
+ button:focus-visible, textarea:focus-visible, a:focus-visible {
483
+ outline: 2px solid var(--tw-accent);
484
+ outline-offset: 2px;
204
485
  }
205
- /* Left/center placements align the launcher + card accordingly. */
206
- :host([placement="bottom-left"]) .tw-root,
207
- :host([placement="top-left"]) .tw-root { align-items: flex-start; }
208
- :host([placement="bottom"]) .tw-root,
209
- :host([placement="top"]) .tw-root { align-items: center; }
486
+ svg { display: block; flex-shrink: 0; }
487
+
488
+ .tw-root { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
489
+ :host([data-placement$="left"]) .tw-root { align-items: flex-start; }
490
+ :host([data-placement="bottom"]) .tw-root, :host([data-placement="top"]) .tw-root { align-items: center; }
210
491
 
211
- /* ---- Floating launcher ---- */
212
- .tw-launcher {
492
+ /* ---- Buttons ---- */
493
+ .tw-btn {
213
494
  display: inline-flex;
214
495
  align-items: center;
215
- gap: 10px;
216
- padding: 12px 18px;
217
- border: none;
218
- border-radius: 999px;
219
- background: var(--trillet-accent);
220
- color: #fff;
221
- font-size: 14px;
496
+ justify-content: center;
497
+ gap: 8px;
498
+ height: 40px;
499
+ padding: 0 16px;
500
+ border-radius: 8px;
501
+ border: 1px solid transparent;
502
+ font-size: 15px;
222
503
  font-weight: 600;
504
+ white-space: nowrap;
505
+ cursor: pointer;
506
+ transition: background 0.15s ease, filter 0.15s ease, border-color 0.15s ease;
507
+ }
508
+ .tw-btn svg { width: 17px; height: 17px; }
509
+ .tw-btn:disabled { opacity: 0.55; cursor: default; }
510
+ .tw-btn-primary { background: var(--tw-accent); color: var(--tw-on-accent); }
511
+ .tw-btn-primary:hover:not(:disabled) { filter: brightness(1.07); }
512
+ .tw-btn-secondary { background: var(--tw-surface); color: var(--tw-ink); border-color: var(--tw-line); }
513
+ .tw-btn-secondary:hover:not(:disabled) { background: var(--tw-raised); }
514
+ .tw-btn-danger { background: var(--tw-danger); color: #fff; }
515
+ .tw-btn-danger:hover:not(:disabled) { filter: brightness(1.07); }
516
+
517
+ .tw-icon-btn {
518
+ width: 32px;
519
+ height: 32px;
520
+ border: none;
521
+ border-radius: 8px;
522
+ background: transparent;
523
+ color: var(--tw-muted);
524
+ display: inline-flex;
525
+ align-items: center;
526
+ justify-content: center;
223
527
  cursor: pointer;
224
- box-shadow: var(--trillet-shadow);
225
- transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
226
- }
227
- .tw-launcher:hover { transform: translateY(-1px); box-shadow: 0 16px 52px rgba(0, 0, 0, 0.26); }
228
- .tw-launcher:active { transform: translateY(0); }
229
- .tw-launcher .tw-launcher-orb {
230
- width: 20px;
231
- height: 20px;
232
- border-radius: 50%;
233
- background:
234
- conic-gradient(from 0deg, var(--trillet-orb-1), var(--trillet-orb-2), var(--trillet-orb-1));
235
- box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.6);
236
- animation: tw-orb-rotate 8s linear infinite;
237
- }
238
- .tw-launcher .tw-launcher-orb-avatar {
239
- background: none;
240
- background-size: cover;
241
- background-position: center;
242
- animation: none;
243
- }
244
- .tw-launcher-copy {
245
- display: flex;
246
- flex-direction: column;
247
- align-items: flex-start;
248
- line-height: 1.15;
249
- text-align: left;
250
- }
251
- .tw-launcher-state {
252
- font-size: 11px;
253
- font-weight: 500;
254
- opacity: 0.92;
255
- }
256
- /* Voice calls stay on this control: connecting, then hang up. */
257
- .tw-launcher.tw-hangup { background: #e5484d; }
258
- .tw-launcher.tw-listening {
259
- box-shadow: var(--trillet-shadow), 0 0 0 3px rgba(255, 255, 255, 0.45);
260
- }
261
- .tw-launcher.tw-speaking {
262
- box-shadow: var(--trillet-shadow), 0 0 0 4px rgba(255, 255, 255, 0.8);
263
- }
264
- .tw-launcher.tw-speaking .tw-launcher-orb {
265
- animation: tw-orb-rotate 4.5s linear infinite, tw-bob 0.7s ease-in-out infinite alternate;
266
528
  }
267
- .tw-launcher.tw-connecting { cursor: default; }
268
- .tw-launcher.tw-connecting .tw-launcher-orb {
269
- animation: tw-orb-rotate 1.2s linear infinite;
529
+ .tw-icon-btn svg { width: 18px; height: 18px; }
530
+ .tw-icon-btn:hover:not(:disabled) { background: var(--tw-raised); color: var(--tw-ink); }
531
+ .tw-icon-btn:disabled { opacity: 0.45; cursor: default; }
532
+ .tw-icon-btn.tw-btn-icon {
533
+ width: 40px;
534
+ height: 40px;
535
+ border: 1px solid var(--tw-line);
536
+ color: var(--tw-ink);
270
537
  }
271
- .tw-launcher:disabled { opacity: 0.72; cursor: default; }
272
- .tw-launcher:disabled:hover { transform: none; box-shadow: var(--trillet-shadow); }
538
+ .tw-icon-btn.tw-muted { color: var(--tw-danger); border-color: var(--tw-danger); }
273
539
 
274
- /* Optional reCAPTCHA sits with the floating control. Not a call panel. */
275
- .tw-inline {
276
- display: flex;
277
- flex-direction: column;
278
- align-items: flex-end;
279
- gap: 10px;
280
- }
281
- :host([placement="bottom-left"]) .tw-inline,
282
- :host([placement="top-left"]) .tw-inline { align-items: flex-start; }
283
- :host([placement="bottom"]) .tw-inline,
284
- :host([placement="top"]) .tw-inline { align-items: center; }
285
- .tw-inline-hint {
286
- max-width: 304px;
287
- padding: 8px 12px;
288
- border-radius: 10px;
289
- background: var(--trillet-surface);
290
- color: var(--trillet-on-surface);
291
- border: 1px solid var(--trillet-border);
292
- box-shadow: var(--trillet-shadow);
293
- font-size: 12px;
540
+ /* Full-width buttons on the panel's centred screens. */
541
+ .tw-primary-btn, .tw-secondary-btn {
542
+ display: inline-flex;
543
+ align-items: center;
544
+ justify-content: center;
545
+ gap: 8px;
546
+ height: 42px;
547
+ padding: 0 18px;
548
+ border-radius: 8px;
549
+ font-size: 15px;
294
550
  font-weight: 600;
551
+ cursor: pointer;
295
552
  }
553
+ .tw-primary-btn svg, .tw-secondary-btn svg { width: 17px; height: 17px; }
554
+ .tw-primary-btn { border: none; background: var(--tw-accent); color: var(--tw-on-accent); }
555
+ .tw-primary-btn:hover:not(:disabled) { filter: brightness(1.07); }
556
+ .tw-primary-btn:disabled { opacity: 0.5; cursor: default; }
557
+ .tw-secondary-btn { border: 1px solid var(--tw-line); background: var(--tw-surface); color: var(--tw-ink); }
558
+ .tw-secondary-btn:hover:not(:disabled) { background: var(--tw-raised); }
559
+ .tw-secondary-btn.tw-small { height: 34px; padding: 0 12px; font-size: 14px; }
296
560
 
297
- /* ---- Panel ---- */
298
- .tw-panel {
299
- width: 320px;
300
- max-width: calc(100vw - 32px);
301
- background: var(--trillet-surface);
302
- border: 1px solid var(--trillet-border);
303
- border-radius: 16px;
304
- box-shadow: var(--trillet-shadow);
305
- overflow: hidden;
306
- display: flex;
307
- flex-direction: column;
561
+ .tw-round-btn {
562
+ width: 48px;
563
+ height: 48px;
564
+ border-radius: 50%;
565
+ border: 1px solid var(--tw-line);
566
+ color: var(--tw-ink);
308
567
  }
309
- .tw-panel.tw-expanded { width: 380px; }
568
+ .tw-round-btn svg { width: 20px; height: 20px; }
569
+ .tw-round-btn.tw-small-round { width: 36px; height: 36px; }
570
+ .tw-round-btn.tw-small-round svg { width: 17px; height: 17px; }
571
+ .tw-round-btn.tw-end-btn { background: var(--tw-danger); border-color: var(--tw-danger); color: #fff; }
310
572
 
311
- .tw-header {
312
- display: flex;
573
+ .tw-link-btn {
574
+ display: inline-flex;
313
575
  align-items: center;
314
- gap: 10px;
315
- padding: 14px 16px;
316
- border-bottom: 1px solid var(--trillet-border);
576
+ gap: 6px;
577
+ border: none;
578
+ background: transparent;
579
+ color: var(--tw-muted);
580
+ font-size: 13px;
581
+ padding: 4px 2px;
582
+ cursor: pointer;
317
583
  }
318
- /* Brand slot: customer logo + optional small brand label, stacked. Subordinate to
319
- the identity title. */
320
- .tw-brand {
584
+ .tw-link-btn:hover:not(:disabled) { color: var(--tw-ink); }
585
+ .tw-link-btn:disabled { opacity: 0.5; cursor: default; }
586
+
587
+ /* ---- Ask bar: the resting widget (input-first) ---- */
588
+ .tw-bar-stack { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
589
+ :host([data-placement$="left"]) .tw-bar-stack { align-items: flex-start; }
590
+ .tw-ask, .tw-callbar {
321
591
  display: flex;
322
592
  align-items: center;
323
- gap: 6px;
324
- min-width: 0;
325
- flex-shrink: 0;
326
- }
327
- .tw-brand-logo {
328
- width: 28px;
329
- height: 28px;
330
- border-radius: 8px;
331
- object-fit: cover;
593
+ gap: 8px;
594
+ width: 320px;
595
+ max-width: calc(100vw - 24px);
596
+ padding: 6px 6px 6px 10px;
597
+ background: var(--tw-surface);
598
+ border: 1px solid var(--tw-line);
599
+ border-radius: 12px;
600
+ box-shadow: var(--tw-shadow);
601
+ transition: border-color 0.15s ease, box-shadow 0.15s ease;
332
602
  }
333
- /* Small customer brand label (brand.name). Visually subordinate to the identity
334
- title \u2014 lighter weight, muted color, smaller. Never used as the header title. */
335
- .tw-brand-name {
336
- font-weight: 500;
337
- font-size: 12px;
338
- color: var(--trillet-muted);
603
+ .tw-ask:focus-within { border-color: var(--tw-accent); }
604
+ .tw-ask-form { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; margin: 0; }
605
+ .tw-ask-input {
606
+ flex: 1;
607
+ min-width: 0;
608
+ border: none;
609
+ outline: none;
610
+ background: transparent;
611
+ color: var(--tw-ink);
612
+ font: inherit;
613
+ font-size: 15px;
614
+ padding: 6px 4px;
615
+ }
616
+ .tw-ask-input::placeholder { color: var(--tw-muted); }
617
+ .tw-ask-input:focus-visible { outline: none; }
618
+ .tw-ask-label {
619
+ flex: 1;
620
+ min-width: 0;
621
+ border: none;
622
+ background: transparent;
623
+ text-align: left;
624
+ font-size: 15px;
625
+ padding: 6px 4px;
626
+ color: var(--tw-ink);
627
+ cursor: pointer;
339
628
  white-space: nowrap;
340
629
  overflow: hidden;
341
630
  text-overflow: ellipsis;
342
- max-width: 120px;
343
631
  }
344
- /* Header title identifying who the user is talking to (agent / call flow /
345
- workspace name). The primary header identity; truncates long names cleanly. */
346
- .tw-header-title {
347
- flex: 1;
348
- min-width: 0;
349
- font-weight: 600;
350
- font-size: 14px;
351
- color: var(--trillet-on-surface);
632
+ .tw-ask-suggestions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 320px; }
633
+ :host([data-placement$="left"]) .tw-ask-suggestions { justify-content: flex-start; }
634
+ .tw-ask-suggestions .tw-suggestion { box-shadow: var(--tw-shadow); }
635
+ .tw-bar-note {
636
+ max-width: 320px;
637
+ padding: 7px 12px;
638
+ font-size: 13px;
639
+ background: var(--tw-surface);
640
+ border: 1px solid var(--tw-line);
641
+ border-radius: 10px;
642
+ box-shadow: var(--tw-shadow);
643
+ }
644
+
645
+ /* Square icon actions. accent = send / call, quiet = mic etc., danger = hang up. */
646
+ .tw-icon-btn.tw-sq { width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0; }
647
+ .tw-icon-btn.tw-sq svg { width: 17px; height: 17px; }
648
+ .tw-icon-btn.tw-sq-accent, .tw-icon-btn.tw-sq-accent:hover:not(:disabled) { background: var(--tw-accent); color: var(--tw-on-accent); }
649
+ .tw-icon-btn.tw-sq-accent:hover:not(:disabled) { filter: brightness(1.08); }
650
+ .tw-icon-btn.tw-sq-accent:disabled { opacity: 0.35; }
651
+ .tw-icon-btn.tw-sq-quiet { color: var(--tw-ink); }
652
+ .tw-icon-btn.tw-sq-danger, .tw-icon-btn.tw-sq-danger:hover:not(:disabled) { background: var(--tw-danger); color: #fff; }
653
+ .tw-icon-btn.tw-sq-danger:hover:not(:disabled) { filter: brightness(1.08); }
654
+ .tw-icon-btn.tw-sq.tw-muted { color: var(--tw-danger); }
655
+
656
+ /* ---- Call bar ---- */
657
+ .tw-callbar { gap: 10px; padding-left: 12px; }
658
+ .tw-callbar-inline { width: auto; margin: 0 12px; box-shadow: none; animation: none; }
659
+ .tw-callbar-text { flex: 1; min-width: 0; }
660
+ .tw-callbar-activity { font-size: 14px; font-weight: 600; line-height: 1.25; }
661
+ .tw-callbar-meta {
662
+ font-size: 12px;
663
+ color: var(--tw-muted);
352
664
  white-space: nowrap;
353
665
  overflow: hidden;
354
666
  text-overflow: ellipsis;
355
667
  }
356
- .tw-icon-btn {
357
- border: none;
358
- background: transparent;
359
- color: var(--trillet-muted);
360
- cursor: pointer;
361
- width: 28px;
362
- height: 28px;
363
- border-radius: 8px;
668
+
669
+ /* The waveform: five bars whose height follows the agent's live voice level. */
670
+ .tw-wave { display: inline-flex; align-items: center; gap: 3px; height: 24px; flex-shrink: 0; }
671
+ .tw-wave i {
672
+ display: block;
673
+ width: 3px;
674
+ border-radius: 2px;
675
+ background: var(--tw-accent);
676
+ height: calc(5px + var(--tw-level) * 19px);
677
+ transition: height 0.08s linear;
678
+ }
679
+ .tw-wave i:nth-child(1), .tw-wave i:nth-child(5) { height: calc(4px + var(--tw-level) * 9px); }
680
+ .tw-wave i:nth-child(2), .tw-wave i:nth-child(4) { height: calc(5px + var(--tw-level) * 15px); }
681
+ .tw-wave:not(.tw-wave-speaking) i { opacity: 0.55; }
682
+
683
+ /* ---- Mark: who the visitor talks to ---- */
684
+ .tw-mark {
364
685
  display: inline-flex;
365
686
  align-items: center;
366
687
  justify-content: center;
367
- font-size: 16px;
368
- line-height: 1;
688
+ flex-shrink: 0;
689
+ border-radius: 7px;
690
+ background: var(--tw-accent);
691
+ color: var(--tw-on-accent);
692
+ font-weight: 600;
693
+ background-size: cover;
694
+ background-position: center;
369
695
  }
370
- .tw-icon-btn:hover { background: rgba(0, 0, 0, 0.05); }
696
+ .tw-mark-sm { width: 24px; height: 24px; font-size: 11px; border-radius: 6px; }
697
+ .tw-mark-md { width: 26px; height: 26px; font-size: 12px; }
698
+ .tw-mark-lg { width: 56px; height: 56px; font-size: 20px; border-radius: 14px; }
699
+ .tw-mark-orb { background: linear-gradient(135deg, var(--tw-orb-1), var(--tw-orb-2)); }
371
700
 
372
- .tw-body {
373
- padding: 20px 16px;
701
+ /* Terms dialog keeps a small card. */
702
+ .tw-card {
374
703
  display: flex;
375
704
  flex-direction: column;
376
- align-items: center;
377
705
  gap: 14px;
706
+ max-width: calc(100vw - 24px);
707
+ padding: 16px;
708
+ background: var(--tw-surface);
709
+ border: 1px solid var(--tw-line);
710
+ border-radius: 12px;
711
+ box-shadow: var(--tw-shadow);
378
712
  }
713
+ .tw-card-title { font-size: 15px; font-weight: 600; }
714
+ .tw-card-actions { display: flex; gap: 8px; }
715
+ .tw-inline-hint { font-size: 13px; color: var(--tw-muted); }
379
716
 
380
- /* ---- Animated 2-color gradient orb / avatar ---- */
381
- .tw-orb-wrap {
382
- position: relative;
383
- width: 96px;
384
- height: 96px;
717
+ /* ---- Panel ---- */
718
+ .tw-panel {
719
+ width: 380px;
720
+ height: min(600px, calc(100vh - 40px));
721
+ max-width: calc(100vw - 24px);
385
722
  display: flex;
386
- align-items: center;
387
- justify-content: center;
723
+ flex-direction: column;
724
+ background: var(--tw-surface);
725
+ border: 1px solid var(--tw-line);
726
+ border-radius: 14px;
727
+ box-shadow: var(--tw-shadow);
728
+ overflow: hidden;
388
729
  }
389
- /* Soft aura behind the orb (breathes gently; stronger while speaking). */
390
- .tw-orb-wrap::before {
391
- content: '';
392
- position: absolute;
393
- width: 78px;
394
- height: 78px;
395
- border-radius: 50%;
396
- background: radial-gradient(circle, var(--trillet-orb-2), transparent 70%);
397
- opacity: 0.5;
398
- filter: blur(10px);
399
- animation: tw-aura 3.2s ease-in-out infinite;
400
- }
401
- .tw-orb {
402
- position: relative;
403
- width: 72px;
404
- height: 72px;
405
- border-radius: 50%;
406
- background:
407
- radial-gradient(circle at 30% 28%, var(--trillet-orb-2), transparent 58%),
408
- conic-gradient(from 0deg, var(--trillet-orb-1), var(--trillet-orb-2), var(--trillet-orb-1));
409
- box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
410
- animation: tw-orb-rotate 9s linear infinite;
411
- }
412
- /* Glossy highlight so the orb reads as a 3D sphere, not a flat disc. */
413
- .tw-orb::after {
414
- content: '';
415
- position: absolute;
416
- inset: 0;
417
- border-radius: 50%;
418
- background: radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.55), transparent 46%);
730
+ .tw-panel.tw-expanded { width: 420px; height: min(680px, calc(100vh - 40px)); }
731
+
732
+ .tw-header {
733
+ display: flex;
734
+ align-items: center;
735
+ gap: 10px;
736
+ padding: 12px 10px 12px 14px;
737
+ border-bottom: 1px solid var(--tw-line);
419
738
  }
420
- /* When an avatar image is provided, show it instead of the gradient. */
421
- .tw-orb.tw-orb-avatar {
422
- background: none;
423
- background-size: cover;
424
- background-position: center;
425
- animation: none;
739
+ .tw-who { flex: 1; min-width: 0; }
740
+ .tw-header-title {
741
+ font-size: 15px;
742
+ font-weight: 600;
743
+ white-space: nowrap;
744
+ overflow: hidden;
745
+ text-overflow: ellipsis;
426
746
  }
427
- .tw-orb.tw-orb-avatar::after { display: none; }
428
-
429
- @keyframes tw-orb-rotate { to { transform: rotate(360deg); } }
430
- @keyframes tw-aura {
431
- 0%, 100% { transform: scale(1); opacity: 0.4; }
432
- 50% { transform: scale(1.16); opacity: 0.66; }
747
+ .tw-status {
748
+ display: flex;
749
+ align-items: center;
750
+ gap: 6px;
751
+ font-size: 13px;
752
+ color: var(--tw-muted);
753
+ white-space: nowrap;
754
+ font-variant-numeric: tabular-nums;
433
755
  }
434
-
435
- /* Connecting: a pulsing ring around the orb. */
436
- .tw-orb-wrap.tw-connecting::after {
756
+ .tw-status.tw-online::before {
437
757
  content: '';
438
- position: absolute;
439
- width: 72px;
440
- height: 72px;
758
+ width: 6px;
759
+ height: 6px;
441
760
  border-radius: 50%;
442
- border: 2px solid var(--trillet-orb-1);
443
- animation: tw-pulse 1.4s ease-out infinite;
444
- }
445
- @keyframes tw-pulse {
446
- 0% { transform: scale(0.85); opacity: 0.7; }
447
- 100% { transform: scale(1.3); opacity: 0; }
761
+ background: var(--tw-online);
448
762
  }
763
+ .tw-brand-logo { height: 22px; max-width: 72px; object-fit: contain; }
764
+ .tw-header-actions { display: flex; gap: 2px; }
449
765
 
450
- /* Listening (live, not speaking): a slow calm breathe. */
451
- .tw-orb-wrap.tw-listening .tw-orb {
452
- animation: tw-orb-rotate 9s linear infinite, tw-breathe 3.6s ease-in-out infinite;
453
- }
454
- @keyframes tw-breathe {
455
- 0%, 100% { transform: scale(1); }
456
- 50% { transform: scale(1.03); }
766
+ .tw-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
767
+ .tw-center-body {
768
+ align-items: center;
769
+ justify-content: center;
770
+ gap: 12px;
771
+ padding: 24px;
772
+ text-align: center;
457
773
  }
774
+ .tw-prompt { margin: 4px 0 0; font-size: 16px; font-weight: 600; max-width: 260px; }
775
+ .tw-timer { font-size: 13px; color: var(--tw-muted); font-variant-numeric: tabular-nums; }
776
+ .tw-error-text { color: var(--tw-danger); }
777
+ .tw-choices, .tw-controls { display: flex; gap: 8px; width: 100%; justify-content: center; }
778
+ .tw-choices { flex-direction: column; max-width: 240px; margin-top: 4px; }
458
779
 
459
- /* Speaking: faster rotation + stronger bob, and a livelier aura. */
460
- .tw-orb-wrap.tw-speaking .tw-orb {
461
- animation: tw-orb-rotate 4.5s linear infinite, tw-bob 0.7s ease-in-out infinite alternate;
780
+ /* ---- Chat ---- */
781
+ .tw-chat {
782
+ flex: 1;
783
+ min-height: 0;
784
+ overflow-y: auto;
785
+ display: flex;
786
+ flex-direction: column;
787
+ gap: 8px;
788
+ padding: 16px 14px 8px;
789
+ scroll-behavior: smooth;
462
790
  }
463
- .tw-orb-wrap.tw-speaking::before { animation: tw-aura 1.2s ease-in-out infinite; }
464
- @keyframes tw-bob {
465
- from { transform: scale(1); }
466
- to { transform: scale(1.08); }
791
+ .tw-msg {
792
+ max-width: 84%;
793
+ padding: 8px 12px;
794
+ border-radius: 10px;
795
+ font-size: 15px;
796
+ line-height: 1.5;
797
+ white-space: pre-wrap;
798
+ overflow-wrap: anywhere;
467
799
  }
468
-
469
- .tw-status {
470
- font-size: 13px;
471
- color: var(--trillet-muted);
472
- min-height: 18px;
473
- text-align: center;
800
+ .tw-msg.tw-run { margin-top: -2px; }
801
+ .tw-msg.tw-assistant {
802
+ align-self: flex-start;
803
+ background: var(--tw-raised);
804
+ border: 1px solid var(--tw-line);
805
+ color: var(--tw-ink);
474
806
  }
475
- .tw-timer {
476
- font-size: 12px;
477
- color: var(--trillet-muted);
478
- font-variant-numeric: tabular-nums;
807
+ .tw-msg-label { font-size: 11px; color: var(--tw-muted); margin-bottom: 1px; }
808
+ .tw-msg.tw-user {
809
+ align-self: flex-end;
810
+ background: var(--tw-accent);
811
+ color: var(--tw-on-accent);
479
812
  }
480
-
481
- /* ---- BYO reCAPTCHA gate ---- */
482
- /* The checkbox is a light-DOM node projected in via <slot name="recaptcha"> \u2014 it can't
483
- render directly in the shadow root (reCAPTCHA v2 hangs there). ::slotted targets that
484
- projected node. The checkbox iframe is a fixed 304x78; scale it down on narrow panels
485
- so it doesn't overflow. */
486
- .tw-recaptcha-slot {
487
- display: flex;
488
- justify-content: center;
489
- width: 100%;
813
+ .tw-msg.tw-typing { display: inline-flex; gap: 4px; padding: 12px 13px; }
814
+ .tw-msg.tw-typing span {
815
+ width: 6px;
816
+ height: 6px;
817
+ border-radius: 50%;
818
+ background: var(--tw-muted);
819
+ animation: tw-typing 1.2s infinite ease-in-out;
490
820
  }
491
- ::slotted(.tw-recaptcha-mount) {
821
+ .tw-msg.tw-typing span:nth-child(2) { animation-delay: 0.15s; }
822
+ .tw-msg.tw-typing span:nth-child(3) { animation-delay: 0.3s; }
823
+
824
+ .tw-suggestions {
492
825
  display: flex;
493
- justify-content: center;
826
+ flex-wrap: wrap;
827
+ justify-content: flex-end;
828
+ gap: 6px;
829
+ padding: 2px 14px 10px;
494
830
  }
495
- @media (max-width: 340px) {
496
- ::slotted(.tw-recaptcha-mount) {
497
- transform: scale(0.85);
498
- transform-origin: center top;
499
- }
831
+ .tw-suggestion {
832
+ border: 1px solid var(--tw-line);
833
+ background: var(--tw-surface);
834
+ color: var(--tw-ink);
835
+ border-radius: 8px;
836
+ padding: 6px 11px;
837
+ font-size: 14px;
838
+ text-align: left;
839
+ cursor: pointer;
500
840
  }
841
+ .tw-suggestion:hover { border-color: var(--tw-accent); color: var(--tw-accent); }
501
842
 
502
- /* ---- Controls ---- */
503
- .tw-controls {
843
+ .tw-composer {
504
844
  display: flex;
505
- align-items: center;
506
- gap: 10px;
507
- width: 100%;
508
- justify-content: center;
509
- }
510
- .tw-controls.tw-controls-stack {
511
- flex-direction: column;
512
- gap: 8px;
845
+ align-items: flex-end;
846
+ gap: 6px;
847
+ margin: 0 12px;
848
+ padding: 5px 5px 5px 12px;
849
+ border: 1px solid var(--tw-line);
850
+ border-radius: 10px;
851
+ background: var(--tw-surface);
852
+ transition: border-color 0.15s ease;
513
853
  }
514
- .tw-controls-stack .tw-primary-btn { width: 100%; }
515
- .tw-primary-btn {
854
+ .tw-composer:focus-within { border-color: var(--tw-accent); }
855
+ .tw-text-input {
856
+ flex: 1;
857
+ min-width: 0;
516
858
  border: none;
517
- border-radius: 999px;
518
- padding: 11px 20px;
519
- font-size: 14px;
520
- font-weight: 600;
521
- cursor: pointer;
522
- background: var(--trillet-accent);
523
- color: #fff;
524
- transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
525
- }
526
- .tw-primary-btn:hover { opacity: 0.92; }
527
- .tw-primary-btn.tw-danger { background: #e5484d; }
528
- .tw-primary-btn.tw-secondary {
859
+ outline: none;
860
+ resize: none;
529
861
  background: transparent;
530
- color: var(--trillet-accent);
531
- border: 1px solid var(--trillet-border);
862
+ color: var(--tw-ink);
863
+ font: inherit;
864
+ font-size: 15px;
865
+ line-height: 1.4;
866
+ padding: 7px 0;
867
+ max-height: 112px;
532
868
  }
533
- .tw-primary-btn.tw-secondary:hover { background: rgba(0, 0, 0, 0.03); opacity: 1; }
534
- .tw-primary-btn:disabled { opacity: 0.6; cursor: default; }
535
- /* Subtle modality switch affordance (mode="both"). */
536
- .tw-switch-btn {
869
+ .tw-text-input:focus-visible { outline: none; }
870
+ .tw-text-input::placeholder { color: var(--tw-muted); }
871
+ .tw-send-btn {
872
+ width: 34px;
873
+ height: 34px;
874
+ flex-shrink: 0;
537
875
  border: none;
538
- background: none;
539
- color: var(--trillet-muted);
540
- font-size: 12px;
541
- font-weight: 500;
542
- cursor: pointer;
543
- padding: 2px 6px;
544
- text-decoration: underline;
545
- text-underline-offset: 2px;
546
- }
547
- .tw-switch-btn:hover { color: var(--trillet-accent); }
548
- .tw-mic-btn {
549
- border: 1px solid var(--trillet-border);
550
- background: var(--trillet-surface);
551
- color: var(--trillet-on-surface);
552
- border-radius: 50%;
553
- width: 42px;
554
- height: 42px;
555
- cursor: pointer;
876
+ border-radius: 8px;
877
+ background: var(--tw-accent);
878
+ color: var(--tw-on-accent);
556
879
  display: inline-flex;
557
880
  align-items: center;
558
881
  justify-content: center;
559
- font-size: 18px;
882
+ cursor: pointer;
560
883
  }
561
- .tw-mic-btn.tw-muted { color: #e5484d; border-color: #e5484d; }
884
+ .tw-send-btn svg { width: 17px; height: 17px; }
885
+ .tw-send-btn:disabled { opacity: 0.35; cursor: default; }
886
+ .tw-composer .tw-composer-mic { width: 34px; height: 34px; }
562
887
 
563
- /* ---- Text mode ---- */
564
- .tw-text-input-row {
888
+ .tw-voice-bar {
565
889
  display: flex;
566
- gap: 8px;
567
- width: 100%;
568
- }
569
- .tw-text-input {
570
- flex: 1;
571
- border: 1px solid var(--trillet-border);
890
+ align-items: center;
891
+ gap: 10px;
892
+ margin: 0 12px;
893
+ padding: 8px 8px 8px 10px;
894
+ border: 1px solid var(--tw-line);
572
895
  border-radius: 10px;
573
- padding: 9px 12px;
574
- font-size: 14px;
575
- font-family: inherit;
576
- color: var(--trillet-on-surface);
577
- background: var(--trillet-surface);
578
- outline: none;
896
+ background: var(--tw-raised);
579
897
  }
580
- .tw-text-input:focus { border-color: var(--trillet-accent); }
581
- .tw-send-btn {
582
- border: none;
583
- border-radius: 10px;
584
- padding: 0 14px;
585
- background: var(--trillet-accent);
586
- color: #fff;
587
- font-weight: 600;
588
- cursor: pointer;
898
+ .tw-voice-bar-text { flex: 1; min-width: 0; }
899
+ .tw-voice-bar-activity { font-size: 14px; font-weight: 600; }
900
+ .tw-voice-bar .tw-timer { font-size: 12px; }
901
+
902
+ .tw-notice {
903
+ margin: 0 12px 8px;
904
+ padding: 8px 12px;
905
+ border-radius: 8px;
906
+ border: 1px solid color-mix(in srgb, var(--tw-danger) 35%, var(--tw-line));
907
+ background: color-mix(in srgb, var(--tw-danger) 6%, var(--tw-surface));
908
+ font-size: 13px;
589
909
  }
590
910
 
591
- /* ---- Transcript ---- */
592
- .tw-transcript {
593
- width: 100%;
594
- max-height: 200px;
595
- overflow-y: auto;
911
+ .tw-chat-footer {
596
912
  display: flex;
597
- flex-direction: column;
598
- gap: 8px;
599
- padding-top: 4px;
600
- border-top: 1px solid var(--trillet-border);
601
- margin-top: 4px;
913
+ align-items: center;
914
+ justify-content: flex-end;
915
+ min-height: 30px;
916
+ padding: 2px 14px 6px;
917
+ }
918
+ .tw-chat-ended {
919
+ display: flex;
920
+ align-items: center;
921
+ justify-content: space-between;
922
+ gap: 10px;
923
+ margin: 4px 12px 12px;
924
+ padding: 10px 12px;
925
+ border-radius: 10px;
926
+ border: 1px solid var(--tw-line);
927
+ background: var(--tw-raised);
928
+ font-size: 14px;
929
+ color: var(--tw-muted);
602
930
  }
603
931
 
604
- /* ---- Chat window (text mode) ----
605
- A fixed-height, internally scrolling thread so the panel does NOT grow as
606
- messages arrive. Height is a sensible fixed value, capped to the viewport on
607
- short screens. Rendered (empty) as soon as the chat opens. */
608
- .tw-chat {
609
- height: min(380px, 60vh);
610
- max-height: none;
932
+ .tw-recaptcha-slot { display: flex; justify-content: center; }
933
+
934
+ /* ---- Markdown in agent messages / terms ---- */
935
+ .tw-md { white-space: normal; }
936
+ .tw-md p { margin: 0; }
937
+ .tw-md p + p, .tw-md p + ul, .tw-md p + ol, .tw-md ul + p, .tw-md ol + p { margin-top: 8px; }
938
+ .tw-md ul, .tw-md ol { margin: 0; padding-left: 20px; }
939
+ .tw-md li + li { margin-top: 2px; }
940
+ .tw-md a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
941
+ .tw-md code {
942
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
943
+ font-size: 0.88em;
944
+ padding: 1px 4px;
945
+ border-radius: 4px;
946
+ background: color-mix(in srgb, var(--tw-ink) 7%, transparent);
947
+ }
948
+
949
+ /* ---- Terms gate ---- */
950
+ .tw-terms { width: 320px; }
951
+ .tw-terms-body {
952
+ max-height: 220px;
611
953
  overflow-y: auto;
612
- padding: 10px;
613
- border: 1px solid var(--trillet-border);
614
- border-top: 1px solid var(--trillet-border);
615
- border-radius: 12px;
616
- margin-top: 0;
617
- background: rgba(0, 0, 0, 0.015);
618
- scroll-behavior: smooth;
954
+ font-size: 14px;
955
+ color: var(--tw-muted);
619
956
  }
620
- /* Faint empty state so the open (message-less) chat doesn't read as broken. */
621
- .tw-chat-empty {
622
- margin: auto;
623
- color: var(--trillet-muted);
624
- opacity: 0.45;
625
- font-size: 20px;
626
- letter-spacing: 2px;
957
+ .tw-terms .tw-pill {
958
+ flex: 1;
959
+ height: 40px;
960
+ border: none;
961
+ border-radius: 8px;
962
+ background: var(--tw-accent);
963
+ color: var(--tw-on-accent);
964
+ font-weight: 600;
965
+ cursor: pointer;
627
966
  }
628
- .tw-msg {
629
- padding: 8px 12px;
630
- border-radius: 12px;
631
- max-width: 85%;
967
+ .tw-terms .tw-secondary-btn { height: 40px; }
968
+
969
+ /* ---- Feedback ---- */
970
+ .tw-feedback {
971
+ display: flex;
972
+ align-items: center;
973
+ gap: 2px;
632
974
  font-size: 13px;
633
- white-space: pre-wrap;
634
- word-break: break-word;
975
+ color: var(--tw-muted);
635
976
  }
636
- .tw-msg.tw-user {
637
- align-self: flex-end;
638
- background: var(--trillet-accent);
639
- color: #fff;
640
- border-bottom-right-radius: 4px;
977
+ .tw-feedback span { margin-right: 6px; }
978
+ .tw-body .tw-feedback { padding: 0 14px 12px; }
979
+
980
+ /* ---- Motion ---- */
981
+ @keyframes tw-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
982
+ @keyframes tw-breathe { 0%, 100% { transform: scale(1.04); } 50% { transform: scale(1.16); } }
983
+ @keyframes tw-typing { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
984
+ @keyframes tw-spin { to { transform: rotate(360deg); } }
985
+ .tw-spin { transform-origin: 12px 12px; animation: tw-spin 0.9s linear infinite; }
986
+
987
+ @media (prefers-reduced-motion: reduce) {
988
+ .tw-enter, .tw-msg.tw-typing span, .tw-spin { animation: none; }
989
+ .tw-wave i { transition: none; }
641
990
  }
642
- .tw-msg.tw-assistant {
643
- align-self: flex-start;
644
- background: rgba(0, 0, 0, 0.05);
645
- color: var(--trillet-on-surface);
646
- border-bottom-left-radius: 4px;
991
+
992
+ /* Phones: the open panel takes the screen width. */
993
+ @media (max-width: 480px) {
994
+ :host { right: 12px; bottom: 12px; }
995
+ .tw-panel, .tw-panel.tw-expanded { width: calc(100vw - 24px); height: calc(100vh - 24px); }
647
996
  }
648
997
 
998
+ .tw-enter { animation: tw-rise 0.2s ease-out both; }
999
+
649
1000
  .tw-hidden { display: none !important; }
650
1001
  `
651
1002
  );
@@ -697,6 +1048,85 @@ async function renderRecaptchaCheckbox(options) {
697
1048
  });
698
1049
  }
699
1050
 
1051
+ // src/widget/markdown.ts
1052
+ var INLINE = /(\*\*[^*\n]+\*\*|\*[^*\n]+\*|`[^`\n]+`|\[[^\]\n]+\]\((?:https?:\/\/)[^)\s]+\)|https?:\/\/[^\s<]+[^\s<.,;:!?)\]])/g;
1053
+ function safeHref(raw) {
1054
+ try {
1055
+ const url = new URL(raw);
1056
+ return url.protocol === "https:" || url.protocol === "http:" ? url.toString() : null;
1057
+ } catch (e) {
1058
+ return null;
1059
+ }
1060
+ }
1061
+ function link(text, href) {
1062
+ const safe = safeHref(href);
1063
+ if (!safe) return document.createTextNode(text);
1064
+ const a = document.createElement("a");
1065
+ a.href = safe;
1066
+ a.target = "_blank";
1067
+ a.rel = "noopener noreferrer nofollow";
1068
+ a.textContent = text;
1069
+ return a;
1070
+ }
1071
+ function appendInline(parent, text) {
1072
+ var _a;
1073
+ let last = 0;
1074
+ for (const match of text.matchAll(INLINE)) {
1075
+ const token = match[0];
1076
+ const index = (_a = match.index) != null ? _a : 0;
1077
+ if (index > last) parent.appendChild(document.createTextNode(text.slice(last, index)));
1078
+ if (token.startsWith("**")) {
1079
+ const strong = document.createElement("strong");
1080
+ strong.textContent = token.slice(2, -2);
1081
+ parent.appendChild(strong);
1082
+ } else if (token.startsWith("`")) {
1083
+ const code = document.createElement("code");
1084
+ code.textContent = token.slice(1, -1);
1085
+ parent.appendChild(code);
1086
+ } else if (token.startsWith("[")) {
1087
+ const label = token.slice(1, token.indexOf("]("));
1088
+ const href = token.slice(token.indexOf("](") + 2, -1);
1089
+ parent.appendChild(link(label, href));
1090
+ } else if (token.startsWith("*")) {
1091
+ const em = document.createElement("em");
1092
+ em.textContent = token.slice(1, -1);
1093
+ parent.appendChild(em);
1094
+ } else {
1095
+ parent.appendChild(link(token, token));
1096
+ }
1097
+ last = index + token.length;
1098
+ }
1099
+ if (last < text.length) parent.appendChild(document.createTextNode(text.slice(last)));
1100
+ }
1101
+ function renderMarkdown(source) {
1102
+ const fragment = document.createDocumentFragment();
1103
+ const blocks = source.replace(/\r\n/g, "\n").split(/\n{2,}/);
1104
+ for (const block of blocks) {
1105
+ const lines = block.split("\n").filter((l) => l.trim() !== "");
1106
+ if (!lines.length) continue;
1107
+ const bullet = /^\s*[-*•]\s+/;
1108
+ const numbered = /^\s*\d+[.)]\s+/;
1109
+ if (lines.every((l) => bullet.test(l)) || lines.every((l) => numbered.test(l))) {
1110
+ const ordered = numbered.test(lines[0]);
1111
+ const list = document.createElement(ordered ? "ol" : "ul");
1112
+ for (const line of lines) {
1113
+ const li = document.createElement("li");
1114
+ appendInline(li, line.replace(ordered ? numbered : bullet, ""));
1115
+ list.appendChild(li);
1116
+ }
1117
+ fragment.appendChild(list);
1118
+ continue;
1119
+ }
1120
+ const p = document.createElement("p");
1121
+ lines.forEach((line, i) => {
1122
+ if (i > 0) p.appendChild(document.createElement("br"));
1123
+ appendInline(p, line);
1124
+ });
1125
+ fragment.appendChild(p);
1126
+ }
1127
+ return fragment;
1128
+ }
1129
+
700
1130
  // src/widget/TrilletWidgetElement.ts
701
1131
  var TrilletWidgetElement = class extends HTMLElement {
702
1132
  constructor() {
@@ -717,6 +1147,13 @@ var TrilletWidgetElement = class extends HTMLElement {
717
1147
  // True while tearing down one modality and reconnecting in the other, so lifecycle
718
1148
  // events (call-start/conversationStarted) aren't re-emitted for an internal switch.
719
1149
  this.switching = false;
1150
+ // Dashboard design (Widget designer), fetched on mount unless remote-config="false".
1151
+ // Attributes always win over it; see configFromElement.
1152
+ this.remote = null;
1153
+ this.remoteDisplay = null;
1154
+ this.remoteLoadedFor = null;
1155
+ // A suggested prompt clicked before the chat finished connecting; sent on connect.
1156
+ this.pendingMessage = null;
720
1157
  // maxCallDuration countdown (UX only — see startConversation()).
721
1158
  this.durationTimer = null;
722
1159
  this.remainingSeconds = null;
@@ -735,6 +1172,25 @@ var TrilletWidgetElement = class extends HTMLElement {
735
1172
  this.recaptchaSolved = false;
736
1173
  this.recaptchaSlot = null;
737
1174
  this.recaptchaWidgetId = null;
1175
+ this.pendingTimer = null;
1176
+ // Which top-level view is on screen; the entrance animation only plays on a change.
1177
+ this.lastView = null;
1178
+ // Inline notice in the chat (e.g. microphone refused). Cleared on the next switch.
1179
+ this.notice = null;
1180
+ this.switchingSide = false;
1181
+ this.smoothedLevel = 0;
1182
+ // ---- Terms gate + feedback --------------------------------------------------
1183
+ this.showTerms = false;
1184
+ this.pendingStart = null;
1185
+ this.callId = null;
1186
+ this.feedbackState = "hidden";
1187
+ // Fallback when storage is blocked: accepted for the life of this page.
1188
+ this.termsAcceptedThisPage = false;
1189
+ this.askFocused = false;
1190
+ // Last start/connection failure, shown instead of the "ended" line.
1191
+ this.errorText = null;
1192
+ // Half-typed message, kept across full re-renders (connecting -> live, etc.).
1193
+ this.draft = "";
738
1194
  this.root = this.attachShadow({ mode: "open" });
739
1195
  this.styleEl = document.createElement("style");
740
1196
  this.styleEl.textContent = WIDGET_STYLES;
@@ -747,11 +1203,37 @@ var TrilletWidgetElement = class extends HTMLElement {
747
1203
  return OBSERVED_ATTRIBUTES;
748
1204
  }
749
1205
  connectedCallback() {
750
- this.config = configFromElement(this);
1206
+ this.refreshConfig();
1207
+ void this.loadRemoteConfig();
1208
+ }
1209
+ refreshConfig() {
1210
+ this.config = configFromElement(this, this.remote);
751
1211
  this.syncActiveMode();
752
1212
  this.applyTheme();
753
1213
  this.render();
754
1214
  }
1215
+ /**
1216
+ * Fetch the design saved in the dashboard. Best-effort: on any failure the widget
1217
+ * keeps rendering from its attributes, exactly as before this existed.
1218
+ */
1219
+ async loadRemoteConfig() {
1220
+ var _a, _b;
1221
+ const { agentId, remoteConfig, apiBase } = this.config;
1222
+ if (!remoteConfig || !agentId || this.remoteLoadedFor === agentId) return;
1223
+ this.remoteLoadedFor = agentId;
1224
+ try {
1225
+ const url = `${apiUrl("/v1/api/web-call/public/widget-config", apiBase)}?agent_id=${encodeURIComponent(agentId)}`;
1226
+ const res = await fetch(url, { headers: { Accept: "application/json" } });
1227
+ if (!res.ok) return;
1228
+ const data = await res.json();
1229
+ if (this.config.agentId !== agentId) return;
1230
+ this.remote = (_a = data.widget) != null ? _a : null;
1231
+ this.remoteDisplay = (_b = data.display) != null ? _b : null;
1232
+ if (this.state === "idle") this.refreshConfig();
1233
+ } catch (error) {
1234
+ console.warn("[trillet-widget] Could not load widget design; using attributes only", error);
1235
+ }
1236
+ }
755
1237
  disconnectedCallback() {
756
1238
  this.clearDurationTimer();
757
1239
  this.teardownAgent();
@@ -759,10 +1241,25 @@ var TrilletWidgetElement = class extends HTMLElement {
759
1241
  }
760
1242
  attributeChangedCallback() {
761
1243
  if (!this.isConnected) return;
762
- this.config = configFromElement(this);
763
- this.syncActiveMode();
764
- this.applyTheme();
765
- this.render();
1244
+ this.refreshConfig();
1245
+ void this.loadRemoteConfig();
1246
+ }
1247
+ /**
1248
+ * Send a chat message as the visitor (text sessions). Opens and starts the chat
1249
+ * first when needed; the message is delivered as soon as the session connects.
1250
+ */
1251
+ async sendMessage(text) {
1252
+ var _a;
1253
+ const message = text.trim();
1254
+ if (!message) return;
1255
+ if (this.state === "live" && (this.resolvedMode() === "text" || this.config.mode === "both")) {
1256
+ await ((_a = this.agent) == null ? void 0 : _a.sendTextMessage(message));
1257
+ return;
1258
+ }
1259
+ if (this.config.mode === "voice") return;
1260
+ if (this.state === "idle" || this.state === "ended") this.transcripts = [];
1261
+ this.pendingMessage = message;
1262
+ if (this.state !== "connecting") await this.startConversation("text");
766
1263
  }
767
1264
  // ---- Public element API ----------------------------------------------------
768
1265
  /**
@@ -771,7 +1268,8 @@ var TrilletWidgetElement = class extends HTMLElement {
771
1268
  */
772
1269
  async startConversation(modality) {
773
1270
  if (this.state === "connecting" || this.state === "live") return;
774
- if (!this.isInlineVoice()) {
1271
+ const chat = this.config.mode === "text" || this.config.mode === "both" && modality !== "voice";
1272
+ if (chat) {
775
1273
  this.open = true;
776
1274
  }
777
1275
  if (this.needsRecaptcha()) {
@@ -794,13 +1292,6 @@ var TrilletWidgetElement = class extends HTMLElement {
794
1292
  this.endConversation();
795
1293
  }
796
1294
  // ---- Modality helpers ------------------------------------------------------
797
- /**
798
- * Voice embeds run entirely on the floating control. Text and `both` still need
799
- * the conversation panel.
800
- */
801
- isInlineVoice() {
802
- return this.config.mode === "voice";
803
- }
804
1295
  /** The concrete modality to run for the current session (`both` -> activeMode). */
805
1296
  resolvedMode() {
806
1297
  var _a;
@@ -827,32 +1318,72 @@ var TrilletWidgetElement = class extends HTMLElement {
827
1318
  this.agent = null;
828
1319
  }
829
1320
  /**
830
- * Switch modality mid-session (mode="both"). Because the core binds `mode` at
831
- * construction, this ends the current `TrilletAgent` and constructs a fresh one in
832
- * the other modality, rejoining via the same credential path. Transcripts and the
833
- * duration timer are preserved across the switch; no lifecycle events fire (it's one
834
- * conversation from the consumer's perspective).
1321
+ * Switch between typing and talking (mode="both"). Same session, same conversation:
1322
+ * the SDK turns the mic on/off and asks the agent to turn its speech on/off. If the
1323
+ * mic is refused, the conversation simply stays in text and says why.
835
1324
  */
836
1325
  async switchModality() {
837
- if (this.config.mode !== "both" || this.state !== "live") return;
838
- const target = this.resolvedMode() === "voice" ? "text" : "voice";
839
- this.switching = true;
840
- this.clearDurationTimer();
841
- this.speaking = false;
842
- this.teardownAgent();
843
- await this.beginCall(target);
1326
+ if (this.config.mode !== "both" || this.state !== "live" || !this.agent) return;
1327
+ const toVoice = this.resolvedMode() === "text";
1328
+ this.notice = null;
1329
+ this.switchingSide = true;
1330
+ this.render();
1331
+ try {
1332
+ await this.agent.setVoiceEnabled(toVoice);
1333
+ } catch (error) {
1334
+ console.warn("[trillet-widget] Could not switch modality", error);
1335
+ this.notice = toVoice ? "Could not turn on your microphone. Check the browser permission and try again." : "Could not switch back to typing. Please try again.";
1336
+ } finally {
1337
+ this.switchingSide = false;
1338
+ this.render();
1339
+ }
1340
+ }
1341
+ /**
1342
+ * Listening <-> Speaking flips several times a second at turn edges. Patch the few
1343
+ * nodes that show it instead of re-rendering, which would rebuild (and flash) the UI.
1344
+ */
1345
+ setSpeaking(speaking) {
1346
+ if (this.speaking === speaking) return;
1347
+ this.speaking = speaking;
1348
+ const activity = speaking ? this.config.speakingText : this.config.listeningText;
1349
+ this.root.querySelectorAll(".tw-callbar-activity").forEach((el) => {
1350
+ el.textContent = activity;
1351
+ });
1352
+ this.root.querySelectorAll(".tw-wave").forEach((el) => el.classList.toggle("tw-wave-speaking", speaking));
1353
+ this.root.querySelectorAll(".tw-mark").forEach((el) => el.classList.toggle("tw-speaking", speaking));
1354
+ const status = this.root.querySelector(".tw-header .tw-status");
1355
+ if (status) status.textContent = this.statusText();
1356
+ }
1357
+ /** Send the message typed before the chat started (once). */
1358
+ flushPending() {
1359
+ if (this.pendingTimer) clearTimeout(this.pendingTimer);
1360
+ this.pendingTimer = null;
1361
+ const queued = this.pendingMessage;
1362
+ this.pendingMessage = null;
1363
+ if (queued && this.agent && this.state === "live") void this.agent.sendTextMessage(queued);
844
1364
  }
845
1365
  // ---- Credential resolution + call lifecycle --------------------------------
846
1366
  async beginCall(modality) {
1367
+ if (this.config.termsText && !this.termsAccepted()) {
1368
+ this.pendingStart = modality != null ? modality : this.resolvedMode();
1369
+ this.showTerms = true;
1370
+ this.render();
1371
+ return;
1372
+ }
1373
+ this.feedbackState = "hidden";
847
1374
  if (modality) this.activeMode = modality;
848
1375
  const mode = this.resolvedMode();
1376
+ const session = this.config.mode === "both" ? "multimodal" : mode;
1377
+ this.notice = null;
849
1378
  if (!this.switching) this.display = null;
850
1379
  this.setState("connecting");
851
1380
  try {
852
1381
  const agent = new TrilletAgent({
853
1382
  agentId: this.config.agentId,
854
1383
  workspaceId: this.config.workspaceId,
855
- mode,
1384
+ apiBaseUrl: this.config.apiBase,
1385
+ mode: session,
1386
+ startWithVoice: session === "multimodal" && mode === "voice",
856
1387
  variables: this.config.variables
857
1388
  });
858
1389
  this.agent = agent;
@@ -860,7 +1391,7 @@ var TrilletWidgetElement = class extends HTMLElement {
860
1391
  if (this.config.signedUrlEndpoint || this.getRoomDetails) {
861
1392
  let details;
862
1393
  if (this.getRoomDetails) {
863
- details = await this.getRoomDetails();
1394
+ details = await this.getRoomDetails({ mode, session });
864
1395
  } else {
865
1396
  const res = await fetch(this.config.signedUrlEndpoint, {
866
1397
  method: "GET",
@@ -887,12 +1418,16 @@ var TrilletWidgetElement = class extends HTMLElement {
887
1418
  }
888
1419
  wireAgentEvents(agent) {
889
1420
  agent.on("connected", (details) => {
890
- var _a;
1421
+ var _a, _b;
891
1422
  this.display = (_a = details == null ? void 0 : details.display) != null ? _a : null;
1423
+ this.callId = (_b = details == null ? void 0 : details.callId) != null ? _b : null;
892
1424
  const wasSwitching = this.switching;
893
1425
  this.setState("live");
894
1426
  this.startDurationTimer(!wasSwitching);
895
1427
  this.switching = false;
1428
+ if (this.pendingMessage) {
1429
+ this.pendingTimer = setTimeout(() => this.flushPending(), 25e3);
1430
+ }
896
1431
  });
897
1432
  agent.on("disconnected", () => {
898
1433
  this.endLocalCall();
@@ -900,32 +1435,43 @@ var TrilletWidgetElement = class extends HTMLElement {
900
1435
  agent.on("error", (error) => {
901
1436
  this.handleError(error);
902
1437
  });
903
- agent.on("assistantStartedSpeaking", () => {
904
- this.speaking = true;
905
- this.render();
906
- });
907
- agent.on("assistantStoppedSpeaking", () => {
1438
+ agent.on("modalityChanged", (side) => {
1439
+ this.activeMode = side;
908
1440
  this.speaking = false;
1441
+ this.dispatch("modality", side);
909
1442
  this.render();
910
1443
  });
1444
+ agent.on("audioData", (samples) => this.setLevel(samples));
1445
+ agent.on("assistantStartedSpeaking", () => this.setSpeaking(true));
1446
+ agent.on("assistantStoppedSpeaking", () => this.setSpeaking(false));
911
1447
  agent.on("transcriptUpdate", (transcripts) => {
912
- this.transcripts = transcripts;
913
- this.dispatch("transcript", transcripts);
914
- this.render();
1448
+ this.transcripts = [...transcripts];
1449
+ if (this.pendingMessage && transcripts.some((t) => t.role === "assistant" && !t.toolUsed)) {
1450
+ this.flushPending();
1451
+ }
1452
+ this.dispatch("transcript", this.transcripts);
1453
+ if (!this.updateThread()) this.render();
915
1454
  });
916
1455
  }
917
1456
  endLocalCall() {
918
1457
  if (this.state === "ended" || this.state === "idle") return;
1458
+ if (this.config.feedback === "end" && this.callId && this.elapsedSeconds >= 5) {
1459
+ this.feedbackState = "ask";
1460
+ }
919
1461
  this.clearDurationTimer();
920
1462
  this.speaking = false;
921
1463
  this.dispatch("call-end", this.elapsedSeconds);
922
1464
  this.dispatch("conversationEnded", this.elapsedSeconds);
923
1465
  this.setState("ended");
924
1466
  this.agent = null;
1467
+ this.pendingMessage = null;
1468
+ if (this.pendingTimer) clearTimeout(this.pendingTimer);
1469
+ this.pendingTimer = null;
925
1470
  if (this.config.mode === "both") this.activeMode = null;
926
1471
  }
927
1472
  handleError(error) {
928
1473
  const err = error instanceof Error ? error : new Error(String(error));
1474
+ this.errorText = friendlyError(err, this.config.copy);
929
1475
  this.clearDurationTimer();
930
1476
  this.speaking = false;
931
1477
  this.switching = false;
@@ -966,6 +1512,7 @@ var TrilletWidgetElement = class extends HTMLElement {
966
1512
  // ---- State + DOM events ----------------------------------------------------
967
1513
  setState(state) {
968
1514
  const prev = this.state;
1515
+ if (state === "connecting") this.errorText = null;
969
1516
  this.state = state;
970
1517
  if (state === "live" && prev !== "live" && !this.switching) {
971
1518
  this.dispatch("call-start", void 0);
@@ -978,16 +1525,21 @@ var TrilletWidgetElement = class extends HTMLElement {
978
1525
  }
979
1526
  // ---- Theming ----------------------------------------------------------------
980
1527
  applyTheme() {
981
- const orb1 = this.config.orbColor1 || DEFAULT_ORB_COLOR_1;
982
- const orb2 = this.config.orbColor2 || DEFAULT_ORB_COLOR_2;
983
- this.style.setProperty("--trillet-orb-1", orb1);
984
- this.style.setProperty("--trillet-orb-2", orb2);
985
- const accent = this.config.brand.primaryColor || this.config.orbColor1;
986
- if (accent) {
987
- this.style.setProperty("--trillet-accent", accent);
988
- } else {
989
- this.style.removeProperty("--trillet-accent");
990
- }
1528
+ const accent = this.config.brand.primaryColor || this.config.orbColor1 || DEFAULT_ACCENT;
1529
+ this.style.setProperty("--tw-accent", accent);
1530
+ this.style.setProperty("--tw-on-accent", readableOn(accent));
1531
+ const custom = this.config.backgroundColor || this.config.textColor;
1532
+ const setOrClear = (name, value) => value ? this.style.setProperty(name, value) : this.style.removeProperty(name);
1533
+ setOrClear("--tw-surface", this.config.backgroundColor);
1534
+ setOrClear("--tw-ink", this.config.textColor);
1535
+ setOrClear("--tw-raised", custom ? "color-mix(in srgb, var(--tw-ink) 7%, var(--tw-surface))" : void 0);
1536
+ setOrClear("--tw-line", custom ? "color-mix(in srgb, var(--tw-ink) 14%, var(--tw-surface))" : void 0);
1537
+ setOrClear("--tw-muted", custom ? "color-mix(in srgb, var(--tw-ink) 62%, var(--tw-surface))" : void 0);
1538
+ if (this.config.buttonTextColor) this.style.setProperty("--tw-on-accent", this.config.buttonTextColor);
1539
+ this.style.setProperty("--tw-orb-1", this.config.orbColor1 || accent);
1540
+ this.style.setProperty("--tw-orb-2", this.config.orbColor2 || "#27a3fd");
1541
+ this.dataset.placement = this.config.placement;
1542
+ this.dataset.theme = this.config.theme;
991
1543
  }
992
1544
  // ---- Rendering --------------------------------------------------------------
993
1545
  formatTime(total) {
@@ -995,23 +1547,22 @@ var TrilletWidgetElement = class extends HTMLElement {
995
1547
  const s = total % 60;
996
1548
  return `${m}:${s.toString().padStart(2, "0")}`;
997
1549
  }
1550
+ /** The line under the agent's name in the header. */
998
1551
  statusText() {
999
- switch (this.state) {
1000
- case "connecting":
1001
- return "Connecting\u2026";
1002
- case "live":
1003
- return this.speaking ? this.config.speakingText : this.config.listeningText;
1004
- case "ended":
1005
- return "Call ended";
1006
- default:
1007
- return this.config.actionText || "";
1552
+ if (this.state === "connecting") return this.config.copy.connecting;
1553
+ if (this.state === "live" && this.resolvedMode() === "voice") {
1554
+ const activity = this.speaking ? this.config.speakingText : this.config.listeningText;
1555
+ return `${activity} ${this.timerText()}`.trim();
1008
1556
  }
1557
+ if (this.state === "live") return this.config.copy.online;
1558
+ return this.config.brand.name || this.config.copy.online;
1009
1559
  }
1010
1560
  renderStatus() {
1011
1561
  const statusEl = this.root.querySelector(".tw-status");
1012
1562
  if (statusEl) statusEl.textContent = this.statusText();
1013
- const timerEl = this.root.querySelector(".tw-timer");
1014
- if (timerEl) timerEl.textContent = this.timerText();
1563
+ this.root.querySelectorAll(".tw-timer").forEach((el) => {
1564
+ el.textContent = el.classList.contains("tw-callbar-meta") ? [this.speakerName(), this.timerText()].filter(Boolean).join(" \xB7 ") : this.timerText();
1565
+ });
1015
1566
  }
1016
1567
  timerText() {
1017
1568
  if (this.state !== "live") return "";
@@ -1020,109 +1571,329 @@ var TrilletWidgetElement = class extends HTMLElement {
1020
1571
  }
1021
1572
  return this.formatTime(this.elapsedSeconds);
1022
1573
  }
1574
+ /**
1575
+ * Agent voice level (0..1) from the live audio. Written straight to a CSS variable
1576
+ * on the host, so the presence ring moves with the real voice without re-rendering.
1577
+ */
1578
+ setLevel(samples) {
1579
+ let sum = 0;
1580
+ for (let i = 0; i < samples.length; i += 1) sum += samples[i] * samples[i];
1581
+ const rms = Math.sqrt(sum / (samples.length || 1));
1582
+ const level = Math.min(1, rms * 6);
1583
+ this.smoothedLevel = this.smoothedLevel * 0.7 + level * 0.3;
1584
+ this.style.setProperty("--tw-level", this.smoothedLevel.toFixed(3));
1585
+ }
1023
1586
  render() {
1024
1587
  this.container.replaceChildren();
1025
- if (this.isInlineVoice()) {
1026
- this.container.appendChild(this.renderInlineVoice());
1027
- return;
1588
+ let view;
1589
+ let el;
1590
+ if (this.showTerms) {
1591
+ view = "terms";
1592
+ el = this.renderTerms();
1593
+ } else if (this.open) {
1594
+ view = "panel";
1595
+ el = this.renderPanel();
1596
+ } else {
1597
+ el = this.renderCard();
1598
+ view = el.querySelector(".tw-callbar") ? "callbar" : "bar";
1028
1599
  }
1029
- if (!this.open) {
1030
- this.container.appendChild(this.renderLauncher());
1031
- return;
1600
+ if (view !== this.lastView) el.classList.add("tw-enter");
1601
+ this.lastView = view;
1602
+ this.container.appendChild(el);
1603
+ }
1604
+ // ---- Shared building blocks ---------------------------------------------------
1605
+ /** Avatar style: an explicit choice, else the image when one is set, else the orb. */
1606
+ avatarStyle() {
1607
+ const chosen = this.config.avatarStyle;
1608
+ if (chosen === "image" && !this.config.avatar) return "orb";
1609
+ if (chosen) return chosen;
1610
+ return this.config.avatar ? "image" : "orb";
1611
+ }
1612
+ /**
1613
+ * The mark: who the visitor is talking to, as a small rounded tile. A gradient in
1614
+ * the brand colours (default), the business's image, or initials. While the agent
1615
+ * speaks on a call, the tile breathes with the voice level (--tw-level).
1616
+ */
1617
+ buildAvatar(size) {
1618
+ const mark = document.createElement("span");
1619
+ const style = this.avatarStyle();
1620
+ mark.className = `tw-mark tw-mark-${size} tw-mark-${style}`;
1621
+ mark.setAttribute("aria-hidden", "true");
1622
+ if (this.state === "live" && this.resolvedMode() === "voice") mark.classList.add("tw-voice-live");
1623
+ if (style === "image") mark.style.backgroundImage = `url("${this.config.avatar}")`;
1624
+ else if (style === "initials") mark.textContent = initials(this.speakerName());
1625
+ return mark;
1626
+ }
1627
+ /** The name shown to visitors: business name, else the agent/flow name. */
1628
+ speakerName() {
1629
+ return this.config.brand.name || this.headerTitle() || "";
1630
+ }
1631
+ /** Live voice level as five bars (heights follow --tw-level). */
1632
+ buildWave() {
1633
+ const wave = document.createElement("span");
1634
+ wave.className = `tw-wave${this.speaking ? " tw-wave-speaking" : ""}`;
1635
+ wave.setAttribute("aria-hidden", "true");
1636
+ for (let n = 0; n < 5; n += 1) wave.appendChild(document.createElement("i"));
1637
+ return wave;
1638
+ }
1639
+ iconButton(icon, label, onClick, extraClass = "") {
1640
+ const btn = document.createElement("button");
1641
+ btn.type = "button";
1642
+ btn.className = `tw-icon-btn ${extraClass}`.trim();
1643
+ btn.title = label;
1644
+ btn.setAttribute("aria-label", label);
1645
+ btn.innerHTML = icon;
1646
+ btn.addEventListener("click", onClick);
1647
+ return btn;
1648
+ }
1649
+ /** Acceptance is remembered per agent and per version of the text. */
1650
+ termsKey() {
1651
+ let hash = 0;
1652
+ for (const ch of this.config.termsText || "") hash = hash * 31 + ch.charCodeAt(0) | 0;
1653
+ return `trillet-terms:${this.config.agentId}:${hash}`;
1654
+ }
1655
+ termsAccepted() {
1656
+ if (this.termsAcceptedThisPage) return true;
1657
+ try {
1658
+ return window.localStorage.getItem(this.termsKey()) === "1";
1659
+ } catch (e) {
1660
+ return false;
1661
+ }
1662
+ }
1663
+ renderTerms() {
1664
+ const card = document.createElement("div");
1665
+ card.className = "tw-card tw-terms";
1666
+ card.setAttribute("role", "dialog");
1667
+ card.setAttribute("aria-label", this.config.copy.terms);
1668
+ const title = document.createElement("div");
1669
+ title.className = "tw-card-title";
1670
+ title.textContent = this.config.copy.termsTitle;
1671
+ card.appendChild(title);
1672
+ const body = document.createElement("div");
1673
+ body.className = "tw-terms-body tw-md";
1674
+ body.appendChild(renderMarkdown(this.config.termsText || ""));
1675
+ card.appendChild(body);
1676
+ const row = document.createElement("div");
1677
+ row.className = "tw-card-actions";
1678
+ const accept = document.createElement("button");
1679
+ accept.type = "button";
1680
+ accept.className = "tw-pill";
1681
+ accept.textContent = this.config.copy.termsAccept;
1682
+ accept.addEventListener("click", () => {
1683
+ try {
1684
+ window.localStorage.setItem(this.termsKey(), "1");
1685
+ } catch (e) {
1686
+ }
1687
+ this.termsAcceptedThisPage = true;
1688
+ this.showTerms = false;
1689
+ const start = this.pendingStart;
1690
+ this.pendingStart = null;
1691
+ if (start === "text") this.open = true;
1692
+ void this.beginCall(start != null ? start : void 0);
1693
+ });
1694
+ const decline = document.createElement("button");
1695
+ decline.type = "button";
1696
+ decline.className = "tw-secondary-btn";
1697
+ decline.textContent = this.config.copy.termsDecline;
1698
+ decline.addEventListener("click", () => {
1699
+ this.showTerms = false;
1700
+ this.pendingStart = null;
1701
+ this.open = false;
1702
+ this.render();
1703
+ });
1704
+ row.appendChild(accept);
1705
+ row.appendChild(decline);
1706
+ card.appendChild(row);
1707
+ return card;
1708
+ }
1709
+ /** "How was this conversation?" thumbs, once, after a conversation ends. */
1710
+ renderFeedback() {
1711
+ if (this.feedbackState === "hidden") return null;
1712
+ const row = document.createElement("div");
1713
+ row.className = "tw-feedback";
1714
+ if (this.feedbackState === "sent") {
1715
+ row.textContent = this.config.copy.feedbackThanks;
1716
+ return row;
1032
1717
  }
1033
- this.container.appendChild(this.renderPanel());
1718
+ const label = document.createElement("span");
1719
+ label.textContent = this.config.copy.feedbackQuestion;
1720
+ row.appendChild(label);
1721
+ const send = (rating) => {
1722
+ this.feedbackState = "sent";
1723
+ this.render();
1724
+ fetch(apiUrl("/v1/api/web-call/public/feedback", this.config.apiBase), {
1725
+ method: "POST",
1726
+ headers: { "Content-Type": "application/json" },
1727
+ body: JSON.stringify({ call_id: this.callId, rating })
1728
+ }).catch(() => void 0);
1729
+ this.dispatch("feedback", rating);
1730
+ };
1731
+ row.appendChild(this.iconButton(ICONS.thumbUp, this.config.copy.feedbackGood, () => send("up")));
1732
+ row.appendChild(this.iconButton(ICONS.thumbDown, this.config.copy.feedbackBad, () => send("down")));
1733
+ return row;
1034
1734
  }
1035
1735
  /**
1036
- * Voice chrome: one floating control. Idle/ended starts the call. Connecting
1037
- * shows progress on that same control. Live turns it into hang up and reflects
1038
- * listening vs speaking. No panel.
1736
+ * The ask bar: the widget's resting state.
1737
+ *
1738
+ * [mark] Ask Firelink anything… (mic) (send)
1739
+ *
1740
+ * Input-first: typing + Enter opens the chat with that message already sent; the
1741
+ * mic starts a call and the bar becomes the call bar. Voice-only shows "Talk to …"
1742
+ * with a call button; chat-only drops the mic.
1039
1743
  */
1040
- renderInlineVoice() {
1041
- const wrap = document.createElement("div");
1042
- wrap.className = "tw-inline";
1043
- const showGate = this.needsRecaptcha() && (this.state === "idle" || this.state === "ended");
1044
- if (showGate) {
1045
- const hint = document.createElement("div");
1046
- hint.className = "tw-inline-hint";
1047
- hint.textContent = this.config.recaptchaText;
1048
- wrap.appendChild(hint);
1744
+ renderCard() {
1745
+ const idle = this.state === "idle" || this.state === "ended";
1746
+ const live = this.state === "live";
1747
+ const voiceLive = live && this.resolvedMode() === "voice";
1748
+ const voiceStarting = this.state === "connecting" && this.resolvedMode() === "voice";
1749
+ const gated = this.needsRecaptcha() && idle;
1750
+ const stack = document.createElement("div");
1751
+ stack.className = "tw-bar-stack";
1752
+ if (voiceLive || voiceStarting) {
1753
+ stack.appendChild(this.renderVoiceBar(false));
1754
+ return stack;
1755
+ }
1756
+ if (this.errorText && idle) {
1757
+ const err = document.createElement("div");
1758
+ err.className = "tw-bar-note tw-error-text";
1759
+ err.textContent = this.errorText;
1760
+ stack.appendChild(err);
1761
+ }
1762
+ const bar = document.createElement("div");
1763
+ bar.className = "tw-ask";
1764
+ bar.appendChild(this.buildAvatar("md"));
1765
+ const name = this.speakerName();
1766
+ const canChat = this.config.mode !== "voice";
1767
+ const canTalk = this.config.mode !== "text";
1768
+ if (live || this.state === "connecting") {
1769
+ const back = document.createElement("button");
1770
+ back.type = "button";
1771
+ back.className = "tw-ask-label";
1772
+ back.textContent = name ? fillName(this.config.copy.chatWithNamed, name) : this.config.copy.backToChat;
1773
+ back.addEventListener("click", () => this.openPanel());
1774
+ bar.appendChild(back);
1775
+ bar.appendChild(this.iconButton(ICONS.chat, this.config.copy.openChat, () => this.openPanel(), "tw-sq tw-sq-accent"));
1776
+ stack.appendChild(bar);
1777
+ return stack;
1778
+ }
1779
+ if (!canChat) {
1780
+ const label = document.createElement("button");
1781
+ label.type = "button";
1782
+ label.className = "tw-ask-label";
1783
+ label.textContent = this.config.greeting || (name ? `Talk to ${name}` : this.config.startCallText);
1784
+ label.disabled = gated;
1785
+ label.addEventListener("click", () => {
1786
+ if (!this.needsRecaptcha()) void this.beginCall("voice");
1787
+ });
1788
+ bar.appendChild(label);
1789
+ const call = this.iconButton(ICONS.phone, this.config.actionText || this.config.startCallText, () => {
1790
+ if (!this.needsRecaptcha()) void this.beginCall("voice");
1791
+ }, "tw-sq tw-sq-accent");
1792
+ call.disabled = gated;
1793
+ bar.appendChild(call);
1794
+ } else {
1795
+ const form = document.createElement("form");
1796
+ form.className = "tw-ask-form";
1797
+ const input = document.createElement("input");
1798
+ input.className = "tw-ask-input";
1799
+ input.type = "text";
1800
+ input.placeholder = this.config.greeting || (name ? fillName(this.config.copy.askNamed, name) : this.config.copy.askAnything);
1801
+ input.setAttribute("aria-label", input.placeholder);
1802
+ input.value = this.draft;
1803
+ input.disabled = gated;
1804
+ const send = this.iconButton(ICONS.send, this.config.copy.send, () => void 0, "tw-sq tw-sq-accent");
1805
+ send.type = "submit";
1806
+ const sync = () => {
1807
+ send.disabled = gated || !input.value.trim();
1808
+ };
1809
+ input.addEventListener("input", () => {
1810
+ this.draft = input.value;
1811
+ sync();
1812
+ });
1813
+ input.addEventListener("focus", () => {
1814
+ this.askFocused = true;
1815
+ this.renderAskSuggestions(stack, bar);
1816
+ });
1817
+ input.addEventListener("blur", () => {
1818
+ this.askFocused = false;
1819
+ setTimeout(() => {
1820
+ var _a;
1821
+ if (!this.askFocused) (_a = stack.querySelector(".tw-ask-suggestions")) == null ? void 0 : _a.remove();
1822
+ }, 150);
1823
+ });
1824
+ form.addEventListener("submit", (e) => {
1825
+ e.preventDefault();
1826
+ const text = input.value.trim();
1827
+ if (!text || this.needsRecaptcha()) return;
1828
+ this.draft = "";
1829
+ void this.sendMessage(text);
1830
+ });
1831
+ form.appendChild(input);
1832
+ if (canTalk) {
1833
+ const call = this.iconButton(ICONS.phone, this.config.actionText || this.config.startCallText, () => {
1834
+ if (!this.needsRecaptcha()) void this.beginCall("voice");
1835
+ }, "tw-sq tw-sq-quiet");
1836
+ call.disabled = gated;
1837
+ form.appendChild(call);
1838
+ }
1839
+ form.appendChild(send);
1840
+ sync();
1841
+ bar.appendChild(form);
1842
+ }
1843
+ stack.appendChild(bar);
1844
+ if (gated) {
1049
1845
  const slot = document.createElement("slot");
1050
1846
  slot.setAttribute("name", "recaptcha");
1051
1847
  slot.className = "tw-recaptcha-slot";
1052
- wrap.appendChild(slot);
1848
+ stack.insertBefore(slot, bar);
1053
1849
  this.ensureRecaptchaSlot();
1054
1850
  }
1055
- const btn = document.createElement("button");
1056
- btn.className = "tw-launcher";
1057
- btn.type = "button";
1058
- const orb = document.createElement("span");
1059
- orb.className = "tw-launcher-orb";
1060
- if (this.config.avatar) {
1061
- orb.classList.add("tw-launcher-orb-avatar");
1062
- orb.style.backgroundImage = `url("${this.config.avatar}")`;
1851
+ const feedback = idle ? this.renderFeedback() : null;
1852
+ if (feedback) {
1853
+ feedback.classList.add("tw-bar-note");
1854
+ stack.insertBefore(feedback, bar);
1063
1855
  }
1064
- btn.appendChild(orb);
1065
- const copy = document.createElement("span");
1066
- copy.className = "tw-launcher-copy";
1067
- const label = document.createElement("span");
1068
- label.className = "tw-launcher-label";
1069
- if (this.state === "connecting") {
1070
- btn.classList.add("tw-connecting");
1071
- btn.disabled = true;
1072
- label.textContent = "Connecting\u2026";
1073
- btn.setAttribute("aria-label", "Connecting");
1074
- } else if (this.state === "live") {
1075
- btn.classList.add("tw-hangup");
1076
- btn.classList.add(this.speaking ? "tw-speaking" : "tw-listening");
1077
- label.textContent = this.config.endCallText;
1078
- const activity = this.speaking ? this.config.speakingText : this.config.listeningText;
1079
- const stateLabel = document.createElement("span");
1080
- stateLabel.className = "tw-launcher-state";
1081
- stateLabel.textContent = activity;
1082
- copy.appendChild(label);
1083
- copy.appendChild(stateLabel);
1084
- btn.setAttribute("aria-label", `${this.config.endCallText}. ${activity}`);
1085
- btn.addEventListener("click", () => {
1086
- this.endConversation();
1087
- });
1088
- } else {
1089
- label.textContent = this.config.actionText || this.config.startCallText;
1090
- btn.disabled = showGate;
1091
- btn.setAttribute("aria-label", label.textContent);
1092
- btn.addEventListener("click", () => {
1093
- if (this.state === "connecting" || this.state === "live") return;
1094
- if (this.needsRecaptcha()) return;
1095
- void this.beginCall();
1856
+ return stack;
1857
+ }
1858
+ /** Suggested questions just above the ask bar while it has focus. */
1859
+ renderAskSuggestions(stack, bar) {
1860
+ if (!this.config.suggestedPrompts.length || stack.querySelector(".tw-ask-suggestions")) return;
1861
+ const row = document.createElement("div");
1862
+ row.className = "tw-ask-suggestions";
1863
+ for (const prompt of this.config.suggestedPrompts) {
1864
+ const chip = document.createElement("button");
1865
+ chip.type = "button";
1866
+ chip.className = "tw-suggestion";
1867
+ chip.textContent = prompt;
1868
+ chip.addEventListener("mousedown", (e) => {
1869
+ e.preventDefault();
1870
+ this.askFocused = false;
1871
+ void this.sendMessage(prompt);
1096
1872
  });
1873
+ row.appendChild(chip);
1097
1874
  }
1098
- if (this.state !== "live") copy.appendChild(label);
1099
- btn.appendChild(copy);
1100
- wrap.appendChild(btn);
1101
- return wrap;
1875
+ stack.insertBefore(row, bar);
1102
1876
  }
1103
- renderLauncher() {
1104
- const btn = document.createElement("button");
1105
- btn.className = "tw-launcher";
1106
- btn.type = "button";
1107
- const orb = document.createElement("span");
1108
- orb.className = "tw-launcher-orb";
1109
- if (this.config.avatar) {
1110
- orb.classList.add("tw-launcher-orb-avatar");
1111
- orb.style.backgroundImage = `url("${this.config.avatar}")`;
1877
+ /**
1878
+ * Open the panel. A text-only widget starts the chat straight away, so the agent's
1879
+ * welcome is already there when the panel opens, like any website chat. `both`
1880
+ * waits for the visitor to pick call or message.
1881
+ */
1882
+ openPanel() {
1883
+ this.open = true;
1884
+ const idle = this.state === "idle" || this.state === "ended";
1885
+ if (this.config.mode === "text" && idle && !this.needsRecaptcha()) {
1886
+ this.transcripts = [];
1887
+ void this.beginCall("text");
1888
+ return;
1112
1889
  }
1113
- btn.appendChild(orb);
1114
- const label = document.createElement("span");
1115
- label.textContent = this.config.actionText || this.config.startCallText;
1116
- btn.appendChild(label);
1117
- btn.addEventListener("click", () => {
1118
- this.open = true;
1119
- this.render();
1120
- });
1121
- return btn;
1890
+ this.render();
1122
1891
  }
1123
1892
  renderPanel() {
1124
1893
  const panel = document.createElement("div");
1125
1894
  panel.className = `tw-panel${this.config.variant === "expanded" ? " tw-expanded" : ""}`;
1895
+ panel.setAttribute("role", "dialog");
1896
+ panel.setAttribute("aria-label", this.headerTitle() || this.config.copy.chat);
1126
1897
  panel.appendChild(this.renderHeader());
1127
1898
  panel.appendChild(this.renderBody());
1128
1899
  return panel;
@@ -1131,90 +1902,70 @@ var TrilletWidgetElement = class extends HTMLElement {
1131
1902
  * The header title identifying who the user is talking to. Each identity value is
1132
1903
  * code-overridable per value: a static `agent-name`/`call-flow-name`/`workspace-name`
1133
1904
  * config value takes precedence over the corresponding backend `display.*` value
1134
- * (which only arrives on `connected`), falling back to it when unset. Resolution:
1135
- * effectiveAgent = config.agentName ?? display.agent_name
1136
- * effectiveCallFlow = config.callFlowName ?? display.call_flow_name
1137
- * effectiveWorkspace = config.workspaceName ?? display.workspace_name
1138
- * title = effectiveAgent || effectiveCallFlow || effectiveWorkspace || ''
1139
- * Because the overrides are static config, the title can render pre-call. Note:
1140
- * `brand.name` is intentionally NOT part of this chain — it renders in the brand
1141
- * slot only.
1905
+ * (which only arrives on `connected`), falling back to it when unset. `brand.name`
1906
+ * is intentionally NOT part of this chain; it renders as the status line pre-call.
1142
1907
  */
1143
1908
  headerTitle() {
1144
- var _a, _b, _c, _d, _e, _f;
1145
- const effectiveAgent = (_b = this.config.agentName) != null ? _b : (_a = this.display) == null ? void 0 : _a.agent_name;
1146
- const effectiveCallFlow = (_d = this.config.callFlowName) != null ? _d : (_c = this.display) == null ? void 0 : _c.call_flow_name;
1147
- const effectiveWorkspace = (_f = this.config.workspaceName) != null ? _f : (_e = this.display) == null ? void 0 : _e.workspace_name;
1909
+ var _a, _b, _c, _d;
1910
+ const display = (_a = this.display) != null ? _a : this.remoteDisplay;
1911
+ const effectiveAgent = (_b = this.config.agentName) != null ? _b : display == null ? void 0 : display.agent_name;
1912
+ const effectiveCallFlow = (_c = this.config.callFlowName) != null ? _c : display == null ? void 0 : display.call_flow_name;
1913
+ const effectiveWorkspace = (_d = this.config.workspaceName) != null ? _d : display == null ? void 0 : display.workspace_name;
1148
1914
  return effectiveAgent || effectiveCallFlow || effectiveWorkspace || "";
1149
1915
  }
1150
1916
  renderHeader() {
1151
1917
  const header = document.createElement("div");
1152
1918
  header.className = "tw-header";
1153
- if (this.config.brand.logo || this.config.brand.name) {
1154
- const brand = document.createElement("div");
1155
- brand.className = "tw-brand";
1156
- if (this.config.brand.logo) {
1157
- const logo = document.createElement("img");
1158
- logo.className = "tw-brand-logo";
1159
- logo.src = this.config.brand.logo;
1160
- logo.alt = this.config.brand.name || "";
1161
- brand.appendChild(logo);
1162
- }
1163
- if (this.config.brand.name) {
1164
- const brandLabel = document.createElement("span");
1165
- brandLabel.className = "tw-brand-name";
1166
- brandLabel.textContent = this.config.brand.name;
1167
- brandLabel.title = this.config.brand.name;
1168
- brand.appendChild(brandLabel);
1169
- }
1170
- header.appendChild(brand);
1171
- }
1919
+ if (!this.bodyShowsLargeAvatar()) header.appendChild(this.buildAvatar("sm"));
1920
+ const who = document.createElement("div");
1921
+ who.className = "tw-who";
1172
1922
  const name = document.createElement("div");
1173
1923
  name.className = "tw-header-title";
1174
- const title = this.headerTitle();
1924
+ const title = this.config.agentName || this.speakerName();
1175
1925
  name.textContent = title;
1176
1926
  if (title) name.title = title;
1177
- header.appendChild(name);
1178
- if (this.config.variant === "compact") {
1179
- const expandBtn = document.createElement("button");
1180
- expandBtn.className = "tw-icon-btn";
1181
- expandBtn.type = "button";
1182
- expandBtn.title = this.config.expandText;
1183
- expandBtn.textContent = "\u2922";
1184
- expandBtn.addEventListener("click", () => {
1185
- this.config = { ...this.config, variant: "expanded" };
1186
- this.render();
1187
- });
1188
- header.appendChild(expandBtn);
1189
- } else {
1190
- const collapseBtn = document.createElement("button");
1191
- collapseBtn.className = "tw-icon-btn";
1192
- collapseBtn.type = "button";
1193
- collapseBtn.title = this.config.collapseText;
1194
- collapseBtn.textContent = "\u2921";
1195
- collapseBtn.addEventListener("click", () => {
1196
- this.config = { ...this.config, variant: "compact" };
1197
- this.render();
1198
- });
1199
- header.appendChild(collapseBtn);
1927
+ const status = document.createElement("div");
1928
+ status.className = "tw-status";
1929
+ if (this.state === "live") status.classList.add("tw-online");
1930
+ status.textContent = this.statusText();
1931
+ who.appendChild(name);
1932
+ who.appendChild(status);
1933
+ header.appendChild(who);
1934
+ if (this.config.brand.logo) {
1935
+ const logo = document.createElement("img");
1936
+ logo.className = "tw-brand-logo";
1937
+ logo.src = this.config.brand.logo;
1938
+ logo.alt = this.config.brand.name || "";
1939
+ header.appendChild(logo);
1200
1940
  }
1201
- if (this.config.dismissible) {
1202
- const closeBtn = document.createElement("button");
1203
- closeBtn.className = "tw-icon-btn";
1204
- closeBtn.type = "button";
1205
- closeBtn.title = "Close";
1206
- closeBtn.textContent = "\u2715";
1207
- closeBtn.addEventListener("click", () => {
1208
- if (this.state === "live" || this.state === "connecting") {
1209
- this.endConversation();
1210
- }
1941
+ const actions = document.createElement("div");
1942
+ actions.className = "tw-header-actions";
1943
+ actions.appendChild(
1944
+ this.iconButton(ICONS.minimize, this.config.copy.minimize, () => {
1211
1945
  this.open = false;
1212
1946
  this.render();
1213
- });
1214
- header.appendChild(closeBtn);
1947
+ })
1948
+ );
1949
+ if (this.config.dismissible) {
1950
+ actions.appendChild(
1951
+ this.iconButton(ICONS.close, this.config.copy.close, () => {
1952
+ if (this.state === "live" || this.state === "connecting") this.endConversation();
1953
+ this.open = false;
1954
+ this.render();
1955
+ })
1956
+ );
1215
1957
  }
1958
+ header.appendChild(actions);
1216
1959
  return header;
1217
1960
  }
1961
+ /** Start, call and gate screens centre a large avatar in the body. */
1962
+ bodyShowsLargeAvatar() {
1963
+ const idle = this.state === "idle" || this.state === "ended";
1964
+ if (this.needsRecaptcha() && idle) return true;
1965
+ if (this.isBothPreCall()) return true;
1966
+ if (this.config.mode !== "both" && this.resolvedMode() === "voice") return true;
1967
+ return this.state === "idle" && this.transcripts.length === 0;
1968
+ }
1218
1969
  /** True when a `both` widget is idle/ended with no modality chosen yet. */
1219
1970
  isBothPreCall() {
1220
1971
  return this.config.mode === "both" && this.activeMode === null && (this.state === "idle" || this.state === "ended");
@@ -1225,43 +1976,38 @@ var TrilletWidgetElement = class extends HTMLElement {
1225
1976
  return Boolean(this.config.recaptchaSiteKey) && !this.recaptchaSolved;
1226
1977
  }
1227
1978
  /**
1228
- * The pre-call gate shown in the panel: orb, prompt, the reCAPTCHA checkbox, and a
1979
+ * The pre-call gate shown in the panel: prompt, the reCAPTCHA checkbox, and a
1229
1980
  * disabled start button. The button enables once the checkbox is solved.
1230
1981
  *
1231
1982
  * The checkbox itself is projected in via a <slot>: reCAPTCHA v2 hangs inside a
1232
1983
  * shadow root (its anchor iframe never finishes initializing), so the actual widget
1233
1984
  * is rendered into a LIGHT-DOM node — a child of the host element — that is assigned
1234
1985
  * to this slot. It therefore *displays* here inside the panel while its DOM home
1235
- * stays in the light tree, where reCAPTCHA works. Verified via examples/recaptcha-
1236
- * isolate.local.html (case C).
1986
+ * stays in the light tree, where reCAPTCHA works.
1237
1987
  */
1238
1988
  renderRecaptchaGate(body) {
1239
- body.appendChild(this.buildOrb());
1240
- const status = document.createElement("div");
1241
- status.className = "tw-status";
1242
- status.textContent = this.config.recaptchaText;
1243
- body.appendChild(status);
1989
+ body.classList.add("tw-center-body");
1990
+ body.appendChild(this.buildAvatar("lg"));
1991
+ const prompt = document.createElement("p");
1992
+ prompt.className = "tw-prompt";
1993
+ prompt.textContent = this.config.recaptchaText;
1994
+ body.appendChild(prompt);
1244
1995
  const slot = document.createElement("slot");
1245
1996
  slot.setAttribute("name", "recaptcha");
1246
1997
  slot.className = "tw-recaptcha-slot";
1247
1998
  body.appendChild(slot);
1248
- const controls = document.createElement("div");
1249
- controls.className = "tw-controls";
1250
1999
  const startBtn = document.createElement("button");
1251
2000
  startBtn.className = "tw-primary-btn";
1252
2001
  startBtn.type = "button";
1253
2002
  startBtn.textContent = this.config.startCallText;
1254
2003
  startBtn.disabled = true;
1255
- controls.appendChild(startBtn);
1256
- body.appendChild(controls);
2004
+ body.appendChild(startBtn);
1257
2005
  this.ensureRecaptchaSlot();
1258
2006
  }
1259
2007
  /**
1260
2008
  * Create the light-DOM node that hosts the reCAPTCHA checkbox and render the checkbox
1261
- * into it. The node is a child of the host element with `slot="recaptcha"`, so it is
1262
- * projected into the gate's <slot>. Idempotent: every widget re-render recreates the
1263
- * <slot> element, but this node (and its iframe) persists in the light DOM untouched,
1264
- * so the checkbox is rendered exactly once and re-projects automatically.
2009
+ * into it. Idempotent: every re-render recreates the <slot>, but this node (and its
2010
+ * iframe) persists in the light DOM untouched, so the checkbox renders exactly once.
1265
2011
  */
1266
2012
  ensureRecaptchaSlot() {
1267
2013
  const siteKey = this.config.recaptchaSiteKey;
@@ -1280,8 +2026,6 @@ var TrilletWidgetElement = class extends HTMLElement {
1280
2026
  this.removeRecaptchaSlot();
1281
2027
  this.render();
1282
2028
  },
1283
- // A solved checkbox expires after ~2 minutes. Google resets its own widget UI in
1284
- // place, and the slot is still showing, so the visitor can just re-tick it.
1285
2029
  onExpired: () => {
1286
2030
  this.recaptchaSolved = false;
1287
2031
  }
@@ -1312,111 +2056,136 @@ var TrilletWidgetElement = class extends HTMLElement {
1312
2056
  this.renderBothEntry(body);
1313
2057
  return body;
1314
2058
  }
1315
- if (this.resolvedMode() === "text") {
2059
+ if (this.resolvedMode() === "text" || this.config.mode === "both") {
1316
2060
  this.renderTextBody(body);
1317
2061
  } else {
1318
2062
  this.renderVoiceBody(body);
1319
2063
  }
1320
2064
  return body;
1321
2065
  }
1322
- /** Build the animated gradient orb (or avatar image) reflecting the current state. */
1323
- buildOrb() {
1324
- const orbWrap = document.createElement("div");
1325
- orbWrap.className = "tw-orb-wrap";
1326
- if (this.state === "connecting") orbWrap.classList.add("tw-connecting");
1327
- if (this.state === "live") orbWrap.classList.add("tw-listening");
1328
- if (this.state === "live" && this.speaking) orbWrap.classList.add("tw-speaking");
1329
- const orb = document.createElement("div");
1330
- orb.className = "tw-orb";
1331
- if (this.config.avatar) {
1332
- orb.classList.add("tw-orb-avatar");
1333
- orb.style.backgroundImage = `url("${this.config.avatar}")`;
1334
- }
1335
- orbWrap.appendChild(orb);
1336
- return orbWrap;
1337
- }
1338
- /** Pre-call panel for mode="both": orb + "Start a call" (voice) and "Message" (text). */
2066
+ /** Pre-call panel for mode="both": the visitor picks how to talk. */
1339
2067
  renderBothEntry(body) {
1340
- body.appendChild(this.buildOrb());
1341
- const controls = document.createElement("div");
1342
- controls.className = "tw-controls tw-controls-stack";
1343
- const callBtn = document.createElement("button");
1344
- callBtn.className = "tw-primary-btn";
1345
- callBtn.type = "button";
1346
- callBtn.textContent = this.config.startCallText;
1347
- callBtn.addEventListener("click", () => {
1348
- void this.beginCall("voice");
1349
- });
1350
- controls.appendChild(callBtn);
1351
- const msgBtn = document.createElement("button");
1352
- msgBtn.className = "tw-primary-btn tw-secondary";
1353
- msgBtn.type = "button";
1354
- msgBtn.textContent = this.config.messageText;
1355
- msgBtn.addEventListener("click", () => {
1356
- void this.beginCall("text");
1357
- });
1358
- controls.appendChild(msgBtn);
1359
- body.appendChild(controls);
2068
+ body.classList.add("tw-center-body");
2069
+ body.appendChild(this.buildAvatar("lg"));
2070
+ const prompt = document.createElement("p");
2071
+ prompt.className = "tw-prompt";
2072
+ prompt.textContent = this.config.greeting || this.config.copy.chooseModePrompt;
2073
+ body.appendChild(prompt);
2074
+ const choices = document.createElement("div");
2075
+ choices.className = "tw-choices";
2076
+ const choice = (icon, text, modality, primary) => {
2077
+ const btn = document.createElement("button");
2078
+ btn.type = "button";
2079
+ btn.className = primary ? "tw-primary-btn" : "tw-secondary-btn";
2080
+ btn.innerHTML = icon;
2081
+ const span = document.createElement("span");
2082
+ span.textContent = text;
2083
+ btn.appendChild(span);
2084
+ btn.addEventListener("click", () => {
2085
+ if (modality === "text") this.transcripts = [];
2086
+ void this.beginCall(modality);
2087
+ });
2088
+ return btn;
2089
+ };
2090
+ choices.appendChild(choice(ICONS.phone, this.config.startCallText, "voice", true));
2091
+ choices.appendChild(choice(ICONS.chat, this.config.messageText, "text", false));
2092
+ body.appendChild(choices);
1360
2093
  }
1361
- /** Voice UI: orb + spoken status + timer + mic/end controls. Never a text input. */
2094
+ /** Voice call: the agent's presence (ring follows their voice), status, controls. */
1362
2095
  renderVoiceBody(body) {
1363
- body.appendChild(this.buildOrb());
1364
- const status = document.createElement("div");
1365
- status.className = "tw-status";
1366
- status.textContent = this.statusText();
2096
+ var _a;
2097
+ body.classList.add("tw-center-body", "tw-voice-body");
2098
+ body.appendChild(this.buildAvatar("lg"));
2099
+ const status = document.createElement("p");
2100
+ status.className = "tw-prompt";
2101
+ if (this.state === "connecting") status.textContent = this.config.copy.connecting;
2102
+ else if (this.state === "live") status.textContent = this.speaking ? this.config.speakingText : this.config.listeningText;
2103
+ else if (this.state === "ended") status.textContent = (_a = this.errorText) != null ? _a : this.config.copy.callEnded;
2104
+ else status.textContent = this.config.actionText || this.config.copy.talkToUs;
2105
+ if (this.errorText && this.state !== "live") status.classList.add("tw-error-text");
1367
2106
  body.appendChild(status);
1368
2107
  const timer = document.createElement("div");
1369
2108
  timer.className = "tw-timer";
1370
2109
  timer.textContent = this.timerText();
1371
2110
  body.appendChild(timer);
1372
2111
  body.appendChild(this.renderControls());
1373
- const switchBtn = this.renderSwitchButton();
1374
- if (switchBtn) body.appendChild(switchBtn);
1375
2112
  }
1376
- /** Text/chat UI: conversation thread + message input. Never an orb or "listening" state. */
2113
+ /** Text/chat UI: conversation thread + message input. */
1377
2114
  renderTextBody(body) {
1378
- if (this.state === "idle" || this.state === "ended") {
1379
- if (this.state === "ended") {
1380
- const status = document.createElement("div");
1381
- status.className = "tw-status";
1382
- status.textContent = "Chat ended";
1383
- body.appendChild(status);
2115
+ var _a;
2116
+ body.classList.add("tw-chat-body");
2117
+ if (this.state === "idle" && this.transcripts.length === 0) {
2118
+ body.classList.add("tw-center-body");
2119
+ body.appendChild(this.buildAvatar("lg"));
2120
+ if (this.errorText) {
2121
+ const err = document.createElement("p");
2122
+ err.className = "tw-prompt tw-error-text";
2123
+ err.textContent = this.errorText;
2124
+ body.appendChild(err);
1384
2125
  }
1385
2126
  body.appendChild(this.renderControls());
1386
2127
  return;
1387
2128
  }
1388
- if (this.state === "connecting") {
1389
- const status = document.createElement("div");
1390
- status.className = "tw-status";
1391
- status.textContent = "Connecting\u2026";
1392
- body.appendChild(status);
1393
- }
1394
2129
  body.appendChild(this.renderTranscript());
1395
- if (this.state === "live") {
1396
- body.appendChild(this.renderTextInput());
2130
+ const suggestions = this.renderSuggestions();
2131
+ if (suggestions) body.appendChild(suggestions);
2132
+ if (this.state === "ended" || this.state === "idle") {
2133
+ const footer2 = document.createElement("div");
2134
+ footer2.className = "tw-chat-ended";
2135
+ const status = document.createElement("span");
2136
+ status.textContent = (_a = this.errorText) != null ? _a : this.config.copy.chatEnded;
2137
+ if (this.errorText) status.classList.add("tw-error-text");
2138
+ footer2.appendChild(status);
2139
+ const restart = document.createElement("button");
2140
+ restart.type = "button";
2141
+ restart.className = "tw-secondary-btn tw-small";
2142
+ restart.textContent = this.config.copy.startNewChat;
2143
+ restart.addEventListener("click", () => {
2144
+ this.transcripts = [];
2145
+ void this.beginCall("text");
2146
+ });
2147
+ footer2.appendChild(restart);
2148
+ body.appendChild(footer2);
2149
+ const feedback = this.renderFeedback();
2150
+ if (feedback) body.appendChild(feedback);
2151
+ return;
1397
2152
  }
2153
+ if (this.notice) {
2154
+ const notice = document.createElement("p");
2155
+ notice.className = "tw-notice";
2156
+ notice.setAttribute("role", "status");
2157
+ notice.textContent = this.notice;
2158
+ body.appendChild(notice);
2159
+ }
2160
+ const talking = this.config.mode === "both" && this.resolvedMode() === "voice";
2161
+ body.appendChild(talking ? this.renderVoiceBar(true) : this.renderTextInput());
2162
+ const footer = document.createElement("div");
2163
+ footer.className = "tw-chat-footer";
1398
2164
  const endBtn = document.createElement("button");
1399
- endBtn.className = "tw-primary-btn tw-danger";
2165
+ endBtn.className = "tw-link-btn tw-end-chat";
1400
2166
  endBtn.type = "button";
1401
- endBtn.textContent = this.config.endCallText;
2167
+ endBtn.textContent = this.config.mode === "text" ? this.config.endCallText : this.config.copy.endConversationText;
1402
2168
  endBtn.disabled = this.state === "connecting";
1403
2169
  endBtn.addEventListener("click", () => this.endConversation());
1404
- body.appendChild(endBtn);
1405
- const switchBtn = this.renderSwitchButton();
1406
- if (switchBtn) body.appendChild(switchBtn);
1407
- }
1408
- /** In mode="both" during a live session, a control to switch to the other modality. */
1409
- renderSwitchButton() {
1410
- if (this.config.mode !== "both" || this.state !== "live") return null;
1411
- const toText = this.resolvedMode() === "voice";
1412
- const btn = document.createElement("button");
1413
- btn.className = "tw-switch-btn";
1414
- btn.type = "button";
1415
- btn.textContent = toText ? this.config.switchToTextText : this.config.switchToVoiceText;
1416
- btn.addEventListener("click", () => {
1417
- void this.switchModality();
1418
- });
1419
- return btn;
2170
+ footer.appendChild(endBtn);
2171
+ body.appendChild(footer);
2172
+ }
2173
+ /** Starter questions, shown until the visitor has said something. */
2174
+ renderSuggestions() {
2175
+ const prompts = this.config.suggestedPrompts;
2176
+ const visitorHasSpoken = this.transcripts.some((t) => t.role === "user");
2177
+ if (!prompts.length || visitorHasSpoken || this.state === "ended") return null;
2178
+ const row = document.createElement("div");
2179
+ row.className = "tw-suggestions";
2180
+ for (const prompt of prompts) {
2181
+ const chip = document.createElement("button");
2182
+ chip.type = "button";
2183
+ chip.className = "tw-suggestion";
2184
+ chip.textContent = prompt;
2185
+ chip.addEventListener("click", () => void this.sendMessage(prompt));
2186
+ row.appendChild(chip);
2187
+ }
2188
+ return row;
1420
2189
  }
1421
2190
  renderControls() {
1422
2191
  const controls = document.createElement("div");
@@ -1425,91 +2194,278 @@ var TrilletWidgetElement = class extends HTMLElement {
1425
2194
  const startBtn = document.createElement("button");
1426
2195
  startBtn.className = "tw-primary-btn";
1427
2196
  startBtn.type = "button";
1428
- startBtn.textContent = this.config.startCallText;
2197
+ const isText = this.resolvedMode() === "text";
2198
+ startBtn.innerHTML = isText ? ICONS.chat : ICONS.phone;
2199
+ const span = document.createElement("span");
2200
+ span.textContent = isText ? this.config.copy.startChatText : this.config.startCallText;
2201
+ startBtn.appendChild(span);
1429
2202
  startBtn.addEventListener("click", () => {
1430
2203
  void this.beginCall();
1431
2204
  });
1432
2205
  controls.appendChild(startBtn);
1433
2206
  return controls;
1434
2207
  }
1435
- if (this.resolvedMode() === "voice" && this.state === "live") {
1436
- const micBtn = document.createElement("button");
1437
- micBtn.className = `tw-mic-btn${this.micEnabled ? "" : " tw-muted"}`;
1438
- micBtn.type = "button";
1439
- micBtn.title = this.micEnabled ? "Mute microphone" : "Unmute microphone";
1440
- micBtn.textContent = this.micEnabled ? "\u{1F399}" : "\u{1F507}";
1441
- micBtn.addEventListener("click", () => {
2208
+ if (this.resolvedMode() === "voice") {
2209
+ const micBtn = this.iconButton(
2210
+ this.micEnabled ? ICONS.mic : ICONS.micOff,
2211
+ this.micEnabled ? this.config.copy.muteMic : this.config.copy.unmuteMic,
2212
+ () => {
2213
+ var _a;
2214
+ this.micEnabled = !this.micEnabled;
2215
+ (_a = this.agent) == null ? void 0 : _a.toggleMicrophone(this.micEnabled);
2216
+ this.render();
2217
+ },
2218
+ `tw-round-btn${this.micEnabled ? "" : " tw-muted"}`
2219
+ );
2220
+ micBtn.disabled = this.state !== "live";
2221
+ controls.appendChild(micBtn);
2222
+ const endBtn = this.iconButton(ICONS.hangup, this.config.endCallText, () => this.endConversation(), "tw-round-btn tw-end-btn");
2223
+ endBtn.disabled = this.state === "connecting";
2224
+ controls.appendChild(endBtn);
2225
+ }
2226
+ return controls;
2227
+ }
2228
+ /**
2229
+ * The call bar. Resting (floating) it replaces the ask bar during a call; inside the
2230
+ * chat panel it replaces the composer on the voice side of a type-or-talk chat.
2231
+ *
2232
+ * ||||| Speaking (mic) (💬 / ⌨) (end)
2233
+ * Firelink · 0:42
2234
+ */
2235
+ renderVoiceBar(inPanel) {
2236
+ const bar = document.createElement("div");
2237
+ bar.className = inPanel ? "tw-callbar tw-callbar-inline" : "tw-callbar";
2238
+ const connecting = this.state === "connecting";
2239
+ bar.appendChild(this.buildWave());
2240
+ const text = document.createElement("div");
2241
+ text.className = "tw-callbar-text";
2242
+ const activity = document.createElement("div");
2243
+ activity.className = "tw-callbar-activity";
2244
+ activity.textContent = connecting ? this.config.copy.connecting : this.speaking ? this.config.speakingText : this.config.listeningText;
2245
+ const meta = document.createElement("div");
2246
+ meta.className = "tw-callbar-meta tw-timer";
2247
+ const name = this.speakerName();
2248
+ meta.textContent = [name, this.timerText()].filter(Boolean).join(" \xB7 ");
2249
+ text.appendChild(activity);
2250
+ text.appendChild(meta);
2251
+ bar.appendChild(text);
2252
+ const mute = this.iconButton(
2253
+ this.micEnabled ? ICONS.mic : ICONS.micOff,
2254
+ this.micEnabled ? this.config.copy.muteMic : this.config.copy.unmuteMic,
2255
+ () => {
1442
2256
  var _a;
1443
2257
  this.micEnabled = !this.micEnabled;
1444
2258
  (_a = this.agent) == null ? void 0 : _a.toggleMicrophone(this.micEnabled);
1445
2259
  this.render();
1446
- });
1447
- controls.appendChild(micBtn);
2260
+ },
2261
+ `tw-sq tw-sq-quiet${this.micEnabled ? "" : " tw-muted"}`
2262
+ );
2263
+ mute.disabled = connecting;
2264
+ bar.appendChild(mute);
2265
+ if (inPanel) {
2266
+ const back = this.iconButton(ICONS.keyboard, this.config.copy.typeInstead, () => void this.switchModality(), "tw-sq tw-sq-quiet");
2267
+ back.disabled = this.switchingSide || connecting;
2268
+ bar.appendChild(back);
2269
+ } else if (this.config.mode === "both") {
2270
+ bar.appendChild(
2271
+ this.iconButton(ICONS.chat, this.config.copy.showConversation, () => {
2272
+ this.open = true;
2273
+ this.render();
2274
+ }, "tw-sq tw-sq-quiet")
2275
+ );
1448
2276
  }
1449
- const endBtn = document.createElement("button");
1450
- endBtn.className = "tw-primary-btn tw-danger";
1451
- endBtn.type = "button";
1452
- endBtn.textContent = this.config.endCallText;
1453
- endBtn.disabled = this.state === "connecting";
1454
- endBtn.addEventListener("click", () => this.endConversation());
1455
- controls.appendChild(endBtn);
1456
- return controls;
2277
+ const end = this.iconButton(ICONS.hangup, this.config.endCallText, () => this.endConversation(), "tw-sq tw-sq-danger");
2278
+ bar.appendChild(end);
2279
+ return bar;
1457
2280
  }
1458
2281
  renderTextInput() {
1459
- const row = document.createElement("div");
1460
- row.className = "tw-text-input-row";
1461
- const input = document.createElement("input");
2282
+ const row = document.createElement("form");
2283
+ row.className = "tw-composer";
2284
+ const input = document.createElement("textarea");
1462
2285
  input.className = "tw-text-input";
1463
- input.type = "text";
1464
- input.placeholder = "Type a message\u2026";
2286
+ input.rows = 1;
2287
+ input.placeholder = this.config.inputPlaceholder;
2288
+ input.value = this.draft;
2289
+ input.setAttribute("aria-label", this.config.inputPlaceholder);
2290
+ const sendBtn = document.createElement("button");
2291
+ sendBtn.className = "tw-send-btn";
2292
+ sendBtn.type = "submit";
2293
+ sendBtn.setAttribute("aria-label", this.config.copy.send);
2294
+ sendBtn.innerHTML = ICONS.send;
2295
+ const syncState = () => {
2296
+ sendBtn.disabled = this.state !== "live" || !input.value.trim();
2297
+ input.style.height = "auto";
2298
+ input.style.height = `${Math.min(input.scrollHeight, 112)}px`;
2299
+ };
1465
2300
  const send = () => {
1466
2301
  var _a;
1467
2302
  const text = input.value.trim();
1468
- if (!text) return;
1469
- void ((_a = this.agent) == null ? void 0 : _a.sendTextMessage(text));
2303
+ if (!text || this.state !== "live") return;
2304
+ this.draft = "";
1470
2305
  input.value = "";
2306
+ syncState();
2307
+ void ((_a = this.agent) == null ? void 0 : _a.sendTextMessage(text));
1471
2308
  };
2309
+ input.addEventListener("input", () => {
2310
+ this.draft = input.value;
2311
+ syncState();
2312
+ });
1472
2313
  input.addEventListener("keydown", (e) => {
1473
- if (e.key === "Enter") send();
2314
+ if (e.key === "Enter" && !e.shiftKey && !e.isComposing) {
2315
+ e.preventDefault();
2316
+ send();
2317
+ }
2318
+ });
2319
+ row.addEventListener("submit", (e) => {
2320
+ e.preventDefault();
2321
+ send();
1474
2322
  });
1475
- const sendBtn = document.createElement("button");
1476
- sendBtn.className = "tw-send-btn";
1477
- sendBtn.type = "button";
1478
- sendBtn.textContent = "Send";
1479
- sendBtn.addEventListener("click", send);
1480
2323
  row.appendChild(input);
2324
+ if (this.config.mode === "both") {
2325
+ const mic = this.iconButton(ICONS.phone, this.config.copy.talkInstead, () => void this.switchModality(), "tw-composer-mic");
2326
+ mic.disabled = this.state !== "live" || this.switchingSide;
2327
+ row.appendChild(mic);
2328
+ }
1481
2329
  row.appendChild(sendBtn);
2330
+ requestAnimationFrame(syncState);
2331
+ if (this.state === "live") requestAnimationFrame(() => input.focus({ preventScroll: true }));
1482
2332
  return row;
1483
2333
  }
1484
- /**
1485
- * The chat thread for text mode. This is a fixed-height, internally scrolling
1486
- * window (like a normal website chatbot): the container is rendered at its full
1487
- * height as soon as the chat opens — empty until messages arrive — and messages
1488
- * accumulate + scroll inside it, so the panel's overall height stays stable.
1489
- * Auto-scrolls to the newest message after each render.
1490
- */
1491
- renderTranscript() {
1492
- const wrap = document.createElement("div");
1493
- wrap.className = "tw-transcript tw-chat";
1494
- if (this.transcripts.length === 0) {
1495
- const empty = document.createElement("div");
1496
- empty.className = "tw-chat-empty";
1497
- empty.textContent = this.state === "connecting" ? "" : "\u2026";
1498
- wrap.appendChild(empty);
1499
- } else {
1500
- for (const t of this.transcripts) {
1501
- const msg = document.createElement("div");
1502
- msg.className = `tw-msg ${t.role === "user" ? "tw-user" : "tw-assistant"}`;
2334
+ /** The agent's reply as it streams in (not yet final), if any. */
2335
+ streamingReply() {
2336
+ var _a, _b;
2337
+ const partials = (_b = (_a = this.agent) == null ? void 0 : _a.getCurrentTranscript()) != null ? _b : {};
2338
+ return Object.entries(partials).filter(([identity]) => identity.startsWith("agent")).map(([, text]) => text).join(" ").trim();
2339
+ }
2340
+ /** Fill a chat thread element with the current messages. */
2341
+ fillThread(wrap) {
2342
+ wrap.replaceChildren();
2343
+ let previousRole = null;
2344
+ for (const t of this.transcripts) {
2345
+ if (t.toolUsed) continue;
2346
+ const msg = document.createElement("div");
2347
+ msg.className = `tw-msg ${t.role === "user" ? "tw-user" : "tw-assistant"}`;
2348
+ if (previousRole === t.role) msg.classList.add("tw-run");
2349
+ previousRole = t.role;
2350
+ if (t.role === "user") {
1503
2351
  msg.textContent = t.text;
1504
- wrap.appendChild(msg);
2352
+ } else {
2353
+ if (!msg.classList.contains("tw-run") && this.speakerName()) {
2354
+ const who = document.createElement("div");
2355
+ who.className = "tw-msg-label";
2356
+ who.textContent = this.speakerName();
2357
+ msg.appendChild(who);
2358
+ }
2359
+ const body = document.createElement("div");
2360
+ body.className = "tw-md";
2361
+ body.appendChild(renderMarkdown(t.text));
2362
+ msg.appendChild(body);
2363
+ }
2364
+ wrap.appendChild(msg);
2365
+ }
2366
+ const streaming = this.streamingReply();
2367
+ if (streaming) {
2368
+ const msg = document.createElement("div");
2369
+ msg.className = "tw-msg tw-assistant tw-streaming";
2370
+ if (previousRole === "assistant") msg.classList.add("tw-run");
2371
+ else if (this.speakerName()) {
2372
+ const who = document.createElement("div");
2373
+ who.className = "tw-msg-label";
2374
+ who.textContent = this.speakerName();
2375
+ msg.appendChild(who);
1505
2376
  }
2377
+ const body = document.createElement("div");
2378
+ body.className = "tw-md";
2379
+ body.appendChild(renderMarkdown(streaming));
2380
+ msg.appendChild(body);
2381
+ wrap.appendChild(msg);
2382
+ } else if (this.isAwaitingReply()) {
2383
+ const typing = document.createElement("div");
2384
+ typing.className = "tw-msg tw-assistant tw-typing";
2385
+ typing.setAttribute("aria-label", this.config.copy.typing);
2386
+ typing.innerHTML = "<span></span><span></span><span></span>";
2387
+ wrap.appendChild(typing);
1506
2388
  }
1507
2389
  requestAnimationFrame(() => {
1508
2390
  wrap.scrollTop = wrap.scrollHeight;
1509
2391
  });
2392
+ }
2393
+ /** Connecting, or the visitor spoke last and the agent hasn't started answering. */
2394
+ isAwaitingReply() {
2395
+ if (this.state === "connecting" || this.pendingMessage) return true;
2396
+ if (this.state !== "live") return false;
2397
+ const last = [...this.transcripts].reverse().find((t) => !t.toolUsed);
2398
+ return (last == null ? void 0 : last.role) === "user";
2399
+ }
2400
+ /**
2401
+ * Patch just the chat thread (and starter questions) in place. Returns false when
2402
+ * there is no text thread on screen, in which case the caller does a full render.
2403
+ */
2404
+ updateThread() {
2405
+ if (!this.open) return false;
2406
+ const thread = this.root.querySelector(".tw-chat");
2407
+ if (!thread) return false;
2408
+ this.fillThread(thread);
2409
+ const existing = this.root.querySelector(".tw-suggestions");
2410
+ const next = this.renderSuggestions();
2411
+ if (existing && !next) existing.remove();
2412
+ const status = this.root.querySelector(".tw-status");
2413
+ if (status) status.textContent = this.statusText();
2414
+ return true;
2415
+ }
2416
+ /** The chat thread: a fixed-height window that scrolls internally. */
2417
+ renderTranscript() {
2418
+ const wrap = document.createElement("div");
2419
+ wrap.className = "tw-chat";
2420
+ wrap.setAttribute("role", "log");
2421
+ wrap.setAttribute("aria-live", "polite");
2422
+ this.fillThread(wrap);
1510
2423
  return wrap;
1511
2424
  }
1512
2425
  };
2426
+ function friendlyError(err, copy) {
2427
+ const msg = err.message || "";
2428
+ if (/Origin not allowed/i.test(msg)) return copy.errorNotEnabled;
2429
+ if (/Public access/i.test(msg)) return copy.errorUnavailable;
2430
+ if (/Too many/i.test(msg)) return copy.errorTooMany;
2431
+ if (/Insufficient funds/i.test(msg)) return copy.errorUnavailable;
2432
+ return copy.errorGeneric;
2433
+ }
2434
+ var DEFAULT_ACCENT = "#0062e9";
2435
+ function readableOn(hex) {
2436
+ const m = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
2437
+ if (!m) return "#ffffff";
2438
+ const full = m[1].length === 3 ? m[1].split("").map((c) => c + c).join("") : m[1];
2439
+ const channel = (i) => {
2440
+ const v = parseInt(full.slice(i, i + 2), 16) / 255;
2441
+ return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
2442
+ };
2443
+ const lum = 0.2126 * channel(0) + 0.7152 * channel(2) + 0.0722 * channel(4);
2444
+ const contrastWhite = 1.05 / (lum + 0.05);
2445
+ const contrastInk = (lum + 0.05) / 0.06;
2446
+ return contrastWhite >= contrastInk ? "#ffffff" : "#16181d";
2447
+ }
2448
+ function initials(name) {
2449
+ const words = name.trim().split(/\s+/).filter((w) => /[a-z0-9]/i.test(w));
2450
+ if (!words.length) return "";
2451
+ const letters = words.length === 1 ? words[0].slice(0, 1) : words[0][0] + words[1][0];
2452
+ return letters.toUpperCase();
2453
+ }
2454
+ var svg = (body) => `<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${body}</svg>`;
2455
+ var ICONS = {
2456
+ chat: svg('<path d="M20 12.5a7.5 7.5 0 0 1-11.2 6.5L4 20l1.1-4.3A7.5 7.5 0 1 1 20 12.5Z"/>'),
2457
+ phone: svg('<path d="M5 4h3l1.6 4-2 1.3a11 11 0 0 0 5.1 5.1l1.3-2 4 1.6v3a2 2 0 0 1-2.2 2A16 16 0 0 1 3 6.2 2 2 0 0 1 5 4Z"/>'),
2458
+ hangup: svg('<path d="M3.5 13.5c4.7-4 12.3-4 17 0l-1.6 2.6-3.4-1.2v-2.5a10 10 0 0 0-7 0v2.5l-3.4 1.2Z"/>'),
2459
+ mic: svg('<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21"/>'),
2460
+ micOff: svg('<path d="M15 10V6a3 3 0 0 0-5.7-1.3M9 9v2a3 3 0 0 0 4.6 2.5M5.5 11a6.5 6.5 0 0 0 10.4 5.2M18.5 11a6.4 6.4 0 0 1-.6 2.6M12 17.5V21M4 4l16 16"/>'),
2461
+ send: svg('<path d="M12 19V5M5.5 11.5 12 5l6.5 6.5"/>'),
2462
+ minimize: svg('<path d="m6 9 6 6 6-6"/>'),
2463
+ thumbUp: svg('<path d="M7 11v9H4v-9h3Zm0 0 4-7a2 2 0 0 1 2 2v3h5a2 2 0 0 1 2 2.3l-1.2 6A2 2 0 0 1 16.8 19H7"/>'),
2464
+ thumbDown: svg('<path d="M17 13V4h3v9h-3Zm0 0-4 7a2 2 0 0 1-2-2v-3H6a2 2 0 0 1-2-2.3l1.2-6A2 2 0 0 1 7.2 5H17"/>'),
2465
+ keyboard: svg('<rect x="3" y="6" width="18" height="12" rx="2"/><path d="M7 10h.01M11 10h.01M15 10h.01M7 14h10"/>'),
2466
+ close: svg('<path d="M6 6l12 12M18 6 6 18"/>'),
2467
+ spinner: svg('<path d="M12 3a9 9 0 1 0 9 9" class="tw-spin"/>')
2468
+ };
1513
2469
 
1514
2470
  // src/widget/register.ts
1515
2471
  var TRILLET_WIDGET_TAG = "trillet-widget";
@@ -1557,6 +2513,8 @@ var TrilletWidget = (props) => {
1557
2513
  setAttr(el, "action-text", props.actionText);
1558
2514
  setAttr(el, "start-call-text", props.startCallText);
1559
2515
  setAttr(el, "end-call-text", props.endCallText);
2516
+ setAttr(el, "end-chat-text", props.endChatText);
2517
+ setAttr(el, "language", props.language);
1560
2518
  setAttr(el, "message-text", props.messageText);
1561
2519
  setAttr(el, "switch-to-text-text", props.switchToTextText);
1562
2520
  setAttr(el, "switch-to-voice-text", props.switchToVoiceText);
@@ -1565,6 +2523,16 @@ var TrilletWidget = (props) => {
1565
2523
  setAttr(el, "expand-text", props.expandText);
1566
2524
  setAttr(el, "collapse-text", props.collapseText);
1567
2525
  setAttr(el, "mode", props.mode);
2526
+ setAttr(el, "api-base", props.apiBase);
2527
+ setAttr(el, "remote-config", props.remoteConfig === false ? "false" : void 0);
2528
+ setAttr(el, "greeting", props.greeting);
2529
+ setAttr(el, "input-placeholder", props.inputPlaceholder);
2530
+ setAttr(
2531
+ el,
2532
+ "suggested-prompts",
2533
+ props.suggestedPrompts ? JSON.stringify(props.suggestedPrompts) : void 0
2534
+ );
2535
+ setAttr(el, "theme", props.theme);
1568
2536
  const vars = (_b = props.variables) != null ? _b : props.dynamicVariables;
1569
2537
  setAttr(el, "variables", vars ? JSON.stringify(vars) : void 0);
1570
2538
  setAttr(el, "max-call-duration", props.maxCallDuration);