@saar-ai/web-widget 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adopt-stylesheet.d.ts +11 -0
- package/dist/adopt-stylesheet.d.ts.map +1 -0
- package/dist/chunks/{host-widget-BtiYIMwb.js → host-widget-Cc0KjJwZ.js} +2366 -280
- package/dist/concierge-shell.css +2 -0
- package/dist/concierge-state.d.ts +234 -0
- package/dist/concierge-state.d.ts.map +1 -0
- package/dist/dock/dock-renderer.d.ts +3 -0
- package/dist/dock/dock-renderer.d.ts.map +1 -0
- package/dist/dock/dock-row.d.ts +3 -23
- package/dist/dock/dock-row.d.ts.map +1 -1
- package/dist/dock/dock-state.d.ts +34 -174
- package/dist/dock/dock-state.d.ts.map +1 -1
- package/dist/generated/concierge-shell-css.d.ts +2 -0
- package/dist/generated/concierge-shell-css.d.ts.map +1 -0
- package/dist/generated/widget-css.d.ts.map +1 -1
- package/dist/handoff-initials.d.ts +34 -0
- package/dist/handoff-initials.d.ts.map +1 -0
- package/dist/host-widget.d.ts +24 -1
- package/dist/host-widget.d.ts.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -138
- package/dist/mount.d.ts +4 -5
- package/dist/mount.d.ts.map +1 -1
- package/dist/next/index.js +1 -1
- package/dist/renderers.d.ts +3 -0
- package/dist/renderers.d.ts.map +1 -0
- package/dist/styles.d.ts +1 -0
- package/dist/styles.d.ts.map +1 -1
- package/dist/voice-widget.d.ts +93 -3
- package/dist/voice-widget.d.ts.map +1 -1
- package/dist/widget/concierge-launcher.d.ts +68 -0
- package/dist/widget/concierge-launcher.d.ts.map +1 -0
- package/dist/widget/concierge-shell.d.ts +299 -0
- package/dist/widget/concierge-shell.d.ts.map +1 -0
- package/dist/widget/position.d.ts +65 -0
- package/dist/widget/position.d.ts.map +1 -0
- package/dist/widget/shell-renderer.d.ts +3 -0
- package/dist/widget/shell-renderer.d.ts.map +1 -0
- package/dist/widget/transcript-geometry.d.ts +220 -0
- package/dist/widget/transcript-geometry.d.ts.map +1 -0
- package/dist/widget/widget-view.d.ts +138 -0
- package/dist/widget/widget-view.d.ts.map +1 -0
- package/dist/widget.css +1 -1
- package/package.json +1 -1
- package/src/styles/brand.css +51 -0
- package/src/styles/concierge-shell-entry.css +55 -0
- package/src/styles/concierge.css +9 -38
- package/src/styles/widget-entry.css +39 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Fragment as Fragment$1, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
2
|
+
import { Fragment as Fragment$1, createContext, createElement, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
3
3
|
//#region ../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
|
|
4
4
|
function r(e) {
|
|
5
5
|
var t, f, n = "";
|
|
@@ -3896,6 +3896,125 @@ function KnotSvg({ state, tightenKey }) {
|
|
|
3896
3896
|
});
|
|
3897
3897
|
}
|
|
3898
3898
|
//#endregion
|
|
3899
|
+
//#region src/avatar.ts
|
|
3900
|
+
/**
|
|
3901
|
+
* Which face the widget draws — a per-tenant `appearance.avatar` choice.
|
|
3902
|
+
*
|
|
3903
|
+
* `'orb'` is `BotFace`, the animated gradient blob this widget has always
|
|
3904
|
+
* shipped. `'knot'` is `RopeKnot`, a hand-drawn rope line that ties and
|
|
3905
|
+
* unties itself through the same four {@link BotState}s. Kept as data,
|
|
3906
|
+
* separate from the components, for the same reason `bot-state.ts` keeps
|
|
3907
|
+
* `BotState` separate from `BotFace`: parsing and defaulting have to be
|
|
3908
|
+
* assertable without rendering either avatar.
|
|
3909
|
+
*/
|
|
3910
|
+
var WIDGET_AVATARS = ["orb", "knot"];
|
|
3911
|
+
/** What every layer in this package falls back to when a tenant never published one. */
|
|
3912
|
+
var DEFAULT_WIDGET_AVATAR = "orb";
|
|
3913
|
+
/** Whether a value is an avatar this widget knows how to render. Mirrors `bot-state.ts`'s `isBotState`. */
|
|
3914
|
+
function isWidgetAvatar(value) {
|
|
3915
|
+
return typeof value === "string" && WIDGET_AVATARS.includes(value);
|
|
3916
|
+
}
|
|
3917
|
+
//#endregion
|
|
3918
|
+
//#region src/morphing-loader.tsx
|
|
3919
|
+
/**
|
|
3920
|
+
* A voice-frequency visualizer loader.
|
|
3921
|
+
*
|
|
3922
|
+
* Six soft vertical bars rise and fall like a calm voice waveform,
|
|
3923
|
+
* using the plum brand family with no amber or yellow tints.
|
|
3924
|
+
* Respects prefers-reduced-motion by resting the bars at mid-height.
|
|
3925
|
+
*/
|
|
3926
|
+
function MorphingLoader({ size = "md", variant = "brand", className, label = "Loading" }) {
|
|
3927
|
+
const dims = {
|
|
3928
|
+
sm: "h-3 w-3",
|
|
3929
|
+
md: "h-5 w-5",
|
|
3930
|
+
lg: "h-10 w-10",
|
|
3931
|
+
full: "h-full w-full"
|
|
3932
|
+
}[size];
|
|
3933
|
+
const barWidth = {
|
|
3934
|
+
sm: "w-px",
|
|
3935
|
+
md: "w-[2px]",
|
|
3936
|
+
lg: "w-[3px]",
|
|
3937
|
+
full: "w-[5%]"
|
|
3938
|
+
}[size];
|
|
3939
|
+
const gap = {
|
|
3940
|
+
sm: "gap-px",
|
|
3941
|
+
md: "gap-[2px]",
|
|
3942
|
+
lg: "gap-[3px]",
|
|
3943
|
+
full: "gap-[2%]"
|
|
3944
|
+
}[size];
|
|
3945
|
+
const bars = [
|
|
3946
|
+
{
|
|
3947
|
+
min: .35,
|
|
3948
|
+
max: .65,
|
|
3949
|
+
opacityMin: .45,
|
|
3950
|
+
opacityMax: .75,
|
|
3951
|
+
duration: 1.2,
|
|
3952
|
+
delay: 0
|
|
3953
|
+
},
|
|
3954
|
+
{
|
|
3955
|
+
min: .3,
|
|
3956
|
+
max: .85,
|
|
3957
|
+
opacityMin: .4,
|
|
3958
|
+
opacityMax: .9,
|
|
3959
|
+
duration: 1.35,
|
|
3960
|
+
delay: .12
|
|
3961
|
+
},
|
|
3962
|
+
{
|
|
3963
|
+
min: .25,
|
|
3964
|
+
max: 1,
|
|
3965
|
+
opacityMin: .35,
|
|
3966
|
+
opacityMax: 1,
|
|
3967
|
+
duration: 1.5,
|
|
3968
|
+
delay: .24
|
|
3969
|
+
},
|
|
3970
|
+
{
|
|
3971
|
+
min: .25,
|
|
3972
|
+
max: 1,
|
|
3973
|
+
opacityMin: .35,
|
|
3974
|
+
opacityMax: 1,
|
|
3975
|
+
duration: 1.5,
|
|
3976
|
+
delay: .36
|
|
3977
|
+
},
|
|
3978
|
+
{
|
|
3979
|
+
min: .3,
|
|
3980
|
+
max: .85,
|
|
3981
|
+
opacityMin: .4,
|
|
3982
|
+
opacityMax: .9,
|
|
3983
|
+
duration: 1.35,
|
|
3984
|
+
delay: .48
|
|
3985
|
+
},
|
|
3986
|
+
{
|
|
3987
|
+
min: .35,
|
|
3988
|
+
max: .65,
|
|
3989
|
+
opacityMin: .45,
|
|
3990
|
+
opacityMax: .75,
|
|
3991
|
+
duration: 1.2,
|
|
3992
|
+
delay: .6
|
|
3993
|
+
}
|
|
3994
|
+
];
|
|
3995
|
+
const isLight = variant === "light";
|
|
3996
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3997
|
+
className: cn("relative inline-flex items-end justify-center", dims, gap, isLight && "text-[var(--widget-accent-foreground)]", className),
|
|
3998
|
+
role: "status",
|
|
3999
|
+
"aria-label": label,
|
|
4000
|
+
children: [bars.map((bar, i) => /* @__PURE__ */ jsx("span", {
|
|
4001
|
+
className: cn("rounded-full motion-reduce:scale-y-75 motion-reduce:opacity-70", "animate-[voice-bar_1.4s_cubic-bezier(0.45,0,0.55,1)_infinite]", barWidth, "h-full", isLight ? "bg-current opacity-90" : "bg-gradient-to-t from-brand-plum to-[color-mix(in_oklab,var(--brand-plum)_55%,white)]"),
|
|
4002
|
+
style: {
|
|
4003
|
+
animationDuration: `${bar.duration}s`,
|
|
4004
|
+
animationDelay: `${bar.delay}s`,
|
|
4005
|
+
["--voice-min"]: bar.min,
|
|
4006
|
+
["--voice-max"]: bar.max,
|
|
4007
|
+
["--voice-min-opacity"]: bar.opacityMin,
|
|
4008
|
+
["--voice-max-opacity"]: bar.opacityMax
|
|
4009
|
+
},
|
|
4010
|
+
"aria-hidden": true
|
|
4011
|
+
}, i)), /* @__PURE__ */ jsx("span", {
|
|
4012
|
+
className: "sr-only",
|
|
4013
|
+
children: label
|
|
4014
|
+
})]
|
|
4015
|
+
});
|
|
4016
|
+
}
|
|
4017
|
+
//#endregion
|
|
3899
4018
|
//#region src/card-aspect.ts
|
|
3900
4019
|
/** The CSS `aspect-ratio` value each of §9.1's three choices means. */
|
|
3901
4020
|
var CARD_ASPECT = Object.freeze({
|
|
@@ -6553,20 +6672,18 @@ function DockFloat({ turn, suppressed, ducked, agentName, youLabel, label, dismi
|
|
|
6553
6672
|
});
|
|
6554
6673
|
}
|
|
6555
6674
|
//#endregion
|
|
6556
|
-
//#region src/
|
|
6675
|
+
//#region src/handoff-initials.ts
|
|
6557
6676
|
/**
|
|
6558
|
-
*
|
|
6677
|
+
* The operator's initials — SHARED chrome, not the dock's.
|
|
6678
|
+
*
|
|
6679
|
+
* Moved out of `dock/dock-row.tsx` for docs/CONCIERGE_GENERATIONS.md §4's
|
|
6680
|
+
* surfaces row: the dock draws them in its handoff disc and the widget draws
|
|
6681
|
+
* them in the launcher's face, and two renderers computing initials two ways
|
|
6682
|
+
* would let the same operator read as `AR` in one and `A` in the other.
|
|
6683
|
+
* `dock-row.tsx` re-exports it, so every existing import still resolves.
|
|
6684
|
+
*
|
|
6685
|
+
* Everything below is the original, unchanged.
|
|
6559
6686
|
*
|
|
6560
|
-
* A thumb HOLDS and a desktop pointer TOGGLES, and `pen` is a desktop pointer
|
|
6561
|
-
* for this purpose: it is aimed, so a press with it is a click. Written once
|
|
6562
|
-
* rather than at each of the three handlers that need it — they have to agree,
|
|
6563
|
-
* and a `pointercancel` that classified itself differently from the
|
|
6564
|
-
* `pointerdown` it cancels would leave the microphone open.
|
|
6565
|
-
*/
|
|
6566
|
-
function micSourceOf(event) {
|
|
6567
|
-
return event.pointerType === "touch" ? "touch" : "pointer";
|
|
6568
|
-
}
|
|
6569
|
-
/**
|
|
6570
6687
|
* The INITIALS a handoff disc draws for `name` — one or two letters, or `''`
|
|
6571
6688
|
* when there is no name to derive them from (DOCK_SPEC §2).
|
|
6572
6689
|
*
|
|
@@ -6591,6 +6708,20 @@ function micSourceOf(event) {
|
|
|
6591
6708
|
function handoffInitials(name) {
|
|
6592
6709
|
return (name ?? "").trim().split(/\s+/).filter(Boolean).slice(0, 2).map((word) => Array.from(word)[0] ?? "").join("").toUpperCase();
|
|
6593
6710
|
}
|
|
6711
|
+
//#endregion
|
|
6712
|
+
//#region src/dock/dock-row.tsx
|
|
6713
|
+
/**
|
|
6714
|
+
* §5.2's gesture split, from one pointer event.
|
|
6715
|
+
*
|
|
6716
|
+
* A thumb HOLDS and a desktop pointer TOGGLES, and `pen` is a desktop pointer
|
|
6717
|
+
* for this purpose: it is aimed, so a press with it is a click. Written once
|
|
6718
|
+
* rather than at each of the three handlers that need it — they have to agree,
|
|
6719
|
+
* and a `pointercancel` that classified itself differently from the
|
|
6720
|
+
* `pointerdown` it cancels would leave the microphone open.
|
|
6721
|
+
*/
|
|
6722
|
+
function micSourceOf(event) {
|
|
6723
|
+
return event.pointerType === "touch" ? "touch" : "pointer";
|
|
6724
|
+
}
|
|
6594
6725
|
/**
|
|
6595
6726
|
* The tenant's mark, at whatever size the row (32 px) or the pill (28 px)
|
|
6596
6727
|
* asks for — or, while a PERSON holds the conversation, that person's disc.
|
|
@@ -7682,9 +7813,9 @@ function safeImageUrl(url) {
|
|
|
7682
7813
|
return /^https:\/\//i.test(url) ? url : void 0;
|
|
7683
7814
|
}
|
|
7684
7815
|
//#endregion
|
|
7685
|
-
//#region src/
|
|
7686
|
-
/** Every state the
|
|
7687
|
-
var
|
|
7816
|
+
//#region src/concierge-state.ts
|
|
7817
|
+
/** Every state the session can be in — §5.1's ten, plus the four the shipped widget already had. */
|
|
7818
|
+
var CONCIERGE_STATES = [
|
|
7688
7819
|
"dormant",
|
|
7689
7820
|
"connecting",
|
|
7690
7821
|
"listening",
|
|
@@ -7700,8 +7831,8 @@ var DOCK_STATES = [
|
|
|
7700
7831
|
"error",
|
|
7701
7832
|
"cards"
|
|
7702
7833
|
];
|
|
7703
|
-
/** A
|
|
7704
|
-
var
|
|
7834
|
+
/** A concierge nobody has touched, on a tenant with no voice. Every field explicit — see `ConciergeStateInput`. */
|
|
7835
|
+
var idleConciergeInput = {
|
|
7705
7836
|
engaged: false,
|
|
7706
7837
|
voice: {
|
|
7707
7838
|
enabled: false,
|
|
@@ -7729,12 +7860,6 @@ var idleDockInput = {
|
|
|
7729
7860
|
composing: false,
|
|
7730
7861
|
textIdle: false
|
|
7731
7862
|
};
|
|
7732
|
-
/** §1 rule 5 — the three states in which the audio channel is open. */
|
|
7733
|
-
var AUDIO_OPEN = new Set([
|
|
7734
|
-
"listening",
|
|
7735
|
-
"thinking",
|
|
7736
|
-
"speaking"
|
|
7737
|
-
]);
|
|
7738
7863
|
/** The live voice states, in `botStateFor`'s order. `null` when the room is not usably live. */
|
|
7739
7864
|
function liveVoiceState(voice) {
|
|
7740
7865
|
if (!voice.enabled) return null;
|
|
@@ -7746,20 +7871,108 @@ function liveVoiceState(voice) {
|
|
|
7746
7871
|
if (!voice.micOpen) return "muted";
|
|
7747
7872
|
return "listening";
|
|
7748
7873
|
}
|
|
7874
|
+
/** See {@link ConciergeSnapshot.callActive}. */
|
|
7875
|
+
function callActive(voice) {
|
|
7876
|
+
if (!voice.enabled) return false;
|
|
7877
|
+
return voice.phase === "connecting" || voice.phase === "connected" || voice.micPending;
|
|
7878
|
+
}
|
|
7749
7879
|
/**
|
|
7750
|
-
* §5.1's
|
|
7880
|
+
* §5.1's precedence, as a function. The ONLY place a session fact becomes a
|
|
7881
|
+
* state.
|
|
7882
|
+
*
|
|
7883
|
+
* @param input the session, as data — see {@link ConciergeStateInput}
|
|
7884
|
+
* @returns the state and the facts every renderer shares
|
|
7885
|
+
*/
|
|
7886
|
+
function deriveConciergeState(input) {
|
|
7887
|
+
const { voice } = input;
|
|
7888
|
+
const base = (() => {
|
|
7889
|
+
if (input.error !== void 0 && input.error !== "") return "error";
|
|
7890
|
+
if (input.offline) return "offline";
|
|
7891
|
+
if (input.escalated) return "human";
|
|
7892
|
+
if (voice.enabled && voice.micBlocked) return "mic_blocked";
|
|
7893
|
+
if (input.reconnecting) return "reconnecting";
|
|
7894
|
+
if (input.ducked) return "ducked";
|
|
7895
|
+
if (input.engaged) return liveVoiceState(voice) ?? (input.channel === "text" ? "typing" : "dormant");
|
|
7896
|
+
return "dormant";
|
|
7897
|
+
})();
|
|
7898
|
+
const state = input.shelfCount > 0 && !input.sheetOpen && (base === "ducked" || base === "dormant") ? "cards" : base;
|
|
7899
|
+
return {
|
|
7900
|
+
state,
|
|
7901
|
+
callActive: callActive(voice),
|
|
7902
|
+
handoff: state === "human",
|
|
7903
|
+
shelfCount: input.shelfCount
|
|
7904
|
+
};
|
|
7905
|
+
}
|
|
7906
|
+
//#endregion
|
|
7907
|
+
//#region src/dock/dock-state.ts
|
|
7908
|
+
/**
|
|
7909
|
+
* THE DOCK'S VIEW — docs/DOCK_SPEC.md §5.1, drawn.
|
|
7910
|
+
*
|
|
7911
|
+
* Which state the session is in is decided in `../concierge-state.ts`
|
|
7912
|
+
* (`deriveConciergeState`) and shared with the widget generation
|
|
7913
|
+
* (docs/CONCIERGE_GENERATIONS.md §3). This module owns the other half for the
|
|
7914
|
+
* dock: what each of those states LOOKS like as a row — its caption, its
|
|
7915
|
+
* control set, its border, its mark's treatment, what it does to the sheet,
|
|
7916
|
+
* and whether it may recede to glass. Everything under `dock/` renders what
|
|
7917
|
+
* `deriveDockState` returns; nothing else in the dock decides a state, and
|
|
7918
|
+
* nothing in here decides one either.
|
|
7919
|
+
*
|
|
7920
|
+
* The precedence order, the `cards` rule and the live-voice ordering used to
|
|
7921
|
+
* live in this file. They moved out on 2026-09-17 with the split, unchanged,
|
|
7922
|
+
* so that both renderers read one state machine; `dock-state.test.ts` still
|
|
7923
|
+
* asserts §5.1 row by row through `deriveDockState`, whose signature and
|
|
7924
|
+
* output are exactly what they were.
|
|
7925
|
+
*
|
|
7926
|
+
* ## Glass is a decision too
|
|
7927
|
+
*
|
|
7928
|
+
* `DockView.glass` (§3.6) is derived here rather than in the row: which
|
|
7929
|
+
* states may recede to the colourless surface is exactly the kind of rule
|
|
7930
|
+
* that drifts when two components each hold half of it.
|
|
7931
|
+
*
|
|
7932
|
+
* ## Copy is a KEY, never a string
|
|
7933
|
+
*
|
|
7934
|
+
* `caption` carries either `{ kind: 'message', key }` — a `WidgetMessages`
|
|
7935
|
+
* key the renderer resolves against the tenant's own catalogue — or
|
|
7936
|
+
* `{ kind: 'text', text }` for something live (a partial transcript, a spoken
|
|
7937
|
+
* clause, an operator's line, the host's error). This module never formats
|
|
7938
|
+
* and never localises: it has no messages, on purpose, so the table can be
|
|
7939
|
+
* asserted without one.
|
|
7940
|
+
*/
|
|
7941
|
+
var DOCK_STATES = CONCIERGE_STATES;
|
|
7942
|
+
/** A dock nobody has touched, on a tenant with no voice — see `idleConciergeInput`. */
|
|
7943
|
+
var idleDockInput = idleConciergeInput;
|
|
7944
|
+
/** §1 rule 5 — the three states in which the audio channel is open. */
|
|
7945
|
+
var AUDIO_OPEN = new Set([
|
|
7946
|
+
"listening",
|
|
7947
|
+
"thinking",
|
|
7948
|
+
"speaking"
|
|
7949
|
+
]);
|
|
7950
|
+
/**
|
|
7951
|
+
* §5.1's table, as a function — the dock's public entry point, unchanged.
|
|
7751
7952
|
*
|
|
7752
7953
|
* @param input the session, as data — see {@link DockStateInput}
|
|
7753
7954
|
* @returns everything the row, the caption and the sheet need for one render
|
|
7754
7955
|
*/
|
|
7755
7956
|
function deriveDockState(input) {
|
|
7756
|
-
|
|
7957
|
+
return deriveDockView(deriveConciergeState(input), input);
|
|
7958
|
+
}
|
|
7959
|
+
/**
|
|
7960
|
+
* The dock's presentation of a state the shared machine already decided.
|
|
7961
|
+
*
|
|
7962
|
+
* Takes the snapshot AND the input: the snapshot for everything a renderer
|
|
7963
|
+
* may not recompute (the state, `handoff`, `callActive`, `shelfCount`), the
|
|
7964
|
+
* input for CONTENT — a partial transcript, a preamble, the operator's line,
|
|
7965
|
+
* the host's error text. The one thing this function never does is look at
|
|
7966
|
+
* the input to decide which state it is in.
|
|
7967
|
+
*/
|
|
7968
|
+
function deriveDockView(snapshot, input) {
|
|
7969
|
+
const derived = deriveView(snapshot.state, input);
|
|
7757
7970
|
const view = {
|
|
7758
7971
|
...derived,
|
|
7759
|
-
callActive: callActive
|
|
7972
|
+
callActive: snapshot.callActive,
|
|
7760
7973
|
glass: glassFor(derived.state, input),
|
|
7761
|
-
shelfCount:
|
|
7762
|
-
handoff:
|
|
7974
|
+
shelfCount: snapshot.shelfCount,
|
|
7975
|
+
handoff: snapshot.handoff
|
|
7763
7976
|
};
|
|
7764
7977
|
if (input.notice === void 0 || input.notice === "") return view;
|
|
7765
7978
|
if (view.state === "error" || view.state === "offline" || view.state === "human") return view;
|
|
@@ -7776,24 +7989,8 @@ function glassFor(state, input) {
|
|
|
7776
7989
|
if (state === "ducked") return true;
|
|
7777
7990
|
return state === "typing" && input.textIdle && !input.composing;
|
|
7778
7991
|
}
|
|
7779
|
-
|
|
7780
|
-
function callActive(voice) {
|
|
7781
|
-
if (!voice.enabled) return false;
|
|
7782
|
-
return voice.phase === "connecting" || voice.phase === "connected" || voice.micPending;
|
|
7783
|
-
}
|
|
7784
|
-
function deriveView(input) {
|
|
7992
|
+
function deriveView(state, input) {
|
|
7785
7993
|
const { voice } = input;
|
|
7786
|
-
const base = (() => {
|
|
7787
|
-
if (input.error !== void 0 && input.error !== "") return "error";
|
|
7788
|
-
if (input.offline) return "offline";
|
|
7789
|
-
if (input.escalated) return "human";
|
|
7790
|
-
if (voice.enabled && voice.micBlocked) return "mic_blocked";
|
|
7791
|
-
if (input.reconnecting) return "reconnecting";
|
|
7792
|
-
if (input.ducked) return "ducked";
|
|
7793
|
-
if (input.engaged) return liveVoiceState(voice) ?? (input.channel === "text" ? "typing" : "dormant");
|
|
7794
|
-
return "dormant";
|
|
7795
|
-
})();
|
|
7796
|
-
const state = input.shelfCount > 0 && !input.sheetOpen && (base === "ducked" || base === "dormant") ? "cards" : base;
|
|
7797
7994
|
const border = AUDIO_OPEN.has(state) ? "primary" : "rest";
|
|
7798
7995
|
const mark = border === "primary" ? "live" : "dimmed";
|
|
7799
7996
|
switch (state) {
|
|
@@ -9572,159 +9769,2047 @@ function botStateFor(snapshot) {
|
|
|
9572
9769
|
return "listening";
|
|
9573
9770
|
}
|
|
9574
9771
|
//#endregion
|
|
9575
|
-
//#region
|
|
9772
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.25.0_react@19.2.7/node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.mjs
|
|
9576
9773
|
/**
|
|
9577
|
-
*
|
|
9774
|
+
* @license lucide-react v1.25.0 - ISC
|
|
9578
9775
|
*
|
|
9579
|
-
*
|
|
9580
|
-
*
|
|
9581
|
-
* so a rejected link still shows its label rather than vanishing.
|
|
9776
|
+
* This source code is licensed under the ISC license.
|
|
9777
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9582
9778
|
*/
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
}
|
|
9779
|
+
var mergeClasses = (...classes) => classes.filter((className, index, array) => {
|
|
9780
|
+
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
|
|
9781
|
+
}).join(" ").trim();
|
|
9782
|
+
//#endregion
|
|
9783
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.25.0_react@19.2.7/node_modules/lucide-react/dist/esm/shared/src/utils/toKebabCase.mjs
|
|
9589
9784
|
/**
|
|
9590
|
-
*
|
|
9785
|
+
* @license lucide-react v1.25.0 - ISC
|
|
9591
9786
|
*
|
|
9592
|
-
*
|
|
9593
|
-
*
|
|
9594
|
-
* inside it is the classic way a renderer mangles a code sample.
|
|
9787
|
+
* This source code is licensed under the ISC license.
|
|
9788
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9595
9789
|
*/
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
while (rest.length > 0) {
|
|
9600
|
-
const match = /`([^`]+)`|\*\*([\s\S]+?)\*\*|__([\s\S]+?)__|(?<!\*)\*(?!\s)([^*\n]+?)\*(?!\*)|(?<!_)_(?!\s)([^_\n]+?)_(?!_)|\[([^\]]*)\]\(([^)\s]+)\)/.exec(rest);
|
|
9601
|
-
if (!match || match.index === void 0) {
|
|
9602
|
-
out.push({
|
|
9603
|
-
kind: "text",
|
|
9604
|
-
text: rest
|
|
9605
|
-
});
|
|
9606
|
-
break;
|
|
9607
|
-
}
|
|
9608
|
-
if (match.index > 0) out.push({
|
|
9609
|
-
kind: "text",
|
|
9610
|
-
text: rest.slice(0, match.index)
|
|
9611
|
-
});
|
|
9612
|
-
const [full, code, boldStar, boldUnd, italStar, italUnd, linkText, linkHref] = match;
|
|
9613
|
-
if (code !== void 0) out.push({
|
|
9614
|
-
kind: "code",
|
|
9615
|
-
text: code
|
|
9616
|
-
});
|
|
9617
|
-
else if (boldStar !== void 0 || boldUnd !== void 0) out.push({
|
|
9618
|
-
kind: "bold",
|
|
9619
|
-
children: parseInline(boldStar ?? boldUnd)
|
|
9620
|
-
});
|
|
9621
|
-
else if (italStar !== void 0 || italUnd !== void 0) out.push({
|
|
9622
|
-
kind: "italic",
|
|
9623
|
-
children: parseInline(italStar ?? italUnd)
|
|
9624
|
-
});
|
|
9625
|
-
else if (linkHref !== void 0) {
|
|
9626
|
-
const href = safeHref(linkHref);
|
|
9627
|
-
const children = parseInline(linkText ?? "");
|
|
9628
|
-
out.push(href ? {
|
|
9629
|
-
kind: "link",
|
|
9630
|
-
href,
|
|
9631
|
-
children
|
|
9632
|
-
} : {
|
|
9633
|
-
kind: "text",
|
|
9634
|
-
text: linkText ?? ""
|
|
9635
|
-
});
|
|
9636
|
-
}
|
|
9637
|
-
rest = rest.slice(match.index + full.length);
|
|
9638
|
-
}
|
|
9639
|
-
return out.filter((n) => !(n.kind === "text" && n.text === ""));
|
|
9640
|
-
}
|
|
9641
|
-
function renderInline(nodes, keyPrefix) {
|
|
9642
|
-
return nodes.map((node, i) => {
|
|
9643
|
-
const key = `${keyPrefix}-${i}`;
|
|
9644
|
-
switch (node.kind) {
|
|
9645
|
-
case "text": return /* @__PURE__ */ jsx(Fragment$1, { children: node.text }, key);
|
|
9646
|
-
case "bold": return /* @__PURE__ */ jsx("strong", { children: renderInline(node.children, key) }, key);
|
|
9647
|
-
case "italic": return /* @__PURE__ */ jsx("em", { children: renderInline(node.children, key) }, key);
|
|
9648
|
-
case "code": return /* @__PURE__ */ jsx("code", {
|
|
9649
|
-
className: "rounded bg-black/10 px-1 py-0.5 font-mono text-[0.85em]",
|
|
9650
|
-
children: node.text
|
|
9651
|
-
}, key);
|
|
9652
|
-
case "link": return /* @__PURE__ */ jsx("a", {
|
|
9653
|
-
href: node.href,
|
|
9654
|
-
target: "_blank",
|
|
9655
|
-
rel: "noopener noreferrer nofollow",
|
|
9656
|
-
className: "underline underline-offset-2",
|
|
9657
|
-
children: renderInline(node.children, key)
|
|
9658
|
-
}, key);
|
|
9659
|
-
}
|
|
9660
|
-
});
|
|
9661
|
-
}
|
|
9662
|
-
var BULLET = /^\s*[-*+]\s+(.*)$/;
|
|
9663
|
-
var ORDERED = /^\s*\d+[.)]\s+(.*)$/;
|
|
9790
|
+
var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
9791
|
+
//#endregion
|
|
9792
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.25.0_react@19.2.7/node_modules/lucide-react/dist/esm/shared/src/utils/toCamelCase.mjs
|
|
9664
9793
|
/**
|
|
9665
|
-
*
|
|
9794
|
+
* @license lucide-react v1.25.0 - ISC
|
|
9666
9795
|
*
|
|
9667
|
-
*
|
|
9668
|
-
*
|
|
9669
|
-
* writes its intro and its bullets with no blank line between them, so
|
|
9670
|
-
* splitting on blank lines alone left `intro - item - item` as one paragraph.
|
|
9796
|
+
* This source code is licensed under the ISC license.
|
|
9797
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9671
9798
|
*/
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
let list = null;
|
|
9676
|
-
const flushParagraph = () => {
|
|
9677
|
-
if (paragraph.length > 0) blocks.push({
|
|
9678
|
-
kind: "paragraph",
|
|
9679
|
-
lines: paragraph
|
|
9680
|
-
});
|
|
9681
|
-
paragraph = [];
|
|
9682
|
-
};
|
|
9683
|
-
const flushList = () => {
|
|
9684
|
-
if (list) blocks.push({
|
|
9685
|
-
kind: "list",
|
|
9686
|
-
ordered: list.ordered,
|
|
9687
|
-
items: list.items
|
|
9688
|
-
});
|
|
9689
|
-
list = null;
|
|
9690
|
-
};
|
|
9691
|
-
for (const line of markdown.split("\n")) {
|
|
9692
|
-
if (line.trim() === "") {
|
|
9693
|
-
flushParagraph();
|
|
9694
|
-
flushList();
|
|
9695
|
-
continue;
|
|
9696
|
-
}
|
|
9697
|
-
const bullet = BULLET.exec(line);
|
|
9698
|
-
const ordered = bullet ? null : ORDERED.exec(line);
|
|
9699
|
-
if (bullet ?? ordered) {
|
|
9700
|
-
flushParagraph();
|
|
9701
|
-
const isOrdered = ordered !== null;
|
|
9702
|
-
const text = (bullet?.[1] ?? ordered?.[1] ?? "").trim();
|
|
9703
|
-
if (list && list.ordered !== isOrdered) flushList();
|
|
9704
|
-
list ??= {
|
|
9705
|
-
ordered: isOrdered,
|
|
9706
|
-
items: []
|
|
9707
|
-
};
|
|
9708
|
-
list.items.push(text);
|
|
9709
|
-
continue;
|
|
9710
|
-
}
|
|
9711
|
-
flushList();
|
|
9712
|
-
paragraph.push(line.trim());
|
|
9713
|
-
}
|
|
9714
|
-
flushParagraph();
|
|
9715
|
-
flushList();
|
|
9716
|
-
return blocks;
|
|
9717
|
-
}
|
|
9799
|
+
var toCamelCase = (string) => string.replace(/^([A-Z])|[\s-_]+(\w)/g, (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase());
|
|
9800
|
+
//#endregion
|
|
9801
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.25.0_react@19.2.7/node_modules/lucide-react/dist/esm/shared/src/utils/toPascalCase.mjs
|
|
9718
9802
|
/**
|
|
9719
|
-
*
|
|
9803
|
+
* @license lucide-react v1.25.0 - ISC
|
|
9720
9804
|
*
|
|
9721
|
-
*
|
|
9722
|
-
*
|
|
9723
|
-
* and render as the literal characters they are, which then resolve
|
|
9724
|
-
* themselves on the delta that closes them — no flicker beyond the marker
|
|
9725
|
-
* briefly showing, and never a thrown parse error mid-stream.
|
|
9805
|
+
* This source code is licensed under the ISC license.
|
|
9806
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9726
9807
|
*/
|
|
9727
|
-
|
|
9808
|
+
var toPascalCase = (string) => {
|
|
9809
|
+
const camelCase = toCamelCase(string);
|
|
9810
|
+
return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
|
|
9811
|
+
};
|
|
9812
|
+
//#endregion
|
|
9813
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.25.0_react@19.2.7/node_modules/lucide-react/dist/esm/defaultAttributes.mjs
|
|
9814
|
+
/**
|
|
9815
|
+
* @license lucide-react v1.25.0 - ISC
|
|
9816
|
+
*
|
|
9817
|
+
* This source code is licensed under the ISC license.
|
|
9818
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9819
|
+
*/
|
|
9820
|
+
var defaultAttributes = {
|
|
9821
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
9822
|
+
width: 24,
|
|
9823
|
+
height: 24,
|
|
9824
|
+
viewBox: "0 0 24 24",
|
|
9825
|
+
fill: "none",
|
|
9826
|
+
stroke: "currentColor",
|
|
9827
|
+
strokeWidth: 2,
|
|
9828
|
+
strokeLinecap: "round",
|
|
9829
|
+
strokeLinejoin: "round"
|
|
9830
|
+
};
|
|
9831
|
+
//#endregion
|
|
9832
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.25.0_react@19.2.7/node_modules/lucide-react/dist/esm/shared/src/utils/hasA11yProp.mjs
|
|
9833
|
+
/**
|
|
9834
|
+
* @license lucide-react v1.25.0 - ISC
|
|
9835
|
+
*
|
|
9836
|
+
* This source code is licensed under the ISC license.
|
|
9837
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9838
|
+
*/
|
|
9839
|
+
var hasA11yProp = (props) => {
|
|
9840
|
+
for (const prop in props) if (prop.startsWith("aria-") || prop === "role" || prop === "title") return true;
|
|
9841
|
+
return false;
|
|
9842
|
+
};
|
|
9843
|
+
//#endregion
|
|
9844
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.25.0_react@19.2.7/node_modules/lucide-react/dist/esm/context.mjs
|
|
9845
|
+
/**
|
|
9846
|
+
* @license lucide-react v1.25.0 - ISC
|
|
9847
|
+
*
|
|
9848
|
+
* This source code is licensed under the ISC license.
|
|
9849
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9850
|
+
*/
|
|
9851
|
+
var LucideContext = createContext({});
|
|
9852
|
+
var useLucideContext = () => useContext(LucideContext);
|
|
9853
|
+
//#endregion
|
|
9854
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.25.0_react@19.2.7/node_modules/lucide-react/dist/esm/Icon.mjs
|
|
9855
|
+
/**
|
|
9856
|
+
* @license lucide-react v1.25.0 - ISC
|
|
9857
|
+
*
|
|
9858
|
+
* This source code is licensed under the ISC license.
|
|
9859
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9860
|
+
*/
|
|
9861
|
+
var Icon = forwardRef(({ color, size, strokeWidth, absoluteStrokeWidth, className = "", children, iconNode, ...rest }, ref) => {
|
|
9862
|
+
const { size: contextSize = 24, strokeWidth: contextStrokeWidth = 2, absoluteStrokeWidth: contextAbsoluteStrokeWidth = false, color: contextColor = "currentColor", className: contextClass = "" } = useLucideContext() ?? {};
|
|
9863
|
+
const calculatedStrokeWidth = absoluteStrokeWidth ?? contextAbsoluteStrokeWidth ? Number(strokeWidth ?? contextStrokeWidth) * 24 / Number(size ?? contextSize) : strokeWidth ?? contextStrokeWidth;
|
|
9864
|
+
return createElement("svg", {
|
|
9865
|
+
ref,
|
|
9866
|
+
...defaultAttributes,
|
|
9867
|
+
width: size ?? contextSize ?? defaultAttributes.width,
|
|
9868
|
+
height: size ?? contextSize ?? defaultAttributes.height,
|
|
9869
|
+
stroke: color ?? contextColor,
|
|
9870
|
+
strokeWidth: calculatedStrokeWidth,
|
|
9871
|
+
className: mergeClasses("lucide", contextClass, className),
|
|
9872
|
+
...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
|
|
9873
|
+
...rest
|
|
9874
|
+
}, [...iconNode.map(([tag, attrs]) => createElement(tag, attrs)), ...Array.isArray(children) ? children : [children]]);
|
|
9875
|
+
});
|
|
9876
|
+
//#endregion
|
|
9877
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.25.0_react@19.2.7/node_modules/lucide-react/dist/esm/createLucideIcon.mjs
|
|
9878
|
+
/**
|
|
9879
|
+
* @license lucide-react v1.25.0 - ISC
|
|
9880
|
+
*
|
|
9881
|
+
* This source code is licensed under the ISC license.
|
|
9882
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9883
|
+
*/
|
|
9884
|
+
var createLucideIcon = (iconName, iconNode) => {
|
|
9885
|
+
const Component = forwardRef(({ className, ...props }, ref) => createElement(Icon, {
|
|
9886
|
+
ref,
|
|
9887
|
+
iconNode,
|
|
9888
|
+
className: mergeClasses(`lucide-${toKebabCase(toPascalCase(iconName))}`, `lucide-${iconName}`, className),
|
|
9889
|
+
...props
|
|
9890
|
+
}));
|
|
9891
|
+
Component.displayName = toPascalCase(iconName);
|
|
9892
|
+
return Component;
|
|
9893
|
+
};
|
|
9894
|
+
/**
|
|
9895
|
+
* @license lucide-react v1.25.0 - ISC
|
|
9896
|
+
*
|
|
9897
|
+
* This source code is licensed under the ISC license.
|
|
9898
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9899
|
+
*/
|
|
9900
|
+
var GripVertical = createLucideIcon("grip-vertical", [
|
|
9901
|
+
["circle", {
|
|
9902
|
+
cx: "9",
|
|
9903
|
+
cy: "12",
|
|
9904
|
+
r: "1",
|
|
9905
|
+
key: "1vctgf"
|
|
9906
|
+
}],
|
|
9907
|
+
["circle", {
|
|
9908
|
+
cx: "9",
|
|
9909
|
+
cy: "5",
|
|
9910
|
+
r: "1",
|
|
9911
|
+
key: "hp0tcf"
|
|
9912
|
+
}],
|
|
9913
|
+
["circle", {
|
|
9914
|
+
cx: "9",
|
|
9915
|
+
cy: "19",
|
|
9916
|
+
r: "1",
|
|
9917
|
+
key: "fkjjf6"
|
|
9918
|
+
}],
|
|
9919
|
+
["circle", {
|
|
9920
|
+
cx: "15",
|
|
9921
|
+
cy: "12",
|
|
9922
|
+
r: "1",
|
|
9923
|
+
key: "1tmaij"
|
|
9924
|
+
}],
|
|
9925
|
+
["circle", {
|
|
9926
|
+
cx: "15",
|
|
9927
|
+
cy: "5",
|
|
9928
|
+
r: "1",
|
|
9929
|
+
key: "19l28e"
|
|
9930
|
+
}],
|
|
9931
|
+
["circle", {
|
|
9932
|
+
cx: "15",
|
|
9933
|
+
cy: "19",
|
|
9934
|
+
r: "1",
|
|
9935
|
+
key: "f4zoj3"
|
|
9936
|
+
}]
|
|
9937
|
+
]);
|
|
9938
|
+
/**
|
|
9939
|
+
* @license lucide-react v1.25.0 - ISC
|
|
9940
|
+
*
|
|
9941
|
+
* This source code is licensed under the ISC license.
|
|
9942
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9943
|
+
*/
|
|
9944
|
+
var MicOff = createLucideIcon("mic-off", [
|
|
9945
|
+
["path", {
|
|
9946
|
+
d: "M12 19v3",
|
|
9947
|
+
key: "npa21l"
|
|
9948
|
+
}],
|
|
9949
|
+
["path", {
|
|
9950
|
+
d: "M15 9.34V5a3 3 0 0 0-5.68-1.33",
|
|
9951
|
+
key: "1gzdoj"
|
|
9952
|
+
}],
|
|
9953
|
+
["path", {
|
|
9954
|
+
d: "M16.95 16.95A7 7 0 0 1 5 12v-2",
|
|
9955
|
+
key: "cqa7eg"
|
|
9956
|
+
}],
|
|
9957
|
+
["path", {
|
|
9958
|
+
d: "M18.89 13.23A7 7 0 0 0 19 12v-2",
|
|
9959
|
+
key: "16hl24"
|
|
9960
|
+
}],
|
|
9961
|
+
["path", {
|
|
9962
|
+
d: "m2 2 20 20",
|
|
9963
|
+
key: "1ooewy"
|
|
9964
|
+
}],
|
|
9965
|
+
["path", {
|
|
9966
|
+
d: "M9 9v3a3 3 0 0 0 5.12 2.12",
|
|
9967
|
+
key: "r2i35w"
|
|
9968
|
+
}]
|
|
9969
|
+
]);
|
|
9970
|
+
/**
|
|
9971
|
+
* @license lucide-react v1.25.0 - ISC
|
|
9972
|
+
*
|
|
9973
|
+
* This source code is licensed under the ISC license.
|
|
9974
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9975
|
+
*/
|
|
9976
|
+
var Mic = createLucideIcon("mic", [
|
|
9977
|
+
["path", {
|
|
9978
|
+
d: "M12 19v3",
|
|
9979
|
+
key: "npa21l"
|
|
9980
|
+
}],
|
|
9981
|
+
["path", {
|
|
9982
|
+
d: "M19 10v2a7 7 0 0 1-14 0v-2",
|
|
9983
|
+
key: "1vc78b"
|
|
9984
|
+
}],
|
|
9985
|
+
["rect", {
|
|
9986
|
+
x: "9",
|
|
9987
|
+
y: "2",
|
|
9988
|
+
width: "6",
|
|
9989
|
+
height: "13",
|
|
9990
|
+
rx: "3",
|
|
9991
|
+
key: "s6n7sd"
|
|
9992
|
+
}]
|
|
9993
|
+
]);
|
|
9994
|
+
/**
|
|
9995
|
+
* @license lucide-react v1.25.0 - ISC
|
|
9996
|
+
*
|
|
9997
|
+
* This source code is licensed under the ISC license.
|
|
9998
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9999
|
+
*/
|
|
10000
|
+
var PhoneOff = createLucideIcon("phone-off", [
|
|
10001
|
+
["path", {
|
|
10002
|
+
d: "M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272",
|
|
10003
|
+
key: "1wngk7"
|
|
10004
|
+
}],
|
|
10005
|
+
["path", {
|
|
10006
|
+
d: "M22 2 2 22",
|
|
10007
|
+
key: "y4kqgn"
|
|
10008
|
+
}],
|
|
10009
|
+
["path", {
|
|
10010
|
+
d: "M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473",
|
|
10011
|
+
key: "10hv5p"
|
|
10012
|
+
}]
|
|
10013
|
+
]);
|
|
10014
|
+
/**
|
|
10015
|
+
* @license lucide-react v1.25.0 - ISC
|
|
10016
|
+
*
|
|
10017
|
+
* This source code is licensed under the ISC license.
|
|
10018
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
10019
|
+
*/
|
|
10020
|
+
var Send = createLucideIcon("send", [["path", {
|
|
10021
|
+
d: "M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",
|
|
10022
|
+
key: "1ffxy3"
|
|
10023
|
+
}], ["path", {
|
|
10024
|
+
d: "m21.854 2.147-10.94 10.939",
|
|
10025
|
+
key: "12cjpa"
|
|
10026
|
+
}]]);
|
|
10027
|
+
/**
|
|
10028
|
+
* @license lucide-react v1.25.0 - ISC
|
|
10029
|
+
*
|
|
10030
|
+
* This source code is licensed under the ISC license.
|
|
10031
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
10032
|
+
*/
|
|
10033
|
+
var Square = createLucideIcon("square", [["rect", {
|
|
10034
|
+
width: "18",
|
|
10035
|
+
height: "18",
|
|
10036
|
+
x: "3",
|
|
10037
|
+
y: "3",
|
|
10038
|
+
rx: "2",
|
|
10039
|
+
key: "afitv7"
|
|
10040
|
+
}]]);
|
|
10041
|
+
/**
|
|
10042
|
+
* @license lucide-react v1.25.0 - ISC
|
|
10043
|
+
*
|
|
10044
|
+
* This source code is licensed under the ISC license.
|
|
10045
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
10046
|
+
*/
|
|
10047
|
+
var X = createLucideIcon("x", [["path", {
|
|
10048
|
+
d: "M18 6 6 18",
|
|
10049
|
+
key: "1bl5f8"
|
|
10050
|
+
}], ["path", {
|
|
10051
|
+
d: "m6 6 12 12",
|
|
10052
|
+
key: "d8bk6v"
|
|
10053
|
+
}]]);
|
|
10054
|
+
//#endregion
|
|
10055
|
+
//#region src/avatar-face.tsx
|
|
10056
|
+
function AvatarFace({ avatar, state, size, label, messageArrived, tightenKey }) {
|
|
10057
|
+
switch (avatar) {
|
|
10058
|
+
case "orb": return /* @__PURE__ */ jsx(BotFace, {
|
|
10059
|
+
state,
|
|
10060
|
+
size,
|
|
10061
|
+
label,
|
|
10062
|
+
messageArrived
|
|
10063
|
+
});
|
|
10064
|
+
case "knot": return /* @__PURE__ */ jsx(RopeKnot, {
|
|
10065
|
+
state,
|
|
10066
|
+
size,
|
|
10067
|
+
label,
|
|
10068
|
+
tightenKey
|
|
10069
|
+
});
|
|
10070
|
+
default: throw new Error(`Unhandled widget avatar: ${String(avatar)}`);
|
|
10071
|
+
}
|
|
10072
|
+
}
|
|
10073
|
+
//#endregion
|
|
10074
|
+
//#region src/widget/position.ts
|
|
10075
|
+
/**
|
|
10076
|
+
* Where the concierge sits on the host page, and how a visitor moves it.
|
|
10077
|
+
*
|
|
10078
|
+
* Six anchors, not four. The two centres exist because the launcher is a PILL
|
|
10079
|
+
* with a label on it now, not a round button: a wide control tucked into a
|
|
10080
|
+
* corner reads as an ad, and the middle of an edge is where a host page's own
|
|
10081
|
+
* content is least likely to be. The corners remain because they are where a
|
|
10082
|
+
* tenant with a fixed footer or a cookie bar needs it.
|
|
10083
|
+
*
|
|
10084
|
+
* The tenant picks the default in the widget config; a visitor may drag it
|
|
10085
|
+
* somewhere else, and where they put it is theirs — see `nearestPosition`.
|
|
10086
|
+
*/
|
|
10087
|
+
var CONCIERGE_POSITIONS = [
|
|
10088
|
+
"top-left",
|
|
10089
|
+
"top-center",
|
|
10090
|
+
"top-right",
|
|
10091
|
+
"bottom-left",
|
|
10092
|
+
"bottom-center",
|
|
10093
|
+
"bottom-right"
|
|
10094
|
+
];
|
|
10095
|
+
var DEFAULT_CONCIERGE_POSITION = "bottom-center";
|
|
10096
|
+
function edgeOf(position) {
|
|
10097
|
+
return position.startsWith("top") ? "top" : "bottom";
|
|
10098
|
+
}
|
|
10099
|
+
function alignOf(position) {
|
|
10100
|
+
if (position.endsWith("left")) return "left";
|
|
10101
|
+
if (position.endsWith("right")) return "right";
|
|
10102
|
+
return "center";
|
|
10103
|
+
}
|
|
10104
|
+
/**
|
|
10105
|
+
* The anchor a dropped widget should snap to.
|
|
10106
|
+
*
|
|
10107
|
+
* Thirds horizontally, halves vertically, measured on the widget's own CENTRE
|
|
10108
|
+
* rather than the pointer: a visitor drags the grip, which sits at one end of
|
|
10109
|
+
* the pill, and snapping on the pointer would send a pill they dropped dead
|
|
10110
|
+
* centre off to whichever side they happened to be holding.
|
|
10111
|
+
*
|
|
10112
|
+
* Pure arithmetic on numbers the caller measures, so it is testable without a
|
|
10113
|
+
* DOM and cannot disagree with itself across browsers.
|
|
10114
|
+
* @param centre the widget's centre point, in viewport pixels
|
|
10115
|
+
* @param viewport the viewport's size, in pixels
|
|
10116
|
+
*/
|
|
10117
|
+
function nearestPosition(centre, viewport) {
|
|
10118
|
+
const edge = centre.y < viewport.height / 2 ? "top" : "bottom";
|
|
10119
|
+
const third = viewport.width / 3;
|
|
10120
|
+
return `${edge}-${centre.x < third ? "left" : centre.x < third * 2 ? "center" : "right"}`;
|
|
10121
|
+
}
|
|
10122
|
+
/**
|
|
10123
|
+
* The anchor an arrow key moves to.
|
|
10124
|
+
*
|
|
10125
|
+
* The keyboard equivalent of dragging, and not a nicety: a pointer-only way to
|
|
10126
|
+
* move the widget is unusable for anyone who cannot drag, and the widget can
|
|
10127
|
+
* cover a host page's own controls. Left/right walk the three columns and stop
|
|
10128
|
+
* at the ends rather than wrapping — a control that jumps from one edge of the
|
|
10129
|
+
* screen to the other because a key was held is disorienting. Up/down flip the
|
|
10130
|
+
* edge.
|
|
10131
|
+
* @param position where it is now
|
|
10132
|
+
* @param key the arrow key pressed
|
|
10133
|
+
*/
|
|
10134
|
+
function positionForArrow(position, key) {
|
|
10135
|
+
const edge = edgeOf(position);
|
|
10136
|
+
const align = alignOf(position);
|
|
10137
|
+
if (key === "ArrowUp") return `top-${align}`;
|
|
10138
|
+
if (key === "ArrowDown") return `bottom-${align}`;
|
|
10139
|
+
const columns = [
|
|
10140
|
+
"left",
|
|
10141
|
+
"center",
|
|
10142
|
+
"right"
|
|
10143
|
+
];
|
|
10144
|
+
const next = columns.indexOf(align) + (key === "ArrowRight" ? 1 : -1);
|
|
10145
|
+
return `${edge}-${columns[Math.min(Math.max(next, 0), columns.length - 1)]}`;
|
|
10146
|
+
}
|
|
10147
|
+
/** Tailwind classes pinning a fixed element to one anchor. */
|
|
10148
|
+
function positionClasses(position) {
|
|
10149
|
+
return `${edgeOf(position) === "top" ? "top-4 sm:top-6" : "bottom-4 sm:bottom-6"} ${{
|
|
10150
|
+
left: "left-4 sm:left-6",
|
|
10151
|
+
center: "left-1/2 -translate-x-1/2",
|
|
10152
|
+
right: "right-4 sm:right-6"
|
|
10153
|
+
}[alignOf(position)]}`;
|
|
10154
|
+
}
|
|
10155
|
+
/**
|
|
10156
|
+
* How the open PANEL lines up under (or over) the launcher.
|
|
10157
|
+
*
|
|
10158
|
+
* The panel is much wider than the pill, so it cannot simply share the
|
|
10159
|
+
* launcher's anchor: pinned left it would still be pinned left, but pinned
|
|
10160
|
+
* centre it has to centre on the viewport rather than on the pill.
|
|
10161
|
+
*/
|
|
10162
|
+
function panelClasses(position) {
|
|
10163
|
+
return `${edgeOf(position) === "top" ? "top-4 sm:top-6" : "bottom-4 sm:bottom-6"} ${{
|
|
10164
|
+
left: "justify-start ps-4 sm:ps-6",
|
|
10165
|
+
center: "justify-center",
|
|
10166
|
+
right: "justify-end pe-4 sm:pe-6"
|
|
10167
|
+
}[alignOf(position)]}`;
|
|
10168
|
+
}
|
|
10169
|
+
//#endregion
|
|
10170
|
+
//#region src/widget/concierge-launcher.tsx
|
|
10171
|
+
/** Nothing to say — what a launcher rendered without a `spec` draws. */
|
|
10172
|
+
var QUIET = {
|
|
10173
|
+
busy: false,
|
|
10174
|
+
dimmed: false,
|
|
10175
|
+
disabled: false,
|
|
10176
|
+
badge: false,
|
|
10177
|
+
initials: false
|
|
10178
|
+
};
|
|
10179
|
+
function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChange, onOpen, hidden, id, testId, avatar = "orb", spec = QUIET, initials = "" }) {
|
|
10180
|
+
const rootRef = useRef(null);
|
|
10181
|
+
/** Pixel offset while a drag is in flight; `null` when it is not. */
|
|
10182
|
+
const [drag, setDrag] = useState(null);
|
|
10183
|
+
/**
|
|
10184
|
+
* Bumped on every press — `RopeKnot`'s click feedback (`rk-tighten` +
|
|
10185
|
+
* `rk-tap`), the same gesture the Lovable prototype's `RopeKnotTrigger`
|
|
10186
|
+
* wired directly into its own `onClick`. `BotFace` has no equivalent prop
|
|
10187
|
+
* and ignores an unused number, so this costs the orb nothing.
|
|
10188
|
+
*/
|
|
10189
|
+
const [tightenKey, setTightenKey] = useState(0);
|
|
10190
|
+
/**
|
|
10191
|
+
* Where the drag started: the pointer, and the pill's centre AT THAT MOMENT.
|
|
10192
|
+
*
|
|
10193
|
+
* The centre is captured on pointer-DOWN rather than measured on pointer-up,
|
|
10194
|
+
* because the pill's rendered box only moves once React has committed the
|
|
10195
|
+
* offset and the browser has painted it. Measuring it at the end made the
|
|
10196
|
+
* snap depend on paint timing: a fast drag — or any burst of pointer events
|
|
10197
|
+
* inside one task — landed the pill exactly where it started, since the box
|
|
10198
|
+
* had not moved yet. Pointer delta plus the starting centre is the same
|
|
10199
|
+
* arithmetic with none of that dependency.
|
|
10200
|
+
*/
|
|
10201
|
+
const origin = useRef(null);
|
|
10202
|
+
const endDrag = useCallback((clientX, clientY) => {
|
|
10203
|
+
const start = origin.current;
|
|
10204
|
+
origin.current = null;
|
|
10205
|
+
setDrag(null);
|
|
10206
|
+
if (!start || !onPositionChange) return;
|
|
10207
|
+
const next = nearestPosition({
|
|
10208
|
+
x: start.centre.x + (clientX - start.pointer.x),
|
|
10209
|
+
y: start.centre.y + (clientY - start.pointer.y)
|
|
10210
|
+
}, {
|
|
10211
|
+
width: window.innerWidth,
|
|
10212
|
+
height: window.innerHeight
|
|
10213
|
+
});
|
|
10214
|
+
if (next !== position) onPositionChange(next);
|
|
10215
|
+
}, [onPositionChange, position]);
|
|
10216
|
+
const onPointerDown = (event) => {
|
|
10217
|
+
if (!onPositionChange) return;
|
|
10218
|
+
try {
|
|
10219
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
10220
|
+
} catch {}
|
|
10221
|
+
const box = rootRef.current?.getBoundingClientRect();
|
|
10222
|
+
origin.current = {
|
|
10223
|
+
pointer: {
|
|
10224
|
+
x: event.clientX,
|
|
10225
|
+
y: event.clientY
|
|
10226
|
+
},
|
|
10227
|
+
centre: box ? {
|
|
10228
|
+
x: box.left + box.width / 2,
|
|
10229
|
+
y: box.top + box.height / 2
|
|
10230
|
+
} : {
|
|
10231
|
+
x: event.clientX,
|
|
10232
|
+
y: event.clientY
|
|
10233
|
+
}
|
|
10234
|
+
};
|
|
10235
|
+
setDrag({
|
|
10236
|
+
dx: 0,
|
|
10237
|
+
dy: 0
|
|
10238
|
+
});
|
|
10239
|
+
};
|
|
10240
|
+
const onPointerMove = (event) => {
|
|
10241
|
+
const start = origin.current;
|
|
10242
|
+
if (!start) return;
|
|
10243
|
+
setDrag({
|
|
10244
|
+
dx: event.clientX - start.pointer.x,
|
|
10245
|
+
dy: event.clientY - start.pointer.y
|
|
10246
|
+
});
|
|
10247
|
+
};
|
|
10248
|
+
const onPointerUp = (event) => {
|
|
10249
|
+
if (!origin.current) return;
|
|
10250
|
+
try {
|
|
10251
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
10252
|
+
} catch {}
|
|
10253
|
+
endDrag(event.clientX, event.clientY);
|
|
10254
|
+
};
|
|
10255
|
+
const onGripKeyDown = (event) => {
|
|
10256
|
+
if (!onPositionChange) return;
|
|
10257
|
+
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight" && event.key !== "ArrowUp" && event.key !== "ArrowDown") return;
|
|
10258
|
+
event.preventDefault();
|
|
10259
|
+
const next = positionForArrow(position, event.key);
|
|
10260
|
+
if (next !== position) onPositionChange(next);
|
|
10261
|
+
};
|
|
10262
|
+
const dragging = drag !== null;
|
|
10263
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
10264
|
+
ref: rootRef,
|
|
10265
|
+
id,
|
|
10266
|
+
"data-testid": testId,
|
|
10267
|
+
"data-position": position,
|
|
10268
|
+
"aria-hidden": hidden,
|
|
10269
|
+
className: cn("fixed z-50 flex items-center gap-1 rounded-full border border-white/40 bg-[var(--widget-card)] py-1.5 pe-4 ps-2 shadow-[0_12px_32px_-12px_color-mix(in_oklab,var(--brand-plum)_35%,transparent)] backdrop-blur-xl", positionClasses(position), dragging ? "cursor-grabbing" : "transition-[opacity,scale] duration-300 ease-out", hidden ? "pointer-events-none scale-75 opacity-0" : "pointer-events-auto opacity-100", !hidden && spec.dimmed ? "opacity-60" : null, spec.disabled ? "cursor-default opacity-70" : null),
|
|
10270
|
+
style: drag ? { transform: `translate(${drag.dx}px, ${drag.dy}px)` } : void 0,
|
|
10271
|
+
children: [onPositionChange ? /* @__PURE__ */ jsx("button", {
|
|
10272
|
+
type: "button",
|
|
10273
|
+
"aria-label": moveLabel,
|
|
10274
|
+
title: moveLabel,
|
|
10275
|
+
tabIndex: hidden ? -1 : 0,
|
|
10276
|
+
"data-testid": testId ? `${testId}-grip` : void 0,
|
|
10277
|
+
onPointerDown,
|
|
10278
|
+
onPointerMove,
|
|
10279
|
+
onPointerUp,
|
|
10280
|
+
onPointerCancel: onPointerUp,
|
|
10281
|
+
onKeyDown: onGripKeyDown,
|
|
10282
|
+
className: cn("touch-none rounded-full p-1 text-[var(--widget-foreground-muted)] transition-colors", "hover:bg-brand-plum/10 hover:text-brand-plum focus-visible:ring-brand-plum/30 focus-visible:ring-2 focus-visible:outline-none", dragging ? "cursor-grabbing" : "cursor-grab"),
|
|
10283
|
+
children: /* @__PURE__ */ jsx(GripVertical, {
|
|
10284
|
+
className: "size-4",
|
|
10285
|
+
"aria-hidden": true
|
|
10286
|
+
})
|
|
10287
|
+
}) : null, /* @__PURE__ */ jsxs("button", {
|
|
10288
|
+
type: "button",
|
|
10289
|
+
"aria-label": label === void 0 ? srLabel : void 0,
|
|
10290
|
+
tabIndex: hidden || spec.disabled ? -1 : 0,
|
|
10291
|
+
disabled: spec.disabled,
|
|
10292
|
+
...spec.busy ? { "aria-busy": true } : {},
|
|
10293
|
+
"data-launcher-state": spec.disabled ? "offline" : spec.busy ? "busy" : spec.dimmed ? "ducked" : void 0,
|
|
10294
|
+
onClick: () => {
|
|
10295
|
+
if (spec.disabled) return;
|
|
10296
|
+
setTightenKey((k) => k + 1);
|
|
10297
|
+
onOpen();
|
|
10298
|
+
},
|
|
10299
|
+
"data-testid": testId ? `${testId}-open` : void 0,
|
|
10300
|
+
className: "flex items-center gap-2.5 rounded-full focus-visible:ring-brand-plum/30 focus-visible:ring-2 focus-visible:outline-none",
|
|
10301
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
10302
|
+
"aria-hidden": true,
|
|
10303
|
+
className: "relative block size-12 shrink-0",
|
|
10304
|
+
children: [
|
|
10305
|
+
spec.initials && initials !== "" ? /* @__PURE__ */ jsx("span", {
|
|
10306
|
+
"data-testid": "widget-launcher-initials",
|
|
10307
|
+
className: "absolute start-1/2 top-1/2 flex size-9 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-[var(--widget-accent)] text-[13px] font-semibold text-[var(--widget-accent-foreground)] rtl:translate-x-1/2",
|
|
10308
|
+
children: initials
|
|
10309
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
10310
|
+
className: "absolute start-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 scale-[0.75] rtl:translate-x-1/2",
|
|
10311
|
+
children: /* @__PURE__ */ jsx(AvatarFace, {
|
|
10312
|
+
avatar,
|
|
10313
|
+
state: "idle",
|
|
10314
|
+
size: "sm",
|
|
10315
|
+
tightenKey
|
|
10316
|
+
})
|
|
10317
|
+
}),
|
|
10318
|
+
spec.busy ? /* @__PURE__ */ jsx("span", {
|
|
10319
|
+
"data-testid": "widget-launcher-busy",
|
|
10320
|
+
className: "pointer-events-none absolute inset-0 animate-spin rounded-full border-2 border-transparent border-t-[var(--widget-accent)] motion-reduce:animate-none"
|
|
10321
|
+
}) : null,
|
|
10322
|
+
spec.badge ? /* @__PURE__ */ jsx("span", {
|
|
10323
|
+
"data-testid": "widget-launcher-badge",
|
|
10324
|
+
className: "absolute end-0 top-0 size-3 rounded-full bg-[var(--widget-accent)] ring-2 ring-[var(--widget-card)]"
|
|
10325
|
+
}) : null
|
|
10326
|
+
]
|
|
10327
|
+
}), label === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
10328
|
+
dir: "auto",
|
|
10329
|
+
className: "max-w-[14rem] truncate text-sm font-medium text-[var(--widget-foreground)]",
|
|
10330
|
+
children: label
|
|
10331
|
+
})]
|
|
10332
|
+
})]
|
|
10333
|
+
});
|
|
10334
|
+
}
|
|
10335
|
+
//#endregion
|
|
10336
|
+
//#region src/widget/transcript-geometry.ts
|
|
10337
|
+
/**
|
|
10338
|
+
* PANEL GEOMETRY — where the conversation's first row sits, as a FRACTION of
|
|
10339
|
+
* the panel's height, and what that costs horizontally.
|
|
10340
|
+
*
|
|
10341
|
+
* Four CSS length expressions and the arithmetic behind them, used by
|
|
10342
|
+
* `concierge-shell.tsx`'s `transcriptEdgeFade`. Their own module, and NOT
|
|
10343
|
+
* re-exported from `index.ts`: `concierge-shell.geometry.test.tsx` has to read
|
|
10344
|
+
* the exact strings the component ships (jsdom's CSS serializer mangles a
|
|
10345
|
+
* `max()` containing a subtraction, so reading them back off a rendered element
|
|
10346
|
+
* tests jsdom rather than this widget), while the package's public API stays
|
|
10347
|
+
* the components themselves.
|
|
10348
|
+
*
|
|
10349
|
+
* One ratio ties the four lengths together, and it is the whole
|
|
10350
|
+
* repair for a bug that shipped: the panel is an ellipse (`rounded-full` on a
|
|
10351
|
+
* `w x 1.6w` box), so how much width it offers depends entirely on how far down
|
|
10352
|
+
* you are. The clearances below scaled with `cqh` while the transcript's
|
|
10353
|
+
* horizontal inset was a fixed 8px tuned for the oval's wide middle, so the
|
|
10354
|
+
* taller the panel got the HIGHER the first message sat proportionally — into a
|
|
10355
|
+
* narrower part of the curve, with no matching inset. Measured live in
|
|
10356
|
+
* Storybook, first agent bubble's top-left corner against the curve at its own
|
|
10357
|
+
* top edge: 14px inside the ellipse at a 582px panel, 37px at 720px, 62px at
|
|
10358
|
+
* 920px (the 2000x1150 desktop it was reported on). `overflow-clip` on the
|
|
10359
|
+
* surface then cut exactly that much off the bubble.
|
|
10360
|
+
*
|
|
10361
|
+
* 0.1924 is not chosen, it is READ OFF the short panel: 112px (the tuned
|
|
10362
|
+
* clearance, see {@link TRANSCRIPT_FADE_TOP_LEN}) over 582px (the panel a
|
|
10363
|
+
* 375x812 phone renders) is 0.19244. Holding that ratio at every size is what
|
|
10364
|
+
* makes the geometry scale-invariant — every panel then presents the first row
|
|
10365
|
+
* at the same point on the same curve, and ONE horizontal inset serves all of
|
|
10366
|
+
* them ({@link TRANSCRIPT_INSET_X}). Expressed as `19.24cqh` in the lengths
|
|
10367
|
+
* below; `cqh` is the panel's own height, via `[container-type:size]` on the
|
|
10368
|
+
* panel div (verified live: `14cqh` resolved to 128.8px on a 920px panel).
|
|
10369
|
+
*
|
|
10370
|
+
* Not a JS constant that gets multiplied out — the panel's height is never
|
|
10371
|
+
* known to JS, only to CSS, which is why every length here is an expression.
|
|
10372
|
+
*/
|
|
10373
|
+
/**
|
|
10374
|
+
* Top ramp when the transcript starts at the panel's top, under the floating
|
|
10375
|
+
* orb — it has to span the orb, so a message is gone before it reaches it
|
|
10376
|
+
* rather than sliding out from behind it half-visible.
|
|
10377
|
+
*
|
|
10378
|
+
* A CSS length EXPRESSION, not a bare number, since the aspect-ratio panel
|
|
10379
|
+
* (`w-[min(97vw,50dvh)]` + `aspect-[5/8]`) ranges from ~582px tall (mobile,
|
|
10380
|
+
* width-bound) to 800px+ (desktop, height-bound) — a fixed 112px clearance
|
|
10381
|
+
* tuned for the OLD fixed-520px panel left too little air under the orb on a
|
|
10382
|
+
* tall one and too much on a short one. `max(112px, 19.24cqh)` is a floor, not
|
|
10383
|
+
* a fixed value: it stays exactly 112px (today's tuned figure) on a short
|
|
10384
|
+
* panel, where 19.24cqh would fall below it, and grows with `cqh` — the query
|
|
10385
|
+
* container's own height, established by `[container-type:size]` on the
|
|
10386
|
+
* panel div below — once the panel is tall enough that 19.24% of it exceeds
|
|
10387
|
+
* 112px. `cqh` rather than `dvh` specifically: the panel's real rendered
|
|
10388
|
+
* height, not the viewport's, since the panel does not always fill the
|
|
10389
|
+
* viewport (mobile: width-bound, height is `w / (8/5)`, shorter than 100dvh).
|
|
10390
|
+
*
|
|
10391
|
+
* 19.24, not the 14 this shipped with: 14cqh gave a TALL panel proportionally
|
|
10392
|
+
* LESS clearance than the 112px floor gives a short one (14% against 19.24%),
|
|
10393
|
+
* which pushed the first message up into the narrowing part of the ellipse —
|
|
10394
|
+
* see the ratio's own note above for the measurements. The floor and the
|
|
10395
|
+
* scaling term now agree at 582px (19.24% of 582 = 111.98), so the two meet
|
|
10396
|
+
* without a step rather than crossing over at some unrelated height.
|
|
10397
|
+
*/
|
|
10398
|
+
var TRANSCRIPT_FADE_TOP_LEN = "max(112px, 19.24cqh)";
|
|
10399
|
+
/**
|
|
10400
|
+
* Top ramp when a `badge` sits above the transcript.
|
|
10401
|
+
*
|
|
10402
|
+
* A badge has ALREADY pushed the transcript clear of the orb, so reusing the
|
|
10403
|
+
* orb-sized ramp charges for the same clearance twice: it left a 112px dead
|
|
10404
|
+
* band directly under the badge and dissolved the opening message for no
|
|
10405
|
+
* reason (measured in `WithABadgeAndNoVoice` — orb ends 565, badge 573-598,
|
|
10406
|
+
* first message could not start above 710). At that point the fade is only
|
|
10407
|
+
* doing its ordinary job of softening a scroll edge, so it wants an ordinary
|
|
10408
|
+
* scroll-edge length. Same floor+`cqh` scheme as {@link TRANSCRIPT_FADE_TOP_LEN}
|
|
10409
|
+
* above and for the same reason — this ramp needs to soften proportionally
|
|
10410
|
+
* more of a tall panel's scroll edge than a short one's.
|
|
10411
|
+
*
|
|
10412
|
+
* The third arm is the ellipse, and it is what keeps this variant honest at
|
|
10413
|
+
* sizes the badge's own fixed offsets stop covering. With a badge the first row
|
|
10414
|
+
* is pushed down by chrome that does NOT scale — 1px surface border + 6px
|
|
10415
|
+
* column padding + the badge wrapper's `mt-[104px]` + 4px list padding = 115px
|
|
10416
|
+
* — so the row lands at `(115px + this ramp) / panelHeight`, a fraction that
|
|
10417
|
+
* SHRINKS as the panel grows. `19.24cqh - 115px` is that equation solved for
|
|
10418
|
+
* the ramp, so the row lands on the same point of the curve the no-badge
|
|
10419
|
+
* variant does. It is inert on the panels this variant was tuned against
|
|
10420
|
+
* (negative at 582px, 4.5px at 720px, so the other two arms win) and takes over
|
|
10421
|
+
* only above ~745px, where the fixed 115px has stopped being enough.
|
|
10422
|
+
*
|
|
10423
|
+
* The badge's own height is counted as ZERO in that 115px, deliberately:
|
|
10424
|
+
* `badge` is an arbitrary node from the host (`voice-widget.tsx` passes a
|
|
10425
|
+
* one-line status pill, ~26px), and only the shortest-badge bound holds for
|
|
10426
|
+
* every caller. A taller badge pushes the row further down, which is the safe
|
|
10427
|
+
* direction.
|
|
10428
|
+
*/
|
|
10429
|
+
var TRANSCRIPT_FADE_TOP_WITH_BADGE_LEN = "max(28px, 4cqh, 19.24cqh - 115px)";
|
|
10430
|
+
var TRANSCRIPT_FADE_BOTTOM_LEN = "max(118px, 20.27cqh)";
|
|
10431
|
+
/**
|
|
10432
|
+
* The transcript's horizontal inset — the width the ellipse actually costs.
|
|
10433
|
+
*
|
|
10434
|
+
* `10.6cqw` is where the curve is at the first row's height: on an ellipse of
|
|
10435
|
+
* width `w`, at the fraction 0.1924 of the way down (the ratio the clearances
|
|
10436
|
+
* above hold at every size), the left edge lies `w * (1 - sqrt(1 - (2*0.1924 -
|
|
10437
|
+
* 1)^2)) / 2` = `0.1058 * w` in from the bounding box. Rounded up to 10.6% so
|
|
10438
|
+
* the rounding goes toward clearance rather than away from it.
|
|
10439
|
+
*
|
|
10440
|
+
* `- 11px` because 11px of that is already paid for by fixed chrome outside
|
|
10441
|
+
* this element: the surface's 1px border plus the inner column's `px-2.5`. The
|
|
10442
|
+
* inset is measured from the PANEL's box, which is where the curve is; this
|
|
10443
|
+
* padding only has to make up the difference. Verified live: a 363.8px-wide
|
|
10444
|
+
* panel put the first bubble's left edge at 19px = 11px chrome + the 8px this
|
|
10445
|
+
* replaces.
|
|
10446
|
+
*
|
|
10447
|
+
* The `8px` floor is the value this shipped with, kept as a lower bound so a
|
|
10448
|
+
* degenerately small panel can never end up with less padding than a plain
|
|
10449
|
+
* scroll edge wants. It is inert at every real size (the formula gives 27.6px
|
|
10450
|
+
* on the smallest panel the widget renders).
|
|
10451
|
+
*
|
|
10452
|
+
* Symmetric on purpose, and applied as `padding-inline` so it stays symmetric
|
|
10453
|
+
* in RTL: the ellipse is symmetric, the visitor's own bubbles are `justify-end`
|
|
10454
|
+
* against the other side of it, and either side is the first row's side
|
|
10455
|
+
* depending on who spoke.
|
|
10456
|
+
*/
|
|
10457
|
+
var TRANSCRIPT_INSET_X = "max(8px, 10.6cqw - 11px)";
|
|
10458
|
+
/**
|
|
10459
|
+
* The composer overlay's bottom offset when the microphone is drawn.
|
|
10460
|
+
*
|
|
10461
|
+
* `11.86cqh` is {@link COMPOSER_ROW_FRACTION} as a length. `- 63px` is
|
|
10462
|
+
* everything between this offset and the input's bottom edge that does NOT
|
|
10463
|
+
* scale: the surface's 1px border (the overlay is positioned against the inner
|
|
10464
|
+
* column's padding box, one border inside the panel) plus the 62px microphone
|
|
10465
|
+
* block — a 10px `gap-2.5`, the row's 4px `mt-1`, and a 48px `size-12` button.
|
|
10466
|
+
*
|
|
10467
|
+
* `max(6px, …)` keeps the 6px this shipped with as a floor, and the two arms
|
|
10468
|
+
* MEET at the panel it was tuned on rather than crossing somewhere unrelated:
|
|
10469
|
+
* `11.86cqh - 63px` is 6.03px at 582px, so a phone renders what it rendered
|
|
10470
|
+
* before to a hundredth of a pixel and only larger panels lift the composer.
|
|
10471
|
+
*/
|
|
10472
|
+
var COMPOSER_BOTTOM_LEN = "max(6px, 11.86cqh - 63px)";
|
|
10473
|
+
/**
|
|
10474
|
+
* The composer overlay's bottom offset when there is NO microphone.
|
|
10475
|
+
*
|
|
10476
|
+
* Same target row, minus only the 1px surface border: with `voice` omitted the
|
|
10477
|
+
* overlay's last child IS the input, so the 62px the microphone block
|
|
10478
|
+
* contributed above has to come from this offset instead. That is a real move —
|
|
10479
|
+
* 6px to 68px on a phone — and it is the fix rather than a side effect. Left at
|
|
10480
|
+
* 6px the input sits 7px off a `rounded-full` panel's bottom tip, where the
|
|
10481
|
+
* ellipse offers 79px of width in total; no width cap can rescue that row, so
|
|
10482
|
+
* the row itself has to come up to where the panel is wide enough to hold it.
|
|
10483
|
+
*
|
|
10484
|
+
* The band it moves into is the one the microphone would have occupied, which
|
|
10485
|
+
* the transcript already clears ({@link TRANSCRIPT_FADE_BOTTOM_LEN} is sized
|
|
10486
|
+
* for the input + microphone pair regardless of whether the pair is drawn), so
|
|
10487
|
+
* nothing above has to move to make room.
|
|
10488
|
+
*/
|
|
10489
|
+
var COMPOSER_BOTTOM_NO_VOICE_LEN = "max(6px, 11.86cqh - 1px)";
|
|
10490
|
+
/**
|
|
10491
|
+
* The composer's width cap — what the ellipse actually offers at that row.
|
|
10492
|
+
*
|
|
10493
|
+
* On an ellipse of width `w`, at the fraction `1 - 0.1186` of the way down, the
|
|
10494
|
+
* full chord is `w * sqrt(1 - (2*0.8814 - 1)^2)` = `0.6465 * w`. So `64.65cqw`
|
|
10495
|
+
* is not a taste-tuned percentage, it is the panel's own width at the row the
|
|
10496
|
+
* two offsets above pin the input to — where `w-[71%]`, the class this caps,
|
|
10497
|
+
* was 6.4% of the panel too wide at EVERY size (10.8px of overhang on a phone,
|
|
10498
|
+
* 52.0px on a 920px panel, because the row also drifts lower as the panel
|
|
10499
|
+
* grows).
|
|
10500
|
+
*
|
|
10501
|
+
* `- 10px` is clearance, 5px each side, matching the 5px the transcript's rows
|
|
10502
|
+
* clear the curve by — the panel paints a 1.5px gradient ring plus a 1px
|
|
10503
|
+
* surface border at that edge, and the input's own rounding means the arc, not
|
|
10504
|
+
* the corner, is what approaches the curve.
|
|
10505
|
+
*
|
|
10506
|
+
* Applied as `max-width` over the existing `w-[71%]`, not in place of it: 71%
|
|
10507
|
+
* stays the upper bound the composer had, and this only ever tightens it (the
|
|
10508
|
+
* ellipse term is below 71% for any panel, since 0.6465 < 0.71). The `160px`
|
|
10509
|
+
* floor is the "cap it sensibly" arm — it stops a degenerately small panel from
|
|
10510
|
+
* resolving the composer to a few dozen pixels of unusable input, and it is
|
|
10511
|
+
* inert at every size the widget really renders (it binds only below a 248px
|
|
10512
|
+
* panel; the narrowest phone in circulation, 320px, gives 310px).
|
|
10513
|
+
*/
|
|
10514
|
+
var COMPOSER_MAX_WIDTH_LEN = "max(160px, 64.65cqw - 10px)";
|
|
10515
|
+
/**
|
|
10516
|
+
* The opaque ground the composer sits on, which has to keep covering it.
|
|
10517
|
+
*
|
|
10518
|
+
* The transcript runs the panel's whole height and passes BEHIND this row, so
|
|
10519
|
+
* this gradient is the only thing between a message and the input's own
|
|
10520
|
+
* translucent chip fill. It was a fixed `h-[132px]`, tuned when the composer
|
|
10521
|
+
* was pinned 6px off the bottom on every panel — and the moment the offsets
|
|
10522
|
+
* above start lifting the composer on a tall panel, a fixed ground stops
|
|
10523
|
+
* reaching its top edge (the composer's top is `11.86cqh + 40px` above the
|
|
10524
|
+
* panel's bottom: 109px at 582px, but 149px at 920px, against 132px of ground).
|
|
10525
|
+
*
|
|
10526
|
+
* 22.68cqh is the same read-off-the-short-panel derivation as everything else
|
|
10527
|
+
* here — 132/582 = 0.22680 — so a phone renders exactly the 132px it rendered
|
|
10528
|
+
* before and the ground grows with the row it is under. It stays above the
|
|
10529
|
+
* composer's own top at every size, and stays the same shade taller than the
|
|
10530
|
+
* transcript's bottom clearance that it is today ({@link
|
|
10531
|
+
* TRANSCRIPT_FADE_BOTTOM_LEN} is 20.27cqh against this 22.68cqh, exactly the
|
|
10532
|
+
* 118:132 relationship the two were tuned at), so they still meet without a
|
|
10533
|
+
* seam or a band of doubly-darkened panel.
|
|
10534
|
+
*/
|
|
10535
|
+
var COMPOSER_GROUND_LEN = "max(132px, 22.68cqh)";
|
|
10536
|
+
//#endregion
|
|
10537
|
+
//#region src/widget/concierge-shell.tsx
|
|
10538
|
+
/**
|
|
10539
|
+
* How far off the bottom still counts as "following the conversation".
|
|
10540
|
+
*
|
|
10541
|
+
* Not zero: fractional scroll metrics on zoomed and hi-dpi displays never
|
|
10542
|
+
* land exactly on the bottom, and a smooth scroll is still in flight when the
|
|
10543
|
+
* next streamed token resizes the content. Both would read as the visitor
|
|
10544
|
+
* having deliberately scrolled up, and stop the transcript following.
|
|
10545
|
+
*/
|
|
10546
|
+
var FOLLOW_TOLERANCE_PX = 24;
|
|
10547
|
+
/**
|
|
10548
|
+
* Build the transcript's mask + the padding that matches it.
|
|
10549
|
+
*
|
|
10550
|
+
* The two must be derived together: the padding is what lets the first and
|
|
10551
|
+
* last messages scroll clear of the ramp, so a ramp length that is not also
|
|
10552
|
+
* the padding leaves the newest message permanently half-dissolved.
|
|
10553
|
+
*
|
|
10554
|
+
* The top ramp's stops are scaled from `topLen` rather than hardcoded, so the
|
|
10555
|
+
* shortened badge variant keeps the same eased shape instead of becoming a
|
|
10556
|
+
* steep two-point cut. `topLen` is a CSS length EXPRESSION now (a `max(<px>,
|
|
10557
|
+
* <N>cqh)` floor, see the constants above), not a plain number — `at(fraction)`
|
|
10558
|
+
* therefore emits `calc(<topLen> * <fraction>)` rather than doing the
|
|
10559
|
+
* multiplication in JS, so each stop scales with the query container's
|
|
10560
|
+
* height (`cqh`) exactly the way `topLen` itself does. `calc()` accepts a
|
|
10561
|
+
* `max()` expression as its left operand (`max()` resolves to a `<length>`,
|
|
10562
|
+
* and a `<length>` may be multiplied by a bare `<number>` inside `calc()`),
|
|
10563
|
+
* so this composes without a second unit-handling special case.
|
|
10564
|
+
*
|
|
10565
|
+
* The bottom ramp's own inner taper (the last four stops, `96px`/`72px`/
|
|
10566
|
+
* `48px`/`24px`) stays fixed pixels, deliberately NOT scaled by `cqh`: it is
|
|
10567
|
+
* a small, fixed-shape cosmetic fade against the very bottom edge, sized
|
|
10568
|
+
* once and unrelated to how much CLEARANCE the composer needs above it —
|
|
10569
|
+
* that clearance is what `TRANSCRIPT_FADE_BOTTOM_LEN` (the transition point
|
|
10570
|
+
* this taper starts from, and the padding below) controls, and that is what
|
|
10571
|
+
* scales.
|
|
10572
|
+
*
|
|
10573
|
+
* The horizontal inset rides along here rather than staying a `px-2` class for
|
|
10574
|
+
* the same reason the vertical padding does: it is derived from `topLen` — the
|
|
10575
|
+
* curve is only knowable once you know how far down the first row starts (see
|
|
10576
|
+
* {@link TRANSCRIPT_INSET_X}) — and splitting a derived pair across a class and
|
|
10577
|
+
* a style object is exactly how the two drift apart.
|
|
10578
|
+
*/
|
|
10579
|
+
function transcriptEdgeFade(topLen) {
|
|
10580
|
+
const at = (fraction) => `calc(${topLen} * ${fraction})`;
|
|
10581
|
+
const gradient = `linear-gradient(to bottom, ${[
|
|
10582
|
+
"transparent 0",
|
|
10583
|
+
`rgba(0,0,0,0.06) ${at(.21)}`,
|
|
10584
|
+
`rgba(0,0,0,0.20) ${at(.43)}`,
|
|
10585
|
+
`rgba(0,0,0,0.45) ${at(.64)}`,
|
|
10586
|
+
`rgba(0,0,0,0.75) ${at(.82)}`,
|
|
10587
|
+
`#000 ${topLen}`,
|
|
10588
|
+
`#000 calc(100% - ${TRANSCRIPT_FADE_BOTTOM_LEN})`,
|
|
10589
|
+
"rgba(0,0,0,0.86) calc(100% - 96px)",
|
|
10590
|
+
"rgba(0,0,0,0.60) calc(100% - 72px)",
|
|
10591
|
+
"rgba(0,0,0,0.32) calc(100% - 48px)",
|
|
10592
|
+
"rgba(0,0,0,0.10) calc(100% - 24px)",
|
|
10593
|
+
"transparent 100%"
|
|
10594
|
+
].join(", ")})`;
|
|
10595
|
+
return {
|
|
10596
|
+
maskImage: gradient,
|
|
10597
|
+
WebkitMaskImage: gradient,
|
|
10598
|
+
paddingTop: topLen,
|
|
10599
|
+
paddingBottom: TRANSCRIPT_FADE_BOTTOM_LEN,
|
|
10600
|
+
paddingInline: TRANSCRIPT_INSET_X
|
|
10601
|
+
};
|
|
10602
|
+
}
|
|
10603
|
+
/** Both variants built once — neither depends on props beyond badge presence. */
|
|
10604
|
+
var TRANSCRIPT_EDGE_FADE = transcriptEdgeFade(TRANSCRIPT_FADE_TOP_LEN);
|
|
10605
|
+
var TRANSCRIPT_EDGE_FADE_WITH_BADGE = transcriptEdgeFade(TRANSCRIPT_FADE_TOP_WITH_BADGE_LEN);
|
|
10606
|
+
/**
|
|
10607
|
+
* Maps the call onto the pill it shows, reusing fields `ConciergeShellVoice`
|
|
10608
|
+
* already carries rather than inventing new plumbing:
|
|
10609
|
+
*
|
|
10610
|
+
* - `'connecting'` → `connecting`
|
|
10611
|
+
* - `'waiting'` (the agent is thinking, between the caller's turn ending and
|
|
10612
|
+
* the reply starting) → `thinking`
|
|
10613
|
+
* - `'live'` + `agentSpeaking` → `speaking`
|
|
10614
|
+
* - `'live'` otherwise → `listening`
|
|
10615
|
+
* - `'idle'` / `'blocked'` → `null`, no pill
|
|
10616
|
+
*
|
|
10617
|
+
* `agentSpeaking` is already a real field on {@link ConciergeShellVoice} —
|
|
10618
|
+
* this function only reads it, it does not require every caller to start
|
|
10619
|
+
* setting it; a caller that never populates it simply never reaches
|
|
10620
|
+
* `'speaking'`, which is exactly the same "renders sensibly with what it is
|
|
10621
|
+
* given" contract every other optional field on this interface follows.
|
|
10622
|
+
*/
|
|
10623
|
+
function voiceStatePillState(voice) {
|
|
10624
|
+
if (!voice) return null;
|
|
10625
|
+
switch (voice.phase) {
|
|
10626
|
+
case "connecting": return "connecting";
|
|
10627
|
+
case "waiting": return "thinking";
|
|
10628
|
+
case "live": return voice.agentSpeaking ? "speaking" : "listening";
|
|
10629
|
+
default: return null;
|
|
10630
|
+
}
|
|
10631
|
+
}
|
|
10632
|
+
/**
|
|
10633
|
+
* The label a pill state shows, falling back to the package's brand-neutral
|
|
10634
|
+
* English word (`defaultWidgetMessages`) when the host's own `labels` omit
|
|
10635
|
+
* it — the same "an existing caller renders sensibly without changes"
|
|
10636
|
+
* contract every field added to `ConciergeShellVoice.labels` after 0.2.0
|
|
10637
|
+
* follows.
|
|
10638
|
+
*/
|
|
10639
|
+
function voiceStatePillLabel(pillState, labels) {
|
|
10640
|
+
switch (pillState) {
|
|
10641
|
+
case "connecting": return labels?.connecting ?? defaultWidgetMessages.voice_state_connecting;
|
|
10642
|
+
case "listening": return labels?.listening ?? defaultWidgetMessages.voice_state_listening;
|
|
10643
|
+
case "thinking": return labels?.thinking ?? defaultWidgetMessages.voice_state_thinking;
|
|
10644
|
+
case "speaking": return labels?.speaking ?? defaultWidgetMessages.voice_state_speaking;
|
|
10645
|
+
}
|
|
10646
|
+
}
|
|
10647
|
+
/**
|
|
10648
|
+
* The leading dot's colour, in brand tokens — never a literal, so it follows
|
|
10649
|
+
* `skinStyle` when a tenant publishes their own brand colours, the same
|
|
10650
|
+
* reasoning every other brand-coloured glow in this file already states.
|
|
10651
|
+
* `listening` and `speaking` share `--brand-rose`: both are "the room is
|
|
10652
|
+
* live" states from the caller's point of view (a caller talking and an
|
|
10653
|
+
* agent talking back both read as "the call is active"), where
|
|
10654
|
+
* `connecting`/`thinking` are the two states with genuinely nothing to
|
|
10655
|
+
* listen to yet.
|
|
10656
|
+
*/
|
|
10657
|
+
function voiceStatePillDotColor(pillState) {
|
|
10658
|
+
switch (pillState) {
|
|
10659
|
+
case "connecting": return "var(--brand-amber)";
|
|
10660
|
+
case "thinking": return "var(--brand-plum)";
|
|
10661
|
+
case "listening":
|
|
10662
|
+
case "speaking": return "var(--brand-rose)";
|
|
10663
|
+
}
|
|
10664
|
+
}
|
|
10665
|
+
/** How long the opening flourish runs. Matches `.widget-portal`'s own duration. */
|
|
10666
|
+
var PORTAL_MS = 720;
|
|
10667
|
+
function ConciergeShell({ open, onOpenChange, state, messageArrived = false, launcher, launcherInitials, typing = false, operatorName, avatar = "orb", labels, children, badge, draft, onDraftChange, onSubmit, composerDisabled = false, voice, announcement, skin, skinStyle, idPrefix = "concierge", scrollKey, composerLeading, testIds, position = DEFAULT_CONCIERGE_POSITION, onPositionChange, attribution }) {
|
|
10668
|
+
const triggerId = `${idPrefix}-trigger`;
|
|
10669
|
+
const inputId = `${idPrefix}-input`;
|
|
10670
|
+
const [portalActive, setPortalActive] = useState(false);
|
|
10671
|
+
const panelRef = useRef(null);
|
|
10672
|
+
const transcriptRef = useRef(null);
|
|
10673
|
+
/** The transcript's content box — what grows as a reply streams in. */
|
|
10674
|
+
const transcriptContentRef = useRef(null);
|
|
10675
|
+
useEffect(() => {
|
|
10676
|
+
if (!open) return;
|
|
10677
|
+
setPortalActive(true);
|
|
10678
|
+
const id = window.setTimeout(() => setPortalActive(false), PORTAL_MS);
|
|
10679
|
+
return () => window.clearTimeout(id);
|
|
10680
|
+
}, [open]);
|
|
10681
|
+
/**
|
|
10682
|
+
* The knot's equivalent of the orb's `bot-nod` flourish — `BotFace` fires
|
|
10683
|
+
* `messageArrived` off `className` presence alone (a CSS animation restarts
|
|
10684
|
+
* whenever a class newly APPLIES), which works because `messageArrived`
|
|
10685
|
+
* itself is a derived, level-triggered boolean ("was the last turn from the
|
|
10686
|
+
* caller") that a component only needs to read once per render. `RopeKnot`'s
|
|
10687
|
+
* tighten/tap flourish is EDGE-triggered instead — it plays once per bump of
|
|
10688
|
+
* `tightenKey`, the exact vehicle a launcher press already uses
|
|
10689
|
+
* (`concierge-launcher.tsx`) — so this only bumps it on the RISING edge
|
|
10690
|
+
* (`false` → `true`), not on every render where `messageArrived` merely
|
|
10691
|
+
* stays `true` (e.g. while the agent is still thinking about the same
|
|
10692
|
+
* caller turn).
|
|
10693
|
+
*/
|
|
10694
|
+
const wasMessageArrived = useRef(false);
|
|
10695
|
+
const [knotTightenKey, setKnotTightenKey] = useState(0);
|
|
10696
|
+
useEffect(() => {
|
|
10697
|
+
if (messageArrived && !wasMessageArrived.current) setKnotTightenKey((k) => k + 1);
|
|
10698
|
+
wasMessageArrived.current = messageArrived;
|
|
10699
|
+
}, [messageArrived]);
|
|
10700
|
+
/**
|
|
10701
|
+
* Whether the transcript is following the conversation.
|
|
10702
|
+
*
|
|
10703
|
+
* True while the visitor is at (or near) the bottom, false the moment they
|
|
10704
|
+
* scroll up to re-read something — see the observer below for why the
|
|
10705
|
+
* distinction has to exist rather than always scrolling.
|
|
10706
|
+
*/
|
|
10707
|
+
const following = useRef(true);
|
|
10708
|
+
useEffect(() => {
|
|
10709
|
+
const el = transcriptRef.current;
|
|
10710
|
+
if (typeof el?.scrollTo !== "function") return;
|
|
10711
|
+
following.current = true;
|
|
10712
|
+
el.scrollTo({
|
|
10713
|
+
top: el.scrollHeight,
|
|
10714
|
+
behavior: "smooth"
|
|
10715
|
+
});
|
|
10716
|
+
}, [scrollKey, state]);
|
|
10717
|
+
/**
|
|
10718
|
+
* Follow the reply as it STREAMS, not just as it starts.
|
|
10719
|
+
*
|
|
10720
|
+
* `scrollKey` is `turns.length` (`voice-widget.tsx`), so the effect above
|
|
10721
|
+
* fires once, when the agent's turn is appended and still empty or one
|
|
10722
|
+
* token long. Everything after that arrives by SSE into the SAME turn: the
|
|
10723
|
+
* bubble grows downward under a scroll position that was correct when it
|
|
10724
|
+
* was pinned and is stale a word later. The visitor watched the TOP of a
|
|
10725
|
+
* long answer and had to scroll for every line of it — the newest text, the
|
|
10726
|
+
* only part they had not read, was the part off-screen.
|
|
10727
|
+
*
|
|
10728
|
+
* A `ResizeObserver` on the content is what closes that gap: it fires on
|
|
10729
|
+
* every layout change the growing text produces, at whatever rate the
|
|
10730
|
+
* tokens land, with no polling and no dependency on how the host chooses to
|
|
10731
|
+
* stream. `scrollKey` still owns the jump to a NEW turn; this owns staying
|
|
10732
|
+
* there while that turn fills in.
|
|
10733
|
+
*
|
|
10734
|
+
* Gated on `following` so it never fights the visitor. Scrolling up to
|
|
10735
|
+
* re-read an earlier answer while the agent is still typing is an ordinary
|
|
10736
|
+
* thing to do, and a transcript that yanks itself back down every 50ms
|
|
10737
|
+
* makes it impossible. `atBottom` uses a tolerance rather than an equality
|
|
10738
|
+
* — fractional scroll metrics on zoomed or hi-dpi displays never land
|
|
10739
|
+
* exactly, and smooth scrolling is still in flight when the next resize
|
|
10740
|
+
* arrives.
|
|
10741
|
+
*
|
|
10742
|
+
* `behavior: 'auto'`, unlike the jump above: a smooth scroll started every
|
|
10743
|
+
* time a token lands never finishes before the next one restarts it, which
|
|
10744
|
+
* reads as the transcript lagging behind its own text.
|
|
10745
|
+
*/
|
|
10746
|
+
useEffect(() => {
|
|
10747
|
+
const el = transcriptRef.current;
|
|
10748
|
+
if (!el || typeof el.scrollTo !== "function") return;
|
|
10749
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
10750
|
+
const atBottom = () => el.scrollHeight - el.scrollTop - el.clientHeight <= FOLLOW_TOLERANCE_PX;
|
|
10751
|
+
const onScroll = () => {
|
|
10752
|
+
following.current = atBottom();
|
|
10753
|
+
};
|
|
10754
|
+
const observer = new ResizeObserver(() => {
|
|
10755
|
+
if (!following.current) return;
|
|
10756
|
+
el.scrollTo({
|
|
10757
|
+
top: el.scrollHeight,
|
|
10758
|
+
behavior: "auto"
|
|
10759
|
+
});
|
|
10760
|
+
});
|
|
10761
|
+
const content = transcriptContentRef.current;
|
|
10762
|
+
if (content) observer.observe(content);
|
|
10763
|
+
el.addEventListener("scroll", onScroll, { passive: true });
|
|
10764
|
+
return () => {
|
|
10765
|
+
observer.disconnect();
|
|
10766
|
+
el.removeEventListener("scroll", onScroll);
|
|
10767
|
+
};
|
|
10768
|
+
}, [open]);
|
|
10769
|
+
const handleClose = useCallback(() => {
|
|
10770
|
+
onOpenChange(false);
|
|
10771
|
+
window.setTimeout(() => {
|
|
10772
|
+
document.getElementById(triggerId)?.focus({ preventScroll: true });
|
|
10773
|
+
}, 400);
|
|
10774
|
+
}, [onOpenChange, triggerId]);
|
|
10775
|
+
useEffect(() => {
|
|
10776
|
+
if (!open) return;
|
|
10777
|
+
const onKeyDown = (e) => {
|
|
10778
|
+
if (e.key === "Escape") {
|
|
10779
|
+
e.preventDefault();
|
|
10780
|
+
handleClose();
|
|
10781
|
+
return;
|
|
10782
|
+
}
|
|
10783
|
+
if (e.key !== "Tab") return;
|
|
10784
|
+
const panel = panelRef.current;
|
|
10785
|
+
if (!panel) return;
|
|
10786
|
+
const focusable = Array.from(panel.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])")).filter((el) => !el.hasAttribute("disabled") && el.offsetParent !== null);
|
|
10787
|
+
if (focusable.length === 0) return;
|
|
10788
|
+
const first = focusable[0];
|
|
10789
|
+
const last = focusable[focusable.length - 1];
|
|
10790
|
+
if (e.shiftKey && document.activeElement === first) {
|
|
10791
|
+
e.preventDefault();
|
|
10792
|
+
last.focus();
|
|
10793
|
+
} else if (!e.shiftKey && document.activeElement === last) {
|
|
10794
|
+
e.preventDefault();
|
|
10795
|
+
first.focus();
|
|
10796
|
+
}
|
|
10797
|
+
};
|
|
10798
|
+
const focusTimer = window.setTimeout(() => document.getElementById(inputId)?.focus(), 120);
|
|
10799
|
+
window.addEventListener("keydown", onKeyDown);
|
|
10800
|
+
return () => {
|
|
10801
|
+
window.clearTimeout(focusTimer);
|
|
10802
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
10803
|
+
};
|
|
10804
|
+
}, [
|
|
10805
|
+
open,
|
|
10806
|
+
handleClose,
|
|
10807
|
+
inputId
|
|
10808
|
+
]);
|
|
10809
|
+
/**
|
|
10810
|
+
* A call is running — anything but `idle`, including the phases that are not
|
|
10811
|
+
* speakable yet. The composer dims from the moment the caller commits to
|
|
10812
|
+
* voice, not only once the transport catches up.
|
|
10813
|
+
*/
|
|
10814
|
+
const inCall = voice !== void 0 && voice.phase !== "idle";
|
|
10815
|
+
/**
|
|
10816
|
+
* The voice-state pill's own state — `null` for `'idle'` (covered by
|
|
10817
|
+
* `inCall` too) AND `'blocked'` (NOT covered by `inCall`, which is why this
|
|
10818
|
+
* is its own value rather than reusing that boolean: a refused microphone
|
|
10819
|
+
* is still "a call", but it is not one of the four states the pill knows
|
|
10820
|
+
* how to draw — see `voiceStatePillState`'s own doc comment).
|
|
10821
|
+
*/
|
|
10822
|
+
const voicePillState = voiceStatePillState(voice);
|
|
10823
|
+
/**
|
|
10824
|
+
* The call has been asked for and has not answered yet — the transport
|
|
10825
|
+
* dialing, or the browser's own microphone prompt still open in front of
|
|
10826
|
+
* the caller (the host folds both into this one phase; see
|
|
10827
|
+
* `useVoiceSession`'s `micPending` and `host-widget.tsx`'s `callPhase`).
|
|
10828
|
+
*
|
|
10829
|
+
* For as long as it lasts, the round control is a SPINNER and is inert. A
|
|
10830
|
+
* microphone glyph here says "talk now" during the one stretch where
|
|
10831
|
+
* talking provably does nothing, and a pressable one turns a single
|
|
10832
|
+
* impatient gesture into either a second call or a mute of a call that does
|
|
10833
|
+
* not exist yet. The wait ends by itself, in one of two directions: `live`
|
|
10834
|
+
* (the microphone comes back) or `blocked` (the existing refused
|
|
10835
|
+
* presentation) — never in a spinner nobody can clear.
|
|
10836
|
+
*/
|
|
10837
|
+
const connecting = voice?.phase === "connecting";
|
|
10838
|
+
/** No voice leg to press at all, or a microphone the browser refused. */
|
|
10839
|
+
const micUnusable = voice !== void 0 && (voice.disabled === true || voice.phase === "blocked");
|
|
10840
|
+
/** Same fallback contract as the pill's own labels — see `voiceStatePillLabel`. */
|
|
10841
|
+
const connectingLabel = voice?.labels.connecting ?? defaultWidgetMessages.voice_state_connecting;
|
|
10842
|
+
/**
|
|
10843
|
+
* Start, mute or unmute — whichever the one round control means right now —
|
|
10844
|
+
* or, ahead of all three, the REASON it means nothing at all.
|
|
10845
|
+
*
|
|
10846
|
+
* `labels.unavailable` wins whenever `micUnusable` holds, because none of
|
|
10847
|
+
* the other three describe this button any more: every one of them names an
|
|
10848
|
+
* action, and an unusable control performs none. It is checked before
|
|
10849
|
+
* `connecting` too, so a host that disables the control mid-dial (an
|
|
10850
|
+
* escalation landing while the transport is still connecting) never leaves
|
|
10851
|
+
* "Connecting" as the name of a button that will now never connect. See
|
|
10852
|
+
* `ConciergeShellVoice.labels.unavailable`.
|
|
10853
|
+
*/
|
|
10854
|
+
const micLabel = micUnusable ? voice?.labels.unavailable ?? voice?.labels.start ?? "" : connecting ? connectingLabel : inCall ? (voice?.muted === true ? voice.labels.unmute : voice.labels.mute) ?? voice.labels.start : voice?.labels.start ?? "";
|
|
10855
|
+
const submit = (e) => {
|
|
10856
|
+
e.preventDefault();
|
|
10857
|
+
if (!draft.trim() || composerDisabled) return;
|
|
10858
|
+
onSubmit();
|
|
10859
|
+
};
|
|
10860
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
10861
|
+
className: "contents",
|
|
10862
|
+
"data-skin": skin,
|
|
10863
|
+
style: skinStyle,
|
|
10864
|
+
children: [
|
|
10865
|
+
/* @__PURE__ */ jsx(ConciergeLauncher, {
|
|
10866
|
+
id: triggerId,
|
|
10867
|
+
...testIds?.trigger !== void 0 ? { testId: testIds.trigger } : {},
|
|
10868
|
+
...labels.launcher !== void 0 ? { label: labels.launcher } : {},
|
|
10869
|
+
srLabel: labels.open,
|
|
10870
|
+
moveLabel: labels.move ?? labels.open,
|
|
10871
|
+
position,
|
|
10872
|
+
...onPositionChange !== void 0 ? { onPositionChange } : {},
|
|
10873
|
+
onOpen: () => onOpenChange(true),
|
|
10874
|
+
hidden: open,
|
|
10875
|
+
avatar,
|
|
10876
|
+
...launcher !== void 0 ? { spec: launcher } : {},
|
|
10877
|
+
...launcherInitials !== void 0 ? { initials: launcherInitials } : {}
|
|
10878
|
+
}),
|
|
10879
|
+
/* @__PURE__ */ jsx("div", {
|
|
10880
|
+
"aria-hidden": true,
|
|
10881
|
+
className: cn("bg-brand-ink/10 fixed inset-0 z-40 backdrop-blur-[2px] transition-opacity duration-500", open ? "pointer-events-auto opacity-100" : "pointer-events-none opacity-0")
|
|
10882
|
+
}),
|
|
10883
|
+
/* @__PURE__ */ jsx("div", {
|
|
10884
|
+
"aria-hidden": !open,
|
|
10885
|
+
className: cn("pointer-events-none fixed inset-x-0 z-50 flex", panelClasses(position)),
|
|
10886
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
10887
|
+
className: "relative flex flex-col items-center",
|
|
10888
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
10889
|
+
ref: panelRef,
|
|
10890
|
+
role: "dialog",
|
|
10891
|
+
"aria-modal": "true",
|
|
10892
|
+
"aria-label": labels.dialog,
|
|
10893
|
+
"data-testid": testIds?.panel,
|
|
10894
|
+
className: cn("origin-bottom rounded-full transition-[transform,opacity] duration-[700ms] motion-reduce:transition-none", open ? "pointer-events-auto aspect-[5/8] w-[min(97vw,50dvh)] min-h-0 scale-100 opacity-100 [container-type:size]" : "pointer-events-none size-16 scale-90 opacity-0"),
|
|
10895
|
+
style: { transitionTimingFunction: "cubic-bezier(0.16, 1, 0.3, 1)" },
|
|
10896
|
+
children: [
|
|
10897
|
+
/* @__PURE__ */ jsx("div", {
|
|
10898
|
+
"aria-hidden": true,
|
|
10899
|
+
className: cn("pointer-events-none absolute -inset-4 rounded-full opacity-25 blur-xl motion-reduce:animate-none", open ? "animate-[spin_18s_linear_infinite]" : "opacity-0"),
|
|
10900
|
+
style: { background: "conic-gradient(from 0deg, color-mix(in oklab, var(--brand-plum) 14%, transparent), color-mix(in oklab, var(--brand-rose) 16%, transparent), color-mix(in oklab, var(--brand-amber) 16%, transparent), color-mix(in oklab, var(--brand-plum) 14%, transparent))" }
|
|
10901
|
+
}),
|
|
10902
|
+
/* @__PURE__ */ jsx("div", {
|
|
10903
|
+
"aria-hidden": true,
|
|
10904
|
+
className: "pointer-events-none absolute inset-0 rounded-full p-[1.5px]",
|
|
10905
|
+
style: {
|
|
10906
|
+
background: "conic-gradient(from 140deg, color-mix(in oklab, var(--brand-plum) 45%, transparent), color-mix(in oklab, var(--brand-rose) 40%, transparent), color-mix(in oklab, var(--brand-amber) 45%, transparent), color-mix(in oklab, var(--brand-plum) 45%, transparent))",
|
|
10907
|
+
WebkitMask: "linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)",
|
|
10908
|
+
WebkitMaskComposite: "xor",
|
|
10909
|
+
maskComposite: "exclude"
|
|
10910
|
+
}
|
|
10911
|
+
}),
|
|
10912
|
+
/* @__PURE__ */ jsx("button", {
|
|
10913
|
+
type: "button",
|
|
10914
|
+
"aria-label": labels.close,
|
|
10915
|
+
onClick: handleClose,
|
|
10916
|
+
className: cn("absolute end-[8%] top-[8%] z-20 rounded-full bg-[var(--widget-card)] p-1.5 text-[var(--widget-foreground)] shadow-[0_2px_10px_-2px_color-mix(in_oklab,var(--brand-plum)_35%,transparent)] ring-1 ring-black/5", "hover:text-brand-plum hover:ring-brand-plum/30 focus-visible:ring-brand-plum/50 focus-visible:ring-2 focus-visible:outline-none", open ? "opacity-100 delay-[350ms]" : "opacity-0"),
|
|
10917
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-4" })
|
|
10918
|
+
}),
|
|
10919
|
+
/* @__PURE__ */ jsxs("div", {
|
|
10920
|
+
className: cn("relative flex h-full w-full flex-col items-center overflow-clip rounded-full border border-white/40 bg-[var(--widget-card)] backdrop-blur-xl", "shadow-[0_30px_80px_-20px_color-mix(in_oklab,var(--brand-plum)_25%,transparent),inset_0_1px_0_rgba(255,255,255,0.75)]"),
|
|
10921
|
+
children: [
|
|
10922
|
+
/* @__PURE__ */ jsx("div", {
|
|
10923
|
+
"aria-hidden": true,
|
|
10924
|
+
className: "pointer-events-none absolute -top-16 -right-10 h-56 w-56 rounded-full bg-[radial-gradient(circle,color-mix(in_oklab,var(--brand-amber)_7%,transparent),transparent_70%)] blur-2xl"
|
|
10925
|
+
}),
|
|
10926
|
+
/* @__PURE__ */ jsx("div", {
|
|
10927
|
+
"aria-hidden": true,
|
|
10928
|
+
className: "pointer-events-none absolute -bottom-20 -left-12 h-52 w-52 rounded-full bg-[radial-gradient(circle,color-mix(in_oklab,var(--brand-rose)_5%,transparent),transparent_70%)] blur-2xl"
|
|
10929
|
+
}),
|
|
10930
|
+
/* @__PURE__ */ jsxs("div", {
|
|
10931
|
+
className: cn("relative flex h-full w-full flex-col items-center justify-center px-2.5 py-1.5 transition-opacity duration-300 motion-reduce:transition-none", open ? "translate-y-0 opacity-100 delay-[300ms]" : "translate-y-2 opacity-0"),
|
|
10932
|
+
children: [
|
|
10933
|
+
/* @__PURE__ */ jsxs("div", {
|
|
10934
|
+
className: "pointer-events-none absolute inset-x-0 top-1.5 z-10 flex flex-col items-center gap-1",
|
|
10935
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
10936
|
+
className: "relative",
|
|
10937
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
10938
|
+
"aria-hidden": true,
|
|
10939
|
+
className: "absolute inset-0 rounded-full bg-[radial-gradient(circle,var(--widget-card)_58%,transparent_72%)]"
|
|
10940
|
+
}), /* @__PURE__ */ jsx(AvatarFace, {
|
|
10941
|
+
avatar,
|
|
10942
|
+
state,
|
|
10943
|
+
size: "lg",
|
|
10944
|
+
messageArrived,
|
|
10945
|
+
tightenKey: knotTightenKey
|
|
10946
|
+
})]
|
|
10947
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
10948
|
+
"data-testid": "widget-voice-state",
|
|
10949
|
+
className: cn("flex items-center gap-1.5 rounded-full bg-[var(--widget-card)] px-2.5 py-1 text-[10px] font-medium tracking-wider text-[var(--widget-foreground-muted)] uppercase ring-1 ring-black/5 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.15)] transition-opacity duration-300", voicePillState ? "opacity-100" : "opacity-0"),
|
|
10950
|
+
children: voicePillState ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
10951
|
+
"aria-hidden": true,
|
|
10952
|
+
className: cn("size-1.5 shrink-0 rounded-full", voicePillState !== "listening" && "animate-pulse motion-reduce:animate-none"),
|
|
10953
|
+
style: { backgroundColor: voiceStatePillDotColor(voicePillState) }
|
|
10954
|
+
}), /* @__PURE__ */ jsx("span", { children: voiceStatePillLabel(voicePillState, voice?.labels) })] }) : null
|
|
10955
|
+
})]
|
|
10956
|
+
}),
|
|
10957
|
+
badge == null && operatorName === void 0 ? null : /* @__PURE__ */ jsxs("div", {
|
|
10958
|
+
className: "z-10 mt-[104px] w-[68%] shrink-0 text-center",
|
|
10959
|
+
children: [operatorName === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
10960
|
+
"data-testid": "widget-operator-name",
|
|
10961
|
+
dir: "auto",
|
|
10962
|
+
className: "text-[11px] font-medium text-[var(--widget-foreground-muted)]",
|
|
10963
|
+
children: operatorName
|
|
10964
|
+
}), badge]
|
|
10965
|
+
}),
|
|
10966
|
+
/* @__PURE__ */ jsx("div", {
|
|
10967
|
+
ref: transcriptRef,
|
|
10968
|
+
className: "no-scrollbar w-full min-h-0 flex-1 overflow-y-auto",
|
|
10969
|
+
style: badge == null ? TRANSCRIPT_EDGE_FADE : TRANSCRIPT_EDGE_FADE_WITH_BADGE,
|
|
10970
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
10971
|
+
ref: transcriptContentRef,
|
|
10972
|
+
children: [children, typing ? /* @__PURE__ */ jsxs("p", {
|
|
10973
|
+
"data-testid": "widget-typing-indicator",
|
|
10974
|
+
className: "flex items-center gap-1 px-1 py-1 text-[var(--widget-foreground-muted)]",
|
|
10975
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
10976
|
+
className: "sr-only",
|
|
10977
|
+
children: defaultWidgetMessages.typing
|
|
10978
|
+
}), [
|
|
10979
|
+
0,
|
|
10980
|
+
1,
|
|
10981
|
+
2
|
|
10982
|
+
].map((i) => /* @__PURE__ */ jsx("span", {
|
|
10983
|
+
"aria-hidden": "true",
|
|
10984
|
+
className: "h-1.5 w-1.5 animate-bounce rounded-full bg-current motion-reduce:animate-none",
|
|
10985
|
+
style: {
|
|
10986
|
+
animationDelay: `${i * 140}ms`,
|
|
10987
|
+
animationDuration: "1s"
|
|
10988
|
+
}
|
|
10989
|
+
}, i))]
|
|
10990
|
+
}) : null]
|
|
10991
|
+
})
|
|
10992
|
+
}),
|
|
10993
|
+
/* @__PURE__ */ jsx("div", {
|
|
10994
|
+
"aria-hidden": true,
|
|
10995
|
+
className: "pointer-events-none absolute inset-x-0 bottom-0 z-10 bg-[linear-gradient(to_bottom,transparent,var(--widget-card)_38%,var(--widget-card))]",
|
|
10996
|
+
style: { height: COMPOSER_GROUND_LEN }
|
|
10997
|
+
}),
|
|
10998
|
+
/* @__PURE__ */ jsx("div", {
|
|
10999
|
+
className: "pointer-events-none absolute inset-x-0 z-20 flex justify-center",
|
|
11000
|
+
style: { bottom: voice ? COMPOSER_BOTTOM_LEN : COMPOSER_BOTTOM_NO_VOICE_LEN },
|
|
11001
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
11002
|
+
className: cn("flex w-[71%] flex-col items-center gap-2.5", open ? "pointer-events-auto" : "pointer-events-none"),
|
|
11003
|
+
style: { maxWidth: COMPOSER_MAX_WIDTH_LEN },
|
|
11004
|
+
children: [/* @__PURE__ */ jsxs("form", {
|
|
11005
|
+
className: "flex w-full items-center gap-2",
|
|
11006
|
+
onSubmit: submit,
|
|
11007
|
+
children: [composerLeading, /* @__PURE__ */ jsxs("div", {
|
|
11008
|
+
className: "relative flex-1",
|
|
11009
|
+
children: [
|
|
11010
|
+
/* @__PURE__ */ jsx("label", {
|
|
11011
|
+
htmlFor: inputId,
|
|
11012
|
+
className: "sr-only",
|
|
11013
|
+
children: labels.composerPlaceholder
|
|
11014
|
+
}),
|
|
11015
|
+
/* @__PURE__ */ jsx("input", {
|
|
11016
|
+
id: inputId,
|
|
11017
|
+
"data-testid": testIds?.input,
|
|
11018
|
+
value: draft,
|
|
11019
|
+
onChange: (e) => onDraftChange(e.target.value),
|
|
11020
|
+
placeholder: labels.composerPlaceholder,
|
|
11021
|
+
dir: "auto",
|
|
11022
|
+
disabled: composerDisabled,
|
|
11023
|
+
className: cn("border-brand-plum/12 h-[40px] w-full rounded-3xl border bg-[var(--widget-chip)] ps-4 pe-12 text-[14px] text-[var(--widget-foreground)] placeholder:text-[var(--widget-foreground-muted)]", "focus:border-brand-plum/30 focus:ring-brand-plum/15 transition-[border-color] focus:bg-[var(--widget-bubble)] focus:ring-2 focus:outline-none disabled:opacity-50", inCall && draft === "" && "opacity-60 focus:opacity-100")
|
|
11024
|
+
}),
|
|
11025
|
+
draft.trim() && /* @__PURE__ */ jsx("button", {
|
|
11026
|
+
type: "submit",
|
|
11027
|
+
"aria-label": labels.send,
|
|
11028
|
+
"data-testid": testIds?.send,
|
|
11029
|
+
disabled: composerDisabled,
|
|
11030
|
+
className: "from-brand-plum to-brand-rose text-[var(--widget-accent-foreground)] absolute end-2 top-1/2 flex size-9 -translate-y-1/2 items-center justify-center rounded-full bg-gradient-to-br transition-[transform,opacity] hover:scale-105 disabled:opacity-40",
|
|
11031
|
+
children: /* @__PURE__ */ jsx(Send, { className: "size-4 rtl:-scale-x-100" })
|
|
11032
|
+
})
|
|
11033
|
+
]
|
|
11034
|
+
})]
|
|
11035
|
+
}), voice ? /* @__PURE__ */ jsxs("div", {
|
|
11036
|
+
className: "mt-1 flex items-center gap-3",
|
|
11037
|
+
children: [
|
|
11038
|
+
/* @__PURE__ */ jsx("button", {
|
|
11039
|
+
type: "button",
|
|
11040
|
+
onClick: connecting ? void 0 : inCall ? voice.onToggleMute ?? voice.onStart : voice.onStart,
|
|
11041
|
+
disabled: micUnusable || connecting,
|
|
11042
|
+
"data-testid": testIds?.mic,
|
|
11043
|
+
title: micLabel,
|
|
11044
|
+
"aria-label": micLabel,
|
|
11045
|
+
...connecting ? { "aria-busy": true } : {},
|
|
11046
|
+
...inCall && !connecting ? { "aria-pressed": voice.muted ?? false } : {},
|
|
11047
|
+
className: cn("from-brand-plum to-brand-rose text-[var(--widget-accent-foreground)] flex size-12 shrink-0 items-center justify-center rounded-full bg-gradient-to-br transition-[transform,opacity]", micUnusable ? "cursor-not-allowed opacity-40" : connecting ? "cursor-wait" : cn("hover:scale-105 focus-visible:ring-2 focus-visible:ring-white/50 focus-visible:outline-none", "shadow-[0_0_0_1px_color-mix(in_oklab,var(--brand-plum)_18%,transparent),0_4px_14px_-2px_color-mix(in_oklab,var(--brand-plum)_45%,transparent),0_0_22px_-4px_color-mix(in_oklab,var(--brand-rose)_40%,transparent)]", "hover:shadow-[0_0_0_1px_color-mix(in_oklab,var(--brand-plum)_26%,transparent),0_6px_18px_-2px_color-mix(in_oklab,var(--brand-plum)_60%,transparent),0_0_30px_-4px_color-mix(in_oklab,var(--brand-rose)_55%,transparent)]"), inCall && !connecting && voice.muted !== true && "ring-brand-rose/50 ring-4"),
|
|
11048
|
+
children: connecting ? /* @__PURE__ */ jsx("span", {
|
|
11049
|
+
"aria-hidden": "true",
|
|
11050
|
+
"data-testid": "widget-mic-spinner",
|
|
11051
|
+
className: "flex items-center justify-center",
|
|
11052
|
+
children: /* @__PURE__ */ jsx(MorphingLoader, {
|
|
11053
|
+
size: "md",
|
|
11054
|
+
variant: "light",
|
|
11055
|
+
label: connectingLabel
|
|
11056
|
+
})
|
|
11057
|
+
}) : inCall && voice.muted === true ? /* @__PURE__ */ jsx(MicOff, { className: "size-5" }) : /* @__PURE__ */ jsx(Mic, { className: "size-5" })
|
|
11058
|
+
}),
|
|
11059
|
+
inCall && voice.agentSpeaking === true && voice.onInterrupt !== void 0 ? /* @__PURE__ */ jsx("button", {
|
|
11060
|
+
type: "button",
|
|
11061
|
+
onClick: () => voice.onInterrupt?.("tap"),
|
|
11062
|
+
"data-testid": "widget-interrupt",
|
|
11063
|
+
title: voice.labels.interrupt ?? "",
|
|
11064
|
+
"aria-label": voice.labels.interrupt ?? "",
|
|
11065
|
+
className: cn("flex size-10 shrink-0 items-center justify-center rounded-full bg-[var(--widget-chip)] text-[var(--widget-foreground)] transition-colors", "hover:bg-[var(--widget-bubble)] focus-visible:ring-2 focus-visible:ring-[var(--widget-accent-ring)] focus-visible:outline-none"),
|
|
11066
|
+
children: /* @__PURE__ */ jsx(Square, { className: "size-4" })
|
|
11067
|
+
}) : null,
|
|
11068
|
+
voice.phase === "blocked" && voice.onFixPermission !== void 0 ? /* @__PURE__ */ jsx("button", {
|
|
11069
|
+
type: "button",
|
|
11070
|
+
onClick: voice.onFixPermission,
|
|
11071
|
+
"data-testid": "widget-fix-permission",
|
|
11072
|
+
className: cn("shrink-0 rounded-full bg-[var(--widget-chip)] px-3 py-2 text-xs font-medium text-[var(--widget-foreground)] transition-colors", "hover:bg-[var(--widget-bubble)] focus-visible:ring-2 focus-visible:ring-[var(--widget-accent-ring)] focus-visible:outline-none"),
|
|
11073
|
+
children: voice.labels.fixBrowser ?? defaultWidgetMessages.dock_fix_browser
|
|
11074
|
+
}) : null,
|
|
11075
|
+
inCall && voice.onEnd !== void 0 ? /* @__PURE__ */ jsx("button", {
|
|
11076
|
+
type: "button",
|
|
11077
|
+
onClick: voice.onEnd,
|
|
11078
|
+
"data-testid": testIds?.endCall,
|
|
11079
|
+
title: voice.labels.end ?? "",
|
|
11080
|
+
"aria-label": voice.labels.end ?? "",
|
|
11081
|
+
className: cn("bg-destructive/10 text-destructive hover:bg-destructive/20 flex size-10 shrink-0 items-center justify-center rounded-full transition-colors", "focus-visible:ring-destructive/30 focus-visible:ring-2 focus-visible:outline-none"),
|
|
11082
|
+
children: /* @__PURE__ */ jsx(PhoneOff, { className: "size-4" })
|
|
11083
|
+
}) : null
|
|
11084
|
+
]
|
|
11085
|
+
}) : null]
|
|
11086
|
+
})
|
|
11087
|
+
})
|
|
11088
|
+
]
|
|
11089
|
+
})
|
|
11090
|
+
]
|
|
11091
|
+
})
|
|
11092
|
+
]
|
|
11093
|
+
}), attribution ? /* @__PURE__ */ jsxs("a", {
|
|
11094
|
+
href: attribution.href,
|
|
11095
|
+
target: "_blank",
|
|
11096
|
+
rel: "noopener noreferrer",
|
|
11097
|
+
"data-testid": "widget-branding",
|
|
11098
|
+
className: cn("absolute top-full left-1/2 mt-2 inline-flex -translate-x-1/2 items-center gap-1.5 whitespace-nowrap text-xs transition-opacity duration-300", open ? "pointer-events-auto opacity-100" : "pointer-events-none opacity-0"),
|
|
11099
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
11100
|
+
"aria-hidden": true,
|
|
11101
|
+
className: "size-2.5 rounded-full bg-gradient-to-br from-brand-rose to-brand-amber"
|
|
11102
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
11103
|
+
className: "text-brand-plum font-semibold tracking-tight",
|
|
11104
|
+
children: attribution.name
|
|
11105
|
+
})]
|
|
11106
|
+
}) : null]
|
|
11107
|
+
})
|
|
11108
|
+
}),
|
|
11109
|
+
portalActive && /* @__PURE__ */ jsx("div", {
|
|
11110
|
+
"aria-hidden": true,
|
|
11111
|
+
className: cn("pointer-events-none fixed z-[55]", positionClasses(position)),
|
|
11112
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
11113
|
+
className: "widget-portal size-16",
|
|
11114
|
+
children: /* @__PURE__ */ jsx(MorphingLoader, {
|
|
11115
|
+
size: "full",
|
|
11116
|
+
label: labels.open
|
|
11117
|
+
})
|
|
11118
|
+
})
|
|
11119
|
+
}),
|
|
11120
|
+
/* @__PURE__ */ jsx("div", {
|
|
11121
|
+
"aria-live": "polite",
|
|
11122
|
+
"aria-atomic": "false",
|
|
11123
|
+
className: "sr-only",
|
|
11124
|
+
children: announcement
|
|
11125
|
+
})
|
|
11126
|
+
]
|
|
11127
|
+
});
|
|
11128
|
+
}
|
|
11129
|
+
//#endregion
|
|
11130
|
+
//#region src/widget/widget-view.ts
|
|
11131
|
+
/** Every launcher field off — the shape most states return. */
|
|
11132
|
+
var QUIET_LAUNCHER = {
|
|
11133
|
+
busy: false,
|
|
11134
|
+
dimmed: false,
|
|
11135
|
+
disabled: false,
|
|
11136
|
+
badge: false,
|
|
11137
|
+
initials: false
|
|
11138
|
+
};
|
|
11139
|
+
/**
|
|
11140
|
+
* The widget's presentation of a state the shared machine already decided.
|
|
11141
|
+
*
|
|
11142
|
+
* @param snapshot the state and the shared facts — see {@link ConciergeSnapshot}
|
|
11143
|
+
* @param input the session, read for CONTENT only (a partial transcript, an
|
|
11144
|
+
* operator's line, the host's error text) — never to decide the state
|
|
11145
|
+
*/
|
|
11146
|
+
function deriveWidgetView(snapshot, input) {
|
|
11147
|
+
const { state } = snapshot;
|
|
11148
|
+
const shared = {
|
|
11149
|
+
state,
|
|
11150
|
+
handoff: snapshot.handoff,
|
|
11151
|
+
callActive: snapshot.callActive,
|
|
11152
|
+
shelfCount: snapshot.shelfCount
|
|
11153
|
+
};
|
|
11154
|
+
const text = (value) => value !== void 0 && value !== "" ? {
|
|
11155
|
+
kind: "text",
|
|
11156
|
+
text: value
|
|
11157
|
+
} : null;
|
|
11158
|
+
switch (state) {
|
|
11159
|
+
case "dormant": return {
|
|
11160
|
+
...shared,
|
|
11161
|
+
avatar: "idle",
|
|
11162
|
+
launcher: QUIET_LAUNCHER,
|
|
11163
|
+
announce: false,
|
|
11164
|
+
typing: false,
|
|
11165
|
+
interrupt: false,
|
|
11166
|
+
panel: "as-is",
|
|
11167
|
+
status: null,
|
|
11168
|
+
composerDisabled: false
|
|
11169
|
+
};
|
|
11170
|
+
case "connecting": return {
|
|
11171
|
+
...shared,
|
|
11172
|
+
avatar: "thinking",
|
|
11173
|
+
launcher: {
|
|
11174
|
+
...QUIET_LAUNCHER,
|
|
11175
|
+
busy: true
|
|
11176
|
+
},
|
|
11177
|
+
announce: false,
|
|
11178
|
+
typing: false,
|
|
11179
|
+
interrupt: false,
|
|
11180
|
+
panel: "as-is",
|
|
11181
|
+
status: {
|
|
11182
|
+
kind: "message",
|
|
11183
|
+
key: "dock_connecting"
|
|
11184
|
+
},
|
|
11185
|
+
composerDisabled: false
|
|
11186
|
+
};
|
|
11187
|
+
case "listening": return {
|
|
11188
|
+
...shared,
|
|
11189
|
+
avatar: "listening",
|
|
11190
|
+
launcher: QUIET_LAUNCHER,
|
|
11191
|
+
announce: false,
|
|
11192
|
+
typing: false,
|
|
11193
|
+
interrupt: false,
|
|
11194
|
+
panel: "as-is",
|
|
11195
|
+
status: text(input.partialTranscript) ?? {
|
|
11196
|
+
kind: "message",
|
|
11197
|
+
key: "dock_listening"
|
|
11198
|
+
},
|
|
11199
|
+
composerDisabled: false
|
|
11200
|
+
};
|
|
11201
|
+
case "thinking": return {
|
|
11202
|
+
...shared,
|
|
11203
|
+
avatar: "thinking",
|
|
11204
|
+
launcher: QUIET_LAUNCHER,
|
|
11205
|
+
announce: false,
|
|
11206
|
+
typing: false,
|
|
11207
|
+
interrupt: false,
|
|
11208
|
+
panel: "as-is",
|
|
11209
|
+
status: text(input.preamble) ?? {
|
|
11210
|
+
kind: "message",
|
|
11211
|
+
key: "dock_thinking"
|
|
11212
|
+
},
|
|
11213
|
+
composerDisabled: false
|
|
11214
|
+
};
|
|
11215
|
+
case "speaking": return {
|
|
11216
|
+
...shared,
|
|
11217
|
+
avatar: "speaking",
|
|
11218
|
+
launcher: QUIET_LAUNCHER,
|
|
11219
|
+
announce: false,
|
|
11220
|
+
typing: false,
|
|
11221
|
+
interrupt: true,
|
|
11222
|
+
panel: "as-is",
|
|
11223
|
+
status: text(input.clause) ?? {
|
|
11224
|
+
kind: "message",
|
|
11225
|
+
key: "dock_thinking"
|
|
11226
|
+
},
|
|
11227
|
+
composerDisabled: false
|
|
11228
|
+
};
|
|
11229
|
+
case "ducked": return {
|
|
11230
|
+
...shared,
|
|
11231
|
+
avatar: "idle",
|
|
11232
|
+
launcher: {
|
|
11233
|
+
...QUIET_LAUNCHER,
|
|
11234
|
+
dimmed: true
|
|
11235
|
+
},
|
|
11236
|
+
announce: false,
|
|
11237
|
+
typing: false,
|
|
11238
|
+
interrupt: false,
|
|
11239
|
+
panel: "as-is",
|
|
11240
|
+
status: {
|
|
11241
|
+
kind: "message",
|
|
11242
|
+
key: "dock_ducked"
|
|
11243
|
+
},
|
|
11244
|
+
composerDisabled: false
|
|
11245
|
+
};
|
|
11246
|
+
case "reconnecting": return {
|
|
11247
|
+
...shared,
|
|
11248
|
+
avatar: "idle",
|
|
11249
|
+
launcher: {
|
|
11250
|
+
...QUIET_LAUNCHER,
|
|
11251
|
+
badge: true
|
|
11252
|
+
},
|
|
11253
|
+
announce: true,
|
|
11254
|
+
typing: false,
|
|
11255
|
+
interrupt: false,
|
|
11256
|
+
panel: "as-is",
|
|
11257
|
+
status: {
|
|
11258
|
+
kind: "message",
|
|
11259
|
+
key: input.roomDropped ? "dock_still_here_resume" : "dock_still_here"
|
|
11260
|
+
},
|
|
11261
|
+
composerDisabled: false
|
|
11262
|
+
};
|
|
11263
|
+
case "muted": return {
|
|
11264
|
+
...shared,
|
|
11265
|
+
avatar: "idle",
|
|
11266
|
+
launcher: QUIET_LAUNCHER,
|
|
11267
|
+
announce: true,
|
|
11268
|
+
typing: false,
|
|
11269
|
+
interrupt: false,
|
|
11270
|
+
panel: "as-is",
|
|
11271
|
+
status: {
|
|
11272
|
+
kind: "message",
|
|
11273
|
+
key: "dock_muted"
|
|
11274
|
+
},
|
|
11275
|
+
composerDisabled: false
|
|
11276
|
+
};
|
|
11277
|
+
case "mic_blocked": return {
|
|
11278
|
+
...shared,
|
|
11279
|
+
avatar: "idle",
|
|
11280
|
+
launcher: QUIET_LAUNCHER,
|
|
11281
|
+
announce: true,
|
|
11282
|
+
typing: false,
|
|
11283
|
+
interrupt: false,
|
|
11284
|
+
panel: "as-is",
|
|
11285
|
+
status: {
|
|
11286
|
+
kind: "message",
|
|
11287
|
+
key: "dock_mic_blocked"
|
|
11288
|
+
},
|
|
11289
|
+
composerDisabled: false
|
|
11290
|
+
};
|
|
11291
|
+
case "typing": return {
|
|
11292
|
+
...shared,
|
|
11293
|
+
avatar: "idle",
|
|
11294
|
+
launcher: QUIET_LAUNCHER,
|
|
11295
|
+
announce: false,
|
|
11296
|
+
typing: input.composing,
|
|
11297
|
+
interrupt: false,
|
|
11298
|
+
panel: "as-is",
|
|
11299
|
+
status: null,
|
|
11300
|
+
composerDisabled: false
|
|
11301
|
+
};
|
|
11302
|
+
case "human": return {
|
|
11303
|
+
...shared,
|
|
11304
|
+
avatar: "idle",
|
|
11305
|
+
launcher: {
|
|
11306
|
+
...QUIET_LAUNCHER,
|
|
11307
|
+
initials: true
|
|
11308
|
+
},
|
|
11309
|
+
announce: true,
|
|
11310
|
+
typing: input.composing,
|
|
11311
|
+
interrupt: false,
|
|
11312
|
+
panel: "as-is",
|
|
11313
|
+
status: text(input.operatorLine) ?? {
|
|
11314
|
+
kind: "message",
|
|
11315
|
+
key: "escalated_banner"
|
|
11316
|
+
},
|
|
11317
|
+
composerDisabled: false
|
|
11318
|
+
};
|
|
11319
|
+
case "offline": return {
|
|
11320
|
+
...shared,
|
|
11321
|
+
avatar: "idle",
|
|
11322
|
+
launcher: {
|
|
11323
|
+
...QUIET_LAUNCHER,
|
|
11324
|
+
disabled: true
|
|
11325
|
+
},
|
|
11326
|
+
announce: true,
|
|
11327
|
+
typing: false,
|
|
11328
|
+
interrupt: false,
|
|
11329
|
+
panel: "as-is",
|
|
11330
|
+
status: text(input.offlineMessage),
|
|
11331
|
+
composerDisabled: true
|
|
11332
|
+
};
|
|
11333
|
+
case "error": return {
|
|
11334
|
+
...shared,
|
|
11335
|
+
avatar: "idle",
|
|
11336
|
+
launcher: QUIET_LAUNCHER,
|
|
11337
|
+
announce: true,
|
|
11338
|
+
typing: false,
|
|
11339
|
+
interrupt: false,
|
|
11340
|
+
panel: "as-is",
|
|
11341
|
+
status: input.errorSource === "voice" && input.voice.enabled && input.voice.phase === "failed" ? {
|
|
11342
|
+
kind: "message",
|
|
11343
|
+
key: "dock_voice_failed"
|
|
11344
|
+
} : text(input.error),
|
|
11345
|
+
composerDisabled: false
|
|
11346
|
+
};
|
|
11347
|
+
case "cards": return {
|
|
11348
|
+
...shared,
|
|
11349
|
+
avatar: "idle",
|
|
11350
|
+
launcher: {
|
|
11351
|
+
...QUIET_LAUNCHER,
|
|
11352
|
+
badge: true
|
|
11353
|
+
},
|
|
11354
|
+
announce: false,
|
|
11355
|
+
typing: false,
|
|
11356
|
+
interrupt: false,
|
|
11357
|
+
panel: "as-is",
|
|
11358
|
+
status: {
|
|
11359
|
+
kind: "message",
|
|
11360
|
+
key: "dock_cards"
|
|
11361
|
+
},
|
|
11362
|
+
composerDisabled: false
|
|
11363
|
+
};
|
|
11364
|
+
}
|
|
11365
|
+
throw new TypeError(`Unknown concierge state: ${JSON.stringify(state)}`);
|
|
11366
|
+
}
|
|
11367
|
+
//#endregion
|
|
11368
|
+
//#region src/widget/shell-renderer.tsx
|
|
11369
|
+
/**
|
|
11370
|
+
* The widget — launcher and panel — as a `ConciergeRenderer`
|
|
11371
|
+
* (docs/CONCIERGE_GENERATIONS.md §3).
|
|
11372
|
+
*
|
|
11373
|
+
* Revived from the wiring `voice-widget.tsx` had before the dock (`3a6452ca^`)
|
|
11374
|
+
* and re-pointed at the `ConversationView` both renderers now read. What
|
|
11375
|
+
* differs from the dock is presentation only: the shell has no row, so the
|
|
11376
|
+
* status line is a badge under the panel header rather than a caption; the
|
|
11377
|
+
* attachment control sits before the composer rather than in a `human` row;
|
|
11378
|
+
* the panel is a thing that opens and closes, so this renderer owns that
|
|
11379
|
+
* state — and the launcher position, since dragging the launcher is a fact
|
|
11380
|
+
* about this chrome and not about the conversation.
|
|
11381
|
+
*
|
|
11382
|
+
* Phase 4 (§4) records, per state, where the widget-native presentation
|
|
11383
|
+
* should differ from the mapping here; this is the working baseline.
|
|
11384
|
+
*/
|
|
11385
|
+
/** §9.1 `layout.desktopAlign` in the shell's own anchor vocabulary. */
|
|
11386
|
+
function positionFor(dock) {
|
|
11387
|
+
const align = dock?.layout?.desktopAlign;
|
|
11388
|
+
return align === "left" || align === "right" ? `bottom-${align}` : DEFAULT_CONCIERGE_POSITION;
|
|
11389
|
+
}
|
|
11390
|
+
function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndCall, statusKind, statusLine, escalated, operatorName, humanTyping, composing, channel, draft, onDraftChange, submit, attaching, onAttach, attachInput, transcript, extras, messages, skinStyle, avatar, attribution, voice: derivedVoice, dock }) {
|
|
11391
|
+
const [open, setOpen] = useState(dock?.initialMinimised === false);
|
|
11392
|
+
const onReady = dock?.onReady;
|
|
11393
|
+
useLayoutEffect(() => {
|
|
11394
|
+
onReady?.();
|
|
11395
|
+
}, []);
|
|
11396
|
+
const [position, setPosition] = useState(() => positionFor(dock));
|
|
11397
|
+
const draggable = dock?.layout?.draggable !== false;
|
|
11398
|
+
const launcherLabel = dock?.copy?.minimisedLabel?.trim();
|
|
11399
|
+
/**
|
|
11400
|
+
* The host's voice bag, merged the same way `DockRenderer` merges it: the
|
|
11401
|
+
* conversation derives the PHASE fields (`agentSpeaking`, `micOpen` …) and
|
|
11402
|
+
* the host supplies the CALLBACKS (`onInterrupt`, `onFixPermission`) on
|
|
11403
|
+
* `dock.voice`. A renderer that read only the derived half would draw a
|
|
11404
|
+
* control the host never gets told about.
|
|
11405
|
+
*/
|
|
11406
|
+
const voiceInput = {
|
|
11407
|
+
...derivedVoice,
|
|
11408
|
+
...dock?.voice ?? {}
|
|
11409
|
+
};
|
|
11410
|
+
const voiceUnavailable = showMic && escalated ? messages.voice_unavailable_escalated : void 0;
|
|
11411
|
+
const lastTurn = turns[turns.length - 1];
|
|
11412
|
+
/**
|
|
11413
|
+
* The SAME state machine the dock runs (docs/CONCIERGE_GENERATIONS.md §2:
|
|
11414
|
+
* one state, two presentations). `Dock` builds a `DockStateInput` from its
|
|
11415
|
+
* props and calls `deriveDockState`; this is that, in the widget's terms.
|
|
11416
|
+
*
|
|
11417
|
+
* Two fields the dock reads from its own internals rather than from props,
|
|
11418
|
+
* answered here the widget's way:
|
|
11419
|
+
*
|
|
11420
|
+
* - `engaged` — the dock tracks a row that has been woken. The widget's
|
|
11421
|
+
* equivalent is a panel the shopper opened, or a call that is running.
|
|
11422
|
+
* - `sheetOpen` — the dock's sheet is the widget's panel.
|
|
11423
|
+
*
|
|
11424
|
+
* And two the widget does not have yet: `ducked` and `textIdle` are timers
|
|
11425
|
+
* the dock runs to recede its row. The widget has no row, and §4's answer —
|
|
11426
|
+
* the launcher dims — is a row of its own with its own timer; until that
|
|
11427
|
+
* lands, the widget never ducks, which is visible here rather than hidden
|
|
11428
|
+
* behind a prop that silently reads `false`.
|
|
11429
|
+
*/
|
|
11430
|
+
const stateInput = useMemo(() => ({
|
|
11431
|
+
...idleConciergeInput,
|
|
11432
|
+
engaged: open || callPhase !== "idle",
|
|
11433
|
+
voice: {
|
|
11434
|
+
enabled: voiceInput.enabled === true,
|
|
11435
|
+
phase: voiceInput.phase ?? "idle",
|
|
11436
|
+
micOpen: voiceInput.micOpen === true,
|
|
11437
|
+
micPending: voiceInput.micPending === true,
|
|
11438
|
+
micBlocked: voiceInput.micBlocked === true,
|
|
11439
|
+
agentPresent: voiceInput.agentPresent === true,
|
|
11440
|
+
agentSpeaking: voiceInput.agentSpeaking === true,
|
|
11441
|
+
callerSpeaking: voiceInput.callerSpeaking === true,
|
|
11442
|
+
awaitingAgent: voiceInput.awaitingAgent === true
|
|
11443
|
+
},
|
|
11444
|
+
draft,
|
|
11445
|
+
escalated,
|
|
11446
|
+
canAttach: onAttach !== void 0,
|
|
11447
|
+
canFixPermission: voiceInput.onFixPermission !== void 0,
|
|
11448
|
+
offline: dock?.offline === true,
|
|
11449
|
+
reconnecting: dock?.reconnecting === true,
|
|
11450
|
+
roomDropped: dock?.roomDropped === true,
|
|
11451
|
+
sheetOpen: open,
|
|
11452
|
+
shelfCount: dock?.shelf?.items.length ?? 0,
|
|
11453
|
+
hasTranscript: turns.length > 0,
|
|
11454
|
+
channel,
|
|
11455
|
+
composing,
|
|
11456
|
+
...operatorName !== void 0 ? { operatorLine: operatorName } : {},
|
|
11457
|
+
...dock?.copy?.offlineMessage !== void 0 ? { offlineMessage: dock.copy.offlineMessage } : {},
|
|
11458
|
+
...statusLine !== void 0 && statusLine !== "" ? {
|
|
11459
|
+
error: statusLine,
|
|
11460
|
+
...statusKind !== void 0 ? { errorSource: statusKind } : {}
|
|
11461
|
+
} : {},
|
|
11462
|
+
...dock?.partialTranscript !== void 0 ? { partialTranscript: dock.partialTranscript } : {},
|
|
11463
|
+
...dock?.preamble !== void 0 ? { preamble: dock.preamble } : {},
|
|
11464
|
+
...dock?.clause !== void 0 ? { clause: dock.clause } : {}
|
|
11465
|
+
}), [
|
|
11466
|
+
open,
|
|
11467
|
+
callPhase,
|
|
11468
|
+
voiceInput,
|
|
11469
|
+
draft,
|
|
11470
|
+
escalated,
|
|
11471
|
+
onAttach,
|
|
11472
|
+
dock,
|
|
11473
|
+
turns.length,
|
|
11474
|
+
channel,
|
|
11475
|
+
composing,
|
|
11476
|
+
operatorName,
|
|
11477
|
+
statusLine,
|
|
11478
|
+
statusKind
|
|
11479
|
+
]);
|
|
11480
|
+
const view = useMemo(() => deriveWidgetView(deriveConciergeState(stateInput), stateInput), [stateInput]);
|
|
11481
|
+
/**
|
|
11482
|
+
* The status line in the shopper's own language. The view decides WHICH
|
|
11483
|
+
* line, never its words: a `text` status is the host's own string (a
|
|
11484
|
+
* partial transcript, an operator's line, an error) and a `message` status
|
|
11485
|
+
* is a key into the tenant's catalogue. Same split the dock's
|
|
11486
|
+
* `resolveCaption` makes, for the same reason — a renderer that invented
|
|
11487
|
+
* copy would need translating twice.
|
|
11488
|
+
*/
|
|
11489
|
+
const statusText = view.status === null ? void 0 : view.status.kind === "text" ? view.status.text : messages[view.status.key] ?? void 0;
|
|
11490
|
+
const voice = showMic ? {
|
|
11491
|
+
phase: callPhase,
|
|
11492
|
+
onStart: onToggleMic,
|
|
11493
|
+
...onEndCall !== void 0 ? { onEnd: onEndCall } : {},
|
|
11494
|
+
onToggleMute: onToggleMic,
|
|
11495
|
+
muted: !micOpen,
|
|
11496
|
+
agentSpeaking: view.interrupt,
|
|
11497
|
+
...voiceInput.onInterrupt !== void 0 ? { onInterrupt: voiceInput.onInterrupt } : {},
|
|
11498
|
+
...voiceInput.onFixPermission !== void 0 ? { onFixPermission: voiceInput.onFixPermission } : {},
|
|
11499
|
+
...voiceUnavailable !== void 0 ? { disabled: true } : {},
|
|
11500
|
+
labels: {
|
|
11501
|
+
start: messages.mic_start,
|
|
11502
|
+
end: messages.call_end,
|
|
11503
|
+
mute: messages.mic_stop,
|
|
11504
|
+
unmute: messages.mic_start,
|
|
11505
|
+
connecting: messages.voice_state_connecting,
|
|
11506
|
+
...messages.dock_fix_browser !== void 0 ? { fixBrowser: messages.dock_fix_browser } : {},
|
|
11507
|
+
listening: messages.voice_state_listening,
|
|
11508
|
+
thinking: messages.voice_state_thinking,
|
|
11509
|
+
speaking: messages.voice_state_speaking,
|
|
11510
|
+
...voiceUnavailable !== void 0 ? { unavailable: voiceUnavailable } : {}
|
|
11511
|
+
}
|
|
11512
|
+
} : void 0;
|
|
11513
|
+
const composerLeading = onAttach ? /* @__PURE__ */ jsxs(Fragment, { children: [attachInput, /* @__PURE__ */ jsxs("button", {
|
|
11514
|
+
type: "button",
|
|
11515
|
+
onClick: onAttach,
|
|
11516
|
+
"data-testid": "widget-attach-button",
|
|
11517
|
+
disabled: attaching !== null && !attaching.failed,
|
|
11518
|
+
className: "flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-full bg-[var(--widget-chip)] text-[var(--widget-foreground-muted)] transition-[background-color,color] hover:text-[var(--widget-foreground)] disabled:cursor-default disabled:opacity-50",
|
|
11519
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
11520
|
+
className: "sr-only",
|
|
11521
|
+
children: messages.attach_label
|
|
11522
|
+
}), /* @__PURE__ */ jsx("svg", {
|
|
11523
|
+
viewBox: "0 0 24 24",
|
|
11524
|
+
className: "h-4 w-4",
|
|
11525
|
+
fill: "none",
|
|
11526
|
+
"aria-hidden": "true",
|
|
11527
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
11528
|
+
d: "M8 12l5.5-5.5a3 3 0 1 1 4.24 4.24L9.5 19a5 5 0 1 1-7.07-7.07L11.5 3",
|
|
11529
|
+
stroke: "currentColor",
|
|
11530
|
+
strokeWidth: "1.8",
|
|
11531
|
+
strokeLinecap: "round",
|
|
11532
|
+
strokeLinejoin: "round"
|
|
11533
|
+
})
|
|
11534
|
+
})]
|
|
11535
|
+
})] }) : null;
|
|
11536
|
+
return /* @__PURE__ */ jsxs(ConciergeShell, {
|
|
11537
|
+
open,
|
|
11538
|
+
onOpenChange: setOpen,
|
|
11539
|
+
state: view.avatar,
|
|
11540
|
+
...skinStyle !== void 0 ? { skinStyle } : {},
|
|
11541
|
+
...avatar !== void 0 ? { avatar } : {},
|
|
11542
|
+
...attribution !== void 0 ? { attribution } : {},
|
|
11543
|
+
launcher: view.launcher,
|
|
11544
|
+
...view.handoff && operatorName !== void 0 ? { operatorName } : {},
|
|
11545
|
+
launcherInitials: view.launcher.initials ? handoffInitials(operatorName) : "",
|
|
11546
|
+
typing: view.typing,
|
|
11547
|
+
messageArrived: lastTurn?.speaker === "caller",
|
|
11548
|
+
idPrefix: "widget",
|
|
11549
|
+
scrollKey: turns.length + (humanTyping ? 1 : 0),
|
|
11550
|
+
draft,
|
|
11551
|
+
onDraftChange,
|
|
11552
|
+
onSubmit: submit,
|
|
11553
|
+
composerDisabled: view.composerDisabled,
|
|
11554
|
+
position,
|
|
11555
|
+
...draggable ? { onPositionChange: setPosition } : {},
|
|
11556
|
+
labels: {
|
|
11557
|
+
open: messages.open,
|
|
11558
|
+
close: messages.minimize,
|
|
11559
|
+
dialog: messages.conversation,
|
|
11560
|
+
composerPlaceholder: messages.type_placeholder,
|
|
11561
|
+
send: messages.send,
|
|
11562
|
+
move: messages.move,
|
|
11563
|
+
...launcherLabel ? { launcher: launcherLabel } : {}
|
|
11564
|
+
},
|
|
11565
|
+
...voice !== void 0 ? { voice } : {},
|
|
11566
|
+
composerLeading,
|
|
11567
|
+
badge: statusText === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
11568
|
+
"data-testid": "widget-status",
|
|
11569
|
+
...view.announce ? {
|
|
11570
|
+
role: "status",
|
|
11571
|
+
"aria-live": "polite"
|
|
11572
|
+
} : {},
|
|
11573
|
+
className: "mt-1 max-w-full rounded-2xl bg-[var(--widget-chip)] px-2.5 py-1 text-center text-[10px] leading-snug font-semibold tracking-wide text-[var(--widget-foreground-muted)]",
|
|
11574
|
+
children: statusText
|
|
11575
|
+
}),
|
|
11576
|
+
testIds: {
|
|
11577
|
+
trigger: "voice-widget-launcher",
|
|
11578
|
+
panel: "voice-widget",
|
|
11579
|
+
input: "widget-text-input",
|
|
11580
|
+
endCall: "widget-end-call",
|
|
11581
|
+
send: "widget-send",
|
|
11582
|
+
mic: "widget-mic"
|
|
11583
|
+
},
|
|
11584
|
+
children: [transcript, extras]
|
|
11585
|
+
});
|
|
11586
|
+
}
|
|
11587
|
+
//#endregion
|
|
11588
|
+
//#region src/dock/dock-renderer.tsx
|
|
11589
|
+
/**
|
|
11590
|
+
* The dock as a `ConciergeRenderer` — docs/CONCIERGE_GENERATIONS.md §3.
|
|
11591
|
+
*
|
|
11592
|
+
* What used to be the tail of `VoiceWidget` verbatim: every prop the `Dock`
|
|
11593
|
+
* takes, from the `ConversationView` the widget derives. Nothing is computed
|
|
11594
|
+
* here that both renderers would need; what is dock-specific (the follow key,
|
|
11595
|
+
* when the sheet reveals itself) stays, because it describes this chrome.
|
|
11596
|
+
*
|
|
11597
|
+
* Imported by `cdn/ui.ts` and by `rendererFor`; never by `voice-widget.tsx`,
|
|
11598
|
+
* so a bundle built around the OTHER renderer does not carry this one.
|
|
11599
|
+
*/
|
|
11600
|
+
function DockRenderer({ turns, lastTurn, operatorName, composing, onEndCall, voice, statusLine, statusKind, notice, escalated, humanTyping, draft, onDraftChange, submit, showBasket, cart, attaching, onAttach, attachInput, transcript, extras, messages, locale, navigate, curationHref, productHref, skinStyle, avatar, attribution, dock }) {
|
|
11601
|
+
return /* @__PURE__ */ jsx(Dock, {
|
|
11602
|
+
identity: {
|
|
11603
|
+
name: "",
|
|
11604
|
+
avatar: avatar === "knot" ? "knot" : "orb"
|
|
11605
|
+
},
|
|
11606
|
+
...dock,
|
|
11607
|
+
voice: {
|
|
11608
|
+
...voice,
|
|
11609
|
+
...dock?.voice ?? {}
|
|
11610
|
+
},
|
|
11611
|
+
messages,
|
|
11612
|
+
locale,
|
|
11613
|
+
status: statusLine,
|
|
11614
|
+
...statusKind !== void 0 ? { statusKind } : {},
|
|
11615
|
+
...notice !== void 0 ? { notice } : {},
|
|
11616
|
+
escalated,
|
|
11617
|
+
...operatorName !== void 0 ? { operatorName } : {},
|
|
11618
|
+
...onEndCall !== void 0 ? { onEndCall } : {},
|
|
11619
|
+
...skinStyle !== void 0 ? { skinStyle } : {},
|
|
11620
|
+
...attribution !== void 0 ? { attribution } : {},
|
|
11621
|
+
...curationHref ? { curationHref } : {},
|
|
11622
|
+
...productHref ? { productHref } : {},
|
|
11623
|
+
...navigate ? { navigate } : {},
|
|
11624
|
+
draft,
|
|
11625
|
+
onDraftChange,
|
|
11626
|
+
onSubmit: submit,
|
|
11627
|
+
revealSheet: showBasket && cart !== void 0 && cart.lines.length > 0 || attaching !== null,
|
|
11628
|
+
followKey: turns.reduce((n, turn) => n + 1 + turn.text.length + (turn.cards?.items.length ?? 0), 0) + (humanTyping ? 1 : 0),
|
|
11629
|
+
...onAttach ? { onAttach } : {},
|
|
11630
|
+
attachBusy: attaching !== null && !attaching.failed,
|
|
11631
|
+
...attachInput !== null ? { attachSlot: attachInput } : {},
|
|
11632
|
+
sheetExtra: extras,
|
|
11633
|
+
transcript,
|
|
11634
|
+
transcriptCount: turns.length,
|
|
11635
|
+
...lastTurn !== void 0 ? { lastTurn } : {},
|
|
11636
|
+
composing
|
|
11637
|
+
});
|
|
11638
|
+
}
|
|
11639
|
+
//#endregion
|
|
11640
|
+
//#region src/renderers.ts
|
|
11641
|
+
/**
|
|
11642
|
+
* The one module that names BOTH renderers — docs/CONCIERGE_GENERATIONS.md §3.
|
|
11643
|
+
*
|
|
11644
|
+
* `VoiceWidget` and `ConciergeWidget` (the npm components) resolve a missing
|
|
11645
|
+
* `renderer` here from `ui.generation`. The CDN entries never import this
|
|
11646
|
+
* file: `cdn/ui.ts` passes `DockRenderer` and `cdn/ui-widget.ts` passes
|
|
11647
|
+
* `ShellRenderer` to `ConciergeHost` directly, which is what keeps each chunk
|
|
11648
|
+
* to one renderer's code (rule 3 of §3: nothing under `widget/` is reachable
|
|
11649
|
+
* from `cdn/ui.ts`, and vice versa — the budget guard measures it).
|
|
11650
|
+
*
|
|
11651
|
+
* Absent ⇒ the dock. That is the npm components' compatibility default, not
|
|
11652
|
+
* the product's: the published config defaults to `widget`
|
|
11653
|
+
* (`widget-config-upcast.ts`), and `cdn/core.ts` reads it that way. A React
|
|
11654
|
+
* host that wants the widget says so.
|
|
11655
|
+
*/
|
|
11656
|
+
function rendererFor(generation) {
|
|
11657
|
+
return generation === "widget" ? ShellRenderer : DockRenderer;
|
|
11658
|
+
}
|
|
11659
|
+
//#endregion
|
|
11660
|
+
//#region src/widget-markdown.tsx
|
|
11661
|
+
/**
|
|
11662
|
+
* Only `http(s)` and `mailto` survive.
|
|
11663
|
+
*
|
|
11664
|
+
* A model can emit `[click here](javascript:…)` as easily as a real URL, and a
|
|
11665
|
+
* bare `href` would execute it on click. Anything else renders as plain text,
|
|
11666
|
+
* so a rejected link still shows its label rather than vanishing.
|
|
11667
|
+
*/
|
|
11668
|
+
function safeHref(raw) {
|
|
11669
|
+
const href = raw.trim();
|
|
11670
|
+
if (/^https?:\/\//i.test(href)) return href;
|
|
11671
|
+
if (/^mailto:[^\s]+@[^\s]+$/i.test(href)) return href;
|
|
11672
|
+
return null;
|
|
11673
|
+
}
|
|
11674
|
+
/**
|
|
11675
|
+
* Inline constructs, innermost-last.
|
|
11676
|
+
*
|
|
11677
|
+
* Code is matched FIRST and never recurses into its own body: `` `**not
|
|
11678
|
+
* bold**` `` is a literal in every Markdown dialect, and parsing emphasis
|
|
11679
|
+
* inside it is the classic way a renderer mangles a code sample.
|
|
11680
|
+
*/
|
|
11681
|
+
function parseInline(src) {
|
|
11682
|
+
const out = [];
|
|
11683
|
+
let rest = src;
|
|
11684
|
+
while (rest.length > 0) {
|
|
11685
|
+
const match = /`([^`]+)`|\*\*([\s\S]+?)\*\*|__([\s\S]+?)__|(?<!\*)\*(?!\s)([^*\n]+?)\*(?!\*)|(?<!_)_(?!\s)([^_\n]+?)_(?!_)|\[([^\]]*)\]\(([^)\s]+)\)/.exec(rest);
|
|
11686
|
+
if (!match || match.index === void 0) {
|
|
11687
|
+
out.push({
|
|
11688
|
+
kind: "text",
|
|
11689
|
+
text: rest
|
|
11690
|
+
});
|
|
11691
|
+
break;
|
|
11692
|
+
}
|
|
11693
|
+
if (match.index > 0) out.push({
|
|
11694
|
+
kind: "text",
|
|
11695
|
+
text: rest.slice(0, match.index)
|
|
11696
|
+
});
|
|
11697
|
+
const [full, code, boldStar, boldUnd, italStar, italUnd, linkText, linkHref] = match;
|
|
11698
|
+
if (code !== void 0) out.push({
|
|
11699
|
+
kind: "code",
|
|
11700
|
+
text: code
|
|
11701
|
+
});
|
|
11702
|
+
else if (boldStar !== void 0 || boldUnd !== void 0) out.push({
|
|
11703
|
+
kind: "bold",
|
|
11704
|
+
children: parseInline(boldStar ?? boldUnd)
|
|
11705
|
+
});
|
|
11706
|
+
else if (italStar !== void 0 || italUnd !== void 0) out.push({
|
|
11707
|
+
kind: "italic",
|
|
11708
|
+
children: parseInline(italStar ?? italUnd)
|
|
11709
|
+
});
|
|
11710
|
+
else if (linkHref !== void 0) {
|
|
11711
|
+
const href = safeHref(linkHref);
|
|
11712
|
+
const children = parseInline(linkText ?? "");
|
|
11713
|
+
out.push(href ? {
|
|
11714
|
+
kind: "link",
|
|
11715
|
+
href,
|
|
11716
|
+
children
|
|
11717
|
+
} : {
|
|
11718
|
+
kind: "text",
|
|
11719
|
+
text: linkText ?? ""
|
|
11720
|
+
});
|
|
11721
|
+
}
|
|
11722
|
+
rest = rest.slice(match.index + full.length);
|
|
11723
|
+
}
|
|
11724
|
+
return out.filter((n) => !(n.kind === "text" && n.text === ""));
|
|
11725
|
+
}
|
|
11726
|
+
function renderInline(nodes, keyPrefix) {
|
|
11727
|
+
return nodes.map((node, i) => {
|
|
11728
|
+
const key = `${keyPrefix}-${i}`;
|
|
11729
|
+
switch (node.kind) {
|
|
11730
|
+
case "text": return /* @__PURE__ */ jsx(Fragment$1, { children: node.text }, key);
|
|
11731
|
+
case "bold": return /* @__PURE__ */ jsx("strong", { children: renderInline(node.children, key) }, key);
|
|
11732
|
+
case "italic": return /* @__PURE__ */ jsx("em", { children: renderInline(node.children, key) }, key);
|
|
11733
|
+
case "code": return /* @__PURE__ */ jsx("code", {
|
|
11734
|
+
className: "rounded bg-black/10 px-1 py-0.5 font-mono text-[0.85em]",
|
|
11735
|
+
children: node.text
|
|
11736
|
+
}, key);
|
|
11737
|
+
case "link": return /* @__PURE__ */ jsx("a", {
|
|
11738
|
+
href: node.href,
|
|
11739
|
+
target: "_blank",
|
|
11740
|
+
rel: "noopener noreferrer nofollow",
|
|
11741
|
+
className: "underline underline-offset-2",
|
|
11742
|
+
children: renderInline(node.children, key)
|
|
11743
|
+
}, key);
|
|
11744
|
+
}
|
|
11745
|
+
});
|
|
11746
|
+
}
|
|
11747
|
+
var BULLET = /^\s*[-*+]\s+(.*)$/;
|
|
11748
|
+
var ORDERED = /^\s*\d+[.)]\s+(.*)$/;
|
|
11749
|
+
/**
|
|
11750
|
+
* Group lines into blocks.
|
|
11751
|
+
*
|
|
11752
|
+
* A blank line always closes the current block; a list item closes a paragraph
|
|
11753
|
+
* and vice versa. That last rule is what fixes the reported bug — the model
|
|
11754
|
+
* writes its intro and its bullets with no blank line between them, so
|
|
11755
|
+
* splitting on blank lines alone left `intro - item - item` as one paragraph.
|
|
11756
|
+
*/
|
|
11757
|
+
function parseBlocks(markdown) {
|
|
11758
|
+
const blocks = [];
|
|
11759
|
+
let paragraph = [];
|
|
11760
|
+
let list = null;
|
|
11761
|
+
const flushParagraph = () => {
|
|
11762
|
+
if (paragraph.length > 0) blocks.push({
|
|
11763
|
+
kind: "paragraph",
|
|
11764
|
+
lines: paragraph
|
|
11765
|
+
});
|
|
11766
|
+
paragraph = [];
|
|
11767
|
+
};
|
|
11768
|
+
const flushList = () => {
|
|
11769
|
+
if (list) blocks.push({
|
|
11770
|
+
kind: "list",
|
|
11771
|
+
ordered: list.ordered,
|
|
11772
|
+
items: list.items
|
|
11773
|
+
});
|
|
11774
|
+
list = null;
|
|
11775
|
+
};
|
|
11776
|
+
for (const line of markdown.split("\n")) {
|
|
11777
|
+
if (line.trim() === "") {
|
|
11778
|
+
flushParagraph();
|
|
11779
|
+
flushList();
|
|
11780
|
+
continue;
|
|
11781
|
+
}
|
|
11782
|
+
const bullet = BULLET.exec(line);
|
|
11783
|
+
const ordered = bullet ? null : ORDERED.exec(line);
|
|
11784
|
+
if (bullet ?? ordered) {
|
|
11785
|
+
flushParagraph();
|
|
11786
|
+
const isOrdered = ordered !== null;
|
|
11787
|
+
const text = (bullet?.[1] ?? ordered?.[1] ?? "").trim();
|
|
11788
|
+
if (list && list.ordered !== isOrdered) flushList();
|
|
11789
|
+
list ??= {
|
|
11790
|
+
ordered: isOrdered,
|
|
11791
|
+
items: []
|
|
11792
|
+
};
|
|
11793
|
+
list.items.push(text);
|
|
11794
|
+
continue;
|
|
11795
|
+
}
|
|
11796
|
+
flushList();
|
|
11797
|
+
paragraph.push(line.trim());
|
|
11798
|
+
}
|
|
11799
|
+
flushParagraph();
|
|
11800
|
+
flushList();
|
|
11801
|
+
return blocks;
|
|
11802
|
+
}
|
|
11803
|
+
/**
|
|
11804
|
+
* Renders one turn's text.
|
|
11805
|
+
*
|
|
11806
|
+
* Safe to call on a PARTIAL string: this runs on every streamed delta, so a
|
|
11807
|
+
* half-written `**bold` is common. Unterminated markers simply fail to match
|
|
11808
|
+
* and render as the literal characters they are, which then resolve
|
|
11809
|
+
* themselves on the delta that closes them — no flicker beyond the marker
|
|
11810
|
+
* briefly showing, and never a thrown parse error mid-stream.
|
|
11811
|
+
*/
|
|
11812
|
+
function WidgetMarkdown({ text }) {
|
|
9728
11813
|
return parseBlocks(text).map((block, i) => {
|
|
9729
11814
|
if (block.kind === "list") return /* @__PURE__ */ jsx(block.ordered ? "ol" : "ul", {
|
|
9730
11815
|
className: `my-1 space-y-1 ps-4 ${block.ordered ? "list-decimal" : "list-disc"}`,
|
|
@@ -10565,7 +12650,20 @@ function basketIntentFromTurns(turns) {
|
|
|
10565
12650
|
* `dir`, resolved from that line's locale rather than inherited from the page —
|
|
10566
12651
|
* inheriting is what renders Arabic punctuation on the wrong end of a sentence.
|
|
10567
12652
|
*/
|
|
10568
|
-
|
|
12653
|
+
/**
|
|
12654
|
+
* The public component: picks a renderer when the caller did not. Kept apart
|
|
12655
|
+
* from `VoiceWidgetWithRenderer` so that a CDN entry which imports only the
|
|
12656
|
+
* latter never bundles the renderer it does not draw — `rendererFor` is the
|
|
12657
|
+
* one place both are named.
|
|
12658
|
+
*/
|
|
12659
|
+
function VoiceWidget({ renderer, generation, ...props }) {
|
|
12660
|
+
return /* @__PURE__ */ jsx(VoiceWidgetWithRenderer, {
|
|
12661
|
+
...props,
|
|
12662
|
+
renderer: renderer ?? rendererFor(generation)
|
|
12663
|
+
});
|
|
12664
|
+
}
|
|
12665
|
+
/** `VoiceWidget` with the renderer decided — the component the CDN entries and `ConciergeHost` use. */
|
|
12666
|
+
function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCall, callPhase = "idle", onSendText, micOpen, status, statusKind, notice, mode = "voice", escalated = false, humanTyping = false, onTyping, onAddToCart, onChooseOptions, chooseOptionsBusy = false, curationHref, productHref, onAttachFile, cart, messages = defaultWidgetMessages, navigate, locale = "en", skinStyle, avatar, attribution, dock }) {
|
|
10569
12667
|
const [draft, setDraft] = useState("");
|
|
10570
12668
|
const [sending, setSending] = useState(false);
|
|
10571
12669
|
/** Roomy mode — see the expand control in the header. Collapses back on close, so a reopened widget starts small. */
|
|
@@ -10815,69 +12913,81 @@ function VoiceWidget({ state, turns, onToggleMic, onEndCall, callPhase = "idle",
|
|
|
10815
12913
|
const lastSpoken = [...turns].reverse().find((t) => t.speaker !== "event");
|
|
10816
12914
|
const replyStreaming = lastSpoken?.speaker === "agent" && lastSpoken.final === false && lastSpoken.filler !== true;
|
|
10817
12915
|
const composing = humanTyping || channel === "text" && (sending || replyStreaming);
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
|
|
12916
|
+
/**
|
|
12917
|
+
* The attachment input lives with the conversation, not with either chrome:
|
|
12918
|
+
* the widget that owns the file input also owns what "uploading" looks like.
|
|
12919
|
+
* The renderers draw only the button that opens it.
|
|
12920
|
+
*/
|
|
12921
|
+
const canAttach = onAttachFile !== void 0 && escalated;
|
|
12922
|
+
const attachInput = canAttach ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("label", {
|
|
12923
|
+
className: "sr-only",
|
|
12924
|
+
htmlFor: fileInputId,
|
|
12925
|
+
children: messages.attach_label
|
|
12926
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
12927
|
+
id: fileInputId,
|
|
12928
|
+
ref: fileInputRef,
|
|
12929
|
+
type: "file",
|
|
12930
|
+
"data-testid": "widget-attach-input",
|
|
12931
|
+
className: "sr-only",
|
|
12932
|
+
onChange: (event) => void onFileSelected(event)
|
|
12933
|
+
})] }) : null;
|
|
12934
|
+
const onAttach = canAttach ? () => fileInputRef.current?.click() : void 0;
|
|
12935
|
+
const extras = /* @__PURE__ */ jsxs(Fragment, { children: [cart && cart.lines.length > 0 && showBasket ? /* @__PURE__ */ jsx(WidgetCartSummary, {
|
|
12936
|
+
lines: cart.lines,
|
|
12937
|
+
subtotalMinor: cart.subtotalMinor,
|
|
12938
|
+
currency: cart.currency,
|
|
12939
|
+
...cart.discountMinor !== void 0 ? { discountMinor: cart.discountMinor } : {},
|
|
12940
|
+
onCheckout: cart.onCheckout,
|
|
10829
12941
|
locale,
|
|
10830
|
-
|
|
10831
|
-
...
|
|
10832
|
-
|
|
12942
|
+
messages,
|
|
12943
|
+
...navigate ? { navigate } : {}
|
|
12944
|
+
}) : null, attaching ? /* @__PURE__ */ jsx("p", {
|
|
12945
|
+
role: "status",
|
|
12946
|
+
className: `text-xs ${attaching.failed ? "text-destructive" : "text-[var(--widget-foreground-muted)]"}`,
|
|
12947
|
+
children: attaching.failed ? formatMessage(messages.attach_error, { filename: attaching.filename }) : formatMessage(messages.attach_uploading, { filename: attaching.filename })
|
|
12948
|
+
}) : null] });
|
|
12949
|
+
return /* @__PURE__ */ jsx(renderer, {
|
|
12950
|
+
state,
|
|
12951
|
+
turns,
|
|
12952
|
+
lastTurn,
|
|
12953
|
+
operatorName,
|
|
12954
|
+
composing,
|
|
12955
|
+
channel,
|
|
12956
|
+
mode,
|
|
12957
|
+
showMic,
|
|
12958
|
+
callPhase,
|
|
12959
|
+
micOpen,
|
|
12960
|
+
onToggleMic,
|
|
12961
|
+
onEndCall,
|
|
12962
|
+
voice: derivedVoice,
|
|
12963
|
+
statusLine,
|
|
12964
|
+
statusKind,
|
|
12965
|
+
notice,
|
|
10833
12966
|
escalated,
|
|
10834
|
-
|
|
10835
|
-
...onEndCall !== void 0 ? { onEndCall } : {},
|
|
10836
|
-
...skinStyle !== void 0 ? { skinStyle } : {},
|
|
10837
|
-
...attribution !== void 0 ? { attribution } : {},
|
|
10838
|
-
...curationHref ? { curationHref } : {},
|
|
10839
|
-
...productHref ? { productHref } : {},
|
|
10840
|
-
...navigate ? { navigate } : {},
|
|
12967
|
+
humanTyping,
|
|
10841
12968
|
draft,
|
|
10842
12969
|
onDraftChange: (value) => {
|
|
10843
12970
|
setDraft(value);
|
|
10844
12971
|
if (value.trim() !== "") onTyping?.();
|
|
10845
12972
|
},
|
|
10846
|
-
|
|
10847
|
-
|
|
10848
|
-
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
htmlFor: fileInputId,
|
|
10854
|
-
children: messages.attach_label
|
|
10855
|
-
}), /* @__PURE__ */ jsx("input", {
|
|
10856
|
-
id: fileInputId,
|
|
10857
|
-
ref: fileInputRef,
|
|
10858
|
-
type: "file",
|
|
10859
|
-
"data-testid": "widget-attach-input",
|
|
10860
|
-
className: "sr-only",
|
|
10861
|
-
onChange: (event) => void onFileSelected(event)
|
|
10862
|
-
})] }) } : {},
|
|
10863
|
-
sheetExtra: /* @__PURE__ */ jsxs(Fragment, { children: [cart && cart.lines.length > 0 && showBasket ? /* @__PURE__ */ jsx(WidgetCartSummary, {
|
|
10864
|
-
lines: cart.lines,
|
|
10865
|
-
subtotalMinor: cart.subtotalMinor,
|
|
10866
|
-
currency: cart.currency,
|
|
10867
|
-
...cart.discountMinor !== void 0 ? { discountMinor: cart.discountMinor } : {},
|
|
10868
|
-
onCheckout: cart.onCheckout,
|
|
10869
|
-
locale,
|
|
10870
|
-
messages,
|
|
10871
|
-
...navigate ? { navigate } : {}
|
|
10872
|
-
}) : null, attaching ? /* @__PURE__ */ jsx("p", {
|
|
10873
|
-
role: "status",
|
|
10874
|
-
className: `text-xs ${attaching.failed ? "text-destructive" : "text-[var(--widget-foreground-muted)]"}`,
|
|
10875
|
-
children: attaching.failed ? formatMessage(messages.attach_error, { filename: attaching.filename }) : formatMessage(messages.attach_uploading, { filename: attaching.filename })
|
|
10876
|
-
}) : null] }),
|
|
12973
|
+
submit: () => void submit(),
|
|
12974
|
+
sending,
|
|
12975
|
+
showBasket,
|
|
12976
|
+
cart,
|
|
12977
|
+
attaching,
|
|
12978
|
+
onAttach,
|
|
12979
|
+
attachInput,
|
|
10877
12980
|
transcript: renderLog(turns),
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
|
|
12981
|
+
extras,
|
|
12982
|
+
messages,
|
|
12983
|
+
locale,
|
|
12984
|
+
navigate,
|
|
12985
|
+
curationHref,
|
|
12986
|
+
productHref,
|
|
12987
|
+
skinStyle,
|
|
12988
|
+
avatar,
|
|
12989
|
+
attribution,
|
|
12990
|
+
dock
|
|
10881
12991
|
});
|
|
10882
12992
|
}
|
|
10883
12993
|
//#endregion
|
|
@@ -15077,42 +17187,17 @@ function deriveCallPhase(voice) {
|
|
|
15077
17187
|
return voice.state === "thinking" ? "waiting" : "live";
|
|
15078
17188
|
}
|
|
15079
17189
|
/**
|
|
15080
|
-
* The
|
|
15081
|
-
*
|
|
15082
|
-
*
|
|
15083
|
-
* (`useChatSession`) and owns its own open/closed state; a host wanting
|
|
15084
|
-
* different session plumbing should compose `VoiceWidget` directly instead
|
|
15085
|
-
* (this component is a convenience, not the only way to use the package).
|
|
15086
|
-
*
|
|
15087
|
-
* ## Voice — offered when, and only when, the tenant published it
|
|
15088
|
-
*
|
|
15089
|
-
* This used to be hardcoded `mode="text"`, on the reasoning that "a generic
|
|
15090
|
-
* host bridge carries no voice transport — LiveKit token minting is a
|
|
15091
|
-
* server concern this package cannot assume any host has". That reasoning
|
|
15092
|
-
* no longer holds: `apps/api`'s `POST /widget/voice/token`
|
|
15093
|
-
* (`docs/WIDGET_EMBED_PLAN.md` §5.6/§7) mints a LiveKit session for ANY
|
|
15094
|
-
* `apiBase` this component is given, the same API surface `useChatSession`
|
|
15095
|
-
* already talks to — so a host with no voice leg of its own (the CDN embed,
|
|
15096
|
-
* an npm consumer) can still offer one.
|
|
15097
|
-
*
|
|
15098
|
-
* Three things must ALL hold before the microphone renders at all:
|
|
15099
|
-
*
|
|
15100
|
-
* 1. `apiBase` is known — `createWidgetVoiceTokenFetcher` needs the widget's
|
|
15101
|
-
* mount point, same contract `useChatSession` already uses (see
|
|
15102
|
-
* `ConciergeWidgetProps.apiBase`'s doc comment).
|
|
15103
|
-
* 2. `session.chatToken` exists — `POST /widget/voice/token` is
|
|
15104
|
-
* authenticated by it, same as every other post-`/session` call.
|
|
15105
|
-
* 3. `session.modalities.voice` is `true` — the TENANT's own published
|
|
15106
|
-
* widget config opted in. `false` (the default before this feature, and
|
|
15107
|
-
* for every tenant who hasn't turned it on) keeps this component exactly
|
|
15108
|
-
* as it always behaved: text-only, no mic control drawn at all.
|
|
15109
|
-
*
|
|
15110
|
-
* `useVoiceSession`'s own `import('livekit-client')` stays behind `start()`
|
|
15111
|
-
* regardless of any of this — see that hook's doc comment — so nothing
|
|
15112
|
-
* about offering voice here costs a byte until a caller actually presses
|
|
15113
|
-
* the microphone.
|
|
17190
|
+
* The public component. Everything below it — the session, the bridge, the
|
|
17191
|
+
* voice and cart plumbing — is `ConciergeHost`; this only picks the chrome
|
|
17192
|
+
* when the caller did not. See `renderers.ts` for why they are two functions.
|
|
15114
17193
|
*/
|
|
15115
|
-
function ConciergeWidget({
|
|
17194
|
+
function ConciergeWidget({ renderer, ...props }) {
|
|
17195
|
+
return /* @__PURE__ */ jsx(ConciergeHost, {
|
|
17196
|
+
...props,
|
|
17197
|
+
renderer: renderer ?? rendererFor(props.generation)
|
|
17198
|
+
});
|
|
17199
|
+
}
|
|
17200
|
+
function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bridge, siteProfile, collector, messages = defaultWidgetMessages, locale = "en", productHref, hostRoutes, curationHref, brandPrimary, brandSecondary, brandAccent, avatar, attribution, color, type, identity, layout, copy, bottomOffset, showPrice, cardImageAspect, voiceAvailable, direction, proactive, initialDraft, initialSelection, initialFocus, initialMinimised, insets, hold, audio, onReady, cartLineIds }) {
|
|
15116
17201
|
/**
|
|
15117
17202
|
* Maps the tenant's semantic config fields onto the widget's historical
|
|
15118
17203
|
* CSS custom properties — this is the "one becomes the other" site
|
|
@@ -16821,7 +18906,8 @@ function ConciergeWidget({ embedKey, apiBase, socketUrl, socketPath, bridge, sit
|
|
|
16821
18906
|
...audio !== void 0 ? { audio } : {},
|
|
16822
18907
|
...onReady !== void 0 ? { onReady } : {}
|
|
16823
18908
|
};
|
|
16824
|
-
return /* @__PURE__ */ jsx(
|
|
18909
|
+
return /* @__PURE__ */ jsx(VoiceWidgetWithRenderer, {
|
|
18910
|
+
renderer,
|
|
16825
18911
|
state: inCall ? voice.state : "idle",
|
|
16826
18912
|
turns: widgetTurns,
|
|
16827
18913
|
mode: voiceEnabled ? "voice" : "text",
|
|
@@ -16854,4 +18940,4 @@ function ConciergeWidget({ embedKey, apiBase, socketUrl, socketPath, bridge, sit
|
|
|
16854
18940
|
});
|
|
16855
18941
|
}
|
|
16856
18942
|
//#endregion
|
|
16857
|
-
export {
|
|
18943
|
+
export { deriveDockView as $, deriveTheme as $t, DockRenderer as A, labelProps as An, SHEET_GAP as At, panelClasses as B, persistMinimised as Bt, readsAsCheckoutIntent as C, MorphingLoader as Cn, PILL_H as Ct, WidgetMarkdown as D, KNOT_PATH as Dn, ROW_H as Dt, WidgetCardList as E, isWidgetAvatar as En, RADII as Et, CONCIERGE_POSITIONS as F, Z_INDEX as Ft, SseFrameParser as G, rowWidthLen as Gt, positionForArrow as H, readStored as Ht, DEFAULT_CONCIERGE_POSITION as I, bottomLen as It, formatMs as J, writeStored as Jt, SESSION_EVENTS as K, sheetMaxHeightLen as Kt, alignOf as L, containerAnchor as Lt, deriveWidgetView as M, SHEET_TOP_CLEARANCE as Mt, ConciergeShell as N, SHEET_TUCK as Nt, parseBlocks as O, RopeKnot as On, SHEET_EXPANDED_DESKTOP_MAX as Ot, ConciergeLauncher as P, SHORT_VIEWPORT as Pt, deriveDockState as Q, WIDGET_THEME_TOKENS as Qt, edgeOf as R, geometryVars as Rt, readsAsCartViewIntent as S, widgetMessagesFromCopy as Sn, MOBILE_MARGIN as St, WidgetCartSummary as T, WIDGET_AVATARS as Tn, PROACTIVE_NUDGE_MS as Tt, IDLE_SNAPSHOT as U, readStoredAlign as Ut, positionClasses as V, pillAnchor as Vt, botStateFor as W, readStoredMinimised as Wt, Dock as X, SHEET_RADIUS_MAX_PX as Xt, latencyBetween as Y, CARD_RADIUS_MAX_PX as Yt, DOCK_STATES as Z, SYSTEM_FONT_STACK as Zt, useChatSession as _, srgbToLinear as _n, DRAG_TAP_SLOP_PX as _t, MAX_REPORTED_CART_LINES as a, hexToOklch as an, idleConciergeInput as at, VoiceWidgetWithRenderer as b, formatMessage as bn, GLASS_IDLE_MS as bt, deriveCallPhase as c, mixToward as cn, BOTTOM_FLOOR as ct, resolveCheckoutUrl as d, oklabToOklch as dn, DESKTOP_BREAKPOINT as dt, themeToCss as en, exchangeCount as et, toChatCart as f, oklchToHex as fn, DESKTOP_GUTTER as ft, isSameOriginPath as g, rotateHue as gn, DRAG_CLICK_WINDOW_MS as gt, useVoiceSession as h, relativeLuminance as hn, DOCK_MINIMISED_STORAGE_KEY as ht, ConciergeWidget as i, hexToOklab as in, deriveConciergeState as it, ShellRenderer as j, cn as jn, SHEET_PEEK_MAX as jt, rendererFor as k, BotFace as kn, SHEET_EXPANDED_VH as kt, mergeAddedCartLine as l, oklabToHex as ln, CONTROL as lt, createWidgetVoiceTokenFetcher as m, parseHex as mn, DOCK_ALIGN_STORAGE_KEY as mt, CART_LINE_VARIANT_ID_SHAPE as n, contrastRatio as nn, latestExchangeStart as nt, cartLinesFromSnapshot as o, linearRgbToOklab as on, formatMoney as ot, ROOM_EVENTS as p, oklchToOklab as pn, DESKTOP_WIDTHS as pt, SessionLog as q, snapAlign as qt, ConciergeHost as r, formatHex as rn, CONCIERGE_STATES as rt, chooseOptionsAction as s, linearToSrgb as sn, ACTIVITY_W as st, CART_LINE_PLATFORM_VARIANT_ID_SHAPE as t, themeToInlineStyle as tn, idleDockInput as tt, resolveAddToCartHandler as u, oklabToLinearRgb as un, DESKTOP_BOTTOM as ut, detectPage as v, withAlpha as vn, FLOAT_DUCK_DISMISS_MS as vt, textDirectionFor as w, DEFAULT_WIDGET_AVATAR as wn, PILL_MARK as wt, basketIntentFromTurns as x, resolveWidgetMessages as xn, MARK as xt, VoiceWidget as y, defaultWidgetMessages as yn, FLOAT_GAP as yt, nearestPosition as z, persistAlign as zt };
|