@nightzeros/chatai-widget 1.3.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,8 +2,14 @@
2
2
  import { render } from "preact";
3
3
 
4
4
  // src/app.tsx
5
- import { useEffect as useEffect2, useMemo, useRef as useRef2, useState } from "preact/hooks";
6
- import { createWidgetController, isVoiceActive as isVoiceActive2 } from "@nightzeros/chatai-widget-core";
5
+ import { useEffect as useEffect5, useMemo, useRef as useRef5, useState } from "preact/hooks";
6
+ import {
7
+ createWidgetController,
8
+ isVoiceActive as isVoiceActive4,
9
+ mergeVoiceAppearance,
10
+ parseVoiceAppearance,
11
+ resolveVoiceAppearance
12
+ } from "@nightzeros/chatai-widget-core";
7
13
 
8
14
  // src/markdown-message.tsx
9
15
  import { jsx, jsxs } from "preact/jsx-runtime";
@@ -182,6 +188,9 @@ function MarkdownMessage({
182
188
  ] });
183
189
  }
184
190
 
191
+ // src/voice/voice-dock.tsx
192
+ import { useEffect as useEffect4, useRef as useRef4 } from "preact/hooks";
193
+
185
194
  // src/voice-ui.tsx
186
195
  import { useEffect, useRef } from "preact/hooks";
187
196
  import {
@@ -311,9 +320,796 @@ function VoiceBar({
311
320
  ] });
312
321
  }
313
322
 
314
- // src/app.tsx
323
+ // src/voice/voice-captions.tsx
315
324
  import { jsx as jsx3, jsxs as jsxs3 } from "preact/jsx-runtime";
325
+ function VoiceCaptions({
326
+ messages,
327
+ open
328
+ }) {
329
+ if (!open) return null;
330
+ const turns = messages.filter((message) => message.modality === "voice");
331
+ if (turns.length === 0) {
332
+ return /* @__PURE__ */ jsx3("div", { className: "chatai-voice-captions is-empty", "aria-live": "polite", children: /* @__PURE__ */ jsx3("p", { children: "Captions appear as you talk." }) });
333
+ }
334
+ const recent = turns.slice(-6);
335
+ return /* @__PURE__ */ jsx3("div", { className: "chatai-voice-captions", "aria-live": "polite", children: recent.map((message, index) => /* @__PURE__ */ jsxs3(
336
+ "p",
337
+ {
338
+ className: `chatai-voice-caption ${message.role}${message.live ? " is-live" : ""}`,
339
+ children: [
340
+ /* @__PURE__ */ jsx3("span", { className: "chatai-voice-caption-who", children: message.role === "user" ? "You" : "Assistant" }),
341
+ /* @__PURE__ */ jsx3("span", { className: "chatai-voice-caption-text", children: message.content || "\u2026" }),
342
+ message.interrupted ? /* @__PURE__ */ jsx3("span", { className: "chatai-voice-caption-note", children: "Interrupted" }) : null
343
+ ]
344
+ },
345
+ `${message.role}-${index}-${message.content.slice(0, 24)}`
346
+ )) });
347
+ }
348
+
349
+ // src/voice/voice-companion.tsx
350
+ import { useEffect as useEffect2, useRef as useRef2 } from "preact/hooks";
351
+ import { jsx as jsx4, jsxs as jsxs4 } from "preact/jsx-runtime";
352
+ function prefersReducedMotion2() {
353
+ return typeof window !== "undefined" && Boolean(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches);
354
+ }
355
+ function clearCompanionVars(el) {
356
+ el.style.removeProperty("--chatai-companion-energy");
357
+ el.style.removeProperty("--chatai-companion-mouth");
358
+ el.style.removeProperty("--chatai-companion-blink");
359
+ el.style.removeProperty("--chatai-companion-peak");
360
+ }
361
+ function VoiceCompanionCharacter({
362
+ motion,
363
+ levels,
364
+ reducedMotion
365
+ }) {
366
+ const ref = useRef2(null);
367
+ const motionRef = useRef2(motion);
368
+ motionRef.current = motion;
369
+ useEffect2(() => {
370
+ const el = ref.current;
371
+ if (!el) return;
372
+ const reduced = reducedMotion || prefersReducedMotion2();
373
+ if (reduced || typeof requestAnimationFrame === "undefined") {
374
+ clearCompanionVars(el);
375
+ return;
376
+ }
377
+ let frame = 0;
378
+ let smoothed = 0;
379
+ let peak = 0;
380
+ let blink = 0;
381
+ let blinkUntil = 0;
382
+ let nextBlinkAt = performance.now() + 2800 + Math.random() * 2200;
383
+ const draw = (now) => {
384
+ const current = motionRef.current;
385
+ let target = 0;
386
+ let mouth = 0;
387
+ if (current === "hearing") {
388
+ target = Math.min(1, levels().input * 8);
389
+ mouth = 0.08 + target * 0.18;
390
+ } else if (current === "speaking") {
391
+ target = Math.min(1, levels().output * 8);
392
+ const flutter = 0.55 + 0.45 * Math.sin(now / 55);
393
+ mouth = Math.min(1, 0.22 + target * 0.78 * flutter);
394
+ } else if (current === "processing" || current === "pending") {
395
+ target = 0.28 + 0.08 * Math.sin(now / 520);
396
+ mouth = 0.04;
397
+ } else if (current === "listening") {
398
+ target = 0.1 + 0.04 * Math.sin(now / 900);
399
+ mouth = 0;
400
+ } else if (current === "settle") {
401
+ target = 0.06;
402
+ mouth = 0;
403
+ }
404
+ smoothed += (target - smoothed) * 0.22;
405
+ const instantPeak = Math.max(0, target - smoothed);
406
+ peak += (instantPeak - peak) * 0.35;
407
+ const canBlink = current === "listening" || current === "hearing" || current === "speaking" || current === "processing" || current === "pending";
408
+ if (canBlink) {
409
+ if (blink > 0 && now >= blinkUntil) {
410
+ blink = 0;
411
+ nextBlinkAt = now + 2800 + Math.random() * 3200;
412
+ } else if (blink === 0 && now >= nextBlinkAt) {
413
+ blink = 1;
414
+ blinkUntil = now + 110 + Math.random() * 50;
415
+ }
416
+ } else {
417
+ blink = 0;
418
+ nextBlinkAt = now + 3e3;
419
+ }
420
+ el.style.setProperty("--chatai-companion-energy", smoothed.toFixed(3));
421
+ el.style.setProperty("--chatai-companion-mouth", mouth.toFixed(3));
422
+ el.style.setProperty("--chatai-companion-blink", blink.toFixed(3));
423
+ el.style.setProperty("--chatai-companion-peak", Math.min(1, peak * 4).toFixed(3));
424
+ frame = requestAnimationFrame(draw);
425
+ };
426
+ frame = requestAnimationFrame(draw);
427
+ return () => {
428
+ cancelAnimationFrame(frame);
429
+ clearCompanionVars(el);
430
+ };
431
+ }, [levels, reducedMotion]);
432
+ return /* @__PURE__ */ jsxs4(
433
+ "div",
434
+ {
435
+ ref,
436
+ className: "chatai-companion-character",
437
+ "data-motion": motion,
438
+ "aria-hidden": "true",
439
+ children: [
440
+ /* @__PURE__ */ jsx4("span", { className: "chatai-companion-body" }),
441
+ /* @__PURE__ */ jsx4("span", { className: "chatai-companion-eye chatai-companion-eye-left" }),
442
+ /* @__PURE__ */ jsx4("span", { className: "chatai-companion-eye chatai-companion-eye-right" }),
443
+ /* @__PURE__ */ jsx4("span", { className: "chatai-companion-mouth" }),
444
+ /* @__PURE__ */ jsx4("span", { className: "chatai-companion-foot chatai-companion-foot-left" }),
445
+ /* @__PURE__ */ jsx4("span", { className: "chatai-companion-foot chatai-companion-foot-right" })
446
+ ]
447
+ }
448
+ );
449
+ }
450
+ function VoiceCompanionCanvas({
451
+ assistantName,
452
+ welcomeMessage,
453
+ voiceOffered,
454
+ onStart
455
+ }) {
456
+ const speech = welcomeMessage?.trim() || `Hi \u2014 I\u2019m ${assistantName}. Ready when you are.`;
457
+ return /* @__PURE__ */ jsxs4("div", { className: "chatai-companion", children: [
458
+ /* @__PURE__ */ jsx4("p", { className: "chatai-companion-kicker", children: "Live companion" }),
459
+ /* @__PURE__ */ jsx4("h3", { className: "chatai-companion-title", children: assistantName }),
460
+ /* @__PURE__ */ jsx4("p", { className: "chatai-companion-speech", "aria-live": "polite", children: speech }),
461
+ /* @__PURE__ */ jsx4(
462
+ VoiceCompanionCharacter,
463
+ {
464
+ motion: "static",
465
+ levels: () => ({ input: 0, output: 0 }),
466
+ reducedMotion: true
467
+ }
468
+ ),
469
+ voiceOffered ? /* @__PURE__ */ jsx4(
470
+ "button",
471
+ {
472
+ type: "button",
473
+ className: "chatai-voice-primary chatai-companion-start",
474
+ onClick: onStart,
475
+ children: "Start conversation"
476
+ }
477
+ ) : null,
478
+ /* @__PURE__ */ jsx4("p", { className: "chatai-companion-hint", children: "Stylized companion \xB7 tap Start to talk" })
479
+ ] });
480
+ }
481
+
482
+ // src/voice/voice-controls.tsx
483
+ import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "preact/jsx-runtime";
484
+ function VoiceControls({
485
+ presentation,
486
+ captionsOpen,
487
+ onStart,
488
+ onEnd,
489
+ onMute,
490
+ onToggleCaptions,
491
+ onRetry,
492
+ onDismiss
493
+ }) {
494
+ const { canStart, canEnd, canMute, canToggleCaptions, canRetry, canDismiss, microphoneMuted } = presentation;
495
+ const startAgain = Boolean(presentation.notice || presentation.status === "Voice ended");
496
+ return /* @__PURE__ */ jsxs5("div", { className: "chatai-voice-controls", children: [
497
+ canStart ? /* @__PURE__ */ jsx5(
498
+ "button",
499
+ {
500
+ type: "button",
501
+ className: "chatai-voice-primary",
502
+ onClick: onStart,
503
+ "aria-label": startAgain ? "Start again" : "Start conversation",
504
+ children: startAgain ? "Start again" : /* @__PURE__ */ jsxs5(Fragment2, { children: [
505
+ /* @__PURE__ */ jsx5("span", { className: "chatai-voice-label-long", children: "Start conversation" }),
506
+ /* @__PURE__ */ jsx5("span", { className: "chatai-voice-label-short", children: "Start" })
507
+ ] })
508
+ }
509
+ ) : null,
510
+ canEnd ? /* @__PURE__ */ jsx5("button", { type: "button", className: "chatai-voice-danger", onClick: onEnd, "aria-label": "End voice", children: "End" }) : null,
511
+ canMute ? /* @__PURE__ */ jsxs5(
512
+ "button",
513
+ {
514
+ type: "button",
515
+ className: `chatai-voice-secondary${microphoneMuted ? " is-pressed" : ""}`,
516
+ onClick: () => onMute(!microphoneMuted),
517
+ "aria-pressed": microphoneMuted,
518
+ "aria-label": microphoneMuted ? "Unmute microphone" : "Mute microphone",
519
+ children: [
520
+ /* @__PURE__ */ jsx5(MicGlyph, { off: microphoneMuted }),
521
+ /* @__PURE__ */ jsx5("span", { children: microphoneMuted ? "Unmute" : "Mute" })
522
+ ]
523
+ }
524
+ ) : null,
525
+ canToggleCaptions ? /* @__PURE__ */ jsxs5(
526
+ "button",
527
+ {
528
+ type: "button",
529
+ className: `chatai-voice-secondary${captionsOpen ? " is-pressed" : ""}`,
530
+ onClick: onToggleCaptions,
531
+ "aria-pressed": captionsOpen,
532
+ "aria-label": captionsOpen ? "Hide captions" : "Show captions",
533
+ children: [
534
+ /* @__PURE__ */ jsx5("span", { className: "chatai-voice-label-long", children: "Captions" }),
535
+ /* @__PURE__ */ jsx5("span", { className: "chatai-voice-label-short", children: "CC" })
536
+ ]
537
+ }
538
+ ) : null,
539
+ canRetry ? /* @__PURE__ */ jsx5("button", { type: "button", className: "chatai-voice-primary", onClick: onRetry, children: "Try again" }) : null,
540
+ canDismiss ? /* @__PURE__ */ jsx5("button", { type: "button", className: "chatai-voice-secondary", onClick: onDismiss, children: presentation.consentPending ? "Cancel" : /* @__PURE__ */ jsxs5(Fragment2, { children: [
541
+ /* @__PURE__ */ jsx5("span", { className: "chatai-voice-label-long", children: "Back to chat" }),
542
+ /* @__PURE__ */ jsx5("span", { className: "chatai-voice-label-short", children: "Chat" })
543
+ ] }) }) : null
544
+ ] });
545
+ }
546
+
547
+ // src/voice/voice-orb.tsx
548
+ import { useEffect as useEffect3, useRef as useRef3 } from "preact/hooks";
549
+ import { jsx as jsx6, jsxs as jsxs6 } from "preact/jsx-runtime";
550
+ function prefersReducedMotion3() {
551
+ return typeof window !== "undefined" && Boolean(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches);
552
+ }
553
+ function VoiceOrb({
554
+ motion,
555
+ levels,
556
+ reducedMotion
557
+ }) {
558
+ const ref = useRef3(null);
559
+ const motionRef = useRef3(motion);
560
+ motionRef.current = motion;
561
+ useEffect3(() => {
562
+ const el = ref.current;
563
+ if (!el) return;
564
+ const reduced = reducedMotion || prefersReducedMotion3();
565
+ if (reduced || typeof requestAnimationFrame === "undefined") {
566
+ el.style.removeProperty("--chatai-orb-energy");
567
+ return;
568
+ }
569
+ let frame = 0;
570
+ const draw = () => {
571
+ const current = motionRef.current;
572
+ let energy = 0;
573
+ if (current === "hearing") {
574
+ energy = Math.min(1, levels().input * 8);
575
+ } else if (current === "speaking") {
576
+ energy = Math.min(1, levels().output * 8);
577
+ } else if (current === "processing" || current === "pending") {
578
+ energy = 0.35;
579
+ } else if (current === "listening") {
580
+ energy = 0.12;
581
+ }
582
+ el.style.setProperty("--chatai-orb-energy", energy.toFixed(3));
583
+ frame = requestAnimationFrame(draw);
584
+ };
585
+ frame = requestAnimationFrame(draw);
586
+ return () => {
587
+ cancelAnimationFrame(frame);
588
+ el.style.removeProperty("--chatai-orb-energy");
589
+ };
590
+ }, [levels, reducedMotion]);
591
+ return /* @__PURE__ */ jsxs6(
592
+ "div",
593
+ {
594
+ ref,
595
+ className: "chatai-orb",
596
+ "data-motion": motion,
597
+ "aria-hidden": "true",
598
+ children: [
599
+ /* @__PURE__ */ jsx6("span", { className: "chatai-orb-core" }),
600
+ /* @__PURE__ */ jsx6("span", { className: "chatai-orb-shine" }),
601
+ /* @__PURE__ */ jsx6("span", { className: "chatai-orb-shadow" })
602
+ ]
603
+ }
604
+ );
605
+ }
606
+
607
+ // src/voice/voice-presentation.ts
608
+ import {
609
+ isVoiceActive as isVoiceActive2
610
+ } from "@nightzeros/chatai-widget-core";
611
+ function voiceMeta2(voice) {
612
+ if (voice.mock) return "Test mode \xB7 no audio";
613
+ if (voice.ephemeral) return "Not saved";
614
+ const parts = [
615
+ voice.recording ? "Recording" : "",
616
+ voice.transcriptSaved === false ? "Voice transcript not saved" : ""
617
+ ];
618
+ return parts.filter(Boolean).join(" \xB7 ");
619
+ }
620
+ function voiceStageVisible(voice) {
621
+ if (voice.consentPending) return true;
622
+ if (isVoiceActive2(voice.connection)) return true;
623
+ if (voice.connection === "failed") return true;
624
+ if (voice.connection === "ended") return true;
625
+ return false;
626
+ }
627
+ function presentVoice(voice) {
628
+ const active = isVoiceActive2(voice.connection);
629
+ const failed = voice.connection === "failed";
630
+ const ended = voice.connection === "ended";
631
+ const consentPending = Boolean(voice.consentPending);
632
+ const microphoneMuted = Boolean(voice.microphoneMuted);
633
+ const meta = voiceMeta2(voice);
634
+ if (consentPending) {
635
+ return {
636
+ status: "This voice conversation is recorded",
637
+ motion: "static",
638
+ canStart: false,
639
+ canEnd: false,
640
+ canMute: false,
641
+ canToggleCaptions: false,
642
+ canRetry: false,
643
+ canDismiss: true,
644
+ meta,
645
+ microphoneMuted: false,
646
+ consentPending: true
647
+ };
648
+ }
649
+ if (failed) {
650
+ return {
651
+ status: "Voice stopped",
652
+ motion: "static",
653
+ canStart: false,
654
+ canEnd: false,
655
+ canMute: false,
656
+ canToggleCaptions: false,
657
+ canRetry: voice.error?.code !== "unsupported",
658
+ canDismiss: true,
659
+ errorMessage: voice.error?.message,
660
+ meta,
661
+ microphoneMuted: false,
662
+ consentPending: false
663
+ };
664
+ }
665
+ if (ended) {
666
+ return {
667
+ status: "Voice ended",
668
+ motion: "static",
669
+ canStart: true,
670
+ canEnd: false,
671
+ canMute: false,
672
+ canToggleCaptions: true,
673
+ canRetry: false,
674
+ canDismiss: true,
675
+ notice: voice.notice,
676
+ meta,
677
+ microphoneMuted: false,
678
+ consentPending: false
679
+ };
680
+ }
681
+ if (!active) {
682
+ return {
683
+ status: "Ready when you are",
684
+ motion: "static",
685
+ canStart: true,
686
+ canEnd: false,
687
+ canMute: false,
688
+ canToggleCaptions: true,
689
+ canRetry: false,
690
+ canDismiss: true,
691
+ meta,
692
+ microphoneMuted: false,
693
+ consentPending: false
694
+ };
695
+ }
696
+ let status;
697
+ let motion;
698
+ switch (voice.phase) {
699
+ case "requesting_mic":
700
+ status = "Allow microphone access";
701
+ motion = "static";
702
+ break;
703
+ case "connecting":
704
+ status = "Connecting\u2026";
705
+ motion = "pending";
706
+ break;
707
+ case "listening":
708
+ status = "I\u2019m listening";
709
+ motion = "listening";
710
+ break;
711
+ case "user_speaking":
712
+ status = "Hearing you";
713
+ motion = "hearing";
714
+ break;
715
+ case "processing":
716
+ status = "Looking that up\u2026";
717
+ motion = "processing";
718
+ break;
719
+ case "assistant_speaking":
720
+ status = "Speaking";
721
+ motion = "speaking";
722
+ break;
723
+ case "interrupted":
724
+ status = "Interrupted \u2014 go ahead";
725
+ motion = "settle";
726
+ break;
727
+ case "reconnecting":
728
+ status = "Reconnecting\u2026";
729
+ motion = "static";
730
+ break;
731
+ default:
732
+ status = "I\u2019m listening";
733
+ motion = "listening";
734
+ }
735
+ if (microphoneMuted && voice.connection === "connected") {
736
+ status = "Microphone muted";
737
+ }
738
+ return {
739
+ status,
740
+ motion,
741
+ canStart: false,
742
+ canEnd: true,
743
+ canMute: voice.connection === "connected" || voice.connection === "reconnecting",
744
+ canToggleCaptions: true,
745
+ canRetry: false,
746
+ canDismiss: false,
747
+ meta,
748
+ microphoneMuted,
749
+ consentPending: false
750
+ };
751
+ }
752
+
753
+ // src/voice/voice-stage.tsx
754
+ import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs7 } from "preact/jsx-runtime";
755
+ function VoiceStage({
756
+ assistantName,
757
+ voice,
758
+ messages,
759
+ levels,
760
+ captionsOpen,
761
+ layout = "orb",
762
+ visual = "orb",
763
+ reducedMotion,
764
+ accentColor,
765
+ onStart,
766
+ onEnd,
767
+ onMute,
768
+ onToggleCaptions,
769
+ onRetry,
770
+ onDismiss,
771
+ onAcceptConsent,
772
+ onDeclineConsent
773
+ }) {
774
+ const presentation = presentVoice(voice);
775
+ const statusId = "chatai-voice-stage-status";
776
+ const companion = visual === "companion";
777
+ return /* @__PURE__ */ jsxs7(
778
+ "div",
779
+ {
780
+ className: `chatai-voice-stage layout-${layout}${companion ? " visual-companion" : ""}`,
781
+ "data-phase": voice.phase,
782
+ "data-motion": presentation.motion,
783
+ style: accentColor ? { "--chatai-voice-accent": accentColor } : void 0,
784
+ children: [
785
+ /* @__PURE__ */ jsxs7("p", { className: "chatai-voice-identity", children: [
786
+ /* @__PURE__ */ jsx7("span", { className: "chatai-kicker", children: companion ? "Live companion" : "Live voice" }),
787
+ /* @__PURE__ */ jsx7("span", { className: "chatai-voice-name", children: assistantName })
788
+ ] }),
789
+ companion ? /* @__PURE__ */ jsx7(
790
+ VoiceCompanionCharacter,
791
+ {
792
+ motion: presentation.motion,
793
+ levels,
794
+ reducedMotion
795
+ }
796
+ ) : /* @__PURE__ */ jsx7(VoiceOrb, { motion: presentation.motion, levels, reducedMotion }),
797
+ /* @__PURE__ */ jsx7("p", { id: statusId, className: "chatai-voice-stage-status", role: "status", "aria-live": "polite", children: presentation.status }),
798
+ presentation.errorMessage ? /* @__PURE__ */ jsx7("p", { className: "chatai-voice-stage-detail", role: "alert", children: presentation.errorMessage }) : null,
799
+ presentation.notice ? /* @__PURE__ */ jsx7("p", { className: "chatai-voice-stage-detail", children: presentation.notice }) : null,
800
+ presentation.meta ? /* @__PURE__ */ jsx7("p", { className: "chatai-voice-stage-meta", children: presentation.meta }) : null,
801
+ presentation.consentPending ? /* @__PURE__ */ jsx7(VoiceConsent, { onAccept: onAcceptConsent, onCancel: onDeclineConsent }) : /* @__PURE__ */ jsxs7(Fragment3, { children: [
802
+ /* @__PURE__ */ jsx7(VoiceCaptions, { messages, open: captionsOpen }),
803
+ /* @__PURE__ */ jsx7(
804
+ VoiceControls,
805
+ {
806
+ presentation,
807
+ captionsOpen,
808
+ onStart,
809
+ onEnd,
810
+ onMute,
811
+ onToggleCaptions,
812
+ onRetry,
813
+ onDismiss
814
+ }
815
+ )
816
+ ] })
817
+ ]
818
+ }
819
+ );
820
+ }
821
+
822
+ // src/voice/voice-dock.tsx
823
+ import { jsx as jsx8, jsxs as jsxs8 } from "preact/jsx-runtime";
316
824
  var FOCUSABLE = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
825
+ function VoiceDockSurface({
826
+ appearance,
827
+ assistantName,
828
+ voice,
829
+ messages,
830
+ levels,
831
+ captionsOpen,
832
+ onClose,
833
+ onStart,
834
+ onEnd,
835
+ onMute,
836
+ onToggleCaptions,
837
+ onRetry,
838
+ onDismiss,
839
+ onAcceptConsent,
840
+ onDeclineConsent
841
+ }) {
842
+ const surfaceRef = useRef4(null);
843
+ useEffect4(() => {
844
+ const node = surfaceRef.current;
845
+ if (!node) return;
846
+ const surface = node;
847
+ const focusables = () => Array.from(surface.querySelectorAll(FOCUSABLE));
848
+ focusables()[0]?.focus();
849
+ function onKeyDown(event) {
850
+ if (event.key === "Escape") {
851
+ event.preventDefault();
852
+ event.stopPropagation();
853
+ onClose();
854
+ return;
855
+ }
856
+ if (event.key !== "Tab") return;
857
+ const nodes = focusables();
858
+ const first = nodes[0];
859
+ const last = nodes[nodes.length - 1];
860
+ if (!first || !last) return;
861
+ const rootNode = surface.getRootNode();
862
+ const active = rootNode instanceof ShadowRoot ? rootNode.activeElement : document.activeElement;
863
+ if (event.shiftKey && active === first) {
864
+ event.preventDefault();
865
+ last.focus();
866
+ } else if (!event.shiftKey && active === last) {
867
+ event.preventDefault();
868
+ first.focus();
869
+ }
870
+ }
871
+ surface.addEventListener("keydown", onKeyDown);
872
+ return () => surface.removeEventListener("keydown", onKeyDown);
873
+ }, [onClose]);
874
+ return /* @__PURE__ */ jsx8(
875
+ "div",
876
+ {
877
+ ref: surfaceRef,
878
+ className: "chatai-dock-surface",
879
+ role: "dialog",
880
+ "aria-modal": "true",
881
+ "aria-label": `${assistantName} voice`,
882
+ children: /* @__PURE__ */ jsx8(
883
+ VoiceStage,
884
+ {
885
+ assistantName,
886
+ voice,
887
+ messages,
888
+ levels,
889
+ captionsOpen,
890
+ layout: "compact",
891
+ reducedMotion: appearance.motion === "reduced",
892
+ accentColor: appearance.accentColor,
893
+ onStart,
894
+ onEnd,
895
+ onMute,
896
+ onToggleCaptions,
897
+ onRetry,
898
+ onDismiss,
899
+ onAcceptConsent,
900
+ onDeclineConsent
901
+ }
902
+ )
903
+ }
904
+ );
905
+ }
906
+ function VoiceDockTalk({
907
+ open,
908
+ onOpen,
909
+ onClose
910
+ }) {
911
+ return /* @__PURE__ */ jsxs8(
912
+ "button",
913
+ {
914
+ type: "button",
915
+ className: `chatai-dock-talk${open ? " is-open" : ""}`,
916
+ onClick: () => open ? onClose() : onOpen(),
917
+ "aria-expanded": open,
918
+ "aria-haspopup": "dialog",
919
+ "aria-label": open ? "Close voice dock" : "Open voice talk",
920
+ children: [
921
+ /* @__PURE__ */ jsx8(MicGlyph, { off: open }),
922
+ /* @__PURE__ */ jsx8("span", { children: "Talk" })
923
+ ]
924
+ }
925
+ );
926
+ }
927
+
928
+ // src/voice/voice-guided.tsx
929
+ import { isVoiceActive as isVoiceActive3 } from "@nightzeros/chatai-widget-core";
930
+ import { jsx as jsx9, jsxs as jsxs9 } from "preact/jsx-runtime";
931
+ function VoiceGuidedCanvas({
932
+ assistantName,
933
+ welcomeMessage,
934
+ questions,
935
+ voiceOffered,
936
+ busy,
937
+ onStart,
938
+ onAsk
939
+ }) {
940
+ return /* @__PURE__ */ jsxs9("div", { className: "chatai-guided", children: [
941
+ /* @__PURE__ */ jsx9("p", { className: "chatai-guided-kicker", children: "Live voice guide" }),
942
+ /* @__PURE__ */ jsx9("h3", { className: "chatai-guided-title", children: assistantName }),
943
+ welcomeMessage ? /* @__PURE__ */ jsx9("p", { className: "chatai-guided-welcome", children: welcomeMessage }) : null,
944
+ questions.length > 0 ? /* @__PURE__ */ jsxs9("div", { className: "chatai-guided-choices", children: [
945
+ /* @__PURE__ */ jsx9("p", { className: "chatai-guided-choices-label", children: "Suggested questions" }),
946
+ questions.map((question) => /* @__PURE__ */ jsxs9(
947
+ "button",
948
+ {
949
+ type: "button",
950
+ className: "chatai-guided-choice",
951
+ onClick: () => onAsk(question),
952
+ disabled: busy,
953
+ children: [
954
+ /* @__PURE__ */ jsx9("span", { children: question }),
955
+ /* @__PURE__ */ jsx9("span", { className: "chatai-guided-choice-mark", "aria-hidden": "true", children: "\u2197" })
956
+ ]
957
+ },
958
+ question
959
+ )),
960
+ /* @__PURE__ */ jsx9("p", { className: "chatai-guided-hint", children: "Tap a question to ask by text, or start voice below." })
961
+ ] }) : /* @__PURE__ */ jsx9("p", { className: "chatai-guided-hint", children: "Start a voice conversation when you are ready." }),
962
+ voiceOffered ? /* @__PURE__ */ jsx9("button", { type: "button", className: "chatai-voice-primary chatai-guided-start", onClick: onStart, children: "Start conversation" }) : null
963
+ ] });
964
+ }
965
+ function VoiceGuidedSpeakHints({ questions }) {
966
+ if (questions.length === 0) return null;
967
+ return /* @__PURE__ */ jsxs9("div", { className: "chatai-guided-speak-hints", children: [
968
+ /* @__PURE__ */ jsx9("p", { className: "chatai-guided-choices-label", children: "Try saying" }),
969
+ /* @__PURE__ */ jsx9("ul", { children: questions.slice(0, 4).map((question) => /* @__PURE__ */ jsx9("li", { children: question }, question)) })
970
+ ] });
971
+ }
972
+ function VoiceGuidedStage({
973
+ appearance,
974
+ assistantName,
975
+ voice,
976
+ messages,
977
+ levels,
978
+ captionsOpen,
979
+ questions,
980
+ onStart,
981
+ onEnd,
982
+ onMute,
983
+ onToggleCaptions,
984
+ onRetry,
985
+ onDismiss,
986
+ onAcceptConsent,
987
+ onDeclineConsent
988
+ }) {
989
+ const showHints = isVoiceActive3(voice.connection) && voice.connection === "connected" && !voice.consentPending && questions.length > 0;
990
+ return /* @__PURE__ */ jsxs9("div", { className: "chatai-guided-stage", children: [
991
+ /* @__PURE__ */ jsx9(
992
+ VoiceStage,
993
+ {
994
+ assistantName,
995
+ voice,
996
+ messages,
997
+ levels,
998
+ captionsOpen,
999
+ layout: "orb",
1000
+ reducedMotion: appearance.motion === "reduced",
1001
+ accentColor: appearance.accentColor,
1002
+ onStart,
1003
+ onEnd,
1004
+ onMute,
1005
+ onToggleCaptions,
1006
+ onRetry,
1007
+ onDismiss,
1008
+ onAcceptConsent,
1009
+ onDeclineConsent
1010
+ }
1011
+ ),
1012
+ showHints ? /* @__PURE__ */ jsx9(VoiceGuidedSpeakHints, { questions }) : null
1013
+ ] });
1014
+ }
1015
+
1016
+ // src/voice/voice-experience.tsx
1017
+ import { jsx as jsx10 } from "preact/jsx-runtime";
1018
+ function VoiceExperience({
1019
+ appearance,
1020
+ assistantName,
1021
+ voice,
1022
+ messages,
1023
+ levels,
1024
+ captionsOpen,
1025
+ questions = [],
1026
+ onStart,
1027
+ onEnd,
1028
+ onMute,
1029
+ onToggleCaptions,
1030
+ onRetry,
1031
+ onDismiss,
1032
+ onAcceptConsent,
1033
+ onDeclineConsent
1034
+ }) {
1035
+ if (appearance.experience === "guided" && voiceStageVisible(voice)) {
1036
+ return /* @__PURE__ */ jsx10(
1037
+ VoiceGuidedStage,
1038
+ {
1039
+ appearance,
1040
+ assistantName,
1041
+ voice,
1042
+ messages,
1043
+ levels,
1044
+ captionsOpen,
1045
+ questions,
1046
+ onStart,
1047
+ onEnd,
1048
+ onMute,
1049
+ onToggleCaptions,
1050
+ onRetry,
1051
+ onDismiss,
1052
+ onAcceptConsent,
1053
+ onDeclineConsent
1054
+ }
1055
+ );
1056
+ }
1057
+ if (appearance.experience === "companion" && voiceStageVisible(voice)) {
1058
+ return /* @__PURE__ */ jsx10(
1059
+ VoiceStage,
1060
+ {
1061
+ assistantName,
1062
+ voice,
1063
+ messages,
1064
+ levels,
1065
+ captionsOpen,
1066
+ layout: "orb",
1067
+ visual: "companion",
1068
+ reducedMotion: appearance.motion === "reduced",
1069
+ accentColor: appearance.accentColor,
1070
+ onStart,
1071
+ onEnd,
1072
+ onMute,
1073
+ onToggleCaptions,
1074
+ onRetry,
1075
+ onDismiss,
1076
+ onAcceptConsent,
1077
+ onDeclineConsent
1078
+ }
1079
+ );
1080
+ }
1081
+ if ((appearance.experience === "orb" || appearance.experience === "side-panel") && voiceStageVisible(voice)) {
1082
+ return /* @__PURE__ */ jsx10(
1083
+ VoiceStage,
1084
+ {
1085
+ assistantName,
1086
+ voice,
1087
+ messages,
1088
+ levels,
1089
+ captionsOpen,
1090
+ layout: "orb",
1091
+ reducedMotion: appearance.motion === "reduced",
1092
+ accentColor: appearance.accentColor,
1093
+ onStart,
1094
+ onEnd,
1095
+ onMute,
1096
+ onToggleCaptions,
1097
+ onRetry,
1098
+ onDismiss,
1099
+ onAcceptConsent,
1100
+ onDeclineConsent
1101
+ }
1102
+ );
1103
+ }
1104
+ if (appearance.experience === "classic") {
1105
+ return /* @__PURE__ */ jsx10(VoiceBar, { voice, levels, onRetry, onDismiss });
1106
+ }
1107
+ return null;
1108
+ }
1109
+
1110
+ // src/app.tsx
1111
+ import { Fragment as Fragment4, jsx as jsx11, jsxs as jsxs10 } from "preact/jsx-runtime";
1112
+ var FOCUSABLE2 = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
317
1113
  function settingOverrides(props) {
318
1114
  return {
319
1115
  primaryColor: props.primaryColor,
@@ -321,7 +1117,8 @@ function settingOverrides(props) {
321
1117
  theme: props.theme,
322
1118
  iconUrl: props.iconUrl,
323
1119
  suggestedQuestions: props.suggestedQuestions,
324
- showSources: props.showSources
1120
+ showSources: props.showSources,
1121
+ voiceAppearance: props.voiceAppearance
325
1122
  };
326
1123
  }
327
1124
  var EMPTY_STATE = {
@@ -331,23 +1128,34 @@ var EMPTY_STATE = {
331
1128
  };
332
1129
  function settingsFrom(state, props) {
333
1130
  const settings = state.config?.settings ?? {};
334
- return {
1131
+ const overrides = settingOverrides(props);
1132
+ const { voiceAppearance: overrideAppearance, ...flatOverrides } = overrides;
1133
+ const merged = {
335
1134
  ...settings,
336
- ...Object.fromEntries(Object.entries(settingOverrides(props)).filter(([, value]) => value !== void 0)),
1135
+ ...Object.fromEntries(Object.entries(flatOverrides).filter(([, value]) => value !== void 0)),
337
1136
  theme: props.theme ?? settings.theme ?? "system",
338
1137
  position: props.position ?? settings.position ?? "bottom-right"
339
1138
  };
1139
+ const appearance = mergeVoiceAppearance(
1140
+ parseVoiceAppearance(settings.voiceAppearance),
1141
+ overrideAppearance !== void 0 ? parseVoiceAppearance(overrideAppearance) : void 0
1142
+ );
1143
+ if (Object.keys(appearance).length > 0) merged.voiceAppearance = appearance;
1144
+ return merged;
1145
+ }
1146
+ function voiceAppearanceFrom(state, props) {
1147
+ return resolveVoiceAppearance(settingsFrom(state, props).voiceAppearance);
340
1148
  }
341
1149
  function ChatGlyph() {
342
- return /* @__PURE__ */ jsxs3("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", fill: "none", stroke: "currentColor", "stroke-width": "2", children: [
343
- /* @__PURE__ */ jsx3("path", { d: "M20 11.5a7.5 7.5 0 0 1-9.4 7.3L5 21l1.4-4.2A7.5 7.5 0 1 1 20 11.5Z" }),
344
- /* @__PURE__ */ jsx3("path", { d: "M8.5 11.5h.01M12 11.5h.01M15.5 11.5h.01", "stroke-linecap": "round" })
1150
+ return /* @__PURE__ */ jsxs10("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", fill: "none", stroke: "currentColor", "stroke-width": "2", children: [
1151
+ /* @__PURE__ */ jsx11("path", { d: "M20 11.5a7.5 7.5 0 0 1-9.4 7.3L5 21l1.4-4.2A7.5 7.5 0 1 1 20 11.5Z" }),
1152
+ /* @__PURE__ */ jsx11("path", { d: "M8.5 11.5h.01M12 11.5h.01M15.5 11.5h.01", "stroke-linecap": "round" })
345
1153
  ] });
346
1154
  }
347
1155
  function ThumbUpGlyph() {
348
- return /* @__PURE__ */ jsxs3("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", fill: "none", stroke: "currentColor", "stroke-width": "2", children: [
349
- /* @__PURE__ */ jsx3("path", { d: "M7 10v12", "stroke-linecap": "round", "stroke-linejoin": "round" }),
350
- /* @__PURE__ */ jsx3(
1156
+ return /* @__PURE__ */ jsxs10("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", fill: "none", stroke: "currentColor", "stroke-width": "2", children: [
1157
+ /* @__PURE__ */ jsx11("path", { d: "M7 10v12", "stroke-linecap": "round", "stroke-linejoin": "round" }),
1158
+ /* @__PURE__ */ jsx11(
351
1159
  "path",
352
1160
  {
353
1161
  d: "M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",
@@ -358,9 +1166,9 @@ function ThumbUpGlyph() {
358
1166
  ] });
359
1167
  }
360
1168
  function ThumbDownGlyph() {
361
- return /* @__PURE__ */ jsxs3("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", fill: "none", stroke: "currentColor", "stroke-width": "2", children: [
362
- /* @__PURE__ */ jsx3("path", { d: "M17 14V2", "stroke-linecap": "round", "stroke-linejoin": "round" }),
363
- /* @__PURE__ */ jsx3(
1169
+ return /* @__PURE__ */ jsxs10("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", fill: "none", stroke: "currentColor", "stroke-width": "2", children: [
1170
+ /* @__PURE__ */ jsx11("path", { d: "M17 14V2", "stroke-linecap": "round", "stroke-linejoin": "round" }),
1171
+ /* @__PURE__ */ jsx11(
364
1172
  "path",
365
1173
  {
366
1174
  d: "M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",
@@ -371,10 +1179,10 @@ function ThumbDownGlyph() {
371
1179
  ] });
372
1180
  }
373
1181
  function TypingIndicator() {
374
- return /* @__PURE__ */ jsxs3("div", { className: "chatai-typing", "aria-label": "Assistant is typing", role: "status", children: [
375
- /* @__PURE__ */ jsx3("span", {}),
376
- /* @__PURE__ */ jsx3("span", {}),
377
- /* @__PURE__ */ jsx3("span", {})
1182
+ return /* @__PURE__ */ jsxs10("div", { className: "chatai-typing", "aria-label": "Assistant is typing", role: "status", children: [
1183
+ /* @__PURE__ */ jsx11("span", {}),
1184
+ /* @__PURE__ */ jsx11("span", {}),
1185
+ /* @__PURE__ */ jsx11("span", {})
378
1186
  ] });
379
1187
  }
380
1188
  function WidgetApp(props) {
@@ -402,11 +1210,14 @@ function WidgetApp(props) {
402
1210
  const [open, setOpen] = useState(false);
403
1211
  const [closing, setClosing] = useState(false);
404
1212
  const [draft, setDraft] = useState("");
405
- const launcherRef = useRef2(null);
406
- const panelRef = useRef2(null);
407
- const transcriptRef = useRef2(null);
408
- const wasOpenRef = useRef2(false);
409
- useEffect2(() => {
1213
+ const [captionsOpen, setCaptionsOpen] = useState(true);
1214
+ const [dockOpen, setDockOpen] = useState(false);
1215
+ const launcherRef = useRef5(null);
1216
+ const panelRef = useRef5(null);
1217
+ const transcriptRef = useRef5(null);
1218
+ const wasOpenRef = useRef5(false);
1219
+ const wasDockOpenRef = useRef5(false);
1220
+ useEffect5(() => {
410
1221
  const unsubscribe = controller.subscribe(setState);
411
1222
  void controller.load();
412
1223
  return () => {
@@ -415,9 +1226,17 @@ function WidgetApp(props) {
415
1226
  };
416
1227
  }, [controller]);
417
1228
  const settings = settingsFrom(state, props);
1229
+ const appearance = voiceAppearanceFrom(state, props);
418
1230
  const questions = settings.suggestedQuestions?.filter(Boolean) ?? [];
419
- const voiceOn = isVoiceActive2(state.voice.connection);
1231
+ const voiceOn = isVoiceActive4(state.voice.connection);
420
1232
  const voiceOffered = props.voice !== false && Boolean(state.config?.voice?.enabled);
1233
+ const isDock = appearance.experience === "dock";
1234
+ const isGuided = appearance.experience === "guided";
1235
+ const isCompanion = appearance.experience === "companion";
1236
+ const isSidePanel = appearance.experience === "side-panel";
1237
+ const voiceStage = voiceOffered && (appearance.experience === "orb" || appearance.experience === "guided" || appearance.experience === "companion" || appearance.experience === "side-panel") && voiceStageVisible(state.voice);
1238
+ const guidedCanvas = voiceOffered && isGuided && !voiceStageVisible(state.voice);
1239
+ const companionCanvas = voiceOffered && isCompanion && !voiceStageVisible(state.voice);
421
1240
  const streaming = state.status === "streaming";
422
1241
  const busy = streaming || voiceOn;
423
1242
  const panelShown = open || closing;
@@ -427,7 +1246,16 @@ function WidgetApp(props) {
427
1246
  function reduceMotion() {
428
1247
  return typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
429
1248
  }
1249
+ function releaseDockVoice() {
1250
+ void controller.endVoice();
1251
+ controller.dismissVoiceError();
1252
+ if (controller.getState().voice.consentPending) controller.declineRecordingConsent();
1253
+ }
430
1254
  function openPanel() {
1255
+ if (dockOpen) {
1256
+ releaseDockVoice();
1257
+ setDockOpen(false);
1258
+ }
431
1259
  setClosing(false);
432
1260
  setOpen(true);
433
1261
  }
@@ -446,6 +1274,21 @@ function WidgetApp(props) {
446
1274
  if (open) closePanel();
447
1275
  else openPanel();
448
1276
  }
1277
+ function openDock() {
1278
+ setOpen(false);
1279
+ setClosing(false);
1280
+ setDockOpen(true);
1281
+ }
1282
+ function closeDock() {
1283
+ releaseDockVoice();
1284
+ setDockOpen(false);
1285
+ }
1286
+ function dismissDockToChat() {
1287
+ releaseDockVoice();
1288
+ setDockOpen(false);
1289
+ setClosing(false);
1290
+ setOpen(true);
1291
+ }
449
1292
  function send(message) {
450
1293
  if (!message.trim()) return;
451
1294
  setDraft("");
@@ -461,11 +1304,11 @@ function WidgetApp(props) {
461
1304
  if (voiceOn) void controller.endVoice();
462
1305
  else void controller.startVoice();
463
1306
  }
464
- useEffect2(() => {
1307
+ useEffect5(() => {
465
1308
  if (!panelShown) return;
466
1309
  const panel = panelRef.current;
467
1310
  if (!panel) return;
468
- const focusables = () => Array.from(panel.querySelectorAll(FOCUSABLE));
1311
+ const focusables = () => Array.from(panel.querySelectorAll(FOCUSABLE2));
469
1312
  const initial = focusables();
470
1313
  (initial.find((el) => el.id === "chatai-message-input") ?? initial[0])?.focus();
471
1314
  function onKeyDown(event) {
@@ -489,25 +1332,73 @@ function WidgetApp(props) {
489
1332
  }
490
1333
  panel.addEventListener("keydown", onKeyDown);
491
1334
  return () => panel.removeEventListener("keydown", onKeyDown);
492
- }, [panelShown]);
493
- useEffect2(() => {
1335
+ }, [panelShown, voiceStage]);
1336
+ useEffect5(() => {
494
1337
  if (wasOpenRef.current && !open && !closing) {
495
1338
  launcherRef.current?.focus();
496
1339
  }
497
1340
  wasOpenRef.current = open || closing;
498
1341
  }, [open, closing]);
499
- useEffect2(() => {
1342
+ useEffect5(() => {
500
1343
  const el = transcriptRef.current;
501
1344
  if (!el) return;
502
1345
  el.scrollTop = el.scrollHeight;
503
1346
  }, [state.messages, state.error, showTyping, panelShown]);
504
- return /* @__PURE__ */ jsxs3(
1347
+ useEffect5(() => {
1348
+ if (!voiceStage && !dockOpen) setCaptionsOpen(appearance.captionsDefault);
1349
+ }, [appearance.captionsDefault, voiceStage, dockOpen]);
1350
+ useEffect5(() => {
1351
+ if (wasDockOpenRef.current && !dockOpen) {
1352
+ launcherRef.current?.focus();
1353
+ }
1354
+ wasDockOpenRef.current = dockOpen;
1355
+ }, [dockOpen]);
1356
+ useEffect5(() => {
1357
+ if (!isDock && dockOpen) {
1358
+ void controller.endVoice();
1359
+ setDockOpen(false);
1360
+ }
1361
+ }, [isDock, dockOpen, controller]);
1362
+ const voiceHandlers = {
1363
+ onStart: () => void controller.startVoice(),
1364
+ onEnd: () => void controller.endVoice(),
1365
+ onMute: (muted) => controller.setVoiceMicrophoneMuted(muted),
1366
+ onToggleCaptions: () => setCaptionsOpen((value) => !value),
1367
+ onRetry: () => void controller.startVoice(),
1368
+ onDismiss: () => controller.dismissVoiceError(),
1369
+ onAcceptConsent: () => void controller.acceptRecordingConsent(),
1370
+ onDeclineConsent: () => controller.declineRecordingConsent()
1371
+ };
1372
+ return /* @__PURE__ */ jsxs10(
505
1373
  "div",
506
1374
  {
507
- className: `chatai-widget ${isDark ? "theme-dark" : "theme-light"} ${settings.position === "bottom-left" ? "position-left" : "position-right"} ${props.layout === "contained" ? "layout-contained" : ""}`,
508
- style: { "--chatai-accent": settings.primaryColor ?? "#0F766E" },
1375
+ className: `chatai-widget ${isDark ? "theme-dark" : "theme-light"} ${settings.position === "bottom-left" ? "position-left" : "position-right"} ${props.layout === "contained" ? "layout-contained" : ""}${isDock ? " experience-dock" : ""}${isSidePanel ? " experience-side-panel" : ""}`,
1376
+ style: {
1377
+ "--chatai-accent": settings.primaryColor ?? "#0F766E",
1378
+ ...appearance.accentColor ? { "--chatai-voice-accent": appearance.accentColor } : {}
1379
+ },
509
1380
  children: [
510
- panelShown ? /* @__PURE__ */ jsxs3(
1381
+ dockOpen && voiceOffered && isDock ? /* @__PURE__ */ jsx11(
1382
+ VoiceDockSurface,
1383
+ {
1384
+ appearance,
1385
+ assistantName: state.config?.name ?? "Assistant",
1386
+ voice: state.voice,
1387
+ messages: state.messages,
1388
+ levels: () => controller.voiceLevels(),
1389
+ captionsOpen,
1390
+ onClose: closeDock,
1391
+ onStart: voiceHandlers.onStart,
1392
+ onEnd: voiceHandlers.onEnd,
1393
+ onMute: voiceHandlers.onMute,
1394
+ onToggleCaptions: voiceHandlers.onToggleCaptions,
1395
+ onRetry: voiceHandlers.onRetry,
1396
+ onDismiss: dismissDockToChat,
1397
+ onAcceptConsent: voiceHandlers.onAcceptConsent,
1398
+ onDeclineConsent: voiceHandlers.onDeclineConsent
1399
+ }
1400
+ ) : null,
1401
+ panelShown ? /* @__PURE__ */ jsxs10(
511
1402
  "section",
512
1403
  {
513
1404
  ref: panelRef,
@@ -519,149 +1410,303 @@ function WidgetApp(props) {
519
1410
  if (closing) setClosing(false);
520
1411
  },
521
1412
  children: [
522
- /* @__PURE__ */ jsxs3("header", { className: "chatai-header", children: [
523
- /* @__PURE__ */ jsxs3("div", { children: [
524
- /* @__PURE__ */ jsx3("p", { className: "chatai-kicker", children: "Knowledge assistant" }),
525
- /* @__PURE__ */ jsx3("h2", { children: state.config?.name ?? "Loading assistant\u2026" })
1413
+ /* @__PURE__ */ jsxs10("header", { className: "chatai-header", children: [
1414
+ /* @__PURE__ */ jsxs10("div", { children: [
1415
+ /* @__PURE__ */ jsx11("p", { className: "chatai-kicker", children: isSidePanel ? "Side panel" : "Knowledge assistant" }),
1416
+ /* @__PURE__ */ jsx11("h2", { children: state.config?.name ?? "Loading assistant\u2026" })
526
1417
  ] }),
527
- /* @__PURE__ */ jsx3("button", { type: "button", className: "chatai-close", onClick: closePanel, "aria-label": "Close chat", children: "\xD7" })
528
- ] }),
529
- /* @__PURE__ */ jsxs3("div", { ref: transcriptRef, className: "chatai-transcript", "aria-live": voiceOn ? "off" : "polite", children: [
530
- state.config?.welcomeMessage ? /* @__PURE__ */ jsx3("article", { className: "chatai-message assistant", children: /* @__PURE__ */ jsx3(MarkdownMessage, { content: state.config.welcomeMessage }) }) : null,
531
- questions.length > 0 && state.messages.length === 0 ? /* @__PURE__ */ jsx3("div", { className: "chatai-prompts", children: questions.map((question) => /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => send(question), disabled: busy, children: question }, question)) }) : null,
532
- state.messages.map((message, index) => {
533
- const isLast = index === state.messages.length - 1;
534
- const isStreamingPlaceholder = showTyping && isLast && message.role === "assistant";
535
- const isStreamingContent = streaming && isLast && message.role === "assistant" && Boolean(message.content);
536
- const isVoice = message.modality === "voice";
537
- return /* @__PURE__ */ jsxs3(
538
- "article",
539
- {
540
- className: `chatai-message ${message.role}${isVoice ? " is-voice" : ""}${message.live ? " is-live" : ""}`,
541
- children: [
542
- isVoice ? /* @__PURE__ */ jsxs3("span", { className: "chatai-voice-tag", children: [
543
- /* @__PURE__ */ jsx3(VoiceGlyph, {}),
544
- /* @__PURE__ */ jsx3("span", { className: "chatai-visually-hidden", children: message.role === "user" ? "You said:" : "Assistant said:" })
545
- ] }) : null,
546
- isStreamingPlaceholder ? /* @__PURE__ */ jsx3(TypingIndicator, {}) : message.role === "assistant" && !isVoice ? message.content ? /* @__PURE__ */ jsx3(MarkdownMessage, { content: message.content, streaming: isStreamingContent }) : /* @__PURE__ */ jsx3("p", { children: streaming ? "Thinking\u2026" : "" }) : /* @__PURE__ */ jsx3("p", { className: "chatai-user-text", children: message.content }),
547
- message.interrupted ? /* @__PURE__ */ jsx3("p", { className: "chatai-voice-note", children: "Interrupted" }) : null,
548
- message.role === "assistant" && message.id ? /* @__PURE__ */ jsxs3("div", { className: "chatai-feedback", children: [
549
- /* @__PURE__ */ jsx3("span", { children: "Was this helpful?" }),
550
- /* @__PURE__ */ jsx3(
551
- "button",
552
- {
553
- type: "button",
554
- "aria-label": "Mark response helpful",
555
- "aria-pressed": message.feedback === "positive",
556
- onClick: () => rate(message.id, "positive"),
557
- children: /* @__PURE__ */ jsx3(ThumbUpGlyph, {})
558
- }
559
- ),
560
- /* @__PURE__ */ jsx3(
561
- "button",
562
- {
563
- type: "button",
564
- "aria-label": "Mark response not helpful",
565
- "aria-pressed": message.feedback === "negative",
566
- onClick: () => rate(message.id, "negative"),
567
- children: /* @__PURE__ */ jsx3(ThumbDownGlyph, {})
568
- }
569
- )
570
- ] }) : null
571
- ]
572
- },
573
- `${message.role}-${index}`
574
- );
575
- }),
576
- state.error ? /* @__PURE__ */ jsxs3("div", { className: "chatai-error", role: "alert", children: [
577
- /* @__PURE__ */ jsx3("p", { children: state.error }),
578
- /* @__PURE__ */ jsx3("button", { type: "button", className: "chatai-retry", onClick: retry, disabled: busy, children: "Retry" })
579
- ] }) : null
1418
+ /* @__PURE__ */ jsx11("button", { type: "button", className: "chatai-close", onClick: closePanel, "aria-label": "Close chat", children: "\xD7" })
580
1419
  ] }),
581
- voiceOffered && state.voice.consentPending ? /* @__PURE__ */ jsx3(
582
- VoiceConsent,
583
- {
584
- onAccept: () => void controller.acceptRecordingConsent(),
585
- onCancel: () => {
586
- controller.declineRecordingConsent();
587
- panelRef.current?.querySelector("#chatai-message-input")?.focus();
588
- }
589
- }
590
- ) : null,
591
- voiceOffered ? /* @__PURE__ */ jsx3(
592
- VoiceBar,
1420
+ voiceStage ? /* @__PURE__ */ jsx11(
1421
+ VoiceExperience,
593
1422
  {
1423
+ appearance,
1424
+ assistantName: state.config?.name ?? "Assistant",
594
1425
  voice: state.voice,
1426
+ messages: state.messages,
595
1427
  levels: () => controller.voiceLevels(),
596
- onRetry: () => void controller.startVoice(),
597
- onDismiss: () => controller.dismissVoiceError()
598
- }
599
- ) : null,
600
- /* @__PURE__ */ jsxs3(
601
- "form",
602
- {
603
- className: "chatai-composer",
604
- onSubmit: (event) => {
605
- event.preventDefault();
606
- send(draft);
607
- },
608
- children: [
609
- /* @__PURE__ */ jsx3("label", { className: "chatai-visually-hidden", htmlFor: "chatai-message-input", children: "Message" }),
610
- /* @__PURE__ */ jsx3(
611
- "input",
612
- {
613
- id: "chatai-message-input",
614
- value: draft,
615
- onInput: (event) => setDraft(event.currentTarget.value),
616
- placeholder: voiceOn ? "Voice is on \u2014 end it to type" : "Ask a question\u2026",
617
- maxLength: 4e3,
618
- disabled: busy
619
- }
620
- ),
621
- voiceOffered ? /* @__PURE__ */ jsx3(
622
- "button",
623
- {
624
- type: "button",
625
- className: `chatai-mic${voiceOn ? " is-active" : ""}`,
626
- onClick: toggleVoice,
627
- disabled: streaming,
628
- "aria-pressed": voiceOn,
629
- "aria-label": voiceOn ? "End voice conversation" : "Start voice conversation",
630
- title: voiceOn ? "End voice" : "Talk instead",
631
- children: /* @__PURE__ */ jsx3(MicGlyph, { off: voiceOn })
632
- }
633
- ) : null,
634
- /* @__PURE__ */ jsx3("button", { type: "submit", disabled: busy || !draft.trim(), "aria-label": "Send message", children: "\u2191" })
635
- ]
1428
+ captionsOpen,
1429
+ questions,
1430
+ ...voiceHandlers
636
1431
  }
637
- )
1432
+ ) : guidedCanvas ? /* @__PURE__ */ jsxs10(Fragment4, { children: [
1433
+ /* @__PURE__ */ jsx11(
1434
+ VoiceGuidedCanvas,
1435
+ {
1436
+ assistantName: state.config?.name ?? "Assistant",
1437
+ welcomeMessage: state.config?.welcomeMessage,
1438
+ questions,
1439
+ voiceOffered,
1440
+ busy,
1441
+ onStart: () => void controller.startVoice(),
1442
+ onAsk: send
1443
+ }
1444
+ ),
1445
+ state.messages.length > 0 ? /* @__PURE__ */ jsx11(
1446
+ "div",
1447
+ {
1448
+ ref: transcriptRef,
1449
+ className: "chatai-transcript chatai-guided-history",
1450
+ "aria-live": "polite",
1451
+ children: state.messages.map((message, index) => {
1452
+ const isVoice = message.modality === "voice";
1453
+ return /* @__PURE__ */ jsxs10(
1454
+ "article",
1455
+ {
1456
+ className: `chatai-message ${message.role}${isVoice ? " is-voice" : ""}`,
1457
+ children: [
1458
+ isVoice ? /* @__PURE__ */ jsx11("span", { className: "chatai-voice-tag", children: /* @__PURE__ */ jsx11(VoiceGlyph, {}) }) : null,
1459
+ message.role === "assistant" && !isVoice ? message.content ? /* @__PURE__ */ jsx11(MarkdownMessage, { content: message.content }) : null : /* @__PURE__ */ jsx11("p", { className: "chatai-user-text", children: message.content })
1460
+ ]
1461
+ },
1462
+ `${message.role}-${index}`
1463
+ );
1464
+ })
1465
+ }
1466
+ ) : null,
1467
+ /* @__PURE__ */ jsxs10(
1468
+ "form",
1469
+ {
1470
+ className: "chatai-composer",
1471
+ onSubmit: (event) => {
1472
+ event.preventDefault();
1473
+ send(draft);
1474
+ },
1475
+ children: [
1476
+ /* @__PURE__ */ jsx11("label", { className: "chatai-visually-hidden", htmlFor: "chatai-message-input", children: "Message" }),
1477
+ /* @__PURE__ */ jsx11(
1478
+ "input",
1479
+ {
1480
+ id: "chatai-message-input",
1481
+ value: draft,
1482
+ onInput: (event) => setDraft(event.currentTarget.value),
1483
+ placeholder: "Or type a question\u2026",
1484
+ maxLength: 4e3,
1485
+ disabled: busy
1486
+ }
1487
+ ),
1488
+ /* @__PURE__ */ jsx11("button", { type: "submit", disabled: busy || !draft.trim(), "aria-label": "Send message", children: "\u2191" })
1489
+ ]
1490
+ }
1491
+ )
1492
+ ] }) : companionCanvas ? /* @__PURE__ */ jsxs10(Fragment4, { children: [
1493
+ /* @__PURE__ */ jsx11(
1494
+ VoiceCompanionCanvas,
1495
+ {
1496
+ assistantName: state.config?.name ?? "Assistant",
1497
+ welcomeMessage: state.config?.welcomeMessage,
1498
+ voiceOffered,
1499
+ onStart: () => void controller.startVoice()
1500
+ }
1501
+ ),
1502
+ state.messages.length > 0 ? /* @__PURE__ */ jsx11(
1503
+ "div",
1504
+ {
1505
+ ref: transcriptRef,
1506
+ className: "chatai-transcript chatai-companion-history",
1507
+ "aria-live": "polite",
1508
+ children: state.messages.map((message, index) => {
1509
+ const isVoice = message.modality === "voice";
1510
+ return /* @__PURE__ */ jsxs10(
1511
+ "article",
1512
+ {
1513
+ className: `chatai-message ${message.role}${isVoice ? " is-voice" : ""}`,
1514
+ children: [
1515
+ isVoice ? /* @__PURE__ */ jsx11("span", { className: "chatai-voice-tag", children: /* @__PURE__ */ jsx11(VoiceGlyph, {}) }) : null,
1516
+ message.role === "assistant" && !isVoice ? message.content ? /* @__PURE__ */ jsx11(MarkdownMessage, { content: message.content }) : null : /* @__PURE__ */ jsx11("p", { className: "chatai-user-text", children: message.content })
1517
+ ]
1518
+ },
1519
+ `${message.role}-${index}`
1520
+ );
1521
+ })
1522
+ }
1523
+ ) : null,
1524
+ /* @__PURE__ */ jsxs10(
1525
+ "form",
1526
+ {
1527
+ className: "chatai-composer",
1528
+ onSubmit: (event) => {
1529
+ event.preventDefault();
1530
+ send(draft);
1531
+ },
1532
+ children: [
1533
+ /* @__PURE__ */ jsx11("label", { className: "chatai-visually-hidden", htmlFor: "chatai-message-input", children: "Message" }),
1534
+ /* @__PURE__ */ jsx11(
1535
+ "input",
1536
+ {
1537
+ id: "chatai-message-input",
1538
+ value: draft,
1539
+ onInput: (event) => setDraft(event.currentTarget.value),
1540
+ placeholder: "Or type a message\u2026",
1541
+ maxLength: 4e3,
1542
+ disabled: busy
1543
+ }
1544
+ ),
1545
+ /* @__PURE__ */ jsx11("button", { type: "submit", disabled: busy || !draft.trim(), "aria-label": "Send message", children: "\u2191" })
1546
+ ]
1547
+ }
1548
+ )
1549
+ ] }) : /* @__PURE__ */ jsxs10(Fragment4, { children: [
1550
+ /* @__PURE__ */ jsxs10(
1551
+ "div",
1552
+ {
1553
+ ref: transcriptRef,
1554
+ className: "chatai-transcript",
1555
+ "aria-live": voiceOn ? "off" : "polite",
1556
+ children: [
1557
+ state.config?.welcomeMessage ? /* @__PURE__ */ jsx11("article", { className: "chatai-message assistant", children: /* @__PURE__ */ jsx11(MarkdownMessage, { content: state.config.welcomeMessage }) }) : null,
1558
+ questions.length > 0 && state.messages.length === 0 ? /* @__PURE__ */ jsx11("div", { className: "chatai-prompts", children: questions.map((question) => /* @__PURE__ */ jsx11(
1559
+ "button",
1560
+ {
1561
+ type: "button",
1562
+ onClick: () => send(question),
1563
+ disabled: busy,
1564
+ children: question
1565
+ },
1566
+ question
1567
+ )) }) : null,
1568
+ state.messages.map((message, index) => {
1569
+ const isLast = index === state.messages.length - 1;
1570
+ const isStreamingPlaceholder = showTyping && isLast && message.role === "assistant";
1571
+ const isStreamingContent = streaming && isLast && message.role === "assistant" && Boolean(message.content);
1572
+ const isVoice = message.modality === "voice";
1573
+ return /* @__PURE__ */ jsxs10(
1574
+ "article",
1575
+ {
1576
+ className: `chatai-message ${message.role}${isVoice ? " is-voice" : ""}${message.live ? " is-live" : ""}`,
1577
+ children: [
1578
+ isVoice ? /* @__PURE__ */ jsxs10("span", { className: "chatai-voice-tag", children: [
1579
+ /* @__PURE__ */ jsx11(VoiceGlyph, {}),
1580
+ /* @__PURE__ */ jsx11("span", { className: "chatai-visually-hidden", children: message.role === "user" ? "You said:" : "Assistant said:" })
1581
+ ] }) : null,
1582
+ isStreamingPlaceholder ? /* @__PURE__ */ jsx11(TypingIndicator, {}) : message.role === "assistant" && !isVoice ? message.content ? /* @__PURE__ */ jsx11(MarkdownMessage, { content: message.content, streaming: isStreamingContent }) : /* @__PURE__ */ jsx11("p", { children: streaming ? "Thinking\u2026" : "" }) : /* @__PURE__ */ jsx11("p", { className: "chatai-user-text", children: message.content }),
1583
+ message.interrupted ? /* @__PURE__ */ jsx11("p", { className: "chatai-voice-note", children: "Interrupted" }) : null,
1584
+ message.role === "assistant" && message.id ? /* @__PURE__ */ jsxs10("div", { className: "chatai-feedback", children: [
1585
+ /* @__PURE__ */ jsx11("span", { children: "Was this helpful?" }),
1586
+ /* @__PURE__ */ jsx11(
1587
+ "button",
1588
+ {
1589
+ type: "button",
1590
+ "aria-label": "Mark response helpful",
1591
+ "aria-pressed": message.feedback === "positive",
1592
+ onClick: () => rate(message.id, "positive"),
1593
+ children: /* @__PURE__ */ jsx11(ThumbUpGlyph, {})
1594
+ }
1595
+ ),
1596
+ /* @__PURE__ */ jsx11(
1597
+ "button",
1598
+ {
1599
+ type: "button",
1600
+ "aria-label": "Mark response not helpful",
1601
+ "aria-pressed": message.feedback === "negative",
1602
+ onClick: () => rate(message.id, "negative"),
1603
+ children: /* @__PURE__ */ jsx11(ThumbDownGlyph, {})
1604
+ }
1605
+ )
1606
+ ] }) : null
1607
+ ]
1608
+ },
1609
+ `${message.role}-${index}`
1610
+ );
1611
+ }),
1612
+ state.error ? /* @__PURE__ */ jsxs10("div", { className: "chatai-error", role: "alert", children: [
1613
+ /* @__PURE__ */ jsx11("p", { children: state.error }),
1614
+ /* @__PURE__ */ jsx11("button", { type: "button", className: "chatai-retry", onClick: retry, disabled: busy, children: "Retry" })
1615
+ ] }) : null
1616
+ ]
1617
+ }
1618
+ ),
1619
+ voiceOffered && state.voice.consentPending ? /* @__PURE__ */ jsx11(
1620
+ VoiceConsent,
1621
+ {
1622
+ onAccept: () => void controller.acceptRecordingConsent(),
1623
+ onCancel: () => {
1624
+ controller.declineRecordingConsent();
1625
+ panelRef.current?.querySelector("#chatai-message-input")?.focus();
1626
+ }
1627
+ }
1628
+ ) : null,
1629
+ voiceOffered && appearance.experience === "classic" ? /* @__PURE__ */ jsx11(
1630
+ VoiceExperience,
1631
+ {
1632
+ appearance,
1633
+ assistantName: state.config?.name ?? "Assistant",
1634
+ voice: state.voice,
1635
+ messages: state.messages,
1636
+ levels: () => controller.voiceLevels(),
1637
+ captionsOpen,
1638
+ ...voiceHandlers
1639
+ }
1640
+ ) : null,
1641
+ /* @__PURE__ */ jsxs10(
1642
+ "form",
1643
+ {
1644
+ className: "chatai-composer",
1645
+ onSubmit: (event) => {
1646
+ event.preventDefault();
1647
+ send(draft);
1648
+ },
1649
+ children: [
1650
+ /* @__PURE__ */ jsx11("label", { className: "chatai-visually-hidden", htmlFor: "chatai-message-input", children: "Message" }),
1651
+ /* @__PURE__ */ jsx11(
1652
+ "input",
1653
+ {
1654
+ id: "chatai-message-input",
1655
+ value: draft,
1656
+ onInput: (event) => setDraft(event.currentTarget.value),
1657
+ placeholder: voiceOn ? "Voice is on \u2014 end it to type" : "Ask a question\u2026",
1658
+ maxLength: 4e3,
1659
+ disabled: busy
1660
+ }
1661
+ ),
1662
+ voiceOffered && !isDock && !isGuided ? /* @__PURE__ */ jsx11(
1663
+ "button",
1664
+ {
1665
+ type: "button",
1666
+ className: `chatai-mic${voiceOn ? " is-active" : ""}`,
1667
+ onClick: toggleVoice,
1668
+ disabled: streaming,
1669
+ "aria-pressed": voiceOn,
1670
+ "aria-label": voiceOn ? "End voice conversation" : "Start voice conversation",
1671
+ title: voiceOn ? "End voice" : "Talk instead",
1672
+ children: /* @__PURE__ */ jsx11(MicGlyph, { off: voiceOn })
1673
+ }
1674
+ ) : null,
1675
+ /* @__PURE__ */ jsx11("button", { type: "submit", disabled: busy || !draft.trim(), "aria-label": "Send message", children: "\u2191" })
1676
+ ]
1677
+ }
1678
+ )
1679
+ ] })
638
1680
  ]
639
1681
  }
640
1682
  ) : null,
641
- /* @__PURE__ */ jsx3(
642
- "button",
643
- {
644
- ref: launcherRef,
645
- type: "button",
646
- className: "chatai-launcher",
647
- onClick: togglePanel,
648
- "aria-label": open || closing ? "Close chat" : "Open chat",
649
- "aria-expanded": open && !closing,
650
- "aria-haspopup": "dialog",
651
- children: settings.iconUrl ? /* @__PURE__ */ jsx3("img", { src: settings.iconUrl, alt: "" }) : /* @__PURE__ */ jsx3(ChatGlyph, {})
652
- }
653
- )
1683
+ /* @__PURE__ */ jsxs10("div", { className: "chatai-launch-row", children: [
1684
+ voiceOffered && isDock ? /* @__PURE__ */ jsx11(VoiceDockTalk, { open: dockOpen, onOpen: openDock, onClose: closeDock }) : null,
1685
+ /* @__PURE__ */ jsx11(
1686
+ "button",
1687
+ {
1688
+ ref: launcherRef,
1689
+ type: "button",
1690
+ className: "chatai-launcher",
1691
+ onClick: togglePanel,
1692
+ "aria-label": open || closing ? "Close chat" : "Open chat",
1693
+ "aria-expanded": open && !closing,
1694
+ "aria-haspopup": "dialog",
1695
+ children: settings.iconUrl ? /* @__PURE__ */ jsx11("img", { src: settings.iconUrl, alt: "" }) : /* @__PURE__ */ jsx11(ChatGlyph, {})
1696
+ }
1697
+ )
1698
+ ] })
654
1699
  ]
655
1700
  }
656
1701
  );
657
1702
  }
658
1703
 
659
1704
  // src/styles.generated.ts
660
- var styles = ':host {\n all: initial;\n}\n\n.chatai-widget {\n --chatai-accent: #0f766e;\n --chatai-ink: #14241e;\n --chatai-surface: #f6f6f0;\n --chatai-panel: #fffef9;\n --chatai-muted: #6d766f;\n --chatai-border: #d9ddd7;\n display: flex;\n width: fit-content;\n max-width: calc(100vw - 32px);\n flex-direction: column;\n align-items: flex-end;\n position: fixed;\n z-index: 2147483647;\n bottom: 20px;\n font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", sans-serif;\n color: var(--chatai-ink);\n}\n\n.chatai-widget.position-right {\n right: 20px;\n align-items: flex-end;\n}\n\n.chatai-widget.position-left {\n left: 20px;\n align-items: flex-start;\n}\n\n.chatai-widget.layout-contained {\n position: absolute;\n z-index: 1;\n max-width: 100%;\n}\n\n.chatai-widget-host-contained {\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n}\n\n.chatai-widget.layout-contained .chatai-panel {\n width: min(380px, 100%);\n height: min(570px, calc(100% - 70px));\n}\n\n.chatai-widget.layout-contained.position-right {\n right: 12px;\n}\n\n.chatai-widget.layout-contained.position-left {\n left: 12px;\n}\n\n.chatai-widget.theme-dark {\n --chatai-ink: #ecf4ec;\n --chatai-surface: #17231d;\n --chatai-panel: #101a14;\n --chatai-muted: #a9b8ad;\n --chatai-border: #2d4135;\n}\n\n.chatai-widget *,\n.chatai-widget *::before,\n.chatai-widget *::after {\n box-sizing: border-box;\n}\n\n.chatai-launcher {\n display: grid;\n flex-shrink: 0;\n width: 56px;\n height: 56px;\n padding: 0;\n place-items: center;\n border: 0;\n border-radius: 50% 50% 14% 50%;\n background: var(--chatai-accent);\n color: white;\n cursor: pointer;\n box-shadow: 0 12px 28px rgb(20 36 30 / 26%);\n transition: transform 160ms ease, box-shadow 160ms ease;\n}\n\n.chatai-widget.position-left .chatai-launcher {\n border-radius: 50% 50% 50% 14%;\n}\n\n.chatai-launcher[aria-expanded="true"] {\n transform: rotate(8deg) scale(0.96);\n}\n\n.chatai-launcher:hover {\n transform: translateY(-2px) rotate(-3deg);\n box-shadow: 0 16px 32px rgb(20 36 30 / 34%);\n}\n\n.chatai-launcher:focus-visible,\n.chatai-close:focus-visible,\n.chatai-prompts button:focus-visible,\n.chatai-composer input:focus-visible,\n.chatai-composer button:focus-visible,\n.chatai-retry:focus-visible {\n outline: 3px solid color-mix(in srgb, var(--chatai-accent), white 55%);\n outline-offset: 2px;\n}\n\n.chatai-launcher svg,\n.chatai-launcher img {\n width: 24px;\n height: 24px;\n}\n\n.chatai-launcher img {\n border-radius: 50%;\n object-fit: cover;\n}\n\n.chatai-panel {\n display: flex;\n width: min(380px, calc(100vw - 32px));\n height: min(570px, calc(100dvh - 104px));\n margin-bottom: 14px;\n flex-direction: column;\n flex-shrink: 0;\n overflow: hidden;\n border: 1px solid var(--chatai-border);\n border-radius: 24px 24px 8px 24px;\n background: var(--chatai-panel);\n box-shadow: 0 24px 70px rgb(20 36 30 / 24%);\n transform-origin: bottom right;\n animation: chatai-panel-in 180ms ease-out;\n}\n\n.chatai-widget.position-left .chatai-panel {\n border-radius: 24px 24px 24px 8px;\n transform-origin: bottom left;\n}\n\n.chatai-panel.is-closing {\n animation: chatai-panel-out 140ms ease-in forwards;\n}\n\n@keyframes chatai-panel-in {\n from {\n opacity: 0;\n transform: translateY(10px) scale(0.98);\n }\n\n to {\n opacity: 1;\n transform: none;\n }\n}\n\n@keyframes chatai-panel-out {\n from {\n opacity: 1;\n transform: none;\n }\n\n to {\n opacity: 0;\n transform: translateY(8px) scale(0.98);\n }\n}\n\n.chatai-header {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n padding: 20px 20px 16px;\n border-bottom: 1px solid var(--chatai-border);\n background: linear-gradient(135deg, color-mix(in srgb, var(--chatai-accent), var(--chatai-panel) 90%), var(--chatai-panel));\n}\n\n.chatai-widget.position-left .chatai-header {\n background: linear-gradient(225deg, color-mix(in srgb, var(--chatai-accent), var(--chatai-panel) 90%), var(--chatai-panel));\n}\n\n.chatai-kicker {\n margin: 0 0 5px;\n color: var(--chatai-muted);\n font-size: 10px;\n font-weight: 750;\n letter-spacing: 0.14em;\n text-transform: uppercase;\n}\n\n.chatai-header h2 {\n margin: 0;\n font-size: 18px;\n letter-spacing: -0.03em;\n}\n\n.chatai-close {\n display: grid;\n width: 30px;\n height: 30px;\n place-items: center;\n border: 1px solid var(--chatai-border);\n border-radius: 50%;\n background: transparent;\n color: var(--chatai-ink);\n cursor: pointer;\n font-size: 22px;\n line-height: 1;\n}\n\n.chatai-transcript {\n display: flex;\n flex: 1;\n flex-direction: column;\n gap: 12px;\n overflow-y: auto;\n padding: 18px;\n background:\n radial-gradient(circle at 95% 4%, color-mix(in srgb, var(--chatai-accent), transparent 90%), transparent 30%),\n var(--chatai-surface);\n}\n\n.chatai-widget.position-left .chatai-transcript {\n background:\n radial-gradient(circle at 5% 4%, color-mix(in srgb, var(--chatai-accent), transparent 90%), transparent 30%),\n var(--chatai-surface);\n}\n\n.chatai-message {\n max-width: 87%;\n padding: 12px 13px;\n border-radius: 15px;\n font-size: 14px;\n line-height: 1.45;\n}\n\n.chatai-message p,\n.chatai-user-text {\n margin: 0;\n white-space: pre-wrap;\n}\n\n.chatai-message.assistant {\n align-self: flex-start;\n border: 1px solid var(--chatai-border);\n border-radius: 5px 15px 15px;\n background: var(--chatai-panel);\n}\n\n.chatai-message.user {\n align-self: flex-end;\n border-radius: 15px 5px 15px 15px;\n background: var(--chatai-accent);\n color: #fff;\n}\n\n.chatai-md {\n font-size: 14px;\n line-height: 1.5;\n}\n\n.chatai-md-p {\n margin: 0;\n white-space: pre-wrap;\n}\n\n.chatai-md-p + .chatai-md-p,\n.chatai-md-p + .chatai-md-ul,\n.chatai-md-p + .chatai-md-ol,\n.chatai-md-p + .chatai-md-pre,\n.chatai-md-ul + .chatai-md-p,\n.chatai-md-ol + .chatai-md-p,\n.chatai-md-pre + .chatai-md-p {\n margin-top: 0.55em;\n}\n\n.chatai-md-ul,\n.chatai-md-ol {\n margin: 0.45em 0;\n padding-left: 1.25em;\n}\n\n.chatai-md-ul {\n list-style: disc;\n}\n\n.chatai-md-ol {\n list-style: decimal;\n}\n\n.chatai-md-link {\n color: var(--chatai-accent);\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n\n.chatai-md-link:focus-visible {\n outline: 2px solid var(--chatai-accent);\n outline-offset: 2px;\n border-radius: 2px;\n}\n\n.chatai-md-code {\n border-radius: 4px;\n background: color-mix(in srgb, var(--chatai-border), transparent 55%);\n padding: 0.1em 0.35em;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 0.85em;\n}\n\n.chatai-md-pre {\n margin: 0.55em 0;\n overflow-x: auto;\n border-radius: 8px;\n background: color-mix(in srgb, var(--chatai-border), transparent 55%);\n padding: 0.65em 0.75em;\n font-size: 0.85em;\n}\n\n.chatai-md-pre code {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n white-space: pre;\n}\n\n.chatai-md-caret {\n display: inline-block;\n width: 2px;\n height: 0.9em;\n margin-left: 2px;\n vertical-align: middle;\n background: var(--chatai-ink);\n animation: chatai-caret-pulse 1s ease-in-out infinite;\n}\n\n@keyframes chatai-caret-pulse {\n 0%,\n 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0.2;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .chatai-md-caret {\n animation: none;\n opacity: 0.7;\n }\n}\n\n.chatai-prompts {\n display: flex;\n flex-wrap: wrap;\n gap: 7px;\n}\n\n.chatai-prompts button {\n border: 1px solid color-mix(in srgb, var(--chatai-accent), var(--chatai-border) 60%);\n border-radius: 999px;\n background: transparent;\n color: var(--chatai-ink);\n cursor: pointer;\n font: inherit;\n font-size: 12px;\n line-height: 1.25;\n padding: 8px 10px;\n text-align: left;\n}\n\n.chatai-feedback {\n display: flex;\n align-items: center;\n gap: 5px;\n margin-top: 10px;\n padding-top: 9px;\n border-top: 1px solid var(--chatai-border);\n color: var(--chatai-muted);\n font-size: 11px;\n}\n\n.chatai-feedback span {\n margin-right: 2px;\n}\n\n.chatai-feedback button {\n display: inline-grid;\n place-items: center;\n width: 25px;\n height: 25px;\n border: 1px solid var(--chatai-border);\n border-radius: 6px;\n background: transparent;\n color: var(--chatai-ink);\n cursor: pointer;\n font: inherit;\n line-height: 1;\n padding: 0;\n}\n\n.chatai-feedback button svg {\n width: 13px;\n height: 13px;\n}\n\n.chatai-feedback button[aria-pressed="true"] {\n border-color: var(--chatai-accent);\n background: color-mix(in srgb, var(--chatai-accent), transparent 90%);\n color: var(--chatai-accent);\n}\n\n.chatai-error {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n margin: 0;\n padding: 10px 12px;\n border: 1px solid color-mix(in srgb, #b42318, var(--chatai-border) 55%);\n border-radius: 12px;\n background: color-mix(in srgb, #b42318, transparent 92%);\n color: #b42318;\n font-size: 12px;\n text-align: center;\n}\n\n.chatai-error p {\n margin: 0;\n line-height: 1.4;\n}\n\n.chatai-retry {\n border: 1px solid color-mix(in srgb, #b42318, var(--chatai-border) 40%);\n border-radius: 8px;\n background: var(--chatai-panel);\n color: #b42318;\n cursor: pointer;\n font: inherit;\n font-size: 12px;\n font-weight: 600;\n padding: 6px 12px;\n}\n\n.chatai-retry:disabled {\n cursor: not-allowed;\n opacity: 0.48;\n}\n\n.chatai-typing {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n min-height: 1.2em;\n}\n\n.chatai-typing span {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: var(--chatai-muted);\n animation: chatai-typing-dot 1s ease-in-out infinite;\n}\n\n.chatai-typing span:nth-child(2) {\n animation-delay: 0.15s;\n}\n\n.chatai-typing span:nth-child(3) {\n animation-delay: 0.3s;\n}\n\n@keyframes chatai-typing-dot {\n 0%,\n 80%,\n 100% {\n opacity: 0.35;\n transform: translateY(0);\n }\n\n 40% {\n opacity: 1;\n transform: translateY(-2px);\n }\n}\n\n.chatai-composer {\n display: flex;\n gap: 8px;\n padding: 12px;\n border-top: 1px solid var(--chatai-border);\n background: var(--chatai-panel);\n}\n\n.chatai-composer input {\n min-width: 0;\n flex: 1;\n border: 1px solid var(--chatai-border);\n border-radius: 10px;\n background: transparent;\n color: var(--chatai-ink);\n font: inherit;\n font-size: 14px;\n padding: 10px 11px;\n}\n\n.chatai-composer button {\n width: 40px;\n border: 0;\n border-radius: 10px;\n background: var(--chatai-accent);\n color: white;\n cursor: pointer;\n font-size: 18px;\n}\n\n.chatai-composer button:disabled,\n.chatai-prompts button:disabled {\n cursor: not-allowed;\n opacity: 0.48;\n}\n\n.chatai-composer input:disabled {\n cursor: not-allowed;\n opacity: 0.7;\n}\n\n.chatai-composer .chatai-mic {\n display: grid;\n place-items: center;\n border: 1px solid var(--chatai-border);\n background: transparent;\n color: var(--chatai-ink);\n}\n\n.chatai-composer .chatai-mic svg {\n width: 18px;\n height: 18px;\n}\n\n.chatai-composer .chatai-mic.is-active {\n border-color: #b42318;\n background: #b42318;\n color: #fff;\n}\n\n.chatai-voice-bar {\n display: flex;\n align-items: center;\n gap: 10px;\n min-height: 44px;\n padding: 8px 14px;\n border-top: 1px solid var(--chatai-border);\n background: color-mix(in srgb, var(--chatai-accent), var(--chatai-panel) 92%);\n font-size: 13px;\n}\n\n.chatai-voice-bar.is-error {\n flex-wrap: wrap;\n justify-content: center;\n background: color-mix(in srgb, #b42318, transparent 92%);\n color: #b42318;\n text-align: center;\n}\n\n.chatai-voice-bar.is-notice {\n flex-wrap: wrap;\n justify-content: center;\n text-align: center;\n}\n\n.chatai-voice-error {\n width: 100%;\n margin: 0;\n font-size: 12px;\n line-height: 1.4;\n}\n\n.chatai-voice-actions {\n display: flex;\n gap: 8px;\n}\n\n.chatai-voice-consent {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 12px 14px;\n border-top: 1px solid var(--chatai-border);\n background: color-mix(in srgb, var(--chatai-accent), var(--chatai-panel) 92%);\n font-size: 13px;\n line-height: 1.45;\n}\n\n.chatai-voice-consent:focus-visible {\n outline: 2px solid var(--chatai-accent);\n outline-offset: -2px;\n}\n\n.chatai-voice-consent-title {\n margin: 0;\n font-weight: 650;\n}\n\n.chatai-voice-consent-text {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 12px;\n}\n\n.chatai-consent-accept,\n.chatai-consent-cancel {\n min-height: 36px;\n padding: 0 14px;\n border-radius: 8px;\n font: inherit;\n font-size: 12px;\n font-weight: 600;\n cursor: pointer;\n}\n\n.chatai-consent-accept {\n border: 0;\n background: var(--chatai-accent);\n color: #fff;\n}\n\n.chatai-consent-cancel {\n border: 1px solid var(--chatai-border);\n background: var(--chatai-panel);\n color: var(--chatai-ink);\n}\n\n.chatai-voice-label {\n font-weight: 650;\n}\n\n.chatai-voice-meta {\n margin-left: auto;\n color: var(--chatai-muted);\n font-size: 11px;\n}\n\n.chatai-wave {\n display: inline-flex;\n align-items: center;\n gap: 3px;\n height: 22px;\n}\n\n.chatai-wave span {\n display: block;\n width: 4px;\n height: 22px;\n border-radius: 2px;\n background: var(--chatai-accent);\n transform: scaleY(0.22);\n transition: transform 80ms linear;\n}\n\n.chatai-voice-bar[data-phase="requesting_mic"] .chatai-wave span,\n.chatai-voice-bar[data-phase="connecting"] .chatai-wave span,\n.chatai-voice-bar[data-phase="processing"] .chatai-wave span {\n animation: chatai-wave-idle 1.1s ease-in-out infinite;\n}\n\n.chatai-wave span:nth-child(2) {\n animation-delay: 0.1s;\n}\n\n.chatai-wave span:nth-child(3) {\n animation-delay: 0.2s;\n}\n\n.chatai-wave span:nth-child(4) {\n animation-delay: 0.3s;\n}\n\n.chatai-wave span:nth-child(5) {\n animation-delay: 0.4s;\n}\n\n.chatai-voice-bar[data-phase="interrupted"] .chatai-wave span {\n background: #b54708;\n}\n\n.chatai-voice-bar[data-phase="reconnecting"] .chatai-wave span {\n background: var(--chatai-muted);\n}\n\n@keyframes chatai-wave-idle {\n 0%,\n 100% {\n transform: scaleY(0.22);\n }\n\n 50% {\n transform: scaleY(0.6);\n }\n}\n\n.chatai-voice-tag {\n display: inline-flex;\n float: right;\n margin: -2px -3px 2px 8px;\n opacity: 0.65;\n}\n\n.chatai-voice-tag svg {\n width: 13px;\n height: 13px;\n}\n\n.chatai-message.is-live {\n opacity: 0.85;\n}\n\n.chatai-message.is-live .chatai-user-text::after {\n content: "\u2026";\n}\n\n.chatai-voice-note {\n margin-top: 6px;\n color: var(--chatai-muted);\n font-size: 11px;\n font-style: italic;\n}\n\n.chatai-message.user .chatai-voice-note {\n color: rgb(255 255 255 / 80%);\n}\n\n.chatai-visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0 0 0 0);\n white-space: nowrap;\n}\n\n@media (max-width: 480px) {\n .chatai-widget {\n bottom: 12px;\n }\n\n .chatai-widget.position-right {\n right: 12px;\n }\n\n .chatai-widget.position-left {\n left: 12px;\n }\n\n .chatai-panel {\n width: calc(100vw - 24px);\n height: min(600px, calc(100dvh - 88px));\n }\n\n .chatai-composer button {\n min-width: 44px;\n min-height: 44px;\n }\n\n .chatai-composer input {\n font-size: 16px;\n }\n\n .chatai-retry {\n min-height: 40px;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .chatai-launcher,\n .chatai-launcher:hover,\n .chatai-launcher[aria-expanded="true"] {\n transition: none;\n transform: none;\n }\n\n .chatai-panel,\n .chatai-panel.is-closing {\n animation: none;\n }\n\n .chatai-typing span {\n animation: none;\n opacity: 0.7;\n }\n\n .chatai-wave span,\n .chatai-voice-bar .chatai-wave span {\n animation: none;\n transition: none;\n transform: scaleY(0.45);\n }\n}\n';
1705
+ var styles = ':host {\n all: initial;\n}\n\n.chatai-widget {\n --chatai-accent: #0f766e;\n --chatai-ink: #14241e;\n --chatai-surface: #f6f6f0;\n --chatai-panel: #fffef9;\n --chatai-muted: #6d766f;\n --chatai-border: #d9ddd7;\n --chatai-safe-bottom: env(safe-area-inset-bottom, 0px);\n --chatai-safe-top: env(safe-area-inset-top, 0px);\n --chatai-safe-left: env(safe-area-inset-left, 0px);\n --chatai-safe-right: env(safe-area-inset-right, 0px);\n display: flex;\n width: fit-content;\n max-width: calc(100vw - 32px - var(--chatai-safe-left) - var(--chatai-safe-right));\n flex-direction: column;\n align-items: flex-end;\n position: fixed;\n z-index: 2147483647;\n bottom: max(20px, var(--chatai-safe-bottom));\n font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", sans-serif;\n color: var(--chatai-ink);\n}\n\n.chatai-widget.position-right {\n right: max(20px, var(--chatai-safe-right));\n align-items: flex-end;\n}\n\n.chatai-widget.position-left {\n left: max(20px, var(--chatai-safe-left));\n align-items: flex-start;\n}\n\n.chatai-widget.layout-contained {\n position: absolute;\n z-index: 1;\n max-width: 100%;\n}\n\n.chatai-widget-host-contained {\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n}\n\n.chatai-widget.layout-contained .chatai-panel {\n width: min(380px, 100%);\n height: min(570px, calc(100% - 70px));\n}\n\n.chatai-widget.layout-contained.position-right {\n right: 12px;\n}\n\n.chatai-widget.layout-contained.position-left {\n left: 12px;\n}\n\n/* Side panel \u2014 tall edge sheet beside host page content (no page scrape / context claims). */\n.chatai-widget.experience-side-panel .chatai-panel {\n width: min(360px, calc(100vw - 24px - var(--chatai-safe-left) - var(--chatai-safe-right)));\n height: min(calc(100dvh - 88px - var(--chatai-safe-bottom) - var(--chatai-safe-top)), 860px);\n border-radius: 18px 18px 8px 18px;\n}\n\n.chatai-widget.experience-side-panel.position-left .chatai-panel {\n border-radius: 18px 18px 18px 8px;\n}\n\n.chatai-widget.experience-side-panel.layout-contained .chatai-panel {\n width: min(360px, 100%);\n height: min(calc(100% - 70px), 100%);\n}\n\n.chatai-widget.theme-dark {\n --chatai-ink: #ecf4ec;\n --chatai-surface: #17231d;\n --chatai-panel: #101a14;\n --chatai-muted: #a9b8ad;\n --chatai-border: #2d4135;\n}\n\n.chatai-widget *,\n.chatai-widget *::before,\n.chatai-widget *::after {\n box-sizing: border-box;\n}\n\n.chatai-launcher {\n display: grid;\n flex-shrink: 0;\n width: 56px;\n height: 56px;\n padding: 0;\n place-items: center;\n border: 0;\n border-radius: 50% 50% 14% 50%;\n background: var(--chatai-accent);\n color: white;\n cursor: pointer;\n box-shadow: 0 12px 28px rgb(20 36 30 / 26%);\n transition: transform 160ms ease, box-shadow 160ms ease;\n}\n\n.chatai-widget.position-left .chatai-launcher {\n border-radius: 50% 50% 50% 14%;\n}\n\n.chatai-launcher[aria-expanded="true"] {\n transform: rotate(8deg) scale(0.96);\n}\n\n.chatai-launcher:hover {\n transform: translateY(-2px) rotate(-3deg);\n box-shadow: 0 16px 32px rgb(20 36 30 / 34%);\n}\n\n.chatai-launcher:focus-visible,\n.chatai-close:focus-visible,\n.chatai-prompts button:focus-visible,\n.chatai-composer input:focus-visible,\n.chatai-composer button:focus-visible,\n.chatai-retry:focus-visible {\n outline: 3px solid color-mix(in srgb, var(--chatai-accent), white 55%);\n outline-offset: 2px;\n}\n\n.chatai-launcher svg,\n.chatai-launcher img {\n width: 24px;\n height: 24px;\n}\n\n.chatai-launcher img {\n border-radius: 50%;\n object-fit: cover;\n}\n\n.chatai-panel {\n display: flex;\n width: min(380px, calc(100vw - 32px - var(--chatai-safe-left) - var(--chatai-safe-right)));\n height: min(570px, calc(100dvh - 104px - var(--chatai-safe-bottom) - var(--chatai-safe-top)));\n margin-bottom: 14px;\n flex-direction: column;\n flex-shrink: 0;\n overflow: hidden;\n border: 1px solid var(--chatai-border);\n border-radius: 24px 24px 8px 24px;\n background: var(--chatai-panel);\n box-shadow: 0 24px 70px rgb(20 36 30 / 24%);\n transform-origin: bottom right;\n animation: chatai-panel-in 180ms ease-out;\n}\n\n.chatai-widget.position-left .chatai-panel {\n border-radius: 24px 24px 24px 8px;\n transform-origin: bottom left;\n}\n\n.chatai-panel.is-closing {\n animation: chatai-panel-out 140ms ease-in forwards;\n}\n\n@keyframes chatai-panel-in {\n from {\n opacity: 0;\n transform: translateY(10px) scale(0.98);\n }\n\n to {\n opacity: 1;\n transform: none;\n }\n}\n\n@keyframes chatai-panel-out {\n from {\n opacity: 1;\n transform: none;\n }\n\n to {\n opacity: 0;\n transform: translateY(8px) scale(0.98);\n }\n}\n\n.chatai-header {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n padding: 20px 20px 16px;\n border-bottom: 1px solid var(--chatai-border);\n background: linear-gradient(135deg, color-mix(in srgb, var(--chatai-accent), var(--chatai-panel) 90%), var(--chatai-panel));\n}\n\n.chatai-widget.position-left .chatai-header {\n background: linear-gradient(225deg, color-mix(in srgb, var(--chatai-accent), var(--chatai-panel) 90%), var(--chatai-panel));\n}\n\n.chatai-kicker {\n margin: 0 0 5px;\n color: var(--chatai-muted);\n font-size: 10px;\n font-weight: 750;\n letter-spacing: 0.14em;\n text-transform: uppercase;\n}\n\n.chatai-header h2 {\n margin: 0;\n font-size: 18px;\n letter-spacing: -0.03em;\n}\n\n.chatai-close {\n display: grid;\n width: 30px;\n height: 30px;\n place-items: center;\n border: 1px solid var(--chatai-border);\n border-radius: 50%;\n background: transparent;\n color: var(--chatai-ink);\n cursor: pointer;\n font-size: 22px;\n line-height: 1;\n}\n\n.chatai-transcript {\n display: flex;\n flex: 1;\n flex-direction: column;\n gap: 12px;\n overflow-y: auto;\n padding: 18px;\n background:\n radial-gradient(circle at 95% 4%, color-mix(in srgb, var(--chatai-accent), transparent 90%), transparent 30%),\n var(--chatai-surface);\n}\n\n.chatai-widget.position-left .chatai-transcript {\n background:\n radial-gradient(circle at 5% 4%, color-mix(in srgb, var(--chatai-accent), transparent 90%), transparent 30%),\n var(--chatai-surface);\n}\n\n.chatai-message {\n max-width: 87%;\n padding: 12px 13px;\n border-radius: 15px;\n font-size: 14px;\n line-height: 1.45;\n}\n\n.chatai-message p,\n.chatai-user-text {\n margin: 0;\n white-space: pre-wrap;\n}\n\n.chatai-message.assistant {\n align-self: flex-start;\n border: 1px solid var(--chatai-border);\n border-radius: 5px 15px 15px;\n background: var(--chatai-panel);\n}\n\n.chatai-message.user {\n align-self: flex-end;\n border-radius: 15px 5px 15px 15px;\n background: var(--chatai-accent);\n color: #fff;\n}\n\n.chatai-md {\n font-size: 14px;\n line-height: 1.5;\n}\n\n.chatai-md-p {\n margin: 0;\n white-space: pre-wrap;\n}\n\n.chatai-md-p + .chatai-md-p,\n.chatai-md-p + .chatai-md-ul,\n.chatai-md-p + .chatai-md-ol,\n.chatai-md-p + .chatai-md-pre,\n.chatai-md-ul + .chatai-md-p,\n.chatai-md-ol + .chatai-md-p,\n.chatai-md-pre + .chatai-md-p {\n margin-top: 0.55em;\n}\n\n.chatai-md-ul,\n.chatai-md-ol {\n margin: 0.45em 0;\n padding-left: 1.25em;\n}\n\n.chatai-md-ul {\n list-style: disc;\n}\n\n.chatai-md-ol {\n list-style: decimal;\n}\n\n.chatai-md-link {\n color: var(--chatai-accent);\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n\n.chatai-md-link:focus-visible {\n outline: 2px solid var(--chatai-accent);\n outline-offset: 2px;\n border-radius: 2px;\n}\n\n.chatai-md-code {\n border-radius: 4px;\n background: color-mix(in srgb, var(--chatai-border), transparent 55%);\n padding: 0.1em 0.35em;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 0.85em;\n}\n\n.chatai-md-pre {\n margin: 0.55em 0;\n overflow-x: auto;\n border-radius: 8px;\n background: color-mix(in srgb, var(--chatai-border), transparent 55%);\n padding: 0.65em 0.75em;\n font-size: 0.85em;\n}\n\n.chatai-md-pre code {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n white-space: pre;\n}\n\n.chatai-md-caret {\n display: inline-block;\n width: 2px;\n height: 0.9em;\n margin-left: 2px;\n vertical-align: middle;\n background: var(--chatai-ink);\n animation: chatai-caret-pulse 1s ease-in-out infinite;\n}\n\n@keyframes chatai-caret-pulse {\n 0%,\n 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0.2;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .chatai-md-caret {\n animation: none;\n opacity: 0.7;\n }\n}\n\n.chatai-prompts {\n display: flex;\n flex-wrap: wrap;\n gap: 7px;\n}\n\n.chatai-prompts button {\n border: 1px solid color-mix(in srgb, var(--chatai-accent), var(--chatai-border) 60%);\n border-radius: 999px;\n background: transparent;\n color: var(--chatai-ink);\n cursor: pointer;\n font: inherit;\n font-size: 12px;\n line-height: 1.25;\n padding: 8px 10px;\n text-align: left;\n}\n\n.chatai-feedback {\n display: flex;\n align-items: center;\n gap: 5px;\n margin-top: 10px;\n padding-top: 9px;\n border-top: 1px solid var(--chatai-border);\n color: var(--chatai-muted);\n font-size: 11px;\n}\n\n.chatai-feedback span {\n margin-right: 2px;\n}\n\n.chatai-feedback button {\n display: inline-grid;\n place-items: center;\n width: 25px;\n height: 25px;\n border: 1px solid var(--chatai-border);\n border-radius: 6px;\n background: transparent;\n color: var(--chatai-ink);\n cursor: pointer;\n font: inherit;\n line-height: 1;\n padding: 0;\n}\n\n.chatai-feedback button svg {\n width: 13px;\n height: 13px;\n}\n\n.chatai-feedback button[aria-pressed="true"] {\n border-color: var(--chatai-accent);\n background: color-mix(in srgb, var(--chatai-accent), transparent 90%);\n color: var(--chatai-accent);\n}\n\n.chatai-error {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n margin: 0;\n padding: 10px 12px;\n border: 1px solid color-mix(in srgb, #b42318, var(--chatai-border) 55%);\n border-radius: 12px;\n background: color-mix(in srgb, #b42318, transparent 92%);\n color: #b42318;\n font-size: 12px;\n text-align: center;\n}\n\n.chatai-error p {\n margin: 0;\n line-height: 1.4;\n}\n\n.chatai-retry {\n border: 1px solid color-mix(in srgb, #b42318, var(--chatai-border) 40%);\n border-radius: 8px;\n background: var(--chatai-panel);\n color: #b42318;\n cursor: pointer;\n font: inherit;\n font-size: 12px;\n font-weight: 600;\n padding: 6px 12px;\n}\n\n.chatai-retry:disabled {\n cursor: not-allowed;\n opacity: 0.48;\n}\n\n.chatai-typing {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n min-height: 1.2em;\n}\n\n.chatai-typing span {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: var(--chatai-muted);\n animation: chatai-typing-dot 1s ease-in-out infinite;\n}\n\n.chatai-typing span:nth-child(2) {\n animation-delay: 0.15s;\n}\n\n.chatai-typing span:nth-child(3) {\n animation-delay: 0.3s;\n}\n\n@keyframes chatai-typing-dot {\n 0%,\n 80%,\n 100% {\n opacity: 0.35;\n transform: translateY(0);\n }\n\n 40% {\n opacity: 1;\n transform: translateY(-2px);\n }\n}\n\n.chatai-composer {\n display: flex;\n gap: 8px;\n padding: 12px;\n border-top: 1px solid var(--chatai-border);\n background: var(--chatai-panel);\n}\n\n.chatai-composer input {\n min-width: 0;\n flex: 1;\n border: 1px solid var(--chatai-border);\n border-radius: 10px;\n background: transparent;\n color: var(--chatai-ink);\n font: inherit;\n font-size: 14px;\n padding: 10px 11px;\n}\n\n.chatai-composer button {\n width: 40px;\n border: 0;\n border-radius: 10px;\n background: var(--chatai-accent);\n color: white;\n cursor: pointer;\n font-size: 18px;\n}\n\n.chatai-composer button:disabled,\n.chatai-prompts button:disabled {\n cursor: not-allowed;\n opacity: 0.48;\n}\n\n.chatai-composer input:disabled {\n cursor: not-allowed;\n opacity: 0.7;\n}\n\n.chatai-composer .chatai-mic {\n display: grid;\n place-items: center;\n border: 1px solid var(--chatai-border);\n background: transparent;\n color: var(--chatai-ink);\n}\n\n.chatai-composer .chatai-mic svg {\n width: 18px;\n height: 18px;\n}\n\n.chatai-composer .chatai-mic.is-active {\n border-color: #b42318;\n background: #b42318;\n color: #fff;\n}\n\n.chatai-voice-bar {\n display: flex;\n align-items: center;\n gap: 10px;\n min-height: 44px;\n padding: 8px 14px;\n border-top: 1px solid var(--chatai-border);\n background: color-mix(in srgb, var(--chatai-accent), var(--chatai-panel) 92%);\n font-size: 13px;\n}\n\n.chatai-voice-bar.is-error {\n flex-wrap: wrap;\n justify-content: center;\n background: color-mix(in srgb, #b42318, transparent 92%);\n color: #b42318;\n text-align: center;\n}\n\n.chatai-voice-bar.is-notice {\n flex-wrap: wrap;\n justify-content: center;\n text-align: center;\n}\n\n.chatai-voice-error {\n width: 100%;\n margin: 0;\n font-size: 12px;\n line-height: 1.4;\n}\n\n.chatai-voice-actions {\n display: flex;\n gap: 8px;\n}\n\n.chatai-voice-consent {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 12px 14px;\n border-top: 1px solid var(--chatai-border);\n background: color-mix(in srgb, var(--chatai-accent), var(--chatai-panel) 92%);\n font-size: 13px;\n line-height: 1.45;\n}\n\n.chatai-voice-consent:focus-visible {\n outline: 2px solid var(--chatai-accent);\n outline-offset: -2px;\n}\n\n.chatai-voice-consent-title {\n margin: 0;\n font-weight: 650;\n}\n\n.chatai-voice-consent-text {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 12px;\n}\n\n.chatai-consent-accept,\n.chatai-consent-cancel {\n min-height: 36px;\n padding: 0 14px;\n border-radius: 8px;\n font: inherit;\n font-size: 12px;\n font-weight: 600;\n cursor: pointer;\n}\n\n.chatai-consent-accept {\n border: 0;\n background: var(--chatai-accent);\n color: #fff;\n}\n\n.chatai-consent-cancel {\n border: 1px solid var(--chatai-border);\n background: var(--chatai-panel);\n color: var(--chatai-ink);\n}\n\n.chatai-voice-label {\n font-weight: 650;\n}\n\n.chatai-voice-meta {\n margin-left: auto;\n color: var(--chatai-muted);\n font-size: 11px;\n}\n\n.chatai-wave {\n display: inline-flex;\n align-items: center;\n gap: 3px;\n height: 22px;\n}\n\n.chatai-wave span {\n display: block;\n width: 4px;\n height: 22px;\n border-radius: 2px;\n background: var(--chatai-accent);\n transform: scaleY(0.22);\n transition: transform 80ms linear;\n}\n\n.chatai-voice-bar[data-phase="requesting_mic"] .chatai-wave span,\n.chatai-voice-bar[data-phase="connecting"] .chatai-wave span,\n.chatai-voice-bar[data-phase="processing"] .chatai-wave span {\n animation: chatai-wave-idle 1.1s ease-in-out infinite;\n}\n\n.chatai-wave span:nth-child(2) {\n animation-delay: 0.1s;\n}\n\n.chatai-wave span:nth-child(3) {\n animation-delay: 0.2s;\n}\n\n.chatai-wave span:nth-child(4) {\n animation-delay: 0.3s;\n}\n\n.chatai-wave span:nth-child(5) {\n animation-delay: 0.4s;\n}\n\n.chatai-voice-bar[data-phase="interrupted"] .chatai-wave span {\n background: #b54708;\n}\n\n.chatai-voice-bar[data-phase="reconnecting"] .chatai-wave span {\n background: var(--chatai-muted);\n}\n\n@keyframes chatai-wave-idle {\n 0%,\n 100% {\n transform: scaleY(0.22);\n }\n\n 50% {\n transform: scaleY(0.6);\n }\n}\n\n.chatai-voice-tag {\n display: inline-flex;\n float: right;\n margin: -2px -3px 2px 8px;\n opacity: 0.65;\n}\n\n.chatai-voice-tag svg {\n width: 13px;\n height: 13px;\n}\n\n.chatai-message.is-live {\n opacity: 0.85;\n}\n\n.chatai-message.is-live .chatai-user-text::after {\n content: "\u2026";\n}\n\n.chatai-voice-note {\n margin-top: 6px;\n color: var(--chatai-muted);\n font-size: 11px;\n font-style: italic;\n}\n\n.chatai-message.user .chatai-voice-note {\n color: rgb(255 255 255 / 80%);\n}\n\n.chatai-visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0 0 0 0);\n white-space: nowrap;\n}\n\n/* Orb / Dock voice stage \u2014 replaces transcript + composer while Voice is active. */\n.chatai-voice-stage {\n --chatai-voice-accent: var(--chatai-accent);\n --chatai-orb-energy: 0;\n display: flex;\n flex: 1;\n flex-direction: column;\n align-items: center;\n gap: 10px;\n min-height: 0;\n padding: 18px 16px calc(14px + var(--chatai-safe-bottom));\n overflow: auto;\n overscroll-behavior: contain;\n text-align: center;\n -webkit-overflow-scrolling: touch;\n}\n\n.chatai-voice-label-short {\n display: none;\n}\n\n.chatai-voice-identity {\n display: flex;\n flex-direction: column;\n gap: 2px;\n margin: 0;\n}\n\n.chatai-voice-name {\n font-size: 17px;\n font-weight: 650;\n letter-spacing: -0.02em;\n}\n\n.chatai-orb {\n position: relative;\n width: 148px;\n height: 148px;\n margin: 8px 0 4px;\n flex-shrink: 0;\n}\n\n.chatai-orb-core,\n.chatai-orb-shine,\n.chatai-orb-shadow {\n position: absolute;\n inset: 0;\n border-radius: 48% 52% 57% 43% / 53% 42% 58% 47%;\n}\n\n.chatai-orb-core {\n background: radial-gradient(\n ellipse at 28% 20%,\n #fff8e8 0%,\n color-mix(in srgb, var(--chatai-voice-accent), #fff 55%) 26%,\n var(--chatai-voice-accent) 54%,\n color-mix(in srgb, var(--chatai-voice-accent), #1a1a12 55%) 82%\n );\n box-shadow:\n inset -12px -18px 22px rgb(20 36 30 / 42%),\n inset 4px 6px 16px rgb(255 255 255 / 42%);\n transform: scale(calc(0.96 + var(--chatai-orb-energy) * 0.12));\n transition: transform 180ms ease, border-radius 500ms ease;\n}\n\n.chatai-orb-shine {\n inset: 10% 18% auto 14%;\n height: 28%;\n border-radius: 50%;\n background: linear-gradient(180deg, rgb(255 255 255 / 55%), transparent);\n pointer-events: none;\n}\n\n.chatai-orb-shadow {\n inset: auto 12% -6% 12%;\n height: 18%;\n border-radius: 50%;\n background: radial-gradient(ellipse, rgb(20 36 30 / 22%), transparent 70%);\n filter: blur(2px);\n pointer-events: none;\n}\n\n.chatai-voice-stage[data-motion="listening"] .chatai-orb-core {\n border-radius: 55% 45% 42% 58% / 43% 60% 40% 57%;\n}\n\n.chatai-voice-stage[data-motion="hearing"] .chatai-orb-core {\n border-radius: 52% 48% 60% 40% / 48% 55% 45% 52%;\n}\n\n.chatai-voice-stage[data-motion="speaking"] .chatai-orb-core {\n border-radius: 40% 60% 52% 48% / 58% 45% 55% 42%;\n}\n\n.chatai-voice-stage[data-motion="processing"] .chatai-orb-core,\n.chatai-voice-stage[data-motion="pending"] .chatai-orb-core {\n border-radius: 50% 50% 46% 54% / 54% 46% 54% 46%;\n}\n\n.chatai-voice-stage[data-motion="settle"] .chatai-orb-core {\n border-radius: 47% 53% 50% 50% / 50% 48% 52% 50%;\n}\n\n.chatai-voice-stage-status {\n margin: 0;\n font-size: 15px;\n font-weight: 650;\n}\n\n.chatai-voice-stage-detail {\n margin: 0;\n max-width: 28ch;\n color: var(--chatai-muted);\n font-size: 12px;\n line-height: 1.4;\n}\n\n.chatai-voice-stage-meta {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 11px;\n}\n\n.chatai-voice-captions {\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n gap: 8px;\n width: 100%;\n min-height: 0;\n max-height: min(140px, 28%);\n margin-top: 4px;\n padding: 10px 12px;\n overflow: auto;\n overscroll-behavior: contain;\n border-radius: 12px;\n background: color-mix(in srgb, var(--chatai-voice-accent), var(--chatai-panel) 92%);\n text-align: left;\n -webkit-overflow-scrolling: touch;\n}\n\n.chatai-voice-captions.is-empty {\n text-align: center;\n color: var(--chatai-muted);\n font-size: 12px;\n}\n\n.chatai-voice-captions.is-empty p {\n margin: 0;\n}\n\n.chatai-voice-caption {\n display: grid;\n gap: 2px;\n margin: 0;\n font-size: 13px;\n line-height: 1.35;\n}\n\n.chatai-voice-caption-who {\n color: var(--chatai-muted);\n font-size: 11px;\n font-weight: 650;\n}\n\n.chatai-voice-caption.user .chatai-voice-caption-who {\n color: var(--chatai-voice-accent);\n}\n\n.chatai-voice-caption.is-live .chatai-voice-caption-text::after {\n content: "\u2026";\n}\n\n.chatai-voice-caption-note {\n color: var(--chatai-muted);\n font-size: 11px;\n font-style: italic;\n}\n\n.chatai-voice-controls {\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n gap: 8px;\n width: 100%;\n margin-top: auto;\n padding-top: 10px;\n flex-shrink: 0;\n}\n\n.chatai-voice-primary,\n.chatai-voice-secondary,\n.chatai-voice-danger {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n min-height: 44px;\n padding: 0 14px;\n border-radius: 10px;\n font: inherit;\n font-size: 13px;\n font-weight: 600;\n cursor: pointer;\n touch-action: manipulation;\n transition: transform 120ms ease-out, opacity 120ms ease-out;\n}\n\n.chatai-voice-primary:active,\n.chatai-voice-secondary:active,\n.chatai-voice-danger:active {\n transform: scale(0.97);\n}\n\n.chatai-voice-primary {\n border: 0;\n background: var(--chatai-voice-accent);\n color: #fff;\n}\n\n.chatai-voice-secondary {\n border: 1px solid var(--chatai-border);\n background: var(--chatai-panel);\n color: var(--chatai-ink);\n}\n\n.chatai-voice-secondary.is-pressed {\n border-color: var(--chatai-voice-accent);\n background: color-mix(in srgb, var(--chatai-voice-accent), var(--chatai-panel) 88%);\n}\n\n.chatai-voice-danger {\n border: 0;\n background: #b42318;\n color: #fff;\n}\n\n.chatai-voice-controls svg {\n width: 16px;\n height: 16px;\n}\n\n.chatai-voice-stage .chatai-voice-consent {\n width: 100%;\n border-top: 0;\n border-radius: 12px;\n text-align: left;\n}\n\n.chatai-voice-stage .chatai-voice-actions {\n flex-wrap: wrap;\n justify-content: stretch;\n}\n\n.chatai-voice-stage .chatai-consent-accept,\n.chatai-voice-stage .chatai-consent-cancel {\n flex: 1;\n min-height: 44px;\n}\n\n.chatai-voice-primary:focus-visible,\n.chatai-voice-secondary:focus-visible,\n.chatai-voice-danger:focus-visible {\n outline: 3px solid color-mix(in srgb, var(--chatai-voice-accent), white 55%);\n outline-offset: 2px;\n}\n\n/* Launch controls stay put; panel/dock surfaces sit above them in the column. */\n.chatai-launch-row {\n display: flex;\n flex-direction: row;\n flex-shrink: 0;\n align-items: center;\n gap: 10px;\n}\n\n.chatai-dock-talk {\n display: inline-flex;\n box-sizing: border-box;\n align-items: center;\n justify-content: center;\n gap: 8px;\n width: 5.75rem;\n min-height: 48px;\n padding: 0 14px;\n border: 0;\n border-radius: 999px;\n background: var(--chatai-voice-accent, var(--chatai-accent));\n color: #fff;\n font: inherit;\n font-size: 14px;\n font-weight: 650;\n cursor: pointer;\n box-shadow: 0 10px 22px rgb(20 36 30 / 22%);\n}\n\n.chatai-dock-talk svg {\n width: 18px;\n height: 18px;\n flex-shrink: 0;\n}\n\n.chatai-dock-talk.is-open {\n background: color-mix(in srgb, var(--chatai-voice-accent, var(--chatai-accent)), #1a1a12 28%);\n}\n\n.chatai-dock-talk:focus-visible {\n outline: 3px solid color-mix(in srgb, var(--chatai-voice-accent, var(--chatai-accent)), white 55%);\n outline-offset: 2px;\n}\n\n/* Same placement model as .chatai-panel: above the launch row, bottom-anchored. */\n.chatai-dock-surface {\n display: flex;\n width: min(320px, calc(100vw - 32px - var(--chatai-safe-left) - var(--chatai-safe-right)));\n max-height: min(420px, calc(100dvh - 104px - var(--chatai-safe-bottom) - var(--chatai-safe-top)));\n margin-bottom: 14px;\n flex-direction: column;\n flex-shrink: 0;\n overflow: hidden;\n border: 1px solid var(--chatai-border);\n border-radius: 20px 20px 8px 20px;\n background: var(--chatai-panel);\n box-shadow: 0 24px 70px rgb(20 36 30 / 24%);\n transform-origin: bottom right;\n animation: chatai-panel-in 180ms ease-out;\n}\n\n.chatai-widget.position-left .chatai-dock-surface {\n border-radius: 20px 20px 20px 8px;\n transform-origin: bottom left;\n}\n\n.chatai-widget.position-left .chatai-launch-row {\n flex-direction: row-reverse;\n}\n\n.chatai-dock-surface .chatai-voice-stage {\n flex: 1;\n min-height: 0;\n overflow: auto;\n}\n\n.chatai-guided {\n display: flex;\n flex: 1;\n flex-direction: column;\n gap: 12px;\n min-height: 0;\n padding: 18px 16px 12px;\n overflow: auto;\n}\n\n.chatai-guided-kicker {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 11px;\n font-weight: 650;\n letter-spacing: 0.12em;\n text-transform: uppercase;\n}\n\n.chatai-guided-title {\n margin: 0;\n font-size: 22px;\n font-weight: 650;\n letter-spacing: -0.03em;\n line-height: 1.15;\n}\n\n.chatai-guided-welcome {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 14px;\n line-height: 1.45;\n}\n\n.chatai-guided-choices {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin-top: 4px;\n}\n\n.chatai-guided-choices-label {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 11px;\n font-weight: 650;\n letter-spacing: 0.06em;\n text-transform: uppercase;\n}\n\n.chatai-guided-choice {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n min-height: 44px;\n padding: 10px 12px;\n border: 1px solid var(--chatai-border);\n border-radius: 12px;\n background: var(--chatai-panel);\n color: var(--chatai-ink);\n font: inherit;\n font-size: 13px;\n font-weight: 550;\n text-align: left;\n cursor: pointer;\n}\n\n.chatai-guided-choice:disabled {\n opacity: 0.55;\n cursor: not-allowed;\n}\n\n.chatai-guided-choice:focus-visible {\n outline: 3px solid color-mix(in srgb, var(--chatai-accent), white 55%);\n outline-offset: 2px;\n}\n\n.chatai-guided-choice-mark {\n color: var(--chatai-muted);\n font-size: 14px;\n}\n\n.chatai-guided-hint {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 12px;\n line-height: 1.4;\n}\n\n.chatai-guided-start {\n align-self: stretch;\n margin-top: auto;\n}\n\n.chatai-guided-history {\n flex: 0 1 40%;\n max-height: 40%;\n border-top: 1px solid var(--chatai-border);\n}\n\n.chatai-guided-stage {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n}\n\n.chatai-guided-stage .chatai-voice-stage {\n flex: 1;\n min-height: 0;\n}\n\n.chatai-guided-speak-hints {\n flex-shrink: 0;\n padding: 8px 14px 12px;\n border-top: 1px solid var(--chatai-border);\n background: color-mix(in srgb, var(--chatai-voice-accent, var(--chatai-accent)), var(--chatai-panel) 94%);\n}\n\n.chatai-guided-speak-hints ul {\n display: flex;\n flex-direction: column;\n gap: 4px;\n margin: 6px 0 0;\n padding: 0;\n list-style: none;\n}\n\n.chatai-guided-speak-hints li {\n color: var(--chatai-muted);\n font-size: 12px;\n line-height: 1.35;\n}\n\n.chatai-guided-speak-hints li::before {\n content: "\u201C";\n}\n\n.chatai-guided-speak-hints li::after {\n content: "\u201D";\n}\n\n/* Companion \u2014 abstract character + idle canvas */\n.chatai-companion {\n display: flex;\n flex: 1;\n flex-direction: column;\n align-items: center;\n gap: 10px;\n padding: 18px 16px 12px;\n overflow: auto;\n text-align: center;\n}\n\n.chatai-companion-kicker {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 11px;\n font-weight: 650;\n letter-spacing: 0.14em;\n text-transform: uppercase;\n}\n\n.chatai-companion-title {\n margin: 0;\n font-size: 20px;\n font-weight: 700;\n letter-spacing: -0.02em;\n}\n\n.chatai-companion-speech {\n position: relative;\n max-width: 28ch;\n margin: 4px 0 0;\n padding: 12px 14px;\n border: 1px solid var(--chatai-border);\n border-radius: 16px;\n background: var(--chatai-panel);\n color: var(--chatai-ink);\n font-size: 13px;\n line-height: 1.4;\n}\n\n.chatai-companion-speech::after {\n content: "";\n position: absolute;\n bottom: -7px;\n left: 50%;\n width: 12px;\n height: 12px;\n margin-left: -6px;\n border-right: 1px solid var(--chatai-border);\n border-bottom: 1px solid var(--chatai-border);\n background: var(--chatai-panel);\n transform: rotate(45deg);\n}\n\n.chatai-companion-character {\n --chatai-companion-energy: 0;\n --chatai-companion-mouth: 0;\n --chatai-companion-blink: 0;\n --chatai-companion-peak: 0;\n --chatai-companion-accent: var(--chatai-voice-accent, var(--chatai-accent));\n position: relative;\n width: 132px;\n height: 148px;\n margin: 18px 0 8px;\n}\n\n.chatai-companion-body {\n position: absolute;\n inset: 0 8% 18% 8%;\n border-radius: 52% 48% 38% 42%;\n background: radial-gradient(\n ellipse at 27% 25%,\n color-mix(in srgb, var(--chatai-companion-accent), #fff 62%) 0%,\n var(--chatai-companion-accent) 52%,\n color-mix(in srgb, var(--chatai-companion-accent), #1a1a12 45%) 88%\n );\n box-shadow:\n inset -10px -12px 18px rgb(20 36 30 / 28%),\n inset 4px 6px 14px rgb(255 255 255 / 35%),\n 0 14px 16px rgb(20 36 30 / 14%);\n transform: rotate(calc(-6deg + var(--chatai-companion-energy) * 14deg))\n translateY(calc(var(--chatai-companion-energy) * -8px))\n scale(\n calc(0.96 + var(--chatai-companion-energy) * 0.1),\n calc(0.97 + var(--chatai-companion-energy) * 0.06 - var(--chatai-companion-peak) * 0.04)\n );\n transition: border-radius 480ms ease;\n will-change: transform;\n}\n\n.chatai-companion-eye {\n position: absolute;\n top: 38%;\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background: #1a1a12;\n box-shadow: inset 0 -1px 0 rgb(255 255 255 / 35%);\n transform: scale(\n calc(1 + var(--chatai-companion-peak) * 0.22),\n calc((1 - var(--chatai-companion-blink) * 0.92) * (1 + var(--chatai-companion-peak) * 0.08))\n );\n transform-origin: center 55%;\n will-change: transform;\n}\n\n.chatai-companion-eye-left {\n left: 34%;\n}\n\n.chatai-companion-eye-right {\n right: 34%;\n}\n\n.chatai-companion-mouth {\n position: absolute;\n top: 52%;\n left: 50%;\n width: calc(18px + var(--chatai-companion-mouth) * 8px);\n height: calc(3px + var(--chatai-companion-mouth) * 14px);\n margin-left: calc(-1 * (9px + var(--chatai-companion-mouth) * 4px));\n border: 2px solid #1a1a12;\n border-radius: calc(2px + var(--chatai-companion-mouth) * 12px);\n background: color-mix(\n in srgb,\n #1a1a12,\n transparent calc(100% - var(--chatai-companion-mouth) * 72%)\n );\n opacity: 0.9;\n box-sizing: border-box;\n /* Closed smile arc when mouth \u2248 0; filled oval when speaking. */\n clip-path: inset(\n calc((1 - var(--chatai-companion-mouth)) * 45%) 0 0 0\n );\n will-change: width, height, background, clip-path;\n}\n\n.chatai-companion-character[data-motion="static"] .chatai-companion-mouth,\n.chatai-companion-character[data-motion="listening"] .chatai-companion-mouth,\n.chatai-companion-character[data-motion="settle"] .chatai-companion-mouth {\n border-top: 0;\n border-radius: 0 0 14px 14px;\n background: transparent;\n clip-path: none;\n height: 10px;\n width: 22px;\n margin-left: -11px;\n}\n\n.chatai-companion-foot {\n position: absolute;\n bottom: 4%;\n width: 22px;\n height: 14px;\n border-radius: 40% 40% 50% 50%;\n background: color-mix(in srgb, var(--chatai-companion-accent), #1a1a12 35%);\n box-shadow: 0 3px 4px rgb(20 36 30 / 18%);\n transform: translateY(calc(var(--chatai-companion-energy) * -5px - var(--chatai-companion-peak) * 3px));\n will-change: transform;\n}\n\n.chatai-companion-foot-left {\n left: 28%;\n}\n\n.chatai-companion-foot-right {\n right: 28%;\n}\n\n.chatai-voice-stage[data-motion="listening"] .chatai-companion-body,\n.chatai-companion-character[data-motion="listening"] .chatai-companion-body {\n border-radius: 48% 52% 42% 40%;\n}\n\n.chatai-voice-stage[data-motion="hearing"] .chatai-companion-body,\n.chatai-companion-character[data-motion="hearing"] .chatai-companion-body {\n border-radius: 42% 58% 45% 35%;\n}\n\n.chatai-voice-stage[data-motion="speaking"] .chatai-companion-body,\n.chatai-companion-character[data-motion="speaking"] .chatai-companion-body {\n border-radius: 40% 60% 48% 38%;\n}\n\n.chatai-voice-stage[data-motion="processing"] .chatai-companion-body,\n.chatai-voice-stage[data-motion="pending"] .chatai-companion-body,\n.chatai-companion-character[data-motion="processing"] .chatai-companion-body,\n.chatai-companion-character[data-motion="pending"] .chatai-companion-body {\n border-radius: 50% 50% 44% 46%;\n}\n\n.chatai-companion-hint {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 11px;\n}\n\n.chatai-companion-start {\n margin-top: 4px;\n min-width: 11rem;\n}\n\n.chatai-companion-history {\n flex: 0 1 auto;\n max-height: 28%;\n border-top: 1px solid var(--chatai-border);\n}\n\n.chatai-voice-stage.visual-companion .chatai-companion-character {\n margin: 8px 0;\n}\n\n.chatai-voice-stage.layout-compact {\n padding: 14px 12px calc(12px + var(--chatai-safe-bottom));\n gap: 8px;\n}\n\n.chatai-voice-stage.layout-compact .chatai-orb {\n width: 108px;\n height: 108px;\n margin: 4px 0;\n}\n\n.chatai-voice-stage.layout-compact .chatai-voice-name {\n font-size: 15px;\n}\n\n.chatai-voice-stage.layout-compact .chatai-voice-captions {\n max-height: 96px;\n}\n\n/* Phones \u2014 near full-viewport sheet so Voice and chat feel native. */\n@media (max-width: 480px) {\n .chatai-widget {\n bottom: max(10px, var(--chatai-safe-bottom));\n max-width: calc(100vw - 16px - var(--chatai-safe-left) - var(--chatai-safe-right));\n }\n\n .chatai-widget.position-right {\n right: max(10px, var(--chatai-safe-right));\n }\n\n .chatai-widget.position-left {\n left: max(10px, var(--chatai-safe-left));\n }\n\n .chatai-panel {\n width: calc(100vw - 16px - var(--chatai-safe-left) - var(--chatai-safe-right));\n height: calc(100dvh - 72px - var(--chatai-safe-bottom) - var(--chatai-safe-top));\n max-height: calc(100dvh - 72px - var(--chatai-safe-bottom) - var(--chatai-safe-top));\n margin-bottom: 10px;\n border-radius: 20px 20px 14px 14px;\n }\n\n .chatai-widget.position-left .chatai-panel {\n border-radius: 20px 20px 14px 14px;\n }\n\n .chatai-launcher {\n width: 52px;\n height: 52px;\n }\n\n .chatai-composer button,\n .chatai-composer .chatai-mic {\n min-width: 44px;\n min-height: 44px;\n }\n\n .chatai-composer input {\n font-size: 16px; /* avoid iOS zoom on focus */\n }\n\n .chatai-retry {\n min-height: 44px;\n }\n\n .chatai-header {\n padding: 12px 14px;\n }\n\n .chatai-header h2 {\n font-size: 16px;\n }\n\n .chatai-voice-stage {\n gap: 8px;\n padding: 12px 12px calc(10px + var(--chatai-safe-bottom));\n }\n\n .chatai-orb {\n width: 112px;\n height: 112px;\n margin: 4px 0;\n }\n\n .chatai-voice-name {\n font-size: 16px;\n }\n\n .chatai-voice-stage-status {\n font-size: 14px;\n }\n\n .chatai-voice-captions {\n max-height: min(28vh, 112px);\n padding: 8px 10px;\n }\n\n .chatai-voice-controls {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 8px;\n }\n\n .chatai-voice-primary,\n .chatai-voice-danger {\n grid-column: 1 / -1;\n }\n\n .chatai-voice-primary,\n .chatai-voice-secondary,\n .chatai-voice-danger {\n min-height: 48px;\n width: 100%;\n padding: 0 12px;\n }\n\n .chatai-voice-label-long {\n display: none;\n }\n\n .chatai-voice-label-short {\n display: inline;\n }\n\n .chatai-voice-stage .chatai-consent-accept,\n .chatai-voice-stage .chatai-consent-cancel {\n min-height: 48px;\n }\n\n .chatai-dock-surface {\n width: calc(100vw - 16px - var(--chatai-safe-left) - var(--chatai-safe-right));\n max-height: min(52dvh, calc(100dvh - 88px - var(--chatai-safe-bottom)));\n margin-bottom: 10px;\n border-radius: 18px 18px 12px 12px;\n }\n\n .chatai-widget.position-left .chatai-dock-surface {\n border-radius: 18px 18px 12px 12px;\n }\n\n .chatai-dock-talk {\n width: auto;\n min-width: 5rem;\n min-height: 48px;\n padding: 0 16px;\n }\n\n .chatai-widget.experience-side-panel .chatai-panel {\n width: calc(100vw - 16px - var(--chatai-safe-left) - var(--chatai-safe-right));\n height: calc(100dvh - 72px - var(--chatai-safe-bottom) - var(--chatai-safe-top));\n max-height: none;\n border-radius: 20px 20px 14px 14px;\n }\n\n .chatai-guided,\n .chatai-companion {\n padding: 14px 12px 10px;\n gap: 10px;\n }\n\n .chatai-guided-title,\n .chatai-companion-title {\n font-size: 20px;\n }\n\n .chatai-guided-history,\n .chatai-companion-history {\n max-height: 30%;\n }\n\n .chatai-guided-speak-hints {\n padding: 8px 12px 10px;\n }\n\n .chatai-voice-bar {\n gap: 8px;\n padding: 8px 12px;\n font-size: 12px;\n }\n}\n\n/* Short phones / landscape \u2014 keep orb + controls visible without scroll fights. */\n@media (max-height: 640px) {\n .chatai-orb {\n width: 96px;\n height: 96px;\n margin: 2px 0;\n }\n\n .chatai-voice-stage.layout-compact .chatai-orb {\n width: 88px;\n height: 88px;\n }\n\n .chatai-voice-captions {\n max-height: min(22vh, 88px);\n }\n\n .chatai-voice-identity .chatai-kicker {\n display: none;\n }\n\n .chatai-guided-welcome {\n display: -webkit-box;\n -webkit-line-clamp: 3;\n -webkit-box-orient: vertical;\n overflow: hidden;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .chatai-launcher,\n .chatai-launcher:hover,\n .chatai-launcher[aria-expanded="true"] {\n transition: none;\n transform: none;\n }\n\n .chatai-panel,\n .chatai-panel.is-closing,\n .chatai-dock-surface {\n animation: none;\n }\n\n .chatai-typing span {\n animation: none;\n opacity: 0.7;\n }\n\n .chatai-wave span,\n .chatai-voice-bar .chatai-wave span {\n animation: none;\n transition: none;\n transform: scaleY(0.45);\n }\n\n .chatai-voice-primary:active,\n .chatai-voice-secondary:active,\n .chatai-voice-danger:active {\n transform: none;\n }\n\n .chatai-orb-core,\n .chatai-companion-body,\n .chatai-companion-eye,\n .chatai-companion-mouth,\n .chatai-companion-foot {\n transition: none;\n transform: none;\n will-change: auto;\n }\n\n .chatai-companion-character {\n --chatai-companion-energy: 0 !important;\n --chatai-companion-mouth: 0 !important;\n --chatai-companion-blink: 0 !important;\n --chatai-companion-peak: 0 !important;\n }\n}\n';
661
1706
  var styles_generated_default = styles;
662
1707
 
663
1708
  // src/mount.tsx
664
- import { jsx as jsx4 } from "preact/jsx-runtime";
1709
+ import { jsx as jsx12 } from "preact/jsx-runtime";
665
1710
  function mountWidget(target, options) {
666
1711
  const root = target.shadowRoot ?? target.attachShadow({ mode: "open" });
667
1712
  const style = document.createElement("style");
@@ -669,8 +1714,17 @@ function mountWidget(target, options) {
669
1714
  const host = document.createElement("div");
670
1715
  host.className = options.layout === "contained" ? "chatai-widget-host-contained" : "";
671
1716
  root.replaceChildren(style, host);
672
- render(/* @__PURE__ */ jsx4(WidgetApp, { ...options }), host);
1717
+ let current = options;
1718
+ const paint = () => {
1719
+ host.className = current.layout === "contained" ? "chatai-widget-host-contained" : "";
1720
+ render(/* @__PURE__ */ jsx12(WidgetApp, { ...current }), host);
1721
+ };
1722
+ paint();
673
1723
  return {
1724
+ update(next) {
1725
+ current = { ...current, ...next };
1726
+ paint();
1727
+ },
674
1728
  destroy() {
675
1729
  render(null, host);
676
1730
  root.replaceChildren();
@@ -679,10 +1733,23 @@ function mountWidget(target, options) {
679
1733
  }
680
1734
 
681
1735
  // src/bootstrap.ts
682
- import { resolveApiUrl } from "@nightzeros/chatai-widget-core";
1736
+ import {
1737
+ resolveApiUrl,
1738
+ VOICE_EXPERIENCES
1739
+ } from "@nightzeros/chatai-widget-core";
683
1740
  function option(value, allowed) {
684
1741
  return value && allowed.includes(value) ? value : void 0;
685
1742
  }
1743
+ function voiceAppearanceFromScript(script) {
1744
+ const experience = option(script.dataset.voiceExperience, VOICE_EXPERIENCES);
1745
+ const captions = script.dataset.voiceCaptions;
1746
+ const captionsDefault = captions === "on" ? true : captions === "off" ? false : void 0;
1747
+ if (experience === void 0 && captionsDefault === void 0) return void 0;
1748
+ return {
1749
+ ...experience !== void 0 ? { experience } : {},
1750
+ ...captionsDefault !== void 0 ? { captionsDefault } : {}
1751
+ };
1752
+ }
686
1753
  function optionsFromScript(script) {
687
1754
  const assistantId = script.dataset.assistantId?.trim();
688
1755
  if (!assistantId) {
@@ -690,13 +1757,15 @@ function optionsFromScript(script) {
690
1757
  }
691
1758
  const apiUrl = resolveApiUrl(script.dataset.apiUrl ?? script.src);
692
1759
  const signEndpoint = script.dataset.signEndpoint?.trim() || void 0;
1760
+ const voiceAppearance = voiceAppearanceFromScript(script);
693
1761
  return {
694
1762
  assistantId,
695
1763
  apiUrl,
696
1764
  ...signEndpoint ? { signEndpoint } : {},
697
1765
  theme: option(script.dataset.theme, ["light", "dark", "system"]),
698
1766
  position: option(script.dataset.position, ["bottom-left", "bottom-right"]),
699
- ...script.dataset.voice === "off" ? { voice: false } : {}
1767
+ ...script.dataset.voice === "off" ? { voice: false } : {},
1768
+ ...voiceAppearance ? { voiceAppearance } : {}
700
1769
  };
701
1770
  }
702
1771
  export {