@saar-ai/web-widget 0.17.0 → 0.20.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/avatar-face.d.ts +9 -3
- package/dist/avatar-face.d.ts.map +1 -1
- package/dist/avatar.d.ts +15 -2
- package/dist/avatar.d.ts.map +1 -1
- package/dist/chunks/{chat-DHMjOVms.js → chat-Bm4MPdY9.js} +25 -1
- package/dist/chunks/{form-fill-dom-D4ZMwxX1.js → form-fill-dom-Dxt-z0H0.js} +4 -0
- package/dist/chunks/{host-widget-BPHMVIjq.js → host-widget-kHzdanwT.js} +2037 -1333
- package/dist/concierge-shell.css +1 -1
- package/dist/dock/dock-row.d.ts +4 -2
- package/dist/dock/dock-row.d.ts.map +1 -1
- package/dist/dock/dock-sheet.d.ts.map +1 -1
- package/dist/dock/dock.d.ts +6 -0
- package/dist/dock/dock.d.ts.map +1 -1
- package/dist/dock/geometry.d.ts +1 -2
- package/dist/dock/geometry.d.ts.map +1 -1
- package/dist/form-fill/form-fill-dom.d.ts +5 -11
- package/dist/form-fill/form-fill-dom.d.ts.map +1 -1
- package/dist/generated/concierge-shell-css.d.ts.map +1 -1
- package/dist/generated/widget-css.d.ts.map +1 -1
- package/dist/host-widget.d.ts +2 -3
- package/dist/host-widget.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -15
- package/dist/messages.d.ts +17 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/next/index.js +1 -1
- package/dist/scroll-row.d.ts +29 -0
- package/dist/scroll-row.d.ts.map +1 -0
- package/dist/spoken-transcript.d.ts +23 -7
- package/dist/spoken-transcript.d.ts.map +1 -1
- package/dist/theme/derive.d.ts +71 -3
- package/dist/theme/derive.d.ts.map +1 -1
- package/dist/theme/host-tone.d.ts +0 -7
- package/dist/theme/host-tone.d.ts.map +1 -1
- package/dist/theme/index.d.ts +5 -1
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/widget-derive.d.ts +17 -0
- package/dist/theme/widget-derive.d.ts.map +1 -0
- package/dist/theme/widget-theme-scope.d.ts +17 -0
- package/dist/theme/widget-theme-scope.d.ts.map +1 -0
- package/dist/turn-order.d.ts +2 -1
- package/dist/turn-order.d.ts.map +1 -1
- package/dist/use-voice-session.d.ts +1 -1
- package/dist/use-voice-session.d.ts.map +1 -1
- package/dist/voice-widget.d.ts +32 -2
- package/dist/voice-widget.d.ts.map +1 -1
- package/dist/widget/call-view.d.ts +176 -0
- package/dist/widget/call-view.d.ts.map +1 -0
- package/dist/widget/concierge-launcher.d.ts +26 -2
- package/dist/widget/concierge-launcher.d.ts.map +1 -1
- package/dist/widget/concierge-shell.d.ts +51 -67
- package/dist/widget/concierge-shell.d.ts.map +1 -1
- package/dist/widget/launcher-look.d.ts +37 -0
- package/dist/widget/launcher-look.d.ts.map +1 -0
- package/dist/widget/mark-look.d.ts +35 -0
- package/dist/widget/mark-look.d.ts.map +1 -0
- package/dist/widget/mark.d.ts +35 -0
- package/dist/widget/mark.d.ts.map +1 -0
- package/dist/widget/mic-button.d.ts +31 -0
- package/dist/widget/mic-button.d.ts.map +1 -0
- package/dist/widget/shell-renderer.d.ts +1 -1
- package/dist/widget/shell-renderer.d.ts.map +1 -1
- package/dist/widget/style-of.d.ts +9 -0
- package/dist/widget/style-of.d.ts.map +1 -0
- package/dist/widget/use-follow-bottom.d.ts +17 -0
- package/dist/widget/use-follow-bottom.d.ts.map +1 -0
- package/dist/widget-cards.d.ts.map +1 -1
- package/dist/widget-cart-summary.d.ts.map +1 -1
- package/dist/widget.css +1 -1
- package/package.json +23 -7
- package/src/styles/call-view.css +290 -0
- package/src/styles/concierge-shell-entry.css +11 -0
- package/src/styles/concierge.css +3 -0
- package/src/styles/mark.css +94 -0
- package/src/styles/scroll-row.css +62 -0
- package/src/styles/tokens.css +1 -1
- package/src/styles/widget-entry.css +1 -0
- package/src/styles/widget-panel.css +644 -0
- package/dist/widget/transcript-geometry.d.ts +0 -226
- package/dist/widget/transcript-geometry.d.ts.map +0 -1
|
@@ -3982,12 +3982,38 @@ function KnotSvg({ state, tightenKey }) {
|
|
|
3982
3982
|
*
|
|
3983
3983
|
* `'orb'` is `BotFace`, the animated gradient blob this widget has always
|
|
3984
3984
|
* shipped. `'knot'` is `RopeKnot`, a hand-drawn rope line that ties and
|
|
3985
|
-
* unties itself through the same four {@link BotState}s.
|
|
3985
|
+
* unties itself through the same four {@link BotState}s. `'bars'`,
|
|
3986
|
+
* `'monogram'` and `'dot'` are `widget/mark.tsx`'s flat brand mark. Kept as data,
|
|
3986
3987
|
* separate from the components, for the same reason `bot-state.ts` keeps
|
|
3987
3988
|
* `BotState` separate from `BotFace`: parsing and defaulting have to be
|
|
3988
3989
|
* assertable without rendering either avatar.
|
|
3989
3990
|
*/
|
|
3990
|
-
var
|
|
3991
|
+
var MARK_VARIANTS = [
|
|
3992
|
+
"bars",
|
|
3993
|
+
"monogram",
|
|
3994
|
+
"dot"
|
|
3995
|
+
];
|
|
3996
|
+
var WIDGET_AVATARS = [
|
|
3997
|
+
"orb",
|
|
3998
|
+
"knot",
|
|
3999
|
+
...MARK_VARIANTS
|
|
4000
|
+
];
|
|
4001
|
+
/**
|
|
4002
|
+
* §9.1's `identity.avatar` — the drawn marks plus the two that are not drawn
|
|
4003
|
+
* from a name: an `image` and `none`. `bars`, `monogram` and `dot` (added
|
|
4004
|
+
* 2026-11-03) are the widget generation's marks and the default for a NEW
|
|
4005
|
+
* config; the dock draws them through {@link dockAvatarFor}.
|
|
4006
|
+
*/
|
|
4007
|
+
var WIDGET_IDENTITY_AVATARS = [
|
|
4008
|
+
...WIDGET_AVATARS,
|
|
4009
|
+
"image",
|
|
4010
|
+
"none"
|
|
4011
|
+
];
|
|
4012
|
+
/** The dock's face for an avatar it has no drawing for: the orb for bars and monogram, nothing for dot. */
|
|
4013
|
+
function dockAvatarFor(avatar) {
|
|
4014
|
+
if (avatar === "bars" || avatar === "monogram") return "orb";
|
|
4015
|
+
return avatar === "dot" ? "none" : avatar;
|
|
4016
|
+
}
|
|
3991
4017
|
/** What every layer in this package falls back to when a tenant never published one. */
|
|
3992
4018
|
var DEFAULT_WIDGET_AVATAR = "orb";
|
|
3993
4019
|
/** Whether a value is an avatar this widget knows how to render. Mirrors `bot-state.ts`'s `isBotState`. */
|
|
@@ -4654,7 +4680,13 @@ var defaultWidgetMessages = {
|
|
|
4654
4680
|
voice_unavailable_escalated: "Voice is unavailable while you’re talking to a person",
|
|
4655
4681
|
choose_options: "Choose options",
|
|
4656
4682
|
choose_options_label: "Choose options for {title}",
|
|
4657
|
-
choose_options_after_call: "I’ll ask about options after the call"
|
|
4683
|
+
choose_options_after_call: "I’ll ask about options after the call",
|
|
4684
|
+
cards_label: "Recommended products",
|
|
4685
|
+
cards_slide: "{n} of {total}",
|
|
4686
|
+
cards_prev: "Previous products",
|
|
4687
|
+
cards_next: "Next products",
|
|
4688
|
+
cards_carousel: "carousel",
|
|
4689
|
+
cards_slide_role: "slide"
|
|
4658
4690
|
};
|
|
4659
4691
|
/**
|
|
4660
4692
|
* Interpolates `{token}` placeholders in a message template. Deliberately the
|
|
@@ -5250,7 +5282,7 @@ function deriveText(surfaceHex) {
|
|
|
5250
5282
|
C: TEXT_C,
|
|
5251
5283
|
h: hue
|
|
5252
5284
|
});
|
|
5253
|
-
if (contrastRatio(candidate, surfaceHex) >=
|
|
5285
|
+
if (contrastRatio(candidate, surfaceHex) >= 4.5) return candidate;
|
|
5254
5286
|
const next = Number((L + step).toFixed(4));
|
|
5255
5287
|
if (next < 0 || next > 1) break;
|
|
5256
5288
|
L = next;
|
|
@@ -5313,8 +5345,8 @@ function deriveText(surfaceHex) {
|
|
|
5313
5345
|
* a mid-lightness surface can be unreachable from one side and comfortable
|
|
5314
5346
|
* from the other.
|
|
5315
5347
|
*/
|
|
5316
|
-
function deriveRing(primaryHex, surfaceHex) {
|
|
5317
|
-
if (contrastRatio(primaryHex, surfaceHex) >=
|
|
5348
|
+
function deriveRing(primaryHex, surfaceHex, floor = RING_CONTRAST_MIN) {
|
|
5349
|
+
if (contrastRatio(primaryHex, surfaceHex) >= floor) return primaryHex;
|
|
5318
5350
|
const primary = hexToOklch(primaryHex);
|
|
5319
5351
|
const preferDark = hexToOklch(surfaceHex).L >= .5;
|
|
5320
5352
|
for (const goDark of preferDark ? [true, false] : [false, true]) {
|
|
@@ -5329,7 +5361,7 @@ function deriveRing(primaryHex, surfaceHex) {
|
|
|
5329
5361
|
C: primary.C,
|
|
5330
5362
|
h: primary.h
|
|
5331
5363
|
});
|
|
5332
|
-
if (contrastRatio(candidate, surfaceHex) >=
|
|
5364
|
+
if (contrastRatio(candidate, surfaceHex) >= floor) return candidate;
|
|
5333
5365
|
}
|
|
5334
5366
|
}
|
|
5335
5367
|
return contrastRatio("#000000", surfaceHex) >= contrastRatio("#ffffff", surfaceHex) ? "#000000" : "#ffffff";
|
|
@@ -5386,8 +5418,8 @@ function deriveTheme(color, type) {
|
|
|
5386
5418
|
dark: deriveVars(color, type, supplied && suppliedIsDark ? supplied : DEFAULT_DARK_SURFACE)
|
|
5387
5419
|
};
|
|
5388
5420
|
}
|
|
5389
|
-
function block(vars, selector, indent) {
|
|
5390
|
-
return `${indent}${selector} {\n${
|
|
5421
|
+
function block(vars, selector, indent, tokens) {
|
|
5422
|
+
return `${indent}${selector} {\n${tokens.map((t) => `${indent} ${t}: ${vars[t]};`).join("\n")}\n${indent}}`;
|
|
5391
5423
|
}
|
|
5392
5424
|
/**
|
|
5393
5425
|
* The theme as a CSS text block: the unconditional rule, plus — for
|
|
@@ -5405,12 +5437,12 @@ function block(vars, selector, indent) {
|
|
|
5405
5437
|
* `:host` is the default because the dock lives in a shadow root; pass a class
|
|
5406
5438
|
* or `:root` for the console preview, which renders in light DOM.
|
|
5407
5439
|
*/
|
|
5408
|
-
function themeToCss(theme, selector = ":host") {
|
|
5409
|
-
let css = `${block(theme.light, selector, "")}\n`;
|
|
5440
|
+
function themeToCss(theme, selector = ":host", tokens = WIDGET_THEME_TOKENS) {
|
|
5441
|
+
let css = `${block(theme.light, selector, "", tokens)}\n`;
|
|
5410
5442
|
if (theme.dark) {
|
|
5411
5443
|
const host = selector === ":host";
|
|
5412
|
-
css += `\n@media (prefers-color-scheme: dark) {\n${block(theme.dark, host ? `:host(:not(${TONE_MARK}"light"]))` : selector, " ")}\n}\n`;
|
|
5413
|
-
if (host) css += `\n${block(theme.dark, `:host(${TONE_MARK}"dark"])`, "")}\n`;
|
|
5444
|
+
css += `\n@media (prefers-color-scheme: dark) {\n${block(theme.dark, host ? `:host(:not(${TONE_MARK}"light"]))` : selector, " ", tokens)}\n}\n`;
|
|
5445
|
+
if (host) css += `\n${block(theme.dark, `:host(${TONE_MARK}"dark"])`, "", tokens)}\n`;
|
|
5414
5446
|
}
|
|
5415
5447
|
return css;
|
|
5416
5448
|
}
|
|
@@ -5421,9 +5453,20 @@ var TONE_MARK = "[data-wgt-tone=";
|
|
|
5421
5453
|
* host page's tone beats the media query on that element too. Matches
|
|
5422
5454
|
* nothing in light DOM. Empty unless the tone is `auto`.
|
|
5423
5455
|
*/
|
|
5424
|
-
function themeToMarkedHostCss(theme, selector) {
|
|
5456
|
+
function themeToMarkedHostCss(theme, selector, tokens = WIDGET_THEME_TOKENS) {
|
|
5425
5457
|
if (!theme.dark) return "";
|
|
5426
|
-
return `${block(theme.light, `:host(${TONE_MARK}"light"]) ${selector}`, "")}\n\n${block(theme.dark, `:host(${TONE_MARK}"dark"]) ${selector}`, "")}\n`;
|
|
5458
|
+
return `${block(theme.light, `:host(${TONE_MARK}"light"]) ${selector}`, "", tokens)}\n\n${block(theme.dark, `:host(${TONE_MARK}"dark"]) ${selector}`, "", tokens)}\n`;
|
|
5459
|
+
}
|
|
5460
|
+
/**
|
|
5461
|
+
* The tenant's tokens for one scoped element (`[data-wgt-scope]`), with the
|
|
5462
|
+
* host's tone marks on it; `host` adds a `:host` block first, for an element
|
|
5463
|
+
* that renders in a shadow root as well as in light DOM. Two blocks with the
|
|
5464
|
+
* same body rather than one selector list, because one invalid selector
|
|
5465
|
+
* invalidates a whole rule.
|
|
5466
|
+
*/
|
|
5467
|
+
function scopedThemeCss(theme, scope, tokens = WIDGET_THEME_TOKENS, host = false) {
|
|
5468
|
+
const css = `${themeToCss(theme, scope, tokens)}\n${themeToMarkedHostCss(theme, scope, tokens)}`;
|
|
5469
|
+
return host ? `${themeToCss(theme, ":host", tokens)}\n${css}` : css;
|
|
5427
5470
|
}
|
|
5428
5471
|
/**
|
|
5429
5472
|
* The theme as a `style` attribute value, for the `core` stage — which paints
|
|
@@ -5434,8 +5477,8 @@ function themeToMarkedHostCss(theme, selector) {
|
|
|
5434
5477
|
* current `prefers-color-scheme` and the adopted stylesheet takes over the
|
|
5435
5478
|
* responsiveness at the React handover.
|
|
5436
5479
|
*/
|
|
5437
|
-
function themeToInlineStyle(vars) {
|
|
5438
|
-
return
|
|
5480
|
+
function themeToInlineStyle(vars, tokens = WIDGET_THEME_TOKENS) {
|
|
5481
|
+
return tokens.map((t) => `${t}:${vars[t]};`).join("");
|
|
5439
5482
|
}
|
|
5440
5483
|
//#endregion
|
|
5441
5484
|
//#region src/dock/geometry.ts
|
|
@@ -5443,8 +5486,7 @@ function themeToInlineStyle(vars) {
|
|
|
5443
5486
|
* DOCK GEOMETRY — every length the dock's row, pill and sheet are built from
|
|
5444
5487
|
* (docs/DOCK_SPEC.md §3), and the CSS expressions that carry them.
|
|
5445
5488
|
*
|
|
5446
|
-
* ONE module owns all of it
|
|
5447
|
-
* owns the panel's four lengths: the dock is drawn TWICE, by two renderers
|
|
5489
|
+
* ONE module owns all of it because the dock is drawn TWICE, by two renderers
|
|
5448
5490
|
* with no shared runtime. The CDN `core` stage paints the resting row and the
|
|
5449
5491
|
* pill in plain DOM before any framework loads, writing these values as an
|
|
5450
5492
|
* inline `style` attribute; the React dock then adopts a stylesheet built
|
|
@@ -5521,7 +5563,7 @@ var DESKTOP_WIDTHS = {
|
|
|
5521
5563
|
full: null
|
|
5522
5564
|
};
|
|
5523
5565
|
/** §9.1 `type.radius`, in px. Mirrors `theme/derive.ts`'s `--wgt-radius`. */
|
|
5524
|
-
var RADII = {
|
|
5566
|
+
var RADII$1 = {
|
|
5525
5567
|
square: 0,
|
|
5526
5568
|
soft: 12,
|
|
5527
5569
|
round: 20,
|
|
@@ -6875,7 +6917,7 @@ function DockMarkFace({ identity, mark, size, testId, handoff, operatorName }) {
|
|
|
6875
6917
|
const initials = handoff === true ? handoffInitials(operatorName) : "";
|
|
6876
6918
|
const handoffKind = handoff !== true ? void 0 : initials === "" ? "person" : "initials";
|
|
6877
6919
|
const url = handoffKind === void 0 && identity.avatar === "image" ? safeAvatarUrl(identity.avatarUrl) : void 0;
|
|
6878
|
-
const kind = url ? "image" : identity.avatar === "image" ? "none" : identity.avatar;
|
|
6920
|
+
const kind = url ? "image" : identity.avatar === "image" ? "none" : dockAvatarFor(identity.avatar);
|
|
6879
6921
|
return /* @__PURE__ */ jsx("span", {
|
|
6880
6922
|
className: "wgt-mark-face",
|
|
6881
6923
|
"data-mark": mark,
|
|
@@ -7563,6 +7605,7 @@ function DockSheet({ snap, onSnapChange, label, peekOnly, header, children, onDi
|
|
|
7563
7605
|
ref: bodyRef,
|
|
7564
7606
|
className: "wgt-sheet-body",
|
|
7565
7607
|
"data-testid": "widget-dock-sheet-body",
|
|
7608
|
+
tabIndex: 0,
|
|
7566
7609
|
onScroll,
|
|
7567
7610
|
children
|
|
7568
7611
|
})]
|
|
@@ -8392,11 +8435,11 @@ function BrandWordmark({ name }) {
|
|
|
8392
8435
|
}
|
|
8393
8436
|
//#endregion
|
|
8394
8437
|
//#region src/dock/dock.tsx
|
|
8395
|
-
var DEFAULT_COLOR = {
|
|
8438
|
+
var DEFAULT_COLOR$1 = {
|
|
8396
8439
|
primary: "#4c1d50",
|
|
8397
8440
|
tone: "light"
|
|
8398
8441
|
};
|
|
8399
|
-
var DEFAULT_TYPE = {
|
|
8442
|
+
var DEFAULT_TYPE$1 = {
|
|
8400
8443
|
font: "inherit",
|
|
8401
8444
|
radius: "soft",
|
|
8402
8445
|
caps: "none"
|
|
@@ -8408,7 +8451,7 @@ var DEFAULT_LAYOUT = {
|
|
|
8408
8451
|
};
|
|
8409
8452
|
var INTERRUPT_SEEN_STORAGE_KEY = "wgt_dock_interrupt_seen";
|
|
8410
8453
|
function Dock(props) {
|
|
8411
|
-
const { identity, color = DEFAULT_COLOR, type = DEFAULT_TYPE, layout = DEFAULT_LAYOUT, copy = {}, direction = "ltr", locale = "en", messages = defaultWidgetMessages, voice, escalated = false, offline = false, status, notice, statusKind, operatorLine, operatorName, reconnecting = false, roomDropped = false, partialTranscript, preamble, clause, channel = "text", shelf, transcript, transcriptCount, lastTurn, composing = false, unread = false, sheetExtra, followKey, revealSheet = false, showPrice = true, cardImageAspect = DEFAULT_CARD_ASPECT, bottomOffset = "auto", curationHref, productHref, navigate, draft, onDraftChange, onSubmit, composerDisabled = false, onAttach, attachSlot, attachBusy, proactive, pageKey, conciergeScrollRef, onEndCall, skinStyle, skin, preview = false, announcement, attribution, privacyChoices, initialDraft, initialSelection, initialFocus, initialMinimised, insets, hold, audio, onReady, onShown } = props;
|
|
8454
|
+
const { identity, color = DEFAULT_COLOR$1, type = DEFAULT_TYPE$1, layout = DEFAULT_LAYOUT, copy = {}, direction = "ltr", locale = "en", messages = defaultWidgetMessages, voice, escalated = false, offline = false, status, notice, statusKind, operatorLine, operatorName, reconnecting = false, roomDropped = false, partialTranscript, preamble, clause, channel = "text", shelf, transcript, transcriptCount, lastTurn, composing = false, unread = false, sheetExtra, followKey, revealSheet = false, showPrice = true, cardImageAspect = DEFAULT_CARD_ASPECT, bottomOffset = "auto", curationHref, productHref, navigate, draft, onDraftChange, onSubmit, composerDisabled = false, onAttach, attachSlot, attachBusy, proactive, pageKey, conciergeScrollRef, onEndCall, skinStyle, skin, preview = false, announcement, attribution, privacyChoices, initialDraft, initialSelection, initialFocus, initialMinimised, insets, hold, audio, onReady, onShown } = props;
|
|
8412
8455
|
const scopeId = useId().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
8413
8456
|
const rootRef = useRef(null);
|
|
8414
8457
|
const rowRef = useRef(null);
|
|
@@ -9296,15 +9339,9 @@ function Dock(props) {
|
|
|
9296
9339
|
* Emitted TWICE, against `:host` and against this instance's own scope
|
|
9297
9340
|
* attribute, because the dock renders in both worlds: inside `core.ts`'s
|
|
9298
9341
|
* shadow root for the CDN embed, and in LIGHT DOM for a Next.js host and
|
|
9299
|
-
* the marketing preview.
|
|
9300
|
-
* one invalid selector invalidates the whole rule — so they are two blocks
|
|
9301
|
-
* with identical bodies.
|
|
9342
|
+
* the marketing preview.
|
|
9302
9343
|
*/
|
|
9303
|
-
const themeCss = useMemo(() => {
|
|
9304
|
-
const theme = deriveTheme(color, type);
|
|
9305
|
-
const scope = `[data-wgt-scope="${scopeId}"]`;
|
|
9306
|
-
return `${themeToCss(theme, ":host")}\n${themeToCss(theme, scope)}\n${themeToMarkedHostCss(theme, scope)}`;
|
|
9307
|
-
}, [
|
|
9344
|
+
const themeCss = useMemo(() => scopedThemeCss(deriveTheme(color, type), `[data-wgt-scope="${scopeId}"]`, void 0, true), [
|
|
9308
9345
|
color,
|
|
9309
9346
|
type,
|
|
9310
9347
|
scopeId
|
|
@@ -10158,7 +10195,7 @@ function createLucideIcon(iconDataOrName, iconNode = [], aliases = []) {
|
|
|
10158
10195
|
* This source code is licensed under the ISC license.
|
|
10159
10196
|
* See the LICENSE file in the root directory of this source tree.
|
|
10160
10197
|
*/
|
|
10161
|
-
var __iconData$
|
|
10198
|
+
var __iconData$5 = {
|
|
10162
10199
|
name: "grip-vertical",
|
|
10163
10200
|
size: 24,
|
|
10164
10201
|
node: [
|
|
@@ -10200,8 +10237,8 @@ var __iconData$6 = {
|
|
|
10200
10237
|
}]
|
|
10201
10238
|
]
|
|
10202
10239
|
};
|
|
10203
|
-
__iconData$
|
|
10204
|
-
var GripVertical = createLucideIcon(__iconData$
|
|
10240
|
+
__iconData$5.node;
|
|
10241
|
+
var GripVertical = createLucideIcon(__iconData$5);
|
|
10205
10242
|
//#endregion
|
|
10206
10243
|
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/mic-off.mjs
|
|
10207
10244
|
/**
|
|
@@ -10210,7 +10247,7 @@ var GripVertical = createLucideIcon(__iconData$6);
|
|
|
10210
10247
|
* This source code is licensed under the ISC license.
|
|
10211
10248
|
* See the LICENSE file in the root directory of this source tree.
|
|
10212
10249
|
*/
|
|
10213
|
-
var __iconData$
|
|
10250
|
+
var __iconData$4 = {
|
|
10214
10251
|
name: "mic-off",
|
|
10215
10252
|
size: 24,
|
|
10216
10253
|
node: [
|
|
@@ -10240,8 +10277,8 @@ var __iconData$5 = {
|
|
|
10240
10277
|
}]
|
|
10241
10278
|
]
|
|
10242
10279
|
};
|
|
10243
|
-
__iconData$
|
|
10244
|
-
var MicOff = createLucideIcon(__iconData$
|
|
10280
|
+
__iconData$4.node;
|
|
10281
|
+
var MicOff = createLucideIcon(__iconData$4);
|
|
10245
10282
|
//#endregion
|
|
10246
10283
|
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/mic.mjs
|
|
10247
10284
|
/**
|
|
@@ -10250,7 +10287,7 @@ var MicOff = createLucideIcon(__iconData$5);
|
|
|
10250
10287
|
* This source code is licensed under the ISC license.
|
|
10251
10288
|
* See the LICENSE file in the root directory of this source tree.
|
|
10252
10289
|
*/
|
|
10253
|
-
var __iconData$
|
|
10290
|
+
var __iconData$3 = {
|
|
10254
10291
|
name: "mic",
|
|
10255
10292
|
size: 24,
|
|
10256
10293
|
node: [
|
|
@@ -10272,8 +10309,8 @@ var __iconData$4 = {
|
|
|
10272
10309
|
}]
|
|
10273
10310
|
]
|
|
10274
10311
|
};
|
|
10275
|
-
__iconData$
|
|
10276
|
-
var Mic = createLucideIcon(__iconData$
|
|
10312
|
+
__iconData$3.node;
|
|
10313
|
+
var Mic = createLucideIcon(__iconData$3);
|
|
10277
10314
|
//#endregion
|
|
10278
10315
|
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/phone-off.mjs
|
|
10279
10316
|
/**
|
|
@@ -10282,7 +10319,7 @@ var Mic = createLucideIcon(__iconData$4);
|
|
|
10282
10319
|
* This source code is licensed under the ISC license.
|
|
10283
10320
|
* See the LICENSE file in the root directory of this source tree.
|
|
10284
10321
|
*/
|
|
10285
|
-
var __iconData$
|
|
10322
|
+
var __iconData$2 = {
|
|
10286
10323
|
name: "phone-off",
|
|
10287
10324
|
size: 24,
|
|
10288
10325
|
node: [
|
|
@@ -10300,8 +10337,8 @@ var __iconData$3 = {
|
|
|
10300
10337
|
}]
|
|
10301
10338
|
]
|
|
10302
10339
|
};
|
|
10303
|
-
__iconData$
|
|
10304
|
-
var PhoneOff = createLucideIcon(__iconData$
|
|
10340
|
+
__iconData$2.node;
|
|
10341
|
+
var PhoneOff = createLucideIcon(__iconData$2);
|
|
10305
10342
|
//#endregion
|
|
10306
10343
|
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/send.mjs
|
|
10307
10344
|
/**
|
|
@@ -10310,7 +10347,7 @@ var PhoneOff = createLucideIcon(__iconData$3);
|
|
|
10310
10347
|
* This source code is licensed under the ISC license.
|
|
10311
10348
|
* See the LICENSE file in the root directory of this source tree.
|
|
10312
10349
|
*/
|
|
10313
|
-
var __iconData$
|
|
10350
|
+
var __iconData$1 = {
|
|
10314
10351
|
name: "send",
|
|
10315
10352
|
size: 24,
|
|
10316
10353
|
node: [["path", {
|
|
@@ -10321,30 +10358,8 @@ var __iconData$2 = {
|
|
|
10321
10358
|
key: "12cjpa"
|
|
10322
10359
|
}]]
|
|
10323
10360
|
};
|
|
10324
|
-
__iconData$2.node;
|
|
10325
|
-
var Send = createLucideIcon(__iconData$2);
|
|
10326
|
-
//#endregion
|
|
10327
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/square.mjs
|
|
10328
|
-
/**
|
|
10329
|
-
* @license lucide-react v1.50.0 - ISC
|
|
10330
|
-
*
|
|
10331
|
-
* This source code is licensed under the ISC license.
|
|
10332
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
10333
|
-
*/
|
|
10334
|
-
var __iconData$1 = {
|
|
10335
|
-
name: "square",
|
|
10336
|
-
size: 24,
|
|
10337
|
-
node: [["rect", {
|
|
10338
|
-
width: "18",
|
|
10339
|
-
height: "18",
|
|
10340
|
-
x: "3",
|
|
10341
|
-
y: "3",
|
|
10342
|
-
rx: "2",
|
|
10343
|
-
key: "afitv7"
|
|
10344
|
-
}]]
|
|
10345
|
-
};
|
|
10346
10361
|
__iconData$1.node;
|
|
10347
|
-
var
|
|
10362
|
+
var Send = createLucideIcon(__iconData$1);
|
|
10348
10363
|
//#endregion
|
|
10349
10364
|
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/x.mjs
|
|
10350
10365
|
/**
|
|
@@ -10367,8 +10382,158 @@ var __iconData = {
|
|
|
10367
10382
|
__iconData.node;
|
|
10368
10383
|
var X = createLucideIcon(__iconData);
|
|
10369
10384
|
//#endregion
|
|
10385
|
+
//#region src/widget/mark-look.ts
|
|
10386
|
+
/**
|
|
10387
|
+
* The mark's static geometry and colours, shared by the React `Mark`
|
|
10388
|
+
* (`mark.tsx`) and the plain-DOM cold launcher (`cdn/launcher-dom.ts`).
|
|
10389
|
+
*
|
|
10390
|
+
* Framework-free on purpose: `launcher-dom.ts` ships in the `core` artefact,
|
|
10391
|
+
* which carries no React. Both renderers read the same declarations, so the
|
|
10392
|
+
* cold launcher and the React one cannot drift apart at the handover. They
|
|
10393
|
+
* are CSS declaration strings rather than style objects because `core` ships
|
|
10394
|
+
* unminified whitespace and a budget with a few hundred bytes of headroom: one
|
|
10395
|
+
* line of CSS per element costs a fraction of an object literal. React reads
|
|
10396
|
+
* them through `styleOf`. Animation lives in `styles/mark.css`, which only
|
|
10397
|
+
* the React stage loads.
|
|
10398
|
+
*/
|
|
10399
|
+
function isMarkVariant(value) {
|
|
10400
|
+
return typeof value === "string" && MARK_VARIANTS.includes(value);
|
|
10401
|
+
}
|
|
10402
|
+
/** Resting heights of the four bars, as a fraction of the bar box. */
|
|
10403
|
+
var MARK_BARS = [
|
|
10404
|
+
.5,
|
|
10405
|
+
.9,
|
|
10406
|
+
.65,
|
|
10407
|
+
.4
|
|
10408
|
+
];
|
|
10409
|
+
var markRootCss = (size) => `position:relative;display:grid;place-items:center;flex:none;width:${size}px;height:${size}px;border-radius:50%;background:var(--wgt-primary,var(--widget-accent,#111827));color:var(--wgt-on-primary,var(--wmk-on,#fff))`;
|
|
10410
|
+
var markBarsCss = (size) => `display:flex;align-items:center;gap:${tenth(size * .055)}px;height:46%`;
|
|
10411
|
+
var markBarCss = (size, k) => `display:block;width:${Math.max(2, tenth(size * .07))}px;height:100%;border-radius:99px;background:currentColor;transform:scaleY(${k})`;
|
|
10412
|
+
var markMonoCss = (size) => `font-weight:600;font-size:${tenth(size * .44)}px;line-height:1;font-family:var(--wgt-font,inherit)`;
|
|
10413
|
+
var MARK_PIP_CSS = "width:30%;height:30%;border-radius:50%;background:currentColor";
|
|
10414
|
+
function tenth(n) {
|
|
10415
|
+
return Math.round(n * 10) / 10;
|
|
10416
|
+
}
|
|
10417
|
+
/** What the mark draws: a monogram with no letter falls back to bars. */
|
|
10418
|
+
function drawnMark(variant, name) {
|
|
10419
|
+
const letter = variant === "monogram" ? firstGrapheme(name) : "";
|
|
10420
|
+
return {
|
|
10421
|
+
drawn: variant === "monogram" && letter === "" ? "bars" : variant,
|
|
10422
|
+
letter
|
|
10423
|
+
};
|
|
10424
|
+
}
|
|
10425
|
+
/**
|
|
10426
|
+
* The monogram's letter: the first grapheme of the agent's name, uppercased.
|
|
10427
|
+
* A grapheme, not a code unit, so an accented or emoji-led name keeps its
|
|
10428
|
+
* first visible character whole. Empty name ⇒ `''`; callers then draw bars.
|
|
10429
|
+
*/
|
|
10430
|
+
function firstGrapheme(name) {
|
|
10431
|
+
const trimmed = name?.trim() ?? "";
|
|
10432
|
+
if (trimmed === "") return "";
|
|
10433
|
+
return ((Intl.Segmenter ? new Intl.Segmenter().segment(trimmed)[Symbol.iterator]().next().value?.segment : Array.from(trimmed)[0]) ?? "").toLocaleUpperCase();
|
|
10434
|
+
}
|
|
10435
|
+
//#endregion
|
|
10436
|
+
//#region src/widget/style-of.ts
|
|
10437
|
+
var cache = /* @__PURE__ */ new Map();
|
|
10438
|
+
/**
|
|
10439
|
+
* A CSS declaration string as a React style object — how the React launcher
|
|
10440
|
+
* and mark read the declarations they share with the cold launcher
|
|
10441
|
+
* (`launcher-look.ts`, `mark-look.ts`). Memoised: the strings are a handful of
|
|
10442
|
+
* constants, and a stable object is one React does not diff key by key.
|
|
10443
|
+
*/
|
|
10444
|
+
function styleOf(css) {
|
|
10445
|
+
let style = cache.get(css);
|
|
10446
|
+
if (style === void 0) {
|
|
10447
|
+
const out = {};
|
|
10448
|
+
for (const declaration of css.split(";")) {
|
|
10449
|
+
const colon = declaration.indexOf(":");
|
|
10450
|
+
if (colon < 0) continue;
|
|
10451
|
+
const name = declaration.slice(0, colon).trim();
|
|
10452
|
+
out[name.startsWith("--") ? name : name.replace(/-([a-z])/g, (_, c) => c.toUpperCase())] = declaration.slice(colon + 1).trim();
|
|
10453
|
+
}
|
|
10454
|
+
style = out;
|
|
10455
|
+
cache.set(css, style);
|
|
10456
|
+
}
|
|
10457
|
+
return style;
|
|
10458
|
+
}
|
|
10459
|
+
//#endregion
|
|
10460
|
+
//#region src/widget/mark.tsx
|
|
10461
|
+
/** Every state the mark draws. `muted` and `connecting` come from the voice session, not `BotState`. */
|
|
10462
|
+
var MARK_STATES = [
|
|
10463
|
+
"idle",
|
|
10464
|
+
"connecting",
|
|
10465
|
+
"listening",
|
|
10466
|
+
"thinking",
|
|
10467
|
+
"speaking",
|
|
10468
|
+
"muted"
|
|
10469
|
+
];
|
|
10470
|
+
/**
|
|
10471
|
+
* The mark's state from the session's. Muted wins over everything except
|
|
10472
|
+
* speaking: the agent can still talk while the shopper's mic is off.
|
|
10473
|
+
*/
|
|
10474
|
+
function markStateFor(state, flags = {}) {
|
|
10475
|
+
return flags.muted && state !== "speaking" ? "muted" : state;
|
|
10476
|
+
}
|
|
10477
|
+
/**
|
|
10478
|
+
* The simple brand mark: a flat disc in the tenant's primary with four bars,
|
|
10479
|
+
* a monogram, or a dot. Motion carries the state (`styles/mark.css`): bars
|
|
10480
|
+
* follow the voice while listening or speaking, a ring ripples while
|
|
10481
|
+
* listening, an arc orbits while thinking. Transform and opacity only, and
|
|
10482
|
+
* static under `prefers-reduced-motion`.
|
|
10483
|
+
*/
|
|
10484
|
+
function Mark({ variant, state = "idle", size, name, label, extraCss, testId }) {
|
|
10485
|
+
const { drawn, letter } = drawnMark(variant, name);
|
|
10486
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
10487
|
+
...label === void 0 ? { "aria-hidden": true } : {
|
|
10488
|
+
role: "img",
|
|
10489
|
+
"aria-label": label
|
|
10490
|
+
},
|
|
10491
|
+
className: "wmk",
|
|
10492
|
+
"data-mark": drawn,
|
|
10493
|
+
"data-mark-state": state,
|
|
10494
|
+
"data-testid": testId,
|
|
10495
|
+
style: styleOf(extraCss ? `${markRootCss(size)};${extraCss}` : markRootCss(size)),
|
|
10496
|
+
children: [
|
|
10497
|
+
state === "listening" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", { className: "wmk-r" }), /* @__PURE__ */ jsx("span", { className: "wmk-r" })] }) : null,
|
|
10498
|
+
drawn === "bars" ? /* @__PURE__ */ jsx("span", {
|
|
10499
|
+
className: "wmk-b",
|
|
10500
|
+
style: styleOf(markBarsCss(size)),
|
|
10501
|
+
children: MARK_BARS.map((k, i) => /* @__PURE__ */ jsx("i", {
|
|
10502
|
+
className: "wmk-i",
|
|
10503
|
+
style: styleOf(markBarCss(size, k))
|
|
10504
|
+
}, i))
|
|
10505
|
+
}) : drawn === "monogram" ? /* @__PURE__ */ jsx("span", {
|
|
10506
|
+
className: "wmk-m",
|
|
10507
|
+
style: styleOf(markMonoCss(size)),
|
|
10508
|
+
children: letter
|
|
10509
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
10510
|
+
className: "wmk-p",
|
|
10511
|
+
style: styleOf(MARK_PIP_CSS)
|
|
10512
|
+
}),
|
|
10513
|
+
state === "thinking" ? /* @__PURE__ */ jsx("svg", {
|
|
10514
|
+
className: "wmk-a",
|
|
10515
|
+
viewBox: "0 0 94 94",
|
|
10516
|
+
width: size + 18,
|
|
10517
|
+
height: size + 18,
|
|
10518
|
+
"aria-hidden": true,
|
|
10519
|
+
children: /* @__PURE__ */ jsx("circle", {
|
|
10520
|
+
cx: "47",
|
|
10521
|
+
cy: "47",
|
|
10522
|
+
r: "45",
|
|
10523
|
+
fill: "none"
|
|
10524
|
+
})
|
|
10525
|
+
}) : null
|
|
10526
|
+
]
|
|
10527
|
+
});
|
|
10528
|
+
}
|
|
10529
|
+
//#endregion
|
|
10370
10530
|
//#region src/avatar-face.tsx
|
|
10371
|
-
|
|
10531
|
+
/** Mark diameter per slot: the launcher's face box and the panel's hero. */
|
|
10532
|
+
var MARK_SIZE = {
|
|
10533
|
+
sm: 48,
|
|
10534
|
+
lg: 64
|
|
10535
|
+
};
|
|
10536
|
+
function AvatarFace({ avatar, state, size, label, messageArrived, tightenKey, name, muted, markSize }) {
|
|
10372
10537
|
switch (avatar) {
|
|
10373
10538
|
case "orb": return /* @__PURE__ */ jsx(BotFace, {
|
|
10374
10539
|
state,
|
|
@@ -10382,10 +10547,61 @@ function AvatarFace({ avatar, state, size, label, messageArrived, tightenKey })
|
|
|
10382
10547
|
label,
|
|
10383
10548
|
tightenKey
|
|
10384
10549
|
});
|
|
10550
|
+
case "bars":
|
|
10551
|
+
case "monogram":
|
|
10552
|
+
case "dot": return /* @__PURE__ */ jsx(Mark, {
|
|
10553
|
+
variant: avatar,
|
|
10554
|
+
state: markStateFor(state, { muted }),
|
|
10555
|
+
size: markSize ?? MARK_SIZE[size],
|
|
10556
|
+
...name !== void 0 ? { name } : {},
|
|
10557
|
+
...label !== void 0 ? { label } : {}
|
|
10558
|
+
});
|
|
10385
10559
|
default: throw new Error(`Unhandled widget avatar: ${String(avatar)}`);
|
|
10386
10560
|
}
|
|
10387
10561
|
}
|
|
10388
10562
|
//#endregion
|
|
10563
|
+
//#region src/widget/launcher-look.ts
|
|
10564
|
+
/**
|
|
10565
|
+
* The collapsed launcher's look, shared by `concierge-launcher.tsx` (React)
|
|
10566
|
+
* and `cdn/launcher-dom.ts` (the plain-DOM cold twin `core` paints first).
|
|
10567
|
+
*
|
|
10568
|
+
* One set of declarations, two renderers: the handover from the cold pill to
|
|
10569
|
+
* React's must not visibly jump, and the cheapest way to keep two renderings
|
|
10570
|
+
* identical is to give them nothing to disagree about. Every value reads a
|
|
10571
|
+
* `--wgt-*` token with a literal fallback, because the cold launcher paints
|
|
10572
|
+
* before any stylesheet defining those tokens has been adopted. Strings, not
|
|
10573
|
+
* objects, for the reason `mark-look.ts` gives. Framework-free: ships in `core`.
|
|
10574
|
+
*/
|
|
10575
|
+
var LAUNCHER_VARIANTS = ["pill", "round"];
|
|
10576
|
+
var DEFAULT_LAUNCHER_VARIANT = "pill";
|
|
10577
|
+
/** Mark diameter inside each launcher. */
|
|
10578
|
+
var LAUNCHER_MARK_SIZE = {
|
|
10579
|
+
pill: 44,
|
|
10580
|
+
round: 60
|
|
10581
|
+
};
|
|
10582
|
+
var LAUNCHER_SURFACE = "var(--wgt-panel-surface,var(--widget-card,#fff))";
|
|
10583
|
+
var LAUNCHER_TEXT = "var(--wgt-text,var(--widget-foreground,#1c1618))";
|
|
10584
|
+
/** The theme's muted text, else the shared role (dark in a `.dark` host), else `deriveWidgetTheme`'s default. */
|
|
10585
|
+
var MUTED = "var(--wgt-text-muted,var(--widget-foreground-muted,rgba(28,22,24,.73)))";
|
|
10586
|
+
var LAUNCHER_ELEVATION = "var(--wgt-elevation,0 0 0 1px rgba(0,0,0,.06),0 24px 60px -22px rgba(0,0,0,.32))";
|
|
10587
|
+
/** The live-call dot, and `--wgt-live`'s value: constant, so it reads as "live" on every theme. */
|
|
10588
|
+
var LIVE_COLOR = "#E5484D";
|
|
10589
|
+
var RADIUS = "var(--wgt-launcher-radius,999px)";
|
|
10590
|
+
/** The fixed root, before the anchor. */
|
|
10591
|
+
var launcherRootCss = (variant) => `display:flex;align-items:center;color:${LAUNCHER_TEXT}` + (variant === "pill" ? `;gap:4px;padding:6px;border-radius:${RADIUS};background:${LAUNCHER_SURFACE};box-shadow:${LAUNCHER_ELEVATION};backdrop-filter:var(--wgt-panel-filter,none);white-space:nowrap` : "");
|
|
10592
|
+
/** The open control: mark + text in the pill, the mark alone in the round. */
|
|
10593
|
+
var launcherOpenCss = (variant) => `position:relative;border:0;margin:0;padding:0;background:none;color:${LAUNCHER_TEXT};font:inherit;cursor:pointer;` + (variant === "pill" ? `display:flex;align-items:center;gap:12px;min-height:48px;padding-inline-end:10px;border-radius:${RADIUS};text-align:start` : "display:grid;place-items:center;width:64px;height:64px;border-radius:50%");
|
|
10594
|
+
/** The round launcher's mark carries the elevation; the pill's sits on a surface. */
|
|
10595
|
+
var ROUND_MARK_CSS = `box-shadow:${LAUNCHER_ELEVATION}`;
|
|
10596
|
+
var LAUNCHER_TEXT_CSS = `display:block;min-width:0;color:${LAUNCHER_TEXT}`;
|
|
10597
|
+
var LAUNCHER_TITLE_CSS = `display:block;max-width:14rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:15px;font-weight:600;line-height:1.3;color:${LAUNCHER_TEXT}`;
|
|
10598
|
+
var LAUNCHER_SUB_CSS = `display:block;white-space:nowrap;font-size:12px;line-height:1.3;color:${MUTED};font-variant-numeric:tabular-nums`;
|
|
10599
|
+
var LAUNCHER_GRIP_CSS = `position:relative;z-index:1;display:grid;place-items:center;min-width:28px;min-height:44px;padding:0;border:0;border-radius:999px;background:none;color:${MUTED};cursor:grab;touch-action:none`;
|
|
10600
|
+
/** In the round launcher the grip is a small disc on the circle's lower start edge. */
|
|
10601
|
+
var ROUND_GRIP_CSS = `position:absolute;bottom:-4px;inset-inline-start:-4px;z-index:1;min-height:28px;background:${LAUNCHER_SURFACE};box-shadow:${LAUNCHER_ELEVATION}`;
|
|
10602
|
+
/** The grip's hit area: 44px across around the 28px grip, which keeps its look. */
|
|
10603
|
+
var GRIP_HIT_CSS = "position:absolute;inset:-8px";
|
|
10604
|
+
//#endregion
|
|
10389
10605
|
//#region src/widget/position.ts
|
|
10390
10606
|
/**
|
|
10391
10607
|
* Where the concierge sits on the host page, and how a visitor moves it.
|
|
@@ -10491,7 +10707,7 @@ var QUIET = {
|
|
|
10491
10707
|
badge: false,
|
|
10492
10708
|
initials: false
|
|
10493
10709
|
};
|
|
10494
|
-
function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChange, onOpen, hidden, id, testId, avatar = "orb", spec = QUIET, initials = "" }) {
|
|
10710
|
+
function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChange, onOpen, hidden, id, testId, avatar = "orb", spec = QUIET, initials = "", launcher = DEFAULT_LAUNCHER_VARIANT, agentName, subLabel, callLabel, callSrLabel }) {
|
|
10495
10711
|
const rootRef = useRef(null);
|
|
10496
10712
|
/** Pixel offset while a drag is in flight; `null` when it is not. */
|
|
10497
10713
|
const [drag, setDrag] = useState(null);
|
|
@@ -10575,15 +10791,24 @@ function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChan
|
|
|
10575
10791
|
if (next !== position) onPositionChange(next);
|
|
10576
10792
|
};
|
|
10577
10793
|
const dragging = drag !== null;
|
|
10794
|
+
const markSize = LAUNCHER_MARK_SIZE[launcher];
|
|
10795
|
+
const round = launcher === "round";
|
|
10796
|
+
const sub = callLabel ?? subLabel;
|
|
10797
|
+
const showText = !round && (label !== void 0 || sub !== void 0);
|
|
10798
|
+
const ariaLabel = round || label === void 0 ? [srLabel, callSrLabel ?? callLabel].filter(Boolean).join(", ") : callSrLabel && `${label}, ${callSrLabel}`;
|
|
10578
10799
|
return /* @__PURE__ */ jsxs("div", {
|
|
10579
10800
|
ref: rootRef,
|
|
10580
10801
|
id,
|
|
10581
10802
|
"data-testid": testId,
|
|
10582
10803
|
"data-position": position,
|
|
10804
|
+
"data-launcher": launcher,
|
|
10583
10805
|
"aria-hidden": hidden,
|
|
10584
|
-
className: cn("fixed z-50
|
|
10585
|
-
style:
|
|
10586
|
-
|
|
10806
|
+
className: cn("fixed z-50", 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),
|
|
10807
|
+
style: {
|
|
10808
|
+
...styleOf(launcherRootCss(launcher)),
|
|
10809
|
+
...drag ? { transform: `translate(${drag.dx}px, ${drag.dy}px)` } : {}
|
|
10810
|
+
},
|
|
10811
|
+
children: [onPositionChange ? /* @__PURE__ */ jsxs("button", {
|
|
10587
10812
|
type: "button",
|
|
10588
10813
|
"aria-label": moveLabel,
|
|
10589
10814
|
title: moveLabel,
|
|
@@ -10594,14 +10819,21 @@ function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChan
|
|
|
10594
10819
|
onPointerUp,
|
|
10595
10820
|
onPointerCancel: onPointerUp,
|
|
10596
10821
|
onKeyDown: onGripKeyDown,
|
|
10597
|
-
className:
|
|
10598
|
-
|
|
10822
|
+
className: FOCUS_RING,
|
|
10823
|
+
style: {
|
|
10824
|
+
...styleOf(round ? `${LAUNCHER_GRIP_CSS};${ROUND_GRIP_CSS}` : LAUNCHER_GRIP_CSS),
|
|
10825
|
+
cursor: dragging ? "grabbing" : "grab"
|
|
10826
|
+
},
|
|
10827
|
+
children: [/* @__PURE__ */ jsx(GripVertical, {
|
|
10599
10828
|
className: "size-4",
|
|
10600
10829
|
"aria-hidden": true
|
|
10601
|
-
})
|
|
10830
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
10831
|
+
"aria-hidden": true,
|
|
10832
|
+
style: styleOf(GRIP_HIT_CSS)
|
|
10833
|
+
})]
|
|
10602
10834
|
}) : null, /* @__PURE__ */ jsxs("button", {
|
|
10603
10835
|
type: "button",
|
|
10604
|
-
"aria-label":
|
|
10836
|
+
"aria-label": ariaLabel,
|
|
10605
10837
|
tabIndex: hidden || spec.disabled ? -1 : 0,
|
|
10606
10838
|
disabled: spec.disabled,
|
|
10607
10839
|
...spec.busy ? { "aria-busy": true } : {},
|
|
@@ -10612,17 +10844,29 @@ function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChan
|
|
|
10612
10844
|
onOpen();
|
|
10613
10845
|
},
|
|
10614
10846
|
"data-testid": testId ? `${testId}-open` : void 0,
|
|
10615
|
-
className:
|
|
10847
|
+
className: FOCUS_RING,
|
|
10848
|
+
style: styleOf(launcherOpenCss(launcher)),
|
|
10616
10849
|
children: [/* @__PURE__ */ jsxs("span", {
|
|
10617
10850
|
"aria-hidden": true,
|
|
10618
|
-
className: "relative block
|
|
10851
|
+
className: "relative block shrink-0",
|
|
10852
|
+
style: {
|
|
10853
|
+
width: markSize,
|
|
10854
|
+
height: markSize
|
|
10855
|
+
},
|
|
10619
10856
|
children: [
|
|
10620
10857
|
spec.initials && initials !== "" ? /* @__PURE__ */ jsx("span", {
|
|
10621
10858
|
"data-testid": "widget-launcher-initials",
|
|
10622
|
-
|
|
10859
|
+
style: styleOf(`${markRootCss(markSize)};${round ? `${ROUND_MARK_CSS};` : ""}font-weight:600;font-size:${Math.round(markSize * .34)}px;line-height:1;font-family:var(--wgt-font,inherit)`),
|
|
10623
10860
|
children: initials
|
|
10861
|
+
}) : isMarkVariant(avatar) ? /* @__PURE__ */ jsx(Mark, {
|
|
10862
|
+
variant: avatar,
|
|
10863
|
+
state: spec.busy ? "connecting" : "idle",
|
|
10864
|
+
size: markSize,
|
|
10865
|
+
...agentName !== void 0 ? { name: agentName } : {},
|
|
10866
|
+
...round ? { extraCss: ROUND_MARK_CSS } : {}
|
|
10624
10867
|
}) : /* @__PURE__ */ jsx("span", {
|
|
10625
|
-
className: "absolute start-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2
|
|
10868
|
+
className: "absolute start-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 rtl:translate-x-1/2",
|
|
10869
|
+
style: { scale: String(markSize / 64) },
|
|
10626
10870
|
children: /* @__PURE__ */ jsx(AvatarFace, {
|
|
10627
10871
|
avatar,
|
|
10628
10872
|
state: "idle",
|
|
@@ -10632,490 +10876,1038 @@ function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChan
|
|
|
10632
10876
|
}),
|
|
10633
10877
|
spec.busy ? /* @__PURE__ */ jsx("span", {
|
|
10634
10878
|
"data-testid": "widget-launcher-busy",
|
|
10635
|
-
className: "pointer-events-none absolute inset-
|
|
10879
|
+
className: "pointer-events-none absolute -inset-[3px] animate-spin rounded-full border-2 border-transparent border-t-[var(--wgt-primary,#111827)] motion-reduce:animate-none"
|
|
10636
10880
|
}) : null,
|
|
10637
10881
|
spec.badge ? /* @__PURE__ */ jsx("span", {
|
|
10638
10882
|
"data-testid": "widget-launcher-badge",
|
|
10639
|
-
|
|
10883
|
+
style: BADGE_STYLE
|
|
10884
|
+
}) : null,
|
|
10885
|
+
round && callLabel !== void 0 ? /* @__PURE__ */ jsx("span", {
|
|
10886
|
+
"data-testid": "widget-launcher-live",
|
|
10887
|
+
title: callLabel,
|
|
10888
|
+
style: LIVE_STYLE
|
|
10640
10889
|
}) : null
|
|
10641
10890
|
]
|
|
10642
|
-
}),
|
|
10891
|
+
}), showText ? /* @__PURE__ */ jsxs("span", {
|
|
10643
10892
|
dir: "auto",
|
|
10644
|
-
|
|
10645
|
-
children: label
|
|
10646
|
-
|
|
10893
|
+
style: styleOf(LAUNCHER_TEXT_CSS),
|
|
10894
|
+
children: [label !== void 0 ? /* @__PURE__ */ jsx("span", {
|
|
10895
|
+
style: styleOf(LAUNCHER_TITLE_CSS),
|
|
10896
|
+
children: label
|
|
10897
|
+
}) : null, sub !== void 0 ? /* @__PURE__ */ jsx("span", {
|
|
10898
|
+
"data-testid": "widget-launcher-sub",
|
|
10899
|
+
style: styleOf(LAUNCHER_SUB_CSS),
|
|
10900
|
+
children: sub
|
|
10901
|
+
}) : null]
|
|
10902
|
+
}) : null]
|
|
10647
10903
|
})]
|
|
10648
10904
|
});
|
|
10649
10905
|
}
|
|
10906
|
+
/** Something landed behind the closed panel. Text-coloured, so it reads on any brand mark. */
|
|
10907
|
+
var BADGE_STYLE = {
|
|
10908
|
+
position: "absolute",
|
|
10909
|
+
top: 0,
|
|
10910
|
+
insetInlineEnd: 0,
|
|
10911
|
+
width: 12,
|
|
10912
|
+
height: 12,
|
|
10913
|
+
borderRadius: "50%",
|
|
10914
|
+
background: LAUNCHER_TEXT,
|
|
10915
|
+
boxShadow: `0 0 0 2px ${LAUNCHER_SURFACE}`
|
|
10916
|
+
};
|
|
10917
|
+
/** A call is live (round launcher). */
|
|
10918
|
+
var LIVE_STYLE = {
|
|
10919
|
+
position: "absolute",
|
|
10920
|
+
top: 2,
|
|
10921
|
+
insetInlineStart: 2,
|
|
10922
|
+
width: 14,
|
|
10923
|
+
height: 14,
|
|
10924
|
+
borderRadius: "50%",
|
|
10925
|
+
background: `var(--wgt-live,${LIVE_COLOR})`,
|
|
10926
|
+
boxShadow: `0 0 0 2px ${LAUNCHER_SURFACE}`
|
|
10927
|
+
};
|
|
10928
|
+
var FOCUS_RING = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--wgt-ring,#111827)]";
|
|
10650
10929
|
//#endregion
|
|
10651
|
-
//#region
|
|
10652
|
-
/**
|
|
10653
|
-
* PANEL GEOMETRY — where the conversation's first row sits, as a FRACTION of
|
|
10654
|
-
* the panel's height, and what that costs horizontally.
|
|
10655
|
-
*
|
|
10656
|
-
* Four CSS length expressions and the arithmetic behind them, used by
|
|
10657
|
-
* `concierge-shell.tsx`'s `transcriptEdgeFade`. Their own module, and NOT
|
|
10658
|
-
* re-exported from `index.ts`: `concierge-shell.geometry.test.tsx` has to read
|
|
10659
|
-
* the exact strings the component ships (jsdom's CSS serializer mangles a
|
|
10660
|
-
* `max()` containing a subtraction, so reading them back off a rendered element
|
|
10661
|
-
* tests jsdom rather than this widget), while the package's public API stays
|
|
10662
|
-
* the components themselves.
|
|
10663
|
-
*
|
|
10664
|
-
* One ratio ties the four lengths together, and it is the whole
|
|
10665
|
-
* repair for a bug that shipped: the panel is an ellipse (`rounded-full` on a
|
|
10666
|
-
* `w x 1.6w` box), so how much width it offers depends entirely on how far down
|
|
10667
|
-
* you are. The clearances below scaled with `cqh` while the transcript's
|
|
10668
|
-
* horizontal inset was a fixed 8px tuned for the oval's wide middle, so the
|
|
10669
|
-
* taller the panel got the HIGHER the first message sat proportionally — into a
|
|
10670
|
-
* narrower part of the curve, with no matching inset. Measured live in
|
|
10671
|
-
* Storybook, first agent bubble's top-left corner against the curve at its own
|
|
10672
|
-
* top edge: 14px inside the ellipse at a 582px panel, 37px at 720px, 62px at
|
|
10673
|
-
* 920px (the 2000x1150 desktop it was reported on). `overflow-clip` on the
|
|
10674
|
-
* surface then cut exactly that much off the bubble.
|
|
10675
|
-
*
|
|
10676
|
-
* 0.1924 is not chosen, it is READ OFF the short panel: 112px (the tuned
|
|
10677
|
-
* clearance, see {@link TRANSCRIPT_FADE_TOP_LEN}) over 582px (the panel a
|
|
10678
|
-
* 375x812 phone renders) is 0.19244. Holding that ratio at every size is what
|
|
10679
|
-
* makes the geometry scale-invariant — every panel then presents the first row
|
|
10680
|
-
* at the same point on the same curve, and ONE horizontal inset serves all of
|
|
10681
|
-
* them ({@link TRANSCRIPT_INSET_X}). Expressed as `19.24cqh` in the lengths
|
|
10682
|
-
* below; `cqh` is the panel's own height, via `[container-type:size]` on the
|
|
10683
|
-
* panel div (verified live: `14cqh` resolved to 128.8px on a 920px panel).
|
|
10684
|
-
*
|
|
10685
|
-
* Not a JS constant that gets multiplied out — the panel's height is never
|
|
10686
|
-
* known to JS, only to CSS, which is why every length here is an expression.
|
|
10687
|
-
*/
|
|
10688
|
-
/**
|
|
10689
|
-
* Top ramp when the transcript starts at the panel's top, under the floating
|
|
10690
|
-
* orb — it has to span the orb, so a message is gone before it reaches it
|
|
10691
|
-
* rather than sliding out from behind it half-visible.
|
|
10692
|
-
*
|
|
10693
|
-
* A CSS length EXPRESSION, not a bare number, since the aspect-ratio panel
|
|
10694
|
-
* (`w-[min(97vw,50dvh)]` + `aspect-[5/8]`) ranges from ~582px tall (mobile,
|
|
10695
|
-
* width-bound) to 800px+ (desktop, height-bound) — a fixed 112px clearance
|
|
10696
|
-
* tuned for the OLD fixed-520px panel left too little air under the orb on a
|
|
10697
|
-
* tall one and too much on a short one. `max(112px, 19.24cqh)` is a floor, not
|
|
10698
|
-
* a fixed value: it stays exactly 112px (today's tuned figure) on a short
|
|
10699
|
-
* panel, where 19.24cqh would fall below it, and grows with `cqh` — the query
|
|
10700
|
-
* container's own height, established by `[container-type:size]` on the
|
|
10701
|
-
* panel div below — once the panel is tall enough that 19.24% of it exceeds
|
|
10702
|
-
* 112px. `cqh` rather than `dvh` specifically: the panel's real rendered
|
|
10703
|
-
* height, not the viewport's, since the panel does not always fill the
|
|
10704
|
-
* viewport (mobile: width-bound, height is `w / (8/5)`, shorter than 100dvh).
|
|
10705
|
-
*
|
|
10706
|
-
* 19.24, not the 14 this shipped with: 14cqh gave a TALL panel proportionally
|
|
10707
|
-
* LESS clearance than the 112px floor gives a short one (14% against 19.24%),
|
|
10708
|
-
* which pushed the first message up into the narrowing part of the ellipse —
|
|
10709
|
-
* see the ratio's own note above for the measurements. The floor and the
|
|
10710
|
-
* scaling term now agree at 582px (19.24% of 582 = 111.98), so the two meet
|
|
10711
|
-
* without a step rather than crossing over at some unrelated height.
|
|
10712
|
-
*/
|
|
10713
|
-
var TRANSCRIPT_FADE_TOP_LEN = "max(112px, 19.24cqh)";
|
|
10714
|
-
/**
|
|
10715
|
-
* Top ramp when a `badge` sits above the transcript.
|
|
10716
|
-
*
|
|
10717
|
-
* A badge has ALREADY pushed the transcript clear of the orb, so reusing the
|
|
10718
|
-
* orb-sized ramp charges for the same clearance twice: it left a 112px dead
|
|
10719
|
-
* band directly under the badge and dissolved the opening message for no
|
|
10720
|
-
* reason (measured in `WithABadgeAndNoVoice` — orb ends 565, badge 573-598,
|
|
10721
|
-
* first message could not start above 710). At that point the fade is only
|
|
10722
|
-
* doing its ordinary job of softening a scroll edge, so it wants an ordinary
|
|
10723
|
-
* scroll-edge length. Same floor+`cqh` scheme as {@link TRANSCRIPT_FADE_TOP_LEN}
|
|
10724
|
-
* above and for the same reason — this ramp needs to soften proportionally
|
|
10725
|
-
* more of a tall panel's scroll edge than a short one's.
|
|
10726
|
-
*
|
|
10727
|
-
* The third arm is the ellipse, and it is what keeps this variant honest at
|
|
10728
|
-
* sizes the badge's own fixed offsets stop covering. With a badge the first row
|
|
10729
|
-
* is pushed down by chrome that does NOT scale — 1px surface border + 6px
|
|
10730
|
-
* column padding + the badge wrapper's `mt-[104px]` + 4px list padding = 115px
|
|
10731
|
-
* — so the row lands at `(115px + this ramp) / panelHeight`, a fraction that
|
|
10732
|
-
* SHRINKS as the panel grows. `19.24cqh - 115px` is that equation solved for
|
|
10733
|
-
* the ramp, so the row lands on the same point of the curve the no-badge
|
|
10734
|
-
* variant does. It is inert on the panels this variant was tuned against
|
|
10735
|
-
* (negative at 582px, 4.5px at 720px, so the other two arms win) and takes over
|
|
10736
|
-
* only above ~745px, where the fixed 115px has stopped being enough.
|
|
10737
|
-
*
|
|
10738
|
-
* The badge's own height is counted as ZERO in that 115px, deliberately:
|
|
10739
|
-
* `badge` is an arbitrary node from the host (`voice-widget.tsx` passes a
|
|
10740
|
-
* one-line status pill, ~26px), and only the shortest-badge bound holds for
|
|
10741
|
-
* every caller. A taller badge pushes the row further down, which is the safe
|
|
10742
|
-
* direction.
|
|
10743
|
-
*/
|
|
10744
|
-
var TRANSCRIPT_FADE_TOP_WITH_BADGE_LEN = "max(28px, 4cqh, 19.24cqh - 115px)";
|
|
10745
|
-
var TRANSCRIPT_FADE_BOTTOM_LEN = "max(136px, 23.36cqh)";
|
|
10746
|
-
/**
|
|
10747
|
-
* The transcript's horizontal inset — the width the ellipse actually costs.
|
|
10748
|
-
*
|
|
10749
|
-
* `10.6cqw` is where the curve is at the first row's height: on an ellipse of
|
|
10750
|
-
* width `w`, at the fraction 0.1924 of the way down (the ratio the clearances
|
|
10751
|
-
* above hold at every size), the left edge lies `w * (1 - sqrt(1 - (2*0.1924 -
|
|
10752
|
-
* 1)^2)) / 2` = `0.1058 * w` in from the bounding box. Rounded up to 10.6% so
|
|
10753
|
-
* the rounding goes toward clearance rather than away from it.
|
|
10754
|
-
*
|
|
10755
|
-
* `- 11px` because 11px of that is already paid for by fixed chrome outside
|
|
10756
|
-
* this element: the surface's 1px border plus the inner column's `px-2.5`. The
|
|
10757
|
-
* inset is measured from the PANEL's box, which is where the curve is; this
|
|
10758
|
-
* padding only has to make up the difference. Verified live: a 363.8px-wide
|
|
10759
|
-
* panel put the first bubble's left edge at 19px = 11px chrome + the 8px this
|
|
10760
|
-
* replaces.
|
|
10761
|
-
*
|
|
10762
|
-
* The `8px` floor is the value this shipped with, kept as a lower bound so a
|
|
10763
|
-
* degenerately small panel can never end up with less padding than a plain
|
|
10764
|
-
* scroll edge wants. It is inert at every real size (the formula gives 27.6px
|
|
10765
|
-
* on the smallest panel the widget renders).
|
|
10766
|
-
*
|
|
10767
|
-
* Symmetric on purpose, and applied as `padding-inline` so it stays symmetric
|
|
10768
|
-
* in RTL: the ellipse is symmetric, the visitor's own bubbles are `justify-end`
|
|
10769
|
-
* against the other side of it, and either side is the first row's side
|
|
10770
|
-
* depending on who spoke.
|
|
10771
|
-
*/
|
|
10772
|
-
var TRANSCRIPT_INSET_X = "max(8px, 10.6cqw - 11px)";
|
|
10773
|
-
/**
|
|
10774
|
-
* The composer overlay's bottom offset when the microphone is drawn.
|
|
10775
|
-
*
|
|
10776
|
-
* `11.86cqh` is {@link COMPOSER_ROW_FRACTION} as a length. `- 63px` is
|
|
10777
|
-
* everything between this offset and the input's bottom edge that does NOT
|
|
10778
|
-
* scale: the surface's 1px border (the overlay is positioned against the inner
|
|
10779
|
-
* column's padding box, one border inside the panel) plus the 62px microphone
|
|
10780
|
-
* block — a 10px `gap-2.5`, the row's 4px `mt-1`, and a 48px `size-12` button.
|
|
10781
|
-
*
|
|
10782
|
-
* `max(6px, …)` keeps the 6px this shipped with as a floor, and the two arms
|
|
10783
|
-
* MEET at the panel it was tuned on rather than crossing somewhere unrelated:
|
|
10784
|
-
* `11.86cqh - 63px` is 6.03px at 582px, so a phone renders what it rendered
|
|
10785
|
-
* before to a hundredth of a pixel and only larger panels lift the composer.
|
|
10786
|
-
*/
|
|
10787
|
-
var COMPOSER_BOTTOM_LEN = "max(6px, 15cqh - 63px)";
|
|
10788
|
-
/**
|
|
10789
|
-
* The composer overlay's bottom offset when there is NO microphone.
|
|
10790
|
-
*
|
|
10791
|
-
* Same target row, minus only the 1px surface border: with `voice` omitted the
|
|
10792
|
-
* overlay's last child IS the input, so the 62px the microphone block
|
|
10793
|
-
* contributed above has to come from this offset instead. That is a real move —
|
|
10794
|
-
* 6px to 68px on a phone — and it is the fix rather than a side effect. Left at
|
|
10795
|
-
* 6px the input sits 7px off a `rounded-full` panel's bottom tip, where the
|
|
10796
|
-
* ellipse offers 79px of width in total; no width cap can rescue that row, so
|
|
10797
|
-
* the row itself has to come up to where the panel is wide enough to hold it.
|
|
10798
|
-
*
|
|
10799
|
-
* The band it moves into is the one the microphone would have occupied, which
|
|
10800
|
-
* the transcript already clears ({@link TRANSCRIPT_FADE_BOTTOM_LEN} is sized
|
|
10801
|
-
* for the input + microphone pair regardless of whether the pair is drawn), so
|
|
10802
|
-
* nothing above has to move to make room.
|
|
10803
|
-
*/
|
|
10804
|
-
var COMPOSER_BOTTOM_NO_VOICE_LEN = "max(6px, 15cqh - 1px)";
|
|
10805
|
-
/**
|
|
10806
|
-
* The composer's width cap — what the ellipse actually offers at that row.
|
|
10807
|
-
*
|
|
10808
|
-
* On an ellipse of width `w`, at the fraction `1 - 0.1186` of the way down, the
|
|
10809
|
-
* full chord is `w * sqrt(1 - (2*0.8814 - 1)^2)` = `0.6465 * w`. So `64.65cqw`
|
|
10810
|
-
* is not a taste-tuned percentage, it is the panel's own width at the row the
|
|
10811
|
-
* two offsets above pin the input to — where `w-[71%]`, the class this caps,
|
|
10812
|
-
* was 6.4% of the panel too wide at EVERY size (10.8px of overhang on a phone,
|
|
10813
|
-
* 52.0px on a 920px panel, because the row also drifts lower as the panel
|
|
10814
|
-
* grows).
|
|
10815
|
-
*
|
|
10816
|
-
* `- 10px` is clearance, 5px each side, matching the 5px the transcript's rows
|
|
10817
|
-
* clear the curve by — the panel paints a 1.5px gradient ring plus a 1px
|
|
10818
|
-
* surface border at that edge, and the input's own rounding means the arc, not
|
|
10819
|
-
* the corner, is what approaches the curve.
|
|
10820
|
-
*
|
|
10821
|
-
* Applied as `max-width` over the existing `w-[71%]`, not in place of it: 71%
|
|
10822
|
-
* stays the upper bound the composer had, and this only ever tightens it (the
|
|
10823
|
-
* ellipse term is below 71% for any panel, since 0.6465 < 0.71). The `160px`
|
|
10824
|
-
* floor is the "cap it sensibly" arm — it stops a degenerately small panel from
|
|
10825
|
-
* resolving the composer to a few dozen pixels of unusable input, and it is
|
|
10826
|
-
* inert at every size the widget really renders (it binds only below a 248px
|
|
10827
|
-
* panel; the narrowest phone in circulation, 320px, gives 310px).
|
|
10828
|
-
*/
|
|
10829
|
-
var COMPOSER_MAX_WIDTH_LEN = "max(160px, 71.41cqw - 10px)";
|
|
10830
|
-
/**
|
|
10831
|
-
* The opaque ground the composer sits on, which has to keep covering it.
|
|
10832
|
-
*
|
|
10833
|
-
* The transcript runs the panel's whole height and passes BEHIND this row, so
|
|
10834
|
-
* this gradient is the only thing between a message and the input's own
|
|
10835
|
-
* translucent chip fill. It was a fixed `h-[132px]`, tuned when the composer
|
|
10836
|
-
* was pinned 6px off the bottom on every panel — and the moment the offsets
|
|
10837
|
-
* above start lifting the composer on a tall panel, a fixed ground stops
|
|
10838
|
-
* reaching its top edge (the composer's top is `11.86cqh + 40px` above the
|
|
10839
|
-
* panel's bottom: 109px at 582px, but 149px at 920px, against 132px of ground).
|
|
10840
|
-
*
|
|
10841
|
-
* 22.68cqh is the same read-off-the-short-panel derivation as everything else
|
|
10842
|
-
* here — 132/582 = 0.22680 — so a phone renders exactly the 132px it rendered
|
|
10843
|
-
* before and the ground grows with the row it is under. It stays above the
|
|
10844
|
-
* composer's own top at every size, and stays the same shade taller than the
|
|
10845
|
-
* transcript's bottom clearance that it is today ({@link
|
|
10846
|
-
* TRANSCRIPT_FADE_BOTTOM_LEN} is 20.27cqh against this 22.68cqh, exactly the
|
|
10847
|
-
* 118:132 relationship the two were tuned at), so they still meet without a
|
|
10848
|
-
* seam or a band of doubly-darkened panel.
|
|
10849
|
-
*/
|
|
10850
|
-
var COMPOSER_GROUND_LEN = "max(150px, 25.77cqh)";
|
|
10851
|
-
//#endregion
|
|
10852
|
-
//#region src/widget/concierge-shell.tsx
|
|
10930
|
+
//#region ../widget-protocol/dist/text-direction.js
|
|
10853
10931
|
/**
|
|
10854
|
-
*
|
|
10932
|
+
* Base direction for a block of text whose language is the CONTENT's, not the
|
|
10933
|
+
* reader's. Pure, string-only and dependency-free: a STATIC import into the
|
|
10934
|
+
* chat bundle a shopper downloads, shared by the console (`apps/web`) and the
|
|
10935
|
+
* widget (`@saar-ai/web-widget`), which used to keep a hand copy each.
|
|
10855
10936
|
*
|
|
10856
|
-
*
|
|
10857
|
-
*
|
|
10858
|
-
*
|
|
10859
|
-
*
|
|
10937
|
+
* It lives here rather than in `@wesence/i18n` because the widget's published
|
|
10938
|
+
* bundle may resolve no `@wesence/*` module at all (`docs/PACKAGE_DISTRIBUTION.md`,
|
|
10939
|
+
* enforced by `scripts/check-npm-bundle-provenance.mjs`), the same reason
|
|
10940
|
+
* `./money` lives here.
|
|
10941
|
+
*
|
|
10942
|
+
* ## Why the console's own direction is the wrong answer
|
|
10943
|
+
*
|
|
10944
|
+
* `<html dir>` is set from the operator's UI locale, and every element inherits
|
|
10945
|
+
* it. That is right for the chrome and wrong for a transcript: an
|
|
10946
|
+
* English-speaking agent reading an Arabic conversation would render each
|
|
10947
|
+
* message with an LTR base direction, and the Unicode bidirectional algorithm
|
|
10948
|
+
* would then lay out the runs in the wrong order and throw trailing punctuation
|
|
10949
|
+
* to the wrong end of the line.
|
|
10950
|
+
*
|
|
10951
|
+
* The failure is invisible to the person looking at it. An agent who cannot read
|
|
10952
|
+
* Arabic sees Arabic-looking text and moves on; the customer is the one who gets
|
|
10953
|
+
* quoted back a sentence that reads incorrectly. The reverse case is just as
|
|
10954
|
+
* real — an Arabic-speaking agent reading English conversations under an RTL
|
|
10955
|
+
* base.
|
|
10956
|
+
*
|
|
10957
|
+
* ## Mixed runs are the normal case here, not an edge case
|
|
10958
|
+
*
|
|
10959
|
+
* Verified against live recognition output: Arabic comes back as
|
|
10960
|
+
* `رقم الـ order هو 4471. Please check من فضلك.` and Hindi as
|
|
10961
|
+
* `मेरा order number 4471 है।`. Latin nouns inside a non-Latin sentence are what
|
|
10962
|
+
* this product's transcripts actually contain, so bidirectional layout is
|
|
10963
|
+
* exercised on ordinary traffic rather than by an unusual customer.
|
|
10964
|
+
*
|
|
10965
|
+
* ## `auto` is the floor, not the goal
|
|
10966
|
+
*
|
|
10967
|
+
* With a known language this returns a definite direction. Without one it
|
|
10968
|
+
* returns `auto`, which delegates to the browser's first-strong-character
|
|
10969
|
+
* heuristic — better than inheriting the chrome, but wrong for a message that
|
|
10970
|
+
* opens with an English word and continues in Arabic (`Please check من فضلك`).
|
|
10971
|
+
* The real fix is to persist the conversation's resolved locale and pass it in;
|
|
10972
|
+
* see the note in `Transcript`.
|
|
10860
10973
|
*/
|
|
10861
|
-
var FOLLOW_TOLERANCE_PX = 24;
|
|
10862
|
-
/**
|
|
10863
|
-
* Build the transcript's mask + the padding that matches it.
|
|
10864
|
-
*
|
|
10865
|
-
* The two must be derived together: the padding is what lets the first and
|
|
10866
|
-
* last messages scroll clear of the ramp, so a ramp length that is not also
|
|
10867
|
-
* the padding leaves the newest message permanently half-dissolved.
|
|
10868
|
-
*
|
|
10869
|
-
* The top half of the top ramp is fully transparent (SAA-435): text beside
|
|
10870
|
-
* the orb read through at 20-45% under the old eased ramp, which looked like
|
|
10871
|
-
* no fade at all. It now clears completely before it reaches the orb's row.
|
|
10872
|
-
*
|
|
10873
|
-
* The top ramp's stops are scaled from `topLen` rather than hardcoded, so the
|
|
10874
|
-
* shortened badge variant keeps the same eased shape instead of becoming a
|
|
10875
|
-
* steep two-point cut. `topLen` is a CSS length EXPRESSION now (a `max(<px>,
|
|
10876
|
-
* <N>cqh)` floor, see the constants above), not a plain number — `at(fraction)`
|
|
10877
|
-
* therefore emits `calc(<topLen> * <fraction>)` rather than doing the
|
|
10878
|
-
* multiplication in JS, so each stop scales with the query container's
|
|
10879
|
-
* height (`cqh`) exactly the way `topLen` itself does. `calc()` accepts a
|
|
10880
|
-
* `max()` expression as its left operand (`max()` resolves to a `<length>`,
|
|
10881
|
-
* and a `<length>` may be multiplied by a bare `<number>` inside `calc()`),
|
|
10882
|
-
* so this composes without a second unit-handling special case.
|
|
10883
|
-
*
|
|
10884
|
-
* The bottom ramp's own inner taper (the last four stops, `96px`/`72px`/
|
|
10885
|
-
* `48px`/`24px`) stays fixed pixels, deliberately NOT scaled by `cqh`: it is
|
|
10886
|
-
* a small, fixed-shape cosmetic fade against the very bottom edge, sized
|
|
10887
|
-
* once and unrelated to how much CLEARANCE the composer needs above it —
|
|
10888
|
-
* that clearance is what `TRANSCRIPT_FADE_BOTTOM_LEN` (the transition point
|
|
10889
|
-
* this taper starts from, and the padding below) controls, and that is what
|
|
10890
|
-
* scales.
|
|
10891
|
-
*
|
|
10892
|
-
* The horizontal inset rides along here rather than staying a `px-2` class for
|
|
10893
|
-
* the same reason the vertical padding does: it is derived from `topLen` — the
|
|
10894
|
-
* curve is only knowable once you know how far down the first row starts (see
|
|
10895
|
-
* {@link TRANSCRIPT_INSET_X}) — and splitting a derived pair across a class and
|
|
10896
|
-
* a style object is exactly how the two drift apart.
|
|
10897
|
-
*/
|
|
10898
|
-
function transcriptEdgeFade(topLen, shift) {
|
|
10899
|
-
const at = (fraction) => shift ? `calc(${shift} + ${topLen} * ${fraction})` : `calc(${topLen} * ${fraction})`;
|
|
10900
|
-
const top = shift ? `calc(${shift} + ${topLen})` : topLen;
|
|
10901
|
-
const gradient = `linear-gradient(to bottom, ${[
|
|
10902
|
-
"transparent 0",
|
|
10903
|
-
`transparent ${at(.5)}`,
|
|
10904
|
-
`rgba(0,0,0,0.25) ${at(.7)}`,
|
|
10905
|
-
`rgba(0,0,0,0.65) ${at(.86)}`,
|
|
10906
|
-
`#000 ${top}`,
|
|
10907
|
-
`#000 calc(100% - ${TRANSCRIPT_FADE_BOTTOM_LEN})`,
|
|
10908
|
-
"rgba(0,0,0,0.86) calc(100% - 96px)",
|
|
10909
|
-
"rgba(0,0,0,0.60) calc(100% - 72px)",
|
|
10910
|
-
"rgba(0,0,0,0.32) calc(100% - 48px)",
|
|
10911
|
-
"rgba(0,0,0,0.10) calc(100% - 24px)",
|
|
10912
|
-
"transparent 100%"
|
|
10913
|
-
].join(", ")})`;
|
|
10914
|
-
return {
|
|
10915
|
-
maskImage: gradient,
|
|
10916
|
-
WebkitMaskImage: gradient,
|
|
10917
|
-
paddingTop: top,
|
|
10918
|
-
paddingBottom: TRANSCRIPT_FADE_BOTTOM_LEN,
|
|
10919
|
-
paddingInline: TRANSCRIPT_INSET_X
|
|
10920
|
-
};
|
|
10921
|
-
}
|
|
10922
|
-
/** All variants built once — none depends on props beyond badge and pill presence. */
|
|
10923
|
-
var TRANSCRIPT_EDGE_FADE = transcriptEdgeFade(TRANSCRIPT_FADE_TOP_LEN);
|
|
10924
10974
|
/**
|
|
10925
|
-
*
|
|
10926
|
-
*
|
|
10927
|
-
*
|
|
10928
|
-
*
|
|
10975
|
+
* Languages written right-to-left. Keyed on the language subtag, so a region
|
|
10976
|
+
* never has to be enumerated.
|
|
10977
|
+
*
|
|
10978
|
+
* Beyond Arabic on purpose: Hebrew, Farsi, Urdu and Pashto are the scripts a CX
|
|
10979
|
+
* product in this region acquires next, and getting one wrong is the same silent
|
|
10980
|
+
* failure. Adding a language to the product must not also require remembering
|
|
10981
|
+
* this file.
|
|
10929
10982
|
*/
|
|
10930
|
-
var
|
|
10931
|
-
|
|
10983
|
+
var RTL_LANGUAGES = /* @__PURE__ */ new Set([
|
|
10984
|
+
"ar",
|
|
10985
|
+
"he",
|
|
10986
|
+
"iw",
|
|
10987
|
+
"fa",
|
|
10988
|
+
"ur",
|
|
10989
|
+
"ps",
|
|
10990
|
+
"sd",
|
|
10991
|
+
"ug",
|
|
10992
|
+
"yi",
|
|
10993
|
+
"dv"
|
|
10994
|
+
]);
|
|
10995
|
+
/** Known LTR languages this product targets, so a typo does not silently pass. */
|
|
10996
|
+
var KNOWN_LTR_LANGUAGES = /* @__PURE__ */ new Set([
|
|
10997
|
+
"en",
|
|
10998
|
+
"hi",
|
|
10999
|
+
"es",
|
|
11000
|
+
"fr",
|
|
11001
|
+
"de",
|
|
11002
|
+
"pt",
|
|
11003
|
+
"it",
|
|
11004
|
+
"nl",
|
|
11005
|
+
"id",
|
|
11006
|
+
"ta",
|
|
11007
|
+
"te",
|
|
11008
|
+
"bn",
|
|
11009
|
+
"mr",
|
|
11010
|
+
"gu",
|
|
11011
|
+
"kn",
|
|
11012
|
+
"ml",
|
|
11013
|
+
"pa"
|
|
11014
|
+
]);
|
|
11015
|
+
/** A well-formed BCP-47-ish language subtag: two or three ASCII letters. */
|
|
11016
|
+
var LANGUAGE_SUBTAG = /^[a-z]{2,3}$/;
|
|
10932
11017
|
/**
|
|
10933
|
-
*
|
|
10934
|
-
* already carries rather than inventing new plumbing:
|
|
10935
|
-
*
|
|
10936
|
-
* - `'connecting'` → `connecting`
|
|
10937
|
-
* - `'waiting'` (the agent is thinking, between the caller's turn ending and
|
|
10938
|
-
* the reply starting) → `thinking`
|
|
10939
|
-
* - `'live'` + `agentSpeaking` → `speaking`
|
|
10940
|
-
* - `'live'` otherwise → `listening`
|
|
10941
|
-
* - `'idle'` / `'blocked'` → `null`, no pill
|
|
11018
|
+
* The base direction for text in `locale`.
|
|
10942
11019
|
*
|
|
10943
|
-
*
|
|
10944
|
-
*
|
|
10945
|
-
*
|
|
10946
|
-
* `'speaking'`, which is exactly the same "renders sensibly with what it is
|
|
10947
|
-
* given" contract every other optional field on this interface follows.
|
|
11020
|
+
* @param locale BCP-47 tag from stored conversation data — untyped by the time
|
|
11021
|
+
* it reaches here, so anything malformed resolves to `auto` rather than to a
|
|
11022
|
+
* guess.
|
|
10948
11023
|
*/
|
|
10949
|
-
function
|
|
10950
|
-
if (
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
|
|
10955
|
-
|
|
10956
|
-
}
|
|
11024
|
+
function textDirectionFor$1(locale) {
|
|
11025
|
+
if (locale === void 0 || locale === null || locale === "") return "auto";
|
|
11026
|
+
const language = locale.toLowerCase().split("-")[0] ?? "";
|
|
11027
|
+
if (!LANGUAGE_SUBTAG.test(language)) return "auto";
|
|
11028
|
+
if (RTL_LANGUAGES.has(language)) return "rtl";
|
|
11029
|
+
if (KNOWN_LTR_LANGUAGES.has(language)) return "ltr";
|
|
11030
|
+
return "auto";
|
|
10957
11031
|
}
|
|
11032
|
+
//#endregion
|
|
11033
|
+
//#region src/text-direction.ts
|
|
11034
|
+
var textDirectionFor = textDirectionFor$1;
|
|
11035
|
+
//#endregion
|
|
11036
|
+
//#region src/widget-markdown.tsx
|
|
10958
11037
|
/**
|
|
10959
|
-
*
|
|
10960
|
-
*
|
|
10961
|
-
*
|
|
10962
|
-
*
|
|
10963
|
-
*
|
|
11038
|
+
* Only `http(s)` and `mailto` survive.
|
|
11039
|
+
*
|
|
11040
|
+
* A model can emit `[click here](javascript:…)` as easily as a real URL, and a
|
|
11041
|
+
* bare `href` would execute it on click. Anything else renders as plain text,
|
|
11042
|
+
* so a rejected link still shows its label rather than vanishing.
|
|
10964
11043
|
*/
|
|
10965
|
-
function
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
10969
|
-
|
|
10970
|
-
case "speaking": return labels?.speaking ?? defaultWidgetMessages.voice_state_speaking;
|
|
10971
|
-
}
|
|
10972
|
-
}
|
|
10973
|
-
/**
|
|
10974
|
-
* The leading dot's colour, in brand tokens — never a literal, so it follows
|
|
10975
|
-
* `skinStyle` when a tenant publishes their own brand colours, the same
|
|
10976
|
-
* reasoning every other brand-coloured glow in this file already states.
|
|
10977
|
-
* `listening` and `speaking` share `--brand-rose`: both are "the room is
|
|
10978
|
-
* live" states from the caller's point of view (a caller talking and an
|
|
10979
|
-
* agent talking back both read as "the call is active"), where
|
|
10980
|
-
* `connecting`/`thinking` are the two states with genuinely nothing to
|
|
10981
|
-
* listen to yet.
|
|
10982
|
-
*/
|
|
10983
|
-
function voiceStatePillDotColor(pillState) {
|
|
10984
|
-
switch (pillState) {
|
|
10985
|
-
case "connecting": return "var(--brand-amber)";
|
|
10986
|
-
case "thinking": return "var(--brand-plum)";
|
|
10987
|
-
case "listening":
|
|
10988
|
-
case "speaking": return "var(--brand-rose)";
|
|
10989
|
-
}
|
|
11044
|
+
function safeHref(raw) {
|
|
11045
|
+
const href = raw.trim();
|
|
11046
|
+
if (/^https?:\/\//i.test(href)) return href;
|
|
11047
|
+
if (/^mailto:[^\s]+@[^\s]+$/i.test(href)) return href;
|
|
11048
|
+
return null;
|
|
10990
11049
|
}
|
|
10991
11050
|
/**
|
|
10992
|
-
* The
|
|
10993
|
-
*
|
|
10994
|
-
*
|
|
11051
|
+
* The bidi embedding and isolate controls (U+202A-U+202E, U+2066-U+2069),
|
|
11052
|
+
* removed from what a bubble shows (SAA-436). A right-to-left override typed
|
|
11053
|
+
* into a message reverses the rest of it on screen ("exe.txt" spoofing); the
|
|
11054
|
+
* bubble's own `dir="auto"` and `unicode-bidi: isolate` already order real
|
|
11055
|
+
* mixed-direction text, so nothing legitimate needs them.
|
|
10995
11056
|
*/
|
|
10996
|
-
|
|
11057
|
+
function stripBidiControls(text) {
|
|
11058
|
+
return text.replace(/[\u202A-\u202E\u2066-\u2069]/g, "");
|
|
11059
|
+
}
|
|
10997
11060
|
/**
|
|
10998
|
-
*
|
|
10999
|
-
*
|
|
11061
|
+
* Inline constructs, innermost-last.
|
|
11062
|
+
*
|
|
11063
|
+
* Code is matched FIRST and never recurses into its own body: `` `**not
|
|
11064
|
+
* bold**` `` is a literal in every Markdown dialect, and parsing emphasis
|
|
11065
|
+
* inside it is the classic way a renderer mangles a code sample.
|
|
11000
11066
|
*/
|
|
11001
|
-
|
|
11002
|
-
|
|
11003
|
-
|
|
11004
|
-
|
|
11005
|
-
|
|
11006
|
-
|
|
11007
|
-
|
|
11008
|
-
|
|
11009
|
-
|
|
11010
|
-
|
|
11011
|
-
|
|
11012
|
-
|
|
11013
|
-
if (
|
|
11014
|
-
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
|
|
11019
|
-
|
|
11020
|
-
|
|
11021
|
-
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
|
|
11032
|
-
|
|
11033
|
-
|
|
11034
|
-
|
|
11035
|
-
|
|
11036
|
-
|
|
11067
|
+
function parseInline(src) {
|
|
11068
|
+
const out = [];
|
|
11069
|
+
let rest = src;
|
|
11070
|
+
while (rest.length > 0) {
|
|
11071
|
+
const match = /`([^`]+)`|\*\*([\s\S]+?)\*\*|__([\s\S]+?)__|(?<!\*)\*(?!\s)([^*\n]+?)\*(?!\*)|(?<!_)_(?!\s)([^_\n]+?)_(?!_)|\[([^\]]*)\]\(([^)\s]+)\)|(https:\/\/[^\s<>"'`]*[^\s<>"'`.,;:!?)\]])/.exec(rest);
|
|
11072
|
+
if (!match || match.index === void 0) {
|
|
11073
|
+
out.push({
|
|
11074
|
+
kind: "text",
|
|
11075
|
+
text: rest
|
|
11076
|
+
});
|
|
11077
|
+
break;
|
|
11078
|
+
}
|
|
11079
|
+
if (match.index > 0) out.push({
|
|
11080
|
+
kind: "text",
|
|
11081
|
+
text: rest.slice(0, match.index)
|
|
11082
|
+
});
|
|
11083
|
+
const [full, code, boldStar, boldUnd, italStar, italUnd, linkText, linkHref, bare] = match;
|
|
11084
|
+
if (code !== void 0) out.push({
|
|
11085
|
+
kind: "code",
|
|
11086
|
+
text: code
|
|
11087
|
+
});
|
|
11088
|
+
else if (boldStar !== void 0 || boldUnd !== void 0) out.push({
|
|
11089
|
+
kind: "bold",
|
|
11090
|
+
children: parseInline(boldStar ?? boldUnd)
|
|
11091
|
+
});
|
|
11092
|
+
else if (italStar !== void 0 || italUnd !== void 0) out.push({
|
|
11093
|
+
kind: "italic",
|
|
11094
|
+
children: parseInline(italStar ?? italUnd)
|
|
11095
|
+
});
|
|
11096
|
+
else if (linkHref !== void 0) {
|
|
11097
|
+
const href = safeHref(linkHref);
|
|
11098
|
+
const children = parseInline(linkText ?? "").flatMap((n) => n.kind === "link" ? n.children : [n]);
|
|
11099
|
+
out.push(href ? {
|
|
11100
|
+
kind: "link",
|
|
11101
|
+
href,
|
|
11102
|
+
children
|
|
11103
|
+
} : {
|
|
11104
|
+
kind: "text",
|
|
11105
|
+
text: linkText ?? ""
|
|
11106
|
+
});
|
|
11107
|
+
} else if (bare !== void 0) out.push({
|
|
11108
|
+
kind: "link",
|
|
11109
|
+
href: bare,
|
|
11110
|
+
children: [{
|
|
11111
|
+
kind: "text",
|
|
11112
|
+
text: bare
|
|
11113
|
+
}]
|
|
11114
|
+
});
|
|
11115
|
+
rest = rest.slice(match.index + full.length);
|
|
11116
|
+
}
|
|
11117
|
+
return out.filter((n) => !(n.kind === "text" && n.text === ""));
|
|
11118
|
+
}
|
|
11119
|
+
function sameOrigin(href) {
|
|
11120
|
+
try {
|
|
11121
|
+
return new URL(href).origin === window.location.origin;
|
|
11122
|
+
} catch {
|
|
11123
|
+
return false;
|
|
11124
|
+
}
|
|
11125
|
+
}
|
|
11126
|
+
function renderInline(nodes, keyPrefix) {
|
|
11127
|
+
return nodes.map((node, i) => {
|
|
11128
|
+
const key = `${keyPrefix}-${i}`;
|
|
11129
|
+
switch (node.kind) {
|
|
11130
|
+
case "text": return /* @__PURE__ */ jsx(Fragment$1, { children: node.text }, key);
|
|
11131
|
+
case "bold": return /* @__PURE__ */ jsx("strong", { children: renderInline(node.children, key) }, key);
|
|
11132
|
+
case "italic": return /* @__PURE__ */ jsx("em", { children: renderInline(node.children, key) }, key);
|
|
11133
|
+
case "code": return /* @__PURE__ */ jsx("code", {
|
|
11134
|
+
className: "rounded bg-black/10 px-1 py-0.5 font-mono text-[0.85em]",
|
|
11135
|
+
children: node.text
|
|
11136
|
+
}, key);
|
|
11137
|
+
case "link": return /* @__PURE__ */ jsx("a", {
|
|
11138
|
+
href: node.href,
|
|
11139
|
+
...sameOrigin(node.href) ? {} : {
|
|
11140
|
+
target: "_blank",
|
|
11141
|
+
rel: "noopener noreferrer nofollow"
|
|
11142
|
+
},
|
|
11143
|
+
className: "underline underline-offset-2 [overflow-wrap:anywhere]",
|
|
11144
|
+
children: renderInline(node.children, key)
|
|
11145
|
+
}, key);
|
|
11146
|
+
}
|
|
11147
|
+
});
|
|
11148
|
+
}
|
|
11149
|
+
var BULLET = /^\s*[-*+]\s+(.*)$/;
|
|
11150
|
+
var ORDERED = /^\s*\d+[.)]\s+(.*)$/;
|
|
11151
|
+
/**
|
|
11152
|
+
* Group lines into blocks.
|
|
11153
|
+
*
|
|
11154
|
+
* A blank line always closes the current block; a list item closes a paragraph
|
|
11155
|
+
* and vice versa. That last rule is what fixes the reported bug — the model
|
|
11156
|
+
* writes its intro and its bullets with no blank line between them, so
|
|
11157
|
+
* splitting on blank lines alone left `intro - item - item` as one paragraph.
|
|
11158
|
+
*/
|
|
11159
|
+
function parseBlocks(markdown) {
|
|
11160
|
+
const blocks = [];
|
|
11161
|
+
let paragraph = [];
|
|
11162
|
+
let list = null;
|
|
11163
|
+
const flushParagraph = () => {
|
|
11164
|
+
if (paragraph.length > 0) blocks.push({
|
|
11165
|
+
kind: "paragraph",
|
|
11166
|
+
lines: paragraph
|
|
11167
|
+
});
|
|
11168
|
+
paragraph = [];
|
|
11169
|
+
};
|
|
11170
|
+
const flushList = () => {
|
|
11171
|
+
if (list) blocks.push({
|
|
11172
|
+
kind: "list",
|
|
11173
|
+
ordered: list.ordered,
|
|
11174
|
+
items: list.items
|
|
11175
|
+
});
|
|
11176
|
+
list = null;
|
|
11177
|
+
};
|
|
11178
|
+
for (const line of markdown.split("\n")) {
|
|
11179
|
+
if (line.trim() === "") {
|
|
11180
|
+
flushParagraph();
|
|
11181
|
+
flushList();
|
|
11182
|
+
continue;
|
|
11183
|
+
}
|
|
11184
|
+
const bullet = BULLET.exec(line);
|
|
11185
|
+
const ordered = bullet ? null : ORDERED.exec(line);
|
|
11186
|
+
if (bullet ?? ordered) {
|
|
11187
|
+
flushParagraph();
|
|
11188
|
+
const isOrdered = ordered !== null;
|
|
11189
|
+
const text = (bullet?.[1] ?? ordered?.[1] ?? "").trim();
|
|
11190
|
+
if (list && list.ordered !== isOrdered) flushList();
|
|
11191
|
+
list ??= {
|
|
11192
|
+
ordered: isOrdered,
|
|
11193
|
+
items: []
|
|
11194
|
+
};
|
|
11195
|
+
list.items.push(text);
|
|
11196
|
+
continue;
|
|
11197
|
+
}
|
|
11198
|
+
flushList();
|
|
11199
|
+
paragraph.push(line.trim());
|
|
11200
|
+
}
|
|
11201
|
+
flushParagraph();
|
|
11202
|
+
flushList();
|
|
11203
|
+
return blocks;
|
|
11204
|
+
}
|
|
11205
|
+
/**
|
|
11206
|
+
* Renders one turn's text.
|
|
11207
|
+
*
|
|
11208
|
+
* Safe to call on a PARTIAL string: this runs on every streamed delta, so a
|
|
11209
|
+
* half-written `**bold` is common. Unterminated markers simply fail to match
|
|
11210
|
+
* and render as the literal characters they are, which then resolve
|
|
11211
|
+
* themselves on the delta that closes them — no flicker beyond the marker
|
|
11212
|
+
* briefly showing, and never a thrown parse error mid-stream.
|
|
11213
|
+
*/
|
|
11214
|
+
function WidgetMarkdown({ text }) {
|
|
11215
|
+
return parseBlocks(stripBidiControls(text)).map((block, i) => {
|
|
11216
|
+
if (block.kind === "list") return /* @__PURE__ */ jsx(block.ordered ? "ol" : "ul", {
|
|
11217
|
+
className: `my-1 space-y-1 ps-4 ${block.ordered ? "list-decimal" : "list-disc"}`,
|
|
11218
|
+
children: block.items.map((item, j) => /* @__PURE__ */ jsx("li", { children: renderInline(parseInline(item), `b${i}-i${j}`) }, `b${i}-i${j}`))
|
|
11219
|
+
}, `b${i}`);
|
|
11220
|
+
return /* @__PURE__ */ jsx("p", {
|
|
11221
|
+
className: "[&:not(:first-child)]:mt-2",
|
|
11222
|
+
children: block.lines.map((line, j) => /* @__PURE__ */ jsxs(Fragment$1, { children: [j > 0 ? /* @__PURE__ */ jsx("br", {}) : null, renderInline(parseInline(line), `b${i}-l${j}`)] }, `b${i}-l${j}`))
|
|
11223
|
+
}, `b${i}`);
|
|
11224
|
+
});
|
|
11225
|
+
}
|
|
11226
|
+
//#endregion
|
|
11227
|
+
//#region src/scroll-row.tsx
|
|
11228
|
+
/**
|
|
11229
|
+
* Which way a horizontal row can still scroll: bit 1 back (towards
|
|
11230
|
+
* inline-start), bit 2 on (towards inline-end). `scrollLeft` runs negative in
|
|
11231
|
+
* RTL, so its magnitude is the distance from the start in both directions.
|
|
11232
|
+
*/
|
|
11233
|
+
function scrollEdges(el) {
|
|
11234
|
+
const x = Math.abs(el.scrollLeft);
|
|
11235
|
+
return (x > 1 ? 1 : 0) | (x < el.scrollWidth - el.clientWidth - 1 ? 2 : 0);
|
|
11236
|
+
}
|
|
11237
|
+
/**
|
|
11238
|
+
* Scrolls by one item and the gap after it (else the row's width), `dir`
|
|
11239
|
+
* physical: 1 is rightwards. Smoothness is the stylesheet's, so it honours
|
|
11240
|
+
* reduced motion.
|
|
11241
|
+
*/
|
|
11242
|
+
function nudge(el, dir) {
|
|
11243
|
+
const [a, b] = el.children;
|
|
11244
|
+
el.scrollBy({ left: dir * (a && b && Math.abs(b.offsetLeft - a.offsetLeft) || el.clientWidth) });
|
|
11245
|
+
}
|
|
11246
|
+
var CHEVRON = /* @__PURE__ */ jsx("svg", {
|
|
11247
|
+
viewBox: "0 0 24 24",
|
|
11248
|
+
"aria-hidden": "true",
|
|
11249
|
+
children: /* @__PURE__ */ jsx("path", { d: "m9 6 6 6-6 6" })
|
|
11250
|
+
});
|
|
11251
|
+
/**
|
|
11252
|
+
* A horizontal scroller a keyboard and a mouse can both drive: the row takes
|
|
11253
|
+
* focus and moves one item per Left/Right, and `arrows` are previous/next
|
|
11254
|
+
* buttons that exist only while there is somewhere to go. Spread `row` on
|
|
11255
|
+
* the scrolling element and render it, with `arrows`, inside `.wsr`
|
|
11256
|
+
* (`styles/scroll-row.css`, which also hides the buttons on touch screens).
|
|
11257
|
+
*
|
|
11258
|
+
* Measured on mount, on scroll, when `count` (the number of items) changes and
|
|
11259
|
+
* when the row is resized, never on an unrelated render: a streamed reply
|
|
11260
|
+
* re-renders on every token, and a read of the row's scroll width forces
|
|
11261
|
+
* layout of rows `content-visibility: auto` skipped.
|
|
11262
|
+
*/
|
|
11263
|
+
function useScrollRow(prev, next, count) {
|
|
11264
|
+
const ref = useRef(null);
|
|
11265
|
+
const [edges, setEdges] = useState(0);
|
|
11266
|
+
const measure = () => {
|
|
11267
|
+
if (ref.current) setEdges(scrollEdges(ref.current));
|
|
11268
|
+
};
|
|
11269
|
+
useEffect(() => {
|
|
11270
|
+
measure();
|
|
11271
|
+
const el = ref.current;
|
|
11272
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
11273
|
+
const observer = new ResizeObserver(measure);
|
|
11274
|
+
observer.observe(el);
|
|
11275
|
+
return () => observer.disconnect();
|
|
11276
|
+
}, [count]);
|
|
11277
|
+
const button = (dir, label, bit) => /* @__PURE__ */ jsx("button", {
|
|
11278
|
+
type: "button",
|
|
11279
|
+
className: "wsr-b",
|
|
11280
|
+
"data-n": dir > 0 ? "" : void 0,
|
|
11281
|
+
"aria-label": label,
|
|
11282
|
+
hidden: !(edges & bit),
|
|
11283
|
+
onClick: () => {
|
|
11284
|
+
const el = ref.current;
|
|
11285
|
+
if (el) nudge(el, getComputedStyle(el).direction === "rtl" ? -dir : dir);
|
|
11286
|
+
},
|
|
11287
|
+
children: CHEVRON
|
|
11288
|
+
});
|
|
11289
|
+
return {
|
|
11290
|
+
row: {
|
|
11291
|
+
ref,
|
|
11292
|
+
tabIndex: 0,
|
|
11293
|
+
onScroll: measure,
|
|
11294
|
+
onKeyDown: (event) => {
|
|
11295
|
+
const dir = event.key === "ArrowRight" ? 1 : event.key === "ArrowLeft" ? -1 : 0;
|
|
11296
|
+
if (!dir || event.target !== event.currentTarget) return;
|
|
11297
|
+
event.preventDefault();
|
|
11298
|
+
nudge(event.currentTarget, dir);
|
|
11299
|
+
}
|
|
11300
|
+
},
|
|
11301
|
+
arrows: /* @__PURE__ */ jsxs(Fragment, { children: [button(-1, prev, 1), button(1, next, 2)] })
|
|
11302
|
+
};
|
|
11303
|
+
}
|
|
11304
|
+
//#endregion
|
|
11305
|
+
//#region src/widget/mic-button.tsx
|
|
11306
|
+
/**
|
|
11307
|
+
* What the microphone control means right now: start, mute or unmute, or,
|
|
11308
|
+
* ahead of all three, the REASON it means nothing (`labels.unavailable`).
|
|
11309
|
+
*
|
|
11310
|
+
* While connecting, dialling or the browser's prompt still open, it is inert
|
|
11311
|
+
* and busy: one impatient press must not become a second call, or a mute of a
|
|
11312
|
+
* call that does not exist yet. It reports no pressed state then, because
|
|
11313
|
+
* there is no call yet to have muted.
|
|
11314
|
+
*
|
|
11315
|
+
* On a call it is a toggle: one name ("Mute") and `aria-pressed` for the
|
|
11316
|
+
* state. A name that flips to "Unmute" as well would be read as "Unmute,
|
|
11317
|
+
* pressed", which says the opposite of what is true.
|
|
11318
|
+
*/
|
|
11319
|
+
function micControl(voice) {
|
|
11320
|
+
const connecting = voice.phase === "connecting";
|
|
11321
|
+
const inCall = voice.phase !== "idle";
|
|
11322
|
+
const unusable = voice.disabled === true || voice.phase === "blocked";
|
|
11323
|
+
const connectingLabel = voice.labels.connecting ?? defaultWidgetMessages.voice_state_connecting;
|
|
11324
|
+
const muted = inCall && voice.muted === true;
|
|
11325
|
+
return {
|
|
11326
|
+
label: unusable ? voice.labels.unavailable ?? voice.labels.start : connecting ? connectingLabel : inCall ? voice.labels.mute ?? (voice.onToggleMute ? defaultWidgetMessages.mic_stop : voice.labels.start) : voice.labels.start,
|
|
11327
|
+
onClick: connecting ? void 0 : inCall ? voice.onToggleMute ?? voice.onStart : voice.onStart,
|
|
11328
|
+
disabled: unusable || connecting,
|
|
11329
|
+
busy: connecting,
|
|
11330
|
+
pressed: inCall && !connecting ? muted : void 0,
|
|
11331
|
+
live: inCall && !connecting && !muted,
|
|
11332
|
+
muted,
|
|
11333
|
+
connectingLabel
|
|
11334
|
+
};
|
|
11335
|
+
}
|
|
11336
|
+
/** The microphone control, in the composer and in the call view's controls. */
|
|
11337
|
+
function MicButton({ voice, testId, className }) {
|
|
11338
|
+
const mic = micControl(voice);
|
|
11339
|
+
return /* @__PURE__ */ jsx("button", {
|
|
11340
|
+
type: "button",
|
|
11341
|
+
onClick: mic.onClick,
|
|
11342
|
+
disabled: mic.disabled,
|
|
11343
|
+
"data-testid": testId,
|
|
11344
|
+
title: mic.label,
|
|
11345
|
+
"aria-label": mic.label,
|
|
11346
|
+
"aria-busy": mic.busy || void 0,
|
|
11347
|
+
"aria-pressed": mic.pressed,
|
|
11348
|
+
"data-live": mic.live ? "" : void 0,
|
|
11349
|
+
className: cn(className, mic.busy && "cursor-wait"),
|
|
11350
|
+
children: mic.busy ? /* @__PURE__ */ jsx("span", {
|
|
11351
|
+
"aria-hidden": "true",
|
|
11352
|
+
"data-testid": "widget-mic-spinner",
|
|
11353
|
+
children: /* @__PURE__ */ jsx(MorphingLoader, {
|
|
11354
|
+
size: "sm",
|
|
11355
|
+
label: mic.connectingLabel
|
|
11356
|
+
})
|
|
11357
|
+
}) : mic.muted ? /* @__PURE__ */ jsx(MicOff, {}) : /* @__PURE__ */ jsx(Mic, {})
|
|
11358
|
+
});
|
|
11359
|
+
}
|
|
11360
|
+
//#endregion
|
|
11361
|
+
//#region src/widget/use-follow-bottom.ts
|
|
11362
|
+
/**
|
|
11363
|
+
* How far off the bottom still counts as "following the conversation".
|
|
11364
|
+
*
|
|
11365
|
+
* Not zero: fractional scroll metrics on zoomed and hi-dpi displays never
|
|
11366
|
+
* land exactly on the bottom, and a smooth scroll is still in flight when the
|
|
11367
|
+
* next streamed token resizes the content.
|
|
11368
|
+
*/
|
|
11369
|
+
var FOLLOW_TOLERANCE_PX = 24;
|
|
11370
|
+
/** `smooth`, or `auto` where the visitor asked for less motion. */
|
|
11371
|
+
function scrollBehavior() {
|
|
11372
|
+
return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
|
|
11373
|
+
}
|
|
11374
|
+
/**
|
|
11375
|
+
* Keeps a scrolling log on its newest line while the reader is there: the
|
|
11376
|
+
* panel's transcript and the call view's turns.
|
|
11377
|
+
*
|
|
11378
|
+
* A rise in `rows`, or any change of `nudge`, jumps to the bottom (with
|
|
11379
|
+
* `keepReader`, only while following: a call delivers turns every few seconds,
|
|
11380
|
+
* and a caller re-reading a card must not be pulled down); a fall in
|
|
11381
|
+
* `rows` does not, because a row going away is not a new turn (SAA-484).
|
|
11382
|
+
* Between turns a `ResizeObserver` on `content` and on the viewport follows a
|
|
11383
|
+
* reply as it streams, but only while following. Only a scroll UP stops
|
|
11384
|
+
* following: a smooth scroll fires `scroll` events on its way down, each short
|
|
11385
|
+
* of the bottom. jsdom and older engines ship no `scrollTo` or
|
|
11386
|
+
* `ResizeObserver`; without them this does nothing rather than throw.
|
|
11387
|
+
*/
|
|
11388
|
+
function useFollowBottom(viewport, content, rows, nudge, keepReader = false) {
|
|
11389
|
+
const following = useRef(true);
|
|
11390
|
+
const lastRows = useRef(rows);
|
|
11391
|
+
useEffect(() => {
|
|
11392
|
+
const el = viewport.current;
|
|
11393
|
+
const before = lastRows.current;
|
|
11394
|
+
lastRows.current = rows;
|
|
11395
|
+
if (typeof rows === "number" && typeof before === "number" && rows < before) return;
|
|
11396
|
+
if (typeof el?.scrollTo !== "function") return;
|
|
11397
|
+
if (keepReader && !following.current) return;
|
|
11398
|
+
following.current = true;
|
|
11399
|
+
el.scrollTo({
|
|
11400
|
+
top: el.scrollHeight,
|
|
11401
|
+
behavior: scrollBehavior()
|
|
11402
|
+
});
|
|
11403
|
+
}, [rows, nudge]);
|
|
11404
|
+
const watching = useRef({ el: null });
|
|
11405
|
+
useEffect(() => {
|
|
11406
|
+
const el = viewport.current;
|
|
11407
|
+
if (watching.current.el === el) return;
|
|
11408
|
+
watching.current.stop?.();
|
|
11409
|
+
watching.current = { el };
|
|
11410
|
+
if (!el || typeof el.scrollTo !== "function" || typeof ResizeObserver === "undefined") return;
|
|
11411
|
+
let lastTop = el.scrollTop;
|
|
11412
|
+
const onScroll = () => {
|
|
11413
|
+
if (el.scrollHeight - el.scrollTop - el.clientHeight <= FOLLOW_TOLERANCE_PX) following.current = true;
|
|
11414
|
+
else if (el.scrollTop < lastTop) following.current = false;
|
|
11415
|
+
lastTop = el.scrollTop;
|
|
11416
|
+
};
|
|
11417
|
+
const observer = new ResizeObserver(() => {
|
|
11418
|
+
if (following.current) el.scrollTo({
|
|
11419
|
+
top: el.scrollHeight,
|
|
11420
|
+
behavior: "auto"
|
|
11421
|
+
});
|
|
11422
|
+
});
|
|
11423
|
+
if (content.current) observer.observe(content.current);
|
|
11424
|
+
observer.observe(el);
|
|
11425
|
+
el.addEventListener("scroll", onScroll, { passive: true });
|
|
11426
|
+
watching.current.stop = () => {
|
|
11427
|
+
observer.disconnect();
|
|
11428
|
+
el.removeEventListener("scroll", onScroll);
|
|
11429
|
+
};
|
|
11430
|
+
});
|
|
11431
|
+
useEffect(() => () => {
|
|
11432
|
+
watching.current.stop?.();
|
|
11433
|
+
watching.current = { el: null };
|
|
11434
|
+
}, []);
|
|
11435
|
+
}
|
|
11436
|
+
//#endregion
|
|
11437
|
+
//#region src/widget/call-view.tsx
|
|
11438
|
+
/**
|
|
11439
|
+
* The call view's own words. Kept out of `defaultWidgetMessages` so the dock's
|
|
11440
|
+
* `ui.mjs` does not carry them; a host catalogue overrides any of them by key.
|
|
11441
|
+
*/
|
|
11442
|
+
var defaultCallMessages = {
|
|
11443
|
+
call_your_turn: "Your turn",
|
|
11444
|
+
call_muted: "Muted",
|
|
11445
|
+
call_paused: "Paused",
|
|
11446
|
+
call_mic_blocked: "Mic blocked",
|
|
11447
|
+
call_human: "With a teammate",
|
|
11448
|
+
call_offline: "Offline",
|
|
11449
|
+
call_problem: "Call problem",
|
|
11450
|
+
call_ended: "Call ended",
|
|
11451
|
+
call_interrupted: "Interrupted",
|
|
11452
|
+
call_try_saying: "Try saying",
|
|
11453
|
+
call_to_text: "Type instead",
|
|
11454
|
+
call_back_to_call: "Back to call",
|
|
11455
|
+
call_back_to_chat: "Back to chat",
|
|
11456
|
+
call_summary_added: "Added to your basket: {items}",
|
|
11457
|
+
call_summary_checkout: "Your checkout is ready.",
|
|
11458
|
+
call_on_call: "On call",
|
|
11459
|
+
call_say_prev: "Previous suggestions",
|
|
11460
|
+
call_say_next: "More suggestions",
|
|
11461
|
+
call_hour_one: "{n} hour",
|
|
11462
|
+
call_hour_other: "{n} hours",
|
|
11463
|
+
call_minute_one: "{n} minute",
|
|
11464
|
+
call_minute_other: "{n} minutes",
|
|
11465
|
+
call_second_one: "{n} second",
|
|
11466
|
+
call_second_other: "{n} seconds"
|
|
11467
|
+
};
|
|
11468
|
+
/** One message, from the host's catalogue when it has the key. */
|
|
11469
|
+
function callText(messages, key) {
|
|
11470
|
+
return messages[key] ?? defaultCallMessages[key] ?? defaultWidgetMessages[key] ?? "";
|
|
11471
|
+
}
|
|
11472
|
+
/**
|
|
11473
|
+
* The header's one word for each of the fourteen states. A `Record` over the
|
|
11474
|
+
* union, so a new state fails to compile until it has a word.
|
|
11475
|
+
*/
|
|
11476
|
+
var CALL_WORDS = {
|
|
11477
|
+
connecting: "voice_state_connecting",
|
|
11478
|
+
listening: "call_your_turn",
|
|
11479
|
+
thinking: "voice_state_thinking",
|
|
11480
|
+
speaking: "voice_state_speaking",
|
|
11481
|
+
muted: "call_muted",
|
|
11482
|
+
ducked: "call_paused",
|
|
11483
|
+
reconnecting: "dock_still_here",
|
|
11484
|
+
mic_blocked: "call_mic_blocked",
|
|
11485
|
+
human: "call_human",
|
|
11486
|
+
offline: "call_offline",
|
|
11487
|
+
error: "call_problem",
|
|
11488
|
+
typing: "call_your_turn",
|
|
11489
|
+
dormant: "call_your_turn",
|
|
11490
|
+
cards: "call_your_turn"
|
|
11491
|
+
};
|
|
11492
|
+
/**
|
|
11493
|
+
* The states whose reason the host's status line spells out under the header.
|
|
11494
|
+
* All but `ducked` are also announced, as in `widget-view.ts`.
|
|
11495
|
+
*/
|
|
11496
|
+
var EXPLAINED = /* @__PURE__ */ new Set([
|
|
11497
|
+
"muted",
|
|
11498
|
+
"ducked",
|
|
11499
|
+
"reconnecting",
|
|
11500
|
+
"mic_blocked",
|
|
11501
|
+
"human",
|
|
11502
|
+
"offline",
|
|
11503
|
+
"error"
|
|
11504
|
+
]);
|
|
11505
|
+
function callStatus(state, { ended, callerSpeaking }) {
|
|
11506
|
+
const explain = EXPLAINED.has(state);
|
|
11507
|
+
return {
|
|
11508
|
+
word: state === "listening" && callerSpeaking ? "voice_state_listening" : ended && !explain ? "call_ended" : CALL_WORDS[state],
|
|
11509
|
+
explain
|
|
11510
|
+
};
|
|
11511
|
+
}
|
|
11512
|
+
/** `mm:ss`, minutes uncapped. */
|
|
11513
|
+
function formatCallTime(ms) {
|
|
11514
|
+
const s = Math.max(0, Math.floor(ms / 1e3));
|
|
11515
|
+
return `${String(Math.floor(s / 60)).padStart(2, "0")}:${String(s % 60).padStart(2, "0")}`;
|
|
11516
|
+
}
|
|
11517
|
+
/**
|
|
11518
|
+
* A call's length three ways: `mm:ss` for the eye, an ISO 8601 duration for
|
|
11519
|
+
* `<time dateTime>`, and words for a screen reader ("1 hour 1 minute 1
|
|
11520
|
+
* second") from `Intl.NumberFormat`'s long units in `locale`, so every CLDR
|
|
11521
|
+
* plural form comes with no catalogue key; a locale it cannot parse speaks
|
|
11522
|
+
* English. A zero part is left out unless it is all there is.
|
|
11523
|
+
*/
|
|
11524
|
+
function callTime(ms, locale = "en") {
|
|
11525
|
+
const s = Math.max(0, Math.floor(ms / 1e3));
|
|
11526
|
+
const h = Math.floor(s / 3600);
|
|
11527
|
+
const m = Math.floor(s / 60) % 60;
|
|
11528
|
+
const unit = (n, u) => {
|
|
11529
|
+
const style = {
|
|
11530
|
+
style: "unit",
|
|
11531
|
+
unit: u,
|
|
11532
|
+
unitDisplay: "long"
|
|
11533
|
+
};
|
|
11534
|
+
try {
|
|
11535
|
+
return new Intl.NumberFormat(locale, style).format(n);
|
|
11536
|
+
} catch {
|
|
11537
|
+
return new Intl.NumberFormat("en", style).format(n);
|
|
11538
|
+
}
|
|
11539
|
+
};
|
|
11540
|
+
return {
|
|
11541
|
+
text: formatCallTime(ms),
|
|
11542
|
+
iso: `PT${h}H${m}M${s % 60}S`,
|
|
11543
|
+
words: [
|
|
11544
|
+
h && unit(h, "hour"),
|
|
11545
|
+
m && unit(m, "minute"),
|
|
11546
|
+
(s % 60 || s < 60) && unit(s % 60, "second")
|
|
11547
|
+
].filter(Boolean).join(" ")
|
|
11548
|
+
};
|
|
11549
|
+
}
|
|
11550
|
+
var IDLE_CALL_RECORD = {
|
|
11551
|
+
id: 0,
|
|
11552
|
+
active: false,
|
|
11553
|
+
startedAt: null,
|
|
11554
|
+
endedAt: null,
|
|
11555
|
+
from: 0,
|
|
11556
|
+
cart: []
|
|
11557
|
+
};
|
|
11558
|
+
function advanceCallRecord(prev, next) {
|
|
11559
|
+
const talking = next.phase === "live" || next.phase === "waiting";
|
|
11560
|
+
if (next.phase === "idle") {
|
|
11561
|
+
if (!prev.active) return prev;
|
|
11562
|
+
return {
|
|
11563
|
+
...prev,
|
|
11564
|
+
active: false,
|
|
11565
|
+
endedAt: prev.startedAt === null ? null : next.now
|
|
11566
|
+
};
|
|
11567
|
+
}
|
|
11568
|
+
if (!prev.active) return {
|
|
11569
|
+
id: prev.id + 1,
|
|
11570
|
+
active: true,
|
|
11571
|
+
startedAt: talking ? next.now : null,
|
|
11572
|
+
endedAt: null,
|
|
11573
|
+
from: next.turns,
|
|
11574
|
+
cart: next.cart,
|
|
11575
|
+
checkoutFrom: next.checkout
|
|
11576
|
+
};
|
|
11577
|
+
const rec = talking && prev.startedAt === null ? {
|
|
11578
|
+
...prev,
|
|
11579
|
+
startedAt: next.now
|
|
11580
|
+
} : prev;
|
|
11581
|
+
return !rec.checkout && next.checkout && next.checkout !== rec.checkoutFrom ? {
|
|
11582
|
+
...rec,
|
|
11583
|
+
checkout: true
|
|
11584
|
+
} : rec;
|
|
11585
|
+
}
|
|
11586
|
+
function useCallRecord(phase, turns, cart, checkout) {
|
|
11587
|
+
const ref = useRef(IDLE_CALL_RECORD);
|
|
11588
|
+
const mounted = useRef(false);
|
|
11589
|
+
useEffect(() => {
|
|
11590
|
+
mounted.current = true;
|
|
11591
|
+
}, []);
|
|
11592
|
+
ref.current = advanceCallRecord(ref.current, {
|
|
11593
|
+
phase,
|
|
11594
|
+
now: performance.now(),
|
|
11595
|
+
turns: mounted.current ? turns.length : turns.findLastIndex((turn) => turn.event === "call_started") + 1,
|
|
11596
|
+
cart: cart ?? [],
|
|
11597
|
+
checkout
|
|
11598
|
+
});
|
|
11599
|
+
return ref.current;
|
|
11600
|
+
}
|
|
11601
|
+
/** The titles whose quantity grew since the call began, in basket order. */
|
|
11602
|
+
function addedDuringCall(before, after) {
|
|
11603
|
+
const had = new Map(before.map((line) => [line.key, line.quantity]));
|
|
11604
|
+
return after.filter((line) => line.quantity > (had.get(line.key) ?? 0)).map((l) => l.title);
|
|
11605
|
+
}
|
|
11606
|
+
/** A call that is live and counting: the timer and the launcher's label tick. */
|
|
11607
|
+
var counting = (record) => record.active && record.startedAt !== null;
|
|
11608
|
+
/** `performance.now()`, re-read once a second while `running`. */
|
|
11609
|
+
function useNow(running) {
|
|
11610
|
+
const [now, setNow] = useState(() => performance.now());
|
|
11611
|
+
useEffect(() => {
|
|
11612
|
+
if (!running) return;
|
|
11613
|
+
setNow(performance.now());
|
|
11614
|
+
const id = window.setInterval(() => setNow(performance.now()), 1e3);
|
|
11615
|
+
return () => window.clearInterval(id);
|
|
11616
|
+
}, [running]);
|
|
11617
|
+
return now;
|
|
11618
|
+
}
|
|
11619
|
+
var NO_TURNS = [];
|
|
11620
|
+
/**
|
|
11621
|
+
* The panel's call lifecycle. A running call takes the panel over unless the
|
|
11622
|
+
* shopper chose "Type instead"; an ended one shows its summary until they
|
|
11623
|
+
* close it. Both choices hold for that call only: the next one shows again.
|
|
11624
|
+
* Absent `call` (the marketing preview), the call view never shows.
|
|
11625
|
+
*/
|
|
11626
|
+
function useCallMode(voice, call) {
|
|
11627
|
+
const record = useCallRecord(voice?.phase ?? "idle", call?.turns ?? NO_TURNS, call?.cart, call?.checkout);
|
|
11628
|
+
const [textCall, setTextCall] = useState(0);
|
|
11629
|
+
const [closedCall, setClosedCall] = useState(0);
|
|
11630
|
+
const now = useNow(counting(record));
|
|
11631
|
+
const onCall = callText(call?.messages ?? defaultWidgetMessages, "call_on_call");
|
|
11632
|
+
const time = counting(record) ? callTime(now - record.startedAt, call?.locale) : void 0;
|
|
11633
|
+
return {
|
|
11634
|
+
shown: call !== void 0 && voice !== void 0 && textCall !== record.id && (record.active || record.endedAt !== null && closedCall !== record.id),
|
|
11635
|
+
record,
|
|
11636
|
+
launcherLabel: time && `${onCall} · ${time.text}`,
|
|
11637
|
+
launcherSpoken: time && `${onCall}, ${time.words}`,
|
|
11638
|
+
toText: () => setTextCall(record.id),
|
|
11639
|
+
backToCall: () => setTextCall(0),
|
|
11640
|
+
closeSummary: () => setClosedCall(record.id)
|
|
11641
|
+
};
|
|
11642
|
+
}
|
|
11643
|
+
/**
|
|
11644
|
+
* The call's length, live or final. A `timer` that never announces itself
|
|
11645
|
+
* (one announcement a second would drown the call), read as words on demand.
|
|
11646
|
+
*/
|
|
11647
|
+
function CallTimer({ record, locale }) {
|
|
11648
|
+
const now = useNow(counting(record));
|
|
11649
|
+
const time = callTime(record.startedAt === null ? 0 : (record.endedAt ?? now) - record.startedAt, locale);
|
|
11650
|
+
return /* @__PURE__ */ jsxs("time", {
|
|
11651
|
+
role: "timer",
|
|
11652
|
+
"aria-live": "off",
|
|
11653
|
+
"aria-label": time.words,
|
|
11654
|
+
dateTime: time.iso,
|
|
11655
|
+
"data-testid": "widget-call-timer",
|
|
11656
|
+
className: "wgc-tm",
|
|
11657
|
+
children: [counting(record) ? /* @__PURE__ */ jsx("i", {
|
|
11658
|
+
"aria-hidden": true,
|
|
11659
|
+
"data-testid": "widget-call-live"
|
|
11660
|
+
}) : null, time.text]
|
|
11661
|
+
});
|
|
11662
|
+
}
|
|
11663
|
+
/**
|
|
11664
|
+
* The widget generation's call: a header that names the state, the call's
|
|
11665
|
+
* own turns with their cards, the "Try saying" lines and the call controls,
|
|
11666
|
+
* then the summary once it ends. Styled by `styles/call-view.css` (`.wgc`).
|
|
11667
|
+
* See docs/CONCIERGE_GENERATIONS.md "Call mode".
|
|
11668
|
+
*/
|
|
11669
|
+
function CallView({ state, callerSpeaking = false, turns, renderCards, suggestions, onSay, checkout = false, cart, messages, locale, voice, name, actions, record, bot, avatar, hint, onText, onBackToChat, testIds }) {
|
|
11670
|
+
const t = (key) => callText(messages, key);
|
|
11671
|
+
const ended = !record.active;
|
|
11672
|
+
const { word, explain } = callStatus(state, {
|
|
11673
|
+
ended,
|
|
11674
|
+
callerSpeaking
|
|
11675
|
+
});
|
|
11676
|
+
const [said, setSaid] = useState([]);
|
|
11677
|
+
const shown = turns.slice(record.from).filter((turn, i, all) => turn.speaker === "event" ? false : turn.filler ? i === all.length - 1 : turn.text.trim() !== "" || (turn.cards?.items.length ?? 0) > 0);
|
|
11678
|
+
const streamRef = useRef(null);
|
|
11679
|
+
const contentRef = useRef(null);
|
|
11680
|
+
const rootRef = useRef(null);
|
|
11681
|
+
useEffect(() => {
|
|
11682
|
+
const root = rootRef.current;
|
|
11683
|
+
const active = (root?.getRootNode())?.activeElement;
|
|
11684
|
+
if (root && (!active || active === document.body)) (root.querySelector("button.wgc-mk,[data-end]") ?? root.querySelector(".wgc-ctl button,.wgc-sum button"))?.focus();
|
|
11685
|
+
}, []);
|
|
11686
|
+
useFollowBottom(streamRef, contentRef, shown.length, void 0, true);
|
|
11687
|
+
const interrupting = voice.agentSpeaking === true && voice.onInterrupt !== void 0;
|
|
11688
|
+
const fixable = voice.phase === "blocked" && voice.onFixPermission !== void 0;
|
|
11689
|
+
const lines = !ended && onSay && (state === "muted" || state === "listening" && !callerSpeaking) ? suggestions.filter((line) => !said.includes(line)) : [];
|
|
11690
|
+
const say = useScrollRow(t("call_say_prev"), t("call_say_next"), lines.length);
|
|
11691
|
+
const added = ended ? addedDuringCall(record.cart, cart ?? []) : [];
|
|
11692
|
+
const mark = /* @__PURE__ */ jsx(AvatarFace, {
|
|
11693
|
+
avatar,
|
|
11694
|
+
state: ended ? "idle" : bot,
|
|
11695
|
+
size: "sm",
|
|
11696
|
+
markSize: 44,
|
|
11697
|
+
muted: voice.muted === true && !ended,
|
|
11698
|
+
...name !== void 0 ? { name } : {}
|
|
11699
|
+
});
|
|
11700
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
11701
|
+
ref: rootRef,
|
|
11702
|
+
"data-testid": "widget-call-view",
|
|
11703
|
+
"data-call-state": state,
|
|
11704
|
+
className: "wgc",
|
|
11705
|
+
children: [
|
|
11706
|
+
/* @__PURE__ */ jsxs("div", {
|
|
11707
|
+
className: "wgc-hd",
|
|
11708
|
+
children: [
|
|
11709
|
+
interrupting ? /* @__PURE__ */ jsx("button", {
|
|
11710
|
+
type: "button",
|
|
11711
|
+
"data-testid": "widget-interrupt",
|
|
11712
|
+
"aria-label": voice.labels.interrupt ?? defaultWidgetMessages.dock_interrupt,
|
|
11713
|
+
onClick: () => voice.onInterrupt?.("tap"),
|
|
11714
|
+
className: "wgc-mk",
|
|
11715
|
+
children: mark
|
|
11716
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
11717
|
+
className: "wgc-mk",
|
|
11718
|
+
children: mark
|
|
11719
|
+
}),
|
|
11720
|
+
/* @__PURE__ */ jsx("p", {
|
|
11721
|
+
"data-testid": "widget-voice-state",
|
|
11722
|
+
className: "wgc-st",
|
|
11723
|
+
children: t(word)
|
|
11724
|
+
}),
|
|
11725
|
+
/* @__PURE__ */ jsx("span", {
|
|
11726
|
+
role: "status",
|
|
11727
|
+
"data-testid": "widget-call-announce",
|
|
11728
|
+
className: "sr-only",
|
|
11729
|
+
children: (ended || explain && state !== "ducked") && !(explain && hint) ? t(word) : null
|
|
11730
|
+
}),
|
|
11731
|
+
/* @__PURE__ */ jsx(CallTimer, {
|
|
11732
|
+
record,
|
|
11733
|
+
locale
|
|
11734
|
+
}),
|
|
11735
|
+
actions
|
|
11736
|
+
]
|
|
11737
|
+
}),
|
|
11738
|
+
explain && hint || fixable ? /* @__PURE__ */ jsxs("div", {
|
|
11739
|
+
className: "wgc-hint",
|
|
11740
|
+
children: [explain ? hint : null, fixable ? /* @__PURE__ */ jsx("button", {
|
|
11741
|
+
type: "button",
|
|
11742
|
+
"data-testid": "widget-fix-permission",
|
|
11743
|
+
onClick: voice.onFixPermission,
|
|
11744
|
+
className: "wgc-chip",
|
|
11745
|
+
children: voice.labels.fixBrowser ?? defaultWidgetMessages.dock_fix_browser
|
|
11746
|
+
}) : null]
|
|
11747
|
+
}) : null,
|
|
11748
|
+
/* @__PURE__ */ jsx("div", {
|
|
11749
|
+
ref: streamRef,
|
|
11750
|
+
role: "log",
|
|
11751
|
+
tabIndex: 0,
|
|
11752
|
+
"aria-label": messages.conversation,
|
|
11753
|
+
className: "wgc-log no-scrollbar",
|
|
11754
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
11755
|
+
ref: contentRef,
|
|
11756
|
+
children: shown.map((turn, i) => {
|
|
11757
|
+
const you = turn.speaker === "caller";
|
|
11758
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
11759
|
+
className: "wgc-t",
|
|
11760
|
+
"data-you": you ? "" : void 0,
|
|
11761
|
+
children: [turn.text.trim() !== "" ? /* @__PURE__ */ jsxs("p", {
|
|
11762
|
+
dir: textDirectionFor(turn.locale),
|
|
11763
|
+
lang: turn.locale,
|
|
11764
|
+
"data-testid": you ? "widget-turn-caller" : "widget-turn-agent",
|
|
11765
|
+
"data-cut": turn.cut || turn.filler ? "" : void 0,
|
|
11766
|
+
"data-cur": i === shown.length - 1 && !ended ? "" : void 0,
|
|
11767
|
+
"data-partial": turn.final === false ? "" : void 0,
|
|
11768
|
+
"aria-hidden": turn.final === false ? true : void 0,
|
|
11769
|
+
className: "wgc-tx",
|
|
11770
|
+
children: [stripBidiControls(turn.text), turn.cut ? /* @__PURE__ */ jsx("span", {
|
|
11771
|
+
className: "wgc-cut",
|
|
11772
|
+
children: t("call_interrupted")
|
|
11773
|
+
}) : null]
|
|
11774
|
+
}) : null, !you && turn.cards && turn.cards.items.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
11775
|
+
className: "wgc-cards",
|
|
11776
|
+
children: renderCards(turn.cards)
|
|
11777
|
+
}) : null]
|
|
11778
|
+
}, i);
|
|
11779
|
+
})
|
|
11780
|
+
})
|
|
11781
|
+
}),
|
|
11782
|
+
lines.length > 0 ? /* @__PURE__ */ jsxs("div", {
|
|
11783
|
+
className: "wgc-say",
|
|
11784
|
+
children: [/* @__PURE__ */ jsx("p", { children: t("call_try_saying") }), /* @__PURE__ */ jsxs("div", {
|
|
11785
|
+
className: "wsr",
|
|
11786
|
+
children: [/* @__PURE__ */ jsx("ul", {
|
|
11787
|
+
"data-testid": "widget-suggestions",
|
|
11788
|
+
"aria-label": messages.suggestions_label,
|
|
11789
|
+
...say.row,
|
|
11790
|
+
children: lines.map((line) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
|
|
11791
|
+
type: "button",
|
|
11792
|
+
"data-testid": "widget-suggestion",
|
|
11793
|
+
className: "wgc-chip",
|
|
11794
|
+
onClick: () => {
|
|
11795
|
+
Promise.resolve(onSay?.(line)).then((sent) => {
|
|
11796
|
+
if (sent !== false) setSaid((prev) => [...prev, line]);
|
|
11797
|
+
});
|
|
11798
|
+
},
|
|
11799
|
+
children: line
|
|
11800
|
+
}) }, line))
|
|
11801
|
+
}), say.arrows]
|
|
11802
|
+
})]
|
|
11803
|
+
}) : null,
|
|
11804
|
+
ended ? /* @__PURE__ */ jsxs("section", {
|
|
11805
|
+
"data-testid": "widget-call-summary",
|
|
11806
|
+
className: "wgc-sum",
|
|
11807
|
+
children: [
|
|
11808
|
+
added.length > 0 ? /* @__PURE__ */ jsx("p", { children: formatMessage(t("call_summary_added"), { items: added.join(", ") }) }) : null,
|
|
11809
|
+
checkout ? /* @__PURE__ */ jsx("p", { children: t("call_summary_checkout") }) : null,
|
|
11810
|
+
/* @__PURE__ */ jsx("button", {
|
|
11811
|
+
type: "button",
|
|
11812
|
+
"data-testid": "widget-call-back-to-chat",
|
|
11813
|
+
onClick: onBackToChat,
|
|
11814
|
+
children: t("call_back_to_chat")
|
|
11815
|
+
})
|
|
11816
|
+
]
|
|
11817
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
11818
|
+
className: "wgc-ctl",
|
|
11819
|
+
children: [
|
|
11820
|
+
/* @__PURE__ */ jsx(MicButton, {
|
|
11821
|
+
voice,
|
|
11822
|
+
testId: testIds?.mic
|
|
11823
|
+
}),
|
|
11824
|
+
voice.onEnd !== void 0 ? /* @__PURE__ */ jsx("button", {
|
|
11825
|
+
type: "button",
|
|
11826
|
+
"data-testid": testIds?.endCall,
|
|
11827
|
+
"data-end": "",
|
|
11828
|
+
onClick: voice.onEnd,
|
|
11829
|
+
"aria-label": voice.labels.end ?? defaultWidgetMessages.call_end,
|
|
11830
|
+
children: /* @__PURE__ */ jsx(PhoneOff, {})
|
|
11831
|
+
}) : null,
|
|
11832
|
+
/* @__PURE__ */ jsx("button", {
|
|
11833
|
+
type: "button",
|
|
11834
|
+
"data-testid": "widget-call-to-text",
|
|
11835
|
+
onClick: onText,
|
|
11836
|
+
"aria-label": t("call_to_text"),
|
|
11837
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
11838
|
+
viewBox: "0 0 24 24",
|
|
11839
|
+
width: "20",
|
|
11840
|
+
height: "20",
|
|
11841
|
+
fill: "none",
|
|
11842
|
+
stroke: "currentColor",
|
|
11843
|
+
strokeWidth: "1.75",
|
|
11844
|
+
"aria-hidden": true,
|
|
11845
|
+
children: /* @__PURE__ */ jsx("path", { d: "M4 20l1.3-4A8 8 0 1 1 8 19z" })
|
|
11846
|
+
})
|
|
11847
|
+
})
|
|
11848
|
+
]
|
|
11849
|
+
})
|
|
11850
|
+
]
|
|
11851
|
+
});
|
|
11852
|
+
}
|
|
11853
|
+
//#endregion
|
|
11854
|
+
//#region src/widget/concierge-shell.tsx
|
|
11855
|
+
/**
|
|
11856
|
+
* Maps the call onto the pill it shows, reusing fields `ConciergeShellVoice`
|
|
11857
|
+
* already carries rather than inventing new plumbing:
|
|
11858
|
+
*
|
|
11859
|
+
* - `'connecting'` → `connecting`
|
|
11860
|
+
* - `'waiting'` (the agent is thinking, between the caller's turn ending and
|
|
11861
|
+
* the reply starting) → `thinking`
|
|
11862
|
+
* - `'live'` + `agentSpeaking` → `speaking`
|
|
11863
|
+
* - `'live'` otherwise → `listening`
|
|
11864
|
+
* - `'idle'` / `'blocked'` → `null`, no pill
|
|
11865
|
+
*
|
|
11866
|
+
* `agentSpeaking` is already a real field on {@link ConciergeShellVoice} —
|
|
11867
|
+
* this function only reads it, it does not require every caller to start
|
|
11868
|
+
* setting it; a caller that never populates it simply never reaches
|
|
11869
|
+
* `'speaking'`, which is exactly the same "renders sensibly with what it is
|
|
11870
|
+
* given" contract every other optional field on this interface follows.
|
|
11871
|
+
*/
|
|
11872
|
+
function voiceStatePillState(voice) {
|
|
11873
|
+
const phase = voice?.phase;
|
|
11874
|
+
return phase === "connecting" ? "connecting" : phase === "waiting" ? "thinking" : phase === "live" ? voice?.agentSpeaking ? "speaking" : "listening" : null;
|
|
11875
|
+
}
|
|
11876
|
+
function ConciergeShell({ open, onOpenChange, state, messageArrived = false, launcher, launcherInitials, launcherVariant, agentName, typing = false, operatorName, avatar = "orb", labels, children, badge, draft, onDraftChange, onSubmit, composerDisabled = false, voice, call, announcement, skin, skinStyle, idPrefix = "concierge", scrollKey, composerLeading, testIds, position = DEFAULT_CONCIERGE_POSITION, onPositionChange, attribution, privacyChoices, focusOnOpen = true }) {
|
|
11877
|
+
const triggerId = `${idPrefix}-trigger`;
|
|
11878
|
+
const inputId = `${idPrefix}-input`;
|
|
11879
|
+
const panelRef = useRef(null);
|
|
11880
|
+
const transcriptRef = useRef(null);
|
|
11881
|
+
/** The transcript's content box — what grows as a reply streams in. */
|
|
11882
|
+
const transcriptContentRef = useRef(null);
|
|
11883
|
+
const callMode = useCallMode(voice, call);
|
|
11884
|
+
const callLabel = callMode.launcherLabel;
|
|
11885
|
+
/** By id within the shell's own root: a shadow root has its own ids, which `document` cannot see. */
|
|
11886
|
+
const byId = (id) => (panelRef.current?.getRootNode())?.getElementById(id);
|
|
11887
|
+
const focusInput = () => window.setTimeout(() => byId(inputId)?.focus(), 0);
|
|
11037
11888
|
/**
|
|
11038
|
-
*
|
|
11039
|
-
*
|
|
11040
|
-
*
|
|
11041
|
-
* scroll up to re-read something — see the observer below for why the
|
|
11042
|
-
* distinction has to exist rather than always scrolling.
|
|
11889
|
+
* The knot's tighten flourish is EDGE-triggered (one play per bump of
|
|
11890
|
+
* `tightenKey`), so it is bumped only on the rising edge of
|
|
11891
|
+
* `messageArrived`, not on every render where it stays `true`.
|
|
11043
11892
|
*/
|
|
11044
|
-
const
|
|
11045
|
-
const
|
|
11893
|
+
const wasMessageArrived = useRef(false);
|
|
11894
|
+
const [knotTightenKey, setKnotTightenKey] = useState(0);
|
|
11046
11895
|
useEffect(() => {
|
|
11047
|
-
|
|
11048
|
-
|
|
11049
|
-
|
|
11050
|
-
lastScrollKey.current = scrollKey;
|
|
11051
|
-
if (shrank || typeof el?.scrollTo !== "function") return;
|
|
11052
|
-
following.current = true;
|
|
11053
|
-
el.scrollTo({
|
|
11054
|
-
top: el.scrollHeight,
|
|
11055
|
-
behavior: "smooth"
|
|
11056
|
-
});
|
|
11057
|
-
}, [scrollKey, state]);
|
|
11896
|
+
if (messageArrived && !wasMessageArrived.current) setKnotTightenKey((k) => k + 1);
|
|
11897
|
+
wasMessageArrived.current = messageArrived;
|
|
11898
|
+
}, [messageArrived]);
|
|
11058
11899
|
/**
|
|
11059
|
-
* Follow the reply as it STREAMS, not just as it starts
|
|
11060
|
-
*
|
|
11061
|
-
*
|
|
11062
|
-
*
|
|
11063
|
-
* token long. Everything after that arrives by SSE into the SAME turn: the
|
|
11064
|
-
* bubble grows downward under a scroll position that was correct when it
|
|
11065
|
-
* was pinned and is stale a word later. The visitor watched the TOP of a
|
|
11066
|
-
* long answer and had to scroll for every line of it — the newest text, the
|
|
11067
|
-
* only part they had not read, was the part off-screen.
|
|
11068
|
-
*
|
|
11069
|
-
* A `ResizeObserver` on the content is what closes that gap: it fires on
|
|
11070
|
-
* every layout change the growing text produces, at whatever rate the
|
|
11071
|
-
* tokens land, with no polling and no dependency on how the host chooses to
|
|
11072
|
-
* stream. `scrollKey` still owns the jump to a NEW turn; this owns staying
|
|
11073
|
-
* there while that turn fills in.
|
|
11074
|
-
*
|
|
11075
|
-
* Gated on `following` so it never fights the visitor. Scrolling up to
|
|
11076
|
-
* re-read an earlier answer while the agent is still typing is an ordinary
|
|
11077
|
-
* thing to do, and a transcript that yanks itself back down every 50ms
|
|
11078
|
-
* makes it impossible. `atBottom` uses a tolerance rather than an equality
|
|
11079
|
-
* — fractional scroll metrics on zoomed or hi-dpi displays never land
|
|
11080
|
-
* exactly, and smooth scrolling is still in flight when the next resize
|
|
11081
|
-
* arrives.
|
|
11082
|
-
*
|
|
11083
|
-
* `behavior: 'auto'`, unlike the jump above: a smooth scroll started every
|
|
11084
|
-
* time a token lands never finishes before the next one restarts it, which
|
|
11085
|
-
* reads as the transcript lagging behind its own text.
|
|
11900
|
+
* Follow the reply as it STREAMS, not just as it starts: `scrollKey` fires
|
|
11901
|
+
* once per turn, and the tokens after that grow the content box. The
|
|
11902
|
+
* viewport is watched too: the status line and the call row change its
|
|
11903
|
+
* height.
|
|
11086
11904
|
*/
|
|
11087
|
-
|
|
11088
|
-
const el = transcriptRef.current;
|
|
11089
|
-
if (!el || typeof el.scrollTo !== "function") return;
|
|
11090
|
-
if (typeof ResizeObserver === "undefined") return;
|
|
11091
|
-
const atBottom = () => el.scrollHeight - el.scrollTop - el.clientHeight <= FOLLOW_TOLERANCE_PX;
|
|
11092
|
-
let lastTop = el.scrollTop;
|
|
11093
|
-
const onScroll = () => {
|
|
11094
|
-
if (atBottom()) following.current = true;
|
|
11095
|
-
else if (el.scrollTop < lastTop) following.current = false;
|
|
11096
|
-
lastTop = el.scrollTop;
|
|
11097
|
-
};
|
|
11098
|
-
const observer = new ResizeObserver(() => {
|
|
11099
|
-
if (!following.current) return;
|
|
11100
|
-
el.scrollTo({
|
|
11101
|
-
top: el.scrollHeight,
|
|
11102
|
-
behavior: "auto"
|
|
11103
|
-
});
|
|
11104
|
-
});
|
|
11105
|
-
const content = transcriptContentRef.current;
|
|
11106
|
-
if (content) observer.observe(content);
|
|
11107
|
-
observer.observe(el);
|
|
11108
|
-
el.addEventListener("scroll", onScroll, { passive: true });
|
|
11109
|
-
return () => {
|
|
11110
|
-
observer.disconnect();
|
|
11111
|
-
el.removeEventListener("scroll", onScroll);
|
|
11112
|
-
};
|
|
11113
|
-
}, [open]);
|
|
11905
|
+
useFollowBottom(transcriptRef, transcriptContentRef, scrollKey, state);
|
|
11114
11906
|
const skipFocus = useRef(!focusOnOpen);
|
|
11115
11907
|
const handleClose = useCallback(() => {
|
|
11116
11908
|
onOpenChange(false);
|
|
11117
11909
|
window.setTimeout(() => {
|
|
11118
|
-
|
|
11910
|
+
byId(triggerId)?.focus({ preventScroll: true });
|
|
11119
11911
|
}, 400);
|
|
11120
11912
|
}, [onOpenChange, triggerId]);
|
|
11121
11913
|
useEffect(() => {
|
|
@@ -11133,15 +11925,16 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
11133
11925
|
if (focusable.length === 0) return;
|
|
11134
11926
|
const first = focusable[0];
|
|
11135
11927
|
const last = focusable[focusable.length - 1];
|
|
11136
|
-
|
|
11928
|
+
const active = panel.getRootNode().activeElement;
|
|
11929
|
+
if (e.shiftKey && active === first) {
|
|
11137
11930
|
e.preventDefault();
|
|
11138
11931
|
last.focus();
|
|
11139
|
-
} else if (!e.shiftKey &&
|
|
11932
|
+
} else if (!e.shiftKey && active === last) {
|
|
11140
11933
|
e.preventDefault();
|
|
11141
11934
|
first.focus();
|
|
11142
11935
|
}
|
|
11143
11936
|
};
|
|
11144
|
-
const focusTimer = skipFocus.current ? void 0 : window.setTimeout(() =>
|
|
11937
|
+
const focusTimer = skipFocus.current ? void 0 : window.setTimeout(() => byId(inputId)?.focus(), 120);
|
|
11145
11938
|
skipFocus.current = false;
|
|
11146
11939
|
window.addEventListener("keydown", onKeyDown);
|
|
11147
11940
|
return () => {
|
|
@@ -11153,52 +11946,23 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
11153
11946
|
handleClose,
|
|
11154
11947
|
inputId
|
|
11155
11948
|
]);
|
|
11156
|
-
/**
|
|
11157
|
-
* A call is running — anything but `idle`, including the phases that are not
|
|
11158
|
-
* speakable yet. The composer dims from the moment the caller commits to
|
|
11159
|
-
* voice, not only once the transport catches up.
|
|
11160
|
-
*/
|
|
11949
|
+
/** A call is running — anything but `idle`, including the phases not speakable yet. */
|
|
11161
11950
|
const inCall = voice !== void 0 && voice.phase !== "idle";
|
|
11162
|
-
/**
|
|
11163
|
-
* The voice-state pill's own state — `null` for `'idle'` (covered by
|
|
11164
|
-
* `inCall` too) AND `'blocked'` (NOT covered by `inCall`, which is why this
|
|
11165
|
-
* is its own value rather than reusing that boolean: a refused microphone
|
|
11166
|
-
* is still "a call", but it is not one of the four states the pill knows
|
|
11167
|
-
* how to draw — see `voiceStatePillState`'s own doc comment).
|
|
11168
|
-
*/
|
|
11951
|
+
/** `null` for `idle` and `blocked` — see `voiceStatePillState`. */
|
|
11169
11952
|
const voicePillState = voiceStatePillState(voice);
|
|
11170
|
-
/**
|
|
11171
|
-
* The call has been asked for and has not answered yet — the transport
|
|
11172
|
-
* dialing, or the browser's own microphone prompt still open in front of
|
|
11173
|
-
* the caller (the host folds both into this one phase; see
|
|
11174
|
-
* `useVoiceSession`'s `micPending` and `host-widget.tsx`'s `callPhase`).
|
|
11175
|
-
*
|
|
11176
|
-
* For as long as it lasts, the round control is a SPINNER and is inert. A
|
|
11177
|
-
* microphone glyph here says "talk now" during the one stretch where
|
|
11178
|
-
* talking provably does nothing, and a pressable one turns a single
|
|
11179
|
-
* impatient gesture into either a second call or a mute of a call that does
|
|
11180
|
-
* not exist yet. The wait ends by itself, in one of two directions: `live`
|
|
11181
|
-
* (the microphone comes back) or `blocked` (the existing refused
|
|
11182
|
-
* presentation) — never in a spinner nobody can clear.
|
|
11183
|
-
*/
|
|
11184
|
-
const connecting = voice?.phase === "connecting";
|
|
11185
11953
|
/** No voice leg to press at all, or a microphone the browser refused. */
|
|
11186
11954
|
const micUnusable = voice !== void 0 && (voice.disabled === true || voice.phase === "blocked");
|
|
11187
|
-
|
|
11188
|
-
|
|
11189
|
-
|
|
11190
|
-
|
|
11191
|
-
|
|
11192
|
-
|
|
11193
|
-
|
|
11194
|
-
|
|
11195
|
-
|
|
11196
|
-
|
|
11197
|
-
|
|
11198
|
-
* "Connecting" as the name of a button that will now never connect. See
|
|
11199
|
-
* `ConciergeShellVoice.labels.unavailable`.
|
|
11200
|
-
*/
|
|
11201
|
-
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 ?? "";
|
|
11955
|
+
const showEnd = inCall && voice.onEnd !== void 0;
|
|
11956
|
+
/** The call view's own controls, kept in reach while it is not shown. */
|
|
11957
|
+
const interrupting = inCall && voice.agentSpeaking === true && voice.onInterrupt !== void 0;
|
|
11958
|
+
const fixable = voice?.phase === "blocked" && voice.onFixPermission !== void 0;
|
|
11959
|
+
const closeButton = /* @__PURE__ */ jsx("button", {
|
|
11960
|
+
type: "button",
|
|
11961
|
+
className: "wgp-ib",
|
|
11962
|
+
"aria-label": labels.close,
|
|
11963
|
+
onClick: handleClose,
|
|
11964
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
11965
|
+
});
|
|
11202
11966
|
const counting = draft.length >= WIDGET_MESSAGE_COUNT_FROM;
|
|
11203
11967
|
const submit = (e) => {
|
|
11204
11968
|
e.preventDefault();
|
|
@@ -11222,268 +11986,260 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
11222
11986
|
hidden: open,
|
|
11223
11987
|
avatar,
|
|
11224
11988
|
...launcher !== void 0 ? { spec: launcher } : {},
|
|
11225
|
-
...launcherInitials !== void 0 ? { initials: launcherInitials } : {}
|
|
11989
|
+
...launcherInitials !== void 0 ? { initials: launcherInitials } : {},
|
|
11990
|
+
...launcherVariant !== void 0 ? { launcher: launcherVariant } : {},
|
|
11991
|
+
...agentName !== void 0 ? { agentName } : {},
|
|
11992
|
+
...callLabel !== void 0 ? {
|
|
11993
|
+
callLabel,
|
|
11994
|
+
callSrLabel: callMode.launcherSpoken
|
|
11995
|
+
} : {}
|
|
11226
11996
|
}),
|
|
11227
11997
|
/* @__PURE__ */ jsx("div", {
|
|
11228
11998
|
"aria-hidden": true,
|
|
11229
|
-
className: cn("
|
|
11999
|
+
className: cn("fixed inset-0 z-40 transition-opacity duration-300 max-sm:bg-black/25", open ? "pointer-events-auto opacity-100" : "pointer-events-none opacity-0")
|
|
11230
12000
|
}),
|
|
11231
12001
|
/* @__PURE__ */ jsx("div", {
|
|
11232
12002
|
"aria-hidden": !open,
|
|
11233
|
-
className: cn("pointer-events-none fixed inset-x-0 z-50 flex", panelClasses(position)),
|
|
11234
|
-
children: /* @__PURE__ */
|
|
11235
|
-
|
|
11236
|
-
|
|
12003
|
+
className: cn("wgp-row pointer-events-none fixed inset-x-0 z-50 flex", panelClasses(position)),
|
|
12004
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
12005
|
+
ref: panelRef,
|
|
12006
|
+
role: "dialog",
|
|
12007
|
+
"aria-modal": "true",
|
|
12008
|
+
"aria-label": labels.dialog,
|
|
12009
|
+
"data-testid": testIds?.panel,
|
|
12010
|
+
"data-open": open ? "" : void 0,
|
|
12011
|
+
className: cn("wgp origin-bottom", open ? "pointer-events-auto" : "pointer-events-none"),
|
|
12012
|
+
children: callMode.shown && call && voice ? /* @__PURE__ */ jsx(CallView, {
|
|
12013
|
+
...call,
|
|
12014
|
+
voice,
|
|
12015
|
+
...agentName !== void 0 ? { name: agentName } : {},
|
|
12016
|
+
checkout: callMode.record.checkout,
|
|
12017
|
+
actions: closeButton,
|
|
12018
|
+
record: callMode.record,
|
|
12019
|
+
bot: state,
|
|
12020
|
+
avatar,
|
|
12021
|
+
hint: badge,
|
|
12022
|
+
onText: () => {
|
|
12023
|
+
callMode.toText();
|
|
12024
|
+
focusInput();
|
|
12025
|
+
},
|
|
12026
|
+
onBackToChat: () => {
|
|
12027
|
+
callMode.closeSummary();
|
|
12028
|
+
focusInput();
|
|
12029
|
+
},
|
|
12030
|
+
testIds: {
|
|
12031
|
+
...testIds?.mic !== void 0 ? { mic: testIds.mic } : {},
|
|
12032
|
+
...testIds?.endCall !== void 0 ? { endCall: testIds.endCall } : {}
|
|
12033
|
+
}
|
|
12034
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11237
12035
|
/* @__PURE__ */ jsxs("div", {
|
|
11238
|
-
|
|
11239
|
-
role: "dialog",
|
|
11240
|
-
"aria-modal": "true",
|
|
11241
|
-
"aria-label": labels.dialog,
|
|
11242
|
-
"data-testid": testIds?.panel,
|
|
11243
|
-
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"),
|
|
11244
|
-
style: { transitionTimingFunction: "cubic-bezier(0.16, 1, 0.3, 1)" },
|
|
12036
|
+
className: "wgp-hd",
|
|
11245
12037
|
children: [
|
|
11246
|
-
/* @__PURE__ */ jsx("
|
|
11247
|
-
"
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11255
|
-
|
|
11256
|
-
|
|
11257
|
-
WebkitMaskComposite: "xor",
|
|
11258
|
-
maskComposite: "exclude"
|
|
11259
|
-
}
|
|
12038
|
+
/* @__PURE__ */ jsx("span", {
|
|
12039
|
+
className: "wgp-mk",
|
|
12040
|
+
children: /* @__PURE__ */ jsx(AvatarFace, {
|
|
12041
|
+
avatar,
|
|
12042
|
+
state,
|
|
12043
|
+
size: "sm",
|
|
12044
|
+
markSize: 34,
|
|
12045
|
+
messageArrived,
|
|
12046
|
+
tightenKey: knotTightenKey,
|
|
12047
|
+
...agentName !== void 0 ? { name: agentName } : {}
|
|
12048
|
+
})
|
|
11260
12049
|
}),
|
|
11261
|
-
/* @__PURE__ */
|
|
11262
|
-
|
|
11263
|
-
"
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
12050
|
+
/* @__PURE__ */ jsxs("div", {
|
|
12051
|
+
className: "wgp-hd-t",
|
|
12052
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
12053
|
+
className: "wgp-name",
|
|
12054
|
+
dir: "auto",
|
|
12055
|
+
children: labels.title ?? labels.dialog
|
|
12056
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
12057
|
+
className: "wgp-sub",
|
|
12058
|
+
children: [
|
|
12059
|
+
/* @__PURE__ */ jsx("span", {
|
|
12060
|
+
"data-testid": "widget-voice-state",
|
|
12061
|
+
className: cn("wgp-pill", voicePillState ? "opacity-100" : "opacity-0"),
|
|
12062
|
+
children: voicePillState ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
12063
|
+
"aria-hidden": true,
|
|
12064
|
+
"data-live": voicePillState === "speaking" || voicePillState === "listening" ? "" : void 0,
|
|
12065
|
+
className: cn(voicePillState !== "listening" && "animate-pulse motion-reduce:animate-none")
|
|
12066
|
+
}), /* @__PURE__ */ jsx("span", { children: voice?.labels[voicePillState] ?? defaultWidgetMessages[`voice_state_${voicePillState}`] })] }) : null
|
|
12067
|
+
}),
|
|
12068
|
+
operatorName === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
12069
|
+
"data-testid": "widget-operator-name",
|
|
12070
|
+
dir: "auto",
|
|
12071
|
+
children: operatorName
|
|
12072
|
+
}),
|
|
12073
|
+
badge
|
|
12074
|
+
]
|
|
12075
|
+
})]
|
|
11267
12076
|
}),
|
|
11268
12077
|
/* @__PURE__ */ jsxs("div", {
|
|
11269
|
-
className:
|
|
12078
|
+
className: "wgp-act",
|
|
12079
|
+
children: [voice && !inCall && !micUnusable ? /* @__PURE__ */ jsx("button", {
|
|
12080
|
+
type: "button",
|
|
12081
|
+
className: "wgp-ib",
|
|
12082
|
+
"data-testid": "widget-voice-cta",
|
|
12083
|
+
"aria-label": voice.labels.start,
|
|
12084
|
+
title: voice.labels.start,
|
|
12085
|
+
onClick: voice.onStart,
|
|
12086
|
+
children: /* @__PURE__ */ jsx(Mic, {})
|
|
12087
|
+
}) : null, closeButton]
|
|
12088
|
+
})
|
|
12089
|
+
]
|
|
12090
|
+
}),
|
|
12091
|
+
/* @__PURE__ */ jsx("div", {
|
|
12092
|
+
ref: transcriptRef,
|
|
12093
|
+
className: "wgp-msgs no-scrollbar",
|
|
12094
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
12095
|
+
ref: transcriptContentRef,
|
|
12096
|
+
children: [
|
|
12097
|
+
children,
|
|
12098
|
+
privacyChoices?.slot ? /* @__PURE__ */ jsx("div", {
|
|
12099
|
+
ref: privacyChoices.slot,
|
|
12100
|
+
className: "wgp-consent"
|
|
12101
|
+
}) : null,
|
|
12102
|
+
typing ? /* @__PURE__ */ jsxs("p", {
|
|
12103
|
+
"data-testid": "widget-typing-indicator",
|
|
12104
|
+
className: "wgp-typing",
|
|
12105
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
12106
|
+
className: "sr-only",
|
|
12107
|
+
children: defaultWidgetMessages.typing
|
|
12108
|
+
}), [
|
|
12109
|
+
0,
|
|
12110
|
+
1,
|
|
12111
|
+
2
|
|
12112
|
+
].map((i) => /* @__PURE__ */ jsx("span", {
|
|
12113
|
+
"aria-hidden": "true",
|
|
12114
|
+
style: {
|
|
12115
|
+
animationDelay: `${i * 150}ms`,
|
|
12116
|
+
animationDuration: "1.2s"
|
|
12117
|
+
}
|
|
12118
|
+
}, i))]
|
|
12119
|
+
}) : null
|
|
12120
|
+
]
|
|
12121
|
+
})
|
|
12122
|
+
}),
|
|
12123
|
+
/* @__PURE__ */ jsxs("form", {
|
|
12124
|
+
className: "wgp-cz",
|
|
12125
|
+
onSubmit: submit,
|
|
12126
|
+
children: [
|
|
12127
|
+
showEnd || interrupting || fixable || call !== void 0 && inCall ? /* @__PURE__ */ jsxs("div", {
|
|
12128
|
+
className: "wgp-call",
|
|
12129
|
+
children: [
|
|
12130
|
+
fixable ? /* @__PURE__ */ jsx("button", {
|
|
12131
|
+
type: "button",
|
|
12132
|
+
onClick: voice.onFixPermission,
|
|
12133
|
+
"data-testid": "widget-fix-permission",
|
|
12134
|
+
className: "wgp-fix",
|
|
12135
|
+
children: voice.labels.fixBrowser ?? defaultWidgetMessages.dock_fix_browser
|
|
12136
|
+
}) : null,
|
|
12137
|
+
interrupting ? /* @__PURE__ */ jsx("button", {
|
|
12138
|
+
type: "button",
|
|
12139
|
+
onClick: () => voice.onInterrupt?.("tap"),
|
|
12140
|
+
"data-testid": "widget-interrupt",
|
|
12141
|
+
"aria-label": voice.labels.interrupt ?? defaultWidgetMessages.dock_interrupt,
|
|
12142
|
+
className: "wgp-ib",
|
|
12143
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
12144
|
+
viewBox: "0 0 24 24",
|
|
12145
|
+
width: "20",
|
|
12146
|
+
height: "20",
|
|
12147
|
+
"aria-hidden": true,
|
|
12148
|
+
children: /* @__PURE__ */ jsx("rect", {
|
|
12149
|
+
x: "7",
|
|
12150
|
+
y: "7",
|
|
12151
|
+
width: "10",
|
|
12152
|
+
height: "10",
|
|
12153
|
+
rx: "2",
|
|
12154
|
+
fill: "currentColor"
|
|
12155
|
+
})
|
|
12156
|
+
})
|
|
12157
|
+
}) : null,
|
|
12158
|
+
call !== void 0 && inCall ? /* @__PURE__ */ jsx("button", {
|
|
12159
|
+
type: "button",
|
|
12160
|
+
onClick: callMode.backToCall,
|
|
12161
|
+
"data-testid": "widget-back-to-call",
|
|
12162
|
+
className: "wgp-fix",
|
|
12163
|
+
children: callText(call.messages, "call_back_to_call")
|
|
12164
|
+
}) : null,
|
|
12165
|
+
showEnd ? /* @__PURE__ */ jsx("button", {
|
|
12166
|
+
type: "button",
|
|
12167
|
+
onClick: voice.onEnd,
|
|
12168
|
+
"data-testid": testIds?.endCall,
|
|
12169
|
+
title: voice.labels.end ?? defaultWidgetMessages.call_end,
|
|
12170
|
+
"aria-label": voice.labels.end ?? defaultWidgetMessages.call_end,
|
|
12171
|
+
"data-end": "",
|
|
12172
|
+
className: "wgp-ib",
|
|
12173
|
+
children: /* @__PURE__ */ jsx(PhoneOff, {})
|
|
12174
|
+
}) : null
|
|
12175
|
+
]
|
|
12176
|
+
}) : null,
|
|
12177
|
+
counting ? /* @__PURE__ */ jsxs("span", {
|
|
12178
|
+
id: `${inputId}-count`,
|
|
12179
|
+
"data-testid": "widget-composer-count",
|
|
12180
|
+
className: "wgp-count",
|
|
12181
|
+
children: [
|
|
12182
|
+
draft.length,
|
|
12183
|
+
"/",
|
|
12184
|
+
WIDGET_MESSAGE_MAX_LENGTH
|
|
12185
|
+
]
|
|
12186
|
+
}) : null,
|
|
12187
|
+
/* @__PURE__ */ jsxs("div", {
|
|
12188
|
+
className: "wgp-field",
|
|
11270
12189
|
children: [
|
|
11271
|
-
|
|
11272
|
-
|
|
11273
|
-
|
|
12190
|
+
composerLeading,
|
|
12191
|
+
/* @__PURE__ */ jsx("label", {
|
|
12192
|
+
htmlFor: inputId,
|
|
12193
|
+
className: "sr-only",
|
|
12194
|
+
children: labels.composerPlaceholder
|
|
11274
12195
|
}),
|
|
11275
|
-
/* @__PURE__ */ jsx("
|
|
11276
|
-
|
|
11277
|
-
|
|
12196
|
+
/* @__PURE__ */ jsx("input", {
|
|
12197
|
+
id: inputId,
|
|
12198
|
+
"data-testid": testIds?.input,
|
|
12199
|
+
value: draft,
|
|
12200
|
+
onChange: (e) => onDraftChange(e.target.value),
|
|
12201
|
+
placeholder: labels.composerPlaceholder,
|
|
12202
|
+
dir: "auto",
|
|
12203
|
+
maxLength: WIDGET_MESSAGE_MAX_LENGTH,
|
|
12204
|
+
...counting ? { "aria-describedby": `${inputId}-count` } : {},
|
|
12205
|
+
disabled: composerDisabled,
|
|
12206
|
+
autoComplete: "off",
|
|
12207
|
+
className: cn("wgp-in", inCall && draft === "" && "opacity-60 focus:opacity-100")
|
|
11278
12208
|
}),
|
|
11279
|
-
/* @__PURE__ */
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
|
|
11292
|
-
size: "lg",
|
|
11293
|
-
messageArrived,
|
|
11294
|
-
tightenKey: knotTightenKey
|
|
11295
|
-
})]
|
|
11296
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
11297
|
-
"data-testid": "widget-voice-state",
|
|
11298
|
-
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 [&:lang(ar)]:tracking-normal [&:lang(hi)]:tracking-normal 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"),
|
|
11299
|
-
children: voicePillState ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
11300
|
-
"aria-hidden": true,
|
|
11301
|
-
className: cn("size-1.5 shrink-0 rounded-full", voicePillState !== "listening" && "animate-pulse motion-reduce:animate-none"),
|
|
11302
|
-
style: { backgroundColor: voiceStatePillDotColor(voicePillState) }
|
|
11303
|
-
}), /* @__PURE__ */ jsx("span", { children: voiceStatePillLabel(voicePillState, voice?.labels) })] }) : null
|
|
11304
|
-
})]
|
|
11305
|
-
}),
|
|
11306
|
-
badge == null && operatorName === void 0 ? null : /* @__PURE__ */ jsxs("div", {
|
|
11307
|
-
className: cn("z-10 w-[68%] shrink-0 text-center", voicePillState ? "mt-[124px]" : "mt-[104px]"),
|
|
11308
|
-
children: [operatorName === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
11309
|
-
"data-testid": "widget-operator-name",
|
|
11310
|
-
dir: "auto",
|
|
11311
|
-
className: "text-[11px] font-medium text-[var(--widget-foreground-muted)]",
|
|
11312
|
-
children: operatorName
|
|
11313
|
-
}), badge]
|
|
11314
|
-
}),
|
|
11315
|
-
/* @__PURE__ */ jsx("div", {
|
|
11316
|
-
ref: transcriptRef,
|
|
11317
|
-
className: "no-scrollbar w-full min-h-0 flex-1 overflow-y-auto",
|
|
11318
|
-
style: badge != null ? TRANSCRIPT_EDGE_FADE_WITH_BADGE : voicePillState ? TRANSCRIPT_EDGE_FADE_WITH_PILL : TRANSCRIPT_EDGE_FADE,
|
|
11319
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
11320
|
-
ref: transcriptContentRef,
|
|
11321
|
-
children: [
|
|
11322
|
-
children,
|
|
11323
|
-
privacyChoices?.slot ? /* @__PURE__ */ jsx("div", { ref: privacyChoices.slot }) : null,
|
|
11324
|
-
typing ? /* @__PURE__ */ jsxs("p", {
|
|
11325
|
-
"data-testid": "widget-typing-indicator",
|
|
11326
|
-
className: "flex items-center gap-1 px-1 py-1 text-[var(--widget-foreground-muted)]",
|
|
11327
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
11328
|
-
className: "sr-only",
|
|
11329
|
-
children: defaultWidgetMessages.typing
|
|
11330
|
-
}), [
|
|
11331
|
-
0,
|
|
11332
|
-
1,
|
|
11333
|
-
2
|
|
11334
|
-
].map((i) => /* @__PURE__ */ jsx("span", {
|
|
11335
|
-
"aria-hidden": "true",
|
|
11336
|
-
className: "h-1.5 w-1.5 animate-bounce rounded-full bg-current motion-reduce:animate-none",
|
|
11337
|
-
style: {
|
|
11338
|
-
animationDelay: `${i * 140}ms`,
|
|
11339
|
-
animationDuration: "1s"
|
|
11340
|
-
}
|
|
11341
|
-
}, i))]
|
|
11342
|
-
}) : null
|
|
11343
|
-
]
|
|
11344
|
-
})
|
|
11345
|
-
}),
|
|
11346
|
-
/* @__PURE__ */ jsx("div", {
|
|
11347
|
-
"aria-hidden": true,
|
|
11348
|
-
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))]",
|
|
11349
|
-
style: { height: COMPOSER_GROUND_LEN }
|
|
11350
|
-
}),
|
|
11351
|
-
/* @__PURE__ */ jsx("div", {
|
|
11352
|
-
className: "pointer-events-none absolute inset-x-0 z-20 flex justify-center",
|
|
11353
|
-
style: { bottom: voice ? COMPOSER_BOTTOM_LEN : COMPOSER_BOTTOM_NO_VOICE_LEN },
|
|
11354
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
11355
|
-
className: cn("flex w-[71%] flex-col items-center gap-2.5", open ? "pointer-events-auto" : "pointer-events-none"),
|
|
11356
|
-
style: { maxWidth: COMPOSER_MAX_WIDTH_LEN },
|
|
11357
|
-
children: [/* @__PURE__ */ jsxs("form", {
|
|
11358
|
-
className: "flex w-full items-center gap-2",
|
|
11359
|
-
onSubmit: submit,
|
|
11360
|
-
children: [composerLeading, /* @__PURE__ */ jsxs("div", {
|
|
11361
|
-
className: "relative flex-1",
|
|
11362
|
-
children: [
|
|
11363
|
-
/* @__PURE__ */ jsx("label", {
|
|
11364
|
-
htmlFor: inputId,
|
|
11365
|
-
className: "sr-only",
|
|
11366
|
-
children: labels.composerPlaceholder
|
|
11367
|
-
}),
|
|
11368
|
-
/* @__PURE__ */ jsx("input", {
|
|
11369
|
-
id: inputId,
|
|
11370
|
-
"data-testid": testIds?.input,
|
|
11371
|
-
value: draft,
|
|
11372
|
-
onChange: (e) => onDraftChange(e.target.value),
|
|
11373
|
-
placeholder: labels.composerPlaceholder,
|
|
11374
|
-
dir: "auto",
|
|
11375
|
-
maxLength: WIDGET_MESSAGE_MAX_LENGTH,
|
|
11376
|
-
...counting ? { "aria-describedby": `${inputId}-count` } : {},
|
|
11377
|
-
disabled: composerDisabled,
|
|
11378
|
-
className: cn("border-brand-plum/12 h-[40px] w-full rounded-3xl border bg-[var(--widget-chip)] ps-4 pe-12 text-[16px] [@media(min-width:640px)_and_(pointer:fine)]: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")
|
|
11379
|
-
}),
|
|
11380
|
-
counting ? /* @__PURE__ */ jsxs("span", {
|
|
11381
|
-
id: `${inputId}-count`,
|
|
11382
|
-
"data-testid": "widget-composer-count",
|
|
11383
|
-
className: "absolute end-4 -top-5 text-[11px] text-[var(--widget-foreground-muted)] tabular-nums",
|
|
11384
|
-
children: [
|
|
11385
|
-
draft.length,
|
|
11386
|
-
"/",
|
|
11387
|
-
WIDGET_MESSAGE_MAX_LENGTH
|
|
11388
|
-
]
|
|
11389
|
-
}) : null,
|
|
11390
|
-
draft.trim() && /* @__PURE__ */ jsx("button", {
|
|
11391
|
-
type: "submit",
|
|
11392
|
-
"aria-label": labels.send,
|
|
11393
|
-
"data-testid": testIds?.send,
|
|
11394
|
-
disabled: composerDisabled,
|
|
11395
|
-
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",
|
|
11396
|
-
children: /* @__PURE__ */ jsx(Send, { className: "size-4 rtl:-scale-x-100" })
|
|
11397
|
-
})
|
|
11398
|
-
]
|
|
11399
|
-
})]
|
|
11400
|
-
}), voice ? /* @__PURE__ */ jsxs("div", {
|
|
11401
|
-
className: "mt-1 flex items-center gap-3",
|
|
11402
|
-
children: [
|
|
11403
|
-
/* @__PURE__ */ jsx("button", {
|
|
11404
|
-
type: "button",
|
|
11405
|
-
onClick: connecting ? void 0 : inCall ? voice.onToggleMute ?? voice.onStart : voice.onStart,
|
|
11406
|
-
disabled: micUnusable || connecting,
|
|
11407
|
-
"data-testid": testIds?.mic,
|
|
11408
|
-
title: micLabel,
|
|
11409
|
-
"aria-label": micLabel,
|
|
11410
|
-
...connecting ? { "aria-busy": true } : {},
|
|
11411
|
-
...inCall && !connecting ? { "aria-pressed": voice.muted ?? false } : {},
|
|
11412
|
-
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"),
|
|
11413
|
-
children: connecting ? /* @__PURE__ */ jsx("span", {
|
|
11414
|
-
"aria-hidden": "true",
|
|
11415
|
-
"data-testid": "widget-mic-spinner",
|
|
11416
|
-
className: "flex items-center justify-center",
|
|
11417
|
-
children: /* @__PURE__ */ jsx(MorphingLoader, {
|
|
11418
|
-
size: "md",
|
|
11419
|
-
variant: "light",
|
|
11420
|
-
label: connectingLabel
|
|
11421
|
-
})
|
|
11422
|
-
}) : inCall && voice.muted === true ? /* @__PURE__ */ jsx(MicOff, { className: "size-5" }) : /* @__PURE__ */ jsx(Mic, { className: "size-5" })
|
|
11423
|
-
}),
|
|
11424
|
-
inCall && voice.agentSpeaking === true && voice.onInterrupt !== void 0 ? /* @__PURE__ */ jsx("button", {
|
|
11425
|
-
type: "button",
|
|
11426
|
-
onClick: () => voice.onInterrupt?.("tap"),
|
|
11427
|
-
"data-testid": "widget-interrupt",
|
|
11428
|
-
title: voice.labels.interrupt ?? "",
|
|
11429
|
-
"aria-label": voice.labels.interrupt ?? "",
|
|
11430
|
-
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"),
|
|
11431
|
-
children: /* @__PURE__ */ jsx(Square, { className: "size-4" })
|
|
11432
|
-
}) : null,
|
|
11433
|
-
voice.phase === "blocked" && voice.onFixPermission !== void 0 ? /* @__PURE__ */ jsx("button", {
|
|
11434
|
-
type: "button",
|
|
11435
|
-
onClick: voice.onFixPermission,
|
|
11436
|
-
"data-testid": "widget-fix-permission",
|
|
11437
|
-
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"),
|
|
11438
|
-
children: voice.labels.fixBrowser ?? defaultWidgetMessages.dock_fix_browser
|
|
11439
|
-
}) : null,
|
|
11440
|
-
inCall && voice.onEnd !== void 0 ? /* @__PURE__ */ jsx("button", {
|
|
11441
|
-
type: "button",
|
|
11442
|
-
onClick: voice.onEnd,
|
|
11443
|
-
"data-testid": testIds?.endCall,
|
|
11444
|
-
title: voice.labels.end ?? "",
|
|
11445
|
-
"aria-label": voice.labels.end ?? "",
|
|
11446
|
-
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"),
|
|
11447
|
-
children: /* @__PURE__ */ jsx(PhoneOff, { className: "size-4" })
|
|
11448
|
-
}) : null
|
|
11449
|
-
]
|
|
11450
|
-
}) : null]
|
|
11451
|
-
})
|
|
11452
|
-
})
|
|
11453
|
-
]
|
|
11454
|
-
})
|
|
12209
|
+
voice ? /* @__PURE__ */ jsx(MicButton, {
|
|
12210
|
+
voice,
|
|
12211
|
+
testId: testIds?.mic,
|
|
12212
|
+
className: "wgp-ib"
|
|
12213
|
+
}) : null,
|
|
12214
|
+
draft.trim() ? /* @__PURE__ */ jsx("button", {
|
|
12215
|
+
type: "submit",
|
|
12216
|
+
"aria-label": labels.send,
|
|
12217
|
+
"data-testid": testIds?.send,
|
|
12218
|
+
disabled: composerDisabled,
|
|
12219
|
+
className: "wgp-ib wgp-send",
|
|
12220
|
+
children: /* @__PURE__ */ jsx(Send, { className: "rtl:-scale-x-100" })
|
|
12221
|
+
}) : null
|
|
11455
12222
|
]
|
|
11456
|
-
})
|
|
12223
|
+
}),
|
|
12224
|
+
attribution || privacyChoices ? /* @__PURE__ */ jsxs("p", {
|
|
12225
|
+
className: "wgp-foot",
|
|
12226
|
+
children: [attribution ? /* @__PURE__ */ jsx("a", {
|
|
12227
|
+
href: attribution.href,
|
|
12228
|
+
target: "_blank",
|
|
12229
|
+
rel: "noopener noreferrer",
|
|
12230
|
+
"data-testid": "widget-branding",
|
|
12231
|
+
style: BRAND_BADGE_PLAIN,
|
|
12232
|
+
children: /* @__PURE__ */ jsx(BrandWordmark, { name: attribution.name })
|
|
12233
|
+
}) : null, privacyChoices ? /* @__PURE__ */ jsx("button", {
|
|
12234
|
+
type: "button",
|
|
12235
|
+
onClick: privacyChoices.open,
|
|
12236
|
+
"data-testid": "widget-privacy-choices",
|
|
12237
|
+
children: privacyChoices.label
|
|
12238
|
+
}) : null]
|
|
12239
|
+
}) : null
|
|
11457
12240
|
]
|
|
11458
|
-
})
|
|
11459
|
-
|
|
11460
|
-
href: attribution.href,
|
|
11461
|
-
target: "_blank",
|
|
11462
|
-
rel: "noopener noreferrer",
|
|
11463
|
-
"data-testid": "widget-branding",
|
|
11464
|
-
className: cn(BADGE_LINK, "left-1/2 inline-flex -translate-x-1/2 items-center whitespace-nowrap", open ? "pointer-events-auto opacity-100" : "pointer-events-none opacity-0"),
|
|
11465
|
-
style: BRAND_BADGE_PLAIN,
|
|
11466
|
-
children: /* @__PURE__ */ jsx(BrandWordmark, { name: attribution.name })
|
|
11467
|
-
}) : null,
|
|
11468
|
-
privacyChoices ? /* @__PURE__ */ jsx("button", {
|
|
11469
|
-
type: "button",
|
|
11470
|
-
onClick: privacyChoices.open,
|
|
11471
|
-
"data-testid": "widget-privacy-choices",
|
|
11472
|
-
className: cn(FOOTER_PILL, "end-0 text-[var(--widget-foreground)] underline", open ? "pointer-events-auto opacity-100" : "pointer-events-none opacity-0"),
|
|
11473
|
-
children: privacyChoices.label
|
|
11474
|
-
}) : null
|
|
11475
|
-
]
|
|
11476
|
-
})
|
|
11477
|
-
}),
|
|
11478
|
-
portalActive && /* @__PURE__ */ jsx("div", {
|
|
11479
|
-
"aria-hidden": true,
|
|
11480
|
-
className: cn("pointer-events-none fixed z-[55]", positionClasses(position)),
|
|
11481
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
11482
|
-
className: "widget-portal size-16",
|
|
11483
|
-
children: /* @__PURE__ */ jsx(MorphingLoader, {
|
|
11484
|
-
size: "full",
|
|
11485
|
-
label: labels.open
|
|
11486
|
-
})
|
|
12241
|
+
})
|
|
12242
|
+
] })
|
|
11487
12243
|
})
|
|
11488
12244
|
}),
|
|
11489
12245
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -11781,7 +12537,7 @@ function positionFor(dock) {
|
|
|
11781
12537
|
const align = dock?.layout?.desktopAlign;
|
|
11782
12538
|
return align === "left" || align === "right" ? `bottom-${align}` : DEFAULT_CONCIERGE_POSITION;
|
|
11783
12539
|
}
|
|
11784
|
-
function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndCall, statusKind, statusLine, escalated, operatorName, humanTyping, composing, replyStreaming, channel, draft, onDraftChange, submit, attaching, onAttach, attachInput, transcript, extras, messages, skinStyle, avatar, attribution, privacyChoices, voice: derivedVoice, dock }) {
|
|
12540
|
+
function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndCall, statusKind, statusLine, escalated, operatorName, humanTyping, composing, replyStreaming, channel, draft, onDraftChange, submit, attaching, onAttach, attachInput, transcript, extras, messages, skinStyle, avatar, attribution, privacyChoices, voice: derivedVoice, renderCards, suggestions, call: callHooks, cart, dock, locale }) {
|
|
11785
12541
|
const [restored] = useState(readOpen);
|
|
11786
12542
|
const [open, setOpen] = useState(dock?.initialMinimised === false || restored);
|
|
11787
12543
|
const onShown = dock?.onShown;
|
|
@@ -11796,6 +12552,7 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
11796
12552
|
const [position, setPosition] = useState(() => positionFor(dock));
|
|
11797
12553
|
const draggable = dock?.layout?.draggable !== false;
|
|
11798
12554
|
const launcherLabel = dock?.copy?.minimisedLabel?.trim();
|
|
12555
|
+
const agentName = dock?.identity?.name?.trim();
|
|
11799
12556
|
/**
|
|
11800
12557
|
* The host's voice bag, merged the same way `DockRenderer` merges it: the
|
|
11801
12558
|
* conversation derives the PHASE fields (`agentSpeaking`, `micOpen` …) and
|
|
@@ -11896,7 +12653,8 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
11896
12653
|
const handoffAt = turns.findLastIndex((t) => t.event === "handoff");
|
|
11897
12654
|
const promiseKept = view.status?.kind === "message" && view.status.key === "escalated_banner" && turns.slice(handoffAt + 1).some((t) => t.speaker === "agent" && t.text.trim() !== "");
|
|
11898
12655
|
const restatesPill = showMic && (callPhase === "connecting" || callPhase === "waiting" || callPhase === "live") && view.status?.kind === "message" && (view.status.key === "dock_listening" || view.status.key === "dock_thinking");
|
|
11899
|
-
const
|
|
12656
|
+
const restatesCaption = view.status?.kind === "text" && view.status.text === dock?.partialTranscript;
|
|
12657
|
+
const statusText = view.status === null || promiseKept || restatesPill || restatesCaption ? void 0 : view.status.kind === "text" ? view.status.text : messages[view.status.key] ?? void 0;
|
|
11900
12658
|
const voice = showMic ? {
|
|
11901
12659
|
phase: callPhase,
|
|
11902
12660
|
onStart: onToggleMic,
|
|
@@ -11943,18 +12701,23 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
11943
12701
|
})
|
|
11944
12702
|
})]
|
|
11945
12703
|
})] }) : null;
|
|
12704
|
+
const checkout = callHooks?.widgetEvents?.findLast((event) => event.type === "checkout");
|
|
12705
|
+
const published = dock?.identity?.avatar;
|
|
12706
|
+
const face = avatar ?? (isWidgetAvatar(published) ? published : void 0);
|
|
11946
12707
|
return /* @__PURE__ */ jsxs(ConciergeShell, {
|
|
11947
12708
|
open,
|
|
11948
12709
|
onOpenChange: setOpen,
|
|
11949
12710
|
...restored ? { focusOnOpen: false } : {},
|
|
11950
12711
|
state: view.avatar,
|
|
11951
12712
|
...skinStyle !== void 0 ? { skinStyle } : {},
|
|
11952
|
-
...
|
|
12713
|
+
...face !== void 0 ? { avatar: face } : {},
|
|
11953
12714
|
...attribution !== void 0 ? { attribution } : {},
|
|
11954
12715
|
...privacyChoices !== void 0 ? { privacyChoices } : {},
|
|
11955
12716
|
launcher: view.launcher,
|
|
11956
12717
|
...view.handoff && operatorName !== void 0 ? { operatorName } : {},
|
|
11957
12718
|
launcherInitials: view.launcher.initials ? handoffInitials(operatorName) : "",
|
|
12719
|
+
...dock?.layout?.launcher !== void 0 ? { launcherVariant: dock.layout.launcher } : {},
|
|
12720
|
+
...agentName ? { agentName } : {},
|
|
11958
12721
|
typing: view.typing,
|
|
11959
12722
|
messageArrived: lastTurn?.speaker === "caller",
|
|
11960
12723
|
idPrefix: "widget",
|
|
@@ -11969,12 +12732,25 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
11969
12732
|
open: messages.open,
|
|
11970
12733
|
close: messages.minimize,
|
|
11971
12734
|
dialog: messages.conversation,
|
|
12735
|
+
...agentName ? { title: agentName } : {},
|
|
11972
12736
|
composerPlaceholder: messages.type_placeholder,
|
|
11973
12737
|
send: messages.send,
|
|
11974
12738
|
move: messages.move,
|
|
11975
12739
|
...launcherLabel ? { launcher: launcherLabel } : {}
|
|
11976
12740
|
},
|
|
11977
12741
|
...voice !== void 0 ? { voice } : {},
|
|
12742
|
+
...voice !== void 0 ? { call: {
|
|
12743
|
+
state: view.state,
|
|
12744
|
+
callerSpeaking: voiceInput.callerSpeaking === true,
|
|
12745
|
+
turns,
|
|
12746
|
+
renderCards,
|
|
12747
|
+
suggestions,
|
|
12748
|
+
...callHooks?.sendText !== void 0 ? { onSay: callHooks.sendText } : {},
|
|
12749
|
+
...checkout !== void 0 ? { checkout } : {},
|
|
12750
|
+
...cart !== void 0 ? { cart: cart.lines } : {},
|
|
12751
|
+
messages,
|
|
12752
|
+
locale
|
|
12753
|
+
} } : {},
|
|
11978
12754
|
composerLeading,
|
|
11979
12755
|
badge: statusText === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
11980
12756
|
"data-testid": "widget-status",
|
|
@@ -11982,7 +12758,7 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
11982
12758
|
role: "status",
|
|
11983
12759
|
"aria-live": "polite"
|
|
11984
12760
|
} : {},
|
|
11985
|
-
className: "
|
|
12761
|
+
className: "m-0",
|
|
11986
12762
|
children: statusText
|
|
11987
12763
|
}),
|
|
11988
12764
|
testIds: {
|
|
@@ -12036,229 +12812,38 @@ function DockRenderer({ turns, lastTurn, operatorName, composing, onEndCall, voi
|
|
|
12036
12812
|
...navigate ? { navigate } : {},
|
|
12037
12813
|
draft,
|
|
12038
12814
|
onDraftChange,
|
|
12039
|
-
onSubmit: submit,
|
|
12040
|
-
revealSheet: showBasket && cart !== void 0 && cart.lines.length > 0 || attaching !== null || capturing,
|
|
12041
|
-
followKey: turns.reduce((n, turn) => n + 1 + turn.text.length + (turn.cards?.items.length ?? 0), 0) + (humanTyping ? 1 : 0),
|
|
12042
|
-
...onAttach ? { onAttach } : {},
|
|
12043
|
-
attachBusy: attaching !== null && !attaching.failed,
|
|
12044
|
-
...attachInput !== null ? { attachSlot: attachInput } : {},
|
|
12045
|
-
sheetExtra: extras,
|
|
12046
|
-
transcript,
|
|
12047
|
-
transcriptCount: turns.length,
|
|
12048
|
-
...lastTurn !== void 0 ? { lastTurn } : {},
|
|
12049
|
-
composing
|
|
12050
|
-
});
|
|
12051
|
-
}
|
|
12052
|
-
//#endregion
|
|
12053
|
-
//#region src/renderers.ts
|
|
12054
|
-
/**
|
|
12055
|
-
* The one module that names BOTH renderers — docs/CONCIERGE_GENERATIONS.md §3.
|
|
12056
|
-
*
|
|
12057
|
-
* `VoiceWidget` and `ConciergeWidget` (the npm components) resolve a missing
|
|
12058
|
-
* `renderer` here from `ui.generation`. The CDN entries never import this
|
|
12059
|
-
* file: `cdn/ui.ts` passes `DockRenderer` and `cdn/ui-widget.ts` passes
|
|
12060
|
-
* `ShellRenderer` to `ConciergeHost` directly, which is what keeps each chunk
|
|
12061
|
-
* to one renderer's code (rule 3 of §3: nothing under `widget/` is reachable
|
|
12062
|
-
* from `cdn/ui.ts`, and vice versa — the budget guard measures it).
|
|
12063
|
-
*
|
|
12064
|
-
* Absent ⇒ the dock. That is the npm components' compatibility default, not
|
|
12065
|
-
* the product's: the published config defaults to `widget`
|
|
12066
|
-
* (`widget-config-upcast.ts`), and `cdn/core.ts` reads it that way. A React
|
|
12067
|
-
* host that wants the widget says so.
|
|
12068
|
-
*/
|
|
12069
|
-
function rendererFor(generation) {
|
|
12070
|
-
return generation === "widget" ? ShellRenderer : DockRenderer;
|
|
12071
|
-
}
|
|
12072
|
-
//#endregion
|
|
12073
|
-
//#region src/widget-markdown.tsx
|
|
12074
|
-
/**
|
|
12075
|
-
* Only `http(s)` and `mailto` survive.
|
|
12076
|
-
*
|
|
12077
|
-
* A model can emit `[click here](javascript:…)` as easily as a real URL, and a
|
|
12078
|
-
* bare `href` would execute it on click. Anything else renders as plain text,
|
|
12079
|
-
* so a rejected link still shows its label rather than vanishing.
|
|
12080
|
-
*/
|
|
12081
|
-
function safeHref(raw) {
|
|
12082
|
-
const href = raw.trim();
|
|
12083
|
-
if (/^https?:\/\//i.test(href)) return href;
|
|
12084
|
-
if (/^mailto:[^\s]+@[^\s]+$/i.test(href)) return href;
|
|
12085
|
-
return null;
|
|
12086
|
-
}
|
|
12087
|
-
/**
|
|
12088
|
-
* The bidi embedding and isolate controls (U+202A-U+202E, U+2066-U+2069),
|
|
12089
|
-
* removed from what a bubble shows (SAA-436). A right-to-left override typed
|
|
12090
|
-
* into a message reverses the rest of it on screen ("exe.txt" spoofing); the
|
|
12091
|
-
* bubble's own `dir="auto"` and `unicode-bidi: isolate` already order real
|
|
12092
|
-
* mixed-direction text, so nothing legitimate needs them.
|
|
12093
|
-
*/
|
|
12094
|
-
function stripBidiControls(text) {
|
|
12095
|
-
return text.replace(/[\u202A-\u202E\u2066-\u2069]/g, "");
|
|
12096
|
-
}
|
|
12097
|
-
/**
|
|
12098
|
-
* Inline constructs, innermost-last.
|
|
12099
|
-
*
|
|
12100
|
-
* Code is matched FIRST and never recurses into its own body: `` `**not
|
|
12101
|
-
* bold**` `` is a literal in every Markdown dialect, and parsing emphasis
|
|
12102
|
-
* inside it is the classic way a renderer mangles a code sample.
|
|
12103
|
-
*/
|
|
12104
|
-
function parseInline(src) {
|
|
12105
|
-
const out = [];
|
|
12106
|
-
let rest = src;
|
|
12107
|
-
while (rest.length > 0) {
|
|
12108
|
-
const match = /`([^`]+)`|\*\*([\s\S]+?)\*\*|__([\s\S]+?)__|(?<!\*)\*(?!\s)([^*\n]+?)\*(?!\*)|(?<!_)_(?!\s)([^_\n]+?)_(?!_)|\[([^\]]*)\]\(([^)\s]+)\)|(https:\/\/[^\s<>"'`]*[^\s<>"'`.,;:!?)\]])/.exec(rest);
|
|
12109
|
-
if (!match || match.index === void 0) {
|
|
12110
|
-
out.push({
|
|
12111
|
-
kind: "text",
|
|
12112
|
-
text: rest
|
|
12113
|
-
});
|
|
12114
|
-
break;
|
|
12115
|
-
}
|
|
12116
|
-
if (match.index > 0) out.push({
|
|
12117
|
-
kind: "text",
|
|
12118
|
-
text: rest.slice(0, match.index)
|
|
12119
|
-
});
|
|
12120
|
-
const [full, code, boldStar, boldUnd, italStar, italUnd, linkText, linkHref, bare] = match;
|
|
12121
|
-
if (code !== void 0) out.push({
|
|
12122
|
-
kind: "code",
|
|
12123
|
-
text: code
|
|
12124
|
-
});
|
|
12125
|
-
else if (boldStar !== void 0 || boldUnd !== void 0) out.push({
|
|
12126
|
-
kind: "bold",
|
|
12127
|
-
children: parseInline(boldStar ?? boldUnd)
|
|
12128
|
-
});
|
|
12129
|
-
else if (italStar !== void 0 || italUnd !== void 0) out.push({
|
|
12130
|
-
kind: "italic",
|
|
12131
|
-
children: parseInline(italStar ?? italUnd)
|
|
12132
|
-
});
|
|
12133
|
-
else if (linkHref !== void 0) {
|
|
12134
|
-
const href = safeHref(linkHref);
|
|
12135
|
-
const children = parseInline(linkText ?? "").flatMap((n) => n.kind === "link" ? n.children : [n]);
|
|
12136
|
-
out.push(href ? {
|
|
12137
|
-
kind: "link",
|
|
12138
|
-
href,
|
|
12139
|
-
children
|
|
12140
|
-
} : {
|
|
12141
|
-
kind: "text",
|
|
12142
|
-
text: linkText ?? ""
|
|
12143
|
-
});
|
|
12144
|
-
} else if (bare !== void 0) out.push({
|
|
12145
|
-
kind: "link",
|
|
12146
|
-
href: bare,
|
|
12147
|
-
children: [{
|
|
12148
|
-
kind: "text",
|
|
12149
|
-
text: bare
|
|
12150
|
-
}]
|
|
12151
|
-
});
|
|
12152
|
-
rest = rest.slice(match.index + full.length);
|
|
12153
|
-
}
|
|
12154
|
-
return out.filter((n) => !(n.kind === "text" && n.text === ""));
|
|
12155
|
-
}
|
|
12156
|
-
function sameOrigin(href) {
|
|
12157
|
-
try {
|
|
12158
|
-
return new URL(href).origin === window.location.origin;
|
|
12159
|
-
} catch {
|
|
12160
|
-
return false;
|
|
12161
|
-
}
|
|
12162
|
-
}
|
|
12163
|
-
function renderInline(nodes, keyPrefix) {
|
|
12164
|
-
return nodes.map((node, i) => {
|
|
12165
|
-
const key = `${keyPrefix}-${i}`;
|
|
12166
|
-
switch (node.kind) {
|
|
12167
|
-
case "text": return /* @__PURE__ */ jsx(Fragment$1, { children: node.text }, key);
|
|
12168
|
-
case "bold": return /* @__PURE__ */ jsx("strong", { children: renderInline(node.children, key) }, key);
|
|
12169
|
-
case "italic": return /* @__PURE__ */ jsx("em", { children: renderInline(node.children, key) }, key);
|
|
12170
|
-
case "code": return /* @__PURE__ */ jsx("code", {
|
|
12171
|
-
className: "rounded bg-black/10 px-1 py-0.5 font-mono text-[0.85em]",
|
|
12172
|
-
children: node.text
|
|
12173
|
-
}, key);
|
|
12174
|
-
case "link": return /* @__PURE__ */ jsx("a", {
|
|
12175
|
-
href: node.href,
|
|
12176
|
-
...sameOrigin(node.href) ? {} : {
|
|
12177
|
-
target: "_blank",
|
|
12178
|
-
rel: "noopener noreferrer nofollow"
|
|
12179
|
-
},
|
|
12180
|
-
className: "underline underline-offset-2 [overflow-wrap:anywhere]",
|
|
12181
|
-
children: renderInline(node.children, key)
|
|
12182
|
-
}, key);
|
|
12183
|
-
}
|
|
12815
|
+
onSubmit: submit,
|
|
12816
|
+
revealSheet: showBasket && cart !== void 0 && cart.lines.length > 0 || attaching !== null || capturing,
|
|
12817
|
+
followKey: turns.reduce((n, turn) => n + 1 + turn.text.length + (turn.cards?.items.length ?? 0), 0) + (humanTyping ? 1 : 0),
|
|
12818
|
+
...onAttach ? { onAttach } : {},
|
|
12819
|
+
attachBusy: attaching !== null && !attaching.failed,
|
|
12820
|
+
...attachInput !== null ? { attachSlot: attachInput } : {},
|
|
12821
|
+
sheetExtra: extras,
|
|
12822
|
+
transcript,
|
|
12823
|
+
transcriptCount: turns.length,
|
|
12824
|
+
...lastTurn !== void 0 ? { lastTurn } : {},
|
|
12825
|
+
composing
|
|
12184
12826
|
});
|
|
12185
12827
|
}
|
|
12186
|
-
|
|
12187
|
-
|
|
12828
|
+
//#endregion
|
|
12829
|
+
//#region src/renderers.ts
|
|
12188
12830
|
/**
|
|
12189
|
-
*
|
|
12831
|
+
* The one module that names BOTH renderers — docs/CONCIERGE_GENERATIONS.md §3.
|
|
12190
12832
|
*
|
|
12191
|
-
*
|
|
12192
|
-
*
|
|
12193
|
-
*
|
|
12194
|
-
*
|
|
12195
|
-
|
|
12196
|
-
|
|
12197
|
-
const blocks = [];
|
|
12198
|
-
let paragraph = [];
|
|
12199
|
-
let list = null;
|
|
12200
|
-
const flushParagraph = () => {
|
|
12201
|
-
if (paragraph.length > 0) blocks.push({
|
|
12202
|
-
kind: "paragraph",
|
|
12203
|
-
lines: paragraph
|
|
12204
|
-
});
|
|
12205
|
-
paragraph = [];
|
|
12206
|
-
};
|
|
12207
|
-
const flushList = () => {
|
|
12208
|
-
if (list) blocks.push({
|
|
12209
|
-
kind: "list",
|
|
12210
|
-
ordered: list.ordered,
|
|
12211
|
-
items: list.items
|
|
12212
|
-
});
|
|
12213
|
-
list = null;
|
|
12214
|
-
};
|
|
12215
|
-
for (const line of markdown.split("\n")) {
|
|
12216
|
-
if (line.trim() === "") {
|
|
12217
|
-
flushParagraph();
|
|
12218
|
-
flushList();
|
|
12219
|
-
continue;
|
|
12220
|
-
}
|
|
12221
|
-
const bullet = BULLET.exec(line);
|
|
12222
|
-
const ordered = bullet ? null : ORDERED.exec(line);
|
|
12223
|
-
if (bullet ?? ordered) {
|
|
12224
|
-
flushParagraph();
|
|
12225
|
-
const isOrdered = ordered !== null;
|
|
12226
|
-
const text = (bullet?.[1] ?? ordered?.[1] ?? "").trim();
|
|
12227
|
-
if (list && list.ordered !== isOrdered) flushList();
|
|
12228
|
-
list ??= {
|
|
12229
|
-
ordered: isOrdered,
|
|
12230
|
-
items: []
|
|
12231
|
-
};
|
|
12232
|
-
list.items.push(text);
|
|
12233
|
-
continue;
|
|
12234
|
-
}
|
|
12235
|
-
flushList();
|
|
12236
|
-
paragraph.push(line.trim());
|
|
12237
|
-
}
|
|
12238
|
-
flushParagraph();
|
|
12239
|
-
flushList();
|
|
12240
|
-
return blocks;
|
|
12241
|
-
}
|
|
12242
|
-
/**
|
|
12243
|
-
* Renders one turn's text.
|
|
12833
|
+
* `VoiceWidget` and `ConciergeWidget` (the npm components) resolve a missing
|
|
12834
|
+
* `renderer` here from `ui.generation`. The CDN entries never import this
|
|
12835
|
+
* file: `cdn/ui.ts` passes `DockRenderer` and `cdn/ui-widget.ts` passes
|
|
12836
|
+
* `ShellRenderer` to `ConciergeHost` directly, which is what keeps each chunk
|
|
12837
|
+
* to one renderer's code (rule 3 of §3: nothing under `widget/` is reachable
|
|
12838
|
+
* from `cdn/ui.ts`, and vice versa — the budget guard measures it).
|
|
12244
12839
|
*
|
|
12245
|
-
*
|
|
12246
|
-
*
|
|
12247
|
-
* and
|
|
12248
|
-
*
|
|
12249
|
-
* briefly showing, and never a thrown parse error mid-stream.
|
|
12840
|
+
* Absent ⇒ the dock. That is the npm components' compatibility default, not
|
|
12841
|
+
* the product's: the published config defaults to `widget`
|
|
12842
|
+
* (`widget-config-upcast.ts`), and `cdn/core.ts` reads it that way. A React
|
|
12843
|
+
* host that wants the widget says so.
|
|
12250
12844
|
*/
|
|
12251
|
-
function
|
|
12252
|
-
return
|
|
12253
|
-
if (block.kind === "list") return /* @__PURE__ */ jsx(block.ordered ? "ol" : "ul", {
|
|
12254
|
-
className: `my-1 space-y-1 ps-4 ${block.ordered ? "list-decimal" : "list-disc"}`,
|
|
12255
|
-
children: block.items.map((item, j) => /* @__PURE__ */ jsx("li", { children: renderInline(parseInline(item), `b${i}-i${j}`) }, `b${i}-i${j}`))
|
|
12256
|
-
}, `b${i}`);
|
|
12257
|
-
return /* @__PURE__ */ jsx("p", {
|
|
12258
|
-
className: "[&:not(:first-child)]:mt-2",
|
|
12259
|
-
children: block.lines.map((line, j) => /* @__PURE__ */ jsxs(Fragment$1, { children: [j > 0 ? /* @__PURE__ */ jsx("br", {}) : null, renderInline(parseInline(line), `b${i}-l${j}`)] }, `b${i}-l${j}`))
|
|
12260
|
-
}, `b${i}`);
|
|
12261
|
-
});
|
|
12845
|
+
function rendererFor(generation) {
|
|
12846
|
+
return generation === "widget" ? ShellRenderer : DockRenderer;
|
|
12262
12847
|
}
|
|
12263
12848
|
//#endregion
|
|
12264
12849
|
//#region src/widget-cards.tsx
|
|
@@ -12315,7 +12900,7 @@ var INLINE_CARD_LIMIT = 4;
|
|
|
12315
12900
|
* branches, each still driving image sizing/shape and the wrapper's flex
|
|
12316
12901
|
* direction together — extended, not duplicated into a second component.
|
|
12317
12902
|
*/
|
|
12318
|
-
function CardBody({ item, href, roomy, locale, navigate, showPrice, imageAspect }) {
|
|
12903
|
+
function CardBody({ item, titleId, href, roomy, locale, navigate, showPrice, imageAspect }) {
|
|
12319
12904
|
const imageBox = {
|
|
12320
12905
|
"data-testid": "widget-card-image",
|
|
12321
12906
|
"data-aspect": imageAspect,
|
|
@@ -12323,7 +12908,7 @@ function CardBody({ item, href, roomy, locale, navigate, showPrice, imageAspect
|
|
|
12323
12908
|
};
|
|
12324
12909
|
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [item.imageUrl ? /* @__PURE__ */ jsx("img", {
|
|
12325
12910
|
src: item.imageUrl,
|
|
12326
|
-
alt:
|
|
12911
|
+
alt: "",
|
|
12327
12912
|
loading: "lazy",
|
|
12328
12913
|
decoding: "async",
|
|
12329
12914
|
className: roomy ? "h-[4.5rem] w-auto shrink-0 rounded-lg object-cover" : "h-auto w-full rounded-lg object-cover",
|
|
@@ -12336,6 +12921,7 @@ function CardBody({ item, href, roomy, locale, navigate, showPrice, imageAspect
|
|
|
12336
12921
|
className: "w-full min-w-0 flex-1",
|
|
12337
12922
|
children: [
|
|
12338
12923
|
/* @__PURE__ */ jsx("p", {
|
|
12924
|
+
id: titleId,
|
|
12339
12925
|
className: "truncate text-sm font-medium text-[var(--widget-foreground)]",
|
|
12340
12926
|
children: item.title
|
|
12341
12927
|
}),
|
|
@@ -12344,6 +12930,7 @@ function CardBody({ item, href, roomy, locale, navigate, showPrice, imageAspect
|
|
|
12344
12930
|
children: formatMoney(item.priceMinor, item.currency, locale)
|
|
12345
12931
|
}) : null,
|
|
12346
12932
|
item.reason ? /* @__PURE__ */ jsx("p", {
|
|
12933
|
+
"data-testid": "widget-card-reason",
|
|
12347
12934
|
className: "line-clamp-2 text-pretty text-xs text-[var(--widget-foreground-muted)] italic",
|
|
12348
12935
|
children: item.reason
|
|
12349
12936
|
}) : null
|
|
@@ -12382,7 +12969,7 @@ function CardBody({ item, href, roomy, locale, navigate, showPrice, imageAspect
|
|
|
12382
12969
|
* Changing quantity is the cart drawer's job, which is a surface that can show
|
|
12383
12970
|
* the quantity it is changing.
|
|
12384
12971
|
*/
|
|
12385
|
-
function AddToCartButton({ item, onAddToCart, messages, fullWidth = false }) {
|
|
12972
|
+
function AddToCartButton({ item, describedBy, onAddToCart, messages, fullWidth = false }) {
|
|
12386
12973
|
const [phase, setPhase] = useState("idle");
|
|
12387
12974
|
const mounted = useRef(true);
|
|
12388
12975
|
useEffect(() => {
|
|
@@ -12407,6 +12994,7 @@ function AddToCartButton({ item, onAddToCart, messages, fullWidth = false }) {
|
|
|
12407
12994
|
type: "button",
|
|
12408
12995
|
"data-testid": "widget-card-add-to-cart",
|
|
12409
12996
|
"data-phase": "unavailable",
|
|
12997
|
+
"aria-describedby": describedBy,
|
|
12410
12998
|
disabled: true,
|
|
12411
12999
|
className: `cursor-default rounded-full bg-black/5 px-3 py-1.5 text-xs font-medium text-[var(--widget-foreground-muted)] ${fullWidth ? "w-full text-center" : "shrink-0"}`,
|
|
12412
13000
|
children: messages.unavailable
|
|
@@ -12415,6 +13003,7 @@ function AddToCartButton({ item, onAddToCart, messages, fullWidth = false }) {
|
|
|
12415
13003
|
type: "button",
|
|
12416
13004
|
"data-testid": "widget-card-add-to-cart",
|
|
12417
13005
|
"data-phase": phase,
|
|
13006
|
+
"aria-describedby": describedBy,
|
|
12418
13007
|
disabled,
|
|
12419
13008
|
"aria-live": "polite",
|
|
12420
13009
|
onClick: () => void onClick(),
|
|
@@ -12507,42 +13096,63 @@ function ChooseOptionsButton({ item, onChooseOptions, messages, fullWidth = fals
|
|
|
12507
13096
|
* bigger canvas of its own page rather than an unbounded scroll.
|
|
12508
13097
|
*/
|
|
12509
13098
|
function WidgetCardList({ cards, onAddToCart, onChooseOptions, chooseOptionsBusy = false, curationHref, productHref, navigate, locale = "en", messages = defaultWidgetMessages, roomy = false, showPrice = true, imageAspect = DEFAULT_CARD_ASPECT }) {
|
|
12510
|
-
|
|
13099
|
+
const text = (key) => messages[key] ?? defaultWidgetMessages[key];
|
|
13100
|
+
const id = useId();
|
|
12511
13101
|
const visibleItems = cards.items.slice(0, INLINE_CARD_LIMIT);
|
|
13102
|
+
const { row, arrows } = useScrollRow(text("cards_prev"), text("cards_next"), visibleItems.length);
|
|
13103
|
+
if (cards.items.length === 0) return null;
|
|
12512
13104
|
const seeAllHref = cards.items.length - visibleItems.length > 0 && cards.curationId && curationHref ? curationHref(cards.curationId) : void 0;
|
|
12513
13105
|
return /* @__PURE__ */ jsxs("div", {
|
|
12514
13106
|
className: "mt-2 flex flex-col gap-2",
|
|
12515
|
-
children: [/* @__PURE__ */
|
|
12516
|
-
|
|
12517
|
-
|
|
12518
|
-
|
|
12519
|
-
|
|
12520
|
-
|
|
12521
|
-
|
|
12522
|
-
|
|
12523
|
-
|
|
12524
|
-
|
|
12525
|
-
|
|
12526
|
-
|
|
12527
|
-
|
|
12528
|
-
|
|
12529
|
-
|
|
12530
|
-
|
|
12531
|
-
|
|
12532
|
-
|
|
12533
|
-
|
|
12534
|
-
|
|
12535
|
-
|
|
12536
|
-
|
|
12537
|
-
|
|
12538
|
-
|
|
12539
|
-
|
|
12540
|
-
|
|
12541
|
-
|
|
12542
|
-
|
|
12543
|
-
|
|
12544
|
-
|
|
12545
|
-
|
|
13107
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
13108
|
+
className: "wsr",
|
|
13109
|
+
...roomy ? {} : {
|
|
13110
|
+
role: "group",
|
|
13111
|
+
"aria-roledescription": text("cards_carousel"),
|
|
13112
|
+
"aria-label": text("cards_label")
|
|
13113
|
+
},
|
|
13114
|
+
children: [/* @__PURE__ */ jsx("ul", {
|
|
13115
|
+
"data-testid": "widget-card-list",
|
|
13116
|
+
"data-layout": roomy ? "grid" : "carousel",
|
|
13117
|
+
...roomy ? {} : row,
|
|
13118
|
+
className: roomy ? "grid grid-cols-[repeat(auto-fit,minmax(15rem,1fr))] gap-2" : "card-carousel flex snap-x snap-mandatory gap-2 overflow-x-auto overscroll-x-contain",
|
|
13119
|
+
children: visibleItems.map((item, i) => {
|
|
13120
|
+
const href = item.handle && productHref ? productHref(item.handle) : void 0;
|
|
13121
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
13122
|
+
"data-testid": "widget-card",
|
|
13123
|
+
...roomy ? {} : {
|
|
13124
|
+
"aria-roledescription": text("cards_slide_role"),
|
|
13125
|
+
"aria-label": formatMessage(text("cards_slide"), {
|
|
13126
|
+
n: i + 1,
|
|
13127
|
+
total: visibleItems.length
|
|
13128
|
+
})
|
|
13129
|
+
},
|
|
13130
|
+
className: `flex flex-col items-start gap-3 rounded-xl border border-black/10 bg-[var(--widget-card)] p-2 ${roomy ? "" : "min-w-0 shrink-0 basis-[calc(100%/1.25)] max-w-[180px] snap-start"}`,
|
|
13131
|
+
children: [/* @__PURE__ */ jsx(CardBody, {
|
|
13132
|
+
item,
|
|
13133
|
+
titleId: `${id}-t${i}`,
|
|
13134
|
+
href,
|
|
13135
|
+
roomy,
|
|
13136
|
+
locale,
|
|
13137
|
+
navigate,
|
|
13138
|
+
showPrice,
|
|
13139
|
+
imageAspect
|
|
13140
|
+
}), item.variantChoiceRequired === true && item.available ? /* @__PURE__ */ jsx(ChooseOptionsButton, {
|
|
13141
|
+
item,
|
|
13142
|
+
onChooseOptions,
|
|
13143
|
+
messages,
|
|
13144
|
+
fullWidth: !roomy,
|
|
13145
|
+
busy: chooseOptionsBusy
|
|
13146
|
+
}) : /* @__PURE__ */ jsx(AddToCartButton, {
|
|
13147
|
+
item,
|
|
13148
|
+
describedBy: `${id}-t${i}`,
|
|
13149
|
+
onAddToCart,
|
|
13150
|
+
messages,
|
|
13151
|
+
fullWidth: !roomy
|
|
13152
|
+
})]
|
|
13153
|
+
}, `${item.productId}-${item.variantId ?? ""}`);
|
|
13154
|
+
})
|
|
13155
|
+
}), roomy ? null : arrows]
|
|
12546
13156
|
}), seeAllHref ? /* @__PURE__ */ jsx("a", {
|
|
12547
13157
|
href: seeAllHref,
|
|
12548
13158
|
"data-testid": "widget-card-see-all",
|
|
@@ -12607,7 +13217,7 @@ function WidgetCartSummary({ lines, subtotalMinor, currency, discountMinor, onCh
|
|
|
12607
13217
|
children: [
|
|
12608
13218
|
line.imageUrl ? /* @__PURE__ */ jsx("img", {
|
|
12609
13219
|
src: line.imageUrl,
|
|
12610
|
-
alt:
|
|
13220
|
+
alt: "",
|
|
12611
13221
|
className: "h-9 w-9 shrink-0 rounded-lg object-cover"
|
|
12612
13222
|
}) : /* @__PURE__ */ jsx("span", {
|
|
12613
13223
|
"aria-hidden": "true",
|
|
@@ -12659,151 +13269,45 @@ function WidgetCartSummary({ lines, subtotalMinor, currency, discountMinor, onCh
|
|
|
12659
13269
|
}
|
|
12660
13270
|
/**
|
|
12661
13271
|
* Checkout → spinner → gone.
|
|
12662
|
-
*
|
|
12663
|
-
* The spinner exists because building the permalink is a real server
|
|
12664
|
-
* round-trip. There is no third state: on success the shopper is already on
|
|
12665
|
-
* their way to Shopify, so the only thing left to render is the failure.
|
|
12666
|
-
*/
|
|
12667
|
-
function CheckoutButton({ onCheckout, navigate, messages }) {
|
|
12668
|
-
const [phase, setPhase] = useState("idle");
|
|
12669
|
-
const start = async () => {
|
|
12670
|
-
if (phase === "working") return;
|
|
12671
|
-
setPhase("working");
|
|
12672
|
-
const href = await onCheckout();
|
|
12673
|
-
if (href === false) {
|
|
12674
|
-
setPhase("idle");
|
|
12675
|
-
return;
|
|
12676
|
-
}
|
|
12677
|
-
if (href === null) {
|
|
12678
|
-
setPhase("failed");
|
|
12679
|
-
return;
|
|
12680
|
-
}
|
|
12681
|
-
(navigate ?? ((url) => window.location.assign(url)))(href);
|
|
12682
|
-
};
|
|
12683
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("button", {
|
|
12684
|
-
type: "button",
|
|
12685
|
-
"data-testid": "widget-checkout-button",
|
|
12686
|
-
"data-phase": phase,
|
|
12687
|
-
disabled: phase === "working",
|
|
12688
|
-
onClick: () => void start(),
|
|
12689
|
-
className: "mt-3 flex w-full cursor-pointer items-center justify-center gap-2 rounded-full bg-[var(--widget-accent)] px-4 py-2.5 text-sm font-semibold text-[var(--widget-accent-foreground)] transition-opacity disabled:cursor-default disabled:opacity-70",
|
|
12690
|
-
children: [phase === "working" ? /* @__PURE__ */ jsx("span", {
|
|
12691
|
-
"aria-hidden": "true",
|
|
12692
|
-
className: "h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent motion-reduce:animate-none"
|
|
12693
|
-
}) : null, messages.checkout_now]
|
|
12694
|
-
}), phase === "failed" ? /* @__PURE__ */ jsx("p", {
|
|
12695
|
-
role: "status",
|
|
12696
|
-
className: "mt-2 text-center text-xs text-[var(--widget-foreground-muted)]",
|
|
12697
|
-
children: messages.checkout_failed
|
|
12698
|
-
}) : null] });
|
|
12699
|
-
}
|
|
12700
|
-
//#endregion
|
|
12701
|
-
//#region ../widget-protocol/dist/text-direction.js
|
|
12702
|
-
/**
|
|
12703
|
-
* Base direction for a block of text whose language is the CONTENT's, not the
|
|
12704
|
-
* reader's. Pure, string-only and dependency-free: a STATIC import into the
|
|
12705
|
-
* chat bundle a shopper downloads, shared by the console (`apps/web`) and the
|
|
12706
|
-
* widget (`@saar-ai/web-widget`), which used to keep a hand copy each.
|
|
12707
|
-
*
|
|
12708
|
-
* It lives here rather than in `@wesence/i18n` because the widget's published
|
|
12709
|
-
* bundle may resolve no `@wesence/*` module at all (`docs/PACKAGE_DISTRIBUTION.md`,
|
|
12710
|
-
* enforced by `scripts/check-npm-bundle-provenance.mjs`), the same reason
|
|
12711
|
-
* `./money` lives here.
|
|
12712
|
-
*
|
|
12713
|
-
* ## Why the console's own direction is the wrong answer
|
|
12714
|
-
*
|
|
12715
|
-
* `<html dir>` is set from the operator's UI locale, and every element inherits
|
|
12716
|
-
* it. That is right for the chrome and wrong for a transcript: an
|
|
12717
|
-
* English-speaking agent reading an Arabic conversation would render each
|
|
12718
|
-
* message with an LTR base direction, and the Unicode bidirectional algorithm
|
|
12719
|
-
* would then lay out the runs in the wrong order and throw trailing punctuation
|
|
12720
|
-
* to the wrong end of the line.
|
|
12721
|
-
*
|
|
12722
|
-
* The failure is invisible to the person looking at it. An agent who cannot read
|
|
12723
|
-
* Arabic sees Arabic-looking text and moves on; the customer is the one who gets
|
|
12724
|
-
* quoted back a sentence that reads incorrectly. The reverse case is just as
|
|
12725
|
-
* real — an Arabic-speaking agent reading English conversations under an RTL
|
|
12726
|
-
* base.
|
|
12727
|
-
*
|
|
12728
|
-
* ## Mixed runs are the normal case here, not an edge case
|
|
12729
|
-
*
|
|
12730
|
-
* Verified against live recognition output: Arabic comes back as
|
|
12731
|
-
* `رقم الـ order هو 4471. Please check من فضلك.` and Hindi as
|
|
12732
|
-
* `मेरा order number 4471 है।`. Latin nouns inside a non-Latin sentence are what
|
|
12733
|
-
* this product's transcripts actually contain, so bidirectional layout is
|
|
12734
|
-
* exercised on ordinary traffic rather than by an unusual customer.
|
|
12735
|
-
*
|
|
12736
|
-
* ## `auto` is the floor, not the goal
|
|
12737
|
-
*
|
|
12738
|
-
* With a known language this returns a definite direction. Without one it
|
|
12739
|
-
* returns `auto`, which delegates to the browser's first-strong-character
|
|
12740
|
-
* heuristic — better than inheriting the chrome, but wrong for a message that
|
|
12741
|
-
* opens with an English word and continues in Arabic (`Please check من فضلك`).
|
|
12742
|
-
* The real fix is to persist the conversation's resolved locale and pass it in;
|
|
12743
|
-
* see the note in `Transcript`.
|
|
12744
|
-
*/
|
|
12745
|
-
/**
|
|
12746
|
-
* Languages written right-to-left. Keyed on the language subtag, so a region
|
|
12747
|
-
* never has to be enumerated.
|
|
12748
|
-
*
|
|
12749
|
-
* Beyond Arabic on purpose: Hebrew, Farsi, Urdu and Pashto are the scripts a CX
|
|
12750
|
-
* product in this region acquires next, and getting one wrong is the same silent
|
|
12751
|
-
* failure. Adding a language to the product must not also require remembering
|
|
12752
|
-
* this file.
|
|
12753
|
-
*/
|
|
12754
|
-
var RTL_LANGUAGES = /* @__PURE__ */ new Set([
|
|
12755
|
-
"ar",
|
|
12756
|
-
"he",
|
|
12757
|
-
"iw",
|
|
12758
|
-
"fa",
|
|
12759
|
-
"ur",
|
|
12760
|
-
"ps",
|
|
12761
|
-
"sd",
|
|
12762
|
-
"ug",
|
|
12763
|
-
"yi",
|
|
12764
|
-
"dv"
|
|
12765
|
-
]);
|
|
12766
|
-
/** Known LTR languages this product targets, so a typo does not silently pass. */
|
|
12767
|
-
var KNOWN_LTR_LANGUAGES = /* @__PURE__ */ new Set([
|
|
12768
|
-
"en",
|
|
12769
|
-
"hi",
|
|
12770
|
-
"es",
|
|
12771
|
-
"fr",
|
|
12772
|
-
"de",
|
|
12773
|
-
"pt",
|
|
12774
|
-
"it",
|
|
12775
|
-
"nl",
|
|
12776
|
-
"id",
|
|
12777
|
-
"ta",
|
|
12778
|
-
"te",
|
|
12779
|
-
"bn",
|
|
12780
|
-
"mr",
|
|
12781
|
-
"gu",
|
|
12782
|
-
"kn",
|
|
12783
|
-
"ml",
|
|
12784
|
-
"pa"
|
|
12785
|
-
]);
|
|
12786
|
-
/** A well-formed BCP-47-ish language subtag: two or three ASCII letters. */
|
|
12787
|
-
var LANGUAGE_SUBTAG = /^[a-z]{2,3}$/;
|
|
12788
|
-
/**
|
|
12789
|
-
* The base direction for text in `locale`.
|
|
12790
|
-
*
|
|
12791
|
-
* @param locale BCP-47 tag from stored conversation data — untyped by the time
|
|
12792
|
-
* it reaches here, so anything malformed resolves to `auto` rather than to a
|
|
12793
|
-
* guess.
|
|
12794
|
-
*/
|
|
12795
|
-
function textDirectionFor$1(locale) {
|
|
12796
|
-
if (locale === void 0 || locale === null || locale === "") return "auto";
|
|
12797
|
-
const language = locale.toLowerCase().split("-")[0] ?? "";
|
|
12798
|
-
if (!LANGUAGE_SUBTAG.test(language)) return "auto";
|
|
12799
|
-
if (RTL_LANGUAGES.has(language)) return "rtl";
|
|
12800
|
-
if (KNOWN_LTR_LANGUAGES.has(language)) return "ltr";
|
|
12801
|
-
return "auto";
|
|
13272
|
+
*
|
|
13273
|
+
* The spinner exists because building the permalink is a real server
|
|
13274
|
+
* round-trip. There is no third state: on success the shopper is already on
|
|
13275
|
+
* their way to Shopify, so the only thing left to render is the failure.
|
|
13276
|
+
*/
|
|
13277
|
+
function CheckoutButton({ onCheckout, navigate, messages }) {
|
|
13278
|
+
const [phase, setPhase] = useState("idle");
|
|
13279
|
+
const start = async () => {
|
|
13280
|
+
if (phase === "working") return;
|
|
13281
|
+
setPhase("working");
|
|
13282
|
+
const href = await onCheckout();
|
|
13283
|
+
if (href === false) {
|
|
13284
|
+
setPhase("idle");
|
|
13285
|
+
return;
|
|
13286
|
+
}
|
|
13287
|
+
if (href === null) {
|
|
13288
|
+
setPhase("failed");
|
|
13289
|
+
return;
|
|
13290
|
+
}
|
|
13291
|
+
(navigate ?? ((url) => window.location.assign(url)))(href);
|
|
13292
|
+
};
|
|
13293
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("button", {
|
|
13294
|
+
type: "button",
|
|
13295
|
+
"data-testid": "widget-checkout-button",
|
|
13296
|
+
"data-phase": phase,
|
|
13297
|
+
disabled: phase === "working",
|
|
13298
|
+
onClick: () => void start(),
|
|
13299
|
+
className: "mt-3 flex w-full cursor-pointer items-center justify-center gap-2 rounded-full bg-[var(--widget-accent)] px-4 py-2.5 text-sm font-semibold text-[var(--widget-accent-foreground)] transition-opacity disabled:cursor-default disabled:opacity-70",
|
|
13300
|
+
children: [phase === "working" ? /* @__PURE__ */ jsx("span", {
|
|
13301
|
+
"aria-hidden": "true",
|
|
13302
|
+
className: "h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent motion-reduce:animate-none"
|
|
13303
|
+
}) : null, messages.checkout_now]
|
|
13304
|
+
}), phase === "failed" ? /* @__PURE__ */ jsx("p", {
|
|
13305
|
+
role: "status",
|
|
13306
|
+
className: "mt-2 text-center text-xs text-[var(--widget-foreground-muted)]",
|
|
13307
|
+
children: messages.checkout_failed
|
|
13308
|
+
}) : null] });
|
|
12802
13309
|
}
|
|
12803
13310
|
//#endregion
|
|
12804
|
-
//#region src/text-direction.ts
|
|
12805
|
-
var textDirectionFor = textDirectionFor$1;
|
|
12806
|
-
//#endregion
|
|
12807
13311
|
//#region src/voice-widget.tsx
|
|
12808
13312
|
/**
|
|
12809
13313
|
* The "still composing" affordance, shown in the agent's own bubble from the
|
|
@@ -13115,7 +13619,7 @@ function VoiceWidget({ renderer, generation, ...props }) {
|
|
|
13115
13619
|
});
|
|
13116
13620
|
}
|
|
13117
13621
|
/** `VoiceWidget` with the renderer decided — the component the CDN entries and `ConciergeHost` use. */
|
|
13118
|
-
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, captureCard, messages = defaultWidgetMessages, suggestions, navigate, locale = "en", skinStyle, avatar, attribution, privacyChoices, dock }) {
|
|
13622
|
+
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, captureCard, messages = defaultWidgetMessages, suggestions, navigate, locale = "en", skinStyle, avatar, attribution, privacyChoices, call, dock }) {
|
|
13119
13623
|
const [draft, setDraft] = useState("");
|
|
13120
13624
|
const [sending, setSending] = useState(false);
|
|
13121
13625
|
/** Roomy mode — see the expand control in the header. Collapses back on close, so a reopened widget starts small. */
|
|
@@ -13209,6 +13713,21 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
|
|
|
13209
13713
|
* with two slices while §3.4 had a latest-exchange view (2026-09-11); since
|
|
13210
13714
|
* 2026-09-15 the visor always holds the whole log, so it renders one.
|
|
13211
13715
|
*/
|
|
13716
|
+
const renderCards = (cards) => /* @__PURE__ */ jsx(WidgetCardList, {
|
|
13717
|
+
cards,
|
|
13718
|
+
onAddToCart,
|
|
13719
|
+
onChooseOptions,
|
|
13720
|
+
chooseOptionsBusy,
|
|
13721
|
+
curationHref,
|
|
13722
|
+
productHref,
|
|
13723
|
+
navigate,
|
|
13724
|
+
locale,
|
|
13725
|
+
messages,
|
|
13726
|
+
roomy: false,
|
|
13727
|
+
...dock?.showPrice !== void 0 ? { showPrice: dock.showPrice } : {},
|
|
13728
|
+
...dock?.cardImageAspect !== void 0 ? { imageAspect: dock.cardImageAspect } : {}
|
|
13729
|
+
});
|
|
13730
|
+
const openers = suggestions ?? SUGGESTION_KEYS.map((key) => messages[key]);
|
|
13212
13731
|
const renderLog = (shown) => /* @__PURE__ */ jsxs("div", {
|
|
13213
13732
|
role: "log",
|
|
13214
13733
|
"aria-live": "polite",
|
|
@@ -13254,20 +13773,7 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
|
|
|
13254
13773
|
}) : null,
|
|
13255
13774
|
turn.cards && turn.cards.items.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
13256
13775
|
className: "w-full",
|
|
13257
|
-
children:
|
|
13258
|
-
cards: turn.cards,
|
|
13259
|
-
onAddToCart,
|
|
13260
|
-
onChooseOptions,
|
|
13261
|
-
chooseOptionsBusy,
|
|
13262
|
-
curationHref,
|
|
13263
|
-
productHref,
|
|
13264
|
-
navigate,
|
|
13265
|
-
locale,
|
|
13266
|
-
messages,
|
|
13267
|
-
roomy: false,
|
|
13268
|
-
...dock?.showPrice !== void 0 ? { showPrice: dock.showPrice } : {},
|
|
13269
|
-
...dock?.cardImageAspect !== void 0 ? { imageAspect: dock.cardImageAspect } : {}
|
|
13270
|
-
})
|
|
13776
|
+
children: renderCards(turn.cards)
|
|
13271
13777
|
}) : null,
|
|
13272
13778
|
turn.delivery !== void 0 ? /* @__PURE__ */ jsx(TurnDeliveryStatus, {
|
|
13273
13779
|
delivery: turn.delivery,
|
|
@@ -13288,7 +13794,7 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
|
|
|
13288
13794
|
"aria-label": messages.suggestions_label,
|
|
13289
13795
|
"data-testid": "widget-suggestions",
|
|
13290
13796
|
className: "flex flex-wrap gap-2 pt-1",
|
|
13291
|
-
children:
|
|
13797
|
+
children: openers.map((text) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
|
|
13292
13798
|
type: "button",
|
|
13293
13799
|
"data-testid": "widget-suggestion",
|
|
13294
13800
|
disabled: sending,
|
|
@@ -13437,6 +13943,9 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
|
|
|
13437
13943
|
onAttach,
|
|
13438
13944
|
attachInput,
|
|
13439
13945
|
transcript: renderLog(turns),
|
|
13946
|
+
renderCards,
|
|
13947
|
+
suggestions: openers,
|
|
13948
|
+
call,
|
|
13440
13949
|
extras,
|
|
13441
13950
|
messages,
|
|
13442
13951
|
locale,
|
|
@@ -16323,6 +16832,114 @@ async function streamReply(args) {
|
|
|
16323
16832
|
}
|
|
16324
16833
|
}
|
|
16325
16834
|
//#endregion
|
|
16835
|
+
//#region src/spoken-transcript.ts
|
|
16836
|
+
/** The caller's words while they are still speaking, if the newest caller line is provisional. */
|
|
16837
|
+
function liveCallerCaption(lines) {
|
|
16838
|
+
const line = lines.findLast((l) => l.speaker === "caller");
|
|
16839
|
+
return line?.final === false && line.text || void 0;
|
|
16840
|
+
}
|
|
16841
|
+
/** The words of `provisional` after the `settled` prefix the caller heard. */
|
|
16842
|
+
function droppedWords(settled, provisional) {
|
|
16843
|
+
return provisional.trim().slice(settled.trim().length).split(/\s+/u).filter(Boolean).length;
|
|
16844
|
+
}
|
|
16845
|
+
/**
|
|
16846
|
+
* The turns the worker reported as cut short, from `turn.latency` frames,
|
|
16847
|
+
* added to `ids` (a fresh set when omitted) so a caller can accumulate them.
|
|
16848
|
+
*/
|
|
16849
|
+
function interruptedTurnIds(turns, ids = /* @__PURE__ */ new Set()) {
|
|
16850
|
+
for (const turn of turns) if (turn.interruptedBy !== void 0) ids.add(turn.turnId);
|
|
16851
|
+
return ids;
|
|
16852
|
+
}
|
|
16853
|
+
/**
|
|
16854
|
+
* So little that a bubble is noise: up to three words and under 24 characters.
|
|
16855
|
+
* A single "word" (a script written without spaces) must also be under
|
|
16856
|
+
* {@link NEGLIGIBLE_UNSPACED_MAX_CHARS}, or a cut-off sentence in Chinese or
|
|
16857
|
+
* Thai would count as one word.
|
|
16858
|
+
*/
|
|
16859
|
+
function isNegligibleText(raw) {
|
|
16860
|
+
const text = raw.trim();
|
|
16861
|
+
const words = text.split(/\s+/u).length;
|
|
16862
|
+
const cap = words > 1 ? 24 : 8;
|
|
16863
|
+
return words <= 3 && text.length < cap;
|
|
16864
|
+
}
|
|
16865
|
+
/**
|
|
16866
|
+
* Which settled agent lines were cut off by the caller. A line counts as cut
|
|
16867
|
+
* off when the hook saw it truncated, or when the worker reported its turn
|
|
16868
|
+
* interrupted and it is that turn's LAST agent line (`interruptedBy` covers
|
|
16869
|
+
* the turn; earlier lines of it finished). Fillers are never replies.
|
|
16870
|
+
*/
|
|
16871
|
+
function cutLineIndexes(lines, interrupted) {
|
|
16872
|
+
const cut = /* @__PURE__ */ new Set();
|
|
16873
|
+
const seen = /* @__PURE__ */ new Set();
|
|
16874
|
+
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
16875
|
+
const line = lines[i];
|
|
16876
|
+
if (line.speaker !== "agent" || !line.final || line.filler) continue;
|
|
16877
|
+
const last = !seen.has(line.turnId);
|
|
16878
|
+
seen.add(line.turnId);
|
|
16879
|
+
if (line.truncated || last && interrupted.has(line.turnId)) cut.add(i);
|
|
16880
|
+
}
|
|
16881
|
+
return cut;
|
|
16882
|
+
}
|
|
16883
|
+
/** The cut-off lines ({@link cutLineIndexes}) that draw the "Interrupted" tag. */
|
|
16884
|
+
function taggedCutIndexes(lines, cut, interrupted) {
|
|
16885
|
+
return new Set([...cut].filter((i) => {
|
|
16886
|
+
const line = lines[i];
|
|
16887
|
+
return interrupted.has(line.turnId) || (line.dropped ?? 0) >= 3;
|
|
16888
|
+
}));
|
|
16889
|
+
}
|
|
16890
|
+
/** The cut-off lines ({@link cutLineIndexes}) with so little spoken that they draw nothing. */
|
|
16891
|
+
function negligibleLineIndexes(lines, cut) {
|
|
16892
|
+
return new Set([...cut].filter((i) => isNegligibleText(lines[i].text)));
|
|
16893
|
+
}
|
|
16894
|
+
/**
|
|
16895
|
+
* Which typed turns are the server's copy of a line the call is drawing live.
|
|
16896
|
+
*
|
|
16897
|
+
* Only turns the poll delivered (they carry `seq`) can be copies; a turn the
|
|
16898
|
+
* shopper typed is never hidden. A copy reaches the screen AFTER the line it
|
|
16899
|
+
* copies (the server stores a line once it is spoken, and the poll fetches it
|
|
16900
|
+
* later), so a live line only absorbs a copy stamped after it. That keeps a new
|
|
16901
|
+
* call's greeting from hiding the previous call's identical one. Each live line
|
|
16902
|
+
* absorbs at most one copy, so a caller who said "yes" twice keeps both answers
|
|
16903
|
+
* if the poll only has one of them.
|
|
16904
|
+
*
|
|
16905
|
+
* When a new call starts, `useVoiceSession` clears its transcript, the live
|
|
16906
|
+
* lines are gone, and the server's copies draw instead. That is how the
|
|
16907
|
+
* previous call stays on screen.
|
|
16908
|
+
*
|
|
16909
|
+
* @param typedStamps, spokenStamps `TurnOrderClock` stamps, index for index
|
|
16910
|
+
*/
|
|
16911
|
+
function echoedTurnIndexes(typed, typedStamps, spoken, spokenStamps) {
|
|
16912
|
+
const key = (line) => `${line.speaker}\u0000${line.text.trim().replace(/\s+/gu, " ")}`;
|
|
16913
|
+
const live = [];
|
|
16914
|
+
spoken.forEach((line, i) => {
|
|
16915
|
+
if (line.final) live.push([key(line), spokenStamps[i]]);
|
|
16916
|
+
});
|
|
16917
|
+
const echoed = /* @__PURE__ */ new Set();
|
|
16918
|
+
typed.forEach((turn, i) => {
|
|
16919
|
+
if (turn.seq === void 0 || turn.speaker === "event") return;
|
|
16920
|
+
const k = key(turn);
|
|
16921
|
+
const at = live.findIndex(([lk, stamp]) => lk === k && stamp < typedStamps[i]);
|
|
16922
|
+
if (at < 0) return;
|
|
16923
|
+
live.splice(at, 1);
|
|
16924
|
+
echoed.add(i);
|
|
16925
|
+
});
|
|
16926
|
+
return echoed;
|
|
16927
|
+
}
|
|
16928
|
+
/**
|
|
16929
|
+
* Where the "Call started" divider goes: just before the call's first line,
|
|
16930
|
+
* when something is already on screen above it. `null` means no divider.
|
|
16931
|
+
*
|
|
16932
|
+
* Stamps are integers from `TurnOrderClock`, so half a step before the first
|
|
16933
|
+
* line sorts the divider between it and the row above it.
|
|
16934
|
+
*
|
|
16935
|
+
* @param spoken this call's rows, @param others every other row on screen
|
|
16936
|
+
*/
|
|
16937
|
+
function callStartStamp(spoken, others) {
|
|
16938
|
+
if (spoken.length === 0) return null;
|
|
16939
|
+
const first = Math.min(...spoken.map((row) => row.stamp));
|
|
16940
|
+
return others.some((row) => row.stamp < first) ? first - .5 : null;
|
|
16941
|
+
}
|
|
16942
|
+
//#endregion
|
|
16326
16943
|
//#region src/use-voice-session.ts
|
|
16327
16944
|
/**
|
|
16328
16945
|
* Loads the call's wire-protocol codec and validation schema — see the module
|
|
@@ -16334,7 +16951,7 @@ async function streamReply(args) {
|
|
|
16334
16951
|
* cache makes a second `start()` after `stop()` free).
|
|
16335
16952
|
*/
|
|
16336
16953
|
async function loadVoiceProtocol() {
|
|
16337
|
-
const [telemetry, chat] = await Promise.all([import("./telemetry-ZeV7hBI7.js"), import("./chat-
|
|
16954
|
+
const [telemetry, chat] = await Promise.all([import("./telemetry-ZeV7hBI7.js"), import("./chat-Bm4MPdY9.js")]);
|
|
16338
16955
|
return {
|
|
16339
16956
|
decodeTelemetry: telemetry.decodeTelemetry,
|
|
16340
16957
|
encodeCallerText: telemetry.encodeCallerText,
|
|
@@ -16479,13 +17096,15 @@ function isCutShort(settled, provisional) {
|
|
|
16479
17096
|
function coalesceTranscript(lines, line) {
|
|
16480
17097
|
const at = lines.findLastIndex((existing) => existing.speaker === line.speaker);
|
|
16481
17098
|
const open = at >= 0 ? lines[at] : void 0;
|
|
17099
|
+
if (line.speaker === "caller" && !line.final && line.text === "") return open?.final === false ? lines.filter((l) => l !== open) : lines;
|
|
16482
17100
|
if (open === void 0 || open.final) return [...lines, line].slice(-50);
|
|
16483
17101
|
const revised = line.speaker === "agent" && !line.final && line.cumulative !== true ? {
|
|
16484
17102
|
...line,
|
|
16485
17103
|
text: open.text.length >= MAX_AGENT_LINE_CHARS ? open.text : joinClauses(open.text, line.text)
|
|
16486
17104
|
} : line.speaker === "agent" && line.final && isCutShort(line.text, open.text) ? {
|
|
16487
17105
|
...line,
|
|
16488
|
-
truncated: true
|
|
17106
|
+
truncated: true,
|
|
17107
|
+
dropped: droppedWords(line.text, open.text)
|
|
16489
17108
|
} : line;
|
|
16490
17109
|
return [
|
|
16491
17110
|
...lines.slice(0, at),
|
|
@@ -17127,6 +17746,151 @@ function useVoiceSession(options = {}) {
|
|
|
17127
17746
|
};
|
|
17128
17747
|
}
|
|
17129
17748
|
//#endregion
|
|
17749
|
+
//#region src/theme/widget-derive.ts
|
|
17750
|
+
/**
|
|
17751
|
+
* The widget generation's extra `--wgt-*` tokens (docs/DOCK_SPEC.md §9.2),
|
|
17752
|
+
* derived on top of the dock's eighteen. Separate from `derive.ts` so the dock
|
|
17753
|
+
* chunk does not carry tokens it never reads (bundle budget).
|
|
17754
|
+
*/
|
|
17755
|
+
var WIDGET_GEN_EXTRA_TOKENS = [
|
|
17756
|
+
"--wgt-panel-radius",
|
|
17757
|
+
"--wgt-card-lg-radius",
|
|
17758
|
+
"--wgt-btn-radius",
|
|
17759
|
+
"--wgt-chip-radius",
|
|
17760
|
+
"--wgt-bubble-radius",
|
|
17761
|
+
"--wgt-bubble-tail-radius",
|
|
17762
|
+
"--wgt-launcher-radius",
|
|
17763
|
+
"--wgt-text-2",
|
|
17764
|
+
"--wgt-surface-3",
|
|
17765
|
+
"--wgt-panel-surface",
|
|
17766
|
+
"--wgt-panel-filter",
|
|
17767
|
+
"--wgt-elevation",
|
|
17768
|
+
"--wgt-card-elevation",
|
|
17769
|
+
"--wgt-accent-ink",
|
|
17770
|
+
"--wgt-live"
|
|
17771
|
+
];
|
|
17772
|
+
/** Every token the widget generation reads: the dock's, then the extras. */
|
|
17773
|
+
var WIDGET_GEN_TOKENS = [...WIDGET_THEME_TOKENS, ...WIDGET_GEN_EXTRA_TOKENS];
|
|
17774
|
+
/**
|
|
17775
|
+
* px per `type.radius`, in the order of the radius tokens above: panel, card,
|
|
17776
|
+
* button, chip, bubble, bubble tail, launcher. `999` is "fully round", a
|
|
17777
|
+
* length the browser clamps to half the box.
|
|
17778
|
+
*/
|
|
17779
|
+
var RADII = {
|
|
17780
|
+
square: [
|
|
17781
|
+
4,
|
|
17782
|
+
2,
|
|
17783
|
+
2,
|
|
17784
|
+
2,
|
|
17785
|
+
2,
|
|
17786
|
+
2,
|
|
17787
|
+
4
|
|
17788
|
+
],
|
|
17789
|
+
soft: [
|
|
17790
|
+
16,
|
|
17791
|
+
12,
|
|
17792
|
+
10,
|
|
17793
|
+
10,
|
|
17794
|
+
16,
|
|
17795
|
+
4,
|
|
17796
|
+
14
|
|
17797
|
+
],
|
|
17798
|
+
round: [
|
|
17799
|
+
24,
|
|
17800
|
+
18,
|
|
17801
|
+
999,
|
|
17802
|
+
999,
|
|
17803
|
+
20,
|
|
17804
|
+
6,
|
|
17805
|
+
999
|
|
17806
|
+
],
|
|
17807
|
+
pill: [
|
|
17808
|
+
28,
|
|
17809
|
+
20,
|
|
17810
|
+
999,
|
|
17811
|
+
999,
|
|
17812
|
+
20,
|
|
17813
|
+
6,
|
|
17814
|
+
999
|
|
17815
|
+
]
|
|
17816
|
+
};
|
|
17817
|
+
/** Secondary text sits this far from the text toward the surface, before the readability walk. */
|
|
17818
|
+
var TEXT_2_MIX = .2;
|
|
17819
|
+
/** The quiet fill is one step deeper than `--wgt-surface-2` (6 %). */
|
|
17820
|
+
var SURFACE_3_MIX = .1;
|
|
17821
|
+
/** `color.glass`: the panel's surface alpha; `widget-derive.test.ts` measures text over black and white pages. */
|
|
17822
|
+
var PANEL_GLASS_ALPHA = .8;
|
|
17823
|
+
var PANEL_GLASS_FILTER = "blur(24px) saturate(1.6)";
|
|
17824
|
+
/** [panel, card] shadows for a light surface, then for a dark one. */
|
|
17825
|
+
var ELEVATION = [["0 0 0 1px rgb(0 0 0 / 0.06), 0 24px 60px -22px rgb(0 0 0 / 0.32)", "0 0 0 1px rgb(0 0 0 / 0.06), 0 8px 20px -16px rgb(0 0 0 / 0.35)"], ["0 0 0 1px rgb(255 255 255 / 0.08), 0 30px 80px -20px rgb(0 0 0 / 0.75)", "0 0 0 1px rgb(255 255 255 / 0.08)"]];
|
|
17826
|
+
/** Secondary text: walked back toward the text until it clears the 4.5:1 floor. */
|
|
17827
|
+
function deriveText2(text, surface) {
|
|
17828
|
+
for (let t = TEXT_2_MIX; t > 0; t = Number((t - .05).toFixed(2))) {
|
|
17829
|
+
const candidate = mixToward(text, surface, t);
|
|
17830
|
+
if (contrastRatio(candidate, surface) >= 4.5) return candidate;
|
|
17831
|
+
}
|
|
17832
|
+
return text;
|
|
17833
|
+
}
|
|
17834
|
+
function extend(base, type, glass) {
|
|
17835
|
+
const surface = base["--wgt-surface"];
|
|
17836
|
+
const text = base["--wgt-text"];
|
|
17837
|
+
const values = [
|
|
17838
|
+
...RADII[type.radius].map((n) => `${n}px`),
|
|
17839
|
+
deriveText2(text, surface),
|
|
17840
|
+
mixToward(surface, text, SURFACE_3_MIX),
|
|
17841
|
+
glass ? withAlpha(surface, PANEL_GLASS_ALPHA) : surface,
|
|
17842
|
+
glass ? PANEL_GLASS_FILTER : "none",
|
|
17843
|
+
...ELEVATION[hexToOklch(surface).L >= .5 ? 0 : 1],
|
|
17844
|
+
deriveRing(base["--wgt-primary"], surface, TEXT_CONTRAST_MIN),
|
|
17845
|
+
LIVE_COLOR
|
|
17846
|
+
];
|
|
17847
|
+
const out = { ...base };
|
|
17848
|
+
WIDGET_GEN_EXTRA_TOKENS.forEach((token, i) => out[token] = values[i]);
|
|
17849
|
+
return out;
|
|
17850
|
+
}
|
|
17851
|
+
/**
|
|
17852
|
+
* Every `--wgt-*` token the widget generation reads, from the published
|
|
17853
|
+
* `color` + `type` groups: {@link deriveTheme}'s eighteen plus the extras,
|
|
17854
|
+
* per block, with the same tone rules. Pure, and throws on the same inputs.
|
|
17855
|
+
*/
|
|
17856
|
+
function deriveWidgetTheme(color, type) {
|
|
17857
|
+
const base = deriveTheme(color, type);
|
|
17858
|
+
const glass = color.glass === true;
|
|
17859
|
+
return {
|
|
17860
|
+
light: extend(base.light, type, glass),
|
|
17861
|
+
...base.dark ? { dark: extend(base.dark, type, glass) } : {}
|
|
17862
|
+
};
|
|
17863
|
+
}
|
|
17864
|
+
//#endregion
|
|
17865
|
+
//#region src/theme/widget-theme-scope.tsx
|
|
17866
|
+
var DEFAULT_COLOR = {
|
|
17867
|
+
primary: "#111827",
|
|
17868
|
+
tone: "light"
|
|
17869
|
+
};
|
|
17870
|
+
var DEFAULT_TYPE = {
|
|
17871
|
+
font: "inherit",
|
|
17872
|
+
radius: "round",
|
|
17873
|
+
caps: "none"
|
|
17874
|
+
};
|
|
17875
|
+
/**
|
|
17876
|
+
* Puts the tenant's `--wgt-*` tokens (docs/DOCK_SPEC.md §9.2) on the widget
|
|
17877
|
+
* generation for every mount without a `core` stage (docs/CONCIERGE_GENERATIONS.md
|
|
17878
|
+
* §3.4). A scoped stylesheet rather than inline style so `tone: 'auto'` can carry
|
|
17879
|
+
* its `prefers-color-scheme` query. Every value comes out of `deriveWidgetTheme`.
|
|
17880
|
+
*/
|
|
17881
|
+
function WidgetThemeScope({ color = DEFAULT_COLOR, type = DEFAULT_TYPE, children }) {
|
|
17882
|
+
const id = useId();
|
|
17883
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
17884
|
+
"data-wgt-scope": id,
|
|
17885
|
+
style: { display: "contents" },
|
|
17886
|
+
children: [/* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: useMemo(() => scopedThemeCss(deriveWidgetTheme(color, type), `[data-wgt-scope="${id}"]`, WIDGET_GEN_TOKENS), [
|
|
17887
|
+
color,
|
|
17888
|
+
type,
|
|
17889
|
+
id
|
|
17890
|
+
]) } }), children]
|
|
17891
|
+
});
|
|
17892
|
+
}
|
|
17893
|
+
//#endregion
|
|
17130
17894
|
//#region ../widget-bridge/dist/page-context.js
|
|
17131
17895
|
function clampId(value, max) {
|
|
17132
17896
|
if (typeof value !== "string") return void 0;
|
|
@@ -17755,7 +18519,8 @@ var TurnOrderClock = class {
|
|
|
17755
18519
|
* Inheritance is disabled outright on a render where the list SHRANK:
|
|
17756
18520
|
* appends and revisions never shrink it and the cap trim keeps the length
|
|
17757
18521
|
* constant, so a shorter list means rows were dropped (`start()`'s reset to
|
|
17758
|
-
* `[]` for a new call,
|
|
18522
|
+
* `[]` for a new call, a retracted live caller caption, or any future
|
|
18523
|
+
* producer change) — and a dropped
|
|
17759
18524
|
* line's stamp must never be donated to a newcomer that merely stands where
|
|
17760
18525
|
* it stood. Surviving identical rows still keep their stamps; everything
|
|
17761
18526
|
* else restamps fresh, i.e. the new call's lines sort after everything
|
|
@@ -17799,93 +18564,6 @@ var TurnOrderClock = class {
|
|
|
17799
18564
|
return stamp;
|
|
17800
18565
|
}
|
|
17801
18566
|
};
|
|
17802
|
-
/**
|
|
17803
|
-
* The turns the worker reported as cut short, from `turn.latency` frames,
|
|
17804
|
-
* added to `ids` (a fresh set when omitted) so a caller can accumulate them.
|
|
17805
|
-
*/
|
|
17806
|
-
function interruptedTurnIds(turns, ids = /* @__PURE__ */ new Set()) {
|
|
17807
|
-
for (const turn of turns) if (turn.interruptedBy !== void 0) ids.add(turn.turnId);
|
|
17808
|
-
return ids;
|
|
17809
|
-
}
|
|
17810
|
-
/**
|
|
17811
|
-
* So little that a bubble is noise: up to three words and under 24 characters.
|
|
17812
|
-
* A single "word" (a script written without spaces) must also be under
|
|
17813
|
-
* {@link NEGLIGIBLE_UNSPACED_MAX_CHARS}, or a cut-off sentence in Chinese or
|
|
17814
|
-
* Thai would count as one word.
|
|
17815
|
-
*/
|
|
17816
|
-
function isNegligibleText(raw) {
|
|
17817
|
-
const text = raw.trim();
|
|
17818
|
-
const words = text.split(/\s+/u).length;
|
|
17819
|
-
const cap = words > 1 ? 24 : 8;
|
|
17820
|
-
return words <= 3 && text.length < cap;
|
|
17821
|
-
}
|
|
17822
|
-
/**
|
|
17823
|
-
* Which settled agent lines were cut off with so little spoken that they draw
|
|
17824
|
-
* nothing. A line counts as cut off when the hook saw it truncated, or when
|
|
17825
|
-
* the worker reported its turn interrupted and it is that turn's LAST agent
|
|
17826
|
-
* line (`interruptedBy` covers the turn; earlier lines of it finished).
|
|
17827
|
-
* Fillers are never replies.
|
|
17828
|
-
*/
|
|
17829
|
-
function negligibleLineIndexes(lines, interrupted) {
|
|
17830
|
-
const hidden = /* @__PURE__ */ new Set();
|
|
17831
|
-
const seen = /* @__PURE__ */ new Set();
|
|
17832
|
-
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
17833
|
-
const line = lines[i];
|
|
17834
|
-
if (line.speaker !== "agent" || !line.final || line.filler) continue;
|
|
17835
|
-
const last = !seen.has(line.turnId);
|
|
17836
|
-
seen.add(line.turnId);
|
|
17837
|
-
if ((line.truncated || last && interrupted.has(line.turnId)) && isNegligibleText(line.text)) hidden.add(i);
|
|
17838
|
-
}
|
|
17839
|
-
return hidden;
|
|
17840
|
-
}
|
|
17841
|
-
/**
|
|
17842
|
-
* Which typed turns are the server's copy of a line the call is drawing live.
|
|
17843
|
-
*
|
|
17844
|
-
* Only turns the poll delivered (they carry `seq`) can be copies; a turn the
|
|
17845
|
-
* shopper typed is never hidden. A copy reaches the screen AFTER the line it
|
|
17846
|
-
* copies (the server stores a line once it is spoken, and the poll fetches it
|
|
17847
|
-
* later), so a live line only absorbs a copy stamped after it. That keeps a new
|
|
17848
|
-
* call's greeting from hiding the previous call's identical one. Each live line
|
|
17849
|
-
* absorbs at most one copy, so a caller who said "yes" twice keeps both answers
|
|
17850
|
-
* if the poll only has one of them.
|
|
17851
|
-
*
|
|
17852
|
-
* When a new call starts, `useVoiceSession` clears its transcript, the live
|
|
17853
|
-
* lines are gone, and the server's copies draw instead. That is how the
|
|
17854
|
-
* previous call stays on screen.
|
|
17855
|
-
*
|
|
17856
|
-
* @param typedStamps, spokenStamps `TurnOrderClock` stamps, index for index
|
|
17857
|
-
*/
|
|
17858
|
-
function echoedTurnIndexes(typed, typedStamps, spoken, spokenStamps) {
|
|
17859
|
-
const key = (line) => `${line.speaker}\u0000${line.text.trim().replace(/\s+/gu, " ")}`;
|
|
17860
|
-
const live = [];
|
|
17861
|
-
spoken.forEach((line, i) => {
|
|
17862
|
-
if (line.final) live.push([key(line), spokenStamps[i]]);
|
|
17863
|
-
});
|
|
17864
|
-
const echoed = /* @__PURE__ */ new Set();
|
|
17865
|
-
typed.forEach((turn, i) => {
|
|
17866
|
-
if (turn.seq === void 0 || turn.speaker === "event") return;
|
|
17867
|
-
const k = key(turn);
|
|
17868
|
-
const at = live.findIndex(([lk, stamp]) => lk === k && stamp < typedStamps[i]);
|
|
17869
|
-
if (at < 0) return;
|
|
17870
|
-
live.splice(at, 1);
|
|
17871
|
-
echoed.add(i);
|
|
17872
|
-
});
|
|
17873
|
-
return echoed;
|
|
17874
|
-
}
|
|
17875
|
-
/**
|
|
17876
|
-
* Where the "Call started" divider goes: just before the call's first line,
|
|
17877
|
-
* when something is already on screen above it. `null` means no divider.
|
|
17878
|
-
*
|
|
17879
|
-
* Stamps are integers from `TurnOrderClock`, so half a step before the first
|
|
17880
|
-
* line sorts the divider between it and the row above it.
|
|
17881
|
-
*
|
|
17882
|
-
* @param spoken this call's rows, @param others every other row on screen
|
|
17883
|
-
*/
|
|
17884
|
-
function callStartStamp(spoken, others) {
|
|
17885
|
-
if (spoken.length === 0) return null;
|
|
17886
|
-
const first = Math.min(...spoken.map((row) => row.stamp));
|
|
17887
|
-
return others.some((row) => row.stamp < first) ? first - .5 : null;
|
|
17888
|
-
}
|
|
17889
18567
|
//#endregion
|
|
17890
18568
|
//#region src/host-widget.tsx
|
|
17891
18569
|
/**
|
|
@@ -18267,10 +18945,28 @@ function deriveCallPhase(voice) {
|
|
|
18267
18945
|
* when the caller did not. See `renderers.ts` for why they are two functions.
|
|
18268
18946
|
*/
|
|
18269
18947
|
function ConciergeWidget({ renderer, ...props }) {
|
|
18270
|
-
|
|
18948
|
+
const host = /* @__PURE__ */ jsx(ConciergeHost, {
|
|
18271
18949
|
...props,
|
|
18272
18950
|
renderer: renderer ?? rendererFor(props.generation)
|
|
18273
18951
|
});
|
|
18952
|
+
const brand = useMemo(() => brandColor(props.brandPrimary), [props.brandPrimary]);
|
|
18953
|
+
return props.generation === "widget" ? /* @__PURE__ */ jsx(WidgetThemeScope, {
|
|
18954
|
+
color: props.color ?? brand,
|
|
18955
|
+
type: props.type,
|
|
18956
|
+
children: host
|
|
18957
|
+
}) : host;
|
|
18958
|
+
}
|
|
18959
|
+
function brandColor(primary) {
|
|
18960
|
+
if (primary === void 0) return void 0;
|
|
18961
|
+
try {
|
|
18962
|
+
parseHex(primary);
|
|
18963
|
+
} catch {
|
|
18964
|
+
return;
|
|
18965
|
+
}
|
|
18966
|
+
return {
|
|
18967
|
+
primary,
|
|
18968
|
+
tone: "light"
|
|
18969
|
+
};
|
|
18274
18970
|
}
|
|
18275
18971
|
function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bridge, siteProfile, collector, messages = defaultWidgetMessages, locale = "en", productHref, hostRoutes, curationHref, brandPrimary, brandSecondary, brandAccent, avatar, attribution, privacyChoices, color, type, identity, layout, copy, bottomOffset, showPrice, cardImageAspect, starters, voiceAvailable, direction, proactive, initialDraft, initialSelection, initialFocus, initialMinimised, insets, hold, audio, onReady, cartLineIds }) {
|
|
18276
18972
|
/**
|
|
@@ -19011,8 +19707,10 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19011
19707
|
if (!inCallRef.current) await waitForTypedTurnToLand();
|
|
19012
19708
|
if (!actLiveRef.current || typeof window === "undefined") return;
|
|
19013
19709
|
try {
|
|
19014
|
-
const { fillHostForm } = await import("./form-fill-dom-
|
|
19015
|
-
if (actLiveRef.current)
|
|
19710
|
+
const { fillHostForm } = await import("./form-fill-dom-Dxt-z0H0.js");
|
|
19711
|
+
if (!actLiveRef.current) return;
|
|
19712
|
+
const report = fillHostForm(window.document, event);
|
|
19713
|
+
if (!inCallRef.current) session.sendReport(report, { quietOnHttpError: true }).catch(() => void 0);
|
|
19016
19714
|
} catch {}
|
|
19017
19715
|
return;
|
|
19018
19716
|
}
|
|
@@ -19566,7 +20264,9 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19566
20264
|
}]);
|
|
19567
20265
|
const lastIndexBySpeaker = /* @__PURE__ */ new Map();
|
|
19568
20266
|
lines.forEach((l, i) => lastIndexBySpeaker.set(l.speaker, i));
|
|
19569
|
-
const
|
|
20267
|
+
const cut = cutLineIndexes(lines, interruptedRef.current);
|
|
20268
|
+
const negligible = negligibleLineIndexes(lines, cut);
|
|
20269
|
+
const tagged = taggedCutIndexes(lines, cut, interruptedRef.current);
|
|
19570
20270
|
const visible = lines.map((line, i) => ({
|
|
19571
20271
|
line,
|
|
19572
20272
|
i
|
|
@@ -19679,6 +20379,7 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19679
20379
|
locale: line.locale,
|
|
19680
20380
|
final: line.final,
|
|
19681
20381
|
...line.filler ? { filler: true } : {},
|
|
20382
|
+
...tagged.has(i) ? { cut: true } : {},
|
|
19682
20383
|
...bound === void 0 ? {} : { cards: {
|
|
19683
20384
|
...bound.curationId !== void 0 ? { curationId: bound.curationId } : {},
|
|
19684
20385
|
items: bound.items
|
|
@@ -20079,6 +20780,7 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
20079
20780
|
* and §4.2's handover payload, both of which this component only forwards.
|
|
20080
20781
|
* See `VoiceWidgetProps.dock` for why the split runs here.
|
|
20081
20782
|
*/
|
|
20783
|
+
const partialTranscript = inCall ? liveCallerCaption(voice.transcript) : void 0;
|
|
20082
20784
|
const dockProps = {
|
|
20083
20785
|
identity: {
|
|
20084
20786
|
name: identity?.name ?? "",
|
|
@@ -20096,6 +20798,7 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
20096
20798
|
...direction !== void 0 ? { direction } : {},
|
|
20097
20799
|
...proactive !== void 0 ? { proactive } : {},
|
|
20098
20800
|
channel: inCall ? "voice" : "text",
|
|
20801
|
+
...partialTranscript !== void 0 ? { partialTranscript } : {},
|
|
20099
20802
|
reconnecting: session.resuming || voiceEnabled && voice.phase === "disconnected",
|
|
20100
20803
|
roomDropped: voiceEnabled && voice.phase === "disconnected",
|
|
20101
20804
|
...latestCuration ? { shelf: latestCuration } : {},
|
|
@@ -20120,7 +20823,8 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
20120
20823
|
onToggleMic,
|
|
20121
20824
|
...voiceEnabled ? {
|
|
20122
20825
|
onEndCall: () => void voice.stop(),
|
|
20123
|
-
callPhase
|
|
20826
|
+
callPhase,
|
|
20827
|
+
call: voice
|
|
20124
20828
|
} : {},
|
|
20125
20829
|
onSendText,
|
|
20126
20830
|
escalated,
|
|
@@ -20148,4 +20852,4 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
20148
20852
|
});
|
|
20149
20853
|
}
|
|
20150
20854
|
//#endregion
|
|
20151
|
-
export {
|
|
20855
|
+
export { botStateFor as $, rowWidthLen as $t, DockRenderer as A, resolveWidgetMessages as An, MOBILE_MARGIN as At, ConciergeLauncher as B, RopeKnot as Bn, SHEET_TOP_CLEARANCE as Bt, VoiceWidgetWithRenderer as C, parseHex as Cn, DOCK_MINIMISED_STORAGE_KEY as Ct, WidgetCartSummary as D, withAlpha as Dn, FLOAT_GAP as Dt, readsAsCheckoutIntent as E, srgbToLinear as En, FLOAT_DUCK_DISMISS_MS as Et, IDLE_CALL_RECORD as F, WIDGET_AVATARS as Fn, ROW_H as Ft, nearestPosition as G, containerAnchor as Gt, DEFAULT_CONCIERGE_POSITION as H, labelProps as Hn, SHORT_VIEWPORT as Ht, WidgetMarkdown as I, WIDGET_IDENTITY_AVATARS as In, SHEET_EXPANDED_DESKTOP_MAX as It, positionForArrow as J, persistMinimised as Jt, panelClasses as K, geometryVars as Kt, parseBlocks as L, dockAvatarFor as Ln, SHEET_EXPANDED_VH as Lt, deriveWidgetView as M, MorphingLoader as Mn, PILL_MARK as Mt, ConciergeShell as N, DEFAULT_WIDGET_AVATAR as Nn, PROACTIVE_NUDGE_MS as Nt, WidgetCardList as O, defaultWidgetMessages as On, GLASS_IDLE_MS as Ot, CallView as P, MARK_VARIANTS as Pn, RADII$1 as Pt, IDLE_SNAPSHOT as Q, readStoredMinimised as Qt, stripBidiControls as R, isWidgetAvatar as Rn, SHEET_GAP as Rt, VoiceWidget as S, oklchToOklab as Sn, DOCK_ALIGN_STORAGE_KEY as St, readsAsCartViewIntent as T, rotateHue as Tn, DRAG_TAP_SLOP_PX as Tt, alignOf as U, cn as Un, Z_INDEX as Ut, CONCIERGE_POSITIONS as V, BotFace as Vn, SHEET_TUCK as Vt, edgeOf as W, bottomLen as Wt, MARK_STATES as X, readStored as Xt, LAUNCHER_VARIANTS as Y, pillAnchor as Yt, Mark as Z, readStoredAlign as Zt, useVoiceSession as _, mixToward as _n, CONTROL as _t, MAX_REPORTED_CART_LINES as a, SYSTEM_FONT_STACK as an, Dock as at, useChatSession as b, oklabToOklch as bn, DESKTOP_GUTTER as bt, deriveCallPhase as c, themeToCss as cn, deriveDockView as ct, resolveCheckoutUrl as d, contrastRatio as dn, deriveConciergeState as dt, sheetMaxHeightLen as en, SseFrameParser as et, toChatCart as f, formatHex as fn, idleConciergeInput as ft, createWidgetVoiceTokenFetcher as g, linearToSrgb as gn, BOTTOM_FLOOR as gt, ROOM_EVENTS as h, linearRgbToOklab as hn, ACTIVITY_W as ht, ConciergeWidget as i, SHEET_RADIUS_MAX_PX as in, latencyBetween as it, ShellRenderer as j, widgetMessagesFromCopy as jn, PILL_H as jt, rendererFor as k, formatMessage as kn, MARK as kt, mergeAddedCartLine as l, themeToInlineStyle as ln, idleDockInput as lt, deriveWidgetTheme as m, hexToOklch as mn, WIDGET_MESSAGE_MAX_LENGTH as mt, CART_LINE_VARIANT_ID_SHAPE as n, writeStored as nn, SessionLog as nt, cartLinesFromSnapshot as o, WIDGET_THEME_TOKENS as on, DOCK_STATES as ot, WidgetThemeScope as p, hexToOklab as pn, formatMoney as pt, positionClasses as q, persistAlign as qt, ConciergeHost as r, CARD_RADIUS_MAX_PX as rn, formatMs as rt, chooseOptionsAction as s, deriveTheme as sn, deriveDockState as st, CART_LINE_PLATFORM_VARIANT_ID_SHAPE as t, snapAlign as tn, SESSION_EVENTS as tt, resolveAddToCartHandler as u, themeToMarkedHostCss as un, CONCIERGE_STATES as ut, CHECKOUT_CAPTURE_REQUIRED as v, oklabToHex as vn, DESKTOP_BOTTOM as vt, basketIntentFromTurns as w, relativeLuminance as wn, DRAG_CLICK_WINDOW_MS as wt, detectPage as x, oklchToHex as xn, DESKTOP_WIDTHS as xt, isSameOriginPath as y, oklabToLinearRgb as yn, DESKTOP_BREAKPOINT as yt, textDirectionFor as z, KNOT_PATH as zn, SHEET_PEEK_MAX as zt };
|